科目接口优化创建组织对象

This commit is contained in:
yuxueliang0813 2025-05-22 16:05:33 +08:00
parent 9ab9643fe2
commit 722c92918c
1 changed files with 17 additions and 15 deletions

View File

@ -42,8 +42,10 @@ public class AspAccountControler {
private static final Log log = LogFactory.getLog(AspAccountControler.class);
private static final String apimenthod = "/account_sync";
private static final Map<String, DynamicObject> mapObject = new HashMap<>();//公司对象集合
private static final Map<String, DynamicObject> hsxmMaps = new HashMap<>();//核算维度对象集合
private Map<String, DynamicObject> mapObject = new HashMap<>();//公司对象集合
private Map<String, DynamicObject> hsxmMaps = new HashMap<>();//核算维度对象集合
private DynamicObject grouporginfo = EsbUtils.getGroupOrg();//获取默认科目表
DynamicObject tableinfo = EsbUtils.getTable();//获取默认科目表
// private static final String insertSql = "insert into T_BD_Account_U (fdataid,fuseorgid) values (?,?);";
@ -90,7 +92,7 @@ public class AspAccountControler {
OperationResult operResult;
Map<String, Long> acctids = new HashMap<>();//科目编号和ID对应关系
Map<String, DynamicObject> accountMaps = new HashMap<>();//将科目编号与对象关联
DynamicObject tableinfo = EsbUtils.getTable();
//先根据基础信息在集团层面生成科目不考虑核算维度使用逐级分配
//再根据公司信息进行科目分配
//最后处理每个公司下科目的核算维度和禁用状态
@ -145,7 +147,7 @@ public class AspAccountControler {
acctInfo.set("number", number);
acctInfo.set("name", name);
//处理父级科目
parentAcctInfo = getParentAcct(number,name,acctType,acctTypeInfo,tableinfo);
parentAcctInfo = getParentAcct(number,name,acctType,acctTypeInfo);
if(parentAcctInfo == null){
itemInfo = new JSONObject();
itemInfo.put("code",number);
@ -157,8 +159,8 @@ public class AspAccountControler {
acctInfo.set("fullname", name);
acctInfo.set("parent", parentAcctInfo);
//创建组织
acctInfo.set("createorg", JhzjUtils.GROUPID);//创建组织
acctInfo.set("org", JhzjUtils.GROUPID);//管理组织
acctInfo.set("createorg", grouporginfo);//创建组织
acctInfo.set("org", grouporginfo);//管理组织
//科目类型
acctInfo.set("accounttype", acctTypeInfo);
//币别核算--外币核算类型--集团科目新增时默认为allcurrency
@ -208,7 +210,7 @@ public class AspAccountControler {
JSONArray companysJson = json_obj.getJSONArray("companys");
//处理科目在每个公司生成
Map<String, DynamicObject> companyAcctMaps = handleAccountCompany(accountMaps,companysJson,tableinfo);
Map<String, DynamicObject> companyAcctMaps = handleAccountCompany(accountMaps,companysJson);
//处理科目分配和反分配
EsbUtils.handleAssignNew(companysJson, acctids, entityName);
EsbUtils.handleUnAssignNew(companysJson, acctids, entityName);
@ -305,7 +307,7 @@ public class AspAccountControler {
}
}
private Map<String, DynamicObject> handleAccountCompany(Map<String, DynamicObject> accountMaps,JSONArray companysJson,DynamicObject tableinfo){
private Map<String, DynamicObject> handleAccountCompany(Map<String, DynamicObject> accountMaps,JSONArray companysJson){
Map<String, DynamicObject> baseMaps = new HashMap<>();
if(companysJson == null){
return baseMaps;
@ -336,7 +338,7 @@ public class AspAccountControler {
continue;
}
//复制对象修改其中的某些属性比如id和组织id新增币别相关属性
newAcctInfo = copydo(oldAcctInfo,hsorgInfo,json_body,tableinfo);
newAcctInfo = copydo(oldAcctInfo,hsorgInfo,json_body);
}else{
//修改币别相关属性
newAcctInfo.set("acctcurrency", json_body.getString("acctcurrency"));
@ -360,15 +362,15 @@ public class AspAccountControler {
return baseMaps;
}
private DynamicObject copydo(DynamicObject olddo, DynamicObject hsorgInfo, JSONObject json_body,DynamicObject tableinfo){
private DynamicObject copydo(DynamicObject olddo, DynamicObject hsorgInfo, JSONObject json_body){
DynamicObject newAcctInfo = BusinessDataServiceHelper.newDynamicObject(entityName);
newAcctInfo.set("accounttable", tableinfo);//TODO 科目表fid上正式时注意此ID
newAcctInfo.set("number", olddo.getString("number"));
newAcctInfo.set("name", olddo.getString("name"));
newAcctInfo.set("longnumber", olddo.getString("longnumber"));
newAcctInfo.set("fullname", olddo.getString("fullname"));
newAcctInfo.set("createorg", hsorgInfo.getLong("id"));//创建组织
newAcctInfo.set("org", hsorgInfo.getLong("id"));//管理组织
newAcctInfo.set("createorg", hsorgInfo);//创建组织
newAcctInfo.set("org", hsorgInfo);//管理组织
//科目类型
newAcctInfo.set("accounttype", olddo.getDynamicObject("accounttype"));
//币别核算--外币核算类型
@ -449,7 +451,7 @@ public class AspAccountControler {
return baseMaps;
}
private DynamicObject getParentAcct(String number,String name,String acctType,DynamicObject acctTypeInfo,DynamicObject tableinfo){
private DynamicObject getParentAcct(String number,String name,String acctType,DynamicObject acctTypeInfo){
//sap科目编号为10位且没有层级关系金蝶按照4-6分两级自行处理
String parentnumber = number.substring(0,4);
DynamicObject acctInfo = BusinessDataServiceHelper.loadSingleFromCache(entityName,
@ -469,8 +471,8 @@ public class AspAccountControler {
acctInfo.set("longnumber", parentnumber);
acctInfo.set("fullname", parentname);
//创建组织
acctInfo.set("createorg", JhzjUtils.GROUPID);//创建组织
acctInfo.set("org", JhzjUtils.GROUPID);//管理组织
acctInfo.set("createorg", grouporginfo);//创建组织
acctInfo.set("org", grouporginfo);//管理组织
//科目类型
acctInfo.set("accounttype", acctTypeInfo);
//币别核算--外币核算类型--集团科目新增时默认为allcurrency