客户供应商接口分类标准处理、会计科目接口分配后版本化子公司科目

This commit is contained in:
yuxueliang0813 2025-05-23 16:26:58 +08:00
parent 2ea5f0077d
commit b364ddc38f
5 changed files with 78 additions and 43 deletions

View File

@ -30,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);
@ -51,7 +51,7 @@ 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;
@ -150,14 +150,26 @@ public class CustomerInitOperation extends AbstractOperationServicePlugIn implem
itemInfo.put("code",cusnumber); itemInfo.put("code",cusnumber);
itemInfo.put("error","客户保存失败"+operResult.getMessage()); itemInfo.put("error","客户保存失败"+operResult.getMessage());
itemsJson.add(itemInfo); 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{ }else{
//修改客户 名称 税务登记号 联系人 联系电话 银行信息 客户组5 //修改客户 名称 税务登记号 联系人 联系电话 银行信息 客户组5
currentSupId = currentCus.getLong("id"); currentSupId = currentCus.getLong("id");
@ -187,7 +199,6 @@ public class CustomerInitOperation extends AbstractOperationServicePlugIn implem
EsbUtils.handleAssignNew(companysJson, cusids, entityName); EsbUtils.handleAssignNew(companysJson, cusids, entityName);
//处理客户取消分配--初始化时不需要用 //处理客户取消分配--初始化时不需要用
// EsbUtils.handleUnAssign(companysJson, cusids, entityName); // EsbUtils.handleUnAssign(companysJson, cusids, entityName);
if(itemsJson.isEmpty()){ if(itemsJson.isEmpty()){
this.operationResult.addSuccessPkId(pzinfo.getPkValue()); this.operationResult.addSuccessPkId(pzinfo.getPkValue());
}else{ }else{

View File

@ -30,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
@ -73,12 +73,13 @@ 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(); DynamicObject rmbinfo = EsbUtils.getRmb();
OperationResult operResult; OperationResult operResult;
Map<String, Long> cusids = new HashMap<>();//供应商编号和ID对应关系 Map<String, Long> cusids = new HashMap<>();//供应商编号和ID对应关系
boolean isNew;
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);
supnumber = json_body.getString("code"); supnumber = json_body.getString("code");
@ -103,6 +104,7 @@ public class SupplierInitOperation extends AbstractOperationServicePlugIn implem
itemsJson.add(itemInfo); itemsJson.add(itemInfo);
continue; continue;
} }
isNew = false;
currentSup = BusinessDataServiceHelper.loadSingle(entityName,new QFilter[]{new QFilter("number","=",supnumber)}); currentSup = BusinessDataServiceHelper.loadSingle(entityName,new QFilter[]{new QFilter("number","=",supnumber)});
if(currentSup == null){ if(currentSup == null){
//根据编号找不到供应商则新增 //根据编号找不到供应商则新增
@ -126,13 +128,7 @@ public class SupplierInitOperation extends AbstractOperationServicePlugIn implem
currentSupId = ID.genLongId(); currentSupId = ID.genLongId();
currentSup.set("id", currentSupId); currentSup.set("id", currentSupId);
currentSup.set("masterid",currentSupId); currentSup.set("masterid",currentSupId);
//处理分类 isNew = true;
// 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});
} }
currentSup.set("name",supname);//供应商名称 currentSup.set("name",supname);//供应商名称
currentSup.set("tx_register_no",taxno);//税务登记号 currentSup.set("tx_register_no",taxno);//税务登记号
@ -194,6 +190,26 @@ public class SupplierInitOperation extends AbstractOperationServicePlugIn implem
itemInfo.put("error","供应商保存失败"+operResult.getMessage()); itemInfo.put("error","供应商保存失败"+operResult.getMessage());
itemsJson.add(itemInfo); 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")); cusids.put(supnumber,currentSup.getLong("id"));
} }

View File

