清账合并推送sap优化

This commit is contained in:
yuxueliang0813 2025-05-21 11:24:03 +08:00
parent 2d9d99ff63
commit 553883a227
9 changed files with 108 additions and 52 deletions

View File

@ -5,11 +5,10 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.util.TypeUtils; import com.alibaba.fastjson.util.TypeUtils;
import kd.bos.context.RequestContext; import kd.bos.context.RequestContext;
import kd.bos.dataentity.OperateOption;
import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection; import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.dataentity.utils.StringUtils; import kd.bos.dataentity.utils.StringUtils;
import kd.bos.db.DB;
import kd.bos.db.DBRoute;
import kd.bos.entity.datamodel.events.BeforeImportEntryEventArgs; import kd.bos.entity.datamodel.events.BeforeImportEntryEventArgs;
import kd.bos.form.control.Control; import kd.bos.form.control.Control;
import kd.bos.form.plugin.AbstractFormPlugin; import kd.bos.form.plugin.AbstractFormPlugin;
@ -19,7 +18,7 @@ import kd.bos.logging.Log;
import kd.bos.logging.LogFactory; 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.SaveServiceHelper; import kd.bos.servicehelper.operation.OperationServiceHelper;
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.utils.JhzjUtils;
@ -39,7 +38,7 @@ public class InitAccountFormPlugin extends AbstractFormPlugin {
private static final String bbName = "bd_currency";//币别 private static final String bbName = "bd_currency";//币别
private static final Map<String, DynamicObject> mapObject = new HashMap<>();//公司对象集合 private static final Map<String, DynamicObject> mapObject = new HashMap<>();//公司对象集合
private static final Map<String, DynamicObject> hsxmMaps = new HashMap<>();//核算维度对象集合 private static final Map<String, DynamicObject> hsxmMaps = new HashMap<>();//核算维度对象集合
private static final String insertSql = "insert into T_BD_Account_U (fdataid,fuseorgid) values (?,?);"; // private static final String insertSql = "insert into T_BD_Account_U (fdataid,fuseorgid) values (?,?);";
//处理科目在每个公司生成 //处理科目在每个公司生成
Map<String, DynamicObject> companyAcctMaps = null; Map<String, DynamicObject> companyAcctMaps = null;
Map<String, Long> acctids = new HashMap<>();//科目编号和ID对应关系 Map<String, Long> acctids = new HashMap<>();//科目编号和ID对应关系
@ -93,10 +92,11 @@ public class InitAccountFormPlugin extends AbstractFormPlugin {
long kmId = ID.genLongId(); long kmId = ID.genLongId();
acctInfo.set("id", kmId); acctInfo.set("id", kmId);
acctInfo.set("masterid", kmId);//主数据内码系统不会根据id自动生成需要手动设置 acctInfo.set("masterid", kmId);//主数据内码系统不会根据id自动生成需要手动设置
//保存数据直接保存入库不走操作校验 //必须调用保存操作否则不符合受控基础资料开发规范
SaveServiceHelper.save(new DynamicObject[]{acctInfo}); // SaveServiceHelper.save(new DynamicObject[]{acctInfo});
OperationServiceHelper.executeOperate("save", entityName, new DynamicObject[]{acctInfo}, OperateOption.create());
//处理科目使用范围 //处理科目使用范围
DB.update(DBRoute.of("fi"), insertSql, new Object[]{kmId,JhzjUtils.GROUPID}); // DB.update(DBRoute.of("fi"), insertSql, new Object[]{kmId,JhzjUtils.GROUPID});
parentMaps.put(parentnumber,acctInfo); parentMaps.put(parentnumber,acctInfo);
} }
return parentMaps.get(parentnumber); return parentMaps.get(parentnumber);
@ -121,6 +121,7 @@ public class InitAccountFormPlugin extends AbstractFormPlugin {
String name;//科目名称 String name;//科目名称
String acctType;//科目类型 资产负债类 损益类 String acctType;//科目类型 资产负债类 损益类
DynamicObject acctTypeInfo; DynamicObject acctTypeInfo;
OperateOption oop = OperateOption.create();
//先根据基础信息在集团层面生成科目不考虑核算维度使用逐级分配 //先根据基础信息在集团层面生成科目不考虑核算维度使用逐级分配
//再根据公司信息进行科目分配 //再根据公司信息进行科目分配
//最后处理每个公司下科目的核算维度和禁用状态 //最后处理每个公司下科目的核算维度和禁用状态
@ -188,10 +189,11 @@ public class InitAccountFormPlugin extends AbstractFormPlugin {
long kmId = ID.genLongId(); long kmId = ID.genLongId();
acctInfo.set("id", kmId); acctInfo.set("id", kmId);
acctInfo.set("masterid", kmId);//主数据内码系统不会根据id自动生成需要手动设置 acctInfo.set("masterid", kmId);//主数据内码系统不会根据id自动生成需要手动设置
//保存数据直接保存入库不走操作校验 //必须调用保存操作否则不符合受控基础资料开发规范
SaveServiceHelper.save(new DynamicObject[]{acctInfo}); // SaveServiceHelper.save(new DynamicObject[]{acctInfo});
OperationServiceHelper.executeOperate("save", entityName, new DynamicObject[]{acctInfo}, oop);
//处理科目使用范围 //处理科目使用范围
DB.update(DBRoute.of("fi"), insertSql, new Object[]{kmId,JhzjUtils.GROUPID}); // DB.update(DBRoute.of("fi"), insertSql, new Object[]{kmId,JhzjUtils.GROUPID});
acctids.put(number,acctInfo.getLong("id")); acctids.put(number,acctInfo.getLong("id"));
accountMaps.put(number,acctInfo); accountMaps.put(number,acctInfo);
@ -255,6 +257,7 @@ public class InitAccountFormPlugin extends AbstractFormPlugin {
String companynum; String companynum;
DynamicObject checkitementryInfo = null; DynamicObject checkitementryInfo = null;
JSONObject json_body; JSONObject json_body;
OperateOption oop = OperateOption.create();
for (int i = 0; i < asstacttypesJson.size(); i++) { for (int i = 0; i < asstacttypesJson.size(); i++) {
json_body = asstacttypesJson.getJSONObject(i); json_body = asstacttypesJson.getJSONObject(i);
hsxm = json_body.getString("shjh_asstactname"); hsxm = json_body.getString("shjh_asstactname");
@ -296,7 +299,9 @@ public class InitAccountFormPlugin extends AbstractFormPlugin {
checkitementryInfo.set("isrequire", false);//必录 checkitementryInfo.set("isrequire", false);//必录
} }
acctInfo.set("isassist", true);//主表的isassist是否包含核算项目为是 acctInfo.set("isassist", true);//主表的isassist是否包含核算项目为是
SaveServiceHelper.save(new DynamicObject[]{acctInfo}); //必须调用保存操作否则不符合受控基础资料开发规范
// SaveServiceHelper.save(new DynamicObject[]{acctInfo});
OperationServiceHelper.executeOperate("save", entityName, new DynamicObject[]{acctInfo}, oop);
companyAcctMaps.put(number+companynum,acctInfo); companyAcctMaps.put(number+companynum,acctInfo);
} }
} }
@ -487,9 +492,11 @@ public class InitAccountFormPlugin extends AbstractFormPlugin {
//手动指定科目的金蝶id //手动指定科目的金蝶id
newAcctInfo.set("id", ID.genLongId()); newAcctInfo.set("id", ID.genLongId());
newAcctInfo.set("masterid", olddo.getLong("id"));//主数据内码系统不会根据id自动生成需要手动设置 newAcctInfo.set("masterid", olddo.getLong("id"));//主数据内码系统不会根据id自动生成需要手动设置
SaveServiceHelper.save(new DynamicObject[]{newAcctInfo}); //必须调用保存操作否则不符合受控基础资料开发规范
// SaveServiceHelper.save(new DynamicObject[]{acctInfo});
OperationServiceHelper.executeOperate("save", entityName, new DynamicObject[]{newAcctInfo}, OperateOption.create());
//处理科目使用范围 //处理科目使用范围
DB.update(DBRoute.of("fi"), insertSql, new Object[]{newAcctInfo.getLong("id"),hsorgInfo.getLong("id")}); // DB.update(DBRoute.of("fi"), insertSql, new Object[]{newAcctInfo.getLong("id"),hsorgInfo.getLong("id")});
return newAcctInfo; return newAcctInfo;
} }

