部门接口

This commit is contained in:
yuxueliang0813 2025-02-12 16:16:45 +08:00
parent 1d6f17330b
commit d11f5895dd
6 changed files with 134 additions and 98 deletions

View File

@ -2,6 +2,7 @@ package shjh.jhzj7.fi.fi.plugin.form;
import kd.bos.entity.filter.ControlFilters; import kd.bos.entity.filter.ControlFilters;
import kd.bos.form.events.SetFilterEvent; import kd.bos.form.events.SetFilterEvent;
import kd.bos.list.IListView;
import kd.bos.list.plugin.AbstractListPlugin; import kd.bos.list.plugin.AbstractListPlugin;
import kd.bos.orm.query.QFilter; import kd.bos.orm.query.QFilter;
@ -16,16 +17,20 @@ public class TestSupplierListPlugin extends AbstractListPlugin {
@Override @Override
public void setFilter(SetFilterEvent e) { public void setFilter(SetFilterEvent e) {
super.setFilter(e); super.setFilter(e);
List<QFilter> lqs = e.getQFilters(); // List<QFilter> lqs = e.getQFilters();
for (int i = 0; i < lqs.size(); i++) { // for (int i = 0; i < lqs.size(); i++) {
QFilter qf = lqs.get(i); // QFilter qf = lqs.get(i);
if("ctrlstrategy".equals(qf.getProperty())){ // if("ctrlstrategy".equals(qf.getProperty())){
lqs.remove(qf); // lqs.remove(qf);
break; // break;
} // }
} // }
lqs.add(new QFilter("createorg.id","=",2116762463713107968l)); // ControlFilters cfilters = ((IListView)this.getView()).getControlFilters();
lqs.size(); //// cfilters.
// lqs.add(new QFilter("createorg.id","=",2116762463713107968l));
// lqs.size();
// ControlFilters cfilters = ((IListView)this.getView()).getControlFilters();
// e.getQFilters().clear();
} }
@Override @Override
@ -33,6 +38,7 @@ public class TestSupplierListPlugin extends AbstractListPlugin {
return super.getControlFilters(); return super.getControlFilters();
} }
@Override @Override
public void afterBindData(EventObject e) { public void afterBindData(EventObject e) {
super.afterBindData(e); super.afterBindData(e);

View File

@ -20,6 +20,7 @@ import kd.bos.servicehelper.QueryServiceHelper;
import kd.bos.servicehelper.org.OrgUnitServiceHelper; import kd.bos.servicehelper.org.OrgUnitServiceHelper;
import kd.bos.servicehelper.org.OrgViewType; import kd.bos.servicehelper.org.OrgViewType;
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.webapi.model.AdminOrgModel; import shjh.jhzj7.fi.fi.webapi.model.AdminOrgModel;
import javax.validation.Valid; import javax.validation.Valid;
@ -41,7 +42,6 @@ public class AdminOrgControler {
*/ */
@ApiPostMapping(value = apimenthod, desc = "行政组织接口") @ApiPostMapping(value = apimenthod, desc = "行政组织接口")
public CustomApiResult<ApiResult> adminorg_sync (@NotNull @Valid @ApiRequestBody(value="入参json格式") AdminOrgModel bizParam) { public CustomApiResult<ApiResult> adminorg_sync (@NotNull @Valid @ApiRequestBody(value="入参json格式") AdminOrgModel bizParam) {
JSONObject json_obj; JSONObject json_obj;
try{ try{
//解析入参如果格式不正确日志记录并反馈esb //解析入参如果格式不正确日志记录并反馈esb
@ -58,8 +58,8 @@ public class AdminOrgControler {
JSONArray itemsJson = new JSONArray();//返回值明细集合 JSONArray itemsJson = new JSONArray();//返回值明细集合
JSONObject itemInfo;//返回值明细对象 JSONObject itemInfo;//返回值明细对象
JSONArray detailsJson = json_obj.getJSONArray("items"); JSONArray detailsJson = json_obj.getJSONArray("items");
//处理入参的排序按照deptLevel正序 // //处理入参的排序按照deptLevel正序
detailsJson.sort(Comparator.comparingInt(json -> ((JSONObject) json).getIntValue("deptLevel"))); // detailsJson.sort(Comparator.comparing(json -> ((JSONObject) json).getString("deptLevel")));
String orgNumber; String orgNumber;
String orgName; String orgName;
String fycc; String fycc;
@ -76,83 +76,103 @@ public class AdminOrgControler {
OrgDutyView dutyView; OrgDutyView dutyView;
String handleResult; String handleResult;
JSONObject json_body; JSONObject json_body;
for (int i = 0; i < detailsJson.size(); i++) { //MDM目前设置了A-H级
json_body = detailsJson.getJSONObject(i); String[] levelStr = new String[]{"A","B","C","D","E","F","G","H"};
orgNumber = json_body.getString("code"); for (int j = 0; j < levelStr.length; j++) {
orgName = json_body.getString("categoryName"); for (int i = 0; i < detailsJson.size(); i++) {
fycc = json_body.getString("fee_cost_center");//费用成本中心 json_body = detailsJson.getJSONObject(i);
parentCode = json_body.getString("parentCode");//上级组织编号 orgLevel = json_body.getString("deptLevel");//组织层级
person_charge = json_body.getString("deptManager");//部门负责人编号 if(!levelStr[j].equals(orgLevel)){
orgLevel = json_body.getString("deptLevel");//组织层级 continue;
company = json_body.getString("company");//所属公司编号 }
if(EsbUtils.isEmpty(orgNumber) || EsbUtils.isEmpty(orgName) || EsbUtils.isEmpty(orgLevel) || orgNumber = json_body.getString("code");
(Integer.parseInt(orgLevel)>1 && EsbUtils.isEmpty(parentCode))){ orgName = json_body.getString("categoryName");
log.error(String.format("行政组织入参为空异常:%s", json_body.toJSONString())); fycc = json_body.getString("fee_cost_center");//费用成本中心
itemInfo = new JSONObject(); parentCode = json_body.getString("parentCode");//上级组织编号
itemInfo.put("code",orgNumber); person_charge = json_body.getString("deptManager");//部门负责人编号
itemInfo.put("error","入参值为空"); company = json_body.getString("company");//所属公司编号
itemsJson.add(itemInfo); if(EsbUtils.isEmpty(orgNumber) || EsbUtils.isEmpty(orgName) || (j>=1 && EsbUtils.isEmpty(parentCode))){
continue; log.error(String.format("行政组织入参为空异常:%s", json_body.toJSONString()));
} itemInfo = new JSONObject();
param = new OrgParam(); itemInfo.put("code",orgNumber);
param.setName(orgName); itemInfo.put("error","入参值为空");
param.setNumber(orgNumber); itemsJson.add(itemInfo);
param.setOrgPatternId(4);//组织形态ID默认ID为4L部门1为公司当前组织是公司还是部门需要有字段可以体现 continue;
param.setDuty(OrgViewType.Admin);//组织属性-行政组织 }
param.setSource("esb");//数据来源 param = new OrgParam();
param.setSimpleName(json_body.getString("deptshortname"));//组织简称 param.setName(orgName);
//处理上级组织 param.setNumber(orgNumber);
parentOrg = QueryServiceHelper.queryOne(entityName,"id,number",new QFilter[]{new QFilter("number","=",parentCode)}); param.setOrgPatternId(4);//组织形态ID默认ID为4L部门1为公司当前组织是公司还是部门需要有字段可以体现
if(parentOrg == null && Integer.parseInt(orgLevel)>1){ param.setDuty(OrgViewType.Admin);//组织属性-行政组织
log.error(String.format("根据父级行政组织编号未在金蝶中找到对应组织:%s", parentCode)); param.setSource("esb");//数据来源
itemInfo = new JSONObject(); param.setSimpleName(json_body.getString("deptshortname"));//组织简称
itemInfo.put("code",orgNumber); //处理上级组织
itemInfo.put("error","根据父级行政组织编号未在金蝶中找到对应组织"); parentOrg = QueryServiceHelper.queryOne(entityName,"id,number",new QFilter[]{new QFilter("number","=",parentCode)});
itemsJson.add(itemInfo); if(parentOrg == null && j>=1){
continue; log.error(String.format("根据父级行政组织编号未在金蝶中找到对应组织:%s", parentCode));
} itemInfo = new JSONObject();
propertyMap.clear(); itemInfo.put("code",orgNumber);
//处理费用成本中心 itemInfo.put("error","根据父级行政组织编号未在金蝶中找到对应组织");
costCenter = QueryServiceHelper.queryOne(ccName,"id,number",new QFilter[]{new QFilter("number","=",fycc)}); itemsJson.add(itemInfo);
if(costCenter != null){ continue;
propertyMap.put("shjh_fycc", costCenter.getLong("id"));//设置成本中心ID }
} propertyMap.clear();
propertyMap.put("shjh_ssgs", company);//设置所属公司编号 //处理费用成本中心
propertyMap.put("shjh_deptmanager", person_charge);//设置部门负责人编号 if(!EsbUtils.isEmpty(fycc)){
//处理禁用组织 costCenter = QueryServiceHelper.queryOne(ccName,"id,number",new QFilter[]{new QFilter("number","=",fycc)});
if("0".equals(json_body.getString("status"))){ if(costCenter != null){
propertyMap.put("enable", "0"); propertyMap.put("shjh_fycc", costCenter.getLong("id"));//设置成本中心ID
} }
param.setPropertyMap(propertyMap); }
//根据组织编号查找系统现有数据是否存在
currentOrg = QueryServiceHelper.queryOne(entityName,"id,number",new QFilter[]{new QFilter("number","=",orgNumber)}); propertyMap.put("shjh_ssgs", company);//设置所属公司编号
if(currentOrg == null){ propertyMap.put("shjh_deptmanager", person_charge);//设置部门负责人编号
//新增组织 //处理禁用组织
param.setParentId(parentOrg.getLong("id"));//上级组织的金蝶ID if("0".equals(json_body.getString("status"))){
OrgUnitServiceHelper.add(param); propertyMap.put("enable", "0");
}else{ }
//更新组织 param.setPropertyMap(propertyMap);
param.setId(currentOrg.getLong("id")); //根据组织编号查找系统现有数据是否存在
//设置多视图参数 currentOrg = QueryServiceHelper.queryOne(entityName,"id,number",new QFilter[]{new QFilter("number","=",orgNumber)});
multiViewMap.clear(); if(currentOrg == null){
dutyView = new OrgDutyView(); //新增组织
//组织移动时设置新的上级ID if("A".equals(orgLevel)){
dutyView.setParentId(parentOrg.getLong("id")); //如果是A 第一级 则上级为组织的根节点
//行政组织 param.setParentId(JhzjUtils.GROUPID);
multiViewMap.put(OrgViewType.Admin, dutyView); }else{
param.setMultiViewMap(multiViewMap); param.setParentId(parentOrg.getLong("id"));//上级组织的金蝶ID
OrgUnitServiceHelper.update(param); }
} OrgUnitServiceHelper.add(param);
if (!param.isSuccess()) { }else{
handleResult = String.format("行政组织保存异常:%s", param.getMsg()); //更新组织
log.error(handleResult); param.setId(currentOrg.getLong("id"));
itemInfo = new JSONObject(); //设置多视图参数
itemInfo.put("code",orgNumber); multiViewMap.clear();
itemInfo.put("error",handleResult); dutyView = new OrgDutyView();
itemsJson.add(itemInfo); //组织移动时设置新的上级ID
if("A".equals(orgLevel)){
//如果是A 第一级 则上级为组织的根节点
dutyView.setParentId(JhzjUtils.GROUPID);
}else{
dutyView.setParentId(parentOrg.getLong("id"));
}
//行政组织
multiViewMap.put(OrgViewType.Admin, dutyView);
param.setMultiViewMap(multiViewMap);
OrgUnitServiceHelper.update(param);
}
if (!param.isSuccess()) {
handleResult = String.format("行政组织保存异常:%s", param.getMsg());
log.error(handleResult);
itemInfo = new JSONObject();
itemInfo.put("code",orgNumber);
itemInfo.put("error",handleResult);
itemsJson.add(itemInfo);
}
} }
} }
//返回最终处理结果,如果上述有单个组织处理失败则总体状态overallStatus是何值 //返回最终处理结果,如果上述有单个组织处理失败则总体状态overallStatus是何值
// json_result.put("overallStatus","1"); // json_result.put("overallStatus","1");
// json_result.put("items",itemsJson); // json_result.put("items",itemsJson);

View File

@ -11,6 +11,8 @@ import kd.bos.api.client.ApiResult;
import kd.bos.context.RequestContext; 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.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;
@ -20,6 +22,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.basedata.BaseDataServiceHelper;
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;
@ -85,8 +88,12 @@ public class AspAccountControler {
DynamicObjectCollection docbb; DynamicObjectCollection docbb;
DynamicObject bbInfo; DynamicObject bbInfo;
String bbiso; String bbiso;
String insertSql = "insert into T_BD_Account_U(fdataid,fuseorgid) values (?,?);";
Map<String, Long> acctids = new HashMap<>();//科目编号和ID对应关系
Map<String, DynamicObject> accountMaps = new HashMap<>();//将科目编号与对象关联 Map<String, DynamicObject> accountMaps = new HashMap<>();//将科目编号与对象关联
//先根据基础信息在集团层面生成科目不考虑核算维度使用逐级分配
//再根据公司信息进行科目分配
//最后处理每个公司下科目的核算维度和禁用状态
for (int i = 0; i < companysJson.size(); i++) { for (int i = 0; i < companysJson.size(); i++) {
company_body = companysJson.getJSONObject(i); company_body = companysJson.getJSONObject(i);
number = company_body.getString("code"); number = company_body.getString("code");
@ -124,8 +131,6 @@ public class AspAccountControler {
if("0".equals(company_body.getString("companystatus")) || "0".equals(json_body.getString("status"))){ if("0".equals(company_body.getString("companystatus")) || "0".equals(json_body.getString("status"))){
acctInfo.set("enable", 0);//科目禁用处理 acctInfo.set("enable", 0);//科目禁用处理
} }
// acctInfo.set("ctrlstrategy", "7");
// acctInfo.set("pltype", getSY(acctType));
acctInfo.set("name", name); acctInfo.set("name", name);
acctInfo.set("fullname", name); acctInfo.set("fullname", name);
acctInfo.set("acctcurrency", bbhs); acctInfo.set("acctcurrency", bbhs);
@ -196,7 +201,7 @@ public class AspAccountControler {
} }
} }
} }
acctInfo.set("ctrlstrategy", "7");//控制策略 5全局共享 7私有 acctInfo.set("ctrlstrategy", "1");//控制策略 5全局共享 7私有 1逐级分配
acctInfo.set("control", "nocontrol");//受控系统 nocontrol 应付 应收 资产 acctInfo.set("control", "nocontrol");//受控系统 nocontrol 应付 应收 资产
//损益类型 //损益类型
acctInfo.set("pltype", getSY(acctType)); acctInfo.set("pltype", getSY(acctType));
@ -222,10 +227,15 @@ public class AspAccountControler {
acctInfo.set("masterid", kmId);//主数据内码系统不会根据id自动生成需要手动设置 acctInfo.set("masterid", kmId);//主数据内码系统不会根据id自动生成需要手动设置
//保存数据直接保存入库不走操作校验 //保存数据直接保存入库不走操作校验
SaveServiceHelper.save(new DynamicObject[]{acctInfo}); SaveServiceHelper.save(new DynamicObject[]{acctInfo});
//处理科目使用范围
DB.update(DBRoute.of("sys"), insertSql, new Object[]{kmId,JhzjUtils.GROUPID});
} }
accountMaps.put(number+companynum,acctInfo); accountMaps.put(number+companynum,acctInfo);
} }
//处理科目分配
EsbUtils.handleAssign(companysJson, acctids, entityName);
//处理核算维度 //处理核算维度
JSONArray asstacttypesJson = json_obj.getJSONArray("asstacttypes"); JSONArray asstacttypesJson = json_obj.getJSONArray("asstacttypes");
String hsxm;//核算维度名称 基础资料 String hsxm;//核算维度名称 基础资料

View File

@ -9,9 +9,9 @@ import java.util.List;
@ApiModel @ApiModel
public class AdminOrgModel implements Serializable { public class AdminOrgModel implements Serializable {
@ApiParam(value="批次id",required=true,position=1) @ApiParam(value="批次id",required=false,position=1)
private String batchId; private String batchId;
@ApiParam(value="明细集合",required=true,position=2) @ApiParam(value="明细集合",required=false,position=2)
private List<AdminOrgModel.EntryBean> items; private List<AdminOrgModel.EntryBean> items;
public void setBatchId(String batchId) { public void setBatchId(String batchId) {
this.batchId = batchId; this.batchId = batchId;

View File

@ -9,9 +9,9 @@ import java.util.List;
@ApiModel @ApiModel
public class CostCenterModel implements Serializable { public class CostCenterModel implements Serializable {
@ApiParam(value="批次id",required=true,position=1) @ApiParam(value="批次id",required=false,position=1)
private String batchId; private String batchId;
@ApiParam(value="明细集合",required=true,position=2) @ApiParam(value="明细集合",required=false,position=2)
private List<EntryBean> items; private List<EntryBean> items;
public void setBatchId(String batchId) { public void setBatchId(String batchId) {
this.batchId = batchId; this.batchId = batchId;

View File

@ -9,11 +9,11 @@ import java.util.List;
@ApiModel @ApiModel
public class PersonModel implements Serializable { public class PersonModel implements Serializable {
@ApiParam(value="批次id",required=true,position=1) @ApiParam(value="批次id",required=false,position=1)
private String batchId; private String batchId;
@ApiParam(value="员工类型",required=true,position=2) @ApiParam(value="员工类型",required=false,position=2)
private String staffType; private String staffType;
@ApiParam(value="明细集合",required=true,position=3) @ApiParam(value="明细集合",required=false,position=3)
private List<PersonModel.EntryBean> items; private List<PersonModel.EntryBean> items;
public void setBatchId(String batchId) { public void setBatchId(String batchId) {
this.batchId = batchId; this.batchId = batchId;