|
|
|
@ -24,20 +24,15 @@ import com.engine.organization.entity.extend.po.ExtendTitlePO;
|
|
|
|
|
import com.engine.organization.entity.job.bo.JobBO;
|
|
|
|
|
import com.engine.organization.entity.job.po.JobPO;
|
|
|
|
|
import com.engine.organization.entity.job.vo.SingleJobTreeVO;
|
|
|
|
|
import com.engine.organization.entity.map.JclOrgMap;
|
|
|
|
|
import com.engine.organization.entity.searchtree.SearchTree;
|
|
|
|
|
import com.engine.organization.entity.searchtree.SearchTreeParams;
|
|
|
|
|
import com.engine.organization.enums.LogModuleNameEnum;
|
|
|
|
|
import com.engine.organization.enums.ModuleTypeEnum;
|
|
|
|
|
import com.engine.organization.enums.OperateTypeEnum;
|
|
|
|
|
import com.engine.organization.exception.OrganizationRunTimeException;
|
|
|
|
|
import com.engine.organization.mapper.codesetting.CodeRuleMapper;
|
|
|
|
|
import com.engine.organization.mapper.comp.CompanyMapper;
|
|
|
|
|
import com.engine.organization.mapper.department.DepartmentMapper;
|
|
|
|
|
import com.engine.organization.mapper.extend.ExtDTMapper;
|
|
|
|
|
import com.engine.organization.mapper.extend.ExtMapper;
|
|
|
|
|
import com.engine.organization.mapper.extend.ExtendTitleMapper;
|
|
|
|
|
import com.engine.organization.mapper.jclorgmap.JclOrgMapper;
|
|
|
|
|
import com.engine.organization.mapper.job.JobMapper;
|
|
|
|
|
import com.engine.organization.service.DepartmentService;
|
|
|
|
|
import com.engine.organization.service.ExtService;
|
|
|
|
@ -50,7 +45,6 @@ import com.engine.organization.util.detach.DetachUtil;
|
|
|
|
|
import com.engine.organization.util.page.Column;
|
|
|
|
|
import com.engine.organization.util.page.PageInfo;
|
|
|
|
|
import com.engine.organization.util.page.PageUtil;
|
|
|
|
|
import com.engine.organization.util.relation.EcHrmRelationUtil;
|
|
|
|
|
import com.engine.organization.util.tree.SearchTreeUtil;
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
@ -173,7 +167,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
DepartmentPO departmentPO = DepartmentBO.convertParamsToPO(param, user.getUID());
|
|
|
|
|
boolean filter = isFilter(departmentPO);
|
|
|
|
|
PageInfo<DepartmentListDTO> pageInfos;
|
|
|
|
|
String orderSql = PageInfoSortUtil.getSortSql(param.getSortParams());
|
|
|
|
|
String orderSql = PageInfoSortUtil.getSortSql(param.getSortParams()," showorder ");
|
|
|
|
|
List<DepartmentPO> allList = getDepartmentMapper().listAll(orderSql);
|
|
|
|
|
new DetachUtil(user.getUID()).filterDepartmentList(allList);
|
|
|
|
|
// 通过子级遍历父级元素
|
|
|
|
@ -528,6 +522,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
deptById.setSupDepId(parentDepartmentId);
|
|
|
|
|
// 显示顺序字段
|
|
|
|
|
deptById.setShowOrder(++maxShowOrder);
|
|
|
|
|
deptById.setUuid(null);
|
|
|
|
|
|
|
|
|
|
// 新增EC表部门
|
|
|
|
|
Map<String, Object> syncMap = addEcDepartment(deptById);
|
|
|
|
@ -544,7 +539,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
if (maxJobOrder == null) {
|
|
|
|
|
maxJobOrder = 0;
|
|
|
|
|
}
|
|
|
|
|
recursionCopyJob(jobPOS, companyId, deptById.getId(), null, maxJobOrder, timeMillis);
|
|
|
|
|
recursionCopyJob(jobPOS, companyId, Integer.parseInt(ecDepartmentID), null, maxJobOrder, timeMillis);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 是否复制子部门信息
|
|
|
|
@ -553,7 +548,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
List<DepartmentPO> deptListByPId = getDepartmentMapper().getDeptListByPId(originalDeptId);
|
|
|
|
|
for (DepartmentPO departmentPO : deptListByPId) {
|
|
|
|
|
// 复制子部门信息、子部门岗位信息
|
|
|
|
|
recursionCopyDept(departmentPO.getId(), deptById.getId(), companyId, maxShowOrder, copySubJob, copySubDept, copySubJob);
|
|
|
|
|
recursionCopyDept(departmentPO.getId(), Integer.parseInt(ecDepartmentID), companyId, maxShowOrder, copySubJob, copySubDept, copySubJob);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -579,17 +574,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
// 被合并部门
|
|
|
|
|
Integer ecParamDepartment = mergeParam.getDepartment();
|
|
|
|
|
DepartmentPO targetDepartment = getDepartmentMapper().getDeptById(ecParamDepartment);
|
|
|
|
|
// map表中合并部门parentID
|
|
|
|
|
Integer oldParamDepartment = mergeParam.getId();
|
|
|
|
|
DepartmentPO oldDepartment = getDepartmentMapper().getDeptById(oldParamDepartment);
|
|
|
|
|
Integer oldFParentId = null;
|
|
|
|
|
if (null != oldDepartment) {
|
|
|
|
|
java.sql.Date currentDate = new java.sql.Date(OrganizationDateUtil.stringToDate(OrganizationDateUtil.getFormatLocalDate(new Date())).getTime());
|
|
|
|
|
JclOrgMap jclOrgMap = MapperProxyFactory.getProxy(JclOrgMapper.class).getJclOrgMapByObjID(currentDate, ModuleTypeEnum.departmentfielddefined.getValue().toString(), oldDepartment.getId().toString());
|
|
|
|
|
if (null != jclOrgMap) {
|
|
|
|
|
oldFParentId = jclOrgMap.getFParentId();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 断言判断
|
|
|
|
|
OrganizationAssert.isFalse(null == targetDepartment, "被合并部门数据有误,暂时无法合并");
|
|
|
|
@ -644,14 +629,11 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
forbiddenChildTag(targetDepartment.getSubCompanyId1(), Util.null2String(targetDepartment.getSubCompanyId1()), deptList);
|
|
|
|
|
}
|
|
|
|
|
// 原部门删除
|
|
|
|
|
DepartmentPO mergeDepartment = getDepartmentMapper().getDeptById(mergeParam.getId());
|
|
|
|
|
// DepartmentPO mergeDepartment = getDepartmentMapper().getDeptById(mergeParam.getId());
|
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
|
|
map.put("id", mergeParam.getId());
|
|
|
|
|
new OrganizationSyncEc(user, LogModuleNameEnum.DEPARTMENT, OperateTypeEnum.CANCELED, map).sync();
|
|
|
|
|
// 删除拓展表、明细表
|
|
|
|
|
MapperProxyFactory.getProxy(ExtMapper.class).deleteByID("jcl_org_deptext", mergeParam.getId());
|
|
|
|
|
MapperProxyFactory.getProxy(ExtDTMapper.class).deleteByMainID("jcl_org_deptext_dt1", mergeParam.getId(), null);
|
|
|
|
|
// TODO 删除 getDepartmentMapper().deleteByIds(DeleteParam.builder().ids(mergeParam.getId().toString()).build().getIds());
|
|
|
|
|
map.put("id", Util.null2String(mergeParam.getId()));
|
|
|
|
|
// 删除部门
|
|
|
|
|
ServiceUtil.getService(OrganizationServiceImpl.class, user).delDepartment(map, user);
|
|
|
|
|
// 更新组织架构图
|
|
|
|
|
// TODO new DepartmentTriggerRunnable(mergeDepartment).run();
|
|
|
|
|
// 更新部门合并后名称
|
|
|
|
@ -725,7 +707,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
refreshJobComp(deptById.getId(), deptById.getSubCompanyId1());
|
|
|
|
|
List<DepartmentPO> deptList = getDepartmentMapper().getDeptListByPId(deptById.getId());
|
|
|
|
|
// 更新当前部门下的人员
|
|
|
|
|
new RecordSet().executeUpdate("update hrmresource set SUBCOMPANYID1 =? where DEPARTMENTID = ?", deptById.getSubCompanyId1(), deptById.getId());
|
|
|
|
|
// new RecordSet().executeUpdate("update hrmresource set SUBCOMPANYID1 =? where DEPARTMENTID = ?", deptById.getSubCompanyId1(), deptById.getId());
|
|
|
|
|
//// 更新人员组织架构图
|
|
|
|
|
//List<Long> hrmResourceIds = getSystemDataMapper().getHrmResourceIdsByDept(deptById.getId().toString());
|
|
|
|
|
//for (Long hrmResourceId : hrmResourceIds) {
|
|
|
|
@ -747,16 +729,16 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
for (DepartmentPO departmentPO : deptList) {
|
|
|
|
|
departmentPO.setSubCompanyId1(parentComp);
|
|
|
|
|
// 更新EC表部门
|
|
|
|
|
updateEcDepartment(departmentPO);
|
|
|
|
|
updateEcDepartment(departmentPO);
|
|
|
|
|
|
|
|
|
|
// 更新组织架构图
|
|
|
|
|
// TODO new DepartmentTriggerRunnable(departmentPO.getId()).run();
|
|
|
|
|
// 刷新岗位所属分部
|
|
|
|
|
refreshJobComp(departmentPO.getId(), parentComp);
|
|
|
|
|
// 更新当前部门下的人员
|
|
|
|
|
String ecDepartmentId = EcHrmRelationUtil.getEcDepartmentId(departmentPO.getId().toString());
|
|
|
|
|
new RecordSet().executeUpdate("update hrmresource set SUBCOMPANYID1 =? where DEPARTMENTID = ?", ecCompanyId, ecDepartmentId);
|
|
|
|
|
new RecordSet().executeUpdate("update jcl_org_hrmresource set company_id =? ,ec_company = ? where department_id =?", parentComp, ecCompanyId, departmentPO.getId());
|
|
|
|
|
// String ecDepartmentId = EcHrmRelationUtil.getEcDepartmentId(departmentPO.getId().toString());
|
|
|
|
|
//new RecordSet().executeUpdate("update hrmresource set SUBCOMPANYID1 =? where DEPARTMENTID = ?", ecCompanyId, ecDepartmentId);
|
|
|
|
|
//new RecordSet().executeUpdate("update jcl_org_hrmresource set company_id =? ,ec_company = ? where department_id =?", parentComp, ecCompanyId, departmentPO.getId());
|
|
|
|
|
//List<Long> hrmResourceIds = getSystemDataMapper().getHrmResourceIdsByDept(departmentPO.getId().toString());
|
|
|
|
|
//// 更新人员组织架构图
|
|
|
|
|
//for (Long hrmResourceId : hrmResourceIds) {
|
|
|
|
@ -905,12 +887,12 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
|
|
map.put("departmentmark", departmentPO.getDepartmentMark());
|
|
|
|
|
map.put("departmentname", departmentPO.getDepartmentName());
|
|
|
|
|
map.put("subcompanyid1", departmentPO.getSubCompanyId1());
|
|
|
|
|
map.put("supdepid", departmentPO.getSupDepId());
|
|
|
|
|
map.put("showorder", departmentPO.getShowOrder());
|
|
|
|
|
map.put("subcompanyid1", Util.null2String(departmentPO.getSubCompanyId1()));
|
|
|
|
|
map.put("supdepid", Util.null2String(departmentPO.getSupDepId()));
|
|
|
|
|
map.put("showorder", Util.null2String(departmentPO.getShowOrder()));
|
|
|
|
|
map.put("departmentcode", departmentPO.getDepartmentCode());
|
|
|
|
|
map.put("coadjutant", departmentPO.getCoadjutant());
|
|
|
|
|
map.put("id", departmentPO.getId());
|
|
|
|
|
map.put("coadjutant", Util.null2String(departmentPO.getCoadjutant()));
|
|
|
|
|
map.put("id", Util.null2String(departmentPO.getId()));
|
|
|
|
|
new OrganizationSyncEc(user, LogModuleNameEnum.DEPARTMENT, OperateTypeEnum.UPDATE, map).sync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -924,9 +906,9 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
|
|
map.put("departmentmark", departmentPO.getDepartmentMark());
|
|
|
|
|
map.put("departmentname", departmentPO.getDepartmentName());
|
|
|
|
|
map.put("subcompanyid1", departmentPO.getSubCompanyId1());
|
|
|
|
|
map.put("supdepid", departmentPO.getSupDepId());
|
|
|
|
|
map.put("showorder", departmentPO.getShowOrder());
|
|
|
|
|
map.put("subcompanyid1", Util.null2String(departmentPO.getSubCompanyId1()));
|
|
|
|
|
map.put("supdepid", Util.null2String(departmentPO.getSupDepId()));
|
|
|
|
|
map.put("showorder", Util.null2String(departmentPO.getShowOrder()));
|
|
|
|
|
map.put("departmentcode", departmentPO.getDepartmentCode());
|
|
|
|
|
return new OrganizationSyncEc(user, LogModuleNameEnum.DEPARTMENT, OperateTypeEnum.ADD, map).sync();
|
|
|
|
|
}
|
|
|
|
@ -961,8 +943,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
List<JobPO> jobPOS = getJobMapper().listJobsByDepartmentId(parentDepartment);
|
|
|
|
|
jobPOS = jobPOS.stream().filter(item -> null == item.getParentJob() || 0 == item.getParentJob()).collect(Collectors.toList());
|
|
|
|
|
if (CollectionUtils.isNotEmpty(jobPOS)) {
|
|
|
|
|
String ecCompanyId = EcHrmRelationUtil.getEcCompanyId(parentComp.toString());
|
|
|
|
|
getJobMapper().updateJobCompany(jobPOS.stream().map(JobPO::getId).collect(Collectors.toList()), parentComp, ecCompanyId);
|
|
|
|
|
getJobMapper().updateJobCompany(jobPOS.stream().map(JobPO::getId).collect(Collectors.toList()), parentComp, parentComp);
|
|
|
|
|
for (JobPO jobPO : jobPOS) {
|
|
|
|
|
// 刷新组织架构图
|
|
|
|
|
new JobTriggerRunnable(jobPO.getId()).run();
|
|
|
|
|