View File

@ -595,16 +595,24 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im
JSONObject clear;//从清账单分录获取应收的凭证数据 JSONObject clear;//从清账单分录获取应收的凭证数据
for (int i = 0; i < docolls.size(); i++) { for (int i = 0; i < docolls.size(); i++) {
entryinfo = docolls.get(i); entryinfo = docolls.get(i);
clear = new JSONObject(); //先从IT_CLEAR集合中查找如果找不到则新增
clear.put("BUKRS",companyCode);//公司代码 clear = getClearJsonObj(IT_CLEAR,entryinfo);
clear.put("BELNR",entryinfo.getString("shjh_e_pzh"));//应收会计凭证编号 if(clear == null){
clear.put("GJAHR",entryinfo.getString("shjh_e_year"));//会计年度 clear = new JSONObject();
clear.put("BUZEI",entryinfo.getString("shjh_e_pzhh"));//行编号 clear.put("BUKRS",companyCode);//公司代码
clear.put("KUNNR",customerCode);//客户编号 clear.put("BELNR",entryinfo.getString("shjh_e_pzh"));//应收会计凭证编号
clear.put("HKONT",entryinfo.getString("shjh_e_account"));//总账科目编号 clear.put("GJAHR",entryinfo.getString("shjh_e_year"));//会计年度
clear.put("UMSKZ", JhzjUtils.getUMSKZ(entryinfo.getString("shjh_e_account")));//特殊总账标识 clear.put("BUZEI",entryinfo.getString("shjh_e_pzhh"));//行编号
clear.put("DMBTR1",entryinfo.getBigDecimal("shjh_e_cursettle").abs());//清账金额--sap接收的正数金额 clear.put("KUNNR",customerCode);//客户编号
IT_CLEAR.add(clear); clear.put("HKONT",entryinfo.getString("shjh_e_account"));//总账科目编号
clear.put("UMSKZ", JhzjUtils.getUMSKZ(entryinfo.getString("shjh_e_account")));//特殊总账标识
clear.put("DMBTR1",entryinfo.getBigDecimal("shjh_e_cursettle").abs());//清账金额--sap接收的正数金额
IT_CLEAR.add(clear);
}else{
//将当前清账分录对象中的清账金额与clear对象合并
clear.put("DMBTR1",JhzjUtils.addTwoAmount(clear.getBigDecimal("DMBTR1"),
entryinfo.getBigDecimal("shjh_e_cursettle").abs()));
}
} }
//从收款单cas_recbill获取实收的凭证数据 //从收款单cas_recbill获取实收的凭证数据
//先根据关系表找到收款单id和收款分录id再将收款单对象查出来 //先根据关系表找到收款单id和收款分录id再将收款单对象查出来
@ -650,6 +658,21 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im
return null; return null;
} }
private JSONObject getClearJsonObj(JSONArray IT_CLEAR, DynamicObject entryinfo){
//根据清账单分录和json集合查找对应json对象
JSONObject jsonobj;
for (int i = 0; i < IT_CLEAR.size(); i++) {
jsonobj = IT_CLEAR.getJSONObject(i);
if(jsonobj.getString("BELNR").equals(entryinfo.getString("shjh_e_pzh")) &&
jsonobj.getString("GJAHR").equals(entryinfo.getString("shjh_e_year")) &&
jsonobj.getString("BUZEI").equals(entryinfo.getString("shjh_e_pzhh")) &&
jsonobj.getString("HKONT").equals(entryinfo.getString("shjh_e_account"))){
return jsonobj;
}
}
return null;
}
private String getAccountNumber(Long recebillid){ private String getAccountNumber(Long recebillid){
//根据收款单ID获取对应金蝶凭证的贷方科目编号 //根据收款单ID获取对应金蝶凭证的贷方科目编号
DynamicObject gl_voucher = BusinessDataServiceHelper.loadSingle(voucherName, DynamicObject gl_voucher = BusinessDataServiceHelper.loadSingle(voucherName,

View File

@ -1,6 +1,7 @@
package shjh.jhzj7.fi.fi.plugin.operate; package shjh.jhzj7.fi.fi.plugin.operate;
import com.sap.db.jdbc.packet.ErrorLevel; import com.sap.db.jdbc.packet.ErrorLevel;
import kd.bos.context.RequestContext;
import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection; import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.db.DB; import kd.bos.db.DB;
@ -291,6 +292,7 @@ public class ClearDetailBillOperation extends AbstractOperationServicePlugIn imp
clearEntryInfo.set("shjh_e_detailentryid",detailEntryInfo.getString("id"));// 明细单分录ID clearEntryInfo.set("shjh_e_detailentryid",detailEntryInfo.getString("id"));// 明细单分录ID
clearEntryInfo.set("shjh_e_detailbillid",detailBillInfo.getString("id"));// 明细单ID clearEntryInfo.set("shjh_e_detailbillid",detailBillInfo.getString("id"));// 明细单ID
clearEntryInfo.set("shjh_e_detailbillno",detailBillInfo.getString("billno"));// 明细单编号 clearEntryInfo.set("shjh_e_detailbillno",detailBillInfo.getString("billno"));// 明细单编号
clearEntryInfo.set("shjh_submituser", RequestContext.get().getCurrUserId());// 明细单提交用户
} }
//处理清账单账扣 //处理清账单账扣
BigDecimal q1 = JhzjUtils.addTwoAmount(clearBillInfo.getBigDecimal("shjh_deductionamount"), BigDecimal q1 = JhzjUtils.addTwoAmount(clearBillInfo.getBigDecimal("shjh_deductionamount"),

View File

@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.sap.db.jdbc.packet.ErrorLevel; import com.sap.db.jdbc.packet.ErrorLevel;
import kd.bos.context.RequestContext; import kd.bos.context.RequestContext;
import kd.bos.dataentity.OperateOption;
import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection; import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.entity.operate.result.OperateErrorInfo; import kd.bos.entity.operate.result.OperateErrorInfo;
@ -15,6 +16,7 @@ import kd.bos.logging.Log;
import kd.bos.logging.LogFactory; 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.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;
@ -51,6 +53,7 @@ public class CustomerInitOperation extends AbstractOperationServicePlugIn implem
JSONObject json_body; JSONObject json_body;
Long currentSupId; Long currentSupId;
DynamicObject custgroupdetail; DynamicObject custgroupdetail;
OperateOption oop = OperateOption.create();
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{
@ -114,7 +117,7 @@ public class CustomerInitOperation extends AbstractOperationServicePlugIn implem
currentCus.set("org", JhzjUtils.GROUPID);//管理组织 默认为集团 currentCus.set("org", JhzjUtils.GROUPID);//管理组织 默认为集团
currentCus.set("ctrlstrategy","1");//控制策略 默认逐级分配1 自由分配2 currentCus.set("ctrlstrategy","1");//控制策略 默认逐级分配1 自由分配2
currentCus.set("group",custype.getLong("id"));//客户分组 currentCus.set("group",custype.getLong("id"));//客户分组
currentCus.set("bitindex",1);//位图 // currentCus.set("bitindex",1);//位图
currentCus.set("customerstatus",EsbUtils.CUSTOMERSTATUS);//客户状态 currentCus.set("customerstatus",EsbUtils.CUSTOMERSTATUS);//客户状态
currentCus.set("name",cusname);//客户名称 currentCus.set("name",cusname);//客户名称
currentCus.set("tx_register_no",taxno);//税务登记号 currentCus.set("tx_register_no",taxno);//税务登记号
@ -135,7 +138,10 @@ public class CustomerInitOperation extends AbstractOperationServicePlugIn implem
//处理 客户组5 //处理 客户组5
handleFive(customerfivesJson,currentCus.getDynamicObjectCollection("shjh_entry_five"),cusnumber); handleFive(customerfivesJson,currentCus.getDynamicObjectCollection("shjh_entry_five"),cusnumber);
SaveServiceHelper.save(new DynamicObject[]{currentCus}); // SaveServiceHelper.save(new DynamicObject[]{currentCus});
//保存客户-必须调用保存操作否则不符合受控基础资料开发规范
// SaveServiceHelper.save(new DynamicObject[]{currentCus});
OperationServiceHelper.executeOperate("save", entityName, new DynamicObject[]{currentCus}, oop);
//处理分类 //处理分类
custgroupdetail = BusinessDataServiceHelper.newDynamicObject(gdName); custgroupdetail = BusinessDataServiceHelper.newDynamicObject(gdName);
custgroupdetail.set("createorg",JhzjUtils.GROUPID);//创建组织 custgroupdetail.set("createorg",JhzjUtils.GROUPID);//创建组织
@ -157,7 +163,7 @@ public class CustomerInitOperation extends AbstractOperationServicePlugIn implem
if(!"M400".equals(type)){ if(!"M400".equals(type)){
handleBank(banksJson,currentCus.getDynamicObjectCollection("entry_bank"),cusnumber,cusname); handleBank(banksJson,currentCus.getDynamicObjectCollection("entry_bank"),cusnumber,cusname);
} }
SaveServiceHelper.save(new DynamicObject[]{currentCus}); OperationServiceHelper.executeOperate("save", entityName, new DynamicObject[]{currentCus}, oop);
} }
cusids.put(cusnumber,currentSupId); cusids.put(cusnumber,currentSupId);
} }

View File

@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.sap.db.jdbc.packet.ErrorLevel; import com.sap.db.jdbc.packet.ErrorLevel;
import kd.bos.context.RequestContext; import kd.bos.context.RequestContext;
import kd.bos.dataentity.OperateOption;
import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection; import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.entity.operate.result.OperateErrorInfo; import kd.bos.entity.operate.result.OperateErrorInfo;
@ -15,6 +16,7 @@ import kd.bos.logging.Log;
import kd.bos.logging.LogFactory; 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.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;
@ -73,6 +75,7 @@ public class SupplierInitOperation extends AbstractOperationServicePlugIn implem
JSONObject json_bank; JSONObject json_bank;
Long currentSupId; Long currentSupId;
DynamicObject suppliergroupdetail; DynamicObject suppliergroupdetail;
OperateOption oop = OperateOption.create();
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++) {
json_body = detailsJson.getJSONObject(i); json_body = detailsJson.getJSONObject(i);
@ -115,7 +118,7 @@ public class SupplierInitOperation extends AbstractOperationServicePlugIn implem
currentSup.set("source","SELF");//来源 默认自建 currentSup.set("source","SELF");//来源 默认自建
currentSup.set("ctrlstrategy","1");//控制策略 默认逐级分配 currentSup.set("ctrlstrategy","1");//控制策略 默认逐级分配
currentSup.set("group",suptype.getLong("id"));//供应商分组 currentSup.set("group",suptype.getLong("id"));//供应商分组
currentSup.set("bitindex",6);//位图 // currentSup.set("bitindex",6);//位图
currentSup.set("supplier_status",EsbUtils.SUPPLIERSTATUS);//供应商状态 默认合格 currentSup.set("supplier_status",EsbUtils.SUPPLIERSTATUS);//供应商状态 默认合格
//设置id和masterid 不然不能进行分配动作 //设置id和masterid 不然不能进行分配动作
currentSupId = ID.genLongId(); currentSupId = ID.genLongId();
@ -179,9 +182,9 @@ public class SupplierInitOperation extends AbstractOperationServicePlugIn implem
} }
//处理 sap公司信息 结算方式 统驭科目 //处理 sap公司信息 结算方式 统驭科目
handleSAPCompany(companysJson,currentSup.getDynamicObjectCollection("shjh_entry_sap"),supnumber); handleSAPCompany(companysJson,currentSup.getDynamicObjectCollection("shjh_entry_sap"),supnumber);
//保存供应商 //保存供应商-必须调用保存操作否则不符合受控基础资料开发规范
SaveServiceHelper.save(new DynamicObject[]{currentSup}); // SaveServiceHelper.save(new DynamicObject[]{currentSup});
// OperationServiceHelper.executeOperate("save", entityName, new DynamicObject[]{currentSup}, OperateOption.create()); OperationServiceHelper.executeOperate("save", entityName, new DynamicObject[]{currentSup}, oop);
cusids.put(supnumber,currentSup.getLong("id")); cusids.put(supnumber,currentSup.getLong("id"));
} }

