Commit 420772e4 authored by 赵啸非's avatar 赵啸非

添加假日数据

parent e411b7a5
......@@ -65,162 +65,12 @@ public class SyncUserTaskImpl implements ITaskExcuteService {
log.info("同步用户");
staffService.syncPersons(null);
// syncPersons();
} catch (Exception e) {
log.error("同步人事异常", e);
}
}
private void syncPersons() {
PersonReq personReq = new PersonReq();
personReq.setPageNo(1);
personReq.setPageSize(1000);
Rest<PersonDataInfo> personRest = hikPersonService.getPersonList(personReq);
if (personRest.getCode() == YesNoEnum.YES.getValue()) {
List<PersonInfo> personInfoList = personRest.getData().getList();
//做差集 更新本地用户为离职员工
StaffQuery staffQuery = new StaffQuery();
staffQuery.setSource(1);
staffQuery.setStatusNotList(Arrays.asList(StaffSatusEnum.离职.getValue()));
Map<String, StaffEntity> staffCollect = staffService.find(staffQuery).stream().collect(Collectors.toMap(x -> x.getWorkNum(), y -> y, (o, n) -> n));
for (PersonInfo personInfo : personInfoList) {
if (ObjectUtils.isEmpty(personInfo.getJobNo())) {
log.info("jobNo is null ==>{}", JSON.toJSONString(personInfo));
continue;
}
if (staffCollect.containsKey(personInfo.getJobNo())) {
staffCollect.remove(personInfo.getJobNo());
}
StaffEntity staffEntity = staffService.getExtCache(StrUtil.padPre(personInfo.getJobNo(), 8, "0"));
DeptEntity deptEntity = deptService.selectOne(new DeptQuery().deptCode(personInfo.getOrgIndexCode()));
//判断本地数据是否为空
if (ObjectUtils.isEmpty(staffEntity)) {
//新增员工信息
staffEntity = new StaffEntity();
staffEntity.initAttrValue();
if (!ObjectUtils.isEmpty(deptEntity)) {
staffEntity.setDeptId(deptEntity.getId());
}
staffEntity.setName(personInfo.getPersonName());
staffEntity.setRemarkId(personInfo.getPersonId());
staffEntity.setPicUri(personInfo.getPersonPhoto().getPicUri());
staffEntity.setServerIndexCode(personInfo.getPersonPhoto().getServerIndexCode());
staffEntity.setDeptName(personInfo.getOrgName());
staffEntity.setGender(personInfo.getGender());
staffEntity.setWorkNum(personInfo.getJobNo());
staffEntity.setPhoneNumber(personInfo.getPhoneNo());
staffEntity.setCreateUserId(1L);
staffEntity.setCreateTime(new Date());
staffService.save(staffEntity);
AttendanceVacationBalanceEntity balanceEntity = new AttendanceVacationBalanceEntity();
balanceEntity.initAttrValue();
balanceEntity.setStaffId(staffEntity.getId());
balanceEntity.setStaffName(staffEntity.getName());
balanceEntity.setDeptId(staffEntity.getDeptId());
balanceEntity.setDeptName(staffEntity.getDeptName());
balanceEntity.setCreateUserId(1L);
balanceEntity.setCreateTime(new Date());
balanceService.save(balanceEntity);
//AttendanceVacationBalanceEntity balanceEntity = balanceService.selectOne(new AttendanceVacationBalanceQuery().staffId(staffEntity.getId()));
AttendanceStatEntity attendanceStatEntity = new AttendanceStatEntity();
attendanceStatEntity.initAttrValue();
attendanceStatEntity.setStaffId(staffEntity.getId());
attendanceStatEntity.setStaffName(staffEntity.getName());
attendanceStatEntity.setDeptId(staffEntity.getDeptId());
attendanceStatEntity.setDeptName(staffEntity.getDeptName());
attendanceStatEntity.setCreateUserId(1L);
attendanceStatEntity.setCreateTime(new Date());
//21假
attendanceStatEntity.setBackToUnit(balanceEntity.getBackToUnit());
attendanceStatEntity.setOnDutyLeave(balanceEntity.getOnDutyLeave());
attendanceStatEntity.setOutOfOffice(balanceEntity.getOutOfOffice());
attendanceStatEntity.setShiftCompensation(balanceEntity.getShiftCompensation());
attendanceStatEntity.setPhysicalExamination(balanceEntity.getPhysicalExamination());
attendanceStatEntity.setQuarantine(balanceEntity.getQuarantine());
attendanceStatEntity.setBusinessTrip(balanceEntity.getBusinessTrip());
attendanceStatEntity.setPublicHoliday(balanceEntity.getPublicHoliday());
attendanceStatEntity.setSickLeave(balanceEntity.getSickLeaveDays());
attendanceStatEntity.setFuneralLeave(balanceEntity.getBereavementLeaveDays());
attendanceStatEntity.setMarriageLeave(balanceEntity.getMarriageLeaveDays());
attendanceStatEntity.setChildRearingLeave(balanceEntity.getChildRearingLeave());
attendanceStatEntity.setBreastfeedingLeaveDays(balanceEntity.getBreastfeedingLeaveDays());
attendanceStatEntity.setMenstrualLeaveDays(balanceEntity.getMenstrualLeaveDays());
attendanceStatEntity.setAnnualLeaveDays(balanceEntity.getAnnualLeaveDays());
attendanceStatEntity.setCompensatedLeaveDays(balanceEntity.getCompensatedLeaveDays());
attendanceStatEntity.setPaternityLeaveDays(balanceEntity.getPaternityLeaveDays());
attendanceStatEntity.setMaternityLeave(balanceEntity.getMaternityLeaveDays());
attendanceStatEntity.setTransferBack(balanceEntity.getTransferBack());
attendanceStatEntity.setHomeLeave(balanceEntity.getHomeLeave());
attendanceStatEntity.setPersonalLeave(balanceEntity.getPersonalLeaveDays());
attendanceStatService.save(attendanceStatEntity);
} else {
//更新
if (!ObjectUtils.isEmpty(deptEntity)) {
staffEntity.setDeptId(deptEntity.getId());
}
staffEntity.setName(personInfo.getPersonName());
staffEntity.setRemarkId(personInfo.getPersonId());
staffEntity.setPicUri(personInfo.getPersonPhoto().getPicUri());
staffEntity.setServerIndexCode(personInfo.getPersonPhoto().getServerIndexCode());
staffEntity.setDeptName(personInfo.getOrgName());
staffEntity.setGender(personInfo.getGender());
staffEntity.setWorkNum(personInfo.getJobNo());
staffEntity.setPhoneNumber(personInfo.getPhoneNo());
staffEntity.setUpdateUserId(1L);
staffEntity.setUpdateTime(new Date());
staffService.update(staffEntity);
}
}
if (staffCollect.size() > 0) {
//需要将此人员变更为离职
staffCollect.entrySet().stream().forEach(item -> {
StaffEntity staffEntity = item.getValue();
staffEntity.setStatus(StaffSatusEnum.离职.getValue());
staffEntity.setUpdateTime(new Date());
staffEntity.setUpdateUserId(1L);
staffService.update(staffEntity);
//新增离职人员
StaffLeaveEntity staffLeaveEntity = new StaffLeaveEntity();
staffLeaveEntity.initAttrValue();
staffLeaveEntity.setStaffId(staffEntity.getId());
staffLeaveEntity.setStaffName(staffEntity.getName());
staffLeaveEntity.setGender(staffEntity.getGender());
staffLeaveEntity.setBirthday(staffEntity.getBirthday());
staffLeaveEntity.setPhotoPath(staffEntity.getPhotoPath());
staffLeaveEntity.setPhoneNumber(staffEntity.getPhoneNumber());
staffLeaveEntity.setIdCard(staffEntity.getIdCard());
staffLeaveEntity.setWorkNum(staffEntity.getWorkNum());
staffLeaveEntity.setPoliticalstatus(staffEntity.getPoliticalstatus());
staffLeaveEntity.setDeptId(staffEntity.getDeptId());
staffLeaveEntity.setDeptName(staffEntity.getDeptName());
staffLeaveEntity.setJobId(staffEntity.getPositionId());
staffLeaveEntity.setJobName(staffEntity.getPositionName());
staffLeaveEntity.setStaffType(staffEntity.getStaffType());
staffLeaveEntity.setStatus(StaffSatusEnum.离职.getValue());
staffLeaveEntity.setLeaveDate(new Date());
staffLeaveEntity.setLeaveReason("");
staffLeaveEntity.setAuditStatus(AuditStatusEnum.通过.getValue());
staffLeaveEntity.setCreateUserId(1L);
staffLeaveEntity.setCreateTime(new Date());
staffLeaveService.save(staffLeaveEntity);
});
}
}
}
private void syncDepts() {
//部门同步
OrgListReq orgListReq = new OrgListReq();
......
......@@ -16,10 +16,7 @@ import com.mortals.framework.utils.poi.ExcelUtil;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.base.system.upload.service.UploadService;
import com.mortals.xhx.common.code.GoWorkResultEnum;
import com.mortals.xhx.common.code.NormalEnum;
import com.mortals.xhx.common.code.OffWorkResultEnum;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.code.*;
import com.mortals.xhx.common.keys.RedisCacheKeys;
import com.mortals.xhx.module.attendance.model.*;
import com.mortals.xhx.module.attendance.model.vo.AttendStatInfo;
......
......@@ -146,7 +146,6 @@ public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, Sta
staffQuery.setStatusNotList(Arrays.asList(StaffSatusEnum.离职.getValue()));
Map<String, StaffEntity> staffCollect = this.find(staffQuery).stream().collect(Collectors.toMap(x -> x.getWorkNum(), y -> y, (o, n) -> n));
List<PersonInfo> personInfoList = personRest.getData().getList();
for (PersonInfo personInfo : personInfoList) {
if (ObjectUtils.isEmpty(personInfo.getJobNo())) {
......@@ -155,7 +154,6 @@ public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, Sta
}
if (staffCollect.containsKey(personInfo.getJobNo())) {
staffCollect.remove(personInfo.getJobNo());
}
StaffEntity staffEntity = this.getExtCache(StrUtil.padPre(personInfo.getJobNo(), 8, "0"));
......@@ -197,12 +195,11 @@ public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, Sta
staffEntity.setUpdateTime(new Date());
this.update(staffEntity);
}
}
log.info("离职人员:size:{},==>{}",staffCollect.size(),JSON.toJSONString(staffCollect));
if (staffCollect.size() > 0) {
//需要将此人员变更为离职
staffCollect.entrySet().stream().forEach(item -> {
String key = item.getKey();
if (!ObjectUtils.isEmpty(key)) {
StaffEntity staff = item.getValue();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment