package com.kingdee.eas.custom.xzkingdeemz;
import java.math.BigDecimal;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Random;
import net.sf.json.JSONArray;
import org.apache.derby.tools.sysinfo;
import org.apache.log4j.Logger;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.kingdee.bos.BOSException;
import com.kingdee.bos.Context;
import com.kingdee.bos.dao.IObjectPK;
import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
import com.kingdee.bos.dao.query.SQLExecutorFactory;
import com.kingdee.bos.metadata.entity.EntityViewInfo;
import com.kingdee.bos.metadata.entity.FilterInfo;
import com.kingdee.bos.metadata.entity.FilterItemInfo;
import com.kingdee.bos.metadata.query.util.CompareType;
import com.kingdee.bos.util.BOSUuid;
import com.kingdee.eas.base.permission.UserFacadeFactory;
import com.kingdee.eas.base.permission.UserFactory;
import com.kingdee.eas.base.permission.UserInfo;
import com.kingdee.eas.basedata.assistant.CostItemFactory;
import com.kingdee.eas.basedata.assistant.KAClassficationFactory;
import com.kingdee.eas.basedata.assistant.KAClassficationInfo;
import com.kingdee.eas.basedata.assistant.MeasureUnitInfo;
import com.kingdee.eas.basedata.framework.DataBaseDAssignFactory;
import com.kingdee.eas.basedata.framework.DataBaseDAssignInfo;
import com.kingdee.eas.basedata.framework.DataStateEnum;
import com.kingdee.eas.basedata.master.material.AccountType;
import com.kingdee.eas.basedata.master.material.CalculateTypeEnum;
import com.kingdee.eas.basedata.master.material.IMaterial;
import com.kingdee.eas.basedata.master.material.MaterialCollection;
import com.kingdee.eas.basedata.master.material.MaterialCompanyInfo;
import com.kingdee.eas.basedata.master.material.MaterialCompanyInfoCollection;
import com.kingdee.eas.basedata.master.material.MaterialCompanyInfoFactory;
import com.kingdee.eas.basedata.master.material.MaterialCompanyInfoInfo;
import com.kingdee.eas.basedata.master.material.MaterialCostCollection;
import com.kingdee.eas.basedata.master.material.MaterialCostFactory;
import com.kingdee.eas.basedata.master.material.MaterialCostInfo;
import com.kingdee.eas.basedata.master.material.MaterialFactory;
import com.kingdee.eas.basedata.master.material.MaterialGroupDetialInfo;
import com.kingdee.eas.basedata.master.material.MaterialGroupInfo;
import com.kingdee.eas.basedata.master.material.MaterialInfo;
import com.kingdee.eas.basedata.master.material.MaterialInventoryCollection;
import com.kingdee.eas.basedata.master.material.MaterialInventoryFactory;
import com.kingdee.eas.basedata.master.material.MaterialInventoryInfo;
import com.kingdee.eas.basedata.master.material.MaterialPurchasingCollection;
import com.kingdee.eas.basedata.master.material.MaterialPurchasingFactory;
import com.kingdee.eas.basedata.master.material.MaterialPurchasingInfo;
import com.kingdee.eas.basedata.master.material.MaterialSalesCollection;
import com.kingdee.eas.basedata.master.material.MaterialSalesFactory;
import com.kingdee.eas.basedata.master.material.MaterialSalesInfo;
import com.kingdee.eas.basedata.master.material.TimeUnitEnum;
import com.kingdee.eas.basedata.master.material.UsedStatusEnum;
import com.kingdee.eas.basedata.master.material.app.MaterialControllerBean;
import com.kingdee.eas.basedata.ncm.ExpenseFactory;
import com.kingdee.eas.basedata.org.CompanyOrgUnit;
import com.kingdee.eas.basedata.org.CompanyOrgUnitFactory;
import com.kingdee.eas.basedata.org.CompanyOrgUnitInfo;
import com.kingdee.eas.basedata.org.CtrlUnitFactory;
import com.kingdee.eas.basedata.org.CtrlUnitInfo;
import com.kingdee.eas.basedata.org.FullOrgUnitFactory;
import com.kingdee.eas.basedata.org.FullOrgUnitInfo;
import com.kingdee.eas.basedata.org.QualityOrgUnitFactory;
import com.kingdee.eas.basedata.org.StorageOrgUnitFactory;
import com.kingdee.eas.basedata.org.StorageOrgUnitInfo;
import com.kingdee.eas.basedata.person.PersonFactory;
import com.kingdee.eas.basedata.person.PersonInfo;
import com.kingdee.eas.basedata.scm.common.util.DataImportUtils;
import com.kingdee.eas.basedata.scm.im.inv.MaterialStorageAssignFactory;
import com.kingdee.eas.basedata.scm.im.inv.MaterialStorageAssignInfo;
import com.kingdee.eas.basedata.scm.im.inv.MaterialStorageAssignTypeEnum;
import com.kingdee.eas.common.EASBizException;
import com.kingdee.eas.common.RefChkFilter;
import com.kingdee.eas.common.RefChkFilterItemEnum;
import com.kingdee.eas.common.RefChkFilterSet;
import com.kingdee.eas.common.app.dao.ReferenceDAO;
import com.kingdee.eas.cp.mail.UserInfoFactory;
import com.kingdee.eas.csinterface.syncdatabase.SQLFacadeFactory;
import com.kingdee.eas.custom.wb.basedata.DrugFormalFactory;
import com.kingdee.eas.util.BizReference;
import com.kingdee.eas.util.app.ContextUtil;
import com.kingdee.eas.util.app.DbUtil;
import com.kingdee.jdbc.rowset.IRowSet;
import com.kingdee.portal.common.util.StringUtil;
import com.kingdee.util.StringUtils;
public class BaseInfoFacadeControllerBean extends
AbstractBaseInfoFacadeControllerBean {
private static Logger logger = Logger
.getLogger("com.kingdee.eas.custom.xzkingdeemz.BaseInfoFacadeControllerBean");
/**
* 获取预算项目222
*/
@Override
protected String _getBudgetItems(Context ctx, String json)
throws BOSException, EASBizException {
// 云之家参数解析:
JSONObject yunjsonObj = JSONObject.parseObject(json);
String keyword = yunjsonObj.getString("keyword");// 搜索关键字
Integer pageNumber = Integer.parseInt(yunjsonObj.getString("curPage"));// 当前页码
StringBuffer sqlcanshuo = new StringBuffer();
if ("".equals(keyword)) {
sqlcanshuo.append(" where 1=1 ");
;
} else {
sqlcanshuo.append(" where FNAME_L2 like '%" + keyword + "%' ");
;
}
JSONObject jsonObject = new JSONObject();// 最外层json对象
JSONObject pageList = new JSONObject();
// 列名
JSONArray colList = new JSONArray();// id
JSONObject fidColL = new JSONObject();
fidColL.put("colEnName", "id");
JSONObject nameColL = new JSONObject();
nameColL.put("showName", "true");
nameColL.put("colZhName", "项目名称");
nameColL.put("widgetType", "textWidget");
nameColL.put("colEnName", "name");
JSONObject priceColL = new JSONObject();
priceColL.put("colZhName", "预算金额调整前");
priceColL.put("widgetType", "moneyWidget");
priceColL.put("colEnName", "number");
priceColL.put("colZhName", "实际发生额");
priceColL.put("widgetType", "moneyWidget");
priceColL.put("colEnName", "number");
colList.add(fidColL);
colList.add(nameColL);
colList.add(priceColL);
StringBuffer sql = new StringBuffer(
" select count(1) count from T_BD_Customer ");
sql.append(sqlcanshuo);
// 查询总记录数
IRowSet rowcount = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sql.toString());
Integer totalRecouds = 0;
try {
while (rowcount.next()) {
totalRecouds = rowcount.getInt("count");
}
} catch (SQLException e1) {
e1.printStackTrace();
}
Integer pageSize = 7; // 每页显示多少条数据
// totalPages 总页数
Integer totalPages = totalRecouds % pageSize == 0 ? totalRecouds
/ pageSize : totalRecouds / pageSize + 1;
// startPage 起始位置
Integer startPage = pageSize * (pageNumber - 1) + 1;
Integer endPage = startPage + pageSize;
// sql 拼接分页
// 查询数据
StringBuffer sqlinfo = new StringBuffer(
" select rownum num ,t.* from T_BD_Customer t ");
sqlinfo.append(sqlcanshuo);
String sqlfy = " select a.* from ( " + sqlinfo
+ " ) a where a.num>='" + startPage + "' and a.num<'"
+ endPage + "' ";
IRowSet rowSet = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sqlfy.toString());
net.sf.json.JSONArray dataList = new net.sf.json.JSONArray();
String Id = "";
String FNAME_L2 = "";
String number = "";
try {
while (rowSet.next()) {
Id = rowSet.getString("FID");
FNAME_L2 = rowSet.getString("FNAME_L2");
number = rowSet.getString("FNumber");
JSONObject jsonObj = new JSONObject();
jsonObj.put("id", Id);
jsonObj.put("name", FNAME_L2);
jsonObj.put("number", number);
dataList.add(jsonObj);
}
} catch (SQLException e) {
e.printStackTrace();
}
/*
* JSONArray defaultValue = new JSONArray();//默认值 JSONObject
* defaultjsonObj = new JSONObject(); defaultjsonObj.put("id", "001");
* defaultjsonObj.put("name", "洋河大曲"); defaultjsonObj.put("price",
* "10"); defaultValue.add(defaultjsonObj);
*/
pageList.put("pageCount", totalPages);
pageList.put("curPage", pageNumber);
pageList.put("rowsCount", totalRecouds);
pageList.put("colList", colList);
pageList.put("dataList", dataList);
// pageList.put("defaultValue", defaultValue);
jsonObject.put("pageList", pageList);
jsonObject.put("error", "null");
jsonObject.put("errorCode", 0);
jsonObject.put("success", true);
return jsonObject.toString();
}
/**
* 获取客户
*/
@Override
protected String _getCustomers(Context ctx, String json)
throws BOSException, EASBizException {
// 云之家参数解析:
JSONObject yunjsonObj = JSONObject.parseObject(json);
String keyword = yunjsonObj.getString("keyword");// 搜索关键字
Integer pageNumber = Integer.parseInt(yunjsonObj.getString("curPage"));// 当前页码
StringBuffer sqlcanshuo = new StringBuffer();
if ("".equals(keyword)) {
sqlcanshuo.append(" where 1=1 ");
;
} else {
sqlcanshuo.append(" where FNAME_L2 like '%" + keyword + "%' ");
;
}
JSONObject jsonObject = new JSONObject();// 最外层json对象
JSONObject pageList = new JSONObject();
// 列名
JSONArray colList = new JSONArray();// id
JSONObject fidColL = new JSONObject();
fidColL.put("colEnName", "id");
JSONObject nameColL = new JSONObject();
nameColL.put("showName", "true");
nameColL.put("colZhName", "客户名称");
nameColL.put("widgetType", "textWidget");
nameColL.put("colEnName", "name");
JSONObject priceColL = new JSONObject();
priceColL.put("colZhName", "客户编码");
priceColL.put("widgetType", "textWidget");
priceColL.put("colEnName", "number");
/*
* JSONObject bankAccountColL = new JSONObject();
* bankAccountColL.put("colZhName", "银行账户");
* bankAccountColL.put("widgetType", "textWidget");
* bankAccountColL.put("colEnName", "bankAccount");
*
* JSONObject bankColL = new JSONObject(); bankColL.put("colZhName",
* "开户行"); bankColL.put("widgetType", "textWidget");
* bankColL.put("colEnName", "bank");
*/
colList.add(fidColL);
colList.add(nameColL);
colList.add(priceColL);
// colList.add(bankAccountColL);
// colList.add(bankColL);
String sqlfirst = " SELECT distinct customer.fid, customer.FNUMBER, customer.FNAME_L2 FROM T_BD_Customer customer where FUsedStatus=1 order by customer.FNAME_L2 desc ";
StringBuffer sql = new StringBuffer(
" select count(1) count from ( " + sqlfirst + " ) ");
sql.append(sqlcanshuo);
// 查询总记录数
IRowSet rowcount = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sql.toString());
Integer totalRecouds = 0;
try {
while (rowcount.next()) {
totalRecouds = rowcount.getInt("count");
}
} catch (SQLException e1) {
e1.printStackTrace();
}
Integer pageSize = 7; // 每页显示多少条数据
// totalPages 总页数
Integer totalPages = totalRecouds % pageSize == 0 ? totalRecouds
/ pageSize : totalRecouds / pageSize + 1;
// startPage 起始位置
Integer startPage = pageSize * (pageNumber - 1) + 1;
Integer endPage = startPage + pageSize;
// sql 拼接分页
// 查询数据
StringBuffer sqlinfo = new StringBuffer(
" select rownum num ,t.* from ( " + sqlfirst
+ " ) t ");
sqlinfo.append(sqlcanshuo);
String sqlfy = " select a.* from ( " + sqlinfo
+ " ) a where a.num>='" + startPage + "' and a.num<'"
+ endPage + "' ";
System.out.println("客户sql" + sqlfy);
IRowSet rowSet = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sqlfy.toString());
net.sf.json.JSONArray dataList = new net.sf.json.JSONArray();
String Id = "";
String FNAME_L2 = "";
String number = "";
String bankAccount = "";
String bank = "";
try {
while (rowSet.next()) {
Id = rowSet.getString("FID");
FNAME_L2 = rowSet.getString("FNAME_L2");
number = rowSet.getString("FNumber");
// bank =
// rowSet.getString("FBANK")==null?"":rowSet.getString("FBANK");
// bankAccount =
// rowSet.getString("FBANKACCOUNT")==null?"":rowSet
// .getString("FBANKACCOUNT");
JSONObject jsonObj = new JSONObject();
Random random = new Random();
jsonObj.put("id", random.toString() + bankAccount); // 这里以Random随机数银行账号充当id
jsonObj.put("name", FNAME_L2);
jsonObj.put("number", number);
// jsonObj.put("bankAccount", bankAccount);
// jsonObj.put("bank", bank);
dataList.add(jsonObj);
}
} catch (SQLException e) {
e.printStackTrace();
}
pageList.put("pageCount", totalPages);
pageList.put("curPage", pageNumber);
pageList.put("rowsCount", totalRecouds);
pageList.put("colList", colList);
pageList.put("dataList", dataList);
// pageList.put("defaultValue", defaultValue);
jsonObject.put("pageList", pageList);
jsonObject.put("error", "null");
jsonObject.put("errorCode", 0);
jsonObject.put("success", true);
return jsonObject.toString();
}
/**
* 获取固定资产
*/
@Override
protected String _getFixedassets(Context ctx, String json)
throws BOSException, EASBizException {
// 云之家参数解析:
JSONObject yunjsonObj = JSONObject.parseObject(json);
String keyword = yunjsonObj.getString("keyword");// 搜索关键字
Integer pageNumber = Integer.parseInt(yunjsonObj.getString("curPage"));// 当前页码
StringBuffer sqlcanshuo = new StringBuffer();
if ("".equals(keyword)) {
sqlcanshuo.append(" where 1=1 ");
;
} else {
sqlcanshuo.append(" where FNAME_L2 like '%" + keyword + "%' ");
;
}
JSONObject jsonObject = new JSONObject();// 最外层json对象
JSONObject pageList = new JSONObject();
//列名
JSONArray colList = new JSONArray();// id
JSONObject fidColL = new JSONObject();
fidColL.put("colEnName", "id");
JSONObject numberColL = new JSONObject();
numberColL.put("showName", "true");
numberColL.put("colZhName", "资产编码");
numberColL.put("widgetType", "textWidget");
numberColL.put("colEnName", "number");
JSONObject nameColL = new JSONObject();
nameColL.put("colZhName", "设备名称");
nameColL.put("widgetType", "textWidget");
nameColL.put("colEnName", "name");
JSONObject syColL = new JSONObject();
syColL.put("colZhName", "使用年限");
syColL.put("widgetType", "textWidget");
syColL.put("colEnName", "useYears");
JSONObject yaunzhiColL = new JSONObject();
yaunzhiColL.put("colZhName", "原值");
yaunzhiColL.put("widgetType", "moneyWidget");
yaunzhiColL.put("colEnName", "assetValue");
JSONObject gexhColL = new JSONObject();
gexhColL.put("colZhName", "规格型号");
gexhColL.put("widgetType", "textWidget");
gexhColL.put("colEnName", "specs");
JSONObject accuDeprColL = new JSONObject();
accuDeprColL.put("colZhName", "已提折旧");
accuDeprColL.put("widgetType", "moneyWidget");
accuDeprColL.put("colEnName", "accuDepr");
JSONObject faCurDepartmentColL = new JSONObject();
faCurDepartmentColL.put("colZhName", "使用部门");
faCurDepartmentColL.put("widgetType", "textWidget");
faCurDepartmentColL.put("colEnName", "faCurDepartment");
JSONObject neatValueColL = new JSONObject();
neatValueColL.put("colZhName", "净值");
neatValueColL.put("widgetType", "moneyWidget");
neatValueColL.put("colEnName", "neatValue");
colList.add(fidColL);
colList.add(nameColL);
colList.add(numberColL);
colList.add(yaunzhiColL);
colList.add(gexhColL);
colList.add(accuDeprColL);
colList.add(neatValueColL);
StringBuffer sql = new StringBuffer(
" select count(1) count from T_FA_FaCurCard ");
sql.append(sqlcanshuo);
// 查询总记录数
IRowSet rowcount = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sql.toString());
Integer totalRecouds = 0;
try {
while (rowcount.next()) {
totalRecouds = rowcount.getInt("count");
}
} catch (SQLException e1) {
e1.printStackTrace();
}
Integer pageSize = 7; // 每页显示多少条数据
// totalPages 总页数
Integer totalPages = totalRecouds % pageSize == 0 ? totalRecouds
/ pageSize : totalRecouds / pageSize + 1;
// startPage 起始位置
Integer startPage = pageSize * (pageNumber - 1) + 1;
Integer endPage = startPage + pageSize;
// sql 拼接分页
// 查询数据
StringBuffer sqlinfo = new StringBuffer(
" select rownum num ,t.* from T_FA_FaCurCard t ");
sqlinfo.append(sqlcanshuo);
String sqlfy = " select a.* from ( " + sqlinfo
+ " ) a where a.num>='" + startPage + "' and a.num<'"
+ endPage + "' ";
IRowSet rowSet = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sqlfy.toString());
net.sf.json.JSONArray dataList = new net.sf.json.JSONArray();
String Id = "";
String FNAME_L2 = "";
String number = "";
String useYears = "";
String assetValue = "";
String specs = "";
String accuDepr = "";
String faCurDepartmentId = "";
String faCurDepartmentName = "";
String neatValue = "";
try {
while (rowSet.next()) {
Id = rowSet.getString("FID");
FNAME_L2 = rowSet.getString("FNAME_L2");
number = rowSet.getString("FNumber");
useYears = rowSet.getString("FuseYears");// 使用年限
assetValue = rowSet.getString("FassetValue");// 原值
specs = rowSet.getString("Fspecs");// 规格
accuDepr = rowSet.getString("FaccuDepr");// 已提折旧
faCurDepartmentId = rowSet.getString("FfaCurDepartment");// 使用部门id
IRowSet rowset2 = SQLFacadeFactory.getLocalInstance(ctx)
.getRowset(
" select FNAME_L2 from T_FA_FaCurDepartment where fid='"
+ faCurDepartmentId + "' ");
while (rowset2.next()) {
faCurDepartmentName = rowset2.getString("FNAME_L2");// 使用部门
}
neatValue = rowSet.getString("FneatValue");// 残值
number = rowSet.getString("FNumber");
JSONObject jsonObj = new JSONObject();
jsonObj.put("id", Id);
jsonObj.put("name", FNAME_L2);
jsonObj.put("number", number);
jsonObj.put("useYears", useYears);
jsonObj.put("assetValue", assetValue);
jsonObj.put("specs", specs);
jsonObj.put("accuDepr", accuDepr);
jsonObj.put("faCurDepartment", faCurDepartmentName);
jsonObj.put("neatValue", neatValue);
dataList.add(jsonObj);
}
} catch (SQLException e) {
e.printStackTrace();
}
/*
* JSONArray defaultValue = new JSONArray();//默认值 JSONObject
* defaultjsonObj = new JSONObject(); defaultjsonObj.put("id", "001");
* defaultjsonObj.put("name", "洋河大曲"); defaultjsonObj.put("price",
* "10"); defaultValue.add(defaultjsonObj);
*/
pageList.put("pageCount", totalPages);
pageList.put("curPage", pageNumber);
pageList.put("rowsCount", totalRecouds);
pageList.put("colList", colList);
pageList.put("dataList", dataList);
// pageList.put("defaultValue", defaultValue);
jsonObject.put("pageList", pageList);
jsonObject.put("error", "null");
jsonObject.put("errorCode", 0);
jsonObject.put("success", true);
return jsonObject.toString();
}
/**
*
获取医院等级
*/
@Override
protected String _getHospitalLevels(Context ctx, String json)
throws BOSException, EASBizException {
// 云之家参数解析:
JSONObject yunjsonObj = JSONObject.parseObject(json);
String keyword = yunjsonObj.getString("keyword");// 搜索关键字
Integer pageNumber = Integer.parseInt(yunjsonObj.getString("curPage"));// 当前页码
StringBuffer sqlcanshuo = new StringBuffer();
if ("".equals(keyword)) {
sqlcanshuo.append(" where 1=1 ");
;
} else {
sqlcanshuo.append(" where FNAME_L2 like '%" + keyword + "%' ");
;
}
JSONObject jsonObject = new JSONObject();// 最外层json对象
JSONObject pageList = new JSONObject();
// 列名
JSONArray colList = new JSONArray();// id
JSONObject fidColL = new JSONObject();
fidColL.put("colEnName", "id");
JSONObject nameColL = new JSONObject();
nameColL.put("showName", "true");
nameColL.put("colZhName", "医院级别名称");
nameColL.put("widgetType", "textWidget");
nameColL.put("colEnName", "name");
JSONObject priceColL = new JSONObject();
priceColL.put("colZhName", "医院级别编码");
priceColL.put("widgetType", "textWidget");
priceColL.put("colEnName", "number");
colList.add(fidColL);
colList.add(nameColL);
colList.add(priceColL);
StringBuffer sql = new StringBuffer(
" select count(1) count from CT_BAS_HospitalLevel ");
sql.append(sqlcanshuo);
// 查询总记录数
IRowSet rowcount = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sql.toString());
Integer totalRecouds = 0;
try {
while (rowcount.next()) {
totalRecouds = rowcount.getInt("count");
}
} catch (SQLException e1) {
e1.printStackTrace();
}
Integer pageSize = 7; // 每页显示多少条数据
// totalPages 总页数
Integer totalPages = totalRecouds % pageSize == 0 ? totalRecouds
/ pageSize : totalRecouds / pageSize + 1;
// startPage 起始位置
Integer startPage = pageSize * (pageNumber - 1) + 1;
Integer endPage = startPage + pageSize;
// sql 拼接分页
// 查询数据
StringBuffer sqlinfo = new StringBuffer(
" select rownum num ,t.* from CT_BAS_HospitalLevel t ");
sqlinfo.append(sqlcanshuo);
String sqlfy = " select a.* from ( " + sqlinfo
+ " ) a where a.num>='" + startPage + "' and a.num<'"
+ endPage + "' ";
IRowSet rowSet = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sqlfy.toString());
net.sf.json.JSONArray dataList = new net.sf.json.JSONArray();
String Id = "";
String FNAME_L2 = "";
String number = "";
try {
while (rowSet.next()) {
Id = rowSet.getString("FID");
FNAME_L2 = rowSet.getString("FNAME_L2");
number = rowSet.getString("FNumber");
JSONObject jsonObj = new JSONObject();
jsonObj.put("id", Id);
jsonObj.put("name", FNAME_L2);
jsonObj.put("number", number);
dataList.add(jsonObj);
}
} catch (SQLException e) {
e.printStackTrace();
}
/*
* JSONArray defaultValue = new JSONArray();//默认值 JSONObject
* defaultjsonObj = new JSONObject(); defaultjsonObj.put("id", "001");
* defaultjsonObj.put("name", "洋河大曲"); defaultjsonObj.put("price",
* "10"); defaultValue.add(defaultjsonObj);
*/
pageList.put("pageCount", totalPages);
pageList.put("curPage", pageNumber);
pageList.put("rowsCount", totalRecouds);
pageList.put("colList", colList);
pageList.put("dataList", dataList);
// pageList.put("defaultValue", defaultValue);
jsonObject.put("pageList", pageList);
jsonObject.put("error", "null");
jsonObject.put("errorCode", 0);
jsonObject.put("success", true);
return jsonObject.toString();
}
/**
* 获取物料信息
*/
@Override
protected String _getMaterials(Context ctx, String json)
throws BOSException, EASBizException {
// 云之家参数解析:
JSONObject yunjsonObj = JSONObject.parseObject(json);
String materialType = "";
materialType = yunjsonObj.getString("materialType") == null ? ""
: yunjsonObj.getString("materialType"); // eclipse
// 传参是否过滤物料过滤50开头
String keyword = yunjsonObj.getString("keyword");// 搜索关键字
Integer pageNumber = Integer.parseInt(yunjsonObj.getString("curPage"));// 当前页码
StringBuffer sqlcanshuo = new StringBuffer();
if ("".equals(keyword)) {
sqlcanshuo.append(" where 1=1 ");
;
} else {
sqlcanshuo.append(" where FNAME_L2 like '%" + keyword + "%' ");
;
}
JSONObject jsonObject = new JSONObject();// 最外层json对象
JSONObject pageList = new JSONObject();
// 列名
JSONArray colList = new JSONArray();// id
JSONObject fidColL = new JSONObject();
fidColL.put("colEnName", "id");
JSONObject nameColL = new JSONObject();
nameColL.put("showName", "true");
nameColL.put("colZhName", "物料名称");
nameColL.put("widgetType", "textWidget");
nameColL.put("colEnName", "name");
JSONObject numberColL = new JSONObject();
numberColL.put("colZhName", "物料编码");
numberColL.put("widgetType", "textWidget");
numberColL.put("colEnName", "number");
JSONObject ggColL = new JSONObject();
ggColL.put("colZhName", "规格型号");
ggColL.put("widgetType", "textWidget");
ggColL.put("colEnName", "model");
colList.add(fidColL);
colList.add(nameColL);
colList.add(numberColL);
colList.add(ggColL);
StringBuffer sql = new StringBuffer(
" select count(1) count from T_BD_Material ");
if (materialType.equals("物料过滤50开头")) {
sql.append(" where fname_l2 like '50%' ");
}
sql.append(sqlcanshuo);
// 查询总记录数
IRowSet rowcount = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sql.toString());
Integer totalRecouds = 0;
try {
while (rowcount.next()) {
totalRecouds = rowcount.getInt("count");
}
} catch (SQLException e1) {
e1.printStackTrace();
}
Integer pageSize = 7; // 每页显示多少条数据
// totalPages 总页数
Integer totalPages = totalRecouds % pageSize == 0 ? totalRecouds
/ pageSize : totalRecouds / pageSize + 1;
// startPage 起始位置
Integer startPage = pageSize * (pageNumber - 1) + 1;
Integer endPage = startPage + pageSize;
// sql 拼接分页
// 查询数据
StringBuffer sqlinfo = new StringBuffer(
" select rownum num ,t.FID, t.FNAME_L2, t.FNumber, t.FMODEL from T_BD_Material t ");
sqlinfo.append(sqlcanshuo);
if (materialType.equals("物料过滤50开头")) {
sqlinfo.append(" and fname_l2 like '50%' ");
}
String sqlfy = " select a.* from ( " + sqlinfo
+ " ) a where a.num>='" + startPage + "' and a.num<'"
+ endPage + "' ";
IRowSet rowSet = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sqlfy.toString());
net.sf.json.JSONArray dataList = new net.sf.json.JSONArray();
String Id = "";
String FNAME_L2 = "";
String number = "";
String model = "";
try {
while (rowSet.next()) {
Id = rowSet.getString("FID");
FNAME_L2 = rowSet.getString("FNAME_L2");
number = rowSet.getString("FNumber");
model = rowSet.getString("FMODEL");
JSONObject jsonObj = new JSONObject();
jsonObj.put("id", Id);
jsonObj.put("name", FNAME_L2);
jsonObj.put("number", number);
if ("".equals(model) || null == model) {
model = "";
}
jsonObj.put("model", model);
dataList.add(jsonObj);
}
} catch (SQLException e) {
e.printStackTrace();
}
/*
* JSONArray defaultValue = new JSONArray();//默认值 JSONObject
* defaultjsonObj = new JSONObject(); defaultjsonObj.put("id", "001");
* defaultjsonObj.put("name", "洋河大曲"); defaultjsonObj.put("price",
* "10"); defaultValue.add(defaultjsonObj);
*/
pageList.put("pageCount", totalPages);
pageList.put("curPage", pageNumber);
pageList.put("rowsCount", totalRecouds);
pageList.put("colList", colList);
pageList.put("dataList", dataList);
// pageList.put("defaultValue", defaultValue);
jsonObject.put("pageList", pageList);
jsonObject.put("error", "null");
jsonObject.put("errorCode", 0);
jsonObject.put("success", true);
return jsonObject.toString();
}
/**
* 获取付款方式
*/
@Override
protected String _getPaymentTypes(Context ctx, String json)
throws BOSException, EASBizException {
// 云之家参数解析:
JSONObject yunjsonObj = JSONObject.parseObject(json);
String keyword = yunjsonObj.getString("keyword");// 搜索关键字
Integer pageNumber = Integer.parseInt(yunjsonObj.getString("curPage"));// 当前页码
StringBuffer sqlcanshuo = new StringBuffer();
if ("".equals(keyword)) {
sqlcanshuo.append(" where 1=1 ");
;
} else {
sqlcanshuo.append(" where FNAME_L2 like '%" + keyword + "%' ");
;
}
JSONObject jsonObject = new JSONObject();// 最外层json对象
JSONObject pageList = new JSONObject();
// 列名
JSONArray colList = new JSONArray();// id
JSONObject fidColL = new JSONObject();
fidColL.put("colEnName", "id");
JSONObject nameColL = new JSONObject();
nameColL.put("showName", "true");
nameColL.put("colZhName", "付款类型名称");
nameColL.put("widgetType", "textWidget");
nameColL.put("colEnName", "name");
JSONObject priceColL = new JSONObject();
priceColL.put("colZhName", "付款类型编码");
priceColL.put("widgetType", "textWidget");
priceColL.put("colEnName", "number");
colList.add(fidColL);
colList.add(nameColL);
colList.add(priceColL);
StringBuffer sql = new StringBuffer(
" select count(1) count from T_CAS_PaymentBillType ");
sql.append(sqlcanshuo);
// 查询总记录数
IRowSet rowcount = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sql.toString());
Integer totalRecouds = 0;
try {
while (rowcount.next()) {
totalRecouds = rowcount.getInt("count");
}
} catch (SQLException e1) {
e1.printStackTrace();
}
Integer pageSize = 7; // 每页显示多少条数据
// totalPages 总页数
Integer totalPages = totalRecouds % pageSize == 0 ? totalRecouds
/ pageSize : totalRecouds / pageSize + 1;
// startPage 起始位置
Integer startPage = pageSize * (pageNumber - 1) + 1;
Integer endPage = startPage + pageSize;
// sql 拼接分页
// 查询数据
StringBuffer sqlinfo = new StringBuffer(
" select rownum num ,t.* from T_CAS_PaymentBillType t ");
sqlinfo.append(sqlcanshuo);
String sqlfy = " select a.* from ( " + sqlinfo
+ " ) a where a.num>='" + startPage + "' and a.num<'"
+ endPage + "' ";
IRowSet rowSet = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sqlfy.toString());
net.sf.json.JSONArray dataList = new net.sf.json.JSONArray();
String Id = "";
String FNAME_L2 = "";
String number = "";
try {
while (rowSet.next()) {
Id = rowSet.getString("FID");
FNAME_L2 = rowSet.getString("FNAME_L2");
number = rowSet.getString("FNumber");
JSONObject jsonObj = new JSONObject();
jsonObj.put("id", Id);
jsonObj.put("name", FNAME_L2);
jsonObj.put("number", number);
dataList.add(jsonObj);
}
} catch (SQLException e) {
e.printStackTrace();
}
/*
* JSONArray defaultValue = new JSONArray();//默认值 JSONObject
* defaultjsonObj = new JSONObject(); defaultjsonObj.put("id", "001");
* defaultjsonObj.put("name", "洋河大曲"); defaultjsonObj.put("price",
* "10"); defaultValue.add(defaultjsonObj);
*/
pageList.put("pageCount", totalPages);
pageList.put("curPage", pageNumber);
pageList.put("rowsCount", totalRecouds);
pageList.put("colList", colList);
pageList.put("dataList", dataList);
// pageList.put("defaultValue", defaultValue);
jsonObject.put("pageList", pageList);
jsonObject.put("error", "null");
jsonObject.put("errorCode", 0);
jsonObject.put("success", true);
return jsonObject.toString();
}
/**
* 获取结算方式
*/
@Override
protected String _getSettlements(Context ctx, String json)
throws BOSException, EASBizException {
// 云之家参数解析:
JSONObject yunjsonObj = JSONObject.parseObject(json);
String keyword = yunjsonObj.getString("keyword");// 搜索关键字
Integer pageNumber = Integer.parseInt(yunjsonObj.getString("curPage"));// 当前页码
StringBuffer sqlcanshuo = new StringBuffer();
if ("".equals(keyword)) {
sqlcanshuo.append(" where 1=1 ");
;
} else {
sqlcanshuo.append(" where FNAME_L2 like '%" + keyword + "%' ");
;
}
JSONObject jsonObject = new JSONObject();// 最外层json对象
JSONObject pageList = new JSONObject();
// 列名
JSONArray colList = new JSONArray();// id
JSONObject fidColL = new JSONObject();
fidColL.put("colEnName", "id");
JSONObject nameColL = new JSONObject();
nameColL.put("showName", "true");
nameColL.put("colZhName", "结算方式名称");
nameColL.put("widgetType", "textWidget");
nameColL.put("colEnName", "name");
JSONObject priceColL = new JSONObject();
priceColL.put("colZhName", "结算方式编码");
priceColL.put("widgetType", "textWidget");
priceColL.put("colEnName", "number");
colList.add(fidColL);
colList.add(nameColL);
colList.add(priceColL);
StringBuffer sql = new StringBuffer(
" select count(1) count from T_BD_SettlementType ");
sql.append(sqlcanshuo);
// 查询总记录数
IRowSet rowcount = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sql.toString());
Integer totalRecouds = 0;
try {
while (rowcount.next()) {
totalRecouds = rowcount.getInt("count");
}
} catch (SQLException e1) {
e1.printStackTrace();
}
Integer pageSize = 7; // 每页显示多少条数据
// totalPages 总页数
Integer totalPages = totalRecouds % pageSize == 0 ? totalRecouds
/ pageSize : totalRecouds / pageSize + 1;
// startPage 起始位置
Integer startPage = pageSize * (pageNumber - 1) + 1;
Integer endPage = startPage + pageSize;
// sql 拼接分页
// 查询数据
StringBuffer sqlinfo = new StringBuffer(
" select rownum num ,t.* from T_BD_SettlementType t ");
sqlinfo.append(sqlcanshuo);
String sqlfy = " select a.* from ( " + sqlinfo
+ " ) a where a.num>='" + startPage + "' and a.num<'"
+ endPage + "' ";
IRowSet rowSet = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sqlfy.toString());
net.sf.json.JSONArray dataList = new net.sf.json.JSONArray();
String Id = "";
String FNAME_L2 = "";
String number = "";
try {
while (rowSet.next()) {
Id = rowSet.getString("FID");
FNAME_L2 = rowSet.getString("FNAME_L2");
number = rowSet.getString("FNumber");
JSONObject jsonObj = new JSONObject();
jsonObj.put("id", Id);
jsonObj.put("name", FNAME_L2);
jsonObj.put("number", number);
dataList.add(jsonObj);
}
} catch (SQLException e) {
e.printStackTrace();
}
/*
* JSONArray defaultValue = new JSONArray();//默认值 JSONObject
* defaultjsonObj = new JSONObject(); defaultjsonObj.put("id", "001");
* defaultjsonObj.put("name", "洋河大曲"); defaultjsonObj.put("price",
* "10"); defaultValue.add(defaultjsonObj);
*/
pageList.put("pageCount", totalPages);
pageList.put("curPage", pageNumber);
pageList.put("rowsCount", totalRecouds);
pageList.put("colList", colList);
pageList.put("dataList", dataList);
// pageList.put("defaultValue", defaultValue);
jsonObject.put("pageList", pageList);
jsonObject.put("error", "null");
jsonObject.put("errorCode", 0);
jsonObject.put("success", true);
return jsonObject.toString();
}
/**
* 获取供应商
*/
@Override
protected String _getSupplier(Context ctx, String json)
throws BOSException, EASBizException {
// 云之家参数解析:
JSONObject yunjsonObj = JSONObject.parseObject(json);
String keyword = yunjsonObj.getString("keyword");// 搜索关键字
Integer pageNumber = Integer.parseInt(yunjsonObj.getString("curPage"));// 当前页码
StringBuffer sqlcanshuo = new StringBuffer();
if ("".equals(keyword)) {
sqlcanshuo.append(" where 1=1 ");
;
} else {
sqlcanshuo.append(" where FNAME_L2 like '%" + keyword + "%' ");
;
}
JSONObject jsonObject = new JSONObject();// 最外层json对象
JSONObject pageList = new JSONObject();
// 列名
JSONArray colList = new JSONArray();// id
JSONObject fidColL = new JSONObject();
fidColL.put("colEnName", "id");
JSONObject nameColL = new JSONObject();
nameColL.put("showName", "true");
nameColL.put("colZhName", "供应商名称");
nameColL.put("widgetType", "textWidget");
nameColL.put("colEnName", "name");
JSONObject priceColL = new JSONObject();
priceColL.put("colZhName", "供应商编码");
priceColL.put("widgetType", "textWidget");
priceColL.put("colEnName", "number");
/*
* JSONObject bankAccountColL = new JSONObject();
* bankAccountColL.put("colZhName", "银行账户");
* bankAccountColL.put("widgetType", "textWidget");
* bankAccountColL.put("colEnName", "bankAccount");
*
*
* JSONObject bankColL = new JSONObject(); bankColL.put("colZhName",
* "开户行"); bankColL.put("widgetType", "textWidget");
* bankColL.put("colEnName", "bank");
*/
colList.add(fidColL);
colList.add(nameColL);
colList.add(priceColL);
// colList.add(bankColL);
// colList.add(bankAccountColL);
String firstSql = " SELECT distinct supplier.fid, supplier.FNUMBER, supplier.FNAME_L2 FROM T_BD_Supplier supplier where supplier.FUSEDSTATUS=1 order by supplier.FNAME_L2 desc ";
StringBuffer sql = new StringBuffer(
" select count(1) count from ( " + firstSql + " ) ");
// StringBuffer sql = new
// StringBuffer(" select count(1) count from T_BD_Supplier ");
sql.append(sqlcanshuo);
// 查询总记录数
IRowSet rowcount = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sql.toString());
Integer totalRecouds = 0;
try {
while (rowcount.next()) {
totalRecouds = rowcount.getInt("count");
}
} catch (SQLException e1) {
e1.printStackTrace();
}
Integer pageSize = 7; // 每页显示多少条数据
// totalPages 总页数
Integer totalPages = totalRecouds % pageSize == 0 ? totalRecouds
/ pageSize : totalRecouds / pageSize + 1;
// startPage 起始位置
Integer startPage = pageSize * (pageNumber - 1) + 1;
Integer endPage = startPage + pageSize;
// sql 拼接分页
// 查询数据
StringBuffer sqlinfo = new StringBuffer(
" select rownum num ,t.* from ( " + firstSql
+ " ) t ");
sqlinfo.append(sqlcanshuo);
String sqlfy = " select a.* from ( " + sqlinfo
+ " ) a where a.num>='" + startPage + "' and a.num<'"
+ endPage + "' ";
IRowSet rowSet = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sqlfy.toString());
net.sf.json.JSONArray dataList = new net.sf.json.JSONArray();
String Id = "";
String FNAME_L2 = "";
String number = "";
String bankAccount = "";
String bank = "";
try {
while (rowSet.next()) {
Id = rowSet.getString("FID");
FNAME_L2 = rowSet.getString("FNAME_L2");
number = rowSet.getString("FNumber");
// bank =
// rowSet.getString("FBANK")==null?"":rowSet.getString("FBANK");
// bankAccount =
// rowSet.getString("FBANKACCOUNT")==null?"":rowSet
// .getString("FBANKACCOUNT");
JSONObject jsonObj = new JSONObject();
// jsonObj.put("id", Id);
Random random = new Random();
jsonObj.put("id", random.toString() + bankAccount);//这里以随机数+银行账号为
// id
// id不能为重复的
jsonObj.put("name", FNAME_L2);
jsonObj.put("number", number);
// jsonObj.put("bankAccount", bankAccount);
// jsonObj.put("bank", bank);
dataList.add(jsonObj);
}
} catch (SQLException e) {
e.printStackTrace();
}
pageList.put("pageCount", totalPages);
pageList.put("curPage", pageNumber);
pageList.put("rowsCount", totalRecouds);
pageList.put("colList", colList);
pageList.put("dataList", dataList);
// pageList.put("defaultValue", defaultValue);
jsonObject.put("pageList", pageList);
jsonObject.put("error", "null");
jsonObject.put("errorCode", 0);
jsonObject.put("success", true);
return jsonObject.toString();
}
/**
* 获取招待用品
*/
@Override
protected String _getSupplies(Context ctx, String json)
throws BOSException, EASBizException {
// 云之家参数解析:
JSONObject yunjsonObj = JSONObject.parseObject(json);
String keyword = yunjsonObj.getString("keyword");// 搜索关键字
Integer pageNumber = Integer.parseInt(yunjsonObj.getString("curPage"));// 当前页码
StringBuffer sqlcanshuo = new StringBuffer();
if ("".equals(keyword)) {
sqlcanshuo.append(" where 1=1 ");
;
} else {
sqlcanshuo.append(" where FNAME_L2 like '%" + keyword + "%' ");
;
}
JSONObject jsonObject = new JSONObject();// 最外层json对象
JSONObject pageList = new JSONObject();
// 列名
JSONArray colList = new JSONArray();// id
JSONObject fidColL = new JSONObject();
fidColL.put("colEnName", "id");
JSONObject nameColL = new JSONObject();// 酒
nameColL.put("showName", "true");
nameColL.put("colZhName", "酒名称");
nameColL.put("widgetType", "textWidget");
nameColL.put("colEnName", "name");
JSONObject priceColL = new JSONObject();// 单价
priceColL.put("colZhName", "单价");
priceColL.put("widgetType", "moneyWidget");
priceColL.put("colEnName", "price");
colList.add(fidColL);
colList.add(nameColL);
colList.add(priceColL);
StringBuffer sql = new StringBuffer(
" select count(1) count from T_BAS_EntertainWine ");
sql.append(sqlcanshuo);
// 查询总记录数
IRowSet rowcount = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sql.toString());
Integer totalRecouds = 0;
try {
while (rowcount.next()) {
totalRecouds = rowcount.getInt("count");
}
} catch (SQLException e1) {
e1.printStackTrace();
}
Integer pageSize = 7; // 每页显示多少条数据
// totalPages 总页数
Integer totalPages = totalRecouds % pageSize == 0 ? totalRecouds
/ pageSize : totalRecouds / pageSize + 1;
// startPage 起始位置
Integer startPage = pageSize * (pageNumber - 1) + 1;
Integer endPage = startPage + pageSize;
// sql 拼接分页
// 查询数据
StringBuffer sqlinfo = new StringBuffer(
" select rownum num ,t.* from T_BAS_EntertainWine t ");
sqlinfo.append(sqlcanshuo);
String sqlfy = " select a.* from ( " + sqlinfo
+ " ) a where a.num>='" + startPage + "' and a.num<'"
+ endPage + "' ";
IRowSet rowSet = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sqlfy.toString());
net.sf.json.JSONArray dataList = new net.sf.json.JSONArray();
String Id = "";
String FNAME_L2 = "";
String PRICE = "";
String TYPE = "";
try {
while (rowSet.next()) {
Id = rowSet.getString("FID");
FNAME_L2 = rowSet.getString("FNAME_L2");
PRICE = rowSet.getString("FPRICE");
TYPE = rowSet.getString("FTYPE");
JSONObject jsonObj = new JSONObject();
jsonObj.put("id", Id);
jsonObj.put("name", FNAME_L2);
jsonObj.put("price", PRICE);
dataList.add(jsonObj);
}
} catch (SQLException e) {
e.printStackTrace();
}
/*
* JSONArray defaultValue = new JSONArray();//默认值 JSONObject
* defaultjsonObj = new JSONObject(); defaultjsonObj.put("id", "001");
* defaultjsonObj.put("name", "洋河大曲"); defaultjsonObj.put("price",
* "10"); defaultValue.add(defaultjsonObj);
*/
pageList.put("pageCount", totalPages);
pageList.put("curPage", pageNumber);
pageList.put("rowsCount", totalRecouds);
pageList.put("colList", colList);
pageList.put("dataList", dataList);
// pageList.put("defaultValue", defaultValue);
jsonObject.put("pageList", pageList);
jsonObject.put("error", "null");
jsonObject.put("errorCode", 0);
jsonObject.put("success", true);
return jsonObject.toString();
}
/**
* 获取医院级别
*/
@Override
protected String _getHospitalLevel(Context ctx, String json)
throws BOSException, EASBizException {
// 云之家参数解析:
JSONObject yunjsonObj = JSONObject.parseObject(json);
String keyword = yunjsonObj.getString("keyword");// 搜索关键字
Integer pageNumber = Integer.parseInt(yunjsonObj.getString("curPage"));// 当前页码
StringBuffer sqlcanshuo = new StringBuffer();
if ("".equals(keyword)) {
sqlcanshuo.append(" where 1=1 ");
;
} else {
sqlcanshuo.append(" where FNAME_L2 like '%" + keyword + "%' ");
;
}
JSONObject jsonObject = new JSONObject();// 最外层json对象
JSONObject pageList = new JSONObject();
// 列名
JSONArray colList = new JSONArray();// id
JSONObject fidColL = new JSONObject();
fidColL.put("colEnName", "id");
JSONObject nameColL = new JSONObject();
nameColL.put("showName", "true");
nameColL.put("colZhName", "医院级别名称");
nameColL.put("widgetType", "textWidget");
nameColL.put("colEnName", "name");
colList.add(fidColL);
colList.add(nameColL);
StringBuffer sql = new StringBuffer(
" select count(1) count from CT_BAS_HospitalLevel ");
sql.append(sqlcanshuo);
// 查询总记录数
IRowSet rowcount = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sql.toString());
Integer totalRecouds = 0;
try {
while (rowcount.next()) {
totalRecouds = rowcount.getInt("count");
}
} catch (SQLException e1) {
e1.printStackTrace();
}
Integer pageSize = 7; // 每页显示多少条数据
// totalPages 总页数
Integer totalPages = totalRecouds % pageSize == 0 ? totalRecouds
/ pageSize : totalRecouds / pageSize + 1;
// startPage 起始位置
Integer startPage = pageSize * (pageNumber - 1) + 1;
Integer endPage = startPage + pageSize;
// sql 拼接分页
// 查询数据
StringBuffer sqlinfo = new StringBuffer(
" select rownum num ,t.* from CT_BAS_HospitalLevel t ");
sqlinfo.append(sqlcanshuo);
String sqlfy = " select a.* from ( " + sqlinfo
+ " ) a where a.num>='" + startPage + "' and a.num<'"
+ endPage + "' ";
IRowSet rowSet = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sqlfy.toString());
net.sf.json.JSONArray dataList = new net.sf.json.JSONArray();
String Id = "";
String FNAME_L2 = "";
try {
while (rowSet.next()) {
Id = rowSet.getString("FID");
FNAME_L2 = rowSet.getString("FNAME_L2");
JSONObject jsonObj = new JSONObject();
jsonObj.put("id", Id);
jsonObj.put("name", FNAME_L2);
dataList.add(jsonObj);
}
} catch (SQLException e) {
e.printStackTrace();
}
pageList.put("pageCount", totalPages);
pageList.put("curPage", pageNumber);
pageList.put("rowsCount", totalRecouds);
pageList.put("colList", colList);
pageList.put("dataList", dataList);
// pageList.put("defaultValue", defaultValue);
jsonObject.put("pageList", pageList);
jsonObject.put("error", "null");
jsonObject.put("errorCode", 0);
jsonObject.put("success", true);
return jsonObject.toString();
}
/**
* 物料类别
*/
@Override
protected String _getMaterialGroup(Context ctx, String json)
throws BOSException, EASBizException {
// 云之家参数解析:
JSONObject yunjsonObj = JSONObject.parseObject(json);
String keyword = yunjsonObj.getString("keyword");// 搜索关键字
Integer pageNumber = Integer.parseInt(yunjsonObj.getString("curPage"));// 当前页码
StringBuffer sqlcanshuo = new StringBuffer();
if ("".equals(keyword)) {
sqlcanshuo.append(" where 1=1 ");
;
} else {
sqlcanshuo.append(" where FNAME_L2 like '%" + keyword + "%' ");
;
}
JSONObject jsonObject = new JSONObject();// 最外层json对象
JSONObject pageList = new JSONObject();
// 列名
JSONArray colList = new JSONArray();// id
JSONObject fidColL = new JSONObject();
fidColL.put("colEnName", "id");
JSONObject nameColL = new JSONObject();
nameColL.put("showName", "true");
nameColL.put("colZhName", "物料类别名称");
nameColL.put("widgetType", "textWidget");
nameColL.put("colEnName", "name");
JSONObject numberColL = new JSONObject();
numberColL.put("colZhName", "物料类别编码");
numberColL.put("widgetType", "textWidget");
numberColL.put("colEnName", "number");
colList.add(fidColL);
colList.add(nameColL);
colList.add(numberColL);
StringBuffer sql = new StringBuffer(
" select count(1) count from T_BD_MaterialGroup ");
sql.append(sqlcanshuo);
// 查询总记录数
IRowSet rowcount = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sql.toString());
Integer totalRecouds = 0;
try {
while (rowcount.next()) {
totalRecouds = rowcount.getInt("count");
}
} catch (SQLException e1) {
e1.printStackTrace();
}
Integer pageSize = 7; // 每页显示多少条数据
// totalPages 总页数
Integer totalPages = totalRecouds % pageSize == 0 ? totalRecouds
/ pageSize : totalRecouds / pageSize + 1;
// startPage 起始位置
Integer startPage = pageSize * (pageNumber - 1) + 1;
Integer endPage = startPage + pageSize;
// sql 拼接分页
// 查询数据
StringBuffer sqlinfo = new StringBuffer(
" select rownum num ,t.* from T_BD_MaterialGroup t ");
sqlinfo.append(sqlcanshuo);
String sqlfy = " select a.* from ( " + sqlinfo
+ " ) a where a.num>='" + startPage + "' and a.num<'"
+ endPage + "' ";
IRowSet rowSet = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sqlfy.toString());
net.sf.json.JSONArray dataList = new net.sf.json.JSONArray();
String Id = "";
String FNAME_L2 = "";
String number = "";
try {
while (rowSet.next()) {
Id = rowSet.getString("FID");
FNAME_L2 = rowSet.getString("FNAME_L2");
number = rowSet.getString("FNUMBER");
JSONObject jsonObj = new JSONObject();
jsonObj.put("id", Id);
jsonObj.put("name", FNAME_L2);
jsonObj.put("number", number);
dataList.add(jsonObj);
}
} catch (SQLException e) {
e.printStackTrace();
}
pageList.put("pageCount", totalPages);
pageList.put("curPage", pageNumber);
pageList.put("rowsCount", totalRecouds);
pageList.put("colList", colList);
pageList.put("dataList", dataList);
// pageList.put("defaultValue", defaultValue);
jsonObject.put("pageList", pageList);
jsonObject.put("error", "null");
jsonObject.put("errorCode", 0);
jsonObject.put("success", true);
return jsonObject.toString();
}
/**
* 获取剂型
*/
@Override
protected String _getDosageForm(Context ctx, String json)
throws BOSException, EASBizException {
// 云之家参数解析:
JSONObject yunjsonObj = JSONObject.parseObject(json);
String keyword = yunjsonObj.getString("keyword");// 搜索关键字
Integer pageNumber = Integer.parseInt(yunjsonObj.getString("curPage"));// 当前页码
StringBuffer sqlcanshuo = new StringBuffer();
if ("".equals(keyword)) {
sqlcanshuo.append(" where 1=1 ");
;
} else {
sqlcanshuo.append(" where FNAME_L2 like '%" + keyword + "%' ");
;
}
JSONObject jsonObject = new JSONObject();// 最外层json对象
JSONObject pageList = new JSONObject();
// 列名
JSONArray colList = new JSONArray();// id
JSONObject fidColL = new JSONObject();
fidColL.put("colEnName", "id");
JSONObject nameColL = new JSONObject();
nameColL.put("showName", "true");
nameColL.put("colZhName", "剂型名称");
nameColL.put("widgetType", "textWidget");
nameColL.put("colEnName", "name");
colList.add(fidColL);
colList.add(nameColL);
StringBuffer sql = new StringBuffer(
" select count(1) count from CT_BAS_Formulations ");
sql.append(sqlcanshuo);
// 查询总记录数
IRowSet rowcount = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sql.toString());
Integer totalRecouds = 0;
try {
while (rowcount.next()) {
totalRecouds = rowcount.getInt("count");
}
} catch (SQLException e1) {
e1.printStackTrace();
}
Integer pageSize = 7; // 每页显示多少条数据
// totalPages 总页数
Integer totalPages = totalRecouds % pageSize == 0 ? totalRecouds
/ pageSize : totalRecouds / pageSize + 1;
// startPage 起始位置
Integer startPage = pageSize * (pageNumber - 1) + 1;
Integer endPage = startPage + pageSize;
// sql 拼接分页
// 查询数据
StringBuffer sqlinfo = new StringBuffer(
" select rownum num ,t.* from CT_BAS_Formulations t ");
sqlinfo.append(sqlcanshuo);
String sqlfy = " select a.* from ( " + sqlinfo
+ " ) a where a.num>='" + startPage + "' and a.num<'"
+ endPage + "' ";
IRowSet rowSet = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sqlfy.toString());
net.sf.json.JSONArray dataList = new net.sf.json.JSONArray();
String Id = "";
String FNAME_L2 = "";
try {
while (rowSet.next()) {
Id = rowSet.getString("FID");
FNAME_L2 = rowSet.getString("FNAME_L2");
JSONObject jsonObj = new JSONObject();
jsonObj.put("id", Id);
jsonObj.put("name", FNAME_L2);
dataList.add(jsonObj);
}
} catch (SQLException e) {
e.printStackTrace();
}
pageList.put("pageCount", totalPages);
pageList.put("curPage", pageNumber);
pageList.put("rowsCount", totalRecouds);
pageList.put("colList", colList);
pageList.put("dataList", dataList);
// pageList.put("defaultValue", defaultValue);
jsonObject.put("pageList", pageList);
jsonObject.put("error", "null");
jsonObject.put("errorCode", 0);
jsonObject.put("success", true);
return jsonObject.toString();
}
/**
* 获取计量单位
*/
@Override
protected String _getUnit(Context ctx, String json) throws BOSException,
EASBizException {
// 云之家参数解析:
JSONObject yunjsonObj = JSONObject.parseObject(json);
String keyword = yunjsonObj.getString("keyword");// 搜索关键字
Integer pageNumber = Integer.parseInt(yunjsonObj.getString("curPage"));// 当前页码
StringBuffer sqlcanshuo = new StringBuffer();
if ("".equals(keyword)) {
sqlcanshuo.append(" where 1=1 ");
;
} else {
sqlcanshuo.append(" where FNAME_L2 like '%" + keyword + "%' ");
;
}
JSONObject jsonObject = new JSONObject();// 最外层json对象
JSONObject pageList = new JSONObject();
// 列名
JSONArray colList = new JSONArray();// id
JSONObject fidColL = new JSONObject();
fidColL.put("colEnName", "id");
JSONObject numberColL = new JSONObject();
numberColL.put("colZhName", "编码");
numberColL.put("widgetType", "textWidget");
numberColL.put("colEnName", "number");
JSONObject nameColL = new JSONObject();
nameColL.put("showName", "true");
nameColL.put("colZhName", "计量单位");
nameColL.put("widgetType", "textWidget");
nameColL.put("colEnName", "name");
colList.add(fidColL);
colList.add(nameColL);
colList.add(numberColL);
StringBuffer sql = new StringBuffer(
" select count(1) count from T_BD_MeasureUnit ");
sql.append(sqlcanshuo);
// 查询总记录数
IRowSet rowcount = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sql.toString());
Integer totalRecouds = 0;
try {
while (rowcount.next()) {
totalRecouds = rowcount.getInt("count");
}
} catch (SQLException e1) {
e1.printStackTrace();
}
Integer pageSize = 7; // 每页显示多少条数据
// totalPages 总页数
Integer totalPages = totalRecouds % pageSize == 0 ? totalRecouds
/ pageSize : totalRecouds / pageSize + 1;
// startPage 起始位置
Integer startPage = pageSize * (pageNumber - 1) + 1;
Integer endPage = startPage + pageSize;
// sql 拼接分页
// 查询数据
StringBuffer sqlinfo = new StringBuffer(
" select rownum num ,t.* from T_BD_MeasureUnit t ");
sqlinfo.append(sqlcanshuo);
String sqlfy = " select a.* from ( " + sqlinfo
+ " ) a where a.num>='" + startPage + "' and a.num<'"
+ endPage + "' ";
IRowSet rowSet = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sqlfy.toString());
net.sf.json.JSONArray dataList = new net.sf.json.JSONArray();
String Id = "";
String FNAME_L2 = "";
String number = "";
try {
while (rowSet.next()) {
Id = rowSet.getString("FID");
FNAME_L2 = rowSet.getString("FNAME_L2");
number = rowSet.getString("Fnumber");
JSONObject jsonObj = new JSONObject();
jsonObj.put("id", Id);
jsonObj.put("number", number);
jsonObj.put("name", FNAME_L2);
dataList.add(jsonObj);
}
} catch (SQLException e) {
e.printStackTrace();
}
pageList.put("pageCount", totalPages);
pageList.put("curPage", pageNumber);
pageList.put("rowsCount", totalRecouds);
pageList.put("colList", colList);
pageList.put("dataList", dataList);
// pageList.put("defaultValue", defaultValue);
jsonObject.put("pageList", pageList);
jsonObject.put("error", "null");
jsonObject.put("errorCode", 0);
jsonObject.put("success", true);
return jsonObject.toString();
}
/**
* 通用接口
*/
@Override
protected String _getbaseInfo(Context ctx, String json, String jsonparam)
throws BOSException, EASBizException {
if (jsonparam.equals("省份人员审批查询")) {
// 云之家参数解析:
// 云之家参数解析:
JSONObject yunjsonObj = JSONObject.parseObject(json);
String keyword = yunjsonObj.getString("keyword");// 搜索关键字
Integer pageNumber = Integer.parseInt(yunjsonObj
.getString("curPage"));// 当前页码
StringBuffer sqlcanshuo = new StringBuffer();
if ("".equals(keyword)) {
sqlcanshuo.append(" where 1=1 ");
;
} else {
sqlcanshuo
.append(" where a.FNAME_L2 like '%" + keyword + "%' ");
;
}
JSONObject jsonObject = new JSONObject();// 最外层json对象
JSONObject pageList = new JSONObject();
// 列名
JSONArray colList = new JSONArray();// id
JSONObject fidColL = new JSONObject();
fidColL.put("colEnName", "id");
JSONObject numberColL = new JSONObject();
numberColL.put("colZhName", "编码");
numberColL.put("widgetType", "textWidget");
numberColL.put("colEnName", "number");
JSONObject nameColL = new JSONObject();
nameColL.put("showName", "true");
nameColL.put("colZhName", "省份");
nameColL.put("widgetType", "textWidget");
nameColL.put("colEnName", "name");
JSONObject personColL = new JSONObject();
personColL.put("colZhName", "人员");
personColL.put("widgetType", "personSelectWidget");
personColL.put("colEnName", "personname");
colList.add(fidColL);
colList.add(numberColL);
colList.add(nameColL);
colList.add(personColL);
StringBuffer firstsql = new StringBuffer(
" select a.fid, a.FNUMBER, provice.fname_l2, CFPERSONID 人员 from CT_CRM_ProvincePerson a inner join T_BD_Province provice on provice.fid=a.CFPROVINCEID ");
firstsql.append(sqlcanshuo);
StringBuffer sql = new StringBuffer(
" select count(1) count from ( " + firstsql + ") ");
// 查询总记录数
IRowSet rowcount = SQLFacadeFactory.getLocalInstance(ctx)
.getRowset(sql.toString());
Integer totalRecouds = 0;
try {
while (rowcount.next()) {
totalRecouds = rowcount.getInt("count");
}
} catch (SQLException e1) {
e1.printStackTrace();
}
Integer pageSize = 7; // 每页显示多少条数据
// totalPages 总页数
Integer totalPages = totalRecouds % pageSize == 0 ? totalRecouds
/ pageSize : totalRecouds / pageSize + 1;
// startPage 起始位置
Integer startPage = pageSize * (pageNumber - 1) + 1;
Integer endPage = startPage + pageSize;
// sql 拼接分页
// 查询数据
StringBuffer sqlinfo = new StringBuffer(
" select rownum num ,t.* from ( " + firstsql
+ ") t ");
String sqlfy = " select a.* from ( " + sqlinfo
+ " ) a where a.num>='" + startPage + "' and a.num<'"
+ endPage + "' ";
IRowSet rowSet = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sqlfy.toString());
net.sf.json.JSONArray dataList = new net.sf.json.JSONArray();
String Id = "";
String PERSONID = "";
String name = "";
String number = "";
try {
while (rowSet.next()) {
PERSONID = rowSet.getString("人员") == null ? "" : rowSet
.getString("人员");
Id = rowSet.getString("fid");
name = rowSet.getString("fname_l2");
number = rowSet.getString("FNUMBER");
JSONObject jsonObj = new JSONObject();
jsonObj.put("id", Id);
jsonObj.put("number", number);
jsonObj.put("name", name);
// 把eas的人员换成 云之家的人员id
String FXTID = "";
String sqlPerson = " select FXTID from T_PM_EASXTUSERMAP where FPERSONID='"
+ PERSONID + "' ";
IRowSet executeSQL = SQLExecutorFactory.getLocalInstance(
ctx, sqlPerson).executeSQL();
while (executeSQL.next()) {
FXTID = executeSQL.getString("FXTID");
}
JSONObject personObj = new JSONObject();
ArrayList pe = new ArrayList();
pe.add(FXTID);
// 人员id能查到再赋值
if (null != FXTID && !"".equals(FXTID)) {
jsonObj.put("personname", pe); // 人员控件 name 传参也是
}
dataList.add(jsonObj);
}
} catch (SQLException e) {
e.printStackTrace();
}
pageList.put("pageCount", totalPages);
pageList.put("curPage", pageNumber);
pageList.put("rowsCount", totalRecouds);
pageList.put("colList", colList);
pageList.put("dataList", dataList);
// pageList.put("defaultValue", defaultValue);
jsonObject.put("pageList", pageList);
jsonObject.put("error", "null");
jsonObject.put("errorCode", 0);
jsonObject.put("success", true);
return jsonObject.toString();
}
if (jsonparam.equals("供应商和银行账号")) {
// 云之家参数解析:
JSONObject yunjsonObj = JSONObject.parseObject(json);
String keyword = yunjsonObj.getString("keyword");// 搜索关键字
Integer pageNumber = Integer.parseInt(yunjsonObj
.getString("curPage"));// 当前页码
StringBuffer sqlcanshuo = new StringBuffer();
if ("".equals(keyword)) {
sqlcanshuo.append(" where 1=1 ");
;
} else {
sqlcanshuo.append(" where FNAME_L2 like '%" + keyword + "%' ");
;
}
JSONObject jsonObject = new JSONObject();// 最外层json对象
JSONObject pageList = new JSONObject();
// 列名
JSONArray colList = new JSONArray();// id
JSONObject fidColL = new JSONObject();
fidColL.put("colEnName", "id");
JSONObject nameColL = new JSONObject();
nameColL.put("showName", "true");
nameColL.put("colZhName", "供应商名称");
nameColL.put("widgetType", "textWidget");
nameColL.put("colEnName", "name");
JSONObject priceColL = new JSONObject();
priceColL.put("colZhName", "供应商编码");
priceColL.put("widgetType", "textWidget");
priceColL.put("colEnName", "number");
JSONObject bankAccountColL = new JSONObject();
bankAccountColL.put("colZhName", "银行账户");
bankAccountColL.put("widgetType", "textWidget");
bankAccountColL.put("colEnName", "bankAccount");
JSONObject bankColL = new JSONObject();
bankColL.put("colZhName", "开户行");
bankColL.put("widgetType", "textWidget");
bankColL.put("colEnName", "bank");
colList.add(fidColL);
colList.add(nameColL);
colList.add(priceColL);
colList.add(bankColL);
colList.add(bankAccountColL);
String firstSql = " SELECT distinct supplier.fid, supplier.FNUMBER, supplier.FNAME_L2, bank.FBANK, bank.FBANKACCOUNT FROM T_BD_Supplier supplier inner join T_BD_SupplierCompanyInfo comanyinfo on comanyinfo.FSUPPLIERID=supplier.fid inner join T_BD_SupplierCompanyBank bank on bank.FSUPPLIERCOMPANYINFOID=comanyinfo.fid where supplier.FUSEDSTATUS=1 order by supplier.FNAME_L2 desc ";
StringBuffer sql = new StringBuffer(
" select count(1) count from ( " + firstSql + " ) ");
sql.append(sqlcanshuo);
// 查询总记录数
IRowSet rowcount = SQLFacadeFactory.getLocalInstance(ctx)
.getRowset(sql.toString());
Integer totalRecouds = 0;
try {
while (rowcount.next()) {
totalRecouds = rowcount.getInt("count");
}
} catch (SQLException e1) {
e1.printStackTrace();
}
Integer pageSize = 7; // 每页显示多少条数据
// totalPages 总页数
Integer totalPages = totalRecouds % pageSize == 0 ? totalRecouds
/ pageSize : totalRecouds / pageSize + 1;
// startPage 起始位置
Integer startPage = pageSize * (pageNumber - 1) + 1;
Integer endPage = startPage + pageSize;
// sql 拼接分页
// 查询数据
StringBuffer sqlinfo = new StringBuffer(
" select rownum num ,t.* from ( " + firstSql
+ " ) t ");
sqlinfo.append(sqlcanshuo);
String sqlfy = " select a.* from ( " + sqlinfo
+ " ) a where a.num>='" + startPage + "' and a.num<'"
+ endPage + "' ";
IRowSet rowSet = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sqlfy.toString());
net.sf.json.JSONArray dataList = new net.sf.json.JSONArray();
String Id = "";
String FNAME_L2 = "";
String number = "";
String bankAccount = "";
String bank = "";
try {
while (rowSet.next()) {
Id = rowSet.getString("FID");
FNAME_L2 = rowSet.getString("FNAME_L2");
number = rowSet.getString("FNumber");
bank = rowSet.getString("FBANK") == null ? "" : rowSet
.getString("FBANK");
bankAccount = rowSet.getString("FBANKACCOUNT") == null ? ""
: rowSet.getString("FBANKACCOUNT");
JSONObject jsonObj = new JSONObject();
// jsonObj.put("id", Id);
Random random = new Random();
jsonObj.put("id", random.toString() + bankAccount);//这里以随机数+
// 银行账号为
// id
// id不能为重复的
jsonObj.put("name", FNAME_L2);
jsonObj.put("number", number);
jsonObj.put("bankAccount", bankAccount);
jsonObj.put("bank", bank);
dataList.add(jsonObj);
}
} catch (SQLException e) {
e.printStackTrace();
}
pageList.put("pageCount", totalPages);
pageList.put("curPage", pageNumber);
pageList.put("rowsCount", totalRecouds);
pageList.put("colList", colList);
pageList.put("dataList", dataList);
// pageList.put("defaultValue", defaultValue);
jsonObject.put("pageList", pageList);
jsonObject.put("error", "null");
jsonObject.put("errorCode", 0);
jsonObject.put("success", true);
return jsonObject.toString();
}
if (jsonparam.equals("客户和银行账号")) {
// 云之家参数解析:
JSONObject yunjsonObj = JSONObject.parseObject(json);
String keyword = yunjsonObj.getString("keyword");// 搜索关键字
Integer pageNumber = Integer.parseInt(yunjsonObj
.getString("curPage"));// 当前页码
StringBuffer sqlcanshuo = new StringBuffer();
if ("".equals(keyword)) {
sqlcanshuo.append(" where 1=1 ");
;
} else {
sqlcanshuo.append(" where FNAME_L2 like '%" + keyword + "%' ");
;
}
JSONObject jsonObject = new JSONObject();// 最外层json对象
JSONObject pageList = new JSONObject();
// 列名
JSONArray colList = new JSONArray();// id
JSONObject fidColL = new JSONObject();
fidColL.put("colEnName", "id");
JSONObject nameColL = new JSONObject();
nameColL.put("showName", "true");
nameColL.put("colZhName", "客户名称");
nameColL.put("widgetType", "textWidget");
nameColL.put("colEnName", "name");
JSONObject priceColL = new JSONObject();
priceColL.put("colZhName", "客户编码");
priceColL.put("widgetType", "textWidget");
priceColL.put("colEnName", "number");
JSONObject bankAccountColL = new JSONObject();
bankAccountColL.put("colZhName", "银行账户");
bankAccountColL.put("widgetType", "textWidget");
bankAccountColL.put("colEnName", "bankAccount");
JSONObject bankColL = new JSONObject();
bankColL.put("colZhName", "开户行");
bankColL.put("widgetType", "textWidget");
bankColL.put("colEnName", "bank");
colList.add(fidColL);
colList.add(nameColL);
colList.add(priceColL);
colList.add(bankAccountColL);
colList.add(bankColL);
String sqlfirst = " SELECT distinct customer.fid, customer.FNUMBER, customer.FNAME_L2, bank.FBANK, bank.FBANKACCOUNT FROM T_BD_Customer customer inner join T_BD_CustomerCompanyInfo comanyinfo on comanyinfo.FCustomerID=customer.fid inner join T_BD_CustomerCompanyBank bank on bank.FCustomerCompanyInfoID=comanyinfo.fid where FUsedStatus=1 order by customer.FNAME_L2 desc ";
StringBuffer sql = new StringBuffer(
" select count(1) count from ( " + sqlfirst + " ) ");
sql.append(sqlcanshuo);
// 查询总记录数
IRowSet rowcount = SQLFacadeFactory.getLocalInstance(ctx)
.getRowset(sql.toString());
Integer totalRecouds = 0;
try {
while (rowcount.next()) {
totalRecouds = rowcount.getInt("count");
}
} catch (SQLException e1) {
e1.printStackTrace();
}
Integer pageSize = 7; // 每页显示多少条数据
// totalPages 总页数
Integer totalPages = totalRecouds % pageSize == 0 ? totalRecouds
/ pageSize : totalRecouds / pageSize + 1;
// startPage 起始位置
Integer startPage = pageSize * (pageNumber - 1) + 1;
Integer endPage = startPage + pageSize;
// sql 拼接分页
// 查询数据
StringBuffer sqlinfo = new StringBuffer(
" select rownum num ,t.* from ( " + sqlfirst
+ " ) t ");
sqlinfo.append(sqlcanshuo);
String sqlfy = " select a.* from ( " + sqlinfo
+ " ) a where a.num>='" + startPage + "' and a.num<'"
+ endPage + "' ";
System.out.println("客户sql" + sqlfy);
IRowSet rowSet = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sqlfy.toString());
net.sf.json.JSONArray dataList = new net.sf.json.JSONArray();
String Id = "";
String FNAME_L2 = "";
String number = "";
String bankAccount = "";
String bank = "";
try {
while (rowSet.next()) {
Id = rowSet.getString("FID");
FNAME_L2 = rowSet.getString("FNAME_L2");
number = rowSet.getString("FNumber");
bank = rowSet.getString("FBANK") == null ? "" : rowSet
.getString("FBANK");
bankAccount = rowSet.getString("FBANKACCOUNT") == null ? ""
: rowSet.getString("FBANKACCOUNT");
JSONObject jsonObj = new JSONObject();
Random random = new Random();
jsonObj.put("id", random.toString() + bankAccount); // 这里以Random随机数银行账号充当id
jsonObj.put("name", FNAME_L2);
jsonObj.put("number", number);
jsonObj.put("bankAccount", bankAccount);
jsonObj.put("bank", bank);
dataList.add(jsonObj);
}
} catch (SQLException e) {
e.printStackTrace();
}
pageList.put("pageCount", totalPages);
pageList.put("curPage", pageNumber);
pageList.put("rowsCount", totalRecouds);
pageList.put("colList", colList);
pageList.put("dataList", dataList);
// pageList.put("defaultValue", defaultValue);
jsonObject.put("pageList", pageList);
jsonObject.put("error", "null");
jsonObject.put("errorCode", 0);
jsonObject.put("success", true);
return jsonObject.toString();
}
if (jsonparam.equals("根据供客户名称过滤显示银行账号与开户行")) {
// 云之家参数解析:
JSONObject yunjsonObj = JSONObject.parseObject(json);
String supplyName = "";
if (!yunjsonObj.getJSONObject("basicFormInfo").isEmpty()) {
JSONObject iw = (JSONObject) yunjsonObj.getJSONObject(
"basicFormInfo").getJSONArray("iw_2").get(0);
supplyName = iw.getString("name");
}
String keyword = supplyName;// 单据上供应商数据互联控件选择的供应商名称
Integer pageNumber = Integer.parseInt(yunjsonObj
.getString("curPage"));// 当前页码
StringBuffer sqlcanshuo = new StringBuffer();
if ("".equals(keyword)) {
sqlcanshuo.append(" where 1=1 ");
} else {
sqlcanshuo.append(" where FNAME_L2 like '%" + keyword + "%' ");
;
}
JSONObject jsonObject = new JSONObject();// 最外层json对象
JSONObject pageList = new JSONObject();
// 列名
JSONArray colList = new JSONArray();
JSONObject fidColL = new JSONObject();// id
fidColL.put("colEnName", "id");
JSONObject bankAccountColL = new JSONObject();
bankAccountColL.put("colZhName", "银行账户");
bankAccountColL.put("widgetType", "textWidget");
bankAccountColL.put("colEnName", "number");
JSONObject bankColL = new JSONObject();
bankColL.put("showName", "true");
bankColL.put("colZhName", "开户行");
bankColL.put("widgetType", "textWidget");
bankColL.put("colEnName", "name");
colList.add(fidColL);
colList.add(bankAccountColL);
colList.add(bankColL);
String sqlfirst = " SELECT distinct customer.fid, customer.FNUMBER, customer.FNAME_L2, bank.FBANK, bank.FBANKACCOUNT FROM T_BD_Customer customer left join T_BD_CustomerCompanyInfo comanyinfo on comanyinfo.FCustomerID=customer.fid inner join T_BD_CustomerCompanyBank bank on bank.FCustomerCompanyInfoID=comanyinfo.fid order by customer.FNAME_L2 ";
StringBuffer sql = new StringBuffer(
" select count(1) count from ( " + sqlfirst + " ) ");
sql.append(sqlcanshuo);
// 查询总记录数
IRowSet rowcount = SQLFacadeFactory.getLocalInstance(ctx)
.getRowset(sql.toString());
Integer totalRecouds = 0;
try {
while (rowcount.next()) {
totalRecouds = rowcount.getInt("count");
}
} catch (SQLException e1) {
e1.printStackTrace();
}
Integer pageSize = 7; // 每页显示多少条数据
// totalPages 总页数
Integer totalPages = totalRecouds % pageSize == 0 ? totalRecouds
/ pageSize : totalRecouds / pageSize + 1;
// startPage 起始位置
Integer startPage = pageSize * (pageNumber - 1) + 1;
Integer endPage = startPage + pageSize;
// sql 拼接分页
// 查询数据
StringBuffer sqlinfo = new StringBuffer(
" select rownum num ,t.* from ( " + sqlfirst
+ " ) t ");
sqlinfo.append(sqlcanshuo);
String sqlfy = " select a.* from ( " + sqlinfo
+ " ) a where a.num>='" + startPage + "' and a.num<'"
+ endPage + "' ";
IRowSet rowSet = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sqlfy.toString());
net.sf.json.JSONArray dataList = new net.sf.json.JSONArray();
String Id = "";
String FNAME_L2 = "";
String number = "";
String bankAccount = "";
String bank = "";
try {
if (rowSet.next()) {
Id = rowSet.getString("FID");
FNAME_L2 = rowSet.getString("FNAME_L2");
number = rowSet.getString("FNumber");
bank = rowSet.getString("FBANK");
bankAccount = rowSet.getString("FBANKACCOUNT");
JSONObject jsonObj = new JSONObject();
jsonObj.put("id", Id);
jsonObj.put("number", bankAccount);
jsonObj.put("name", bank);
dataList.add(jsonObj);
}
} catch (SQLException e) {
e.printStackTrace();
}
pageList.put("pageCount", totalPages);
pageList.put("curPage", pageNumber);
pageList.put("rowsCount", totalRecouds);
pageList.put("colList", colList);
pageList.put("dataList", dataList);
// pageList.put("defaultValue", defaultValue);
jsonObject.put("pageList", pageList);
jsonObject.put("error", "null");
jsonObject.put("errorCode", 0);
jsonObject.put("success", true);
return jsonObject.toString();
}
if (jsonparam.equals("根据供应商名称过滤显示银行账号与开户行")) {
// 云之家参数解析:
JSONObject yunjsonObj = JSONObject.parseObject(json);
String supplyName = "";
if (!yunjsonObj.getJSONObject("basicFormInfo").isEmpty()) {
JSONObject iw = (JSONObject) yunjsonObj.getJSONObject(
"basicFormInfo").getJSONArray("iw_2").get(0);
supplyName = iw.getString("name");
}
String keyword = supplyName;// 单据上供应商数据互联控件选择的供应商名称
Integer pageNumber = Integer.parseInt(yunjsonObj
.getString("curPage"));// 当前页码
StringBuffer sqlcanshuo = new StringBuffer();
if ("".equals(keyword)) {
sqlcanshuo.append(" where 1=1 ");
} else {
sqlcanshuo.append(" where FNAME_L2 like '%" + keyword + "%' ");
;
}
JSONObject jsonObject = new JSONObject();// 最外层json对象
JSONObject pageList = new JSONObject();
// 列名
JSONArray colList = new JSONArray();
JSONObject fidColL = new JSONObject();// id
fidColL.put("colEnName", "id");
JSONObject bankAccountColL = new JSONObject();
bankAccountColL.put("colZhName", "银行账户");
bankAccountColL.put("widgetType", "textWidget");
bankAccountColL.put("colEnName", "number");
JSONObject bankColL = new JSONObject();
bankColL.put("showName", "true");
bankColL.put("colZhName", "开户行");
bankColL.put("widgetType", "textWidget");
bankColL.put("colEnName", "name");
colList.add(fidColL);
colList.add(bankAccountColL);
colList.add(bankColL);
StringBuffer sql = new StringBuffer(
" select count(1) count from ( SELECT distinct supplier.fid, supplier.FNUMBER, supplier.FNAME_L2, bank.FBANK, bank.FBANKACCOUNT FROM T_BD_Supplier supplier left join T_BD_SupplierCompanyInfo comanyinfo on comanyinfo.FSUPPLIERID=supplier.fid inner join T_BD_SupplierCompanyBank bank on bank.FSUPPLIERCOMPANYINFOID=comanyinfo.fid order by supplier.FNAME_L2 ) ");
sql.append(sqlcanshuo);
// 查询总记录数
IRowSet rowcount = SQLFacadeFactory.getLocalInstance(ctx)
.getRowset(sql.toString());
Integer totalRecouds = 0;
try {
while (rowcount.next()) {
totalRecouds = rowcount.getInt("count");
}
} catch (SQLException e1) {
e1.printStackTrace();
}
Integer pageSize = 7; // 每页显示多少条数据
// totalPages 总页数
Integer totalPages = totalRecouds % pageSize == 0 ? totalRecouds
/ pageSize : totalRecouds / pageSize + 1;
// startPage 起始位置
Integer startPage = pageSize * (pageNumber - 1) + 1;
Integer endPage = startPage + pageSize;
// sql 拼接分页
// 查询数据
StringBuffer sqlinfo = new StringBuffer(
" select rownum num ,t.* from ( SELECT distinct supplier.fid, supplier.FNUMBER, supplier.FNAME_L2, bank.FBANK, bank.FBANKACCOUNT FROM T_BD_Supplier supplier left join T_BD_SupplierCompanyInfo comanyinfo on comanyinfo.FSUPPLIERID=supplier.fid inner join T_BD_SupplierCompanyBank bank on bank.FSUPPLIERCOMPANYINFOID=comanyinfo.fid order by supplier.FNUMBER ) t ");
sqlinfo.append(sqlcanshuo);
String sqlfy = " select a.* from ( " + sqlinfo
+ " ) a where a.num>='" + startPage + "' and a.num<'"
+ endPage + "' ";
IRowSet rowSet = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sqlfy.toString());
net.sf.json.JSONArray dataList = new net.sf.json.JSONArray();
String Id = "";
String FNAME_L2 = "";
String number = "";
String bankAccount = "";
String bank = "";
int id = 0;
try {
if (rowSet.next()) {
Id = rowSet.getString("FID");
FNAME_L2 = rowSet.getString("FNAME_L2");
number = rowSet.getString("FNumber");
bank = rowSet.getString("FBANK");
bankAccount = rowSet.getString("FBANKACCOUNT");
JSONObject jsonObj = new JSONObject();
jsonObj.put("id", Id);
jsonObj.put("number", bankAccount);
jsonObj.put("name", bank);
dataList.add(jsonObj);
}
} catch (SQLException e) {
e.printStackTrace();
}
pageList.put("pageCount", totalPages);
pageList.put("curPage", pageNumber);
pageList.put("rowsCount", totalRecouds);
pageList.put("colList", colList);
pageList.put("dataList", dataList);
// pageList.put("defaultValue", defaultValue);
jsonObject.put("pageList", pageList);
jsonObject.put("error", "null");
jsonObject.put("errorCode", 0);
jsonObject.put("success", true);
return jsonObject.toString();
}
if (jsonparam.equals("职级主数据列表")) {
// 云之家参数解析:
JSONObject yunjsonObj = JSONObject.parseObject(json);
String keyword = yunjsonObj.getString("keyword");// 搜索关键字
Integer pageNumber = Integer.parseInt(yunjsonObj
.getString("curPage"));// 当前页码
StringBuffer sqlcanshuo = new StringBuffer();
if ("".equals(keyword)) {
sqlcanshuo.append(" where 1=1 ");
;
} else {
sqlcanshuo.append(" where FNAME_L2 like '%" + keyword + "%' ");
;
}
JSONObject jsonObject = new JSONObject();// 最外层json对象
JSONObject pageList = new JSONObject();
// 列名
JSONArray colList = new JSONArray();// id
JSONObject fidColL = new JSONObject();
fidColL.put("colEnName", "id");
JSONObject nameColL = new JSONObject();
nameColL.put("showName", "true");
nameColL.put("colZhName", "名称");
nameColL.put("widgetType", "textWidget");
nameColL.put("colEnName", "name");
colList.add(fidColL);
colList.add(nameColL);
StringBuffer sql = new StringBuffer(
" select count(1) count from T_HR_JobLevel ");
sql.append(sqlcanshuo);
// 查询总记录数
IRowSet rowcount = SQLFacadeFactory.getLocalInstance(ctx)
.getRowset(sql.toString());
Integer totalRecouds = 0;
try {
while (rowcount.next()) {
totalRecouds = rowcount.getInt("count");
}
} catch (SQLException e1) {
e1.printStackTrace();
}
Integer pageSize = 7; // 每页显示多少条数据
// totalPages 总页数
Integer totalPages = totalRecouds % pageSize == 0 ? totalRecouds
/ pageSize : totalRecouds / pageSize + 1;
// startPage 起始位置
Integer startPage = pageSize * (pageNumber - 1) + 1;
Integer endPage = startPage + pageSize;
// sql 拼接分页
// 查询数据
StringBuffer sqlinfo = new StringBuffer(
" select rownum num ,t.* from T_HR_JobLevel t ");
sqlinfo.append(sqlcanshuo);
String sqlfy = " select a.* from ( " + sqlinfo
+ " ) a where a.num>='" + startPage + "' and a.num<'"
+ endPage + "' ";
IRowSet rowSet = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sqlfy.toString());
net.sf.json.JSONArray dataList = new net.sf.json.JSONArray();
String Id = "";
String FNAME_L2 = "";
try {
while (rowSet.next()) {
Id = rowSet.getString("FID");
FNAME_L2 = rowSet.getString("FNAME_L2");
JSONObject jsonObj = new JSONObject();
jsonObj.put("id", Id);
jsonObj.put("name", FNAME_L2);
dataList.add(jsonObj);
}
} catch (SQLException e) {
e.printStackTrace();
}
pageList.put("pageCount", totalPages);
pageList.put("curPage", pageNumber);
pageList.put("rowsCount", totalRecouds);
pageList.put("colList", colList);
pageList.put("dataList", dataList);
// pageList.put("defaultValue", defaultValue);
jsonObject.put("pageList", pageList);
jsonObject.put("error", "null");
jsonObject.put("errorCode", 0);
jsonObject.put("success", true);
return jsonObject.toString();
}
if (jsonparam.equals("获取费用类型")) {
// 云之家参数解析:
JSONObject yunjsonObj = JSONObject.parseObject(json);
String keyword = yunjsonObj.getString("keyword");// 搜索关键字
Integer pageNumber = Integer.parseInt(yunjsonObj
.getString("curPage"));// 当前页码
StringBuffer sqlcanshuo = new StringBuffer();
if ("".equals(keyword)) {
sqlcanshuo.append(" and 1=1 ");
;
} else {
sqlcanshuo.append(" and FNAME_L2 like '%" + keyword + "%' ");
;
}
JSONObject jsonObject = new JSONObject();// 最外层json对象
JSONObject pageList = new JSONObject();
// 列名
JSONArray colList = new JSONArray();// id
JSONObject fidColL = new JSONObject();
fidColL.put("colEnName", "id");
JSONObject nameColL = new JSONObject();
nameColL.put("showName", "true");
nameColL.put("colZhName", "名称");
nameColL.put("widgetType", "textWidget");
nameColL.put("colEnName", "name");
colList.add(fidColL);
colList.add(nameColL);
StringBuffer sql = new StringBuffer(
" select count(1) count from T_BC_ExpenseType where FISSTART=1 ");
sql.append(sqlcanshuo);
// 查询总记录数
IRowSet rowcount = SQLFacadeFactory.getLocalInstance(ctx)
.getRowset(sql.toString());
Integer totalRecouds = 0;
try {
while (rowcount.next()) {
totalRecouds = rowcount.getInt("count");
}
} catch (SQLException e1) {
e1.printStackTrace();
}
Integer pageSize = 7; // 每页显示多少条数据
// totalPages 总页数
Integer totalPages = totalRecouds % pageSize == 0 ? totalRecouds
/ pageSize : totalRecouds / pageSize + 1;
// startPage 起始位置
Integer startPage = pageSize * (pageNumber - 1) + 1;
Integer endPage = startPage + pageSize;
// sql 拼接分页
// 查询数据
StringBuffer sqlinfo = new StringBuffer(
" select rownum num ,t.* from T_BC_ExpenseType t where t.FISSTART=1 ");
sqlinfo.append(sqlcanshuo);
String sqlfy = " select a.* from ( " + sqlinfo
+ " ) a where a.num>='" + startPage + "' and a.num<'"
+ endPage + "' ";
IRowSet rowSet = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sqlfy.toString());
net.sf.json.JSONArray dataList = new net.sf.json.JSONArray();
String Id = "";
String FNAME_L2 = "";
try {
while (rowSet.next()) {
Id = rowSet.getString("FID");
FNAME_L2 = rowSet.getString("FNAME_L2");
JSONObject jsonObj = new JSONObject();
jsonObj.put("id", Id);
jsonObj.put("name", FNAME_L2);
dataList.add(jsonObj);
}
} catch (SQLException e) {
e.printStackTrace();
}
pageList.put("pageCount", totalPages);
pageList.put("curPage", pageNumber);
pageList.put("rowsCount", totalRecouds);
pageList.put("colList", colList);
pageList.put("dataList", dataList);
// pageList.put("defaultValue", defaultValue);
jsonObject.put("pageList", pageList);
jsonObject.put("error", "null");
jsonObject.put("errorCode", 0);
jsonObject.put("success", true);
return jsonObject.toString();
}
if (jsonparam.equals("项目信息")) {
// 云之家参数解析:
JSONObject yunjsonObj = JSONObject.parseObject(json);
String keyword = yunjsonObj.getString("keyword");// 搜索关键字
Integer pageNumber = Integer.parseInt(yunjsonObj
.getString("curPage"));// 当前页码
StringBuffer sqlcanshuo = new StringBuffer();
if ("".equals(keyword)) {
sqlcanshuo.append(" where 1=1 ");
;
} else {
sqlcanshuo
.append(" where a.FNAME_L2 like '%" + keyword + "%' ");
;
}
JSONObject jsonObject = new JSONObject();// 最外层json对象
JSONObject pageList = new JSONObject();
// 列名
JSONArray colList = new JSONArray();// id
JSONObject fidColL = new JSONObject();
fidColL.put("colEnName", "id");
JSONObject numberColL = new JSONObject();
numberColL.put("colZhName", "项目编码");
numberColL.put("widgetType", "textWidget");
numberColL.put("colEnName", "number");
JSONObject nameColL = new JSONObject();
nameColL.put("showName", "true");
nameColL.put("colZhName", "项目名称");
nameColL.put("widgetType", "textWidget");
nameColL.put("colEnName", "projectName");
JSONObject xmlxColL = new JSONObject();
xmlxColL.put("colZhName", "项目类型");
xmlxColL.put("widgetType", "textWidget");
xmlxColL.put("colEnName", "projectType");
/*
* JSONObject cwxmColL = new JSONObject(); cwxmColL.put("colZhName",
* "财务项目"); cwxmColL.put("widgetType", "textWidget");
* cwxmColL.put("colEnName", "cwName");
*/
JSONObject lxColL = new JSONObject();
lxColL.put("colZhName", "立项单位");
lxColL.put("widgetType", "textWidget");
lxColL.put("colEnName", "lxName");
JSONObject personColL = new JSONObject();
personColL.put("colZhName", "项目经理");
personColL.put("widgetType", "personSelectWidget");
personColL.put("colEnName", "personname");
/*
* JSONObject lxzysColL = new JSONObject();
* lxzysColL.put("colZhName", "立项总预算"); lxzysColL.put("widgetType",
* "moneyWidget"); lxzysColL.put("colEnName", " lxzy");
*/
colList.add(fidColL);
colList.add(numberColL);
colList.add(nameColL);
colList.add(personColL);
colList.add(xmlxColL);
colList.add(lxColL);
// colList.add(lxzysColL);
StringBuffer firstsql = new StringBuffer(
" select cost.FNAME_L2 立项单位, a.fid , a.Fnumber, a.FNAME_L2 项目名称, type.FNAME_L2 项目类型 ,c.CFPROEMPLOYERNUMID 项目经理 ,a.FTotalBudget 立项总预算 from CT_PRB_Probaseinfo a left join CT_PRB_Protype type on a.CFPROTYPEID=type.fid left join CT_PRB_Promember c on c.fid=a.CFPromanagerID inner join T_ORG_CostCenter cost on cost.fid=a.CFProunitID ");
firstsql.append(sqlcanshuo);
StringBuffer sql = new StringBuffer(
" select count(1) count from ( " + firstsql + ") ");
// 查询总记录数
IRowSet rowcount = SQLFacadeFactory.getLocalInstance(ctx)
.getRowset(sql.toString());
Integer totalRecouds = 0;
try {
while (rowcount.next()) {
totalRecouds = rowcount.getInt("count");
}
} catch (SQLException e1) {
e1.printStackTrace();
}
Integer pageSize = 7; // 每页显示多少条数据
// totalPages 总页数
Integer totalPages = totalRecouds % pageSize == 0 ? totalRecouds
/ pageSize : totalRecouds / pageSize + 1;
// startPage 起始位置
Integer startPage = pageSize * (pageNumber - 1) + 1;
Integer endPage = startPage + pageSize;
// sql 拼接分页
// 查询数据
StringBuffer sqlinfo = new StringBuffer(
" select rownum num ,t.* from ( " + firstsql
+ ") t ");
// sqlinfo.append(sqlcanshuo);
String sqlfy = " select a.* from ( " + sqlinfo
+ " ) a where a.num>='" + startPage + "' and a.num<'"
+ endPage + "' ";
IRowSet rowSet = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sqlfy.toString());
net.sf.json.JSONArray dataList = new net.sf.json.JSONArray();
String Id = "";
String PERSONID = "";
String projectName = "";
String number = "";
String projectType = "";
BigDecimal lxzy = BigDecimal.ZERO;
String lxName = "";
try {
while (rowSet.next()) {
PERSONID = rowSet.getString("项目经理") == null ? "" : rowSet
.getString("项目经理");
Id = rowSet.getString("fid");
projectName = rowSet.getString("项目名称");
number = rowSet.getString("Fnumber");
projectType = rowSet.getString("项目类型");
// lxzy = rowSet.getBigDecimal("立项总预算");
lxName = rowSet.getString("立项单位");
JSONObject jsonObj = new JSONObject();
jsonObj.put("id", Id);
jsonObj.put("number", number);
jsonObj.put("projectName", projectName);
// jsonObj.put("lxzy", lxzy);
jsonObj.put("lxName", lxName);
jsonObj.put("projectType", projectType);
jsonObj.put("number", number);
// 把eas的人员换成 云之家的人员id
String FXTID = "";
String sqlPerson = " select FXTID from T_PM_EASXTUSERMAP where FPERSONID='"
+ PERSONID + "' ";
IRowSet executeSQL = SQLExecutorFactory.getLocalInstance(
ctx, sqlPerson).executeSQL();
while (executeSQL.next()) {
FXTID = executeSQL.getString("FXTID");
}
JSONObject personObj = new JSONObject();
ArrayList pe = new ArrayList();
pe.add(FXTID);
// 人员id能查到再赋值
if (null != FXTID && !"".equals(FXTID)) {
jsonObj.put("personname", pe); // 人员控件 name 传参也是
}
dataList.add(jsonObj);
}
} catch (SQLException e) {
e.printStackTrace();
}
pageList.put("pageCount", totalPages);
pageList.put("curPage", pageNumber);
pageList.put("rowsCount", totalRecouds);
pageList.put("colList", colList);
pageList.put("dataList", dataList);
// pageList.put("defaultValue", defaultValue);
jsonObject.put("pageList", pageList);
jsonObject.put("error", "null");
jsonObject.put("errorCode", 0);
jsonObject.put("success", true);
return jsonObject.toString();
}
if (jsonparam.equals("产品经理查询")) {
// 云之家参数解析:
JSONObject yunjsonObj = JSONObject.parseObject(json);
String keyword = yunjsonObj.getString("keyword");// 搜索关键字
Integer pageNumber = Integer.parseInt(yunjsonObj
.getString("curPage"));// 当前页码
StringBuffer sqlcanshuo = new StringBuffer();
if ("".equals(keyword)) {
sqlcanshuo.append(" and 1=1 ");
;
} else {
sqlcanshuo.append(" and FNAME_L2 like '%" + keyword + "%' ");
;
}
JSONObject jsonObject = new JSONObject();// 最外层json对象
JSONObject pageList = new JSONObject();
// 列名
JSONArray colList = new JSONArray();// id
JSONObject fidColL = new JSONObject();
fidColL.put("colEnName", "id");
JSONObject nameColL = new JSONObject();
nameColL.put("showName", "true");
nameColL.put("colZhName", "名称");
nameColL.put("widgetType", "textWidget");
nameColL.put("colEnName", "name");
JSONObject numberColL = new JSONObject();
numberColL.put("colZhName", "编码");
numberColL.put("widgetType", "textWidget");
numberColL.put("colEnName", "number");
JSONObject personColL = new JSONObject();
personColL.put("colZhName", "医学经理");
personColL.put("widgetType", "personSelectWidget");
personColL.put("colEnName", "personname");
JSONObject personGroupColL = new JSONObject();
personGroupColL.put("colZhName", "产品组经理");
personGroupColL.put("widgetType", "personSelectWidget");
personGroupColL.put("colEnName", "personGroup");
JSONObject YXersonColL = new JSONObject();
YXersonColL.put("colZhName", "产品经理");
YXersonColL.put("widgetType", "personSelectWidget");
YXersonColL.put("colEnName", "yxPerson");
colList.add(fidColL);
colList.add(numberColL);
colList.add(nameColL);
colList.add(personColL);
colList.add(personGroupColL);
colList.add(YXersonColL);
StringBuffer sql = new StringBuffer(
" select count(1) count from CT_BD_ProductManager where CFKDCHECKBOX=0 ");
sql.append(sqlcanshuo);
// 查询总记录数
IRowSet rowcount = SQLFacadeFactory.getLocalInstance(ctx)
.getRowset(sql.toString());
Integer totalRecouds = 0;
try {
while (rowcount.next()) {
totalRecouds = rowcount.getInt("count");
}
} catch (SQLException e1) {
e1.printStackTrace();
}
Integer pageSize = 7; // 每页显示多少条数据
// totalPages 总页数
Integer totalPages = totalRecouds % pageSize == 0 ? totalRecouds
/ pageSize : totalRecouds / pageSize + 1;
// startPage 起始位置
Integer startPage = pageSize * (pageNumber - 1) + 1;
Integer endPage = startPage + pageSize;
// sql 拼接分页
// 查询数据 0 是启用
StringBuffer sqlinfo = new StringBuffer(
" select rownum num ,t.* from CT_BD_ProductManager t where t.CFKDCHECKBOX=0 ");
sqlinfo.append(sqlcanshuo);
String sqlfy = " select a.* from ( " + sqlinfo
+ " ) a where a.num>='" + startPage + "' and a.num<'"
+ endPage + "' ";
IRowSet rowSet = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sqlfy.toString());
net.sf.json.JSONArray dataList = new net.sf.json.JSONArray();
String Id = "";
String PERSONID = "";
String personGroup = "";
String FNAME_L2 = "";
String number = "";
String CFPERSONID = "";
try {
while (rowSet.next()) {
PERSONID = rowSet.getString("CFPERSONID") == null ? ""
: rowSet.getString("CFPERSONID");
personGroup = rowSet.getString("CFPRODUCTGROUPMANA") == null ? ""
: rowSet.getString("CFPRODUCTGROUPMANA");
CFPERSONID = rowSet.getString("CFPRODUCTMANAGERID") == null ? ""
: rowSet.getString("CFPRODUCTMANAGERID");
Id = rowSet.getString("fid");
FNAME_L2 = rowSet.getString("FNAME_L2");
number = rowSet.getString("FNUMBER");
JSONObject jsonObj = new JSONObject();
jsonObj.put("id", Id);
jsonObj.put("number", number);
jsonObj.put("name", FNAME_L2);
// 把eas的人员换成 云之家的人员id
String FXTID = "";
String sqlPerson = " /*dialect*/ select FXTID from T_PM_EASXTUSERMAP where FPERSONID='"
+ PERSONID + "' ";
IRowSet executeSQL = SQLExecutorFactory.getLocalInstance(
ctx, sqlPerson).executeSQL();
while (executeSQL.next()) {
FXTID = executeSQL.getString("FXTID");
}
String FXTPRODUCTGROUPMANAID = "";
String sqlFXTPRODUCTGROUPMANAID = " /*dialect*/ select FXTID from T_PM_EASXTUSERMAP where FPERSONID='"
+ personGroup + "' ";
IRowSet executeSQL2 = SQLExecutorFactory.getLocalInstance(
ctx, sqlFXTPRODUCTGROUPMANAID).executeSQL();
while (executeSQL2.next()) {
FXTPRODUCTGROUPMANAID = executeSQL2.getString("FXTID");
}
String FXTCFPERSONID = "";
String sqlCFPERSONID = " /*dialect*/ select FXTID from T_PM_EASXTUSERMAP where FPERSONID='"
+ CFPERSONID + "' ";
IRowSet executeSQL3 = SQLExecutorFactory.getLocalInstance(
ctx, sqlCFPERSONID).executeSQL();
while (executeSQL3.next()) {
FXTCFPERSONID = executeSQL3.getString("FXTID");
}
ArrayList pe = new ArrayList();
pe.add(FXTID);
ArrayList pepersonGroup = new ArrayList();
pepersonGroup.add(FXTPRODUCTGROUPMANAID);// 产品经理组经理id
ArrayList pepersonyx = new ArrayList();
pepersonyx.add(FXTCFPERSONID); // 医学经理id
if (null != FXTID && !"".equals(FXTID)) {
jsonObj.put("personname", pe); // 产品经理
}
if (null != FXTPRODUCTGROUPMANAID
&& !"".equals(FXTPRODUCTGROUPMANAID)) {
jsonObj.put("personGroup", pepersonGroup); // 产品经理组经理
}
if (null != FXTCFPERSONID && !"".equals(FXTCFPERSONID)) {
jsonObj.put("yxPerson", pepersonyx); // 医学经理
}
dataList.add(jsonObj);
}
} catch (SQLException e) {
e.printStackTrace();
}
pageList.put("pageCount", totalPages);
pageList.put("curPage", pageNumber);
pageList.put("rowsCount", totalRecouds);
pageList.put("colList", colList);
pageList.put("dataList", dataList);
// pageList.put("defaultValue", defaultValue);
jsonObject.put("pageList", pageList);
jsonObject.put("error", "null");
jsonObject.put("errorCode", 0);
jsonObject.put("success", true);
return jsonObject.toString();
}
if (jsonparam.equals("市场活动产品组")) {
// 云之家参数解析:
JSONObject yunjsonObj = JSONObject.parseObject(json);
String keyword = yunjsonObj.getString("keyword");// 搜索关键字
Integer pageNumber = Integer.parseInt(yunjsonObj
.getString("curPage"));// 当前页码
StringBuffer sqlcanshuo = new StringBuffer();
if ("".equals(keyword)) {
sqlcanshuo.append(" and 1=1 ");
} else {
sqlcanshuo.append(" and FNAME_L2 like '%" + keyword + "%' ");
;
}
JSONObject jsonObject = new JSONObject();// 最外层json对象
JSONObject pageList = new JSONObject();
// 列名
JSONArray colList = new JSONArray();// id
JSONObject fidColL = new JSONObject();
fidColL.put("colEnName", "id");
JSONObject numberColL = new JSONObject();
numberColL.put("colZhName", "编码");
numberColL.put("widgetType", "textWidget");
numberColL.put("colEnName", "number");
JSONObject nameColL = new JSONObject();
nameColL.put("showName", "true");
nameColL.put("colZhName", "名称");
nameColL.put("widgetType", "textWidget");
nameColL.put("colEnName", "name");
JSONObject sczjColL = new JSONObject();
sczjColL.put("colZhName", "市场总监");
sczjColL.put("widgetType", "personSelectWidget");
sczjColL.put("colEnName", "CFPERSONID");
JSONObject sybfzColL = new JSONObject();
sybfzColL.put("colZhName", "事业部副总");
sybfzColL.put("widgetType", "personSelectWidget");
sybfzColL.put("colEnName", "CFVICEPRESIDENTID");
JSONObject fgfzcColL = new JSONObject();
fgfzcColL.put("colZhName", "分管副总裁");
fgfzcColL.put("widgetType", "personSelectWidget");
fgfzcColL.put("colEnName", "CFUSERID");
JSONObject fgfzColL = new JSONObject();
fgfzColL.put("colZhName", "分管副总");
fgfzColL.put("widgetType", "personSelectWidget");
fgfzColL.put("colEnName", "CFPERSON1ID");
JSONObject sybhgjlColL = new JSONObject();
sybhgjlColL.put("colZhName", "事业部合规经理");
sybhgjlColL.put("widgetType", "personSelectWidget");
sybhgjlColL.put("colEnName", "CFHGBZJLID");
colList.add(fidColL);// id
colList.add(numberColL);// 编码
colList.add(nameColL);// name
colList.add(sczjColL); // 市场总监
colList.add(sybfzColL);// 事业部副总
colList.add(fgfzcColL);// 分管副总裁
colList.add(fgfzColL);// 分管副总
colList.add(sybhgjlColL);// 事业部合规经理
StringBuffer sql = new StringBuffer(
" select count(1) count from CT_BD_ActiveProductGroup where CFYESORNO=1 ");
sql.append(sqlcanshuo);
// 查询总记录数
IRowSet rowcount = SQLFacadeFactory.getLocalInstance(ctx)
.getRowset(sql.toString());
Integer totalRecouds = 0;
try {
while (rowcount.next()) {
totalRecouds = rowcount.getInt("count");
}
} catch (SQLException e1) {
e1.printStackTrace();
}
Integer pageSize = 7; // 每页显示多少条数据
// totalPages 总页数
Integer totalPages = totalRecouds % pageSize == 0 ? totalRecouds
/ pageSize : totalRecouds / pageSize + 1;
// startPage 起始位置
Integer startPage = pageSize * (pageNumber - 1) + 1;
Integer endPage = startPage + pageSize;
// sql 拼接分页
// 查询数据
StringBuffer sqlinfo = new StringBuffer(
" select rownum num ,t.* from CT_BD_ActiveProductGroup t where t.CFYESORNO=1 ");
sqlinfo.append(sqlcanshuo);
String sqlfy = " select a.* from ( " + sqlinfo
+ " ) a where a.num>='" + startPage + "' and a.num<'"
+ endPage + "' ";
IRowSet rowSet = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sqlfy.toString());
net.sf.json.JSONArray dataList = new net.sf.json.JSONArray();
String Id = "";
String FNAME_L2 = "";
String number = "";
String CFPERSONID = "";// 市场总监
String CFVICEPRESIDENTID = "";// 事业部副总
String CFUSERID = "";// 分管副总裁
String CFPERSON1ID = "";// 分管副总
String CFHGBZJLID = "";// 事业部合规经理
try {
while (rowSet.next()) {
Id = rowSet.getString("FID");
FNAME_L2 = rowSet.getString("FNAME_L2");
number = rowSet.getString("Fnumber");
CFPERSONID = rowSet.getString("CFPERSONID");// 市场总监
CFVICEPRESIDENTID = rowSet.getString("CFVICEPRESIDENTID");// 事业部副总
CFUSERID = rowSet.getString("CFUSERID");// 分管副总裁
CFPERSON1ID = rowSet.getString("CFPERSON1ID");// 分管副总
CFHGBZJLID = rowSet.getString("CFHGBZJLID");// 事业部合规经理
JSONObject jsonObj = new JSONObject();
jsonObj.put("id", Id);
jsonObj.put("name", FNAME_L2);
jsonObj.put("number", number);
jsonObj.put("name", FNAME_L2);
// 把eas的人员换成 云之家的人员id
String FXTCFPERSONID = "";
String sqlFXTCFPERSONID = " /*dialect*/ select FXTID from T_PM_EASXTUSERMAP where FPERSONID='"
+ CFPERSONID + "' ";
IRowSet executeSQL = SQLExecutorFactory.getLocalInstance(
ctx, sqlFXTCFPERSONID).executeSQL();
while (executeSQL.next()) {
FXTCFPERSONID = executeSQL.getString("FXTID");// 市场总监
}
String FXTCFVICEPRESIDENTIDD = "";
String sqlFXTCFVICEPRESIDENTIDD = " /*dialect*/ select FXTID from T_PM_EASXTUSERMAP where FPERSONID='"
+ CFVICEPRESIDENTID + "' ";
IRowSet executeSQL2 = SQLExecutorFactory.getLocalInstance(
ctx, sqlFXTCFVICEPRESIDENTIDD).executeSQL();
while (executeSQL2.next()) {
FXTCFVICEPRESIDENTIDD = executeSQL2.getString("FXTID");// 事业部副总
}
String FXTCFUSERID = "";
String sqlCFPERSONID = " /*dialect*/ select FXTID from T_PM_EASXTUSERMAP where FPERSONID='"
+ CFUSERID + "' ";
IRowSet executeSQL3 = SQLExecutorFactory.getLocalInstance(
ctx, sqlCFPERSONID).executeSQL();
while (executeSQL3.next()) {
FXTCFUSERID = executeSQL3.getString("FXTID");// 分管副总裁
}
String FXTCFPERSON1ID = "";
String sqlCFPERSON1ID = " /*dialect*/ select FXTID from T_PM_EASXTUSERMAP where FPERSONID='"
+ CFPERSON1ID + "' ";
IRowSet executeSQL4 = SQLExecutorFactory.getLocalInstance(
ctx, sqlCFPERSON1ID).executeSQL();
while (executeSQL4.next()) {
FXTCFPERSON1ID = executeSQL4.getString("FXTID");// 分管副总
}
String FXTCFHGBZJLID = "";
String sqlCFHGBZJLID = " /*dialect*/ select FXTID from T_PM_EASXTUSERMAP where FPERSONID='"
+ CFHGBZJLID + "' ";
IRowSet executeSQL5 = SQLExecutorFactory.getLocalInstance(
ctx, sqlCFHGBZJLID).executeSQL();
while (executeSQL5.next()) {
FXTCFHGBZJLID = executeSQL5.getString("FXTID");// 事业部合规经理
}
/*
* String CFPERSONID = "";//市场总监 String CFVICEPRESIDENTID =
* "";//事业部副总 String CFUSERID = "";//分管副总裁 String
* CFPERSON1ID = "";//分管副总 String CFHGBZJLID = "";//事业部合规经理
*/
ArrayList peCFPERSONID = new ArrayList();
peCFPERSONID.add(FXTCFPERSONID);// 市场总监
ArrayList peCFVICEPRESIDENTID = new ArrayList();
peCFVICEPRESIDENTID.add(FXTCFVICEPRESIDENTIDD);// 事业部副总
ArrayList peCFUSERID = new ArrayList();
peCFUSERID.add(FXTCFUSERID); // 分管副总裁
ArrayList peCFPERSON1ID = new ArrayList();
peCFPERSON1ID.add(FXTCFPERSON1ID); // 分管副总
ArrayList peCFHGBZJLID = new ArrayList();
peCFHGBZJLID.add(FXTCFHGBZJLID); // 事业部合规经理
if (null != FXTCFPERSONID && !"".equals(FXTCFPERSONID)) {
jsonObj.put("CFPERSONID", peCFPERSONID); // 市场总监
}
if (null != FXTCFVICEPRESIDENTIDD
&& !"".equals(FXTCFVICEPRESIDENTIDD)) {
jsonObj.put("CFVICEPRESIDENTID", peCFVICEPRESIDENTID); // 事业部副总
}
if (null != FXTCFUSERID && !"".equals(FXTCFUSERID)) {
jsonObj.put("CFUSERID", peCFUSERID); // 分管副总裁
}
if (null != FXTCFPERSON1ID && !"".equals(FXTCFPERSON1ID)) {
jsonObj.put("CFPERSON1ID", peCFPERSON1ID); // 分管副总
}
if (null != FXTCFHGBZJLID && !"".equals(FXTCFHGBZJLID)) {
jsonObj.put("CFHGBZJLID", peCFHGBZJLID);// 事业部合规经理
}
dataList.add(jsonObj);
}
} catch (SQLException e) {
e.printStackTrace();
}
pageList.put("pageCount", totalPages);
pageList.put("curPage", pageNumber);
pageList.put("rowsCount", totalRecouds);
pageList.put("colList", colList);
pageList.put("dataList", dataList);
// pageList.put("defaultValue", defaultValue);
jsonObject.put("pageList", pageList);
jsonObject.put("error", "null");
jsonObject.put("errorCode", 0);
jsonObject.put("success", true);
return jsonObject.toString();
}
if (jsonparam.equals("获取公司组织信息")) {
// 云之家参数解析:
JSONObject yunjsonObj = JSONObject.parseObject(json);
String keyword = yunjsonObj.getString("keyword");// 搜索关键字
Integer pageNumber = Integer.parseInt(yunjsonObj
.getString("curPage"));// 当前页码
StringBuffer sqlcanshuo = new StringBuffer();
if ("".equals(keyword)) {
sqlcanshuo.append(" where 1=1 ");
;
} else {
sqlcanshuo.append(" where FNAME_L2 like '%" + keyword + "%' ");
;
}
JSONObject jsonObject = new JSONObject();// 最外层json对象
JSONObject pageList = new JSONObject();
// 列名
JSONArray colList = new JSONArray();// id
JSONObject fidColL = new JSONObject();
fidColL.put("colEnName", "id");
JSONObject nameColL = new JSONObject();
nameColL.put("showName", "true");
nameColL.put("colZhName", "公司名称");
nameColL.put("widgetType", "textWidget");
nameColL.put("colEnName", "name");
colList.add(fidColL);
colList.add(nameColL);
StringBuffer sql = new StringBuffer(
" select count(1) count from T_ORG_Company ");
sql.append(sqlcanshuo);
// 查询总记录数
IRowSet rowcount = SQLFacadeFactory.getLocalInstance(ctx)
.getRowset(sql.toString());
Integer totalRecouds = 0;
try {
while (rowcount.next()) {
totalRecouds = rowcount.getInt("count");
}
} catch (SQLException e1) {
e1.printStackTrace();
}
Integer pageSize = 7; // 每页显示多少条数据
// totalPages 总页数
Integer totalPages = totalRecouds % pageSize == 0 ? totalRecouds
/ pageSize : totalRecouds / pageSize + 1;
// startPage 起始位置
Integer startPage = pageSize * (pageNumber - 1) + 1;
Integer endPage = startPage + pageSize;
// sql 拼接分页
// 查询数据
StringBuffer sqlinfo = new StringBuffer(
" select rownum num ,t.* from T_ORG_Company t ");
sqlinfo.append(sqlcanshuo);
String sqlfy = " select a.* from ( " + sqlinfo
+ " ) a where a.num>='" + startPage + "' and a.num<'"
+ endPage + "' ";
IRowSet rowSet = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sqlfy.toString());
net.sf.json.JSONArray dataList = new net.sf.json.JSONArray();
String Id = "";
String FNAME_L2 = "";
try {
while (rowSet.next()) {
Id = rowSet.getString("FID");
FNAME_L2 = rowSet.getString("FNAME_L2");
JSONObject jsonObj = new JSONObject();
jsonObj.put("id", Id);
jsonObj.put("name", FNAME_L2);
dataList.add(jsonObj);
}
} catch (SQLException e) {
e.printStackTrace();
}
pageList.put("pageCount", totalPages);
pageList.put("curPage", pageNumber);
pageList.put("rowsCount", totalRecouds);
pageList.put("colList", colList);
pageList.put("dataList", dataList);
// pageList.put("defaultValue", defaultValue);
jsonObject.put("pageList", pageList);
jsonObject.put("error", "null");
jsonObject.put("errorCode", 0);
jsonObject.put("success", true);
return jsonObject.toString();
}
if (jsonparam.equals("会议类型")) {
// 云之家参数解析:
JSONObject yunjsonObj = JSONObject.parseObject(json);
String keyword = yunjsonObj.getString("keyword");// 搜索关键字
Integer pageNumber = Integer.parseInt(yunjsonObj
.getString("curPage"));// 当前页码
StringBuffer sqlcanshuo = new StringBuffer();
if ("".equals(keyword)) {
sqlcanshuo.append(" where 1=1 ");
;
} else {
sqlcanshuo.append(" where FNAME_L2 like '%" + keyword + "%' ");
;
}
JSONObject jsonObject = new JSONObject();// 最外层json对象
JSONObject pageList = new JSONObject();
// 列名
JSONArray colList = new JSONArray();// id
JSONObject fidColL = new JSONObject();
fidColL.put("colEnName", "id");
JSONObject nameColL = new JSONObject();
nameColL.put("showName", "true");
nameColL.put("colZhName", "名称");
nameColL.put("widgetType", "textWidget");
nameColL.put("colEnName", "name");
colList.add(fidColL);
colList.add(nameColL);
StringBuffer sql = new StringBuffer(
" select count(1) count from CT_JIC_MeetingType ");
sql.append(sqlcanshuo);
// 查询总记录数
IRowSet rowcount = SQLFacadeFactory.getLocalInstance(ctx)
.getRowset(sql.toString());
Integer totalRecouds = 0;
try {
while (rowcount.next()) {
totalRecouds = rowcount.getInt("count");
}
} catch (SQLException e1) {
e1.printStackTrace();
}
Integer pageSize = 7; // 每页显示多少条数据
// totalPages 总页数
Integer totalPages = totalRecouds % pageSize == 0 ? totalRecouds
/ pageSize : totalRecouds / pageSize + 1;
// startPage 起始位置
Integer startPage = pageSize * (pageNumber - 1) + 1;
Integer endPage = startPage + pageSize;
// sql 拼接分页
// 查询数据
StringBuffer sqlinfo = new StringBuffer(
" select rownum num ,t.* from CT_JIC_MeetingType t ");
sqlinfo.append(sqlcanshuo);
String sqlfy = " select a.* from ( " + sqlinfo
+ " ) a where a.num>='" + startPage + "' and a.num<'"
+ endPage + "' ";
IRowSet rowSet = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sqlfy.toString());
net.sf.json.JSONArray dataList = new net.sf.json.JSONArray();
String Id = "";
String FNAME_L2 = "";
try {
while (rowSet.next()) {
Id = rowSet.getString("FID");
FNAME_L2 = rowSet.getString("FNAME_L2");
JSONObject jsonObj = new JSONObject();
jsonObj.put("id", Id);
jsonObj.put("name", FNAME_L2);
dataList.add(jsonObj);
}
} catch (SQLException e) {
e.printStackTrace();
}
pageList.put("pageCount", totalPages);
pageList.put("curPage", pageNumber);
pageList.put("rowsCount", totalRecouds);
pageList.put("colList", colList);
pageList.put("dataList", dataList);
// pageList.put("defaultValue", defaultValue);
jsonObject.put("pageList", pageList);
jsonObject.put("error", "null");
jsonObject.put("errorCode", 0);
jsonObject.put("success", true);
return jsonObject.toString();
}
if (jsonparam.equals("获取项目基本信息")) {
// 云之家参数解析:
JSONObject yunjsonObj = JSONObject.parseObject(json);
String keyword = yunjsonObj.getString("keyword");// 搜索关键字
Integer pageNumber = Integer.parseInt(yunjsonObj
.getString("curPage"));// 当前页码
StringBuffer sqlcanshuo = new StringBuffer();
if ("".equals(keyword)) {
sqlcanshuo.append(" where 1=1 ");
;
} else {
sqlcanshuo.append(" where FNAME_L2 like '%" + keyword + "%' ");
;
}
JSONObject jsonObject = new JSONObject();// 最外层json对象
JSONObject pageList = new JSONObject();
// 列名
JSONArray colList = new JSONArray();// id
JSONObject fidColL = new JSONObject();
fidColL.put("colEnName", "id");
JSONObject numberColL = new JSONObject();
numberColL.put("colZhName", "编码");
numberColL.put("widgetType", "textWidget");
numberColL.put("colEnName", "number");
JSONObject nameColL = new JSONObject();
nameColL.put("showName", "true");
nameColL.put("colZhName", "名称");
nameColL.put("widgetType", "textWidget");
nameColL.put("colEnName", "name");
JSONObject projectPersonColL = new JSONObject();
projectPersonColL.put("colZhName", "项目经理");
projectPersonColL.put("widgetType", "personSelectWidget");
projectPersonColL.put("colEnName", "projectPerson");
colList.add(fidColL);
colList.add(numberColL);
colList.add(nameColL);
colList.add(projectPersonColL);
StringBuffer sql = new StringBuffer(
" select count(1) count from CT_PRB_Probaseinfo ");
sql.append(sqlcanshuo);
// 查询总记录数
IRowSet rowcount = SQLFacadeFactory.getLocalInstance(ctx)
.getRowset(sql.toString());
Integer totalRecouds = 0;
try {
while (rowcount.next()) {
totalRecouds = rowcount.getInt("count");
}
} catch (SQLException e1) {
e1.printStackTrace();
}
Integer pageSize = 7; // 每页显示多少条数据
// totalPages 总页数
Integer totalPages = totalRecouds % pageSize == 0 ? totalRecouds
/ pageSize : totalRecouds / pageSize + 1;
// startPage 起始位置
Integer startPage = pageSize * (pageNumber - 1) + 1;
Integer endPage = startPage + pageSize;
// sql 拼接分页
// 查询数据
StringBuffer sqlinfo = new StringBuffer(
" select rownum num ,t.* from CT_PRB_Probaseinfo t ");
sqlinfo.append(sqlcanshuo);
String sqlfy = " select a.* from ( " + sqlinfo
+ " ) a where a.num>='" + startPage + "' and a.num<'"
+ endPage + "' ";
IRowSet rowSet = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sqlfy.toString());
net.sf.json.JSONArray dataList = new net.sf.json.JSONArray();
String Id = "";
String FNAME_L2 = "";
String number = "";
String projectPerson = "";
try {
while (rowSet.next()) {
Id = rowSet.getString("FID");
FNAME_L2 = rowSet.getString("FNAME_L2");
number = rowSet.getString("FNUMBER");
projectPerson = rowSet.getString("CFPROMANAGERID");
JSONObject jsonObj = new JSONObject();
jsonObj.put("id", Id);
jsonObj.put("number", number);
jsonObj.put("name", FNAME_L2);
// 把eas的人员换成 云之家的人员id
String FXTCFPERSONID = "";
String sqlFXTCFPERSONID = " /*dialect*/ select FXTID from T_PM_EASXTUSERMAP where FPERSONID= " +
"( select CFPROEMPLOYERNUMID from CT_PRB_Promember where fid ='"+projectPerson+"' ) ";
IRowSet executeSQL = SQLExecutorFactory.getLocalInstance(
ctx, sqlFXTCFPERSONID).executeSQL();
while (executeSQL.next()) {
FXTCFPERSONID = executeSQL.getString("FXTID");
}
ArrayList peCFHGBZJLID = new ArrayList();
peCFHGBZJLID.add(FXTCFPERSONID);
if (null != FXTCFPERSONID && !"".equals(FXTCFPERSONID)) {
jsonObj.put("projectPerson", peCFHGBZJLID);
}
dataList.add(jsonObj);
}
} catch (SQLException e) {
e.printStackTrace();
}
pageList.put("pageCount", totalPages);
pageList.put("curPage", pageNumber);
pageList.put("rowsCount", totalRecouds);
pageList.put("colList", colList);
pageList.put("dataList", dataList);
// pageList.put("defaultValue", defaultValue);
jsonObject.put("pageList", pageList);
jsonObject.put("error", "null");
jsonObject.put("errorCode", 0);
jsonObject.put("success", true);
return jsonObject.toString();
}
if (jsonparam.equals("样品送检项目信息")) {
// 云之家参数解析:
JSONObject yunjsonObj = JSONObject.parseObject(json);
String keyword = yunjsonObj.getString("keyword");// 搜索关键字
Integer pageNumber = Integer.parseInt(yunjsonObj
.getString("curPage"));// 当前页码
StringBuffer sqlcanshuo = new StringBuffer();
if ("".equals(keyword)) {
sqlcanshuo.append(" where 1=1 ");
;
} else {
sqlcanshuo.append(" where FNAME_L2 like '%" + keyword + "%' ");
;
}
JSONObject jsonObject = new JSONObject();// 最外层json对象
JSONObject pageList = new JSONObject();
// 列名
JSONArray colList = new JSONArray();// id
JSONObject fidColL = new JSONObject();
fidColL.put("colEnName", "id");
JSONObject numberColL = new JSONObject();
numberColL.put("colZhName", "编码");
numberColL.put("widgetType", "textWidget");
numberColL.put("colEnName", "number");
// JSONObject nameColL = new JSONObject();
// nameColL.put("showName", "true");
// nameColL.put("colZhName", "名称");
// nameColL.put("widgetType", "textWidget");
// nameColL.put("colEnName", "name");
//
JSONObject xmhColL = new JSONObject();
xmhColL.put("colZhName", "项目号");
xmhColL.put("widgetType", "textWidget");
xmhColL.put("colEnName", "name");
JSONObject jcxmColL = new JSONObject();
jcxmColL.put("showName", "true");
jcxmColL.put("colZhName", "检查项目");
jcxmColL.put("widgetType", "textWidget");
jcxmColL.put("colEnName", "jcxm");
JSONObject fyColL = new JSONObject();
fyColL.put("colZhName", "费用");
fyColL.put("widgetType", "textWidget");
fyColL.put("colEnName", "fy");
JSONObject jcgsColL = new JSONObject();
jcgsColL.put("colZhName", "检测公司");
jcgsColL.put("widgetType", "textWidget");
jcgsColL.put("colEnName", "jcgs");
JSONObject jjColL = new JSONObject();
jjColL.put("colZhName", "加急");
jjColL.put("widgetType", "textWidget");
jjColL.put("colEnName", "jj");
JSONObject sbColL = new JSONObject();
sbColL.put("colZhName", "申报");
sbColL.put("widgetType", "textWidget");
sbColL.put("colEnName", "sb");
colList.add(fidColL);
//colList.add(nameColL);
colList.add(numberColL);
colList.add(xmhColL);
colList.add(jcxmColL);
colList.add(fyColL);
colList.add(jcgsColL);
colList.add(jjColL);
colList.add(sbColL);
StringBuffer sql = new StringBuffer(
" select count(1) count from CT_WFM_YPSJXM ");
sql.append(sqlcanshuo);
// 查询总记录数
IRowSet rowcount = SQLFacadeFactory.getLocalInstance(ctx)
.getRowset(sql.toString());
Integer totalRecouds = 0;
try {
while (rowcount.next()) {
totalRecouds = rowcount.getInt("count");
}
} catch (SQLException e1) {
e1.printStackTrace();
}
Integer pageSize = 7; // 每页显示多少条数据
// totalPages 总页数
Integer totalPages = totalRecouds % pageSize == 0 ? totalRecouds
/ pageSize : totalRecouds / pageSize + 1;
// startPage 起始位置
Integer startPage = pageSize * (pageNumber - 1) + 1;
Integer endPage = startPage + pageSize;
// sql 拼接分页
// 查询数据
StringBuffer sqlinfo = new StringBuffer(
" select rownum num ,t.* from CT_WFM_YPSJXM t ");
sqlinfo.append(sqlcanshuo);
String sqlfy = " select a.* from ( " + sqlinfo
+ " ) a where a.num>='" + startPage + "' and a.num<'"
+ endPage + "' ";
IRowSet rowSet = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sqlfy.toString());
net.sf.json.JSONArray dataList = new net.sf.json.JSONArray();
String Id = "";
String FNUMBER = "";//编码
String FNAME_L2 = "";//项目号
String FSIMPLENAME = "";//检查项目
String CFKDTEXTFIELD = "";//费用
String CFKDTEXTFIELD1 = "";//检测公司
String CFKDCHECKBOX1 = "";//加急
String CFKDCHECKBOX= "";//申报
try {
while (rowSet.next()) {
Id = rowSet.getString("FID");
FNUMBER = rowSet.getString("FNUMBER");
FNAME_L2 = rowSet.getString("FNAME_L2");
FSIMPLENAME = rowSet.getString("FSIMPLENAME");
CFKDTEXTFIELD = rowSet.getString("CFKDTEXTFIELD");
CFKDTEXTFIELD1 = rowSet.getString("CFKDTEXTFIELD1");
CFKDCHECKBOX = rowSet.getString("CFKDCHECKBOX");
CFKDCHECKBOX1 = rowSet.getString("CFKDCHECKBOX1");
JSONObject jsonObj = new JSONObject();
jsonObj.put("id", Id);
// jsonObj.put("name", FNAME_L2);
jsonObj.put("number", FNUMBER);//编码
jsonObj.put("name", FNAME_L2);//项目号
jsonObj.put("jcxm", FSIMPLENAME);//检查项目
jsonObj.put("fy", CFKDTEXTFIELD);//费用
if(CFKDTEXTFIELD1==null||CFKDTEXTFIELD1.equals(null)){
CFKDTEXTFIELD1="";
}
jsonObj.put("jcgs", CFKDTEXTFIELD1);//检测公司
if(CFKDCHECKBOX.equals("1")){
CFKDCHECKBOX="是";
}else{
CFKDCHECKBOX="否";
}
if(CFKDCHECKBOX1.equals("1")){
CFKDCHECKBOX1="是";
}else{
CFKDCHECKBOX1="否";
}
jsonObj.put("jj", CFKDCHECKBOX1);//加急
jsonObj.put("sb", CFKDCHECKBOX);//申报
dataList.add(jsonObj);
}
} catch (SQLException e) {
e.printStackTrace();
}
pageList.put("pageCount", totalPages);
pageList.put("curPage", pageNumber);
pageList.put("rowsCount", totalRecouds);
pageList.put("colList", colList);
pageList.put("dataList", dataList);
// pageList.put("defaultValue", defaultValue);
jsonObject.put("pageList", pageList);
jsonObject.put("error", "null");
jsonObject.put("errorCode", 0);
jsonObject.put("success", true);
return jsonObject.toString();
}
if(jsonparam.equals("OEA项目立项获取上级")){
// 云之家参数解析:
JSONObject yunjsonObj = JSONObject.parseObject(json);
String codeId = yunjsonObj.getString("codeId");
String groupCode = yunjsonObj.getString("groupCode");
String groupDeptCode = yunjsonObj.getString("groupDeptCode");
JSONObject _S_APPLY = yunjsonObj.getJSONObject("data")
.getJSONObject("formInfo").getJSONObject("widgetMap")
.getJSONObject(groupCode );//组长
JSONObject personInfo = (JSONObject) _S_APPLY.getJSONArray(
"personInfo").get(0);
String userId = personInfo.getString("oid");// 组长云之家id
JSONObject _S_DEPT = yunjsonObj.getJSONObject("data")
.getJSONObject("formInfo").getJSONObject("widgetMap")
.getJSONObject(groupDeptCode);//组长部门
JSONObject deptInfo = _S_DEPT.getJSONArray("deptInfo")
.getJSONObject(0);
String orgId = deptInfo.getString("orgId");///组长部门云之家id
//userId ="5f5ae94cd5de03577719fa31";
//orgId="b160b456-bf9d-4e90-a4e7-73e53f45835b";
String EASORGID = "";
String PERSONID = "";
String sqldept = " select FEASORGID from T_PM_EASXTORGMAP where FXTORGID= '"
+ orgId + "' ";
String sqlPerson = " select FPERSONID from T_PM_EASXTUSERMAP where FXTID='"
+ userId + "' ";
IRowSet deptRs = SQLExecutorFactory.getLocalInstance(ctx, sqldept)
.executeSQL();
try {
while (deptRs.next()) {
EASORGID = deptRs.getString("FEASORGID");
}
} catch (SQLException e2) {
e2.printStackTrace();
}
IRowSet personRs = SQLExecutorFactory.getLocalInstance(ctx,
sqlPerson).executeSQL();
try {
while (personRs.next()) {
PERSONID = personRs.getString("FPERSONID");
}
} catch (SQLException e2) {
e2.printStackTrace();
}
StringBuffer sqlcanshuo = new StringBuffer();
String sqlzw = " select * from T_PM_EASXTUSERMAP where FPERSONID in (select Fpersonid from T_ORG_PositionMember where Fpositionid in (select Fparentid from T_ORG_PositionHierarchy where Fchildid in (SELECT a.fid FROM T_ORG_Position a LEFT JOIN T_ORG_PositionMember b on a.fid = b.FPOSITIONID where b.FPERSONID = '"
+ PERSONID
+ "' and a.FADMINORGUNITID = '"
+ EASORGID
+ "'))) ";
IRowSet rowSet = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sqlzw);
net.sf.json.JSONArray dataList = new net.sf.json.JSONArray();
String Id = "";
String FNAME_L2 = "";
ArrayList pe = new ArrayList();
try {
if (rowSet.next()) {
Id = rowSet.getString("FXTID");
if (null != Id && !"".equals(Id)) {
pe.add(Id);
}
}
} catch (SQLException e) {
e.printStackTrace();
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("success", true);
jsonObject.put("error", null);
JSONObject data = new JSONObject();
JSONObject widgetValue = new JSONObject();
widgetValue.put(codeId, pe);
data.put("widgetValue", widgetValue);
jsonObject.put("data", data);
return jsonObject.toJSONString();
}
if (jsonparam.equals("根据提交人获取上级")) {
// 云之家参数解析:
JSONObject yunjsonObj = JSONObject.parseObject(json);
String codeId = yunjsonObj.getString("codeId");
JSONObject _S_APPLY = yunjsonObj.getJSONObject("data")
.getJSONObject("formInfo").getJSONObject("widgetMap")
.getJSONObject("_S_APPLY");
JSONObject personInfo = (JSONObject) _S_APPLY.getJSONArray(
"personInfo").get(0);
String userId = personInfo.getString("oid");// 云之家申请人id
JSONObject _S_DEPT = yunjsonObj.getJSONObject("data")
.getJSONObject("formInfo").getJSONObject("widgetMap")
.getJSONObject("_S_DEPT");
JSONObject deptInfo = _S_DEPT.getJSONArray("deptInfo")
.getJSONObject(0);
String orgId = deptInfo.getString("orgId");// 申请人部门云之家id
//userId ="5f5ae94cd5de03577719fa31";
//orgId="b160b456-bf9d-4e90-a4e7-73e53f45835b";
String EASORGID = "";
String PERSONID = "";
String sqldept = " select FEASORGID from T_PM_EASXTORGMAP where FXTORGID= '"
+ orgId + "' ";
String sqlPerson = " select FPERSONID from T_PM_EASXTUSERMAP where FXTID='"
+ userId + "' ";
IRowSet deptRs = SQLExecutorFactory.getLocalInstance(ctx, sqldept)
.executeSQL();
try {
while (deptRs.next()) {
EASORGID = deptRs.getString("FEASORGID");
}
} catch (SQLException e2) {
e2.printStackTrace();
}
IRowSet personRs = SQLExecutorFactory.getLocalInstance(ctx,
sqlPerson).executeSQL();
try {
while (personRs.next()) {
PERSONID = personRs.getString("FPERSONID");
}
} catch (SQLException e2) {
e2.printStackTrace();
}
StringBuffer sqlcanshuo = new StringBuffer();
String sqlzw = " select * from T_PM_EASXTUSERMAP where FPERSONID in (select Fpersonid from T_ORG_PositionMember where Fpositionid in (select Fparentid from T_ORG_PositionHierarchy where Fchildid in (SELECT a.fid FROM T_ORG_Position a LEFT JOIN T_ORG_PositionMember b on a.fid = b.FPOSITIONID where b.FPERSONID = '"
+ PERSONID
+ "' and a.FADMINORGUNITID = '"
+ EASORGID
+ "'))) ";
IRowSet rowSet = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sqlzw);
net.sf.json.JSONArray dataList = new net.sf.json.JSONArray();
String Id = "";
String FNAME_L2 = "";
ArrayList pe = new ArrayList();
try {
if (rowSet.next()) {
Id = rowSet.getString("FXTID");
if (null != Id && !"".equals(Id)) {
pe.add(Id);
}
}
} catch (SQLException e) {
e.printStackTrace();
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("success", true);
jsonObject.put("error", null);
JSONObject data = new JSONObject();
JSONObject widgetValue = new JSONObject();
widgetValue.put(codeId, pe);
data.put("widgetValue", widgetValue);
jsonObject.put("data", data);
return jsonObject.toJSONString();
}
if (jsonparam.equals("根据提交人获取上上级")) {
// 云之家参数解析:
JSONObject yunjsonObj = JSONObject.parseObject(json);
String codeId = yunjsonObj.getString("codeId");
JSONObject _S_APPLY = yunjsonObj.getJSONObject("data")
.getJSONObject("formInfo").getJSONObject("widgetMap")
.getJSONObject("_S_APPLY");
JSONObject personInfo = (JSONObject) _S_APPLY.getJSONArray(
"personInfo").get(0);
String userId = personInfo.getString("oid");// 云之家申请人id
JSONObject _S_DEPT = yunjsonObj.getJSONObject("data")
.getJSONObject("formInfo").getJSONObject("widgetMap")
.getJSONObject("_S_DEPT");
JSONObject deptInfo = _S_DEPT.getJSONArray("deptInfo")
.getJSONObject(0);
String orgId = deptInfo.getString("orgId");// 申请人部门id
String EASORGID = "";
String PERSONID = "";
String sqldept = " select FEASORGID from T_PM_EASXTORGMAP where FXTORGID= '"
+ orgId + "' ";
String sqlPerson = " select FPERSONID from T_PM_EASXTUSERMAP where FXTID='"
+ userId + "' ";
IRowSet deptRs = SQLExecutorFactory.getLocalInstance(ctx, sqldept)
.executeSQL();
try {
while (deptRs.next()) {
EASORGID = deptRs.getString("FEASORGID");
}
} catch (SQLException e2) {
e2.printStackTrace();
}
IRowSet personRs = SQLExecutorFactory.getLocalInstance(ctx,
sqlPerson).executeSQL();
try {
while (personRs.next()) {
PERSONID = personRs.getString("FPERSONID");
}
} catch (SQLException e2) {
e2.printStackTrace();
}
StringBuffer sqlcanshuo = new StringBuffer();
String sqlzw = " select * from T_PM_EASXTUSERMAP where FPERSONID in ( select Fpersonid from T_ORG_PositionMember where Fpositionid in "
+ "(select Fparentid from T_ORG_PositionHierarchy where Fchildid in "
+ "(select Fparentid from T_ORG_PositionHierarchy where Fchildid in "
+ "(SELECT a.fid FROM T_ORG_Position a LEFT JOIN T_ORG_PositionMember b on a.fid = b.FPOSITIONID "
+ "where b.FPERSONID = '"
+ PERSONID
+ "' and a.FADMINORGUNITID = '"
+ EASORGID
+ "'))) ) ";
IRowSet rowSet = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sqlzw);
net.sf.json.JSONArray dataList = new net.sf.json.JSONArray();
String Id = "";
String FNAME_L2 = "";
ArrayList pe = new ArrayList();
try {
if (rowSet.next()) {
Id = rowSet.getString("FXTID");
if (null != Id && !"".equals(Id)) {
if(Id.equals("5f5ae94cd5de03577719f99a")){
//间接领导 -吴世斌 ,就把直接领导赋值给吴世斌。//5f5ae94cd5de03577719f99a --5f5ae94cd5de03577719f9bf
String sqlzw2 = " select * from T_PM_EASXTUSERMAP where FPERSONID in (select Fpersonid from T_ORG_PositionMember where Fpositionid in (select Fparentid from T_ORG_PositionHierarchy where Fchildid in (SELECT a.fid FROM T_ORG_Position a LEFT JOIN T_ORG_PositionMember b on a.fid = b.FPOSITIONID where b.FPERSONID = '"
+ PERSONID
+ "' and a.FADMINORGUNITID = '"
+ EASORGID
+ "'))) ";
IRowSet rowSet2 = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sqlzw2);
net.sf.json.JSONArray dataList2 = new net.sf.json.JSONArray();
String Id2 = "";
if (rowSet2.next()) {
Id2 = rowSet2.getString("FXTID");
if (null != Id2 && !"".equals(Id2)) {
pe.add(Id2);
}
}
}else{
pe.add(Id);
}
}
}
} catch (SQLException e) {
e.printStackTrace();
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("success", true);
jsonObject.put("error", null);
JSONObject data = new JSONObject();
JSONObject widgetValue = new JSONObject();
widgetValue.put(codeId, pe);
data.put("widgetValue", widgetValue);
jsonObject.put("data", data);
// String str =
// JSONObject.toJSONString(jsonObject,SerializerFeature.
// WriteMapNullValue);
return jsonObject.toJSONString();
}
// 获取行名行号
if (jsonparam.equals("获取行名行号")) {
// 云之家参数解析:
JSONObject yunjsonObj = JSONObject.parseObject(json);
String keyword = yunjsonObj.getString("keyword");// 搜索关键字
Integer pageNumber = Integer.parseInt(yunjsonObj
.getString("curPage"));// 当前页码
StringBuffer sqlcanshuo = new StringBuffer();
if ("".equals(keyword)) {
sqlcanshuo.append(" where 1=1 ");
;
} else {
sqlcanshuo.append(" where FNAME_L2 like '%" + keyword + "%' ");
;
}
JSONObject jsonObject = new JSONObject();// 最外层json对象
JSONObject pageList = new JSONObject();
// 列名
JSONArray colList = new JSONArray();// id
JSONObject fidColL = new JSONObject();
fidColL.put("colEnName", "id");
JSONObject nameColL = new JSONObject();
nameColL.put("showName", "true");
nameColL.put("colZhName", "银行名称");
nameColL.put("widgetType", "textWidget");
nameColL.put("colEnName", "name");
colList.add(fidColL);
colList.add(nameColL);
StringBuffer sql = new StringBuffer(
" select count(1) count from T_BE_BEBank ");
sql.append(sqlcanshuo);
// 查询总记录数
IRowSet rowcount = SQLFacadeFactory.getLocalInstance(ctx)
.getRowset(sql.toString());
Integer totalRecouds = 0;
try {
while (rowcount.next()) {
totalRecouds = rowcount.getInt("count");
}
} catch (SQLException e1) {
e1.printStackTrace();
}
Integer pageSize = 7; // 每页显示多少条数据
// totalPages 总页数
Integer totalPages = totalRecouds % pageSize == 0 ? totalRecouds
/ pageSize : totalRecouds / pageSize + 1;
// startPage 起始位置
Integer startPage = pageSize * (pageNumber - 1) + 1;
Integer endPage = startPage + pageSize;
// sql 拼接分页
// 查询数据
StringBuffer sqlinfo = new StringBuffer(
" select rownum num ,t.* from T_BE_BEBank t ");
sqlinfo.append(sqlcanshuo);
String sqlfy = " select a.* from ( " + sqlinfo
+ " ) a where a.num>='" + startPage + "' and a.num<'"
+ endPage + "' ";
IRowSet rowSet = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sqlfy.toString());
net.sf.json.JSONArray dataList = new net.sf.json.JSONArray();
String Id = "";
String FNAME_L2 = "";
try {
while (rowSet.next()) {
Id = rowSet.getString("FID");
FNAME_L2 = rowSet.getString("FNAME_L2");
JSONObject jsonObj = new JSONObject();
jsonObj.put("id", Id);
jsonObj.put("name", FNAME_L2);
dataList.add(jsonObj);
}
} catch (SQLException e) {
e.printStackTrace();
}
pageList.put("pageCount", totalPages);
pageList.put("curPage", pageNumber);
pageList.put("rowsCount", totalRecouds);
pageList.put("colList", colList);
pageList.put("dataList", dataList);
// pageList.put("defaultValue", defaultValue);
jsonObject.put("pageList", pageList);
jsonObject.put("error", "null");
jsonObject.put("errorCode", 0);
jsonObject.put("success", true);
return jsonObject.toString();
}
if (jsonparam.equals("记账分类")) {
// 云之家参数解析:
JSONObject yunjsonObj = JSONObject.parseObject(json);
String keyword = yunjsonObj.getString("keyword");// 搜索关键字
Integer pageNumber = Integer.parseInt(yunjsonObj
.getString("curPage"));// 当前页码
String fpCompanyId="mEcAAAAAA+/M567U";
if(yunjsonObj.getJSONObject("basicFormInfo").getJSONArray("iw_8")==null){
}else{
JSONObject iw_8 = (JSONObject) yunjsonObj.getJSONObject("basicFormInfo").getJSONArray("iw_8").getJSONObject(0);
fpCompanyId = iw_8.getString("id");//分配公司id
}
StringBuffer sqlcanshuo = new StringBuffer();
if ("".equals(keyword)) {
sqlcanshuo.append(" where 1=1 and FCURRENCYCOMPANY ='"+fpCompanyId+"' and FTYPELINK='mEcAAAABRS95h9RO' ");
;
} else {
sqlcanshuo.append(" where FNAME_L2 like '%" + keyword + "%' and FCURRENCYCOMPANY ='"+fpCompanyId+"' and FTYPELINK='mEcAAAABRS95h9RO' " );
;
}
JSONObject jsonObject = new JSONObject();// 最外层json对象
JSONObject pageList = new JSONObject();
// 列名
JSONArray colList = new JSONArray();// id
JSONObject fidColL = new JSONObject();
fidColL.put("colEnName", "id");
JSONObject numberColL = new JSONObject();
numberColL.put("colZhName", "编码");
numberColL.put("widgetType", "textWidget");
numberColL.put("colEnName", "number");
JSONObject nameColL = new JSONObject();
nameColL.put("showName", "true");
nameColL.put("colZhName", "名称");
nameColL.put("widgetType", "textWidget");
nameColL.put("colEnName", "name");
colList.add(fidColL);
colList.add(numberColL);
colList.add(nameColL);
StringBuffer sql = new StringBuffer(
" select count(1) count from T_BD_KAClassfication ");
sql.append(sqlcanshuo);
// 查询总记录数
IRowSet rowcount = SQLFacadeFactory.getLocalInstance(ctx)
.getRowset(sql.toString());
Integer totalRecouds = 0;
try {
while (rowcount.next()) {
totalRecouds = rowcount.getInt("count");
}
} catch (SQLException e1) {
e1.printStackTrace();
}
Integer pageSize = 7; // 每页显示多少条数据
// totalPages 总页数
Integer totalPages = totalRecouds % pageSize == 0 ? totalRecouds
/ pageSize : totalRecouds / pageSize + 1;
// startPage 起始位置
Integer startPage = pageSize * (pageNumber - 1) + 1;
Integer endPage = startPage + pageSize;
// sql 拼接分页
// 查询数据
StringBuffer sqlinfo = new StringBuffer(
" select rownum num ,t.* from T_BD_KAClassfication t ");
sqlinfo.append(sqlcanshuo);
String sqlfy = " select a.* from ( " + sqlinfo
+ " ) a where a.num>='" + startPage + "' and a.num<'"
+ endPage + "' ";
IRowSet rowSet = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sqlfy.toString());
net.sf.json.JSONArray dataList = new net.sf.json.JSONArray();
String Id = "";
String FNAME_L2 = "";
String number = "";
try {
while (rowSet.next()) {
Id = rowSet.getString("FID");
FNAME_L2 = rowSet.getString("FNAME_L2");
number = rowSet.getString("Fnumber");
JSONObject jsonObj = new JSONObject();
jsonObj.put("id", Id);
jsonObj.put("number", number);
jsonObj.put("name", FNAME_L2);
dataList.add(jsonObj);
}
} catch (SQLException e) {
e.printStackTrace();
}
pageList.put("pageCount", totalPages);
pageList.put("curPage", pageNumber);
pageList.put("rowsCount", totalRecouds);
pageList.put("colList", colList);
pageList.put("dataList", dataList);
// pageList.put("defaultValue", defaultValue);
jsonObject.put("pageList", pageList);
jsonObject.put("error", "null");
jsonObject.put("errorCode", 0);
jsonObject.put("success", true);
return jsonObject.toString();
}
if (jsonparam.equals("要素费用")) {
// 云之家参数解析:
JSONObject yunjsonObj = JSONObject.parseObject(json);
String keyword = yunjsonObj.getString("keyword");// 搜索关键字
Integer pageNumber = Integer.parseInt(yunjsonObj
.getString("curPage"));// 当前页码
String fpCompanyId="mEcAAAAAA+/M567U";
if(yunjsonObj.getJSONObject("basicFormInfo").getJSONArray("iw_8")==null){
}else{
JSONObject iw_8 = (JSONObject) yunjsonObj.getJSONObject("basicFormInfo").getJSONArray("iw_8").getJSONObject(0);
fpCompanyId = iw_8.getString("id");//分配公司id
}
StringBuffer sqlcanshuo = new StringBuffer();
if ("".equals(keyword)) {
sqlcanshuo.append(" where 1=1 and fid in ( select FDATABASEDID from T_BD_DataBaseDAssign where FBOSOBJECTTYPE='4A255827' and FASSIGNCUID='"+fpCompanyId+"' ) ");
;
} else {
sqlcanshuo.append(" where FNAME_L2 like '%" + keyword + "%' and fid in ( select FDATABASEDID from T_BD_DataBaseDAssign where FBOSOBJECTTYPE='4A255827' and FASSIGNCUID='"+fpCompanyId+"' ) ");
;
}
JSONObject jsonObject = new JSONObject();// 最外层json对象
JSONObject pageList = new JSONObject();
// 列名
JSONArray colList = new JSONArray();// id
JSONObject fidColL = new JSONObject();
fidColL.put("colEnName", "id");
JSONObject numberColL = new JSONObject();
numberColL.put("colZhName", "编码");
numberColL.put("widgetType", "textWidget");
numberColL.put("colEnName", "number");
JSONObject nameColL = new JSONObject();
nameColL.put("showName", "true");
nameColL.put("colZhName", "名称");
nameColL.put("widgetType", "textWidget");
nameColL.put("colEnName", "name");
colList.add(fidColL);
colList.add(numberColL);
colList.add(nameColL);
StringBuffer sql = new StringBuffer(
" select count(1) count from T_NCM_Expense ");
sql.append(sqlcanshuo);
// 查询总记录数
IRowSet rowcount = SQLFacadeFactory.getLocalInstance(ctx)
.getRowset(sql.toString());
Integer totalRecouds = 0;
try {
while (rowcount.next()) {
totalRecouds = rowcount.getInt("count");
}
} catch (SQLException e1) {
e1.printStackTrace();
}
Integer pageSize = 7; // 每页显示多少条数据
// totalPages 总页数
Integer totalPages = totalRecouds % pageSize == 0 ? totalRecouds
/ pageSize : totalRecouds / pageSize + 1;
// startPage 起始位置
Integer startPage = pageSize * (pageNumber - 1) + 1;
Integer endPage = startPage + pageSize;
// sql 拼接分页
// 查询数据
StringBuffer sqlinfo = new StringBuffer(
" select rownum num ,t.* from T_NCM_Expense t ");
sqlinfo.append(sqlcanshuo);
String sqlfy = " select a.* from ( " + sqlinfo
+ " ) a where a.num>='" + startPage + "' and a.num<'"
+ endPage + "' ";
IRowSet rowSet = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sqlfy.toString());
net.sf.json.JSONArray dataList = new net.sf.json.JSONArray();
String Id = "";
String FNAME_L2 = "";
String number = "";
try {
while (rowSet.next()) {
Id = rowSet.getString("FID");
number = rowSet.getString("Fnumber");
FNAME_L2 = rowSet.getString("FNAME_L2");
JSONObject jsonObj = new JSONObject();
jsonObj.put("id", Id);
jsonObj.put("number", number);
jsonObj.put("name", FNAME_L2);
dataList.add(jsonObj);
}
} catch (SQLException e) {
e.printStackTrace();
}
pageList.put("pageCount", totalPages);
pageList.put("curPage", pageNumber);
pageList.put("rowsCount", totalRecouds);
pageList.put("colList", colList);
pageList.put("dataList", dataList);
// pageList.put("defaultValue", defaultValue);
jsonObject.put("pageList", pageList);
jsonObject.put("error", "null");
jsonObject.put("errorCode", 0);
jsonObject.put("success", true);
return jsonObject.toString();
}
if (jsonparam.equals("成本项目")) {
// 云之家参数解析:
JSONObject yunjsonObj = JSONObject.parseObject(json);
String keyword = yunjsonObj.getString("keyword");// 搜索关键字
Integer pageNumber = Integer.parseInt(yunjsonObj
.getString("curPage"));// 当前页码
String fpCompanyId="mEcAAAAAA+/M567U";
if(yunjsonObj.getJSONObject("basicFormInfo").getJSONArray("iw_8")==null){
}else{
JSONObject iw_8 = (JSONObject) yunjsonObj.getJSONObject("basicFormInfo").getJSONArray("iw_8").getJSONObject(0);
fpCompanyId = iw_8.getString("id");//分配公司id
}
StringBuffer sqlcanshuo = new StringBuffer();
if ("".equals(keyword)) {
sqlcanshuo.append(" where 1=1 and fid in ( select FDATABASEDID from T_BD_DataBaseDAssign where FBOSOBJECTTYPE='548C5A91' and FASSIGNCUID='"+fpCompanyId+"' ) ");
;
} else {
sqlcanshuo.append(" where FNAME_L2 like '%" + keyword + "%' and fid in ( select FDATABASEDID from T_BD_DataBaseDAssign where FBOSOBJECTTYPE='548C5A91' and FASSIGNCUID='"+fpCompanyId+"' ) ");
;
}
JSONObject jsonObject = new JSONObject();// 最外层json对象
JSONObject pageList = new JSONObject();
// 列名
JSONArray colList = new JSONArray();// id
JSONObject fidColL = new JSONObject();
fidColL.put("colEnName", "id");
JSONObject numberColL = new JSONObject();
numberColL.put("colZhName", "编码");
numberColL.put("widgetType", "textWidget");
numberColL.put("colEnName", "number");
JSONObject nameColL = new JSONObject();
nameColL.put("showName", "true");
nameColL.put("colZhName", "名称");
nameColL.put("widgetType", "textWidget");
nameColL.put("colEnName", "name");
colList.add(fidColL);
colList.add(numberColL);
colList.add(nameColL);
StringBuffer sql = new StringBuffer(
" select count(1) count from T_NCM_CostItem ");
sql.append(sqlcanshuo);
// 查询总记录数
IRowSet rowcount = SQLFacadeFactory.getLocalInstance(ctx)
.getRowset(sql.toString());
Integer totalRecouds = 0;
try {
while (rowcount.next()) {
totalRecouds = rowcount.getInt("count");
}
} catch (SQLException e1) {
e1.printStackTrace();
}
Integer pageSize = 7; // 每页显示多少条数据
// totalPages 总页数
Integer totalPages = totalRecouds % pageSize == 0 ? totalRecouds
/ pageSize : totalRecouds / pageSize + 1;
// startPage 起始位置
Integer startPage = pageSize * (pageNumber - 1) + 1;
Integer endPage = startPage + pageSize;
// sql 拼接分页
// 查询数据
StringBuffer sqlinfo = new StringBuffer(
" select rownum num ,t.* from T_NCM_CostItem t ");
sqlinfo.append(sqlcanshuo);
String sqlfy = " select a.* from ( " + sqlinfo
+ " ) a where a.num>='" + startPage + "' and a.num<'"
+ endPage + "' ";
IRowSet rowSet = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sqlfy.toString());
net.sf.json.JSONArray dataList = new net.sf.json.JSONArray();
String Id = "";
String FNAME_L2 = "";
String number = "";
try {
while (rowSet.next()) {
Id = rowSet.getString("FID");
FNAME_L2 = rowSet.getString("FNAME_L2");
number = rowSet.getString("Fnumber");
JSONObject jsonObj = new JSONObject();
jsonObj.put("id", Id);
jsonObj.put("number", number);
jsonObj.put("name", FNAME_L2);
dataList.add(jsonObj);
}
} catch (SQLException e) {
e.printStackTrace();
}
pageList.put("pageCount", totalPages);
pageList.put("curPage", pageNumber);
pageList.put("rowsCount", totalRecouds);
pageList.put("colList", colList);
pageList.put("dataList", dataList);
// pageList.put("defaultValue", defaultValue);
jsonObject.put("pageList", pageList);
jsonObject.put("error", "null");
jsonObject.put("errorCode", 0);
jsonObject.put("success", true);
return jsonObject.toString();
}
if (jsonparam.equals("仓库组织过滤")) {
// 云之家参数解析:
JSONObject yunjsonObj = JSONObject.parseObject(json);
String keyword = yunjsonObj.getString("keyword");// 搜索关键字
Integer pageNumber = Integer.parseInt(yunjsonObj
.getString("curPage"));// 当前页码
String fpCompanyId="mEcAAAAAA+/M567U";
if(yunjsonObj.getJSONObject("basicFormInfo").getJSONArray("iw_8")==null){
}else{
JSONObject iw_8 = (JSONObject) yunjsonObj.getJSONObject("basicFormInfo").getJSONArray("iw_8").getJSONObject(0);
fpCompanyId = iw_8.getString("id");//分配公司id
}
StringBuffer sqlcanshuo = new StringBuffer();
if ("".equals(keyword)) {
sqlcanshuo.append(" where 1=1 and FSTORAGEORGID='"+fpCompanyId+"' ");
;
} else {
sqlcanshuo.append(" where FNAME_L2 like '%" + keyword + "%' and FSTORAGEORGID='"+fpCompanyId+"' ");
;
}
JSONObject jsonObject = new JSONObject();// 最外层json对象
JSONObject pageList = new JSONObject();
// 列名
JSONArray colList = new JSONArray();// id
JSONObject fidColL = new JSONObject();
fidColL.put("colEnName", "id");
JSONObject numberColL = new JSONObject();
numberColL.put("colZhName", "编码");
numberColL.put("widgetType", "textWidget");
numberColL.put("colEnName", "number");
JSONObject nameColL = new JSONObject();
nameColL.put("showName", "true");
nameColL.put("colZhName", "名称");
nameColL.put("widgetType", "textWidget");
nameColL.put("colEnName", "name");
colList.add(fidColL);
colList.add(numberColL);
colList.add(nameColL);
StringBuffer sql = new StringBuffer(
" select count(1) count from T_DB_WAREHOUSE ");
sql.append(sqlcanshuo);
// 查询总记录数
IRowSet rowcount = SQLFacadeFactory.getLocalInstance(ctx)
.getRowset(sql.toString());
Integer totalRecouds = 0;
try {
while (rowcount.next()) {
totalRecouds = rowcount.getInt("count");
}
} catch (SQLException e1) {
e1.printStackTrace();
}
Integer pageSize = 7; // 每页显示多少条数据
// totalPages 总页数
Integer totalPages = totalRecouds % pageSize == 0 ? totalRecouds
/ pageSize : totalRecouds / pageSize + 1;
// startPage 起始位置
Integer startPage = pageSize * (pageNumber - 1) + 1;
Integer endPage = startPage + pageSize;
// sql 拼接分页
// 查询数据
StringBuffer sqlinfo = new StringBuffer(
" select rownum num ,t.* from T_DB_WAREHOUSE t ");
sqlinfo.append(sqlcanshuo);
String sqlfy = " select a.* from ( " + sqlinfo
+ " ) a where a.num>='" + startPage + "' and a.num<'"
+ endPage + "' ";
IRowSet rowSet = SQLFacadeFactory.getLocalInstance(ctx).getRowset(
sqlfy.toString());
net.sf.json.JSONArray dataList = new net.sf.json.JSONArray();
String Id = "";
String FNAME_L2 = "";
String number = "";
try {
while (rowSet.next()) {
Id = rowSet.getString("FID");
FNAME_L2 = rowSet.getString("FNAME_L2");
number = rowSet.getString("Fnumber");
JSONObject jsonObj = new JSONObject();
jsonObj.put("id", Id);
jsonObj.put("number", number);
jsonObj.put("name", FNAME_L2);
dataList.add(jsonObj);
}
} catch (SQLException e) {
e.printStackTrace();
}
pageList.put("pageCount", totalPages);
pageList.put("curPage", pageNumber);
pageList.put("rowsCount", totalRecouds);
pageList.put("colList", colList);
pageList.put("dataList", dataList);
// pageList.put("defaultValue", defaultValue);
jsonObject.put("pageList", pageList);
jsonObject.put("error", "null");
jsonObject.put("errorCode", 0);
jsonObject.put("success", true);
return jsonObject.toString();
}
if (jsonparam.equals("物料操作")) {
long currentTimeMillis = System.currentTimeMillis();
Thread material = new Thread(new BaseInfoFacadeControllerMaterial(ctx,json));
material.start();//防止接口重复请求, 启线程
JSONObject jsonObject = new JSONObject();
jsonObject.put("success", true);
jsonObject.put("error", null);
jsonObject.put("errorCode", 0);
JSONObject data = new JSONObject();
jsonObject.put("data", data);
long time= System.currentTimeMillis()-currentTimeMillis;
System.out.println("return前返回执行时间:'"+time+"'---------- -----"+json);
//防止接口重复请求, 先返回
String str = JSONObject.toJSONString(jsonObject,SerializerFeature.WriteMapNullValue);
return str;
}
return null;
}
}
package com.kingdee.eas.custom.xzkingdeemz;
import java.math.BigDecimal;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.kingdee.bos.BOSException;
import com.kingdee.bos.Context;
import com.kingdee.bos.dao.IObjectPK;
import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
import com.kingdee.bos.dao.query.SQLExecutorFactory;
import com.kingdee.bos.metadata.entity.EntityViewInfo;
import com.kingdee.bos.metadata.entity.FilterInfo;
import com.kingdee.bos.metadata.entity.FilterItemInfo;
import com.kingdee.bos.metadata.query.util.CompareType;
import com.kingdee.bos.util.BOSUuid;
import com.kingdee.eas.base.codingrule.CodingRuleManagerFactory;
import com.kingdee.eas.base.codingrule.util.ParmCodingRule;
import com.kingdee.eas.base.permission.UserInfo;
import com.kingdee.eas.basedata.assistant.CostItemFactory;
import com.kingdee.eas.basedata.assistant.KAClassficationFactory;
import com.kingdee.eas.basedata.assistant.MeasureUnitInfo;
import com.kingdee.eas.basedata.master.material.AccountType;
import com.kingdee.eas.basedata.master.material.CalculateTypeEnum;
import com.kingdee.eas.basedata.master.material.IMaterial;
import com.kingdee.eas.basedata.master.material.MaterialCompanyInfoCollection;
import com.kingdee.eas.basedata.master.material.MaterialCompanyInfoFactory;
import com.kingdee.eas.basedata.master.material.MaterialCompanyInfoInfo;
import com.kingdee.eas.basedata.master.material.MaterialCostCollection;
import com.kingdee.eas.basedata.master.material.MaterialCostFactory;
import com.kingdee.eas.basedata.master.material.MaterialCostInfo;
import com.kingdee.eas.basedata.master.material.MaterialFactory;
import com.kingdee.eas.basedata.master.material.MaterialGroupInfo;
import com.kingdee.eas.basedata.master.material.MaterialInfo;
import com.kingdee.eas.basedata.master.material.MaterialInventoryCollection;
import com.kingdee.eas.basedata.master.material.MaterialInventoryFactory;
import com.kingdee.eas.basedata.master.material.MaterialInventoryInfo;
import com.kingdee.eas.basedata.master.material.MaterialPurchasingCollection;
import com.kingdee.eas.basedata.master.material.MaterialPurchasingFactory;
import com.kingdee.eas.basedata.master.material.MaterialPurchasingInfo;
import com.kingdee.eas.basedata.master.material.MaterialSalesCollection;
import com.kingdee.eas.basedata.master.material.MaterialSalesFactory;
import com.kingdee.eas.basedata.master.material.MaterialSalesInfo;
import com.kingdee.eas.basedata.master.material.TimeUnitEnum;
import com.kingdee.eas.basedata.master.material.UsedStatusEnum;
import com.kingdee.eas.basedata.ncm.ExpenseFactory;
import com.kingdee.eas.basedata.org.CompanyOrgUnitFactory;
import com.kingdee.eas.basedata.org.CompanyOrgUnitInfo;
import com.kingdee.eas.basedata.org.CtrlUnitFactory;
import com.kingdee.eas.basedata.org.CtrlUnitInfo;
import com.kingdee.eas.basedata.org.FullOrgUnitFactory;
import com.kingdee.eas.basedata.org.FullOrgUnitInfo;
import com.kingdee.eas.basedata.org.QualityOrgUnitFactory;
import com.kingdee.eas.basedata.person.PersonFactory;
import com.kingdee.eas.basedata.person.PersonInfo;
import com.kingdee.eas.basedata.scm.common.util.DataImportUtils;
import com.kingdee.eas.common.EASBizException;
import com.kingdee.eas.common.RefChkFilter;
import com.kingdee.eas.common.RefChkFilterItemEnum;
import com.kingdee.eas.common.RefChkFilterSet;
import com.kingdee.eas.common.app.dao.ReferenceDAO;
import com.kingdee.eas.custom.wb.basedata.DrugFormalFactory;
import com.kingdee.eas.util.StringUtil;
import com.kingdee.eas.util.app.ContextUtil;
import com.kingdee.eas.util.app.DbUtil;
import com.kingdee.jdbc.rowset.IRowSet;
import com.kingdee.util.StringUtils;
import com.sun.star.bridge.oleautomation.Date;
import edu.emory.mathcs.backport.java.util.Collections;
public class BaseInfoFacadeControllerMaterial implements Runnable{
private String json;
private Context ctx;
protected BaseInfoFacadeControllerMaterial(Context ctx,String json){
this.json=json;
this.ctx=ctx;
}
@Override
public void run() {
// 云之家参数解析:
JSONObject yunjsonObj = JSONObject.parseObject(json);
String codeId = yunjsonObj.getString("codeId");
JSONObject _S_APPLY = yunjsonObj.getJSONObject("data")
.getJSONObject("formInfo").getJSONObject("widgetMap")
.getJSONObject("_S_APPLY");
JSONObject personInfo = (JSONObject) _S_APPLY.getJSONArray(
"personInfo").get(0);
String userId = personInfo.getString("oid");// 云之家申请人id
JSONObject _S_DEPT = yunjsonObj.getJSONObject("data")
.getJSONObject("formInfo").getJSONObject("widgetMap")
.getJSONObject("_S_DEPT");
JSONObject deptInfo = _S_DEPT.getJSONArray("deptInfo")
.getJSONObject(0);
String orgId = deptInfo.getString("orgId");// 申请人部门id
String EASORGID = "";
String PERSONID = "";
String sqldept = " select FEASORGID from T_PM_EASXTORGMAP where FXTORGID= '"
+ orgId + "' ";
String sqlPerson = " select FPERSONID from T_PM_EASXTUSERMAP where FXTID='"
+ userId + "' ";
try {
IRowSet deptRs = SQLExecutorFactory.getLocalInstance(ctx, sqldept)
.executeSQL();
while (deptRs.next()) {
EASORGID = deptRs.getString("FEASORGID");
}
IRowSet personRs = SQLExecutorFactory.getLocalInstance(ctx,
sqlPerson).executeSQL();
while (personRs.next()) {
PERSONID = personRs.getString("FPERSONID");
}
} catch (SQLException e2) {
e2.printStackTrace();
} catch (BOSException e) {
e.printStackTrace();
}
//物料操作代码
JSONObject materialInfo=new JSONObject();
JSONObject widgetMap = yunjsonObj.getJSONObject("data")
.getJSONObject("formInfo").getJSONObject("widgetMap");
JSONObject iw_8 = (JSONObject) widgetMap.getJSONObject("iw_8").getJSONArray("value").get(0);
String fpCompanyId = iw_8.getString("id");//分配公司id
materialInfo.put("fpCompanyId", fpCompanyId);
//基本资料-----------------------------------------------------------------------------------------
String number = "";
//物料编码
if(null!= widgetMap.getJSONObject("Te_16").get("value")){
number = widgetMap.getJSONObject("Te_16").get("value").toString();
}
//物料名称
String name = widgetMap.getJSONObject("Te_2").get("value").toString();
//规格型号
String Te_0 = widgetMap.getJSONObject("Te_0").get("value").toString();
//基本计量单位
String unit = "";
if( widgetMap.getJSONObject("iw_1").getJSONArray("value").size()>0){
JSONObject iw_1 = (JSONObject) widgetMap.getJSONObject("iw_1").getJSONArray("value").get(0);
unit = iw_1.getString("number");
}
String personId = personInfo.getString("id");
//规格
String model = widgetMap.getJSONObject("Te_3").get("value").toString();
//物料分类
JSONObject iw_0 = (JSONObject) widgetMap.getJSONObject("iw_0").getJSONArray("value").get(0);
String materialTypeId = iw_0.getString("id");
String materialTypeNUmber = iw_0.getString("number");
//剂型
String jxid ="";
if( widgetMap.getJSONObject("iw_2").getJSONArray("value").size()>0){
JSONObject iw_2 = (JSONObject) widgetMap.getJSONObject("iw_2").getJSONArray("value").get(0);
jxid = iw_2.getString("id");
}
//包装规格
String Te_4 = widgetMap.getJSONObject("Te_4").get("value").toString();
//质量标准
String Te_1 = widgetMap.getJSONObject("Te_1").get("value").toString();
//存储
String Te_6 = widgetMap.getJSONObject("Te_6").get("value").toString();
//商品名
String Te_5 = widgetMap.getJSONObject("Te_5").get("value").toString();
//品牌
String Te_15 = widgetMap.getJSONObject("Te_15").get("value").toString();
//批准文号
String Te_8 = widgetMap.getJSONObject("Te_8").get("value").toString();
//生产企业
String Te_7 = widgetMap.getJSONObject("Te_7").get("value").toString();
// 是否专用备件
String Ra_13 = widgetMap.getJSONObject("Ra_13").get("value")
.toString();
if (Ra_13.equals("AaBaCcDd")) {
materialInfo.put("是否专用备件", true);
} else {
materialInfo.put("是否专用备件", false);
}
// 是否金桥中间体
String Ra_0 = widgetMap.getJSONObject("Ra_0").get("value")
.toString();
if (Ra_0.equals("AaBaCcDd")) {
materialInfo.put("是否金桥中间体", true);
} else {
materialInfo.put("是否金桥中间体", false);
}
//财务资料--------------------------------------------------------------------------
//记账分类
String jzflId ="";
if( widgetMap.getJSONObject("iw_6").getJSONArray("value").size()>0){
JSONObject iw_6 = (JSONObject) widgetMap.getJSONObject("iw_6").getJSONArray("value").get(0);
jzflId = iw_6.getString("id");
}
//要素费用
String ysfylId ="";
if( widgetMap.getJSONObject("iw_9").getJSONArray("value").size()>0){
JSONObject iw_9 = (JSONObject) widgetMap.getJSONObject("iw_9").getJSONArray("value").get(0);
ysfylId = iw_9.getString("id");
}
//成本项目
String cbxmId = "";
if( widgetMap.getJSONObject("iw_10").getJSONArray("value").size()>0){
JSONObject iw_10 = (JSONObject) widgetMap.getJSONObject("iw_10").getJSONArray("value").get(0);
cbxmId = iw_10.getString("id");
}
//采购资料--------------------------------------------------------------------------
//采购计量单位
String purcharUnit ="";
if( widgetMap.getJSONObject("iw_3").getJSONArray("value").size()>0){
JSONObject iw_3 = (JSONObject) widgetMap.getJSONObject("iw_3").getJSONArray("value").get(0);
purcharUnit = iw_3.getString("number");
}
//采购检验
String Ra_4 = "";
if(null!= widgetMap.getJSONObject("Ra_4").get("value")){
Ra_4 = widgetMap.getJSONObject("Ra_4").get("value").toString();
if(Ra_4.equals("AaBaCcDd")){
materialInfo.put("isPurchaseCheck", true);
}else{
materialInfo.put("isPurchaseCheck", false);
}
}else{
materialInfo.put("isPurchaseCheck", "");
}
//不控制数量
String Ra_5 = "";
if(null!=widgetMap.getJSONObject("Ra_5").get("value")){
Ra_5 = widgetMap.getJSONObject("Ra_5").get("value").toString();
if(Ra_5.equals("AaBaCcDd")){
materialInfo.put("isNotControlQty", true);
}else{
materialInfo.put("isNotControlQty", false);
}
}else{
materialInfo.put("isNotControlQty", "");
}
//不控制时间
String Ra_6 ="";
if(null!=widgetMap.getJSONObject("Ra_6").get("value")){
Ra_6 = widgetMap.getJSONObject("Ra_6").get("value").toString();
if(Ra_6.equals("AaBaCcDd")){
materialInfo.put("isNotControlTime", true);
}else{
materialInfo.put("isNotControlTime", false);
}
}else{
materialInfo.put("isNotControlTime", "");
}
String Ra_7 = "";
if(null!=widgetMap.getJSONObject("Ra_7").get("value")){
//允许退货
Ra_7 = widgetMap.getJSONObject("Ra_7").get("value").toString();
if(Ra_7.equals("AaBaCcDd")){
materialInfo.put("cgisReturn", true);
}else{
materialInfo.put("cgisReturn", false);
}
}else{
materialInfo.put("cgisReturn", "");
}
//生产厂家
String Te_9 = widgetMap.getJSONObject("Te_9").get("value").toString();
//产地
String Te_10 = widgetMap.getJSONObject("Te_10").get("value").toString();
//销售资料---------------------------------------------------------------------------
//销售计量单位
String saleUnit ="";
if( widgetMap.getJSONObject("iw_4").getJSONArray("value").size()>0){
JSONObject iw_4 = (JSONObject) widgetMap.getJSONObject("iw_4").getJSONArray("value").get(0);
saleUnit = iw_4.getString("number");
}
//允许退货
String Ra_8 ="";
if(null!= widgetMap.getJSONObject("Ra_8").get("value")){
Ra_8 = widgetMap.getJSONObject("Ra_8").get("value").toString();
if(Ra_8.equals("AaBaCcDd")){
materialInfo.put("xsisReturn", true);
}else{
materialInfo.put("xsisReturn", false);
}
}else{
materialInfo.put("xsisReturn", "");
}
//库存资料--------------------------------------------------------------------------
//库存计量单位
String storeOrgUnit = "";
if( widgetMap.getJSONObject("iw_5").getJSONArray("value").size()>0){
JSONObject iw_5 = (JSONObject) widgetMap.getJSONObject("iw_5").getJSONArray("value").get(0);
storeOrgUnit = iw_5.getString("number");
}
//保质期天数
String Te_11 = widgetMap.getJSONObject("Te_11").get("value").toString();
//默认仓库
String storeOrg ="";
if( widgetMap.getJSONObject("iw_11").getJSONArray("value").size()>0){
JSONObject iw_11 = (JSONObject) widgetMap.getJSONObject("iw_11").getJSONArray("value").get(0);
storeOrg = iw_11.getString("number");
}
//库存管理
String Ra_10 = "";
if(null!= widgetMap.getJSONObject("Ra_10").get("value")){
Ra_10 = widgetMap.getJSONObject("Ra_10").get("value").toString();
if(Ra_10.equals("AaBaCcDd")){
materialInfo.put("isStore", true);
}else{
materialInfo.put("isStore", false);
}
}else{
materialInfo.put("isStore", "");
}
//批次管理
String Ra_11 ="";
if(null!= widgetMap.getJSONObject("Ra_11").get("value")){
Ra_11 = widgetMap.getJSONObject("Ra_11").get("value").toString();
if(Ra_11.equals("AaBaCcDd")){
materialInfo.put("isBatchNo", true);
}else{
materialInfo.put("isBatchNo", false);
}
}else{
materialInfo.put("isBatchNo", "");
}
//保质期管理
String Ra_12 = "";
if(null!= widgetMap.getJSONObject("Ra_12").get("value")){
Ra_12 = widgetMap.getJSONObject("Ra_12").get("value").toString();
if(Ra_12.equals("AaBaCcDd")){
materialInfo.put("isPeriodValid", true);
}else{
materialInfo.put("isPeriodValid", false);
}
}else{
materialInfo.put("isPeriodValid", "");
}
//判断申请类型: 新增、更新信息
boolean isUpdate = false;
String Ra_14 = widgetMap.getJSONObject("Ra_14").get("value").toString();
if(Ra_14.equals("AaBaCcDd")){
isUpdate = false;//新增
}else{
isUpdate = true;//更新信息
}
materialInfo.put("number", number );
materialInfo.put("name", name);
materialInfo.put("PERSONID", PERSONID);
materialInfo.put("unit", unit);//基本计量单位
materialInfo.put("model", Te_0);//规格型号
materialInfo.put("model2", model);//规格
materialInfo.put("materialTypeId", materialTypeId);//物料分类
materialInfo.put("materialTypeNUmber", materialTypeNUmber);//物料分类编码
materialInfo.put("Packing", Te_4);//包装规格
materialInfo.put("Formulations", jxid);//剂型
materialInfo.put("Storage", Te_6); //存储
materialInfo.put("ProductName", Te_5);//商品名
materialInfo.put("kDTextField", Te_15);//品牌
materialInfo.put("warrantnumber", Te_8);//批准文号
materialInfo.put("shengchanqiye", Te_7);//生产企业
materialInfo.put("kAClass", jzflId);//记账分类
materialInfo.put("purchaseunit", purcharUnit);//采购计量单位编码
materialInfo.put("produceFactory", Te_9);//生产厂家
materialInfo.put("producingArea", Te_10);//产地
materialInfo.put("saleunit", saleUnit);//销售计量单位
materialInfo.put("keepDys", Te_11);//保质期天数
materialInfo.put("defaultWarehouse", storeOrg);//默认仓库编码
materialInfo.put("storeOrgUnit", storeOrgUnit);//库存计量单位
materialInfo.put("expense", ysfylId);//要素费用
materialInfo.put("defaultCostItem", cbxmId);//默认成本项目
if(!isUpdate){//新增物料
try {
importMaterialInfo( ctx, materialInfo.toJSONString()) ;
} catch (SQLException e) {
e.printStackTrace();
} catch (BOSException e) {
e.printStackTrace();
}
}else{
try {
updateMaterialInfo( ctx, materialInfo.toJSONString() );
} catch (EASBizException e) {
e.printStackTrace();
} catch (BOSException e) {
e.printStackTrace();
}
}
}
//物料新增方法
protected String importMaterialInfo(Context ctx, String materialInfo ) throws BOSException, SQLException {
Map<String, String> result = new HashMap<String, String>();
result.put("code", "0");
MaterialInfo info = new MaterialInfo();
JSONObject json = JSON.parseObject(materialInfo);
result.put("msg", json.getString("number"));
IObjectPK pk = null;
try {
IMaterial imaterial = MaterialFactory.getLocalInstance(ctx);
info.setName(json.getString("name"));
CtrlUnitInfo cu = DataImportUtils.getCtrlUnitInfoFromNumber(ctx, "000000");
ContextUtil.setCurrentOrgUnit(ctx, cu);
ContextUtil.setCurrentCtrlUnit(ctx, cu);//能维护其他管理单元的资料!
PersonInfo personInfo = PersonFactory.getLocalInstance(ctx).getPersonInfo(new ObjectUuidPK(json.getString("PERSONID")));
UserInfo userInfo = DataImportUtils.getUserInfoFromNumber(ctx, personInfo.getNumber());
ContextUtil.setCurrentUserInfo(ctx, DataImportUtils.getUserInfoFromNumber(ctx, personInfo.getNumber()));
info.setCU(cu);
ctx.put("disablePermissionForKScript", Boolean.TRUE);
info.put("Packing", json.getString("Packing"));//包装规格
ctx.setCaller(new ObjectUuidPK(personInfo.getId()));
String ais = ctx.getAIS();
if(ais.equals("_105")){
json.put("Formulations", "mEcAAABrH5UV4pXk");
}
if(!org.apache.commons.lang.StringUtils.isEmpty(json.getString("Formulations")))
{
info.put("Formulations", DrugFormalFactory.getLocalInstance(ctx).getDataBaseInfo(new ObjectUuidPK(json.getString("Formulations"))));//剂型
}
info.put("Storage", json.getString("Storage")); //存储
info.put("ProductName", json.getString("ProductName")); //商品名
info.put("kDTextField", json.getString("kDTextField")); //品牌
info.put("producingArea", json.getString("producingArea")); //产地
info.setWarrantnumber(json.getString("warrantnumber"));//批准文号
info.put("shengchanqiye", json.getString("shengchanqiye")); //生产企业
info.setEffectedStatus(2);//暂存或保存
info.setAvailable(true);
info.setCreator(userInfo);//创建人
info.setPricePrecision(6);//单价精度
info.setBarCode(null);//条形码
info.setDescription(null);//描述
info.setModel(json.getString("model"));//规格型号
info.put("model2", json.getString("model2"));//规格
info.setCU(cu);
info.setAdminCU(cu);
info.setVersion(0);
// info.set
MeasureUnitInfo baseunit = new MeasureUnitInfo();
baseunit = DataImportUtils.getMeasureUnitInfoFromNumber(ctx, json
.getString("unit").toString());
info.setBaseUnit(baseunit);
MaterialGroupInfo mginfo = DataImportUtils
.getMaterialGroupInfoFromNumber(ctx, json.getString("materialTypeNUmber"));
info.setMaterialGroup(mginfo);
String number = getMaterial( ctx, json.getString("materialTypeNUmber") );
info.setNumber(number);
info.setStatus(UsedStatusEnum.UNAPPROVE);
Object object = ctx.get("ctx");
//提交物料基本资料前 判断物料编码是否已存在
boolean exist = CodingRuleManagerFactory.getLocalInstance(ctx).isExist( info, cu.getId().toString(), "", new ParmCodingRule());
pk = MaterialFactory.getLocalInstance(ctx).submit(info);
imaterial.approve(pk);
StringBuilder sql = new StringBuilder();
sql
.append( //物料分配标准表 -- 分类标准(基本分配标准)
"/*dialect*/insert into t_bd_materialgroupdetial value (select newbosid('B9B5052C'),'")
.append(pk)
.append("','dR8lnQEPEADgAAWKwKgSxZeb4R8=','").append(
mginfo.getId()).append("' from dual)");
DbUtil.execute(ctx, sql.toString());
info = imaterial.getMaterialInfo(pk);
result.put("number", info.getNumber());
//财务资料页签------------------------------------------------------------------
CompanyOrgUnitInfo companyInfo = DataImportUtils
.getCompanyOrgUnitInfoFromNumber(ctx, "000000");
MaterialCompanyInfoInfo mcu = new MaterialCompanyInfoInfo();//物料财务资料
mcu.setMateial(info);
mcu.setCompany(companyInfo);
mcu.setCU(cu);
mcu.setCreateTime(new Timestamp(System.currentTimeMillis()) );
mcu.setCreator( userInfo);
mcu.setEffectedStatus(2);
mcu.setStatus(UsedStatusEnum.UNAPPROVE);
mcu.setAccountType(AccountType.SPECIAL_ACCT);//计价方法
mcu.setCalculateType(CalculateTypeEnum.PURCHASE);//核算类别
mcu.setStandardCost(BigDecimal.ZERO);//单位标准成本
//记账分类
if(!org.apache.commons.lang.StringUtils.isEmpty(json
.getString("kAClass"))){
mcu.setKAClass(KAClassficationFactory.getLocalInstance(ctx).getKAClassficationInfo(new ObjectUuidPK(json.getString("kAClass"))));
}
IObjectPK materialComPk = MaterialCompanyInfoFactory
.getLocalInstance(ctx).submit(mcu);
MaterialCompanyInfoFactory.getLocalInstance(ctx).approve(
materialComPk);
//采购资料页签-----------------------------------------------------------------
FullOrgUnitInfo purorg = FullOrgUnitFactory.getLocalInstance(
ctx).getFullOrgUnitInfo(
"where number='000000'");
MaterialPurchasingInfo purInfo = new MaterialPurchasingInfo();
purInfo.setIsNotControlQty(json.getBoolean("isNotControlQty"));//不控制数量
purInfo.setIsNotControlTime(json.getBoolean("isNotControlTime"));//不控制时间
purInfo.setIsReturn(json.getBoolean("cgisReturn"));//是否允许退货
purInfo.setIsPurchaseCheck(json.getBoolean("isPurchaseCheck"));//采购检验 采购检验为true时 检验组织不能为空
if(json.getBoolean("isPurchaseCheck")==true){
purInfo.setQualityOrg(QualityOrgUnitFactory.getLocalInstance(ctx).getQualityOrgUnitInfo(" where number='000000' "));
}
purInfo.setMaterial(info);
purInfo.setOrgUnit(purorg);
purInfo.setEffectedStatus(1);
purInfo.setUnit(baseunit);
purInfo.setAvailable(true);
purInfo.setCU(cu);
purInfo.setAvailable(true);
purInfo.setCreateTime(new Timestamp(System.currentTimeMillis()) );
purInfo.setCreator( userInfo);
if( !org.apache.commons.lang.StringUtils.isEmpty(json
.getString("purchaseunit"))){
purInfo.setUnit(DataImportUtils.getMeasureUnitInfoFromNumber(ctx, json
.getString("purchaseunit").toString()));//采购计量单位编码
}
purInfo.setProduceFactory(json.getString("produceFactory"));//生产厂家
purInfo.setProducingArea(json.getString("producingArea"));//产地
purInfo.setStatus(UsedStatusEnum.UNAPPROVE);
IObjectPK purPk = MaterialPurchasingFactory.getLocalInstance(
ctx).submit(purInfo);
MaterialPurchasingFactory.getLocalInstance(ctx).approve(purPk);
//库存资料页签--------------------------------------------------------------------------
MaterialInventoryInfo materialInvInfo = new MaterialInventoryInfo();
materialInvInfo.setMaterial(info);
materialInvInfo.setOrgUnit(purorg);
materialInvInfo.setIsControl(true);
materialInvInfo.setUnit(DataImportUtils.getMeasureUnitInfoFromNumber(ctx, json
.getString("storeOrgUnit").toString()));
materialInvInfo.setEffectedStatus(1);//暂存或保存标记
materialInvInfo.setCU(cu);
materialInvInfo.setCreateTime(new Timestamp(System.currentTimeMillis()) );
materialInvInfo.setCreator( userInfo);
materialInvInfo.setStatus(UsedStatusEnum.UNAPPROVE);
materialInvInfo.setPeriodValidUnit(TimeUnitEnum.DAY);//保质期单位
materialInvInfo.setAheadUnit(TimeUnitEnum.DAY);//提前期单位
materialInvInfo.setPeriodValid(json.getIntValue("keepDys"));//保质期
if(json.getIntValue("keepDys")==0){
materialInvInfo.setPeriodValid(1);//保质期默认值不能是0
}
materialInvInfo.setIsPeriodValid(json.getBoolean("isPeriodValid"));//保质期管理
materialInvInfo.setIsLotNumber(json.getBoolean("isBatchNo"));//批次管理
materialInvInfo.setIsControl(json.getBoolean("isStore"));//库存管理
if(!org.apache.commons.lang.StringUtils.isEmpty(json
.getString("defaultWarehouse"))){
materialInvInfo.setDefaultWarehouse(DataImportUtils.getWarehouseInfoFromNumber(ctx, json.getString("defaultWarehouse")));
}
materialInvInfo.setOutWarehsAhead(1);//出库失效提前期
materialInvInfo.setAvailable(true);
IObjectPK materialInvPk = MaterialInventoryFactory
.getLocalInstance(ctx).submit(materialInvInfo);
MaterialInventoryFactory.getLocalInstance(ctx).approve(
materialInvPk);
//销售资料页签-----------------------------------------------------------------
MaterialSalesInfo saleinfo = new MaterialSalesInfo();
FullOrgUnitInfo saleorg = FullOrgUnitFactory.getLocalInstance(
ctx).getFullOrgUnitInfo(
"where number='000000'");
saleinfo.setMaterial(info);
saleinfo.setOrgUnit(saleorg);
saleinfo.setCU(cu);
saleinfo.setPrice(BigDecimal.ZERO);
saleinfo.setStatus(UsedStatusEnum.UNAPPROVE);
saleinfo.setAvailable(true);
saleinfo.setCreateTime(new Timestamp(System.currentTimeMillis()) );
saleinfo.setCreator( userInfo);
saleinfo.setIsReturn(json.getBoolean("xsisReturn"));//是否允许退货
if(!org.apache.commons.lang.StringUtils.isEmpty(json
.getString("saleunit"))){
saleinfo.setUnit(DataImportUtils.getMeasureUnitInfoFromNumber(ctx, json
.getString("saleunit").toString()));
}
IObjectPK materialSalePk = MaterialSalesFactory
.getLocalInstance(ctx).submit(saleinfo);
MaterialSalesFactory.getLocalInstance(ctx).approve(saleinfo);
//物料成本页签-----------------------------------------------------------------------------
MaterialCostInfo materialCostInfo = new MaterialCostInfo();
FullOrgUnitInfo costorg = FullOrgUnitFactory.getLocalInstance(
ctx).getFullOrgUnitInfo(
"where number='000000'");
materialCostInfo.setMaterial(info);
materialCostInfo.setOrgUnit(costorg);
//默认成本对象
if(!org.apache.commons.lang.StringUtils.isEmpty(json
.getString("defaultCostItem"))){
materialCostInfo.setDefaultCostItem(CostItemFactory.getLocalInstance(ctx).getCostItemInfo(new ObjectUuidPK(json.getString("defaultCostItem"))));
}
//要素费用
if(!org.apache.commons.lang.StringUtils.isEmpty(json
.getString("expense"))){
materialCostInfo.setExpense(ExpenseFactory.getLocalInstance(ctx).getExpenseInfo(new ObjectUuidPK(json.getString("expense"))));
}
materialCostInfo.setStatus(UsedStatusEnum.UNAPPROVE);
materialCostInfo.setAvailable(true);
materialCostInfo.setCU(cu);
materialCostInfo.setCreateTime(new Timestamp(System.currentTimeMillis()) );
materialCostInfo.setCreator( userInfo);
IObjectPK materialCosPK= MaterialCostFactory.getLocalInstance(ctx).submit(materialCostInfo);
MaterialCostFactory.getLocalInstance(ctx).approve( materialCosPK);
//物料存放分配-------------------------------------------------------------------------------
/* MaterialStorageAssignInfo storageInfo = new MaterialStorageAssignInfo();
storageInfo.setMaterial(info);
StorageOrgUnitInfo storageOrg = (StorageOrgUnitInfo) StorageOrgUnitFactory
.getLocalInstance(ctx).getDataBaseInfo(
"where number='000000'");
storageInfo.setStorageOrg(storageOrg);
storageInfo
.setStorageAssignType(MaterialStorageAssignTypeEnum.BYMATERIAL);
storageInfo.setAvailable(true);
storageInfo.setCU(cu);
storageInfo.setMaterialGroup(info.getMaterialGroup());
MaterialStorageAssignFactory.getLocalInstance(ctx).submit(
storageInfo);*/
} catch (EASBizException e1) {
result.put("code", "2");
result.put("msg", e1.getMessage());
String sql=" insert into CT_CUS_Yunzhijiamaterial (Fid, FNumber,FName_l2,CFOperType,CFOperResult,CFOperTime ,FControlUnitID,CFPERSONID,FDescription_l2) " +
" values (newbosid('E75E01FB'),'"+info.getNumber()+"','"+info.getName()+"','新增', '失败',SYSDATE,'00000000-0000-0000-0000-000000000000CCE7AED4','"+ctx.getCaller()+"','"+e1.getMessage()+"') ";
DbUtil.execute(ctx, sql);
return JSON.toJSONString(result);
}
//物料新增后 分配
String fpCompanyId = json.getString("fpCompanyId");
try {
CtrlUnitInfo ctrlUnitInfo =CtrlUnitFactory.getLocalInstance(ctx).getCtrlUnitInfo(new ObjectUuidPK(fpCompanyId));
JSONObject materialInfojson = JSON.parseObject(materialInfo);
materialInfojson.put("pk", pk.toString());
createDAssignRelation( ctx, info.getId() , ctrlUnitInfo,materialInfojson.toString(),"新增") ; //分类物料方法 (辅助账分配)
} catch (EASBizException e) {
e.printStackTrace();
}
try {
FullOrgUnitInfo costorg = FullOrgUnitFactory.getLocalInstance(
ctx).getFullOrgUnitInfo(
"where number='000000'");
String sql=" insert into CT_CUS_Yunzhijiamaterial (Fid, FNumber,FName_l2,CFOperType,CFOperResult,CFOperTime ,FControlUnitID,CFPERSONID) values (newbosid('E75E01FB'),'"+info.getNumber()+"','"+info.getName()+"','新增', '成功',SYSDATE,'"+costorg.getId().toString()+"','"+ctx.getCaller()+"') ";
DbUtil.execute(ctx, sql);
} catch (EASBizException e) {
e.printStackTrace();
}
System.out.println("--------------新增物料结束-----------------------------------------------------");
return null;
}
/**
* 物料更新方法
* @throws BOSException
* @throws EASBizException
* @throws EASBizException
*/
protected String updateMaterialInfo(Context ctx, String materialInfo ) throws BOSException, EASBizException {
Map<String, String> result = new HashMap<String, String>();
result.put("code", "0");
JSONObject json = JSON.parseObject(materialInfo);
result.put("msg", json.getString("number"));
MaterialInfo info =DataImportUtils.getMaterialInfoFromNumber(ctx, json.getString("number"));
//根据物料编码得到物料 id
String materialId = DataImportUtils.getMaterialInfoFromNumber(ctx, json.getString("number")).getId().toString();
CompanyOrgUnitInfo companyInfo = CompanyOrgUnitFactory.getLocalInstance(ctx).getCompanyOrgUnitInfo(new ObjectUuidPK( json.getString("fpCompanyId")));
Boolean reference=false;
//判断物料是否被引用
if(checkReference( ctx, info.getId())){
reference=true;
}
IMaterial imaterial = MaterialFactory.getLocalInstance(ctx);
IObjectPK pk = null;
info.setName(json.getString("name"));
CtrlUnitInfo cu = DataImportUtils.getCtrlUnitInfoFromNumber(ctx,"000000");//修改 物料基本页签 时上下文cu切换成集团组织
ContextUtil.setCurrentOrgUnit(ctx, cu);
ContextUtil.setCurrentCtrlUnit(ctx, cu);//能维护其他管理单元的资料!
PersonInfo personInfo = PersonFactory.getLocalInstance(ctx).getPersonInfo(new ObjectUuidPK(json.getString("PERSONID")));
UserInfo userInfo = DataImportUtils.getUserInfoFromNumber(ctx, personInfo.getNumber());
ContextUtil.setCurrentUserInfo(ctx, DataImportUtils.getUserInfoFromNumber(ctx, personInfo.getNumber()));
ctx.setCaller(new ObjectUuidPK(personInfo.getId()));
info.setCU(cu);
ctx.put("disablePermissionForKScript", Boolean.TRUE);
info.put("Packing", json.getString("Packing").equals("")?info.get("Packing"):json.getString("Packing"));//包装规格
String ais = ctx.getAIS();
if(ais.equals("_105")){
json.put("Formulations", "mEcAAABrH5UV4pXk");
}
info.put("Formulations",json.getString("Formulations").equals("")?info.get("Formulations"): DrugFormalFactory.getLocalInstance(ctx).getDataBaseInfo(new ObjectUuidPK(json.getString("Formulations"))));//剂型
info.put("Storage", json.getString("Storage").equals("")?info.get("Storage"):json.getString("Storage")); //存储
info.put("ProductName", json.getString("ProductName").equals("")?info.get("ProductName"):json.getString("ProductName")); //商品名
info.put("kDTextField", json.getString("kDTextField").equals("")?info.get("kDTextField"): json.getString("kDTextField")); //品牌
info.put("producingArea", json.getString("producingArea").equals("")?info.get("producingArea"):json.getString("producingArea")); //产地
info.setWarrantnumber(json.getString("warrantnumber").equals("")?info.getWarrantnumber():json.getString("warrantnumber"));//批准文号
info.put("shengchanqiye", json.getString("shengchanqiye").equals("")?info.get("shengchanqiye"): json.getString("shengchanqiye")); //生产企业
info.setEffectedStatus(2);//暂存或保存
info.setAvailable(true);
info.setCreator(userInfo);//创建人
//info.setPricePrecision(6);//单价精度
info.setBarCode(null);//条形码
info.setDescription(null);//描述
info.setModel(json.getString("model").equals("")?info.getModel():json.getString("model"));//规格型号
info.setCU(cu);
info.setAdminCU(cu);
info.setVersion(0);
info.setLastUpdateUser(userInfo);
info.setLastUpdateTime(new Timestamp(System.currentTimeMillis()));
// 计量单位不让修改
MeasureUnitInfo baseunit = info.getBaseUnit();
if("".equals(json.getString("unit"))){
baseunit = DataImportUtils.getMeasureUnitInfoFromNumber(ctx, json
.getString("unit").toString());
}
if(!reference){
info.setBaseUnit(baseunit);
}
MaterialGroupInfo mginfo = DataImportUtils
.getMaterialGroupInfoFromNumber(ctx, json.getString("materialTypeNUmber"));
info.setMaterialGroup(mginfo);
if(info.getStatus().equals(UsedStatusEnum.APPROVED)){
MaterialFactory.getLocalInstance(ctx).unapprove(new ObjectUuidPK(materialId)) ;
info.setStatus(UsedStatusEnum.UNAPPROVE);
}
try {
MaterialFactory.getLocalInstance(ctx).update(new ObjectUuidPK(materialId), info);
MaterialFactory.getLocalInstance(ctx).submit(info);
MaterialFactory.getLocalInstance(ctx).approve(new ObjectUuidPK(info.getId()));
} catch (Exception e5) {
String sqlupdate=" insert into CT_CUS_Yunzhijiamaterial (Fid, FNumber,FName_l2,CFOperType,CFOperResult,CFOperTime ,FControlUnitID,CFPERSONID,FDescription_l2) " +
" values (newbosid('E75E01FB'),'"+info.getNumber()+"','"+info.getName()+"','修改', '失败',SYSDATE,'00000000-0000-0000-0000-000000000000CCE7AED4','"+ctx.getCaller()+"','"+e5.getMessage()+"') ";
DbUtil.execute(ctx, sqlupdate);
e5.printStackTrace();
}
//-----------------------------------
EntityViewInfo view = new EntityViewInfo();
FilterInfo filterInfo = new FilterInfo();
filterInfo.getFilterItems().add(new FilterItemInfo("mateial.id",materialId, CompareType.EQUALS));
filterInfo.getFilterItems().add(new FilterItemInfo("company.id", companyInfo.getId(), CompareType.EQUALS));
view.setFilter(filterInfo);
//-----------------------------------------------------------------------------
// 修改时 该物料不存在该公司下 需要先分配到该公司下 再进行修改
MaterialCompanyInfoCollection materialCompanyInfoCollection = MaterialCompanyInfoFactory.getLocalInstance(ctx).getMaterialCompanyInfoCollection(view);
if(materialCompanyInfoCollection.size()<=0){
//物料不存在该公司 先进行分配
CtrlUnitInfo ctrlUnitInfo =CtrlUnitFactory.getLocalInstance(ctx).getCtrlUnitInfo(new ObjectUuidPK(companyInfo.getId()));
JSONObject materialInfojson = JSON.parseObject(materialInfo);
materialInfojson.put("pk", materialId);
createDAssignRelation( ctx, info.getId() , ctrlUnitInfo,materialInfojson.toString(),"修改") ; //分类物料方法 (辅助账分配)
//这里存在问题: 客户在集团建物料不规范 没有设置其他页签的组织 为集团导致 分配下去的组织也是空白,后面根据组织和物料代码查找财务页签报null 829行代码进行特殊处理
}
cu = DataImportUtils.getCtrlUnitInfoFromNumber(ctx,companyInfo.getNumber());//修改非物料基本页签 时上下文cu切换成分配组织
ContextUtil.setCurrentOrgUnit(ctx, cu);
ContextUtil.setCurrentCtrlUnit(ctx, cu);//能维护其他管理单元的资料!
//财务资料页签---------------------------------------------------------------------------------------------
MaterialCompanyInfoCollection materialCompanyInfoColl = MaterialCompanyInfoFactory.getLocalInstance(ctx).getMaterialCompanyInfoCollection(view);
MaterialCompanyInfoInfo mcu = materialCompanyInfoColl.get(0);
if(null==mcu){
mcu=new MaterialCompanyInfoInfo();
mcu.setAccountType(AccountType.SPECIAL_ACCT);//计价方法 -新增必录值
mcu.setCalculateType(CalculateTypeEnum.PURCHASE);//核算类别 -新增必录值
}
mcu.setMateial(info);
CtrlUnitInfo companycu = DataImportUtils.getCtrlUnitInfoFromNumber(ctx, companyInfo.getNumber());
// CtrlUnitInfo Ctrlcu = DataImportUtils.getCtrlUnitInfoFromNumber(ctx,"000000");//
// mcu.setCU(Ctrlcu);//Ctrlcu 是集团
/* mcu.setCreateTime(new Timestamp(System.currentTimeMillis()) );
mcu.setCreator( userInfo);*/
mcu.setLastUpdateUser(userInfo);
mcu.setLastUpdateTime(new Timestamp(System.currentTimeMillis()));
mcu.setCompany(companyInfo);
mcu.setEffectedStatus(2);
if(!reference){
mcu.setAccountType(AccountType.SPECIAL_ACCT);//计价方法
}
mcu.setCalculateType(CalculateTypeEnum.PURCHASE);//核算类别
if(!reference){
mcu.setStandardCost(BigDecimal.ZERO);//单位标准成本
}
//记账分类
if(!"".equals(json.getString("kAClass"))){
mcu.setKAClass(KAClassficationFactory.getLocalInstance(ctx).getKAClassficationInfo(new ObjectUuidPK(json.getString("kAClass"))));
}
if(mcu.getStatus().equals(UsedStatusEnum.APPROVED)){
MaterialCompanyInfoFactory.getLocalInstance(ctx).unApprove(new ObjectUuidPK(mcu.getId().toString()) );
mcu.setStatus(UsedStatusEnum.UNAPPROVE);
}
try {
if( mcu.getId()==null){
// mcu.setId(BOSUuid.create("D431F8BB")) ; //D431F8BB
MaterialCompanyInfoFactory.getLocalInstance(ctx).addnew(new ObjectUuidPK(BOSUuid.create("D431F8BB")), mcu) ;
}else{
MaterialCompanyInfoFactory.getLocalInstance(ctx).update(new ObjectUuidPK(mcu.getId().toString()), mcu);
}
MaterialCompanyInfoFactory.getLocalInstance(ctx).save(new ObjectUuidPK(mcu.getId().toString()), mcu);
MaterialCompanyInfoFactory.getLocalInstance(ctx).submit(mcu);
MaterialCompanyInfoFactory.getLocalInstance(ctx).approve(mcu);
} catch (Exception e4) {
StringBuffer error=new StringBuffer();
if(e4.getLocalizedMessage().length()>255){
error=new StringBuffer("系统异常,详情查看日志");
}else{
error=new StringBuffer(e4.getLocalizedMessage());
}
String sqlupdate=" insert into CT_CUS_Yunzhijiamaterial (Fid, FNumber,FName_l2,CFOperType,CFOperResult,CFOperTime ,FControlUnitID,CFPERSONID,FDescription_l2) " +
" values (newbosid('E75E01FB'),'"+info.getNumber()+"','"+info.getName()+"','修改', '失败',SYSDATE,'00000000-0000-0000-0000-000000000000CCE7AED4','"+ctx.getCaller()+"','"+error+"') ";
DbUtil.execute(ctx, sqlupdate);
e4.printStackTrace();
}
//采购资料页签-----------------------------------------------------------------
MaterialPurchasingInfo purInfo = MaterialPurchasingFactory.getLocalInstance(ctx).getPurchasingInfo(materialId, companyInfo.getId().toString());
if(null==purInfo){
purInfo =new MaterialPurchasingInfo();
}
FullOrgUnitInfo purorg = FullOrgUnitFactory.getLocalInstance(
ctx).getFullOrgUnitInfo("where number='"+companyInfo.getNumber()+"'");
purInfo.setIsNotControlQty(json.getString("isNotControlQty").equals("")?purInfo.isIsNotControlQty():json.getBoolean("isNotControlQty"));//不控制数量
purInfo.setIsNotControlTime(json.getString("isNotControlTime").equals("")?purInfo.isIsNotControlTime():json.getBoolean("isNotControlTime"));//不控制时间
purInfo.setIsReturn(json.getBoolean("cgisReturn"));//是否允许退货
purInfo.setIsPurchaseCheck(json.getString("isPurchaseCheck").equals("")?purInfo.isIsPurchaseCheck():json.getBoolean("isPurchaseCheck"));//采购检验 采购检验为true时 检验组织不能为空
if(!json.getString("isPurchaseCheck").equals("")){
if(json.getBoolean("isPurchaseCheck")==true){
purInfo.setQualityOrg(QualityOrgUnitFactory.getLocalInstance(ctx).getQualityOrgUnitInfo(" where number='000000' "));
}
}
purInfo.setMaterial(info);
purInfo.setOrgUnit(purorg);
purInfo.setEffectedStatus(1);
purInfo.setAvailable(true);
purInfo.setCU(cu);
purInfo.setLastUpdateUser(userInfo);
purInfo.setLastUpdateTime(new Timestamp(System.currentTimeMillis()));
purInfo.setAvailable(true);
if(!"".equals(json.getString("purchaseunit"))){
purInfo.setUnit(DataImportUtils.getMeasureUnitInfoFromNumber(ctx, json.getString("purchaseunit").toString()));//采购计量单位编码
}
purInfo.setProduceFactory(json.getString("produceFactory").equals("")?purInfo.getProduceFactory():json.getString("produceFactory"));//生产厂家
purInfo.setProducingArea(json.getString("producingArea").equals("")?purInfo.getProducingArea():json.getString("producingArea"));//产地
if(purInfo.getStatus().equals(UsedStatusEnum.APPROVED)){
MaterialPurchasingFactory.getLocalInstance(ctx).unApprove (new ObjectUuidPK(purInfo.getId()) ) ;
purInfo.setStatus(UsedStatusEnum.UNAPPROVE);
}
try {
if(null==purInfo.getId()){
MaterialPurchasingFactory.getLocalInstance(ctx).addnew(new ObjectUuidPK(BOSUuid.create("0193BD9B")), purInfo) ;
}else{
MaterialPurchasingFactory.getLocalInstance(ctx).update(new ObjectUuidPK(purInfo.getId()), purInfo) ;
}
MaterialPurchasingFactory.getLocalInstance(ctx).save(purInfo);
MaterialPurchasingFactory.getLocalInstance(ctx).submit(purInfo);
MaterialPurchasingFactory.getLocalInstance(ctx).approve(purInfo);
} catch (Exception e3) {
String sqlupdate=" insert into CT_CUS_Yunzhijiamaterial (Fid, FNumber,FName_l2,CFOperType,CFOperResult,CFOperTime ,FControlUnitID,CFPERSONID,FDescription_l2) " +
" values (newbosid('E75E01FB'),'"+info.getNumber()+"','"+info.getName()+"','修改', '失败',SYSDATE,'00000000-0000-0000-0000-000000000000CCE7AED4','"+ctx.getCaller()+"','"+e3.getLocalizedMessage()+"') ";
DbUtil.execute(ctx, sqlupdate);
e3.printStackTrace();
}
//库存资料页签--------------------------------------------------------------------------
MaterialInventoryInfo materialInvInfo =MaterialInventoryFactory.getLocalInstance(ctx).getInventoryInfo(materialId, companyInfo.getId().toString());
if(null==materialInvInfo){
materialInvInfo=new MaterialInventoryInfo();
materialInvInfo.setPeriodValid(1);
}
materialInvInfo.setMaterial(info);
materialInvInfo.setOrgUnit(purorg);
materialInvInfo.setIsControl(true);
if(!"".equals(json
.getString("storeOrgUnit"))){
materialInvInfo.setUnit(DataImportUtils.getMeasureUnitInfoFromNumber(ctx, json
.getString("storeOrgUnit").toString()));
}
materialInvInfo.setEffectedStatus(1);//暂存或保存标记
materialInvInfo.setCU(cu);
materialInvInfo.setLastUpdateUser(userInfo);
materialInvInfo.setLastUpdateTime(new Timestamp(System.currentTimeMillis()));
materialInvInfo.setPeriodValidUnit(TimeUnitEnum.DAY);//保质期单位
materialInvInfo.setAheadUnit(TimeUnitEnum.DAY);//提前期单位
materialInvInfo.setPeriodValid(json.getString("keepDys").equals("")?materialInvInfo.getPeriodValid():json.getIntValue("keepDys"));//保质期
if(!json.getString("keepDys").equals("")){
if(json.getIntValue("keepDys")==0){
materialInvInfo.setPeriodValid(1);//保质期默认值不能是0
}
}else{
materialInvInfo.setPeriodValid(1);
}
materialInvInfo.setIsPeriodValid(json.getString("isPeriodValid").equals("")?materialInvInfo.isIsPeriodValid():json.getBoolean("isPeriodValid"));//保质期管理
materialInvInfo.setIsLotNumber(json.getString("isBatchNo").equals("")?materialInvInfo.isIsLotNumber():json.getBoolean("isBatchNo"));//批次管理
materialInvInfo.setIsControl(json.getString("isStore").equals("")?materialInvInfo.isIsControl():json.getBoolean("isStore"));//库存管理
materialInvInfo.setDefaultWarehouse(json.getString("defaultWarehouse").equals("")?materialInvInfo.getDefaultWarehouse():DataImportUtils.getWarehouseInfoFromNumber(ctx, json.getString("defaultWarehouse")));
materialInvInfo.setOutWarehsAhead(1);//出库失效提前期
materialInvInfo.setAvailable(true);
if(materialInvInfo.getStatus().equals(UsedStatusEnum.APPROVED)){
MaterialInventoryFactory.getLocalInstance(ctx).unApprove (new ObjectUuidPK(materialInvInfo.getId()) ) ;
materialInvInfo.setStatus(UsedStatusEnum.UNAPPROVE);
}
try {
if(null==materialInvInfo.getId()){
MaterialInventoryFactory.getLocalInstance(ctx).addnew(new ObjectUuidPK(BOSUuid.create("557E499F")), materialInvInfo);
}else{
MaterialInventoryFactory.getLocalInstance(ctx).update(new ObjectUuidPK(materialInvInfo.getId()), materialInvInfo) ;
}
MaterialInventoryFactory.getLocalInstance(ctx).save(materialInvInfo);
MaterialInventoryFactory.getLocalInstance(ctx).submit(materialInvInfo);
MaterialInventoryFactory.getLocalInstance(ctx).approve(materialInvInfo);
} catch (Exception e2) {
String sql=" insert into CT_CUS_Yunzhijiamaterial (Fid, FNumber,FName_l2,CFOperType,CFOperResult,CFOperTime ,FControlUnitID,CFPERSONID,FDescription_l2) " +
" values (newbosid('E75E01FB'),'"+info.getNumber()+"','"+info.getName()+"','新增', '失败',SYSDATE,'00000000-0000-0000-0000-000000000000CCE7AED4','"+ctx.getCaller()+"','"+e2.getMessage()+"') ";
DbUtil.execute(ctx, sql);
e2.printStackTrace();
}
//销售资料页签-----------------------------------------------------------------
MaterialSalesInfo saleinfo = MaterialSalesFactory.getLocalInstance(ctx).getSalesInfo(materialId, companyInfo.getId().toString());
if(null==saleinfo){
saleinfo=new MaterialSalesInfo();
saleinfo.setEffectedStatus(1);
}
FullOrgUnitInfo saleorg = FullOrgUnitFactory.getLocalInstance(
ctx).getFullOrgUnitInfo(
"where number='"+companyInfo.getNumber()+"'");
saleinfo.setMaterial(info);
saleinfo.setOrgUnit(saleorg);
saleinfo.setCU(cu);
saleinfo.setLastUpdateUser(userInfo);
saleinfo.setLastUpdateTime(new Timestamp(System.currentTimeMillis()));
saleinfo.setPrice(BigDecimal.ZERO);
saleinfo.setAvailable(true);
saleinfo.setIsReturn(json.getString("xsisReturn").equals("")?saleinfo.isIsReturn():json.getBoolean("xsisReturn"));//是否允许退货
if(!"".equals(json.getString("saleunit"))){
saleinfo.setUnit(DataImportUtils.getMeasureUnitInfoFromNumber(ctx, json.getString("saleunit").toString()));
}
if(saleinfo.getStatus().equals(UsedStatusEnum.APPROVED)){
MaterialSalesFactory.getLocalInstance(ctx).unApprove (new ObjectUuidPK(saleinfo.getId().toString()) );
saleinfo.setStatus(UsedStatusEnum.UNAPPROVE);
}
try {
if(null==saleinfo.getId()){
MaterialSalesFactory.getLocalInstance(ctx).addnew(new ObjectUuidPK(BOSUuid.create("C84112CF")), saleinfo);
}else{
MaterialSalesFactory.getLocalInstance(ctx).update(new ObjectUuidPK(saleinfo.getId()), saleinfo);
}
MaterialSalesFactory.getLocalInstance(ctx).save(saleinfo);
MaterialSalesFactory.getLocalInstance(ctx).submit(saleinfo);
MaterialSalesFactory.getLocalInstance(ctx).approve(saleinfo );
} catch (Exception e) {
String sqlupdate=" insert into CT_CUS_Yunzhijiamaterial (Fid, FNumber,FName_l2,CFOperType,CFOperResult,CFOperTime ,FControlUnitID,CFPERSONID,FDescription_l2) " +
" values (newbosid('E75E01FB'),'"+info.getNumber()+"','"+info.getName()+"','修改', '失败',SYSDATE,'00000000-0000-0000-0000-000000000000CCE7AED4','"+ctx.getCaller()+"','"+e.getLocalizedMessage()+"') ";
DbUtil.execute(ctx, sqlupdate);
e.printStackTrace();
}
//物料成本页签-----------------------------------------------------------------------------
String sql=" select fid from T_BD_MaterialCost where FMaterialID='"+materialId+"'and FOrgUnit='"+companyInfo.getId().toString()+"' ";
IRowSet executeSQL = SQLExecutorFactory.getLocalInstance(ctx, sql).executeSQL();
String fid ="";
try {
while(executeSQL.next()){
fid = executeSQL.getString("fid");
}
} catch (SQLException e) {
e.printStackTrace();
}
MaterialCostInfo materialCostInfo =new MaterialCostInfo();
if(fid.equals("")){
materialCostInfo.setEffectedStatus(1);
}else{
materialCostInfo= MaterialCostFactory.getLocalInstance(ctx).getMaterialCostInfo(new ObjectUuidPK(fid));
}
FullOrgUnitInfo costorg = FullOrgUnitFactory.getLocalInstance(
ctx).getFullOrgUnitInfo(
"where number='"+companyInfo.getNumber()+"'");
materialCostInfo.setMaterial(info);
materialCostInfo.setOrgUnit(costorg);
//默认成本对象
if(!"".equals(json.getString("defaultCostItem"))){
materialCostInfo.setDefaultCostItem(CostItemFactory.getLocalInstance(ctx).getCostItemInfo(new ObjectUuidPK(json.getString("defaultCostItem"))));
}
//要素费用
if(!"".equals(json.getString("expense"))){
materialCostInfo.setExpense(ExpenseFactory.getLocalInstance(ctx).getExpenseInfo(new ObjectUuidPK(json.getString("expense"))));
}
materialCostInfo.setAvailable(true);
materialCostInfo.setCU(cu);
materialCostInfo.setLastUpdateUser(userInfo);
materialCostInfo.setLastUpdateTime(new Timestamp(System.currentTimeMillis()));
if(materialCostInfo.getStatus().equals(UsedStatusEnum.APPROVED)){
MaterialCostFactory.getLocalInstance(ctx).unApprove (new ObjectUuidPK(materialCostInfo.getId().toString()) );
materialCostInfo.setStatus(UsedStatusEnum.UNAPPROVE);
}
try {
if(null==materialCostInfo.getId()){
MaterialCostFactory.getLocalInstance(ctx).addnew(new ObjectUuidPK(BOSUuid.create("C45E21AA")), materialCostInfo) ;
}else{
MaterialCostFactory.getLocalInstance(ctx).update(new ObjectUuidPK(materialCostInfo.getId()), materialCostInfo);
}
MaterialCostFactory.getLocalInstance(ctx).save(materialCostInfo);
MaterialCostFactory.getLocalInstance(ctx).submit(materialCostInfo);
MaterialCostFactory.getLocalInstance(ctx).approve(materialCostInfo );
//物料存放分配-------------------------------------------------------------------------------
/* MaterialStorageAssignInfo storageInfo = new MaterialStorageAssignInfo();
storageInfo.setMaterial(info);
StorageOrgUnitInfo storageOrg = (StorageOrgUnitInfo) StorageOrgUnitFactory
.getLocalInstance(ctx).getDataBaseInfo(
"where number='000000'");
storageInfo.setStorageOrg(storageOrg);
storageInfo
.setStorageAssignType(MaterialStorageAssignTypeEnum.BYMATERIAL);
storageInfo.setAvailable(true);
storageInfo.setCU(cu);
storageInfo.setMaterialGroup(info.getMaterialGroup());
MaterialStorageAssignFactory.getLocalInstance(ctx).submit(
storageInfo);*/
} catch (EASBizException e1) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("success", false);
jsonObject.put("error", e1.getLocalizedMessage());
JSONObject data = new JSONObject();
JSONObject widgetValue = new JSONObject();
widgetValue.put("", "");
data.put("widgetValue", widgetValue);
jsonObject.put("data", data);
String sqlupdate=" insert into CT_CUS_Yunzhijiamaterial (Fid, FNumber,FName_l2,CFOperType,CFOperResult,CFOperTime ,FControlUnitID,CFPERSONID,FDescription_l2) " +
" values (newbosid('E75E01FB'),'"+info.getNumber()+"','"+info.getName()+"','修改', '失败',SYSDATE,'00000000-0000-0000-0000-000000000000CCE7AED4','"+ctx.getCaller()+"','"+e1.getLocalizedMessage()+"') ";
DbUtil.execute(ctx, sqlupdate);
return jsonObject.toJSONString();
}
System.out.println("-----------修改物料方法执行------------------------------------------------------");
String sqlupdate=" insert into CT_CUS_Yunzhijiamaterial (Fid, FNumber,FName_l2,CFOperType,CFOperResult,CFOperTime ,FControlUnitID,CFPERSONID,FDescription_l2) " +
" values (newbosid('E75E01FB'),'"+info.getNumber()+"','"+info.getName()+"','修改', '成功',SYSDATE,'00000000-0000-0000-0000-000000000000CCE7AED4','"+ctx.getCaller()+"','') ";
DbUtil.execute(ctx, sqlupdate);
return null;
}
/**
* 物料分配方法 ctx上下文中的cu 需设置为集团cu
* @param ctx
* @param strMaterialId
* @param ctrlUnitInfo
* @throws EASBizException
* @throws BOSException
*/
private void createDAssignRelation(Context ctx,BOSUuid strMaterialId,CtrlUnitInfo ctrlUnitInfo,String materialInfo , String Type)
throws EASBizException, BOSException {
CtrlUnitInfo cu = DataImportUtils.getCtrlUnitInfoFromNumber(ctx,"000000");//修改 物料基本页签 时上下文cu切换成集团组织
ContextUtil.setCurrentOrgUnit(ctx, cu);
ContextUtil.setCurrentCtrlUnit(ctx, cu);//能维护其他管理单元的资料!
/* DataBaseDAssignInfo dAssignInfo = new DataBaseDAssignInfo();
dAssignInfo.setDataBaseDID(strMaterialId);
dAssignInfo.setAssignCU(ctrlUnitInfo);
dAssignInfo.setBosObjectType("4409E7F0");
dAssignInfo.setStatus(DataStateEnum.ENABLE);
dAssignInfo.setAvailable(true);//?
DataBaseDAssignFactory.getLocalInstance(ctx).addnew(dAssignInfo);*/
String[] diddata = new String[]{strMaterialId.toString()};
String[] cuiddata = new String[]{ctrlUnitInfo.getId().toString()};
MaterialFactory.getLocalInstance(ctx).batchAssign2( cu.getId().toString() , diddata, cuiddata, new HashSet());
try {
if(Type.equals("新增")){
updateMaterialInfo( ctx, materialInfo,ctrlUnitInfo.getId().toString() );
} ; //eg: 新增物料后 分配 时 ,成本页签的 要素费用。成本对象 是分配不过来的。 标准功能也分配不过来
} catch (SQLException e) {
MaterialInfo info = MaterialFactory.getLocalInstance(ctx).getMaterialInfo(new ObjectUuidPK(strMaterialId));
String sqlupdate=" insert into CT_CUS_Yunzhijiamaterial (Fid, FNumber,FName_l2,CFOperType,CFOperResult,CFOperTime ,FControlUnitID,CFPERSONID,FDescription_l2) " +
" values (newbosid('E75E01FB'),'"+info.getNumber()+"','"+info.getName()+"','修改', '失败',SYSDATE,'00000000-0000-0000-0000-000000000000CCE7AED4','"+ctx.getCaller()+"','"+e.getLocalizedMessage()+"') ";
DbUtil.execute(ctx, sqlupdate);
e.printStackTrace();
}
}
// 获取物料编码的方法 客户编码没按组别建立 比如 物料组别01.01 下面会建 成02.02.058
public String getMaterial( Context ctx, String materialTypeNumber ) throws BOSException, SQLException {
ArrayList numberList= new ArrayList();
String sql=" select FNUMBER from T_BD_MATERIAL where FMATERIALGROUPID= ( select fid from T_BD_MATERIALGROUP where FNUMBER='"+materialTypeNumber+"' ) order by FNUMBER desc ";
IRowSet executeSQL = SQLExecutorFactory.getLocalInstance(ctx, sql).executeSQL();
String number="";
while (executeSQL.next() ) {
number=executeSQL.getString("FNUMBER");
int lastIndexOf = number.lastIndexOf(".");
String c=number.substring(lastIndexOf+1,number.length() );
numberList.add(c);
}
if(numberList.size()<=0){
numberList.add("0001");
}
Collections.sort(numberList);
number=numberList.get(numberList.size() - 1).toString();
number=new StringBuffer(materialTypeNumber).append(".").append(number).toString();
int lastIndexOf = number.lastIndexOf(".");
String c=number.substring(0, lastIndexOf+1);
// Integer b=new Integer(a.substring(lastIndexOf+1, a.length()));
String augend = number.substring(lastIndexOf+1, number.length());
long b = Long.parseLong(number.substring(lastIndexOf+1, number.length()));
//被加数前面有0,前面的0会消失, 进行补0
String format = String.format("%0"+augend.length()+"d", Long.parseLong(augend)+1);
// b=b+1;
number=c+format;
return number;
}
/**
* 物料更新方法 分配过去的物料,eq:成本页签的 要素费用不会带过去 代码实现
*/
protected String updateMaterialInfo(Context ctx, String materialInfo,String assigcu ) throws BOSException, SQLException {
Map<String, String> result = new HashMap<String, String>();
result.put("code", "0");
JSONObject json = JSON.parseObject(materialInfo);
result.put("msg", json.getString("number"));
try {
//MaterialInfo info =DataImportUtils.getMaterialInfoFromNumber(ctx, json.getString("number"));
//根据物料编码得到物料 id
String materialId = json.getString("pk").toString();
MaterialInfo info = MaterialFactory.getLocalInstance(ctx).getMaterialInfo(new ObjectUuidPK(materialId));
CtrlUnitInfo cu = CtrlUnitFactory.getLocalInstance(ctx).getCtrlUnitInfo(new ObjectUuidPK(assigcu));
ContextUtil.setCurrentOrgUnit(ctx, cu);
ContextUtil.setCurrentCtrlUnit(ctx, cu);//能维护其他管理单元的资料! 这次是把ctx上下文cu put进分配公司
MeasureUnitInfo baseunit = new MeasureUnitInfo();
baseunit = DataImportUtils.getMeasureUnitInfoFromNumber(ctx, json
.getString("unit").toString());
CompanyOrgUnitInfo companyInfo = CompanyOrgUnitFactory.getLocalInstance(ctx).getCompanyOrgUnitInfo(new ObjectUuidPK( assigcu));
EntityViewInfo view = new EntityViewInfo();
FilterInfo filterInfo = new FilterInfo();
filterInfo.getFilterItems().add(new FilterItemInfo("mateial.id",materialId, CompareType.EQUALS));
filterInfo.getFilterItems().add(new FilterItemInfo("company.id", companyInfo.getId(), CompareType.EQUALS));
view.setFilter(filterInfo);
//-------------------------------------
//财务资料页签------------------------------------------------------------------
MaterialCompanyInfoCollection materialCompanyInfoColl = MaterialCompanyInfoFactory.getLocalInstance(ctx).getMaterialCompanyInfoCollection(view);
MaterialCompanyInfoInfo mcu = materialCompanyInfoColl.get(0);
mcu.setMateial(info);
mcu.setCompany(companyInfo);
mcu.setCU(cu);
mcu.setEffectedStatus(2);
mcu.setStatus(UsedStatusEnum.UNAPPROVE);
mcu.setAccountType(AccountType.SPECIAL_ACCT);//计价方法
mcu.setCalculateType(CalculateTypeEnum.PURCHASE);//核算类别
mcu.setStandardCost(BigDecimal.ZERO);//单位标准成本
mcu.setStatus(UsedStatusEnum.UNAPPROVE);
//记账分类
if(!org.apache.commons.lang.StringUtils.isEmpty(json
.getString("kAClass"))){
mcu.setKAClass(KAClassficationFactory.getLocalInstance(ctx).getKAClassficationInfo(new ObjectUuidPK(json.getString("kAClass"))));
}
MaterialCompanyInfoFactory
.getLocalInstance(ctx).unApprove(new ObjectUuidPK(mcu.getId().toString()) );
MaterialCompanyInfoFactory
.getLocalInstance(ctx).update(new ObjectUuidPK(mcu.getId().toString()), mcu);
MaterialCompanyInfoFactory.getLocalInstance(ctx).submit(mcu);
MaterialCompanyInfoFactory.getLocalInstance(ctx).approve(mcu);
//采购资料页签-----------------------------------------------------------------
MaterialPurchasingInfo purInfo = MaterialPurchasingFactory.getLocalInstance(ctx).getPurchasingInfo(materialId, companyInfo.getId().toString());
purInfo.setIsNotControlQty(json.getBoolean("isNotControlQty"));//不控制数量
purInfo.setIsNotControlTime(json.getBoolean("isNotControlTime"));//不控制时间
purInfo.setIsReturn(json.getBoolean("cgisReturn"));//是否允许退货
purInfo.setIsPurchaseCheck(json.getBoolean("isPurchaseCheck"));//采购检验 采购检验为true时 检验组织不能为空
if(json.getBoolean("isPurchaseCheck")==true){
purInfo.setQualityOrg(QualityOrgUnitFactory.getLocalInstance(ctx).getQualityOrgUnitInfo("where number='"+companyInfo.getNumber()+"'"));
}
purInfo.setMaterial(info);
//purInfo.setOrgUnit(companyInfo);
purInfo.setEffectedStatus(1);
purInfo.setUnit(baseunit);
purInfo.setAvailable(true);
purInfo.setCU(cu);
purInfo.setAvailable(true);
purInfo.setUnit(DataImportUtils.getMeasureUnitInfoFromNumber(ctx, json
.getString("purchaseunit").toString()));//采购计量单位编码
purInfo.setProduceFactory(json.getString("produceFactory"));//生产厂家
purInfo.setProducingArea(json.getString("producingArea"));//产地
purInfo.setStatus(UsedStatusEnum.UNAPPROVE);
MaterialPurchasingFactory.getLocalInstance(ctx).unApprove (new ObjectUuidPK(purInfo.getId()) ) ;
MaterialPurchasingFactory.getLocalInstance(ctx).update(new ObjectUuidPK(purInfo.getId()), purInfo) ;
MaterialPurchasingFactory.getLocalInstance(ctx).submit(purInfo);
MaterialPurchasingFactory.getLocalInstance(ctx).approve(purInfo);
//库存资料页签--------------------------------------------------------------------------
MaterialInventoryInfo materialInvInfo =MaterialInventoryFactory.getLocalInstance(ctx).getInventoryInfo(materialId, companyInfo.getId().toString());
materialInvInfo.setMaterial(info);
//materialInvInfo.setOrgUnit(purorg);
materialInvInfo.setIsControl(true);
if(!org.apache.commons.lang.StringUtils.isEmpty(json
.getString("storeOrgUnit"))){
materialInvInfo.setUnit(DataImportUtils.getMeasureUnitInfoFromNumber(ctx, json
.getString("storeOrgUnit").toString()));
}
materialInvInfo.setEffectedStatus(1);//暂存或保存标记
materialInvInfo.setCU(cu);
materialInvInfo.setStatus(UsedStatusEnum.UNAPPROVE);
materialInvInfo.setPeriodValidUnit(TimeUnitEnum.DAY);//保质期单位
materialInvInfo.setAheadUnit(TimeUnitEnum.DAY);//提前期单位
if(!org.apache.commons.lang.StringUtils.isEmpty(json
.getString("keepDys"))){
materialInvInfo.setPeriodValid(json.getIntValue("keepDys"));//保质期
if(json.getIntValue("keepDys")==0){
materialInvInfo.setPeriodValid(1);//保质期默认值不能是0
}
}
materialInvInfo.setIsPeriodValid(json.getBoolean("isPeriodValid"));//保质期管理
materialInvInfo.setIsLotNumber(json.getBoolean("isBatchNo"));//批次管理
materialInvInfo.setIsControl(json.getBoolean("isStore"));//库存管理
if(!org.apache.commons.lang.StringUtils.isEmpty(json.getString("defaultWarehouse")))
{
materialInvInfo.setDefaultWarehouse(DataImportUtils.getWarehouseInfoFromNumber(ctx, json.getString("defaultWarehouse")));
}
materialInvInfo.setOutWarehsAhead(1);//出库失效提前期
materialInvInfo.setAvailable(true);
materialInvInfo.setStatus(UsedStatusEnum.UNAPPROVE);
MaterialInventoryFactory
.getLocalInstance(ctx).unApprove (new ObjectUuidPK(materialInvInfo.getId()) ) ;
MaterialInventoryFactory
.getLocalInstance(ctx).update(new ObjectUuidPK(materialInvInfo.getId()), materialInvInfo) ;
MaterialInventoryFactory.getLocalInstance(ctx).submit(materialInvInfo);
MaterialInventoryFactory.getLocalInstance(ctx).approve(materialInvInfo);
//销售资料页签-----------------------------------------------------------------
MaterialSalesInfo saleinfo = MaterialSalesFactory.getLocalInstance(ctx).getSalesInfo(materialId, companyInfo.getId().toString());
FullOrgUnitInfo saleorg = FullOrgUnitFactory.getLocalInstance(
ctx).getFullOrgUnitInfo(
"where number='"+companyInfo.getNumber()+"'");
saleinfo.setMaterial(info);
saleinfo.setOrgUnit(saleorg);
saleinfo.setCU(cu);
saleinfo.setPrice(BigDecimal.ZERO);
saleinfo.setStatus(UsedStatusEnum.UNAPPROVE);
saleinfo.setAvailable(true);
saleinfo.setIsReturn(json.getBoolean("xsisReturn"));//是否允许退货
if(!org.apache.commons.lang.StringUtils.isEmpty(json.getString("saleunit"))){
saleinfo.setUnit(DataImportUtils.getMeasureUnitInfoFromNumber(ctx, json.getString("saleunit").toString()));
}
MaterialSalesFactory.getLocalInstance(ctx).unApprove (new ObjectUuidPK(saleinfo.getId()) );
MaterialSalesFactory.getLocalInstance(ctx).update(new ObjectUuidPK(saleinfo.getId()), saleinfo);
MaterialSalesFactory.getLocalInstance(ctx).approve(saleinfo);
//物料成本页签-----------------------------------------------------------------------------
String sql=" select fid from T_BD_MaterialCost where FMaterialID='"+materialId+"'and FOrgUnit='"+companyInfo.getId().toString()+"' ";
IRowSet executeSQL = SQLExecutorFactory.getLocalInstance(ctx, sql).executeSQL();
String fid ="";
while(executeSQL.next()){
fid = executeSQL.getString("fid");
}
MaterialCostInfo materialCostInfo = MaterialCostFactory.getLocalInstance(ctx).getMaterialCostInfo(new ObjectUuidPK(fid));
FullOrgUnitInfo costorg = FullOrgUnitFactory.getLocalInstance(
ctx).getFullOrgUnitInfo(
"where number='"+companyInfo.getNumber()+"'");
materialCostInfo.setMaterial(info);
materialCostInfo.setOrgUnit(costorg);
//默认成本对象
if(!org.apache.commons.lang.StringUtils.isEmpty(json.getString("defaultCostItem"))){
materialCostInfo.setDefaultCostItem(CostItemFactory.getLocalInstance(ctx).getCostItemInfo(new ObjectUuidPK(json.getString("defaultCostItem"))));
}
//要素费用
if(!org.apache.commons.lang.StringUtils.isEmpty(json.getString("expense"))){
materialCostInfo.setExpense(ExpenseFactory.getLocalInstance(ctx).getExpenseInfo(new ObjectUuidPK(json.getString("expense"))));
}
materialCostInfo.setStatus(UsedStatusEnum.UNAPPROVE);
materialCostInfo.setAvailable(true);
materialCostInfo.setCU(cu);
MaterialCostFactory.getLocalInstance(ctx).unApprove (new ObjectUuidPK(materialCostInfo.getId()) );
MaterialCostFactory.getLocalInstance(ctx).update(new ObjectUuidPK(materialCostInfo.getId()), materialCostInfo);
MaterialCostFactory.getLocalInstance(ctx).submit(materialCostInfo);
MaterialCostFactory.getLocalInstance(ctx).approve(materialCostInfo);
//物料存放分配-------------------------------------------------------------------------------
/* MaterialStorageAssignInfo storageInfo = new MaterialStorageAssignInfo();
storageInfo.setMaterial(info);
StorageOrgUnitInfo storageOrg = (StorageOrgUnitInfo) StorageOrgUnitFactory
.getLocalInstance(ctx).getDataBaseInfo(
"where number='000000'");
storageInfo.setStorageOrg(storageOrg);
storageInfo
.setStorageAssignType(MaterialStorageAssignTypeEnum.BYMATERIAL);
storageInfo.setAvailable(true);
storageInfo.setCU(cu);
storageInfo.setMaterialGroup(info.getMaterialGroup());
MaterialStorageAssignFactory.getLocalInstance(ctx).submit(
storageInfo);*/
} catch (EASBizException e1) {
result.put("code", "2");
result.put("msg", e1.getMessage());
MaterialInfo info =DataImportUtils.getMaterialInfoFromNumber(ctx, json.getString("number"));
//根据物料编码得到物料 id
String sqlupdate=" insert into CT_CUS_Yunzhijiamaterial (Fid, FNumber,FName_l2,CFOperType,CFOperResult,CFOperTime ,FControlUnitID,CFPERSONID,FDescription_l2) " +
" values (newbosid('E75E01FB'),'"+info.getNumber()+"','"+info.getName()+"','分配物料后修改其他页签', '失败',SYSDATE,'00000000-0000-0000-0000-000000000000CCE7AED4','"+ctx.getCaller()+"','"+e1.getLocalizedMessage()+"') ";
DbUtil.execute(ctx, sqlupdate);
return JSON.toJSONString(result);
}
System.out.println("----------- -----------------分配物料后修改其他页签-------------------------------------");
return null;
}
/**
* 判断物料是否被引用
*/
private boolean checkReference(Context ctx, BOSUuid id)
{
RefChkFilterSet filterSet = new RefChkFilterSet();
HashSet hs = new HashSet();
hs.add("D431F8BB");
hs.add("0193BD9B");
hs.add("C84112CF");
hs.add("557E499F");
hs.add("C45E21AA");
hs.add("C463FD06");
hs.add("C8D5221F");
hs.add("AEAA1BF0");
RefChkFilter filter = new RefChkFilter(RefChkFilterItemEnum.ExcludedRefobjTypeList, hs);
filterSet.add(filter);
return ReferenceDAO.isReferenced(ctx, id, filterSet);
}
}