主数据接口优化为save操作,利润中心和客户组5已调试

This commit is contained in:
yuxueliang0813 2025-05-22 10:02:58 +08:00
parent 56880b2a4d
commit f1f045f42f
10 changed files with 111 additions and 101 deletions

View File

@ -18,10 +18,8 @@ import kd.bos.logging.LogFactory;
import kd.bos.orm.query.QFilter; import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.OperationServiceHelper; import kd.bos.servicehelper.operation.OperationServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import kd.sdk.plugin.Plugin; import kd.sdk.plugin.Plugin;
import shjh.jhzj7.fi.fi.utils.EsbUtils; import shjh.jhzj7.fi.fi.utils.EsbUtils;
import shjh.jhzj7.fi.fi.utils.JhzjUtils;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
@ -32,7 +30,7 @@ public class CustomerInitOperation extends AbstractOperationServicePlugIn implem
private static final String entityName = "bd_customer";//系统库 表名 T_BD_Customer private static final String entityName = "bd_customer";//系统库 表名 T_BD_Customer
private static final String cusTypeName = "bd_customergroup";//系统库 表名 t_bd_customergroup 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 String bebankName = "bd_bebank";//系统库 行名行号 表名 t_bd_bebank
private static final Log log = LogFactory.getLog(CustomerInitOperation.class); private static final Log log = LogFactory.getLog(CustomerInitOperation.class);
@ -53,10 +51,11 @@ public class CustomerInitOperation extends AbstractOperationServicePlugIn implem
DynamicObject custype; DynamicObject custype;
JSONObject json_body; JSONObject json_body;
Long currentSupId; Long currentSupId;
DynamicObject custgroupdetail; // DynamicObject custgroupdetail;
OperateOption oop = OperateOption.create(); OperateOption oop = OperateOption.create();
DynamicObject grouporginfo = EsbUtils.getGroupOrg(); DynamicObject grouporginfo = EsbUtils.getGroupOrg();
OperationResult operResult; OperationResult operResult;
DynamicObject rmbinfo = EsbUtils.getRmb();
for (DynamicObject pzinfo : dos) { for (DynamicObject pzinfo : dos) {
pzinfo = BusinessDataServiceHelper.loadSingle(pzinfo.getPkValue(), pzinfo.getDataEntityType().getName()); pzinfo = BusinessDataServiceHelper.loadSingle(pzinfo.getPkValue(), pzinfo.getDataEntityType().getName());
try{ try{
@ -133,7 +132,7 @@ public class CustomerInitOperation extends AbstractOperationServicePlugIn implem
currentCus.set("masterid",currentSupId); currentCus.set("masterid",currentSupId);
//处理银行-新增-员工类客户不需要处理 //处理银行-新增-员工类客户不需要处理
if(!"M400".equals(type)){ if(!"M400".equals(type)){
handleBank(banksJson,currentCus.getDynamicObjectCollection("entry_bank"),cusnumber,cusname); handleBank(banksJson,currentCus.getDynamicObjectCollection("entry_bank"),cusnumber,cusname,rmbinfo);
}else{ }else{
//如果是个人则伙伴类型字段为个人 //如果是个人则伙伴类型字段为个人
currentCus.set("type","4");//伙伴类型 currentCus.set("type","4");//伙伴类型
@ -153,12 +152,12 @@ public class CustomerInitOperation extends AbstractOperationServicePlugIn implem
itemsJson.add(itemInfo); itemsJson.add(itemInfo);
} }
//处理分类 //处理分类
custgroupdetail = BusinessDataServiceHelper.newDynamicObject(gdName); // custgroupdetail = BusinessDataServiceHelper.newDynamicObject(gdName);
custgroupdetail.set("createorg",JhzjUtils.GROUPID);//创建组织 // custgroupdetail.set("createorg",JhzjUtils.GROUPID);//创建组织
custgroupdetail.set("standard",EsbUtils.CUSTOMERSTAND);//客户分类标准 // custgroupdetail.set("standard",EsbUtils.CUSTOMERSTAND);//客户分类标准
custgroupdetail.set("group",custype.getLong("id"));//具体分类 // custgroupdetail.set("group",custype.getLong("id"));//具体分类
custgroupdetail.set("customer",currentSupId);//客户 // custgroupdetail.set("customer",currentSupId);//客户
SaveServiceHelper.save(new DynamicObject[]{custgroupdetail}); // SaveServiceHelper.save(new DynamicObject[]{custgroupdetail});
}else{ }else{
//修改客户 名称 税务登记号 联系人 联系电话 银行信息 客户组5 //修改客户 名称 税务登记号 联系人 联系电话 银行信息 客户组5
currentSupId = currentCus.getLong("id"); currentSupId = currentCus.getLong("id");
@ -171,7 +170,7 @@ public class CustomerInitOperation extends AbstractOperationServicePlugIn implem
handleFive(customerfivesJson,currentCus.getDynamicObjectCollection("shjh_entry_five"),cusnumber); handleFive(customerfivesJson,currentCus.getDynamicObjectCollection("shjh_entry_five"),cusnumber);
//处理银行-新增-员工类客户不需要处理 //处理银行-新增-员工类客户不需要处理
if(!"M400".equals(type)){ if(!"M400".equals(type)){
handleBank(banksJson,currentCus.getDynamicObjectCollection("entry_bank"),cusnumber,cusname); handleBank(banksJson,currentCus.getDynamicObjectCollection("entry_bank"),cusnumber,cusname,rmbinfo);
} }
operResult = OperationServiceHelper.executeOperate("save", entityName, new DynamicObject[]{currentCus}, oop); operResult = OperationServiceHelper.executeOperate("save", entityName, new DynamicObject[]{currentCus}, oop);
if(!operResult.isSuccess()){ if(!operResult.isSuccess()){
@ -230,7 +229,7 @@ public class CustomerInitOperation extends AbstractOperationServicePlugIn implem
} }
} }
private void handleBank(JSONArray banksJson,DynamicObjectCollection doc_bank,String cusnumber,String cusname){ private void handleBank(JSONArray banksJson,DynamicObjectCollection doc_bank,String cusnumber,String cusname,DynamicObject rmbinfo){
if(banksJson == null){ if(banksJson == null){
return; return;
} }
@ -256,7 +255,7 @@ public class CustomerInitOperation extends AbstractOperationServicePlugIn implem
} }
bankinfo.set("bank",bebankinfo.getLong("id"));//开户银行-行名行号 根据入参查找 bankinfo.set("bank",bebankinfo.getLong("id"));//开户银行-行名行号 根据入参查找
bankinfo.set("currency", JhzjUtils.CNY);//币别 默认人民币 bankinfo.set("currency", rmbinfo);//币别 默认人民币
} }
} }
if(!doc_bank.isEmpty()){ if(!doc_bank.isEmpty()){

View File

@ -18,10 +18,8 @@ import kd.bos.logging.LogFactory;
import kd.bos.orm.query.QFilter; import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.OperationServiceHelper; import kd.bos.servicehelper.operation.OperationServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import kd.sdk.plugin.Plugin; import kd.sdk.plugin.Plugin;
import shjh.jhzj7.fi.fi.utils.EsbUtils; import shjh.jhzj7.fi.fi.utils.EsbUtils;
import shjh.jhzj7.fi.fi.utils.JhzjUtils;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
@ -32,7 +30,7 @@ public class SupplierInitOperation extends AbstractOperationServicePlugIn implem
private static final String entityName = "bd_supplier";//系统库 表名 T_BD_Supplier private static final String entityName = "bd_supplier";//系统库 表名 T_BD_Supplier
private static final String supTypeName = "bd_suppliergroup";//系统库 表名 t_bd_suppliergroup private static final String supTypeName = "bd_suppliergroup";//系统库 表名 t_bd_suppliergroup
private static final String bebankName = "bd_bebank";//系统库 行名行号 表名 t_bd_bebank 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); private static final Log log = LogFactory.getLog(SupplierInitOperation.class);
@Override @Override
@ -75,9 +73,10 @@ public class SupplierInitOperation extends AbstractOperationServicePlugIn implem
DynamicObject bebankinfo; DynamicObject bebankinfo;
JSONObject json_bank; JSONObject json_bank;
Long currentSupId; Long currentSupId;
DynamicObject suppliergroupdetail; // DynamicObject suppliergroupdetail;
OperateOption oop = OperateOption.create(); OperateOption oop = OperateOption.create();
DynamicObject grouporginfo = EsbUtils.getGroupOrg(); DynamicObject grouporginfo = EsbUtils.getGroupOrg();
DynamicObject rmbinfo = EsbUtils.getRmb();
OperationResult operResult; OperationResult operResult;
Map<String, Long> cusids = new HashMap<>();//供应商编号和ID对应关系 Map<String, Long> cusids = new HashMap<>();//供应商编号和ID对应关系
for (int i = 0; i < detailsJson.size(); i++) { for (int i = 0; i < detailsJson.size(); i++) {
@ -128,12 +127,12 @@ public class SupplierInitOperation extends AbstractOperationServicePlugIn implem
currentSup.set("id", currentSupId); currentSup.set("id", currentSupId);
currentSup.set("masterid",currentSupId); currentSup.set("masterid",currentSupId);
//处理分类 //处理分类
suppliergroupdetail = BusinessDataServiceHelper.newDynamicObject(gdName); // suppliergroupdetail = BusinessDataServiceHelper.newDynamicObject(gdName);
suppliergroupdetail.set("createorg",JhzjUtils.GROUPID);//创建组织 // suppliergroupdetail.set("createorg",JhzjUtils.GROUPID);//创建组织
suppliergroupdetail.set("standard",EsbUtils.SUPPLIERSTAND);//供应商分类标准 // suppliergroupdetail.set("standard",EsbUtils.SUPPLIERSTAND);//供应商分类标准
suppliergroupdetail.set("group",suptype.getLong("id"));//具体分类 // suppliergroupdetail.set("group",suptype.getLong("id"));//具体分类
suppliergroupdetail.set("supplier",currentSupId);//供应商 // suppliergroupdetail.set("supplier",currentSupId);//供应商
SaveServiceHelper.save(new DynamicObject[]{suppliergroupdetail}); // SaveServiceHelper.save(new DynamicObject[]{suppliergroupdetail});
} }
currentSup.set("name",supname);//供应商名称 currentSup.set("name",supname);//供应商名称
currentSup.set("tx_register_no",taxno);//税务登记号 currentSup.set("tx_register_no",taxno);//税务登记号
@ -173,8 +172,8 @@ public class SupplierInitOperation extends AbstractOperationServicePlugIn implem
}else{ }else{
bankinfo.set("accountname",json_bank.getString("acctname"));//账户名称 bankinfo.set("accountname",json_bank.getString("acctname"));//账户名称
} }
bankinfo.set("bank",bebankinfo.getLong("id"));//开户银行-行名行号 根据入参查找 bankinfo.set("bank",bebankinfo);//开户银行-行名行号 根据入参查找
bankinfo.set("currency",JhzjUtils.CNY);//币别 默认人民币 bankinfo.set("currency",rmbinfo);//币别 默认人民币
bankinfo.set("shjh_banktype",json_bank.getString("banktype"));//合作银行类型 bankinfo.set("shjh_banktype",json_bank.getString("banktype"));//合作银行类型
bankinfo.set("shjh_bankstatus",json_bank.getString("bankstatus"));//账户状态 bankinfo.set("shjh_bankstatus",json_bank.getString("bankstatus"));//账户状态
} }

