You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
151 lines
6.6 KiB
Java
151 lines
6.6 KiB
Java
3 years ago
|
package com.engine.organization.thread;
|
||
|
|
||
|
import com.alibaba.fastjson.JSONObject;
|
||
|
import com.engine.organization.entity.department.po.DepartmentPO;
|
||
|
import com.engine.organization.entity.extend.param.ExtendInfoParams;
|
||
|
import com.engine.organization.entity.logview.bo.FieldBaseEquator;
|
||
|
import com.engine.organization.mapper.department.DepartmentMapper;
|
||
|
import com.engine.organization.mapper.extend.ExtMapper;
|
||
|
import com.engine.organization.mapper.trigger.CompTriggerMapper;
|
||
|
import com.engine.organization.mapper.trigger.DepartmentTriggerMapper;
|
||
|
import com.engine.organization.util.OrganizationDateUtil;
|
||
|
import com.engine.organization.util.db.MapperProxyFactory;
|
||
|
import org.apache.commons.collections.CollectionUtils;
|
||
|
import weaver.common.DateUtil;
|
||
|
import weaver.hrm.passwordprotection.domain.HrmResource;
|
||
|
|
||
|
import java.sql.Date;
|
||
|
import java.util.Calendar;
|
||
|
import java.util.HashMap;
|
||
|
import java.util.List;
|
||
|
import java.util.Map;
|
||
|
|
||
|
/**
|
||
|
* @author:dxfeng
|
||
|
* @createTime: 2022/08/30
|
||
|
* @version: 1.0
|
||
|
*/
|
||
|
public class DepartmentTriggerRunnable implements Runnable {
|
||
|
|
||
|
private final DepartmentPO oldDepartment;
|
||
|
private final DepartmentPO newDepartment;
|
||
|
|
||
|
private CompTriggerMapper getCompTriggerMapper() {
|
||
|
return MapperProxyFactory.getProxy(CompTriggerMapper.class);
|
||
|
}
|
||
|
|
||
|
private DepartmentTriggerMapper getDepartmentTriggerMapper() {
|
||
|
return MapperProxyFactory.getProxy(DepartmentTriggerMapper.class);
|
||
|
}
|
||
|
|
||
|
public DepartmentTriggerRunnable(DepartmentPO oldDepartment, DepartmentPO newDepartment) {
|
||
|
this.oldDepartment = oldDepartment;
|
||
|
this.newDepartment = newDepartment;
|
||
|
}
|
||
|
|
||
|
public DepartmentTriggerRunnable(Long departmentId) {
|
||
|
this.oldDepartment = new DepartmentPO();
|
||
|
this.newDepartment = MapperProxyFactory.getProxy(DepartmentMapper.class).getDeptById(departmentId);
|
||
|
}
|
||
|
|
||
|
public DepartmentTriggerRunnable(DepartmentPO newDepartment) {
|
||
|
this.oldDepartment = new DepartmentPO();
|
||
|
this.newDepartment = newDepartment;
|
||
|
this.newDepartment.setDeleteType(1);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void run() {
|
||
|
FieldBaseEquator fieldBaseEquator = new FieldBaseEquator();
|
||
|
List<String> diffFields = fieldBaseEquator.getDiffFieldList(oldDepartment, newDepartment);
|
||
|
if (CollectionUtils.isEmpty(diffFields)) {
|
||
|
return;
|
||
|
}
|
||
|
// 判断
|
||
|
if (diffFields.contains("deptName") || diffFields.contains("deptPrincipal") || diffFields.contains("parentComp") || diffFields.contains("parentDept") || diffFields.contains("forbiddenTag") || diffFields.contains("deleteType")) {
|
||
|
Integer fType = 2;
|
||
|
int st = 100000000;
|
||
|
// 更新逻辑
|
||
|
Integer fObjId = newDepartment.getId().intValue();
|
||
|
Integer id = newDepartment.getId().intValue() + st;
|
||
|
String uuid = newDepartment.getUuid();
|
||
|
String fNumber = newDepartment.getDeptNo();
|
||
|
String fName = newDepartment.getDeptName();
|
||
|
Integer fLeader = null == newDepartment.getDeptPrincipal() ? null : newDepartment.getDeptPrincipal().intValue();
|
||
|
Long fParentId = null == newDepartment.getParentDept() ? newDepartment.getParentComp() : newDepartment.getParentDept() + st;
|
||
|
Long fObjParentId = null == newDepartment.getParentDept() ? newDepartment.getParentComp() : newDepartment.getParentDept();
|
||
|
// delete
|
||
|
|
||
|
Integer fEcId = getDepartmentTriggerMapper().getEcDepartmentIdByUuid(uuid);
|
||
|
|
||
|
|
||
|
int fClass = 0;
|
||
|
String fClassName = "行政维度";
|
||
|
HrmResource hrmResourceById = getCompTriggerMapper().getHrmResourceById(fLeader);
|
||
|
|
||
|
String fLeaderImg = "";
|
||
|
String fLeaderName = "";
|
||
|
Integer fLeaderJobId = null;
|
||
|
if (null != hrmResourceById) {
|
||
|
fLeaderImg = hrmResourceById.getMessagerurl();
|
||
|
fLeaderName = hrmResourceById.getLastname();
|
||
|
fLeaderJobId = hrmResourceById.getJobtitle();
|
||
|
}
|
||
|
|
||
|
String fLeaderJob = getCompTriggerMapper().getJobTitleMarkById(fLeaderJobId);
|
||
|
|
||
|
JSONObject cusFieldDataById = getCompTriggerMapper().getCusFieldDataById(fLeader);
|
||
|
String fLeaderSt = "";
|
||
|
String fLeaderLv = "";
|
||
|
if (null != cusFieldDataById) {
|
||
|
fLeaderSt = cusFieldDataById.getString("field100008");
|
||
|
fLeaderLv = cusFieldDataById.getString("field100007");
|
||
|
}
|
||
|
Date fDateBegin = new Date(System.currentTimeMillis());
|
||
|
Date fDateEnd = new Date(OrganizationDateUtil.stringToDate("2099-12-31").getTime());
|
||
|
|
||
|
|
||
|
Integer fPlan = getDepartmentTriggerMapper().sumStaffNum(fDateBegin, fObjId);
|
||
|
Integer fonJob = getDepartmentTriggerMapper().countHrmResource(fEcId);
|
||
|
int fIsVitual = 0;
|
||
|
|
||
|
Calendar cal = Calendar.getInstance();
|
||
|
cal.setTime(fDateBegin);
|
||
|
Calendar calendar = DateUtil.addDay(cal, -1);
|
||
|
Date time = new Date(calendar.getTime().getTime());
|
||
|
getCompTriggerMapper().deleteMap(fType, fObjId, fDateBegin);
|
||
|
getCompTriggerMapper().updateMap(fType, fObjId, fDateBegin, time);
|
||
|
|
||
|
|
||
|
if (1 != newDepartment.getDeleteType() && 1 != newDepartment.getForbiddenTag()) {
|
||
|
Map<String, Object> params = new HashMap<>();
|
||
|
params.put("id", id);
|
||
|
params.put("ftype", fType);
|
||
|
params.put("fobjid", fObjId);
|
||
|
params.put("fecid", fEcId);
|
||
|
params.put("uuid", uuid);
|
||
|
params.put("fclass", fClass);
|
||
|
params.put("fclassname", fClassName);
|
||
|
params.put("fnumber", fNumber);
|
||
|
params.put("fname", fName);
|
||
|
params.put("fleader", fLeader);
|
||
|
params.put("fleaderimg", fLeaderImg);
|
||
|
params.put("fleadername", fLeaderName);
|
||
|
params.put("fleaderjobid", fLeaderJobId);
|
||
|
params.put("fleaderjob", fLeaderJob);
|
||
|
params.put("fleaderlv", fLeaderLv);
|
||
|
params.put("fleaderst", fLeaderSt);
|
||
|
params.put("fparentid", fParentId);
|
||
|
params.put("fobjparentid", fObjParentId);
|
||
|
params.put("fplan", null == fPlan ? 0 : fPlan);
|
||
|
params.put("fonjob", fonJob);
|
||
|
params.put("fisvitual", fIsVitual);
|
||
|
params.put("fdatebegin", fDateBegin);
|
||
|
params.put("fdateend", fDateEnd);
|
||
|
ExtendInfoParams infoParams = ExtendInfoParams.builder().tableName("jcl_org_map").params(params).build();
|
||
|
MapperProxyFactory.getProxy(ExtMapper.class).insertTable(infoParams);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|