@ -48,24 +48,26 @@ public class PersonCustomerBankTask extends AbstractTask implements Plugin {
//只处理新增 //只处理新增
return; 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 cusname = ups.getString("name");//姓名
// String skyh = ups.getString("shjh_skyh");//收款银行 // String skyh = ups.getString("shjh_skyh");//收款银行
String xxyh = ups.getString("shjh_xxyh");//详细分机银行
DynamicObject bankinfo; DynamicObject bankinfo;
if(doc_bank.isEmpty()){ if(doc_bank.isEmpty()){
bankinfo = doc_bank.addNew(); bankinfo = doc_bank.addNew();
bankinfo.set("isdefault_bank",true);
}else{ }else{
bankinfo = doc_bank.get(0); bankinfo = doc_bank.get(0);
} }
bankinfo.set("bankaccount",acctnum);//银行账号 bankinfo.set("bankaccount",acctnum);//银行账号
bankinfo.set("accountname",cusname);//账户名称 bankinfo.set("accountname",cusname);//账户名称
//根据详细分机银行 查找对应的行名行号 bankinfo.set("bank",bebankinfo);//开户银行-行名行号 根据入参查找
DynamicObject bebankinfo = BusinessDataServiceHelper.loadSingleFromCache(bebankName,"id,name",new QFilter[]{new QFilter("name","=",xxyh)});
if(bebankinfo != null){
bankinfo.set("bank",bebankinfo.getLong("id"));//开户银行-行名行号 根据入参查找
}
bankinfo.set("currency", rmbinfo);//币别 默认人民币 bankinfo.set("currency", rmbinfo);//币别 默认人民币
bankinfo.set("isdefault_bank",true);
SaveServiceHelper.save(new DynamicObject[]{currentCus}); SaveServiceHelper.save(new DynamicObject[]{currentCus});
} }
//客户还未生成需要在客户生成时从人员处获取银行账号 //客户还未生成需要在客户生成时从人员处获取银行账号

View File