View File

@ -11,7 +11,6 @@ import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper; import kd.bos.servicehelper.operation.SaveServiceHelper;
import kd.sdk.plugin.Plugin; import kd.sdk.plugin.Plugin;
import shjh.jhzj7.fi.fi.utils.EsbUtils; import shjh.jhzj7.fi.fi.utils.EsbUtils;
import shjh.jhzj7.fi.fi.utils.JhzjUtils;
import java.util.Map; import java.util.Map;
@ -30,13 +29,13 @@ public class PersonCustomerBankTask extends AbstractTask implements Plugin {
QFilter qFilter = new QFilter("shjh_acctnum", QCP.not_equals, "");//收款账号 不为空 QFilter qFilter = new QFilter("shjh_acctnum", QCP.not_equals, "");//收款账号 不为空
DynamicObject[] collection = BusinessDataServiceHelper.load(entityName, "id,number,name,shjh_acctnum,shjh_skyh,shjh_xxyh", qFilter.toArray()); DynamicObject[] collection = BusinessDataServiceHelper.load(entityName, "id,number,name,shjh_acctnum,shjh_skyh,shjh_xxyh", qFilter.toArray());
DynamicObject rmbinfo = EsbUtils.getRmb();
for (DynamicObject userinfo : collection) { for (DynamicObject userinfo : collection) {
handlePersonForCustomer(userinfo); handlePersonForCustomer(userinfo,rmbinfo);
} }
} }
private void handlePersonForCustomer(DynamicObject ups){ private void handlePersonForCustomer(DynamicObject ups,DynamicObject rmbinfo){
String cusnumber = ups.getString("number");//客户编号-即是 人员的编号 String cusnumber = ups.getString("number");//客户编号-即是 人员的编号
DynamicObject currentCus = BusinessDataServiceHelper.loadSingle(cusEntityName,new QFilter[]{new QFilter("number","=",cusnumber)}); DynamicObject currentCus = BusinessDataServiceHelper.loadSingle(cusEntityName,new QFilter[]{new QFilter("number","=",cusnumber)});
if(currentCus != null){ if(currentCus != null){
@ -65,7 +64,7 @@ public class PersonCustomerBankTask extends AbstractTask implements Plugin {
if(bebankinfo != null){ if(bebankinfo != null){
bankinfo.set("bank",bebankinfo.getLong("id"));//开户银行-行名行号 根据入参查找 bankinfo.set("bank",bebankinfo.getLong("id"));//开户银行-行名行号 根据入参查找
} }
bankinfo.set("currency", JhzjUtils.CNY);//币别 默认人民币 bankinfo.set("currency", rmbinfo);//币别 默认人民币
bankinfo.set("isdefault_bank",true); bankinfo.set("isdefault_bank",true);
SaveServiceHelper.save(new DynamicObject[]{currentCus}); SaveServiceHelper.save(new DynamicObject[]{currentCus});
} }

View File

@ -19,13 +19,15 @@ public class EsbUtils {
private static final String jklogEntityName = "shjh_jklog"; private static final String jklogEntityName = "shjh_jklog";
public static final Long CCROOTID = 100000L;//成本中心根节点ID public static final Long CCROOTID = 100000L;//成本中心根节点ID
public static final Long SUPPLIERSTATUS = 880835462149703680L;//供应商状态 默认合格 // public static final Long SUPPLIERSTATUS = 880835462149703680L;//供应商状态 默认合格
public static final Long SUPPLIERSTAND = 716529547008326656L;//供应商分类标准 public static final Long SUPPLIERSTAND = 716529547008326656L;//供应商分类标准
public static final Long CUSTOMERSTAND = 712984405228187648L;//客户分类标准 public static final Long CUSTOMERSTAND = 712984405228187648L;//客户分类标准
public static final Long CUSTOMERSTATUS = 1122390034075371520L;//客户状态 默认合格 // public static final Long CUSTOMERSTATUS = 1122390034075371520L;//客户状态 默认合格
public static final Long ACCTABLE = 2184297498435138560L;//科目表 财务库 T_BD_Accounttable public static final Long ACCTABLE = 2184297498435138560L;//科目表 财务库 T_BD_Accounttable
private static final String orgName = "bos_org";//系统库 表名 t_org_org private static final String orgName = "bos_org";//系统库 表名 t_org_org
private static final String bbName = "bd_currency";//系统库 币别 表名 t_bd_currency
public static final String deptOrgName = "上海家化联合股份有限公司";//指定部门名称-原始 public static final String deptOrgName = "上海家化联合股份有限公司";//指定部门名称-原始
public static final String newDeptOrgName = "上海家化(联合股份)";//指定部门名称--防止与业务单元中的名称重复 public static final String newDeptOrgName = "上海家化(联合股份)";//指定部门名称--防止与业务单元中的名称重复
@ -50,6 +52,11 @@ public class EsbUtils {
return BusinessDataServiceHelper.loadSingleFromCache(JhzjUtils.GROUPID,orgName); return BusinessDataServiceHelper.loadSingleFromCache(JhzjUtils.GROUPID,orgName);
} }
public static DynamicObject getRmb(){
//获取人民币对象
return BusinessDataServiceHelper.loadSingleFromCache(JhzjUtils.CNY,bbName);
}
//获取当前核算组织的编号和id对应关系 //获取当前核算组织的编号和id对应关系
public static Map<String, Long> getOrgNumberIds(){ public static Map<String, Long> getOrgNumberIds(){
Map<String, Long> orgids = new HashMap<>(); Map<String, Long> orgids = new HashMap<>();

View File

@ -9,6 +9,7 @@ import kd.bos.api.client.ApiResult;
import kd.bos.context.RequestContext; import kd.bos.context.RequestContext;
import kd.bos.dataentity.OperateOption; import kd.bos.dataentity.OperateOption;
import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.entity.operate.result.OperationResult;
import kd.bos.id.ID; import kd.bos.id.ID;
import kd.bos.logging.Log; import kd.bos.logging.Log;
import kd.bos.logging.LogFactory; import kd.bos.logging.LogFactory;
@ -29,6 +30,7 @@ import javax.validation.Valid;
public class CostCenterControler { public class CostCenterControler {
private static final String entityName = "bos_costcenter";//系统库 表名 t_bas_costcenter private static final String entityName = "bos_costcenter";//系统库 表名 t_bas_costcenter
private static final String orgEntName = "bos_org";//系统库 表名 t_org_org private static final String orgEntName = "bos_org";//系统库 表名 t_org_org
private static final String dutyName = "bos_org_duty";//系统库 表名 t_org_duty 部门属性
private static final String apimenthod = "/costcenter_sync"; private static final String apimenthod = "/costcenter_sync";
private static final Log log = LogFactory.getLog(CostCenterControler.class); private static final Log log = LogFactory.getLog(CostCenterControler.class);
@ -71,6 +73,7 @@ public class CostCenterControler {
DynamicObject companyInfo; DynamicObject companyInfo;
JSONObject json_body; JSONObject json_body;
OperateOption oop = OperateOption.create(); OperateOption oop = OperateOption.create();
OperationResult operResult;
for (int i = 0; i < detailsJson.size(); i++) { for (int i = 0; i < detailsJson.size(); i++) {
json_body = detailsJson.getJSONObject(i); json_body = detailsJson.getJSONObject(i);
orgNumber = json_body.getString("code");//成本中心编号 orgNumber = json_body.getString("code");//成本中心编号
@ -111,7 +114,7 @@ public class CostCenterControler {
itemsJson.add(itemInfo); itemsJson.add(itemInfo);
continue; continue;
} }
currentOrg.set("accountorg",companyInfo.getLong("id")); currentOrg.set("accountorg",companyInfo);
currentOrg.set("addtype","manual");//新增方式默认手工新增 currentOrg.set("addtype","manual");//新增方式默认手工新增
currentOrg.set("status","C");//数据状态 currentOrg.set("status","C");//数据状态
currentOrg.set("creator", RequestContext.get().getCurrUserId());//创建人 currentOrg.set("creator", RequestContext.get().getCurrUserId());//创建人
@ -120,8 +123,8 @@ public class CostCenterControler {
currentOrg.set("level",2);//层级默认为2不会改变 currentOrg.set("level",2);//层级默认为2不会改变
//处理长编号和长名称 //处理长编号和长名称
if(parentOrg != null){ if(parentOrg != null){
currentOrg.set("parent",parentOrg.getLong("id"));//父级 currentOrg.set("parent",parentOrg);//父级
currentOrg.set("longnumber",parentOrg.getString("number")+"."+orgNumber); // currentOrg.set("longnumber",parentOrg.getString("number")+"."+orgNumber);
}else{ }else{
currentOrg.set("longnumber",orgNumber); currentOrg.set("longnumber",orgNumber);
} }
@ -134,7 +137,7 @@ public class CostCenterControler {
currentOrg.set("orgduty",getDuty(typeNum));//类型 currentOrg.set("orgduty",getDuty(typeNum));//类型
currentOrg.set("shjh_comids",json_body.getString("other_company"));//跨公司ID currentOrg.set("shjh_comids",json_body.getString("other_company"));//跨公司ID
if(parentOrg != null){ if(parentOrg != null){
currentOrg.set("fullname",parentOrg.getString("name")+"."+orgName); // currentOrg.set("fullname",parentOrg.getString("name")+"."+orgName);
}else{ }else{
currentOrg.set("fullname",orgName); currentOrg.set("fullname",orgName);
} }
@ -144,12 +147,14 @@ public class CostCenterControler {
} }
//保存成本中心-必须调用保存操作否则不符合受控基础资料开发规范 //保存成本中心-必须调用保存操作否则不符合受控基础资料开发规范
// SaveServiceHelper.save(new DynamicObject[]{currentOrg}); // SaveServiceHelper.save(new DynamicObject[]{currentOrg});
OperationServiceHelper.executeOperate("save", entityName, new DynamicObject[]{currentOrg}, oop); operResult = OperationServiceHelper.executeOperate("save", entityName, new DynamicObject[]{currentOrg}, oop);
// itemInfo = new JSONObject(); if(!operResult.isSuccess()){
// itemInfo.put("pkId",orgNumber); log.error(String.format("成本中心保存失败:%s", json_body.toJSONString()));
// itemInfo.put("status","1"); itemInfo = new JSONObject();
// itemInfo.put("message",""); itemInfo.put("code",orgNumber);
// itemsJson.add(itemInfo); itemInfo.put("error","成本中心保存失败"+operResult.getMessage());
itemsJson.add(itemInfo);
}
} }
if(itemsJson.isEmpty()){ if(itemsJson.isEmpty()){
@ -163,29 +168,27 @@ public class CostCenterControler {
} }
//金蝶成本中心的部门属性 bos_org_duty 表名 t_org_duty //金蝶成本中心的部门属性 bos_org_duty 表名 t_org_duty
private Long getDuty(String type){ private DynamicObject getDuty(String type){
Long typevalue; DynamicObject typevalue;
switch (type){ switch (type){
case "L": case "L":
typevalue = 1l;//管理 typevalue = BusinessDataServiceHelper.loadSingleFromCache(1L,dutyName);//管理
break; break;
case "E": case "E":
typevalue = 2l;//开发 typevalue = BusinessDataServiceHelper.loadSingleFromCache(2L,dutyName);//开发
break; break;
case "V": case "V":
typevalue = 3l;//销售 typevalue = BusinessDataServiceHelper.loadSingleFromCache(3L,dutyName);//销售
break; break;
case "F": case "F":
typevalue = 4l;//生产 typevalue = BusinessDataServiceHelper.loadSingleFromCache(4L,dutyName);//生产
break; break;
case "H": case "H":
typevalue = 2134881123853953024l;//服务成本中心
break;
case "NULL": case "NULL":
typevalue = 0l;// typevalue = BusinessDataServiceHelper.loadSingleFromCache(2134881123853953024L,dutyName);//服务成本中心
break; break;
default: default:
typevalue = 0l; typevalue = BusinessDataServiceHelper.loadSingleFromCache(2134881123853953024L,dutyName);
} }
return typevalue; return typevalue;
} }

View File

@ -21,9 +21,7 @@ import kd.bos.openapi.common.result.CustomApiResult;
import kd.bos.orm.query.QFilter; import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.OperationServiceHelper; import kd.bos.servicehelper.operation.OperationServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import shjh.jhzj7.fi.fi.utils.EsbUtils; import shjh.jhzj7.fi.fi.utils.EsbUtils;
import shjh.jhzj7.fi.fi.utils.JhzjUtils;
import shjh.jhzj7.fi.fi.webapi.model.CustomerModel; import shjh.jhzj7.fi.fi.webapi.model.CustomerModel;
import javax.validation.Valid; import javax.validation.Valid;
@ -36,7 +34,7 @@ public class CustomerControler {
private static final String entityName = "bd_customer";//系统库 表名 T_BD_Customer private static final String entityName = "bd_customer";//系统库 表名 T_BD_Customer
private static final String cusTypeName = "bd_customergroup";//系统库 表名 t_bd_customergroup 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 String bebankName = "bd_bebank";//系统库 行名行号 表名 t_bd_bebank
private static final Log log = LogFactory.getLog(CustomerControler.class); private static final Log log = LogFactory.getLog(CustomerControler.class);
private static final String apimenthod = "/customer_sync"; private static final String apimenthod = "/customer_sync";
@ -76,10 +74,11 @@ public class CustomerControler {
DynamicObject custype; DynamicObject custype;
JSONObject json_body; JSONObject json_body;
Long currentSupId; Long currentSupId;
DynamicObject custgroupdetail; // DynamicObject custgroupdetail;
Map<String, Long> cusids = new HashMap<>();//客户编号和ID对应关系 Map<String, Long> cusids = new HashMap<>();//客户编号和ID对应关系
OperateOption oop = OperateOption.create(); OperateOption oop = OperateOption.create();
DynamicObject grouporginfo = EsbUtils.getGroupOrg(); DynamicObject grouporginfo = EsbUtils.getGroupOrg();
DynamicObject rmbinfo = EsbUtils.getRmb();
OperationResult operResult; OperationResult operResult;
for (int i = 0; i < detailsJson.size(); i++) { for (int i = 0; i < detailsJson.size(); i++) {
json_body = detailsJson.getJSONObject(i); json_body = detailsJson.getJSONObject(i);
@ -135,7 +134,7 @@ public class CustomerControler {
currentCus.set("masterid",currentSupId); currentCus.set("masterid",currentSupId);
//处理银行-新增-员工类客户不需要处理 //处理银行-新增-员工类客户不需要处理
if(!"M400".equals(type)){ if(!"M400".equals(type)){
handleBank(banksJson,currentCus.getDynamicObjectCollection("entry_bank"),cusnumber,cusname); handleBank(banksJson,currentCus.getDynamicObjectCollection("entry_bank"),cusnumber,cusname,rmbinfo);
}else{ }else{
//如果是个人则伙伴类型字段为个人 //如果是个人则伙伴类型字段为个人
currentCus.set("type","4");//伙伴类型 currentCus.set("type","4");//伙伴类型
@ -154,12 +153,12 @@ public class CustomerControler {
itemsJson.add(itemInfo); itemsJson.add(itemInfo);
} }
//处理分类 //处理分类
custgroupdetail = BusinessDataServiceHelper.newDynamicObject(gdName); // custgroupdetail = BusinessDataServiceHelper.newDynamicObject(gdName);
custgroupdetail.set("createorg",JhzjUtils.GROUPID);//创建组织 // custgroupdetail.set("createorg",JhzjUtils.GROUPID);//创建组织
custgroupdetail.set("standard",EsbUtils.CUSTOMERSTAND);//客户分类标准 // custgroupdetail.set("standard",EsbUtils.CUSTOMERSTAND);//客户分类标准
custgroupdetail.set("group",custype.getLong("id"));//具体分类 // custgroupdetail.set("group",custype.getLong("id"));//具体分类
custgroupdetail.set("customer",currentSupId);//客户 // custgroupdetail.set("customer",currentSupId);//客户
SaveServiceHelper.save(new DynamicObject[]{custgroupdetail}); // SaveServiceHelper.save(new DynamicObject[]{custgroupdetail});
}else{ }else{
//修改客户 名称 税务登记号 联系人 联系电话 银行信息 客户组5 //修改客户 名称 税务登记号 联系人 联系电话 银行信息 客户组5
currentSupId = currentCus.getLong("id"); currentSupId = currentCus.getLong("id");
@ -172,7 +171,7 @@ public class CustomerControler {
handleFive(customerfivesJson,currentCus.getDynamicObjectCollection("shjh_entry_five"),cusnumber); handleFive(customerfivesJson,currentCus.getDynamicObjectCollection("shjh_entry_five"),cusnumber);
//处理银行-新增-员工类客户不需要处理 //处理银行-新增-员工类客户不需要处理
if(!"M400".equals(type)){ if(!"M400".equals(type)){
handleBank(banksJson,currentCus.getDynamicObjectCollection("entry_bank"),cusnumber,cusname); handleBank(banksJson,currentCus.getDynamicObjectCollection("entry_bank"),cusnumber,cusname,rmbinfo);
} }
operResult = OperationServiceHelper.executeOperate("save", entityName, new DynamicObject[]{currentCus}, oop); operResult = OperationServiceHelper.executeOperate("save", entityName, new DynamicObject[]{currentCus}, oop);
if(!operResult.isSuccess()){ if(!operResult.isSuccess()){
@ -246,7 +245,7 @@ public class CustomerControler {
return null; return null;
} }
private void handleBank(JSONArray banksJson,DynamicObjectCollection doc_bank,String cusnumber,String cusname){ private void handleBank(JSONArray banksJson,DynamicObjectCollection doc_bank,String cusnumber,String cusname,DynamicObject rmbinfo){
if(banksJson == null){ if(banksJson == null){
return; return;
} }
@ -275,7 +274,7 @@ public class CustomerControler {
} }
bankinfo.set("bank",bebankinfo);//开户银行-行名行号 根据入参查找 bankinfo.set("bank",bebankinfo);//开户银行-行名行号 根据入参查找
bankinfo.set("currency", JhzjUtils.CNY);//币别 默认人民币 bankinfo.set("currency", rmbinfo);//币别 默认人民币
} }
} }
if(!doc_bank.isEmpty()){ if(!doc_bank.isEmpty()){

View File

@ -9,6 +9,7 @@ import kd.bos.api.client.ApiResult;
import kd.bos.context.RequestContext; import kd.bos.context.RequestContext;
import kd.bos.dataentity.OperateOption; import kd.bos.dataentity.OperateOption;
import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.entity.operate.result.OperationResult;
import kd.bos.id.ID; import kd.bos.id.ID;
import kd.bos.logging.Log; import kd.bos.logging.Log;
import kd.bos.logging.LogFactory; import kd.bos.logging.LogFactory;
@ -19,7 +20,6 @@ import kd.bos.openapi.common.result.CustomApiResult;
import kd.bos.orm.query.QFilter; import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.OperationServiceHelper; import kd.bos.servicehelper.operation.OperationServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import shjh.jhzj7.fi.fi.utils.EsbUtils; import shjh.jhzj7.fi.fi.utils.EsbUtils;
import shjh.jhzj7.fi.fi.webapi.model.CustomerFiveModel; import shjh.jhzj7.fi.fi.webapi.model.CustomerFiveModel;
@ -68,6 +68,7 @@ public class CustomerFiveControler {
DynamicObject currentOrg; DynamicObject currentOrg;
JSONObject json_body; JSONObject json_body;
OperateOption oop = OperateOption.create(); OperateOption oop = OperateOption.create();
OperationResult operResult;
for (int i = 0; i < detailsJson.size(); i++) { for (int i = 0; i < detailsJson.size(); i++) {
json_body = detailsJson.getJSONObject(i); json_body = detailsJson.getJSONObject(i);
orgNumber = json_body.getString("code"); orgNumber = json_body.getString("code");
@ -80,7 +81,7 @@ public class CustomerFiveControler {
subchannelname = json_body.getString("subchannelname"); subchannelname = json_body.getString("subchannelname");
startdate = json_body.getDate("startdate"); startdate = json_body.getDate("startdate");
enddate = json_body.getDate("enddate"); enddate = json_body.getDate("enddate");
if(EsbUtils.isEmpty(orgNumber) || EsbUtils.isEmpty(orgName) || startdate == null || enddate == null){ if(EsbUtils.isEmpty(orgNumber) || EsbUtils.isEmpty(orgName)){
log.error(String.format("客户组5接口入参为空异常%s", json_body.toJSONString())); log.error(String.format("客户组5接口入参为空异常%s", json_body.toJSONString()));
itemInfo = new JSONObject(); itemInfo = new JSONObject();
itemInfo.put("code",orgNumber); itemInfo.put("code",orgNumber);
@ -116,8 +117,15 @@ public class CustomerFiveControler {
if("0".equals(json_body.getString("status"))){ if("0".equals(json_body.getString("status"))){
currentOrg.set("enable",0); currentOrg.set("enable",0);
} }
SaveServiceHelper.save(new DynamicObject[]{currentOrg}); // SaveServiceHelper.save(new DynamicObject[]{currentOrg});
OperationServiceHelper.executeOperate("save", entityName, new DynamicObject[]{currentOrg}, oop); operResult = OperationServiceHelper.executeOperate("save", entityName, new DynamicObject[]{currentOrg}, oop);
if(!operResult.isSuccess()){
log.error(String.format("客户组5保存失败%s", json_body.toJSONString()));
itemInfo = new JSONObject();
itemInfo.put("code",orgNumber);
itemInfo.put("error","客户组5保存失败"+operResult.getMessage());
itemsJson.add(itemInfo);
}
} }
if(itemsJson.isEmpty()){ if(itemsJson.isEmpty()){
EsbUtils.saveLog(apimenthod,"ESB",json_obj.toString(),null,true,"API"); EsbUtils.saveLog(apimenthod,"ESB",json_obj.toString(),null,true,"API");

View File

@ -24,7 +24,6 @@ import kd.bos.servicehelper.QueryServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper; import kd.bos.servicehelper.operation.SaveServiceHelper;
import kd.bos.servicehelper.user.UserServiceHelper; import kd.bos.servicehelper.user.UserServiceHelper;
import shjh.jhzj7.fi.fi.utils.EsbUtils; import shjh.jhzj7.fi.fi.utils.EsbUtils;
import shjh.jhzj7.fi.fi.utils.JhzjUtils;
import shjh.jhzj7.fi.fi.webapi.model.PersonModel; import shjh.jhzj7.fi.fi.webapi.model.PersonModel;
import javax.validation.Valid; import javax.validation.Valid;
@ -200,6 +199,7 @@ public class PersonControler implements Serializable {
updateList.add(user); updateList.add(user);
} }
} }
DynamicObject rmbinfo = EsbUtils.getRmb();
String handleResult; String handleResult;
//处理新增的用户 //处理新增的用户
if(!addList.isEmpty()){ if(!addList.isEmpty()){
@ -217,7 +217,7 @@ public class PersonControler implements Serializable {
// itemInfo.put("status","1"); // itemInfo.put("status","1");
// itemInfo.put("message",""); // itemInfo.put("message","");
//更新人员对应客户的银行信息 //更新人员对应客户的银行信息
handlePersonForCustomer(result); handlePersonForCustomer(result,rmbinfo);
//新增人员金蝶id和企微id的对应关系 //新增人员金蝶id和企微id的对应关系
insertPersonImmapping(result); insertPersonImmapping(result);
} }
@ -239,7 +239,7 @@ public class PersonControler implements Serializable {
// itemInfo.put("status","1"); // itemInfo.put("status","1");
// itemInfo.put("message",""); // itemInfo.put("message","");
//更新人员对应客户的银行信息 //更新人员对应客户的银行信息
handlePersonForCustomer(result); handlePersonForCustomer(result,rmbinfo);
//修改人员金蝶id和企微id的对应关系 //修改人员金蝶id和企微id的对应关系
updatePersonImmapping(result); updatePersonImmapping(result);
} }
@ -274,7 +274,7 @@ public class PersonControler implements Serializable {
} }
} }
private void handlePersonForCustomer(UserParam ups){ private void handlePersonForCustomer(UserParam ups,DynamicObject rmbinfo){
String cusnumber = (String) ups.getDataMap().get("number");//客户编号-即是 人员的编号 String cusnumber = (String) ups.getDataMap().get("number");//客户编号-即是 人员的编号
DynamicObject currentCus = BusinessDataServiceHelper.loadSingle(cusEntityName,new QFilter[]{new QFilter("number","=",cusnumber)}); DynamicObject currentCus = BusinessDataServiceHelper.loadSingle(cusEntityName,new QFilter[]{new QFilter("number","=",cusnumber)});
if(currentCus != null){ if(currentCus != null){
@ -299,7 +299,7 @@ public class PersonControler implements Serializable {
if(bebankinfo != null){ if(bebankinfo != null){
bankinfo.set("bank",bebankinfo.getLong("id"));//开户银行-行名行号 根据入参查找 bankinfo.set("bank",bebankinfo.getLong("id"));//开户银行-行名行号 根据入参查找
} }
bankinfo.set("currency", JhzjUtils.CNY);//币别 默认人民币 bankinfo.set("currency", rmbinfo);//币别 默认人民币
bankinfo.set("isdefault_bank",1); bankinfo.set("isdefault_bank",1);
SaveServiceHelper.save(new DynamicObject[]{currentCus}); SaveServiceHelper.save(new DynamicObject[]{currentCus});
} }

View File

@ -9,6 +9,7 @@ import kd.bos.api.client.ApiResult;
import kd.bos.context.RequestContext; import kd.bos.context.RequestContext;
import kd.bos.dataentity.OperateOption; import kd.bos.dataentity.OperateOption;
import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.entity.operate.result.OperationResult;
import kd.bos.id.ID; import kd.bos.id.ID;
import kd.bos.logging.Log; import kd.bos.logging.Log;
import kd.bos.logging.LogFactory; import kd.bos.logging.LogFactory;
@ -58,6 +59,7 @@ public class ProfitCenterControler {
DynamicObject currentOrg; DynamicObject currentOrg;
JSONObject json_body; JSONObject json_body;
OperateOption oop = OperateOption.create(); OperateOption oop = OperateOption.create();
OperationResult operResult;
for (int i = 0; i < detailsJson.size(); i++) { for (int i = 0; i < detailsJson.size(); i++) {
json_body = detailsJson.getJSONObject(i); json_body = detailsJson.getJSONObject(i);
orgNumber = json_body.getString("code"); orgNumber = json_body.getString("code");
@ -89,7 +91,14 @@ public class ProfitCenterControler {
currentOrg.set("enable",0); currentOrg.set("enable",0);
} }
// SaveServiceHelper.save(new DynamicObject[]{currentOrg}); // SaveServiceHelper.save(new DynamicObject[]{currentOrg});
OperationServiceHelper.executeOperate("save", entityName, new DynamicObject[]{currentOrg}, oop); operResult = OperationServiceHelper.executeOperate("save", entityName, new DynamicObject[]{currentOrg}, oop);
if(!operResult.isSuccess()){
log.error(String.format("利润中心保存失败:%s", json_body.toJSONString()));
itemInfo = new JSONObject();
itemInfo.put("code",orgNumber);
itemInfo.put("error","利润中心保存失败"+operResult.getMessage());
itemsJson.add(itemInfo);
}
} }
if(itemsJson.isEmpty()){ if(itemsJson.isEmpty()){
EsbUtils.saveLog(apimenthod,"ESB",json_obj.toString(),null,true,"API"); EsbUtils.saveLog(apimenthod,"ESB",json_obj.toString(),null,true,"API");

View File

@ -21,9 +21,7 @@ import kd.bos.openapi.common.result.CustomApiResult;
import kd.bos.orm.query.QFilter; import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.OperationServiceHelper; import kd.bos.servicehelper.operation.OperationServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import shjh.jhzj7.fi.fi.utils.EsbUtils; import shjh.jhzj7.fi.fi.utils.EsbUtils;
import shjh.jhzj7.fi.fi.utils.JhzjUtils;
import shjh.jhzj7.fi.fi.webapi.model.SupplierModel; import shjh.jhzj7.fi.fi.webapi.model.SupplierModel;
import javax.validation.Valid; import javax.validation.Valid;
@ -36,7 +34,8 @@ public class SupplierControler {
private static final String entityName = "bd_supplier";//系统库 表名 T_BD_Supplier private static final String entityName = "bd_supplier";//系统库 表名 T_BD_Supplier
private static final String supTypeName = "bd_suppliergroup";//系统库 表名 t_bd_suppliergroup private static final String supTypeName = "bd_suppliergroup";//系统库 表名 t_bd_suppliergroup
private static final String bebankName = "bd_bebank";//系统库 行名行号 表名 t_bd_bebank 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 String parterName = "bd_bizpartner";//系统库 商务伙伴 表名 T_BD_BizPartner // private static final String parterName = "bd_bizpartner";//系统库 商务伙伴 表名 T_BD_BizPartner
private static final Log log = LogFactory.getLog(SupplierControler.class); private static final Log log = LogFactory.getLog(SupplierControler.class);
private static final String apimenthod = "/supplier_sync"; private static final String apimenthod = "/supplier_sync";
@ -81,11 +80,12 @@ public class SupplierControler {
DynamicObject bebankinfo; DynamicObject bebankinfo;
JSONObject json_bank; JSONObject json_bank;
Long currentSupId; Long currentSupId;
DynamicObject suppliergroupdetail; // DynamicObject suppliergroupdetail;
// DynamicObject parterInfo; // DynamicObject parterInfo;
Map<String, Long> cusids = new HashMap<>();//供应商编号和ID对应关系 Map<String, Long> cusids = new HashMap<>();//供应商编号和ID对应关系
OperateOption oop = OperateOption.create(); OperateOption oop = OperateOption.create();
DynamicObject grouporginfo = EsbUtils.getGroupOrg(); DynamicObject grouporginfo = EsbUtils.getGroupOrg();
DynamicObject rmbinfo = EsbUtils.getRmb();
OperationResult operResult; OperationResult operResult;
for (int i = 0; i < detailsJson.size(); i++) { for (int i = 0; i < detailsJson.size(); i++) {
json_body = detailsJson.getJSONObject(i); json_body = detailsJson.getJSONObject(i);
@ -135,12 +135,12 @@ public class SupplierControler {
currentSup.set("id", currentSupId); currentSup.set("id", currentSupId);
currentSup.set("masterid",currentSupId); currentSup.set("masterid",currentSupId);
//处理分类 //处理分类
suppliergroupdetail = BusinessDataServiceHelper.newDynamicObject(gdName); // suppliergroupdetail = BusinessDataServiceHelper.newDynamicObject(gdName);
suppliergroupdetail.set("createorg",JhzjUtils.GROUPID);//创建组织 // suppliergroupdetail.set("createorg",JhzjUtils.GROUPID);//创建组织
suppliergroupdetail.set("standard",EsbUtils.SUPPLIERSTAND);//供应商分类标准 // suppliergroupdetail.set("standard",EsbUtils.SUPPLIERSTAND);//供应商分类标准
suppliergroupdetail.set("group",suptype.getLong("id"));//具体分类 // suppliergroupdetail.set("group",suptype.getLong("id"));//具体分类
suppliergroupdetail.set("supplier",currentSupId);//供应商 // suppliergroupdetail.set("supplier",currentSupId);//供应商
SaveServiceHelper.save(new DynamicObject[]{suppliergroupdetail}); // SaveServiceHelper.save(new DynamicObject[]{suppliergroupdetail});
} }
currentSup.set("name",supname);//供应商名称 currentSup.set("name",supname);//供应商名称
currentSup.set("tx_register_no",taxno);//税务登记号 currentSup.set("tx_register_no",taxno);//税务登记号
@ -163,11 +163,6 @@ public class SupplierControler {
bankcode = json_bank.getString("bankcode"); bankcode = json_bank.getString("bankcode");
if(EsbUtils.isEmpty(bankcode)){ if(EsbUtils.isEmpty(bankcode)){
//联行号为空不处理 //联行号为空不处理
// log.error(String.format("供应商行名行号为空异常:%s", json_bank.toJSONString()));
// itemInfo = new JSONObject();
// itemInfo.put("code",supnumber);
// itemInfo.put("error","行名行号入参值为空");
// itemsJson.add(itemInfo);
continue; continue;
} }
bebankinfo = BusinessDataServiceHelper.loadSingleFromCache(bebankName,"id,number",new QFilter[]{new QFilter("number","=",bankcode)}); bebankinfo = BusinessDataServiceHelper.loadSingleFromCache(bebankName,"id,number",new QFilter[]{new QFilter("number","=",bankcode)});
@ -175,14 +170,6 @@ public class SupplierControler {
//联行号在金蝶中无对应记录不处理 //联行号在金蝶中无对应记录不处理
continue; continue;
} }
// if(bebankinfo == null){
// log.error(String.format("供应商行名行号未匹配:%s", json_bank.toJSONString()));
// itemInfo = new JSONObject();
// itemInfo.put("code",supnumber);
// itemInfo.put("error","供应商行名行号未匹配");
// itemsJson.add(itemInfo);
// continue;
// }
//供应商银行账户对象从现有集合中查找查找不到则新增 //供应商银行账户对象从现有集合中查找查找不到则新增
bankinfo = getBankInfo(doc_bank,json_bank.getString("banknumber")); bankinfo = getBankInfo(doc_bank,json_bank.getString("banknumber"));
if(bankinfo == null && "E".equals(json_bank.getString("bankstatus"))){ if(bankinfo == null && "E".equals(json_bank.getString("bankstatus"))){
@ -200,7 +187,7 @@ public class SupplierControler {
bankinfo.set("accountname",json_bank.getString("acctname"));//账户名称 bankinfo.set("accountname",json_bank.getString("acctname"));//账户名称
} }
bankinfo.set("bank",bebankinfo);//开户银行-行名行号 根据入参查找 bankinfo.set("bank",bebankinfo);//开户银行-行名行号 根据入参查找
bankinfo.set("currency",BusinessDataServiceHelper.loadSingleFromCache(JhzjUtils.CNY,"bd_currency"));//币别 默认人民币 bankinfo.set("currency",rmbinfo);//币别 默认人民币
bankinfo.set("shjh_banktype",json_bank.getString("banktype"));//合作银行类型 bankinfo.set("shjh_banktype",json_bank.getString("banktype"));//合作银行类型
bankinfo.set("shjh_bankstatus",json_bank.getString("bankstatus"));//账户状态 bankinfo.set("shjh_bankstatus",json_bank.getString("bankstatus"));//账户状态
} }