科目初始化优化
This commit is contained in:
parent
bd10bc0f4c
commit
670c39f54f
|
|
@ -47,14 +47,166 @@ public class InitAccountFormPlugin extends AbstractFormPlugin {
|
|||
super.beforeImportEntry(e);
|
||||
//处理导入的excel数据 注意 excel中的列名必须与分录的列标识一致,否则无法识别到excel中的数据
|
||||
HashMap itemEntry = (HashMap) e.getSource();//excel表格全量数据
|
||||
ArrayList list = (ArrayList) itemEntry.get("shjh_details");//excel表格的某个页签
|
||||
ArrayList list = (ArrayList) itemEntry.get("shjh_details");//excel表格的某个页签-科目基本信息
|
||||
Iterator iterator = list.iterator();//遍历页签
|
||||
ImportEntryData importData;
|
||||
JSONObject rowdata;
|
||||
String number;//科目编号
|
||||
String name;//科目名称
|
||||
String acctType;//科目类型 资产负债类 损益类
|
||||
DynamicObject acctInfo;
|
||||
DynamicObject acctTypeInfo;
|
||||
Map<String, Long> acctids = new HashMap<>();//科目编号和ID对应关系
|
||||
Map<String, DynamicObject> accountMaps = new HashMap<>();//将科目编号与对象关联
|
||||
//先根据基础信息在集团层面生成科目,不考虑核算维度,使用逐级分配
|
||||
//再根据公司信息进行科目分配
|
||||
//最后处理每个公司下科目的核算维度和禁用状态
|
||||
StringBuilder resultstr = new StringBuilder();
|
||||
while (iterator.hasNext()) {
|
||||
importData = (ImportEntryData) iterator.next();
|
||||
rowdata = importData.getData();//具体的某行数据,key值为列名
|
||||
if("0".equals(rowdata.getString("shjh_status"))){
|
||||
//科目状态为0,不导入
|
||||
continue;
|
||||
}
|
||||
number = rowdata.getString("shjh_code");//科目编号
|
||||
name = rowdata.getString("shjh_name");//科目名称
|
||||
acctType = rowdata.getString("shjh_type");//科目类型
|
||||
acctTypeInfo = BusinessDataServiceHelper.loadSingleFromCache(acctTypeName,new QFilter[]{
|
||||
new QFilter("number","=",acctType)});
|
||||
if(acctTypeInfo == null){
|
||||
log.error(String.format("科目类型在金蝶中找不到:%s", acctType));
|
||||
resultstr.append(number);
|
||||
resultstr.append("科目类型在金蝶中找不到");
|
||||
continue;
|
||||
}
|
||||
//不存在,做新增 根据实体名称创建动态对象
|
||||
acctInfo = BusinessDataServiceHelper.newDynamicObject(entityName);
|
||||
acctInfo.set("accounttable", EsbUtils.ACCTABLE);//科目表fid,上正式时,注意此ID
|
||||
acctInfo.set("number", number);
|
||||
acctInfo.set("name", name);
|
||||
//处理父级科目
|
||||
// parentAcctInfo = getParentAcct(number);
|
||||
acctInfo.set("longnumber", number);
|
||||
acctInfo.set("fullname", name);
|
||||
// acctInfo.set("parent", parentAcctInfo.getLong("id"));
|
||||
//创建组织
|
||||
acctInfo.set("createorg", JhzjUtils.GROUPID);//创建组织
|
||||
acctInfo.set("org", JhzjUtils.GROUPID);//管理组织
|
||||
//科目类型
|
||||
acctInfo.set("accounttype", acctTypeInfo);
|
||||
//币别核算--外币核算类型--集团科目新增时默认为allcurrency
|
||||
acctInfo.set("acctcurrency", "allcurrency");//不核算外币nocurrency 指定核算币别descurrency 核算所有币别allcurrency
|
||||
acctInfo.set("ctrlstrategy", "1");//控制策略 5全局共享 7私有 1逐级分配
|
||||
acctInfo.set("control", "nocontrol");//受控系统 nocontrol 无 应付 应收 资产
|
||||
//损益类型
|
||||
acctInfo.set("pltype", getSY(acctType));
|
||||
acctInfo.set("dc", 1);//余额方向 默认为借
|
||||
acctInfo.set("level", 1);//级次 默认为1
|
||||
acctInfo.set("isleaf", true);//明细科目 默认为是
|
||||
acctInfo.set("startdate", new Date());//版本化日期
|
||||
acctInfo.set("enddate", TypeUtils.castToDate("2999-12-31"));//失效日期
|
||||
acctInfo.set("accrualdirection", "nocontrol");//科目录入方向控制 不控制nocontrol 借方debit 贷方credit
|
||||
acctInfo.set("orgcontrollevel", 1);//控制级次 默认为1
|
||||
acctInfo.set("isallowca", false);//允许公司增加下级科目 由接口同步 为false时控制级次可以不设置
|
||||
acctInfo.set("ismanual", false);//手工录入 由接口同步
|
||||
acctInfo.set("iscash", false);//现金科目 默认false sap不区分
|
||||
acctInfo.set("isbank", false);//银行科目 默认false sap不区分
|
||||
acctInfo.set("iscashequivalent", false);//现金等价物 默认false sap不区分
|
||||
acctInfo.set("isjournal", false);//登日记账 现金等价物时需要勾选
|
||||
acctInfo.set("enable", 1);//是否启用
|
||||
acctInfo.set("status", "C");//单据状态 A保存 B已提交 C已审核
|
||||
acctInfo.set("creator", RequestContext.get().getCurrUserId());//创建人
|
||||
//手动指定科目的金蝶id
|
||||
long kmId = ID.genLongId();
|
||||
acctInfo.set("id", kmId);
|
||||
acctInfo.set("masterid", kmId);//主数据内码,系统不会根据id自动生成,需要手动设置
|
||||
//保存数据:直接保存入库,不走操作校验
|
||||
SaveServiceHelper.save(new DynamicObject[]{acctInfo});
|
||||
//处理科目使用范围
|
||||
DB.update(DBRoute.of("fi"), insertSql, new Object[]{kmId,JhzjUtils.GROUPID});
|
||||
acctids.put(number,acctInfo.getLong("id"));
|
||||
accountMaps.put(number,acctInfo);
|
||||
}
|
||||
list = (ArrayList) itemEntry.get("shjh_companys");//excel表格的某个页签-科目公司信息
|
||||
iterator = list.iterator();//遍历页签
|
||||
JSONArray companysJson = new JSONArray();
|
||||
while (iterator.hasNext()) {
|
||||
importData = (ImportEntryData) iterator.next();
|
||||
rowdata = importData.getData();//具体的某行数据,key值为列名
|
||||
companysJson.add(rowdata);
|
||||
}
|
||||
//处理科目在每个公司生成
|
||||
Map<String, DynamicObject> companyAcctMaps = handleAccountCompany(accountMaps,companysJson);
|
||||
//处理科目分配
|
||||
EsbUtils.handleAssignInit(companysJson, acctids, entityName);
|
||||
//处理每个公司下科目的核算维度和禁用状态
|
||||
list = (ArrayList) itemEntry.get("shjh_hswds");//excel表格的某个页签-科目核算维度信息
|
||||
iterator = list.iterator();//遍历页签
|
||||
JSONArray asstacttypesJson = new JSONArray();
|
||||
while (iterator.hasNext()) {
|
||||
importData = (ImportEntryData) iterator.next();
|
||||
rowdata = importData.getData();//具体的某行数据,key值为列名
|
||||
asstacttypesJson.add(rowdata);
|
||||
}
|
||||
if(!asstacttypesJson.isEmpty()){
|
||||
String hsxm;//核算维度名称 基础资料
|
||||
DynamicObject hsxmInfo;//核算维度对象
|
||||
DynamicObjectCollection dochswd;
|
||||
String companynum;
|
||||
DynamicObject checkitementryInfo = null;
|
||||
JSONObject json_body;
|
||||
for (int i = 0; i < asstacttypesJson.size(); i++) {
|
||||
json_body = asstacttypesJson.getJSONObject(i);
|
||||
hsxm = json_body.getString("shjh_asstactname");
|
||||
number = json_body.getString("shjh_hcode");
|
||||
if(EsbUtils.isEmpty(hsxm)){
|
||||
log.error(String.format("核算维度为空:%s", number));
|
||||
continue;
|
||||
}
|
||||
companynum = json_body.getString("shjh_companynums");
|
||||
//根据科目核算维度中的科目编号和公司编号获取对应科目对象,不存在的不处理
|
||||
acctInfo = companyAcctMaps.get(number+companynum);
|
||||
if(acctInfo == null){
|
||||
continue;
|
||||
}
|
||||
hsxmInfo = getHsxmInfo(hsxm);
|
||||
if(hsxmInfo == null){
|
||||
log.error(String.format("核算维度在金蝶中找不到:%s", hsxm));
|
||||
resultstr.append(number);
|
||||
resultstr.append("核算维度在金蝶中找不到");
|
||||
continue;
|
||||
}
|
||||
//判断当前科目是否存在此核算维度,不存在则新增,存在则判断是否必录
|
||||
dochswd = acctInfo.getDynamicObjectCollection("checkitementry");
|
||||
for (int j = 0; j < dochswd.size(); j++) {
|
||||
checkitementryInfo = dochswd.get(j);
|
||||
if(hsxmInfo.getLong("id") == checkitementryInfo.getDynamicObject("asstactitem").getLong("id")){
|
||||
break;
|
||||
}
|
||||
checkitementryInfo = null;
|
||||
}
|
||||
if(checkitementryInfo == null || dochswd.isEmpty()){
|
||||
checkitementryInfo = dochswd.addNew();
|
||||
checkitementryInfo.set("asstactitem",hsxmInfo);
|
||||
checkitementryInfo.set("isdetail", true);//明细
|
||||
}
|
||||
if("1".equals(json_body.getString("shjh_isneed"))){
|
||||
checkitementryInfo.set("isrequire", true);//必录
|
||||
}else{
|
||||
checkitementryInfo.set("isrequire", false);//必录
|
||||
}
|
||||
acctInfo.set("isassist", true);//主表的isassist是否包含核算项目为是
|
||||
SaveServiceHelper.save(new DynamicObject[]{acctInfo});
|
||||
companyAcctMaps.put(number+companynum,acctInfo);
|
||||
}
|
||||
}
|
||||
|
||||
if(resultstr.length() > 0){
|
||||
this.getView().showMessage("科目数据处理异常"+resultstr);;
|
||||
return;
|
||||
}
|
||||
this.getView().showMessage("处理成功");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -92,173 +244,18 @@ public class InitAccountFormPlugin extends AbstractFormPlugin {
|
|||
}
|
||||
JSONArray itemsJson = new JSONArray();//返回值明细集合
|
||||
JSONObject itemInfo;//返回值明细对象
|
||||
String number;//科目编号
|
||||
String name;//科目名称
|
||||
String acctType;//科目类型 资产负债类 损益类
|
||||
DynamicObject acctInfo;
|
||||
DynamicObject acctTypeInfo;
|
||||
JSONObject json_body;
|
||||
|
||||
Map<String, Long> acctids = new HashMap<>();//科目编号和ID对应关系
|
||||
Map<String, DynamicObject> accountMaps = new HashMap<>();//将科目编号与对象关联
|
||||
//先根据基础信息在集团层面生成科目,不考虑核算维度,使用逐级分配
|
||||
//再根据公司信息进行科目分配
|
||||
//最后处理每个公司下科目的核算维度和禁用状态
|
||||
for (int i = 0; i < detailsJson.size(); i++) {
|
||||
json_body = detailsJson.getJSONObject(i);
|
||||
number = json_body.getString("code");
|
||||
name = json_body.getString("name");
|
||||
acctType = json_body.getString("type");
|
||||
if(EsbUtils.isEmpty(number) || EsbUtils.isEmpty(name) || EsbUtils.isEmpty(acctType)){
|
||||
log.error(String.format("会计科目接口入参为空异常:%s", json_body.toJSONString()));
|
||||
itemInfo = new JSONObject();
|
||||
itemInfo.put("code",number);
|
||||
itemInfo.put("error","入参值为空");
|
||||
itemsJson.add(itemInfo);
|
||||
continue;
|
||||
}
|
||||
//根据科目编号和集团ID查找对应科目是否已存在
|
||||
acctInfo = BusinessDataServiceHelper.loadSingle(entityName,new QFilter[]{new QFilter("number","=",number),
|
||||
new QFilter("createorg.id","=", JhzjUtils.GROUPID)});
|
||||
if(acctInfo != null){
|
||||
//处理科目更新逻辑,此时能修改哪些字段?名称 是否可用
|
||||
if("0".equals(json_body.getString("status")) || !name.equals(acctInfo.getString("name"))){
|
||||
acctInfo.set("enable", 0);//科目禁用处理
|
||||
acctInfo.set("name", name);
|
||||
acctInfo.set("fullname", name);
|
||||
SaveServiceHelper.save(new DynamicObject[]{acctInfo});
|
||||
}
|
||||
}else{
|
||||
acctTypeInfo = BusinessDataServiceHelper.loadSingleFromCache(acctTypeName,new QFilter[]{new QFilter("number","=",acctType)});
|
||||
if(acctTypeInfo == null){
|
||||
log.error(String.format("科目类型在金蝶中找不到:%s", acctType));
|
||||
itemInfo = new JSONObject();
|
||||
itemInfo.put("code",number);
|
||||
itemInfo.put("error","科目类型在金蝶中找不到");
|
||||
itemsJson.add(itemInfo);
|
||||
continue;
|
||||
}
|
||||
//不存在,做新增 根据实体名称创建动态对象
|
||||
acctInfo = BusinessDataServiceHelper.newDynamicObject(entityName);
|
||||
acctInfo.set("accounttable", EsbUtils.ACCTABLE);//科目表fid,上正式时,注意此ID
|
||||
acctInfo.set("number", number);
|
||||
acctInfo.set("name", name);
|
||||
//处理父级科目
|
||||
// parentAcctInfo = getParentAcct(number);
|
||||
acctInfo.set("longnumber", number);
|
||||
acctInfo.set("fullname", name);
|
||||
// acctInfo.set("parent", parentAcctInfo.getLong("id"));
|
||||
//创建组织
|
||||
acctInfo.set("createorg", JhzjUtils.GROUPID);//创建组织
|
||||
acctInfo.set("org", JhzjUtils.GROUPID);//管理组织
|
||||
//科目类型
|
||||
acctInfo.set("accounttype", acctTypeInfo);
|
||||
//币别核算--外币核算类型--集团科目新增时默认为allcurrency
|
||||
acctInfo.set("acctcurrency", "allcurrency");//不核算外币nocurrency 指定核算币别descurrency 核算所有币别allcurrency
|
||||
acctInfo.set("ctrlstrategy", "1");//控制策略 5全局共享 7私有 1逐级分配
|
||||
acctInfo.set("control", "nocontrol");//受控系统 nocontrol 无 应付 应收 资产
|
||||
//损益类型
|
||||
acctInfo.set("pltype", getSY(acctType));
|
||||
acctInfo.set("dc", 1);//余额方向 默认为借
|
||||
acctInfo.set("level", 1);//级次 默认为1
|
||||
acctInfo.set("isleaf", true);//明细科目 默认为是
|
||||
acctInfo.set("startdate", new Date());//版本化日期
|
||||
acctInfo.set("enddate", TypeUtils.castToDate("2999-12-31"));//失效日期
|
||||
acctInfo.set("accrualdirection", "nocontrol");//科目录入方向控制 不控制nocontrol 借方debit 贷方credit
|
||||
acctInfo.set("orgcontrollevel", 1);//控制级次 默认为1
|
||||
acctInfo.set("isallowca", false);//允许公司增加下级科目 由接口同步 为false时控制级次可以不设置
|
||||
acctInfo.set("ismanual", false);//手工录入 由接口同步
|
||||
acctInfo.set("iscash", false);//现金科目 默认false sap不区分
|
||||
acctInfo.set("isbank", false);//银行科目 默认false sap不区分
|
||||
acctInfo.set("iscashequivalent", false);//现金等价物 默认false sap不区分
|
||||
acctInfo.set("isjournal", false);//登日记账 现金等价物时需要勾选
|
||||
acctInfo.set("enable", 1);//是否启用
|
||||
acctInfo.set("status", "C");//单据状态 A保存 B已提交 C已审核
|
||||
acctInfo.set("creator", RequestContext.get().getCurrUserId());//创建人
|
||||
//手动指定科目的金蝶id
|
||||
long kmId = ID.genLongId();
|
||||
acctInfo.set("id", kmId);
|
||||
acctInfo.set("masterid", kmId);//主数据内码,系统不会根据id自动生成,需要手动设置
|
||||
//保存数据:直接保存入库,不走操作校验
|
||||
SaveServiceHelper.save(new DynamicObject[]{acctInfo});
|
||||
//处理科目使用范围
|
||||
DB.update(DBRoute.of("fi"), insertSql, new Object[]{kmId,JhzjUtils.GROUPID});
|
||||
}
|
||||
acctids.put(number,acctInfo.getLong("id"));
|
||||
accountMaps.put(number,acctInfo);
|
||||
}
|
||||
|
||||
JSONArray companysJson = json_obj.getJSONArray("companys");
|
||||
//处理科目在每个公司生成
|
||||
Map<String, DynamicObject> companyAcctMaps = handleAccountCompany(accountMaps,companysJson);
|
||||
//处理科目分配和反分配
|
||||
EsbUtils.handleAssign(companysJson, acctids, entityName);
|
||||
EsbUtils.handleUnAssign(companysJson, acctids, entityName);
|
||||
//处理每个公司下科目的核算维度和禁用状态
|
||||
JSONArray asstacttypesJson = json_obj.getJSONArray("asstacttypes");
|
||||
if(asstacttypesJson != null){
|
||||
String hsxm;//核算维度名称 基础资料
|
||||
DynamicObject hsxmInfo;//核算维度对象
|
||||
DynamicObjectCollection dochswd;
|
||||
String companynum;
|
||||
DynamicObject checkitementryInfo = null;
|
||||
for (int i = 0; i < asstacttypesJson.size(); i++) {
|
||||
json_body = asstacttypesJson.getJSONObject(i);
|
||||
hsxm = json_body.getString("asstactname");
|
||||
number = json_body.getString("code");
|
||||
if(EsbUtils.isEmpty(hsxm)){
|
||||
log.error(String.format("核算维度为空:%s", number));
|
||||
itemInfo = new JSONObject();
|
||||
itemInfo.put("code",number);
|
||||
itemInfo.put("error","核算维度为空"+number);
|
||||
itemsJson.add(itemInfo);
|
||||
continue;
|
||||
}
|
||||
companynum = json_body.getString("companynum");
|
||||
//根据科目核算维度中的科目编号和公司编号获取对应科目对象,不存在的不处理
|
||||
acctInfo = companyAcctMaps.get(number+companynum);
|
||||
if(acctInfo == null){
|
||||
continue;
|
||||
}
|
||||
hsxmInfo = getHsxmInfo(hsxm);
|
||||
if(hsxmInfo == null){
|
||||
log.error(String.format("核算维度在金蝶中找不到:%s", hsxm));
|
||||
itemInfo = new JSONObject();
|
||||
itemInfo.put("code",number);
|
||||
itemInfo.put("error","核算维度在金蝶中找不到"+hsxm);
|
||||
itemsJson.add(itemInfo);
|
||||
continue;
|
||||
}
|
||||
//判断当前科目是否存在此核算维度,不存在则新增,存在则判断是否必录
|
||||
dochswd = acctInfo.getDynamicObjectCollection("checkitementry");
|
||||
for (int j = 0; j < dochswd.size(); j++) {
|
||||
checkitementryInfo = dochswd.get(j);
|
||||
if(hsxmInfo.getLong("id") == checkitementryInfo.getDynamicObject("asstactitem").getLong("id")){
|
||||
break;
|
||||
}
|
||||
checkitementryInfo = null;
|
||||
}
|
||||
if(checkitementryInfo == null || dochswd.isEmpty()){
|
||||
checkitementryInfo = dochswd.addNew();
|
||||
checkitementryInfo.set("asstactitem",hsxmInfo);
|
||||
checkitementryInfo.set("isdetail", true);//明细
|
||||
}
|
||||
if("1".equals(json_body.getString("isneed"))){
|
||||
checkitementryInfo.set("isrequire", true);//必录
|
||||
}else{
|
||||
checkitementryInfo.set("isrequire", false);//必录
|
||||
}
|
||||
acctInfo.set("isassist", true);//主表的isassist是否包含核算项目为是
|
||||
SaveServiceHelper.save(new DynamicObject[]{acctInfo});
|
||||
companyAcctMaps.put(number+companynum,acctInfo);
|
||||
}
|
||||
}
|
||||
|
||||
if(!itemsJson.isEmpty()){
|
||||
this.getView().showMessage("科目数据处理异常"+itemsJson.toJSONString());;
|
||||
return;
|
||||
}
|
||||
this.getView().showMessage("处理成功");
|
||||
// for (int i = 0; i < detailsJson.size(); i++) {
|
||||
// json_body = detailsJson.getJSONObject(i);
|
||||
// if(EsbUtils.isEmpty(number) || EsbUtils.isEmpty(name) || EsbUtils.isEmpty(acctType)){
|
||||
// log.error(String.format("会计科目接口入参为空异常:%s", json_body.toJSONString()));
|
||||
// itemInfo = new JSONObject();
|
||||
// itemInfo.put("code",number);
|
||||
// itemInfo.put("error","入参值为空");
|
||||
// itemsJson.add(itemInfo);
|
||||
// continue;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("按钮处理异常:"+e.getMessage());
|
||||
|
|
@ -269,9 +266,6 @@ public class InitAccountFormPlugin extends AbstractFormPlugin {
|
|||
|
||||
private Map<String, DynamicObject> handleAccountCompany(Map<String, DynamicObject> accountMaps,JSONArray companysJson){
|
||||
Map<String, DynamicObject> baseMaps = new HashMap<>();
|
||||
if(companysJson == null){
|
||||
return baseMaps;
|
||||
}
|
||||
JSONObject json_body;
|
||||
DynamicObject oldAcctInfo;
|
||||
DynamicObject newAcctInfo;
|
||||
|
|
@ -280,8 +274,8 @@ public class InitAccountFormPlugin extends AbstractFormPlugin {
|
|||
String acctnum;
|
||||
for (int i = 0; i < companysJson.size(); i++) {
|
||||
json_body = companysJson.getJSONObject(i);
|
||||
acctnum = json_body.getString("code");//科目编号
|
||||
compnum = json_body.getString("companynum");//公司编号
|
||||
acctnum = json_body.getString("shjh_ccode");//科目编号
|
||||
compnum = json_body.getString("shjh_companynum");//公司编号
|
||||
if(EsbUtils.isEmpty(acctnum) || EsbUtils.isEmpty(compnum)){
|
||||
continue;
|
||||
}
|
||||
|
|
@ -300,7 +294,7 @@ public class InitAccountFormPlugin extends AbstractFormPlugin {
|
|||
newAcctInfo = copydo(oldAcctInfo,hsorgInfo,json_body);
|
||||
}else{
|
||||
//修改币别相关属性
|
||||
newAcctInfo.set("acctcurrency", json_body.getString("acctcurrency"));
|
||||
newAcctInfo.set("acctcurrency", json_body.getString("shjh_acctcurrency"));
|
||||
//如果是指定核算币别
|
||||
// if("descurrency".equals(json_body.getString("acctcurrency"))){
|
||||
// //处理具体币别分录数据,根据逗号进行分割
|
||||
|
|
@ -333,12 +327,13 @@ public class InitAccountFormPlugin extends AbstractFormPlugin {
|
|||
//科目类型
|
||||
newAcctInfo.set("accounttype", olddo.getDynamicObject("accounttype"));
|
||||
//币别核算--外币核算类型
|
||||
newAcctInfo.set("acctcurrency", json_body.getString("acctcurrency"));//不核算外币nocurrency 指定核算币别descurrency 核算所有币别allcurrency
|
||||
newAcctInfo.set("acctcurrency", json_body.getString("shjh_acctcurrency"));//不核算外币nocurrency 指定核算币别descurrency 核算所有币别allcurrency
|
||||
//如果是指定核算币别
|
||||
if("descurrency".equals(json_body.getString("acctcurrency")) && !EsbUtils.isEmpty(json_body.getString("descurrencynum"))){
|
||||
if("descurrency".equals(json_body.getString("shjh_acctcurrency")) &&
|
||||
!EsbUtils.isEmpty(json_body.getString("shjh_descurrencynum"))){
|
||||
//处理具体币别分录数据,根据逗号进行分割
|
||||
DynamicObjectCollection docbb = newAcctInfo.getDynamicObjectCollection("currencyentry");
|
||||
String[] dess = json_body.getString("descurrencynum").split(",");
|
||||
String[] dess = json_body.getString("shjh_descurrencynum").split(",");
|
||||
String bbiso;
|
||||
DynamicObject bbInfo;
|
||||
for (int j = 0; j < dess.length; j++) {
|
||||
|
|
|
|||
|
|
@ -38,6 +38,69 @@ public class EsbUtils {
|
|||
return null;
|
||||
}
|
||||
|
||||
//处理科目初始化时的分配
|
||||
public static void handleAssignInit(JSONArray companysJson, Map<String, Long> cusids, String entityName) {
|
||||
if(companysJson == null || cusids.isEmpty()){
|
||||
return;
|
||||
}
|
||||
JSONObject json_body;
|
||||
String compnum;
|
||||
String cusnumber = "";//当前编号
|
||||
String firstnumber = "firstnumber";//初始化编号
|
||||
Long curid;//当前数据id
|
||||
DynamicObject compinfo;
|
||||
List<Long> dataList = new ArrayList<>();
|
||||
List<Long> orgList = new ArrayList<>();
|
||||
for (int i = 0; i < companysJson.size(); i++) {
|
||||
json_body = companysJson.getJSONObject(i);
|
||||
cusnumber = json_body.getString("shjh_ccode");//客户-供应商编号
|
||||
compnum = json_body.getString("shjh_companynum");//公司编号
|
||||
if(EsbUtils.isEmpty(cusnumber) || EsbUtils.isEmpty(compnum) || "0".equals(json_body.getString("shjh_companystatus"))){
|
||||
//公司编号为空 或者 公司层面使用状态-禁用的 不处理
|
||||
continue;
|
||||
}
|
||||
//还原公司id
|
||||
compinfo = BusinessDataServiceHelper.loadSingleFromCache(orgName,"id,number",new QFilter[]{new QFilter("number","=",compnum)});
|
||||
if(compinfo == null){
|
||||
continue;
|
||||
}
|
||||
if("firstnumber".equals(firstnumber)){
|
||||
//初始化,改变初始化值
|
||||
firstnumber = cusnumber;
|
||||
orgList.add(compinfo.getLong("id"));
|
||||
}else if(firstnumber.equals(cusnumber)){
|
||||
//还是同一个客户
|
||||
orgList.add(compinfo.getLong("id"));
|
||||
}else{
|
||||
//另一个客户,先处理上一个客户的分配
|
||||
if(!orgList.isEmpty()){
|
||||
curid = cusids.get(cusnumber);
|
||||
if(curid == null){
|
||||
//当前编号对应的id不存在,即上一个数据没有保存成功 不处理分配,上一个组织数据清空,增加当前组织
|
||||
orgList.clear();
|
||||
orgList.add(compinfo.getLong("id"));
|
||||
continue;
|
||||
}
|
||||
dataList.clear();
|
||||
dataList.add(curid);
|
||||
BaseDataServiceHelper.batchAssignWithDetail(entityName,JhzjUtils.GROUPID,dataList,orgList);
|
||||
//处理完成后,清空组织列表
|
||||
orgList.clear();
|
||||
orgList.add(compinfo.getLong("id"));
|
||||
}
|
||||
firstnumber = cusnumber;
|
||||
orgList.add(compinfo.getLong("id"));
|
||||
}
|
||||
}
|
||||
curid = cusids.get(cusnumber);
|
||||
//考虑最后一个客户的分配情况
|
||||
if(!orgList.isEmpty() && curid != null){
|
||||
dataList.clear();
|
||||
dataList.add(curid);
|
||||
BaseDataServiceHelper.batchAssignWithDetail(entityName,JhzjUtils.GROUPID,dataList,orgList);
|
||||
}
|
||||
}
|
||||
|
||||
//处理分配
|
||||
public static void handleAssign(JSONArray companysJson, Map<String, Long> cusids, String entityName) {
|
||||
if(companysJson == null || cusids.isEmpty()){
|
||||
|
|
|
|||
Loading…
Reference in New Issue