View File

@ -9,10 +9,9 @@ import com.alibaba.fastjson.util.TypeUtils;
import com.drew.lang.annotations.NotNull; import com.drew.lang.annotations.NotNull;
import kd.bos.api.client.ApiResult; 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.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection; import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.db.DB;
import kd.bos.db.DBRoute;
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;
@ -22,7 +21,7 @@ import kd.bos.openapi.common.custom.annotation.ApiRequestBody;
import kd.bos.openapi.common.result.CustomApiResult; 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.SaveServiceHelper; import kd.bos.servicehelper.operation.OperationServiceHelper;
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.utils.JhzjUtils;
import shjh.jhzj7.fi.fi.webapi.model.AccountModel; import shjh.jhzj7.fi.fi.webapi.model.AccountModel;
@ -45,7 +44,7 @@ public class AspAccountControler {
private static final Map<String, DynamicObject> mapObject = new HashMap<>();//公司对象集合 private static final Map<String, DynamicObject> mapObject = new HashMap<>();//公司对象集合
private static final Map<String, DynamicObject> hsxmMaps = new HashMap<>();//核算维度对象集合 private static final Map<String, DynamicObject> hsxmMaps = new HashMap<>();//核算维度对象集合
private static final String insertSql = "insert into T_BD_Account_U (fdataid,fuseorgid) values (?,?);"; // private static final String insertSql = "insert into T_BD_Account_U (fdataid,fuseorgid) values (?,?);";
/** /**
* @param bizParam 入参json格式数据 * @param bizParam 入参json格式数据
@ -86,7 +85,7 @@ public class AspAccountControler {
DynamicObject acctTypeInfo; DynamicObject acctTypeInfo;
DynamicObject parentAcctInfo; DynamicObject parentAcctInfo;
JSONObject json_body; JSONObject json_body;
OperateOption oop = OperateOption.create();
Map<String, Long> acctids = new HashMap<>();//科目编号和ID对应关系 Map<String, Long> acctids = new HashMap<>();//科目编号和ID对应关系
Map<String, DynamicObject> accountMaps = new HashMap<>();//将科目编号与对象关联 Map<String, DynamicObject> accountMaps = new HashMap<>();//将科目编号与对象关联
//先根据基础信息在集团层面生成科目不考虑核算维度使用逐级分配 //先根据基础信息在集团层面生成科目不考虑核算维度使用逐级分配
@ -125,7 +124,7 @@ public class AspAccountControler {
acctInfo.set("enable", 0);//科目禁用处理 acctInfo.set("enable", 0);//科目禁用处理
acctInfo.set("name", name); acctInfo.set("name", name);
acctInfo.set("fullname", name); acctInfo.set("fullname", name);
SaveServiceHelper.save(new DynamicObject[]{acctInfo}); OperationServiceHelper.executeOperate("save", entityName, new DynamicObject[]{acctInfo}, oop);
} }
}else{ }else{
acctTypeInfo = BusinessDataServiceHelper.loadSingleFromCache(acctTypeName,new QFilter[]{new QFilter("number","=",acctType)}); acctTypeInfo = BusinessDataServiceHelper.loadSingleFromCache(acctTypeName,new QFilter[]{new QFilter("number","=",acctType)});
@ -181,9 +180,10 @@ public class AspAccountControler {
acctInfo.set("id", kmId); acctInfo.set("id", kmId);
acctInfo.set("masterid", kmId);//主数据内码系统不会根据id自动生成需要手动设置 acctInfo.set("masterid", kmId);//主数据内码系统不会根据id自动生成需要手动设置
//保存数据直接保存入库不走操作校验 //保存数据直接保存入库不走操作校验
SaveServiceHelper.save(new DynamicObject[]{acctInfo}); // SaveServiceHelper.save(new DynamicObject[]{acctInfo});
OperationServiceHelper.executeOperate("save", entityName, new DynamicObject[]{acctInfo}, oop);
//处理科目使用范围 //处理科目使用范围
DB.update(DBRoute.of("fi"), insertSql, new Object[]{kmId,JhzjUtils.GROUPID}); // DB.update(DBRoute.of("fi"), insertSql, new Object[]{kmId,JhzjUtils.GROUPID});
} }
acctids.put(number,acctInfo.getLong("id")); acctids.put(number,acctInfo.getLong("id"));
accountMaps.put(number,acctInfo); accountMaps.put(number,acctInfo);
@ -250,7 +250,8 @@ public class AspAccountControler {
checkitementryInfo.set("isrequire", false);//必录 checkitementryInfo.set("isrequire", false);//必录
} }
acctInfo.set("isassist", true);//主表的isassist是否包含核算项目为是 acctInfo.set("isassist", true);//主表的isassist是否包含核算项目为是
SaveServiceHelper.save(new DynamicObject[]{acctInfo}); // SaveServiceHelper.save(new DynamicObject[]{acctInfo});
OperationServiceHelper.executeOperate("save", entityName, new DynamicObject[]{acctInfo}, oop);
companyAcctMaps.put(number+companynum,acctInfo); companyAcctMaps.put(number+companynum,acctInfo);
} }
} }
@ -387,9 +388,10 @@ public class AspAccountControler {
//手动指定科目的金蝶id //手动指定科目的金蝶id
newAcctInfo.set("id", ID.genLongId()); newAcctInfo.set("id", ID.genLongId());
newAcctInfo.set("masterid", olddo.getLong("id"));//主数据内码系统不会根据id自动生成需要手动设置 newAcctInfo.set("masterid", olddo.getLong("id"));//主数据内码系统不会根据id自动生成需要手动设置
SaveServiceHelper.save(new DynamicObject[]{newAcctInfo}); // SaveServiceHelper.save(new DynamicObject[]{newAcctInfo});
OperationServiceHelper.executeOperate("save", entityName, new DynamicObject[]{newAcctInfo}, OperateOption.create());
//处理科目使用范围 //处理科目使用范围
DB.update(DBRoute.of("fi"), insertSql, new Object[]{newAcctInfo.getLong("id"),hsorgInfo.getLong("id")}); // DB.update(DBRoute.of("fi"), insertSql, new Object[]{newAcctInfo.getLong("id"),hsorgInfo.getLong("id")});
return newAcctInfo; return newAcctInfo;
} }
@ -476,9 +478,10 @@ public class AspAccountControler {
acctInfo.set("id", kmId); acctInfo.set("id", kmId);
acctInfo.set("masterid", kmId);//主数据内码系统不会根据id自动生成需要手动设置 acctInfo.set("masterid", kmId);//主数据内码系统不会根据id自动生成需要手动设置
//保存数据直接保存入库不走操作校验 //保存数据直接保存入库不走操作校验
SaveServiceHelper.save(new DynamicObject[]{acctInfo}); // SaveServiceHelper.save(new DynamicObject[]{acctInfo});
OperationServiceHelper.executeOperate("save", entityName, new DynamicObject[]{acctInfo}, OperateOption.create());
//处理科目使用范围 //处理科目使用范围
DB.update(DBRoute.of("fi"), insertSql, new Object[]{kmId,JhzjUtils.GROUPID}); // DB.update(DBRoute.of("fi"), insertSql, new Object[]{kmId,JhzjUtils.GROUPID});
} }
return acctInfo; return acctInfo;
} }

View File

@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject;
import com.drew.lang.annotations.NotNull; import com.drew.lang.annotations.NotNull;
import kd.bos.api.client.ApiResult; 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.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.id.ID; import kd.bos.id.ID;
import kd.bos.logging.Log; import kd.bos.logging.Log;
@ -18,7 +19,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.QueryServiceHelper; import kd.bos.servicehelper.QueryServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper; import kd.bos.servicehelper.operation.OperationServiceHelper;
import shjh.jhzj7.fi.fi.utils.EsbUtils; import shjh.jhzj7.fi.fi.utils.EsbUtils;
import shjh.jhzj7.fi.fi.webapi.model.CostCenterModel; import shjh.jhzj7.fi.fi.webapi.model.CostCenterModel;
@ -69,6 +70,7 @@ public class CostCenterControler {
DynamicObject currentOrg; DynamicObject currentOrg;
DynamicObject companyInfo; DynamicObject companyInfo;
JSONObject json_body; JSONObject json_body;
OperateOption oop = OperateOption.create();
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");//成本中心编号
@ -140,7 +142,9 @@ public class CostCenterControler {
if("X".equals(json_body.getString("sjcjcb"))){ if("X".equals(json_body.getString("sjcjcb"))){
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);
// itemInfo = new JSONObject(); // itemInfo = new JSONObject();
// itemInfo.put("pkId",orgNumber); // itemInfo.put("pkId",orgNumber);
// itemInfo.put("status","1"); // itemInfo.put("status","1");

View File

@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject;
import com.drew.lang.annotations.NotNull; import com.drew.lang.annotations.NotNull;
import kd.bos.api.client.ApiResult; 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.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection; import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.id.ID; import kd.bos.id.ID;
@ -18,6 +19,7 @@ import kd.bos.openapi.common.custom.annotation.ApiRequestBody;
import kd.bos.openapi.common.result.CustomApiResult; 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.SaveServiceHelper; 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.utils.JhzjUtils;
@ -75,7 +77,7 @@ public class CustomerControler {
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();
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);
cusnumber = json_body.getString("code"); cusnumber = json_body.getString("code");
@ -117,7 +119,7 @@ public class CustomerControler {
currentCus.set("org", JhzjUtils.GROUPID);//管理组织 默认为集团 currentCus.set("org", JhzjUtils.GROUPID);//管理组织 默认为集团
currentCus.set("ctrlstrategy","1");//控制策略 默认逐级分配1 自由分配2 currentCus.set("ctrlstrategy","1");//控制策略 默认逐级分配1 自由分配2
currentCus.set("group",custype.getLong("id"));//客户分组 currentCus.set("group",custype.getLong("id"));//客户分组
currentCus.set("bitindex",1);//位图 // currentCus.set("bitindex",1);//位图
currentCus.set("customerstatus",EsbUtils.CUSTOMERSTATUS);//客户状态 currentCus.set("customerstatus",EsbUtils.CUSTOMERSTATUS);//客户状态
currentCus.set("name",cusname);//客户名称 currentCus.set("name",cusname);//客户名称
currentCus.set("tx_register_no",taxno);//税务登记号 currentCus.set("tx_register_no",taxno);//税务登记号
@ -138,7 +140,9 @@ public class CustomerControler {
//处理 客户组5 //处理 客户组5
handleFive(customerfivesJson,currentCus.getDynamicObjectCollection("shjh_entry_five"),cusnumber); handleFive(customerfivesJson,currentCus.getDynamicObjectCollection("shjh_entry_five"),cusnumber);
SaveServiceHelper.save(new DynamicObject[]{currentCus}); //保存客户-必须调用保存操作否则不符合受控基础资料开发规范
// SaveServiceHelper.save(new DynamicObject[]{currentCus});
OperationServiceHelper.executeOperate("save", entityName, new DynamicObject[]{currentCus}, oop);
//处理分类 //处理分类
custgroupdetail = BusinessDataServiceHelper.newDynamicObject(gdName); custgroupdetail = BusinessDataServiceHelper.newDynamicObject(gdName);
custgroupdetail.set("createorg",JhzjUtils.GROUPID);//创建组织 custgroupdetail.set("createorg",JhzjUtils.GROUPID);//创建组织
@ -160,7 +164,7 @@ public class CustomerControler {
if(!"M400".equals(type)){ if(!"M400".equals(type)){
handleBank(banksJson,currentCus.getDynamicObjectCollection("entry_bank"),cusnumber,cusname); handleBank(banksJson,currentCus.getDynamicObjectCollection("entry_bank"),cusnumber,cusname);
} }
SaveServiceHelper.save(new DynamicObject[]{currentCus}); OperationServiceHelper.executeOperate("save", entityName, new DynamicObject[]{currentCus}, oop);
} }
cusids.put(cusnumber,currentSupId); cusids.put(cusnumber,currentSupId);
} }

View File

@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject;
import com.drew.lang.annotations.NotNull; import com.drew.lang.annotations.NotNull;
import kd.bos.api.client.ApiResult; 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.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection; import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.id.ID; import kd.bos.id.ID;
@ -18,6 +19,7 @@ import kd.bos.openapi.common.custom.annotation.ApiRequestBody;
import kd.bos.openapi.common.result.CustomApiResult; 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.SaveServiceHelper; 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.utils.JhzjUtils;
@ -81,6 +83,7 @@ public class SupplierControler {
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();
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");
@ -122,7 +125,7 @@ public class SupplierControler {
currentSup.set("source","SELF");//来源 默认自建 currentSup.set("source","SELF");//来源 默认自建
currentSup.set("ctrlstrategy","1");//控制策略 默认逐级分配 currentSup.set("ctrlstrategy","1");//控制策略 默认逐级分配
currentSup.set("group",suptype.getLong("id"));//供应商分组 currentSup.set("group",suptype.getLong("id"));//供应商分组
currentSup.set("bitindex",6);//位图 // currentSup.set("bitindex",6);//位图
currentSup.set("supplier_status",EsbUtils.SUPPLIERSTATUS);//供应商状态 默认合格 currentSup.set("supplier_status",EsbUtils.SUPPLIERSTATUS);//供应商状态 默认合格
//设置id和masterid 不然不能进行分配动作 //设置id和masterid 不然不能进行分配动作
currentSupId = ID.genLongId(); currentSupId = ID.genLongId();
@ -205,8 +208,9 @@ public class SupplierControler {
} }
//处理 sap公司信息 结算方式 统驭科目 //处理 sap公司信息 结算方式 统驭科目
handleSAPCompany(companysJson,currentSup.getDynamicObjectCollection("shjh_entry_sap"),supnumber); handleSAPCompany(companysJson,currentSup.getDynamicObjectCollection("shjh_entry_sap"),supnumber);
//保存供应商 //保存供应商-必须调用保存操作否则不符合受控基础资料开发规范
SaveServiceHelper.save(new DynamicObject[]{currentSup}); // SaveServiceHelper.save(new DynamicObject[]{currentSup});
OperationServiceHelper.executeOperate("save", entityName, new DynamicObject[]{currentSup}, oop);
cusids.put(supnumber,currentSup.getLong("id")); cusids.put(supnumber,currentSup.getLong("id"));
//处理商务伙伴先判断是否已经生成了伙伴没有则新增一个伙伴 //处理商务伙伴先判断是否已经生成了伙伴没有则新增一个伙伴
// parterInfo = BusinessDataServiceHelper.loadSingle(parterName,new QFilter[]{new QFilter("number","=",supnumber)}); // parterInfo = BusinessDataServiceHelper.loadSingle(parterName,new QFilter[]{new QFilter("number","=",supnumber)});