部门接口

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.form.events.SetFilterEvent;
import kd.bos.list.IListView;
import kd.bos.list.plugin.AbstractListPlugin;
import kd.bos.orm.query.QFilter;
@ -16,16 +17,20 @@ public class TestSupplierListPlugin extends AbstractListPlugin {
@Override
public void setFilter(SetFilterEvent e) {
super.setFilter(e);
List<QFilter> lqs = e.getQFilters();
for (int i = 0; i < lqs.size(); i++) {
QFilter qf = lqs.get(i);
if("ctrlstrategy".equals(qf.getProperty())){
lqs.remove(qf);
break;
}
}
lqs.add(new QFilter("createorg.id","=",2116762463713107968l));
lqs.size();
// List<QFilter> lqs = e.getQFilters();
// for (int i = 0; i < lqs.size(); i++) {
// QFilter qf = lqs.get(i);
// if("ctrlstrategy".equals(qf.getProperty())){
// lqs.remove(qf);
// break;
// }
// }
// ControlFilters cfilters = ((IListView)this.getView()).getControlFilters();
//// cfilters.
// lqs.add(new QFilter("createorg.id","=",2116762463713107968l));
// lqs.size();
// ControlFilters cfilters = ((IListView)this.getView()).getControlFilters();
// e.getQFilters().clear();
}
@Override
@ -33,6 +38,7 @@ public class TestSupplierListPlugin extends AbstractListPlugin {
return super.getControlFilters();
}
@Override
public void afterBindData(EventObject 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.OrgViewType;
import shjh.jhzj7.fi.fi.utils.EsbUtils;
import shjh.jhzj7.fi.fi.utils.JhzjUtils;
import shjh.jhzj7.fi.fi.webapi.model.AdminOrgModel;
import javax.validation.Valid;
@ -41,7 +42,6 @@ public class AdminOrgControler {
*/
@ApiPostMapping(value = apimenthod, desc = "行政组织接口")
public CustomApiResult<ApiResult> adminorg_sync (@NotNull @Valid @ApiRequestBody(value="入参json格式") AdminOrgModel bizParam) {
JSONObject json_obj;
try{
//解析入参如果格式不正确日志记录并反馈esb
@ -58,8 +58,8 @@ public class AdminOrgControler {
JSONArray itemsJson = new JSONArray();//返回值明细集合
JSONObject itemInfo;//返回值明细对象
JSONArray detailsJson = json_obj.getJSONArray("items");
//处理入参的排序按照deptLevel正序
detailsJson.sort(Comparator.comparingInt(json -> ((JSONObject) json).getIntValue("deptLevel")));
// //处理入参的排序按照deptLevel正序
// detailsJson.sort(Comparator.comparing(json -> ((JSONObject) json).getString("deptLevel")));
String orgNumber;
String orgName;
String fycc;
@ -76,17 +76,22 @@ public class AdminOrgControler {
OrgDutyView dutyView;
String handleResult;
JSONObject json_body;
//MDM目前设置了A-H级
String[] levelStr = new String[]{"A","B","C","D","E","F","G","H"};
for (int j = 0; j < levelStr.length; j++) {
for (int i = 0; i < detailsJson.size(); i++) {
json_body = detailsJson.getJSONObject(i);
orgLevel = json_body.getString("deptLevel");//组织层级
if(!levelStr[j].equals(orgLevel)){
continue;
}
orgNumber = json_body.getString("code");
orgName = json_body.getString("categoryName");
fycc = json_body.getString("fee_cost_center");//费用成本中心
parentCode = json_body.getString("parentCode");//上级组织编号
person_charge = json_body.getString("deptManager");//部门负责人编号
orgLevel = json_body.getString("deptLevel");//组织层级
company = json_body.getString("company");//所属公司编号
if(EsbUtils.isEmpty(orgNumber) || EsbUtils.isEmpty(orgName) || EsbUtils.isEmpty(orgLevel) ||
(Integer.parseInt(orgLevel)>1 && EsbUtils.isEmpty(parentCode))){
if(EsbUtils.isEmpty(orgNumber) || EsbUtils.isEmpty(orgName) || (j>=1 && EsbUtils.isEmpty(parentCode))){
log.error(String.format("行政组织入参为空异常:%s", json_body.toJSONString()));
itemInfo = new JSONObject();
itemInfo.put("code",orgNumber);
@ -103,7 +108,7 @@ public class AdminOrgControler {
param.setSimpleName(json_body.getString("deptshortname"));//组织简称
//处理上级组织
parentOrg = QueryServiceHelper.queryOne(entityName,"id,number",new QFilter[]{new QFilter("number","=",parentCode)});
if(parentOrg == null && Integer.parseInt(orgLevel)>1){
if(parentOrg == null && j>=1){
log.error(String.format("根据父级行政组织编号未在金蝶中找到对应组织:%s", parentCode));
itemInfo = new JSONObject();
itemInfo.put("code",orgNumber);
@ -113,10 +118,13 @@ public class AdminOrgControler {
}
propertyMap.clear();
//处理费用成本中心
if(!EsbUtils.isEmpty(fycc)){
costCenter = QueryServiceHelper.queryOne(ccName,"id,number",new QFilter[]{new QFilter("number","=",fycc)});
if(costCenter != null){
propertyMap.put("shjh_fycc", costCenter.getLong("id"));//设置成本中心ID
}
}
propertyMap.put("shjh_ssgs", company);//设置所属公司编号
propertyMap.put("shjh_deptmanager", person_charge);//设置部门负责人编号
//处理禁用组织
@ -128,7 +136,12 @@ public class AdminOrgControler {
currentOrg = QueryServiceHelper.queryOne(entityName,"id,number",new QFilter[]{new QFilter("number","=",orgNumber)});
if(currentOrg == null){
//新增组织
if("A".equals(orgLevel)){
//如果是A 第一级 则上级为组织的根节点
param.setParentId(JhzjUtils.GROUPID);
}else{
param.setParentId(parentOrg.getLong("id"));//上级组织的金蝶ID
}
OrgUnitServiceHelper.add(param);
}else{
//更新组织
@ -137,7 +150,12 @@ public class AdminOrgControler {
multiViewMap.clear();
dutyView = new OrgDutyView();
//组织移动时设置新的上级ID
if("A".equals(orgLevel)){
//如果是A 第一级 则上级为组织的根节点
dutyView.setParentId(JhzjUtils.GROUPID);
}else{
dutyView.setParentId(parentOrg.getLong("id"));
}
//行政组织
multiViewMap.put(OrgViewType.Admin, dutyView);
param.setMultiViewMap(multiViewMap);
@ -152,6 +170,8 @@ public class AdminOrgControler {
itemsJson.add(itemInfo);
}
}
}
//返回最终处理结果,如果上述有单个组织处理失败则总体状态overallStatus是何值
// json_result.put("overallStatus","1");

View File

@ -11,6 +11,8 @@ import kd.bos.api.client.ApiResult;
import kd.bos.context.RequestContext;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.db.DB;
import kd.bos.db.DBRoute;
import kd.bos.id.ID;
import kd.bos.logging.Log;
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.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.basedata.BaseDataServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import shjh.jhzj7.fi.fi.utils.EsbUtils;
import shjh.jhzj7.fi.fi.utils.JhzjUtils;
@ -85,8 +88,12 @@ public class AspAccountControler {
DynamicObjectCollection docbb;
DynamicObject bbInfo;
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<>();//将科目编号与对象关联
//先根据基础信息在集团层面生成科目不考虑核算维度使用逐级分配
//再根据公司信息进行科目分配
//最后处理每个公司下科目的核算维度和禁用状态
for (int i = 0; i < companysJson.size(); i++) {
company_body = companysJson.getJSONObject(i);
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"))){
acctInfo.set("enable", 0);//科目禁用处理
}
// acctInfo.set("ctrlstrategy", "7");
// acctInfo.set("pltype", getSY(acctType));
acctInfo.set("name", name);
acctInfo.set("fullname", name);
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("pltype", getSY(acctType));
@ -222,10 +227,15 @@ public class AspAccountControler {
acctInfo.set("masterid", kmId);//主数据内码系统不会根据id自动生成需要手动设置
//保存数据直接保存入库不走操作校验
SaveServiceHelper.save(new DynamicObject[]{acctInfo});
//处理科目使用范围
DB.update(DBRoute.of("sys"), insertSql, new Object[]{kmId,JhzjUtils.GROUPID});
}
accountMaps.put(number+companynum,acctInfo);
}
//处理科目分配
EsbUtils.handleAssign(companysJson, acctids, entityName);
//处理核算维度
JSONArray asstacttypesJson = json_obj.getJSONArray("asstacttypes");
String hsxm;//核算维度名称 基础资料

View File

@ -9,9 +9,9 @@ import java.util.List;
@ApiModel
public class AdminOrgModel 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<AdminOrgModel.EntryBean> items;
public void setBatchId(String batchId) {
this.batchId = batchId;

View File

@ -9,9 +9,9 @@ import java.util.List;
@ApiModel
public class CostCenterModel 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;
public void setBatchId(String batchId) {
this.batchId = batchId;

View File

@ -9,11 +9,11 @@ import java.util.List;
@ApiModel
public class PersonModel 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 String staffType;
@ApiParam(value="明细集合",required=true,position=3)
@ApiParam(value="明细集合",required=false,position=3)
private List<PersonModel.EntryBean> items;
public void setBatchId(String batchId) {
this.batchId = batchId;