科目接口优化2

This commit is contained in:
yuxueliang0813 2025-05-30 17:36:29 +08:00
parent 5c78dd468a
commit 3240be77a1
2 changed files with 48 additions and 29 deletions

View File

@ -9,6 +9,8 @@ import kd.bos.dataentity.OperateOption;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
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.form.control.Control;
import kd.bos.form.plugin.AbstractFormPlugin;
@ -19,6 +21,7 @@ import kd.bos.logging.LogFactory;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
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.JhzjUtils;
@ -38,14 +41,17 @@ public class InitAccountFormPlugin extends AbstractFormPlugin {
private static final String bbName = "bd_currency";//币别
private static final Map<String, DynamicObject> mapObject = 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, Long> acctids = new HashMap<>();//科目编号和ID对应关系
Map<String, DynamicObject> accountMaps = new HashMap<>();//将科目编号与对象关联
Map<String, DynamicObject> parentMaps = new HashMap<>();//将父级科目编号与对象关联
private DynamicObject handleParentAcct(String number,String name,String acctType,DynamicObject acctTypeInfo){
private DynamicObject grouporginfo = EsbUtils.getGroupOrg();//获取默认科目表
DynamicObject tableinfo = EsbUtils.getTable();//获取默认科目表
private DynamicObject getParentAcct(String number,String name,String acctType,DynamicObject acctTypeInfo){
String parentnumber = number.substring(0, 4);
if(parentMaps.get(parentnumber) == null){
//处理父级科目名称
@ -54,14 +60,14 @@ public class InitAccountFormPlugin extends AbstractFormPlugin {
parentname = name.substring(0, name.indexOf("-"));
}
DynamicObject acctInfo = BusinessDataServiceHelper.newDynamicObject(entityName);
acctInfo.set("accounttable", EsbUtils.ACCTABLE);//科目表fid上正式时注意此ID
acctInfo.set("accounttable", tableinfo);//科目表fid上正式时注意此ID
acctInfo.set("number", parentnumber);
acctInfo.set("name", parentname);
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
@ -73,7 +79,7 @@ public class InitAccountFormPlugin extends AbstractFormPlugin {
acctInfo.set("dc", 1);//余额方向 默认为借
acctInfo.set("level", 1);//级次 默认为1
acctInfo.set("isleaf", false);//明细科目 默认为否
acctInfo.set("startdate", TypeUtils.castToDate("2024-01-01"));//版本化日期
acctInfo.set("startdate", TypeUtils.castToDate("1900-01-01"));//版本化日期
acctInfo.set("enddate", TypeUtils.castToDate("2999-12-31"));//失效日期
acctInfo.set("accrualdirection", "nocontrol");//科目录入方向控制 不控制nocontrol 借方debit 贷方credit
acctInfo.set("orgcontrollevel", 1);//控制级次 默认为1
@ -85,7 +91,7 @@ public class InitAccountFormPlugin extends AbstractFormPlugin {
acctInfo.set("isjournal", false);//登日记账 现金等价物时需要勾选
//处理现金 银行科目 登日记账
handleAcctProperty(parentnumber,acctInfo);
acctInfo.set("enable", 1);//是否启用
acctInfo.set("enable", true);//是否启用
acctInfo.set("status", "C");//单据状态 A保存 B已提交 C已审核
acctInfo.set("creator", RequestContext.get().getCurrUserId());//创建人
//手动指定科目的金蝶id
@ -144,21 +150,21 @@ public class InitAccountFormPlugin extends AbstractFormPlugin {
continue;
}
//根据当前编号和名称处理父级科目
parentAcctInfo = handleParentAcct(number,name,acctType,acctTypeInfo);
parentAcctInfo = getParentAcct(number,name,acctType,acctTypeInfo);
// if(name.contains("-")){
// name = name.substring(name.indexOf("-")+1);
// }
//不存在做新增 根据实体名称创建动态对象
acctInfo = BusinessDataServiceHelper.newDynamicObject(entityName);
acctInfo.set("accounttable", EsbUtils.ACCTABLE);//科目表fid上正式时注意此ID
acctInfo.set("accounttable", tableinfo);//科目表fid上正式时注意此ID
acctInfo.set("number", number);
acctInfo.set("name", name);
acctInfo.set("longnumber", number);
acctInfo.set("fullname", name);
// acctInfo.set("longnumber", number);
// 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
@ -170,10 +176,10 @@ public class InitAccountFormPlugin extends AbstractFormPlugin {
acctInfo.set("dc", 1);//余额方向 默认为借
acctInfo.set("level", 2);//级次 默认为2
acctInfo.set("isleaf", true);//明细科目 默认为是
acctInfo.set("startdate", TypeUtils.castToDate("2024-01-01"));//版本化日期
acctInfo.set("startdate", TypeUtils.castToDate("1900-01-01"));//版本化日期
acctInfo.set("enddate", TypeUtils.castToDate("2999-12-31"));//失效日期
acctInfo.set("accrualdirection", "nocontrol");//科目录入方向控制 不控制nocontrol 借方debit 贷方credit
acctInfo.set("orgcontrollevel", 1);//控制级次 默认为1
acctInfo.set("orgcontrollevel", 2);//控制级次 默认为2
acctInfo.set("isallowca", false);//允许公司增加下级科目 由接口同步 为false时控制级次可以不设置
acctInfo.set("ismanual", true);//手工录入 由接口同步
acctInfo.set("iscash", false);//现金科目 默认false sap不区分
@ -182,7 +188,7 @@ public class InitAccountFormPlugin extends AbstractFormPlugin {
acctInfo.set("isjournal", false);//登日记账 现金等价物时需要勾选
//处理现金 银行科目 登日记账
handleAcctProperty(number,acctInfo);
acctInfo.set("enable", 1);//是否启用
acctInfo.set("enable", true);//是否启用
acctInfo.set("status", "C");//单据状态 A保存 B已提交 C已审核
acctInfo.set("creator", RequestContext.get().getCurrUserId());//创建人
//手动指定科目的金蝶id
@ -221,10 +227,11 @@ public class InitAccountFormPlugin extends AbstractFormPlugin {
rowdata = importData.getData();//具体的某行数据key值为列名
companysJson.add(rowdata);
}
//处理科目分配-分配好了后再创建子公司下的科目
EsbUtils.handleAssignInit(companysJson, acctids, entityName);
//处理科目在每个公司生成
companyAcctMaps = handleAccountCompany(accountMaps,companysJson);
//处理科目分配
EsbUtils.handleAssignInit(companysJson, acctids, entityName);
}
//处理每个公司下科目的核算维度和禁用状态
list = (ArrayList) itemEntry.get("shjh_hswds");//excel表格的某个页签-科目核算维度信息
@ -300,8 +307,8 @@ public class InitAccountFormPlugin extends AbstractFormPlugin {
}
acctInfo.set("isassist", true);//主表的isassist是否包含核算项目为是
//必须调用保存操作否则不符合受控基础资料开发规范
// SaveServiceHelper.save(new DynamicObject[]{acctInfo});
OperationServiceHelper.executeOperate("save", entityName, new DynamicObject[]{acctInfo}, oop);
SaveServiceHelper.save(new DynamicObject[]{acctInfo});
// OperationServiceHelper.executeOperate("save", entityName, new DynamicObject[]{acctInfo}, oop);
companyAcctMaps.put(number+companynum,acctInfo);
}
}
@ -441,7 +448,7 @@ public class InitAccountFormPlugin extends AbstractFormPlugin {
private DynamicObject copydo(DynamicObject olddo, DynamicObject hsorgInfo, JSONObject json_body){
DynamicObject newAcctInfo = BusinessDataServiceHelper.newDynamicObject(entityName);
newAcctInfo.set("accounttable", EsbUtils.ACCTABLE);//TODO 科目表fid上正式时注意此ID
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"));
@ -468,6 +475,18 @@ public class InitAccountFormPlugin extends AbstractFormPlugin {
}
}
}
if(olddo.getString("number").startsWith("2211")){
//2211开头的科目统一在科目接口上设置税基和税码的核算维度
DynamicObjectCollection dochswd = newAcctInfo.getDynamicObjectCollection("checkitementry");
DynamicObject itementryInfo = dochswd.addNew();
itementryInfo.set("asstactitem",getHsxmInfo("税基"));
itementryInfo.set("isdetail", true);//明细
itementryInfo.set("isrequire", false);//必录
DynamicObject itementryInfo1 = dochswd.addNew();
itementryInfo1.set("asstactitem",getHsxmInfo("税码"));
itementryInfo1.set("isdetail", true);//明细
itementryInfo1.set("isrequire", false);//必录
}
//损益类型
newAcctInfo.set("pltype", olddo.getString("pltype"));
newAcctInfo.set("parent", olddo.getDynamicObject("parent"));
@ -476,10 +495,10 @@ public class InitAccountFormPlugin extends AbstractFormPlugin {
newAcctInfo.set("dc", 1);//余额方向 默认为借
newAcctInfo.set("level", olddo.getInt("level"));//级次 根据源科目来设置
newAcctInfo.set("isleaf", true);//明细科目 默认为是
newAcctInfo.set("startdate", TypeUtils.castToDate("2024-01-01"));//版本化日期
newAcctInfo.set("startdate", TypeUtils.castToDate("1900-01-01"));//版本化日期
newAcctInfo.set("enddate", TypeUtils.castToDate("2999-12-31"));//失效日期
newAcctInfo.set("accrualdirection", "nocontrol");//科目录入方向控制 不控制nocontrol 借方debit 贷方credit
newAcctInfo.set("orgcontrollevel", 1);//控制级次 默认为1
newAcctInfo.set("orgcontrollevel", olddo.getInt("orgcontrollevel"));//控制级次 默认为1
newAcctInfo.set("isallowca", false);//允许公司增加下级科目 由接口同步 为false时控制级次可以不设置
newAcctInfo.set("ismanual", true);//手工录入 由接口同步
newAcctInfo.set("iscash", olddo.getBoolean("iscash"));//现金科目 默认false sap不区分
@ -493,10 +512,10 @@ public class InitAccountFormPlugin extends AbstractFormPlugin {
newAcctInfo.set("id", ID.genLongId());
newAcctInfo.set("masterid", olddo.getLong("id"));//主数据内码系统不会根据id自动生成需要手动设置
//必须调用保存操作否则不符合受控基础资料开发规范
// SaveServiceHelper.save(new DynamicObject[]{acctInfo});
OperationServiceHelper.executeOperate("save", entityName, new DynamicObject[]{newAcctInfo}, OperateOption.create());
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;
}

View File

@ -177,7 +177,7 @@ public class AspAccountControler {
acctInfo.set("dc", 1);//余额方向 默认为借
acctInfo.set("level", 2);//级次 默认为2
acctInfo.set("isleaf", true);//明细科目 默认为是
acctInfo.set("startdate", TypeUtils.castToDate("2024-01-01"));//版本化日期
acctInfo.set("startdate", TypeUtils.castToDate("1900-01-01"));//版本化日期
acctInfo.set("enddate", TypeUtils.castToDate("2999-12-31"));//失效日期
acctInfo.set("accrualdirection", "nocontrol");//科目录入方向控制 不控制nocontrol 借方debit 贷方credit
acctInfo.set("orgcontrollevel", 2);//控制级次 默认为2
@ -417,7 +417,7 @@ public class AspAccountControler {
newAcctInfo.set("dc", 1);//余额方向 默认为借
newAcctInfo.set("level", olddo.getInt("level"));//级次 根据源科目来设置
newAcctInfo.set("isleaf", true);//明细科目 默认为是
newAcctInfo.set("startdate", TypeUtils.castToDate("2024-01-01"));//版本化日期
newAcctInfo.set("startdate", TypeUtils.castToDate("1900-01-01"));//版本化日期
newAcctInfo.set("enddate", TypeUtils.castToDate("2999-12-31"));//失效日期
newAcctInfo.set("accrualdirection", "nocontrol");//科目录入方向控制 不控制nocontrol 借方debit 贷方credit
newAcctInfo.set("orgcontrollevel", olddo.getInt("orgcontrollevel"));//控制级次 根据源科目来设置
@ -503,7 +503,7 @@ public class AspAccountControler {
acctInfo.set("dc", 1);//余额方向 默认为借
acctInfo.set("level", 1);//级次 默认为1
acctInfo.set("isleaf", false);//明细科目 默认为否
acctInfo.set("startdate", TypeUtils.castToDate("2024-01-01"));//版本化日期
acctInfo.set("startdate", TypeUtils.castToDate("1900-01-01"));//版本化日期
acctInfo.set("enddate", TypeUtils.castToDate("2999-12-31"));//失效日期
acctInfo.set("accrualdirection", "nocontrol");//科目录入方向控制 不控制nocontrol 借方debit 贷方credit
acctInfo.set("orgcontrollevel", 1);//控制级次 默认为1