|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
package weaver.interfaces.jclproduct;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
|
import com.engine.jclproduct.entity.bo.EmploymentRecordBo;
|
|
|
|
|
import com.engine.jclproduct.entity.po.DataDutyPo;
|
|
|
|
|
import com.engine.jclproduct.entity.po.EmploymentRecordPo;
|
|
|
|
@ -14,9 +15,9 @@ import weaver.common.DateUtil;
|
|
|
|
|
import weaver.conn.RecordSet;
|
|
|
|
|
import weaver.interfaces.schedule.BaseCronJob;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.time.LocalDate;
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Author liang.cheng
|
|
|
|
@ -56,9 +57,16 @@ public class EmploymentRecordCrob extends BaseCronJob {
|
|
|
|
|
|
|
|
|
|
//1.入转调离 人员数据变化处理
|
|
|
|
|
DataDutyPo dataDutyPo = dutyDatasChange(hrmresource);
|
|
|
|
|
hrmresourceUpdate.add(dataDutyPo.getHrmresourceUpdate());
|
|
|
|
|
hrmresourceInsert.add(dataDutyPo.getHrmresourceInsert());
|
|
|
|
|
employmentRecordInsert.addAll(dataDutyPo.getEmploymentRecordInsert());
|
|
|
|
|
if (dataDutyPo.getHrmresourceUpdate() != null) {
|
|
|
|
|
hrmresourceUpdate.add(dataDutyPo.getHrmresourceUpdate());
|
|
|
|
|
}
|
|
|
|
|
if (dataDutyPo.getHrmresourceInsert() != null) {
|
|
|
|
|
hrmresourceInsert.add(dataDutyPo.getHrmresourceInsert());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(dataDutyPo.getEmploymentRecordInsert())) {
|
|
|
|
|
employmentRecordInsert.addAll(dataDutyPo.getEmploymentRecordInsert());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -67,20 +75,38 @@ public class EmploymentRecordCrob extends BaseCronJob {
|
|
|
|
|
bb.writeLog("employmentRecordInsert:"+employmentRecordInsert.size());
|
|
|
|
|
//3.人员信息中间表
|
|
|
|
|
//更新
|
|
|
|
|
hrmresourceUpdate.forEach(e -> {
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
hrmresourceUpdate.forEach(e -> rs.executeUpdate("update uf_hrmresource_day set status=?,companystartdate=?,companyworkyear=?," +
|
|
|
|
|
" sex=?,birthday=?,jobtitle=?,departmentid=?,subcompanyid=?,managerid=? where userid=?",e.getStatus(),e.getCompanyStartDate(),
|
|
|
|
|
e.getCompanyWorkyear(),e.getSex(),e.getBirthday(),e.getJobTitle(),e.getDepartmentId(),e.getSubcompanyId(),e.getManagerId(),e.getUserId()));
|
|
|
|
|
|
|
|
|
|
//插入
|
|
|
|
|
hrmresourceInsert.forEach(e->{
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
hrmresourceInsert.forEach(e-> rs.executeUpdate("insert into uf_hrmresource_day(userId,workcode,companystartdate,companyworkyear," +
|
|
|
|
|
" birthday,jobtitle,departmentid,subcompanyid,managerid,status,sex) values(?,?,?,?,?,?,?,?,?,?,?)",e.getUserId(),e.getWorkcode(),
|
|
|
|
|
e.getCompanyStartDate(),e.getCompanyWorkyear(),e.getBirthday(),e.getJobTitle(),e.getDepartmentId(),e.getSubcompanyId(),e.getManagerId(),e.getStatus(),e.getSex()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//4.人员任职记录表
|
|
|
|
|
employmentRecordInsert.forEach(e->{
|
|
|
|
|
|
|
|
|
|
//1.更新上一条数据stopDate
|
|
|
|
|
List<EmploymentRecordPo> list = new ArrayList<>();
|
|
|
|
|
rs.executeQuery("select id,startDate from uf_EmploymentRecord where userid = ?",e.getUserId());
|
|
|
|
|
while (rs.next()) {
|
|
|
|
|
list.add(EmploymentRecordPo.builder().id(Util.getIntValue(rs.getString("id"))).startDate(Util.null2String(rs.getString("startDate"))).build());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(list)) {
|
|
|
|
|
String date = DateUtil.getCurrentDate();
|
|
|
|
|
EmploymentRecordPo latest = list.stream()
|
|
|
|
|
.max(Comparator.comparing(record -> LocalDate.parse(record.getStartDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"))))
|
|
|
|
|
.orElse(null);
|
|
|
|
|
assert latest != null;
|
|
|
|
|
if (EmploymentUtil.compareDate(latest.getStartDate())) {
|
|
|
|
|
date = DateUtil.getYesterday();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rs.executeUpdate("update uf_EmploymentRecord set stopDate = ? where id = ?",date,latest.getId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//2.新增数据
|
|
|
|
@ -147,16 +173,21 @@ public class EmploymentRecordCrob extends BaseCronJob {
|
|
|
|
|
employmentRecord.setChangeNewSuperior(hrmresource.getManagerId());
|
|
|
|
|
|
|
|
|
|
//调动
|
|
|
|
|
employmentRecord.setChangType(3);
|
|
|
|
|
|
|
|
|
|
employmentRecord.setChangType(2);
|
|
|
|
|
employmentRecords.add(employmentRecord);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//3.1 数据不一致,人员中间表更新
|
|
|
|
|
hrmresource.setId(lastResource.getId());
|
|
|
|
|
dataDutyPo.setHrmresourceUpdate(hrmresource);
|
|
|
|
|
//3.2 数据不一致,任职记录表新增
|
|
|
|
|
dataDutyPo.setEmploymentRecordInsert(employmentRecords);
|
|
|
|
|
|
|
|
|
|
if (!hrmresource.getStatus().equals(lastResource.getStatus())
|
|
|
|
|
|| !hrmresource.getDepartmentId().equals(lastResource.getDepartmentId())
|
|
|
|
|
|| !hrmresource.getJobTitle().equals(lastResource.getJobTitle())
|
|
|
|
|
|| !hrmresource.getManagerId().equals(lastResource.getManagerId())) {
|
|
|
|
|
//3.1 数据不一致,人员中间表更新
|
|
|
|
|
hrmresource.setId(lastResource.getId());
|
|
|
|
|
dataDutyPo.setHrmresourceUpdate(hrmresource);
|
|
|
|
|
//3.2 数据不一致,任职记录表新增
|
|
|
|
|
dataDutyPo.setEmploymentRecordInsert(employmentRecords);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
//4.数据不存在作新增
|
|
|
|
|