From b364ddc38fb2e292b3fce6d85af7954268450005 Mon Sep 17 00:00:00 2001 From: yuxueliang0813 <407010292@qq.com> Date: Fri, 23 May 2025 16:26:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=A2=E6=88=B7=E4=BE=9B=E5=BA=94=E5=95=86?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=88=86=E7=B1=BB=E6=A0=87=E5=87=86=E5=A4=84?= =?UTF-8?q?=E7=90=86=E3=80=81=E4=BC=9A=E8=AE=A1=E7=A7=91=E7=9B=AE=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=88=86=E9=85=8D=E5=90=8E=E7=89=88=E6=9C=AC=E5=8C=96?= =?UTF-8?q?=E5=AD=90=E5=85=AC=E5=8F=B8=E7=A7=91=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/operate/CustomerInitOperation.java | 31 +++++++++++------ .../plugin/operate/SupplierInitOperation.java | 34 ++++++++++++++----- .../plugin/task/PersonCustomerBankTask.java | 16 +++++---- .../fi/fi/webapi/AspAccountControler.java | 18 +++++----- .../jhzj7/fi/fi/webapi/PersonControler.java | 22 +++++++----- 5 files changed, 78 insertions(+), 43 deletions(-) diff --git a/main/java/shjh/jhzj7/fi/fi/plugin/operate/CustomerInitOperation.java b/main/java/shjh/jhzj7/fi/fi/plugin/operate/CustomerInitOperation.java index 1306b44..98d6435 100644 --- a/main/java/shjh/jhzj7/fi/fi/plugin/operate/CustomerInitOperation.java +++ b/main/java/shjh/jhzj7/fi/fi/plugin/operate/CustomerInitOperation.java @@ -30,7 +30,7 @@ public class CustomerInitOperation extends AbstractOperationServicePlugIn implem private static final String entityName = "bd_customer";//系统库 表名 T_BD_Customer private static final String cusTypeName = "bd_customergroup";//系统库 表名 t_bd_customergroup -// private static final String gdName = "bd_customergroupdetail";//系统库 客户分组 表名 t_bd_customergroupdetail + private static final String gdName = "bd_customergroupdetail";//系统库 客户分组 表名 t_bd_customergroupdetail private static final String bebankName = "bd_bebank";//系统库 行名行号 表名 t_bd_bebank private static final Log log = LogFactory.getLog(CustomerInitOperation.class); @@ -51,7 +51,7 @@ public class CustomerInitOperation extends AbstractOperationServicePlugIn implem DynamicObject custype; JSONObject json_body; Long currentSupId; -// DynamicObject custgroupdetail; + DynamicObject custgroupdetail; OperateOption oop = OperateOption.create(); DynamicObject grouporginfo = EsbUtils.getGroupOrg(); OperationResult operResult; @@ -150,14 +150,26 @@ public class CustomerInitOperation extends AbstractOperationServicePlugIn implem itemInfo.put("code",cusnumber); itemInfo.put("error","客户保存失败"+operResult.getMessage()); itemsJson.add(itemInfo); + continue; + } + //处理分类-客户只有一个分类 + custgroupdetail = BusinessDataServiceHelper.loadSingle(gdName,new QFilter[]{ + new QFilter("customer.id","=",currentSupId)}); + if(custgroupdetail == null){ + custgroupdetail = BusinessDataServiceHelper.newDynamicObject(gdName); + custgroupdetail.set("createorg", grouporginfo);//创建组织 + custgroupdetail.set("standard",EsbUtils.CUSTOMERSTAND);//客户分类标准 + custgroupdetail.set("customer",currentCus);//客户 + } + custgroupdetail.set("group",custype);//具体分类 + operResult = OperationServiceHelper.executeOperate("save", gdName, new DynamicObject[]{custgroupdetail}, oop); + if(!operResult.isSuccess()){ + log.error(String.format("客户分类保存失败:%s", json_body.toJSONString())); + itemInfo = new JSONObject(); + itemInfo.put("code",cusnumber); + itemInfo.put("error","客户分类保存失败"+operResult.getMessage()); + itemsJson.add(itemInfo); } - //处理分类 -// custgroupdetail = BusinessDataServiceHelper.newDynamicObject(gdName); -// custgroupdetail.set("createorg",JhzjUtils.GROUPID);//创建组织 -// custgroupdetail.set("standard",EsbUtils.CUSTOMERSTAND);//客户分类标准 -// custgroupdetail.set("group",custype.getLong("id"));//具体分类 -// custgroupdetail.set("customer",currentSupId);//客户 -// SaveServiceHelper.save(new DynamicObject[]{custgroupdetail}); }else{ //修改客户 名称 税务登记号 联系人 联系电话 银行信息 客户组5 currentSupId = currentCus.getLong("id"); @@ -187,7 +199,6 @@ public class CustomerInitOperation extends AbstractOperationServicePlugIn implem EsbUtils.handleAssignNew(companysJson, cusids, entityName); //处理客户取消分配--初始化时不需要用 // EsbUtils.handleUnAssign(companysJson, cusids, entityName); - if(itemsJson.isEmpty()){ this.operationResult.addSuccessPkId(pzinfo.getPkValue()); }else{ diff --git a/main/java/shjh/jhzj7/fi/fi/plugin/operate/SupplierInitOperation.java b/main/java/shjh/jhzj7/fi/fi/plugin/operate/SupplierInitOperation.java index b8abae6..94363cb 100644 --- a/main/java/shjh/jhzj7/fi/fi/plugin/operate/SupplierInitOperation.java +++ b/main/java/shjh/jhzj7/fi/fi/plugin/operate/SupplierInitOperation.java @@ -30,7 +30,7 @@ public class SupplierInitOperation extends AbstractOperationServicePlugIn implem private static final String entityName = "bd_supplier";//系统库 表名 T_BD_Supplier private static final String supTypeName = "bd_suppliergroup";//系统库 表名 t_bd_suppliergroup private static final String bebankName = "bd_bebank";//系统库 行名行号 表名 t_bd_bebank -// private static final String gdName = "bd_suppliergroupdetail";//系统库 供应商分组 表名 t_bd_suppliergroupdetail + private static final String gdName = "bd_suppliergroupdetail";//系统库 供应商分组 表名 t_bd_suppliergroupdetail private static final Log log = LogFactory.getLog(SupplierInitOperation.class); @Override @@ -73,12 +73,13 @@ public class SupplierInitOperation extends AbstractOperationServicePlugIn implem DynamicObject bebankinfo; JSONObject json_bank; Long currentSupId; -// DynamicObject suppliergroupdetail; + DynamicObject suppliergroupdetail; OperateOption oop = OperateOption.create(); DynamicObject grouporginfo = EsbUtils.getGroupOrg(); DynamicObject rmbinfo = EsbUtils.getRmb(); OperationResult operResult; Map cusids = new HashMap<>();//供应商编号和ID对应关系 + boolean isNew; for (int i = 0; i < detailsJson.size(); i++) { json_body = detailsJson.getJSONObject(i); supnumber = json_body.getString("code"); @@ -103,6 +104,7 @@ public class SupplierInitOperation extends AbstractOperationServicePlugIn implem itemsJson.add(itemInfo); continue; } + isNew = false; currentSup = BusinessDataServiceHelper.loadSingle(entityName,new QFilter[]{new QFilter("number","=",supnumber)}); if(currentSup == null){ //根据编号找不到供应商,则新增 @@ -126,13 +128,7 @@ public class SupplierInitOperation extends AbstractOperationServicePlugIn implem currentSupId = ID.genLongId(); currentSup.set("id", currentSupId); currentSup.set("masterid",currentSupId); - //处理分类 -// suppliergroupdetail = BusinessDataServiceHelper.newDynamicObject(gdName); -// suppliergroupdetail.set("createorg",JhzjUtils.GROUPID);//创建组织 -// suppliergroupdetail.set("standard",EsbUtils.SUPPLIERSTAND);//供应商分类标准 -// suppliergroupdetail.set("group",suptype.getLong("id"));//具体分类 -// suppliergroupdetail.set("supplier",currentSupId);//供应商 -// SaveServiceHelper.save(new DynamicObject[]{suppliergroupdetail}); + isNew = true; } currentSup.set("name",supname);//供应商名称 currentSup.set("tx_register_no",taxno);//税务登记号 @@ -194,6 +190,26 @@ public class SupplierInitOperation extends AbstractOperationServicePlugIn implem itemInfo.put("error","供应商保存失败"+operResult.getMessage()); itemsJson.add(itemInfo); } + //新增时处理分类-只有一个分类 + if(isNew){ + suppliergroupdetail = BusinessDataServiceHelper.loadSingle(gdName,new QFilter[]{ + new QFilter("supplier.id","=",currentSup.getLong("id"))}); + if(suppliergroupdetail == null){ + suppliergroupdetail = BusinessDataServiceHelper.newDynamicObject(gdName); + suppliergroupdetail.set("createorg", grouporginfo);//创建组织 + suppliergroupdetail.set("standard",EsbUtils.SUPPLIERSTAND);//供应商分类标准 + suppliergroupdetail.set("supplier",currentSup);//供应商 + } + suppliergroupdetail.set("group",suptype);//具体分类 + operResult = OperationServiceHelper.executeOperate("save", gdName, new DynamicObject[]{suppliergroupdetail}, oop); + if(!operResult.isSuccess()){ + log.error(String.format("供应商分类保存失败:%s", json_body.toJSONString())); + itemInfo = new JSONObject(); + itemInfo.put("code",supnumber); + itemInfo.put("error","供应商分类保存失败"+operResult.getMessage()); + itemsJson.add(itemInfo); + } + } cusids.put(supnumber,currentSup.getLong("id")); } diff --git a/main/java/shjh/jhzj7/fi/fi/plugin/task/PersonCustomerBankTask.java b/main/java/shjh/jhzj7/fi/fi/plugin/task/PersonCustomerBankTask.java index 85e7380..d12293b 100644 --- a/main/java/shjh/jhzj7/fi/fi/plugin/task/PersonCustomerBankTask.java +++ b/main/java/shjh/jhzj7/fi/fi/plugin/task/PersonCustomerBankTask.java @@ -48,24 +48,26 @@ public class PersonCustomerBankTask extends AbstractTask implements Plugin { //只处理新增 return; } + String xxyh = ups.getString("shjh_xxyh");//详细分机银行 + //根据详细分机银行 查找对应的行名行号 + DynamicObject bebankinfo = BusinessDataServiceHelper.loadSingleFromCache(bebankName,"id,number,name", + new QFilter[]{new QFilter("name","=",xxyh)}); + if(bebankinfo == null){ + return; + } String cusname = ups.getString("name");//姓名 // String skyh = ups.getString("shjh_skyh");//收款银行 - String xxyh = ups.getString("shjh_xxyh");//详细分机银行 DynamicObject bankinfo; if(doc_bank.isEmpty()){ bankinfo = doc_bank.addNew(); + bankinfo.set("isdefault_bank",true); }else{ bankinfo = doc_bank.get(0); } bankinfo.set("bankaccount",acctnum);//银行账号 bankinfo.set("accountname",cusname);//账户名称 - //根据详细分机银行 查找对应的行名行号 - DynamicObject bebankinfo = BusinessDataServiceHelper.loadSingleFromCache(bebankName,"id,name",new QFilter[]{new QFilter("name","=",xxyh)}); - if(bebankinfo != null){ - bankinfo.set("bank",bebankinfo.getLong("id"));//开户银行-行名行号 根据入参查找 - } + bankinfo.set("bank",bebankinfo);//开户银行-行名行号 根据入参查找 bankinfo.set("currency", rmbinfo);//币别 默认人民币 - bankinfo.set("isdefault_bank",true); SaveServiceHelper.save(new DynamicObject[]{currentCus}); } //客户还未生成,需要在客户生成时,从人员处获取银行账号 diff --git a/main/java/shjh/jhzj7/fi/fi/webapi/AspAccountControler.java b/main/java/shjh/jhzj7/fi/fi/webapi/AspAccountControler.java index bca345d..471942d 100644 --- a/main/java/shjh/jhzj7/fi/fi/webapi/AspAccountControler.java +++ b/main/java/shjh/jhzj7/fi/fi/webapi/AspAccountControler.java @@ -130,7 +130,7 @@ public class AspAccountControler { if("0".equals(json_body.getString("status")) || !name.equals(acctInfo.getString("name"))){ acctInfo.set("enable", 0);//科目禁用处理 acctInfo.set("name", name); - acctInfo.set("fullname", name); +// acctInfo.set("fullname", name); OperationServiceHelper.executeOperate("save", entityName, new DynamicObject[]{acctInfo}, oop); } }else{ @@ -157,8 +157,8 @@ public class AspAccountControler { itemsJson.add(itemInfo); continue; } - acctInfo.set("longnumber", number); - acctInfo.set("fullname", name); +// acctInfo.set("longnumber", number); +// acctInfo.set("fullname", name); acctInfo.set("parent", parentAcctInfo); //创建组织 acctInfo.set("createorg", grouporginfo);//创建组织 @@ -211,11 +211,10 @@ public class AspAccountControler { } JSONArray companysJson = json_obj.getJSONArray("companys"); + //处理科目分配 + EsbUtils.handleAssignNew(companysJson, acctids, entityName); //处理科目在每个公司生成 Map companyAcctMaps = handleAccountCompany(accountMaps,companysJson); - //处理科目分配和反分配 - EsbUtils.handleAssignNew(companysJson, acctids, entityName); - EsbUtils.handleUnAssignNew(companysJson, acctids, entityName); //处理每个公司下科目的核算维度和禁用状态 JSONArray asstacttypesJson = json_obj.getJSONArray("asstacttypes"); if(asstacttypesJson != null){ @@ -283,6 +282,8 @@ public class AspAccountControler { companyAcctMaps.put(number+companynum,acctInfo); } } + //最后处理科目的反分配 + EsbUtils.handleUnAssignNew(companysJson, acctids, entityName); if(itemsJson.isEmpty()){ EsbUtils.saveLog(apimenthod,"ESB",json_obj.toString(),null,true,"API"); @@ -365,6 +366,7 @@ public class AspAccountControler { } private DynamicObject copydo(DynamicObject olddo, DynamicObject hsorgInfo, JSONObject json_body){ + //根据集团的科目复制一份作为子公司的科目,此时需要处理一下核算维度,其他属性和集团一样 DynamicObject newAcctInfo = BusinessDataServiceHelper.newDynamicObject(entityName); newAcctInfo.set("accounttable", tableinfo);//TODO 科目表fid,上正式时,注意此ID newAcctInfo.set("number", olddo.getString("number")); @@ -470,8 +472,8 @@ public class AspAccountControler { acctInfo.set("accounttable", tableinfo);//科目表fid,上正式时,注意此ID acctInfo.set("number", parentnumber); acctInfo.set("name", parentname); - acctInfo.set("longnumber", parentnumber); - acctInfo.set("fullname", parentname); +// acctInfo.set("longnumber", parentnumber); +// acctInfo.set("fullname", parentname); //创建组织 acctInfo.set("createorg", grouporginfo);//创建组织 acctInfo.set("org", grouporginfo);//管理组织 diff --git a/main/java/shjh/jhzj7/fi/fi/webapi/PersonControler.java b/main/java/shjh/jhzj7/fi/fi/webapi/PersonControler.java index 066c4a1..a173a52 100644 --- a/main/java/shjh/jhzj7/fi/fi/webapi/PersonControler.java +++ b/main/java/shjh/jhzj7/fi/fi/webapi/PersonControler.java @@ -265,7 +265,9 @@ public class PersonControler implements Serializable { update t_bas_immapping SET FUSERID = (select fid from t_sec_user where fphone = '用户手机号') where fid = '用户手机号'; 如果没有同步用户,即t_bas_immapping表中查不到数据,则会跳转到苍穹登陆界面;用户输入信息之后苍穹会自动在t_bas_immapping中获取openid并存储; */ - DB.update(DBRoute.of("sys"), insertMmapping, new Object[]{ID.genLongId(),ups.getDataMap().get("shjh_oaid"),ups.getId()}); + if(!EsbUtils.isEmpty((String) ups.getDataMap().get("shjh_oaid"))){ + DB.update(DBRoute.of("sys"), insertMmapping, new Object[]{ID.genLongId(),ups.getDataMap().get("shjh_oaid"),ups.getId()}); + } } private void updatePersonImmapping(UserParam ups){ @@ -283,27 +285,29 @@ public class PersonControler implements Serializable { return; } String cusname = (String) ups.getDataMap().get("name");//姓名 - String skyh = (String) ups.getDataMap().get("shjh_skyh");//收款银行 +// String skyh = (String) ups.getDataMap().get("shjh_skyh");//收款银行 String xxyh = (String) ups.getDataMap().get("shjh_xxyh");//详细分机银行 + //根据详细分机银行 查找对应的行名行号 + DynamicObject bebankinfo = BusinessDataServiceHelper.loadSingleFromCache(bebankName,"id,number,name", + new QFilter[]{new QFilter("name","=",xxyh)}); + if(bebankinfo == null){ + return; + } DynamicObjectCollection doc_bank = currentCus.getDynamicObjectCollection("entry_bank"); DynamicObject bankinfo; if(doc_bank.isEmpty()){ bankinfo = doc_bank.addNew(); + bankinfo.set("isdefault_bank",true); }else{ bankinfo = doc_bank.get(0); } bankinfo.set("bankaccount",acctnum);//银行账号 bankinfo.set("accountname",cusname);//账户名称 - //根据详细分机银行 查找对应的行名行号 - DynamicObject bebankinfo = BusinessDataServiceHelper.loadSingleFromCache(bebankName,"id,name",new QFilter[]{new QFilter("name","=",xxyh)}); - if(bebankinfo != null){ - bankinfo.set("bank",bebankinfo.getLong("id"));//开户银行-行名行号 根据入参查找 - } + + bankinfo.set("bank",bebankinfo);//开户银行-行名行号 根据入参查找 bankinfo.set("currency", rmbinfo);//币别 默认人民币 - bankinfo.set("isdefault_bank",1); SaveServiceHelper.save(new DynamicObject[]{currentCus}); } - //客户还未生成,需要在客户生成时,从人员处获取银行账号 } }