组织架构图编制、在岗数据刷新
parent
c3e73c2b44
commit
ab61cde4a7
@ -0,0 +1,63 @@
|
||||
<%@ page import="com.engine.organization.thread.CompanyTriggerRunnable" %>
|
||||
<%@ page import="com.engine.organization.thread.DepartmentTriggerRunnable" %>
|
||||
<%@ page import="com.engine.organization.thread.JobTriggerRunnable" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="java.util.HashSet" %>
|
||||
<%@ page import="java.util.Set" %>
|
||||
<%@ page import="com.engine.organization.util.db.MapperProxyFactory" %>
|
||||
<%@ page import="com.engine.organization.mapper.job.JobMapper" %>
|
||||
<%@ page import="com.engine.organization.entity.job.po.JobPO" %>
|
||||
<%@ page import="com.engine.organization.entity.department.po.DepartmentPO" %>
|
||||
<%@ page import="com.engine.organization.mapper.department.DepartmentMapper" %>
|
||||
<%@ page import="com.engine.organization.mapper.comp.CompMapper" %>
|
||||
<%@ page import="com.engine.organization.entity.company.po.CompPO" %>
|
||||
<%@ page import="com.engine.organization.initdata.RefreshPlan" %>
|
||||
<%@ page contentType="text/html; charset=UTF-8" %>
|
||||
<%
|
||||
RecordSet rs = new RecordSet();
|
||||
// 刷新岗位
|
||||
Set<Long> jobSet = new HashSet<>();
|
||||
Set<Long> departmentSet = new HashSet<>();
|
||||
Set<Long> companySet = new HashSet<>();
|
||||
rs.executeQuery("select id, parent_job from jcl_org_job where id not in( select ifnull(parent_job, '') from jcl_org_job where delete_type =0) and delete_type =0");
|
||||
while (rs.next()) {
|
||||
Long jobId = Long.parseLong(Util.null2String(rs.getString("id")));
|
||||
JobPO jobPO = MapperProxyFactory.getProxy(JobMapper.class).getJobById(jobId);
|
||||
RefreshPlan.updateResourceJob(jobId);
|
||||
new JobTriggerRunnable(jobPO, jobPO).run();
|
||||
|
||||
String parentJobId = Util.null2String(rs.getString("parent_job"));
|
||||
if (StringUtils.isNotBlank(parentJobId)) {
|
||||
RefreshPlan.refreshJob(Long.parseLong(parentJobId), jobSet);
|
||||
}
|
||||
}
|
||||
// 刷新部门
|
||||
rs.executeQuery("select id, parent_dept from jcl_org_dept where id not in( select ifnull(parent_dept , '') from jcl_org_dept where delete_type =0) and delete_type =0");
|
||||
while (rs.next()) {
|
||||
Long departmentId = Long.parseLong(Util.null2String(rs.getString("id")));
|
||||
DepartmentPO deptById = MapperProxyFactory.getProxy(DepartmentMapper.class).getDeptById(departmentId);
|
||||
new DepartmentTriggerRunnable(deptById, deptById).run();
|
||||
|
||||
String parentDepartmentId = Util.null2String(rs.getString("parent_dept"));
|
||||
if (StringUtils.isNotBlank(parentDepartmentId)) {
|
||||
RefreshPlan.refreshDepartment(Long.parseLong(parentDepartmentId), departmentSet);
|
||||
}
|
||||
}
|
||||
|
||||
// 刷新分部
|
||||
rs.executeQuery("select id, parent_company from jcl_org_comp where id not in( select ifnull(parent_company , '') from jcl_org_comp where delete_type =0) and delete_type =0");
|
||||
while (rs.next()) {
|
||||
Long companyId = Long.parseLong(Util.null2String(rs.getString("id")));
|
||||
CompPO compPO = MapperProxyFactory.getProxy(CompMapper.class).listById(companyId);
|
||||
new CompanyTriggerRunnable(compPO, compPO).run();
|
||||
|
||||
String parentCompanyId = Util.null2String(rs.getString("parent_company"));
|
||||
if (StringUtils.isNotBlank(parentCompanyId)) {
|
||||
RefreshPlan.refreshCompany(Long.parseLong(parentCompanyId), companySet);
|
||||
}
|
||||
}
|
||||
out.println("数据刷新完成");
|
||||
|
||||
%>
|
@ -0,0 +1,87 @@
|
||||
package com.engine.organization.initdata;
|
||||
|
||||
import com.engine.organization.entity.company.po.CompPO;
|
||||
import com.engine.organization.entity.department.po.DepartmentPO;
|
||||
import com.engine.organization.entity.job.po.JobPO;
|
||||
import com.engine.organization.mapper.comp.CompMapper;
|
||||
import com.engine.organization.mapper.department.DepartmentMapper;
|
||||
import com.engine.organization.mapper.job.JobMapper;
|
||||
import com.engine.organization.thread.CompanyTriggerRunnable;
|
||||
import com.engine.organization.thread.DepartmentTriggerRunnable;
|
||||
import com.engine.organization.thread.HrmResourceTriggerRunnable;
|
||||
import com.engine.organization.thread.JobTriggerRunnable;
|
||||
import com.engine.organization.util.db.MapperProxyFactory;
|
||||
import weaver.conn.RecordSet;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
* @createTime: 2022/11/07
|
||||
* @version: 1.0
|
||||
*/
|
||||
public class RefreshPlan {
|
||||
|
||||
private static JobMapper getJobMapper() {
|
||||
return MapperProxyFactory.getProxy(JobMapper.class);
|
||||
}
|
||||
|
||||
private static CompMapper getCompMapper() {
|
||||
return MapperProxyFactory.getProxy(CompMapper.class);
|
||||
}
|
||||
|
||||
private static DepartmentMapper getDepartmentMapper() {
|
||||
return MapperProxyFactory.getProxy(DepartmentMapper.class);
|
||||
}
|
||||
|
||||
// 递归刷新岗位
|
||||
public static void refreshJob(Long parentJobId, Set<Long> jobSet) {
|
||||
if (null == parentJobId || jobSet.contains(parentJobId)) {
|
||||
return;
|
||||
}
|
||||
// 获取父级岗位、同步数据
|
||||
JobPO jobById = getJobMapper().getJobById(parentJobId);
|
||||
if (null != jobById) {
|
||||
updateResourceJob(parentJobId);
|
||||
new JobTriggerRunnable(jobById, jobById).run();
|
||||
refreshJob(jobById.getParentJob(), jobSet);
|
||||
}
|
||||
jobSet.add(parentJobId);
|
||||
}
|
||||
|
||||
// 递归刷新部门
|
||||
public static void refreshDepartment(Long parentDepartmentId, Set<Long> departmentSet) {
|
||||
if (null == parentDepartmentId || departmentSet.contains(parentDepartmentId)) {
|
||||
return;
|
||||
}
|
||||
// 获取父级岗位、同步数据
|
||||
DepartmentPO deptById = getDepartmentMapper().getDeptById(parentDepartmentId);
|
||||
if (null != deptById) {
|
||||
new DepartmentTriggerRunnable(deptById, deptById).run();
|
||||
refreshDepartment(deptById.getParentDept(), departmentSet);
|
||||
}
|
||||
departmentSet.add(parentDepartmentId);
|
||||
}
|
||||
|
||||
public static void refreshCompany(Long parentCompanyId, Set<Long> companySet) {
|
||||
if (null == parentCompanyId || companySet.contains(parentCompanyId)) {
|
||||
return;
|
||||
}
|
||||
// 获取父级分部、同步数据
|
||||
CompPO compPO = getCompMapper().listById(parentCompanyId);
|
||||
if (null != compPO) {
|
||||
new CompanyTriggerRunnable(compPO, compPO).run();
|
||||
refreshCompany(compPO.getParentCompany(), companySet);
|
||||
}
|
||||
companySet.add(parentCompanyId);
|
||||
}
|
||||
|
||||
public static void updateResourceJob(Long jobId) {
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeQuery("select id from cus_fielddata where scope = 'hrmcustomfieldbyinfotype' and scopeid = -1 and field100002 = ?", jobId);
|
||||
while (rs.next()) {
|
||||
Long resourceId = Long.parseLong(rs.getString("id"));
|
||||
new HrmResourceTriggerRunnable(resourceId).run();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue