会计科目接口优化
This commit is contained in:
parent
9d68d478f9
commit
46f31cf0fd
|
|
@ -18,15 +18,16 @@ public class PayinfoChangeOperation extends AbstractOperationServicePlugIn imple
|
|||
@Override
|
||||
public void beforeExecuteOperationTransaction(BeforeOperationArgs e) {
|
||||
super.beforeExecuteOperationTransaction(e);
|
||||
//增加校验,源单类型是费控的,不允许发起收款信息变更;
|
||||
//增加校验,来源系统是费控的,不允许发起收款信息变更;
|
||||
String eok = e.getOperationKey();
|
||||
if("recpushchg".equals(eok)){
|
||||
DynamicObject[] dos = e.getDataEntities();
|
||||
DynamicObject prinfo = null;
|
||||
for (int i = 0; i < dos.length; i++) {
|
||||
//TODO 反审核操作之前系统未把info对象所有属性加载出来,尤其是二开的字段,需要在此处重新load一下
|
||||
prinfo = BusinessDataServiceHelper.loadSingle(dos[i].getPkValue(),dos[i].getDataEntityType().getName());
|
||||
if("".equals(prinfo.getString(""))){
|
||||
prinfo = BusinessDataServiceHelper.loadSingle(dos[i].getPkValue(),dos[i].getDataEntityType().getName(),
|
||||
"id,billno,shjh_sourcesystem");
|
||||
if("B".equals(prinfo.getString("shjh_sourcesystem"))){
|
||||
e.setCancelMessage(prinfo.getString("billno")+"为费控推送的单据,不能发起收款信息变更");
|
||||
e.setCancel(true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
package shjh.jhzj7.fi.fi.plugin.operate;
|
||||
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
||||
import kd.bos.entity.plugin.args.BeforeOperationArgs;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* 付款申请单据操作插件
|
||||
*/
|
||||
public class PayrequestBillOperation extends AbstractOperationServicePlugIn implements Plugin {
|
||||
|
||||
/**
|
||||
* 操作校验通过之后,开启事务之前,触发此事件;
|
||||
* 插件可以在此事件,对通过校验的数据,进行整理
|
||||
*/
|
||||
@Override
|
||||
public void beforeExecuteOperationTransaction(BeforeOperationArgs e) {
|
||||
super.beforeExecuteOperationTransaction(e);
|
||||
//增加校验,标记为“来源调整单”的付款申请单,不能手动去关闭或反审核。
|
||||
String eok = e.getOperationKey();
|
||||
if("closepay".equals(eok) || "unaudit".equals(eok)){
|
||||
DynamicObject[] dos = e.getDataEntities();
|
||||
DynamicObject prinfo = null;
|
||||
for (int i = 0; i < dos.length; i++) {
|
||||
//反审核操作之前系统未把info对象所有属性加载出来,尤其是二开的字段,需要在此处重新load一下
|
||||
prinfo = BusinessDataServiceHelper.loadSingle(dos[i].getPkValue(),dos[i].getDataEntityType().getName(),
|
||||
"id,billno,shjh_sourceadjustment");
|
||||
if(prinfo.getBoolean("shjh_sourceadjustment")){
|
||||
e.setCancelMessage(prinfo.getString("billno")+"来源于费控付款调整单,不能手动关闭或者反审核");
|
||||
e.setCancel(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -25,7 +25,7 @@ public class EsbUtils {
|
|||
public static final Long CUSTOMERSTAND = 712984405228187648l;//客户分类标准
|
||||
public static final Long CUSTOMERSTATUS = 1122390034075371520l;//客户状态 默认合格
|
||||
|
||||
public static final Long ACCTABLE = 1318154893474663424L;//科目表
|
||||
public static final Long ACCTABLE = 2125524820924832768L;//科目表
|
||||
private static final String orgName = "bos_org";//系统库 表名 t_org_org
|
||||
|
||||
public static boolean isEmpty(String value) {
|
||||
|
|
|
|||
|
|
@ -66,12 +66,15 @@ public class AspAccountControler {
|
|||
EsbUtils.saveLog(apimenthod,"ESB",null,jsonResult,false,"API");
|
||||
return CustomApiResult.fail("400","接口入参异常");
|
||||
}
|
||||
|
||||
JSONArray detailsJson = json_obj.getJSONArray("items");
|
||||
if(detailsJson == null){
|
||||
return CustomApiResult.fail("400","未识别到items参数");
|
||||
}
|
||||
JSONArray itemsJson = new JSONArray();//返回值明细集合
|
||||
JSONObject itemInfo;//返回值明细对象
|
||||
//根据科目基本信息得到科目编号和JSONObject
|
||||
// Map<String, JSONObject> baseMaps = getBaseMap(json_obj.getJSONArray("items"));
|
||||
JSONArray companysJson = json_obj.getJSONArray("companys");
|
||||
JSONArray detailsJson = json_obj.getJSONArray("items");
|
||||
String number;//科目编号
|
||||
String name;//科目名称
|
||||
// String isleaf;//是否叶子节点
|
||||
|
|
@ -81,10 +84,8 @@ public class AspAccountControler {
|
|||
String bbhs;//币别核算 不核算外币 核算所有外币 指定核算币别(需要指定币别ISO)
|
||||
String acctType;//科目类型 资产负债类 损益类
|
||||
String descurrencynum;//指定币别编号
|
||||
// DynamicObject hsorgInfo;
|
||||
DynamicObject acctInfo;
|
||||
DynamicObject acctTypeInfo;
|
||||
// DynamicObject parentAcctInfo;
|
||||
JSONObject json_body;
|
||||
DynamicObjectCollection docbb;
|
||||
DynamicObject bbInfo;
|
||||
|
|
@ -96,7 +97,7 @@ public class AspAccountControler {
|
|||
//再根据公司信息进行科目分配
|
||||
//最后处理每个公司下科目的核算维度和禁用状态
|
||||
for (int i = 0; i < detailsJson.size(); i++) {
|
||||
json_body = companysJson.getJSONObject(i);
|
||||
json_body = detailsJson.getJSONObject(i);
|
||||
number = json_body.getString("code");
|
||||
// json_body = baseMaps.get(number);
|
||||
// companynum = company_body.getString("companynum");//公司编号
|
||||
|
|
@ -183,7 +184,7 @@ public class AspAccountControler {
|
|||
// acctInfo.set("createorg", hsorgInfo.getLong("id"));//创建组织
|
||||
// acctInfo.set("org", hsorgInfo.getLong("id"));//管理组织
|
||||
//科目类型
|
||||
acctInfo.set("accounttype", acctTypeInfo.getLong("id"));
|
||||
acctInfo.set("accounttype", acctTypeInfo);
|
||||
//币别核算--外币核算类型
|
||||
acctInfo.set("acctcurrency", bbhs);//不核算外币nocurrency 指定核算币别descurrency 核算所有币别allcurrency
|
||||
//如果是指定核算币别
|
||||
|
|
@ -226,17 +227,21 @@ public class AspAccountControler {
|
|||
//保存数据:直接保存入库,不走操作校验
|
||||
SaveServiceHelper.save(new DynamicObject[]{acctInfo});
|
||||
//处理科目使用范围
|
||||
DB.update(DBRoute.of("sys"), insertSql, new Object[]{kmId,JhzjUtils.GROUPID});
|
||||
DB.update(DBRoute.of("fi"), insertSql, new Object[]{kmId,JhzjUtils.GROUPID});
|
||||
}
|
||||
acctids.put(number,acctInfo.getLong("id"));
|
||||
accountMaps.put(number,acctInfo);
|
||||
}
|
||||
//处理科目分配
|
||||
EsbUtils.handleAssign(companysJson, acctids, entityName);
|
||||
|
||||
JSONArray companysJson = json_obj.getJSONArray("companys");
|
||||
//处理科目在每个公司生成
|
||||
Map<String, DynamicObject> companyAcctMaps = handleAccountCompany(accountMaps,companysJson);
|
||||
//处理科目分配和反分配
|
||||
EsbUtils.handleAssign(companysJson, acctids, entityName);
|
||||
EsbUtils.handleUnAssign(companysJson, acctids, entityName);
|
||||
//处理每个公司下科目的核算维度和禁用状态
|
||||
JSONArray asstacttypesJson = json_obj.getJSONArray("asstacttypes");
|
||||
if(asstacttypesJson != null){
|
||||
String hsxm;//核算维度名称 基础资料
|
||||
DynamicObject hsxmInfo;//核算维度对象
|
||||
DynamicObjectCollection dochswd;
|
||||
|
|
@ -278,9 +283,9 @@ public class AspAccountControler {
|
|||
}
|
||||
checkitementryInfo = null;
|
||||
}
|
||||
if(checkitementryInfo == null){
|
||||
if(checkitementryInfo == null || dochswd.size() == 0){
|
||||
checkitementryInfo = dochswd.addNew();
|
||||
checkitementryInfo.set("asstactitem",hsxmInfo.getLong("id"));
|
||||
checkitementryInfo.set("asstactitem",hsxmInfo);
|
||||
checkitementryInfo.set("isdetail", true);//明细
|
||||
}
|
||||
if("1".equals(json_body.getString("isneed"))){
|
||||
|
|
@ -292,6 +297,7 @@ public class AspAccountControler {
|
|||
SaveServiceHelper.save(new DynamicObject[]{acctInfo});
|
||||
companyAcctMaps.put(number+companynum,acctInfo);
|
||||
}
|
||||
}
|
||||
|
||||
if(itemsJson.isEmpty()){
|
||||
EsbUtils.saveLog(apimenthod,"ESB",json_obj.toString(),null,true,"API");
|
||||
|
|
@ -304,6 +310,9 @@ public class AspAccountControler {
|
|||
|
||||
private Map<String, DynamicObject> handleAccountCompany(Map<String, DynamicObject> accountMaps,JSONArray companysJson){
|
||||
Map<String, DynamicObject> baseMaps = new HashMap<>();
|
||||
if(companysJson == null){
|
||||
return baseMaps;
|
||||
}
|
||||
JSONObject json_body;
|
||||
DynamicObject oldAcctInfo;
|
||||
DynamicObject newAcctInfo;
|
||||
|
|
@ -346,7 +355,7 @@ public class AspAccountControler {
|
|||
newAcctInfo.set("createorg", hsorgInfo.getLong("id"));//创建组织
|
||||
newAcctInfo.set("org", hsorgInfo.getLong("id"));//管理组织
|
||||
//科目类型
|
||||
newAcctInfo.set("accounttype", olddo.getDynamicObject("accounttype").getLong("id"));
|
||||
newAcctInfo.set("accounttype", olddo.getDynamicObject("accounttype"));
|
||||
//币别核算--外币核算类型
|
||||
newAcctInfo.set("acctcurrency", olddo.getString("acctcurrency"));//不核算外币nocurrency 指定核算币别descurrency 核算所有币别allcurrency
|
||||
//如果是指定核算币别
|
||||
|
|
@ -366,7 +375,7 @@ public class AspAccountControler {
|
|||
newAcctInfo.set("ctrlstrategy", "1");//控制策略 5全局共享 7私有 1逐级分配
|
||||
newAcctInfo.set("control", "nocontrol");//受控系统 nocontrol 无 应付 应收 资产
|
||||
newAcctInfo.set("dc", 1);//余额方向 默认为借
|
||||
newAcctInfo.set("level", 1);//级次 默认为1
|
||||
newAcctInfo.set("level", olddo.getInt("level"));//级次 根据源科目来设置
|
||||
newAcctInfo.set("isleaf", true);//明细科目 默认为是
|
||||
newAcctInfo.set("startdate", new Date());//版本化日期
|
||||
newAcctInfo.set("enddate", TypeUtils.castToDate("2999-12-31"));//失效日期
|
||||
|
|
@ -386,7 +395,7 @@ public class AspAccountControler {
|
|||
newAcctInfo.set("masterid", olddo.getLong("id"));//主数据内码,系统不会根据id自动生成,需要手动设置
|
||||
SaveServiceHelper.save(new DynamicObject[]{newAcctInfo});
|
||||
//处理科目使用范围
|
||||
DB.update(DBRoute.of("sys"), insertSql, new Object[]{newAcctInfo.getLong("id"),JhzjUtils.GROUPID});
|
||||
DB.update(DBRoute.of("fi"), insertSql, new Object[]{newAcctInfo.getLong("id"),hsorgInfo.getLong("id")});
|
||||
return newAcctInfo;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ import java.util.List;
|
|||
|
||||
@ApiModel
|
||||
public class AccountModel implements Serializable {
|
||||
@ApiParam(value="批次id",required=true,position=1)
|
||||
@ApiParam(value="批次id",required=false,position=1)
|
||||
private String batchId;
|
||||
@ApiParam(value="科目明细集合",required=true,position=2)
|
||||
@ApiParam(value="科目明细集合",required=false,position=2)
|
||||
private List<EntryBean> items;
|
||||
@ApiParam(value="公司信息集合",required=false,position=3)
|
||||
private List<CompanyBean> companys;
|
||||
|
|
|
|||
Loading…
Reference in New Issue