@ -130,7 +130,7 @@ public class AspAccountControler {
if("0".equals(json_body.getString("status")) || !name.equals(acctInfo.getString("name"))){ if("0".equals(json_body.getString("status")) || !name.equals(acctInfo.getString("name"))){
acctInfo.set("enable", 0);//科目禁用处理 acctInfo.set("enable", 0);//科目禁用处理
acctInfo.set("name", name); acctInfo.set("name", name);
acctInfo.set("fullname", name); // acctInfo.set("fullname", name);
OperationServiceHelper.executeOperate("save", entityName, new DynamicObject[]{acctInfo}, oop); OperationServiceHelper.executeOperate("save", entityName, new DynamicObject[]{acctInfo}, oop);
} }
}else{ }else{
@ -157,8 +157,8 @@ public class AspAccountControler {
itemsJson.add(itemInfo); itemsJson.add(itemInfo);
continue; continue;
} }
acctInfo.set("longnumber", number); // acctInfo.set("longnumber", number);
acctInfo.set("fullname", name); // acctInfo.set("fullname", name);
acctInfo.set("parent", parentAcctInfo); acctInfo.set("parent", parentAcctInfo);
//创建组织 //创建组织
acctInfo.set("createorg", grouporginfo);//创建组织 acctInfo.set("createorg", grouporginfo);//创建组织
@ -211,11 +211,10 @@ public class AspAccountControler {
} }
JSONArray companysJson = json_obj.getJSONArray("companys"); JSONArray companysJson = json_obj.getJSONArray("companys");
//处理科目分配
EsbUtils.handleAssignNew(companysJson, acctids, entityName);
//处理科目在每个公司生成 //处理科目在每个公司生成
Map<String, DynamicObject> companyAcctMaps = handleAccountCompany(accountMaps,companysJson); Map<String, DynamicObject> companyAcctMaps = handleAccountCompany(accountMaps,companysJson);
//处理科目分配和反分配
EsbUtils.handleAssignNew(companysJson, acctids, entityName);
EsbUtils.handleUnAssignNew(companysJson, acctids, entityName);
//处理每个公司下科目的核算维度和禁用状态 //处理每个公司下科目的核算维度和禁用状态
JSONArray asstacttypesJson = json_obj.getJSONArray("asstacttypes"); JSONArray asstacttypesJson = json_obj.getJSONArray("asstacttypes");
if(asstacttypesJson != null){ if(asstacttypesJson != null){
@ -283,6 +282,8 @@ public class AspAccountControler {
companyAcctMaps.put(number+companynum,acctInfo); companyAcctMaps.put(number+companynum,acctInfo);
} }
} }
//最后处理科目的反分配
EsbUtils.handleUnAssignNew(companysJson, acctids, entityName);
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");
@ -365,6 +366,7 @@ public class AspAccountControler {
} }
private DynamicObject copydo(DynamicObject olddo, DynamicObject hsorgInfo, JSONObject json_body){ private DynamicObject copydo(DynamicObject olddo, DynamicObject hsorgInfo, JSONObject json_body){
//根据集团的科目复制一份作为子公司的科目此时需要处理一下核算维度其他属性和集团一样
DynamicObject newAcctInfo = BusinessDataServiceHelper.newDynamicObject(entityName); DynamicObject newAcctInfo = BusinessDataServiceHelper.newDynamicObject(entityName);
newAcctInfo.set("accounttable", tableinfo);//TODO 科目表fid上正式时注意此ID newAcctInfo.set("accounttable", tableinfo);//TODO 科目表fid上正式时注意此ID
newAcctInfo.set("number", olddo.getString("number")); newAcctInfo.set("number", olddo.getString("number"));
@ -470,8 +472,8 @@ public class AspAccountControler {
acctInfo.set("accounttable", tableinfo);//科目表fid上正式时注意此ID acctInfo.set("accounttable", tableinfo);//科目表fid上正式时注意此ID
acctInfo.set("number", parentnumber); acctInfo.set("number", parentnumber);
acctInfo.set("name", parentname); acctInfo.set("name", parentname);
acctInfo.set("longnumber", parentnumber); // acctInfo.set("longnumber", parentnumber);
acctInfo.set("fullname", parentname); // acctInfo.set("fullname", parentname);
//创建组织 //创建组织
acctInfo.set("createorg", grouporginfo);//创建组织 acctInfo.set("createorg", grouporginfo);//创建组织
acctInfo.set("org", grouporginfo);//管理组织 acctInfo.set("org", grouporginfo);//管理组织

View File

@ -265,8 +265,10 @@ public class PersonControler implements Serializable {
update t_bas_immapping SET FUSERID = (select fid from t_sec_user where fphone = '用户手机号') where fid = '用户手机号'; update t_bas_immapping SET FUSERID = (select fid from t_sec_user where fphone = '用户手机号') where fid = '用户手机号';
如果没有同步用户即t_bas_immapping表中查不到数据则会跳转到苍穹登陆界面用户输入信息之后苍穹会自动在t_bas_immapping中获取openid并存储 如果没有同步用户即t_bas_immapping表中查不到数据则会跳转到苍穹登陆界面用户输入信息之后苍穹会自动在t_bas_immapping中获取openid并存储
*/ */
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()}); DB.update(DBRoute.of("sys"), insertMmapping, new Object[]{ID.genLongId(),ups.getDataMap().get("shjh_oaid"),ups.getId()});
} }
}
private void updatePersonImmapping(UserParam ups){ private void updatePersonImmapping(UserParam ups){
if(!EsbUtils.isEmpty((String) ups.getDataMap().get("shjh_oaid"))){ if(!EsbUtils.isEmpty((String) ups.getDataMap().get("shjh_oaid"))){
@ -283,27 +285,29 @@ public class PersonControler implements Serializable {
return; return;
} }
String cusname = (String) ups.getDataMap().get("name");//姓名 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");//详细分机银行 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"); DynamicObjectCollection doc_bank = currentCus.getDynamicObjectCollection("entry_bank");
DynamicObject bankinfo; DynamicObject bankinfo;
if(doc_bank.isEmpty()){ if(doc_bank.isEmpty()){
bankinfo = doc_bank.addNew(); bankinfo = doc_bank.addNew();
bankinfo.set("isdefault_bank",true);
}else{ }else{
bankinfo = doc_bank.get(0); bankinfo = doc_bank.get(0);
} }
bankinfo.set("bankaccount",acctnum);//银行账号 bankinfo.set("bankaccount",acctnum);//银行账号
bankinfo.set("accountname",cusname);//账户名称 bankinfo.set("accountname",cusname);//账户名称
//根据详细分机银行 查找对应的行名行号
DynamicObject bebankinfo = BusinessDataServiceHelper.loadSingleFromCache(bebankName,"id,name",new QFilter[]{new QFilter("name","=",xxyh)}); bankinfo.set("bank",bebankinfo);//开户银行-行名行号 根据入参查找
if(bebankinfo != null){
bankinfo.set("bank",bebankinfo.getLong("id"));//开户银行-行名行号 根据入参查找
}
bankinfo.set("currency", rmbinfo);//币别 默认人民币 bankinfo.set("currency", rmbinfo);//币别 默认人民币
bankinfo.set("isdefault_bank",1);
SaveServiceHelper.save(new DynamicObject[]{currentCus}); SaveServiceHelper.save(new DynamicObject[]{currentCus});
} }
//客户还未生成需要在客户生成时从人员处获取银行账号
} }
} }