业务单元分配部门默认设置更新接口
This commit is contained in:
parent
4647ad692a
commit
81288acce7
|
@ -0,0 +1,67 @@
|
|||
package shkd.cosmic.cxkg.task;
|
||||
|
||||
import kd.bos.context.RequestContext;
|
||||
import kd.bos.dataentity.OperateOption;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.exception.KDException;
|
||||
import kd.bos.isc.util.dt.D;
|
||||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.schedule.executor.AbstractTask;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.QueryServiceHelper;
|
||||
import kd.bos.servicehelper.operation.OperationServiceHelper;
|
||||
import kd.bos.servicehelper.org.OrgUnitServiceHelper;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 后台任务插件
|
||||
*/
|
||||
public class DefaultAdminOrgRelationTaskImpl extends AbstractTask implements Plugin {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(HrmDepartmentTaskImpl.class);
|
||||
|
||||
@Override
|
||||
public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException {
|
||||
List<Long> orgIds_query = new ArrayList<>();
|
||||
orgIds_query.add(1947801724118892544L);//1947801724118892544L
|
||||
//查询上海晨曦私募基金管理有限公司分配的行政组织集合
|
||||
List<Long> 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();
|
||||
// List<DynamicObject> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue