From fbac3eb04e5b56bdadce016327c7f34288d3152f Mon Sep 17 00:00:00 2001 From: zengweihai Date: Fri, 28 Jun 2024 14:05:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=9A=E5=8A=A1=E5=8D=95=E5=85=83=E5=88=86?= =?UTF-8?q?=E9=85=8D=E9=83=A8=E9=97=A8=E6=8F=92=E4=BB=B6=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../task/DefaultAdminOrgRelationTaskImpl.java | 68 +++++++++++-------- 1 file changed, 40 insertions(+), 28 deletions(-) diff --git a/shkd-cosmic-debug/src/main/java/shkd/cosmic/cxkg/task/DefaultAdminOrgRelationTaskImpl.java b/shkd-cosmic-debug/src/main/java/shkd/cosmic/cxkg/task/DefaultAdminOrgRelationTaskImpl.java index 33f7318..cc01f85 100644 --- a/shkd-cosmic-debug/src/main/java/shkd/cosmic/cxkg/task/DefaultAdminOrgRelationTaskImpl.java +++ b/shkd-cosmic-debug/src/main/java/shkd/cosmic/cxkg/task/DefaultAdminOrgRelationTaskImpl.java @@ -14,6 +14,7 @@ import kd.bos.servicehelper.QueryServiceHelper; import kd.bos.servicehelper.operation.OperationServiceHelper; import kd.bos.servicehelper.org.OrgUnitServiceHelper; import kd.sdk.plugin.Plugin; +import kd.tmc.tm.business.validate.business.BusinessUnauditOpValidator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -32,36 +33,47 @@ public class DefaultAdminOrgRelationTaskImpl extends AbstractTask implements Plu @Override public void execute(RequestContext requestContext, Map map) throws KDException { List orgIds_query = new ArrayList<>(); - orgIds_query.add(1947801724118892544L);//1947801724118892544L - //查询上海晨曦私募基金管理有限公司分配的行政组织集合 - List adminOrgRelation = OrgUnitServiceHelper.getAdminOrgRelation(orgIds_query,true); - //查询oa同步的行政组织 - QFilter qf = new QFilter("number",QCP.not_equals,"16005873"); - qf.and("shkd_oaid",QCP.not_equals,""); - DynamicObjectCollection queryOrges = QueryServiceHelper.query("bos_adminorg", "id,number,name", qf.toArray()); - int i = 0; - OperateOption option = OperateOption.create(); + QFilter numberQF = new QFilter("number", QCP.equals, "Q-003-001"); + DynamicObject org = BusinessDataServiceHelper.loadSingle("bos_org", "id", numberQF.toArray()); + if (org != null){ + long orgID = org.getLong("id"); + orgIds_query.add(orgID); + //查询上海晨曦私募基金管理有限公司分配的行政组织集合 + List adminOrgRelation = OrgUnitServiceHelper.getAdminOrgRelation(orgIds_query,true); + //查询oa同步的行政组织 + QFilter qf = new QFilter("number",QCP.not_equals,"16005873"); + qf.and("shkd_oaid",QCP.not_equals,""); + logger.info("开始查询oa同步过来的行政组织"); + DynamicObjectCollection queryOrges = QueryServiceHelper.query("bos_adminorg", "id,number,name", qf.toArray()); + logger.info("查询的oa行政组织为:"+queryOrges.toString()); + QFilter org_typerelation_qFilter = new QFilter("number", QCP.equals, "orgunit2admin");//设置为业务单元委托行政组织 + DynamicObject typerelation_dynamicObject = BusinessDataServiceHelper.loadSingle("bos_org_typerelation", "id", org_typerelation_qFilter.toArray()); + int i = 0; + OperateOption option = OperateOption.create(); // List dys = new ArrayList<>();//设置对象集合 - for (DynamicObject queryOrg : queryOrges) { - long id = queryOrg.getLong("id"); - if (!adminOrgRelation.contains(id)){//当查询出的行政组织还没分配给该业务单元时,创建分配关系 - i++; - logger.info("第"+i+"家"+"组织:"+queryOrg.get("name")+",还未分配部门,准备分配中......"); - DynamicObject newDynamicObject = BusinessDataServiceHelper.newDynamicObject("bos_org_orgrelation_dept");//创建实体对象 - DynamicObject newOrg = BusinessDataServiceHelper.newDynamicObject("bos_org");//业务单元 - newOrg.set("id",1947801724118892544L); - DynamicObject newAdminOrg = BusinessDataServiceHelper.newDynamicObject("bos_adminorg");//行政组织 - newAdminOrg.set("id",id); - DynamicObject newOrgDuty = BusinessDataServiceHelper.newDynamicObject("bos_org_duty");//部门属性 - newOrgDuty.set("id",1L); - DynamicObject newOrgTypeRelation = BusinessDataServiceHelper.newDynamicObject("bos_org_typerelation");//协作关系类型 - newOrgTypeRelation.set("id",585511977942548480L); - newDynamicObject.set("fromorg",newOrg); - newDynamicObject.set("toorg",newAdminOrg); - newDynamicObject.set("orgduty",newOrgDuty); - newDynamicObject.set("typerelation",newOrgTypeRelation); - OperationServiceHelper.executeOperate("save", "bos_adminorg", new DynamicObject[]{newDynamicObject}, option); + for (DynamicObject queryOrg : queryOrges) { + long id = queryOrg.getLong("id"); + if (!adminOrgRelation.contains(id)){//当查询出的行政组织还没分配给该业务单元时,创建分配关系 + i++; + logger.info("第"+i+"家"+"组织:"+queryOrg.get("name")+",还未分配部门,准备分配中......"); + DynamicObject newDynamicObject = BusinessDataServiceHelper.newDynamicObject("bos_org_orgrelation_dept");//创建实体对象 + DynamicObject newOrg = BusinessDataServiceHelper.newDynamicObject("bos_org");//业务单元固定为上海晨曦私募基金管理有限公司分或编码为Q-003-001 + newOrg.set("id",orgID); + logger.info("第"+i+"次分配操作,业务单元元素为:"+newOrg.toString()); + DynamicObject newAdminOrg = BusinessDataServiceHelper.newDynamicObject("bos_adminorg");//行政组织 + newAdminOrg.set("id",id); + logger.info("第"+i+"次分配操作,行政组织元素为:"+newAdminOrg.toString()); + DynamicObject newOrgDuty = BusinessDataServiceHelper.newDynamicObject("bos_org_duty");//部门属性 + newOrgDuty.set("id",1L); + logger.info("第"+i+"次分配操作,部门属性元素为:"+newOrgDuty.toString()); + newDynamicObject.set("fromorg",newOrg); + newDynamicObject.set("toorg",newAdminOrg); + newDynamicObject.set("orgduty",newOrgDuty); + newDynamicObject.set("typerelation",typerelation_dynamicObject);//统一设置为业务单元委托行政组织 + OperationServiceHelper.executeOperate("save", "bos_org_orgrelation_dept", new DynamicObject[]{newDynamicObject}, option); + } } } + } } \ No newline at end of file