Commit 2ed8948e by 张富康

feat(perfSalary): 新增考勤数据清洗功能

- 调整考勤数据清洗定时任务执行时间为每天6点
- 实现考勤数据清洗服务,按员工手机号批量查询处理考勤记录
- 查询上月在职或当月离职的员工信息及门店考勤清单
- 在远程接口中新增考勤数据清洗的RPC方法及实现
- 为企微考勤记录模型添加迟到、早退及旷工时长字段
1 parent f853c79a
......@@ -162,6 +162,28 @@ public class StaffQwClockInInfo implements Serializable {
private String qwExceptionType;
/**
* 企微迟到时长
*/
@ApiModelProperty(notes = "企微迟到时长")
@Column(name = "qw_late_duration")
private Integer qwLateDuration;
/**
* 企微早退时长
*/
@ApiModelProperty(notes = "企微早退时长")
@Column(name = "qw_leave_early_duration")
private Integer qwLeaveEarlyDuration;
/**
* 企微旷工时长
*/
@ApiModelProperty(notes = "企微旷工时长")
@Column(name = "qw_absentee_duration")
private Integer qwAbsenteeDuration;
/**
*
*/
@ApiModelProperty(notes = "")
......@@ -198,25 +220,4 @@ public class StaffQwClockInInfo implements Serializable {
@Column(name = "deleted_flag")
private String deletedFlag;
/**
* 企微迟到时长
*/
@ApiModelProperty(notes = "企微迟到时长")
@Column(name = "qw_late_duration")
private Integer qwLateDuration;
/**
* 企微早退时长
*/
@ApiModelProperty(notes = "企微早退时长")
@Column(name = "qw_leave_early_duration")
private Integer qwLeaveEarlyDuration;
/**
* 企微旷工时长
*/
@ApiModelProperty(notes = "企微旷工时长")
@Column(name = "qw_absentee_duration")
private Integer qwAbsenteeDuration;
}
......@@ -54,4 +54,8 @@ public interface PerfRuleRemote {
*/
RpcResponse<Boolean> perfAppraisalBatchSubmit(PerfAppraisalBatchSubmitReqDTO perfAppraisalBatchSubmitReqDTO);
/**
* 考勤数据清洗
*/
RpcResponse<Boolean> attendanceDataCleansing();
}
......@@ -9,7 +9,7 @@ import org.oreframework.boot.autoconfigure.elasticjob.annotation.ElasticJobConf;
import javax.annotation.Resource;
@Slf4j
@ElasticJobConf(name = "AttendanceDataCleansing", cron = "0 6 1 * *", description = "考勤数据清洗", overwrite = false)
@ElasticJobConf(name = "AttendanceDataCleansing", cron = "0 0 6 1 * ? ", description = "考勤数据清洗", overwrite = false)
public class AttendanceDataCleansingJob implements SimpleJob {
@Resource
......
package cn.com.glsx.dj.staff.remote.perfSalary;
import cn.com.glsx.dj.staff.dto.perfSalary.*;
import cn.com.glsx.dj.staff.service.perfSalary.AttendanceDataCleansingService;
import cn.com.glsx.dj.staff.service.perfSalary.PerfRuleRemoteService;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.exception.RpcServiceException;
......@@ -16,6 +17,9 @@ public class PerfRuleRemoteImpl implements PerfRuleRemote {
@Resource
private PerfRuleRemoteService perfRuleRemoteService;
@Resource
private AttendanceDataCleansingService attendanceDataCleansingService;
/**
......@@ -104,4 +108,15 @@ public class PerfRuleRemoteImpl implements PerfRuleRemote {
public RpcResponse<Boolean> perfAppraisalBatchSubmit(PerfAppraisalBatchSubmitReqDTO perfAppraisalBatchSubmitReqDTO) {
return null;
}
/**
* 考勤数据清洗
*/
@Override
public RpcResponse<Boolean> attendanceDataCleansing() {
attendanceDataCleansingService.attendanceDataCleansing();
return RpcResponse.success(true);
}
}
package cn.com.glsx.dj.staff.service.perfSalary;
import cn.com.glsx.dj.staff.mapper.StaffBeisenBaseInfoMapper;
import cn.com.glsx.dj.staff.mapper.perfSalary.MerchantAttendanceListMapper;
import cn.com.glsx.dj.staff.mapper.perfSalary.StaffQwClockInInfoMapper;
import cn.com.glsx.dj.staff.model.StaffBeisenBaseInfo;
import cn.com.glsx.dj.staff.model.perfSalary.MerchantAttendanceList;
import cn.com.glsx.dj.staff.model.perfSalary.StaffQwClockInInfo;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;
import org.oreframework.boot.env.OrePropertyConfigurer;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
......@@ -17,25 +29,49 @@ import java.util.stream.Collectors;
@Transactional(propagation = Propagation.SUPPORTS, rollbackFor = RpcServiceException.class)
public class AttendanceDataCleansingService {
@Resource
private StaffBeisenBaseInfoMapper staffBeisenBaseInfoMapper;
@Resource
private StaffQwClockInInfoMapper staffQwClockInInfoMapper;
@Resource
private MerchantAttendanceListMapper merchantAttendanceListMapper;
// 员工批量处理大小
Integer EMPLOYEE_BATCH_SIZE = OrePropertyConfigurer.getProperty("EMPLOYEE_BATCH_SIZE", Integer.class, 50);
public void attendanceDataCleansing() {
// 查询北森全量数据
List<StaffBeisenBaseInfo> beiSenEmployeeInfos = new ArrayList<>();
beiSenEmployeeInfos.add(new StaffBeisenBaseInfo());
beiSenEmployeeInfos.add(new StaffBeisenBaseInfo());
// 查询北森全量数据 上月在职或当月离职的数据
Example staffBeisenBaseExample = new Example(StaffBeisenBaseInfo.class);
// 上个月
String lastMonth = DateUtil.format(DateUtil.offsetMonth(new Date(), -1), DatePattern.NORM_MONTH_PATTERN);
log.info("查询时间:{}", lastMonth);
String staffBeisenBaseCondition = "(DATE_FORMAT(last_work_date, '%Y-%m') = '{}' or last_work_date is null)";
staffBeisenBaseCondition = StrUtil.format(staffBeisenBaseCondition, lastMonth);
staffBeisenBaseExample.createCriteria().andEqualTo("deletedFlag", 'N').andCondition(staffBeisenBaseCondition);
List<StaffBeisenBaseInfo> staffBeiSenBaseInfos = staffBeisenBaseInfoMapper.selectByExample(staffBeisenBaseExample);
log.info("员工数据信息:{}", JSONUtil.toJsonStr(staffBeiSenBaseInfos));
// 考勤打卡门店清单
Example merchantAttendanceListExample = new Example(MerchantAttendanceList.class);
merchantAttendanceListExample.createCriteria().andEqualTo("deletedFlag", 'N');
List<MerchantAttendanceList> merchantAttendanceLists = merchantAttendanceListMapper.selectByExample(merchantAttendanceListExample);
// 对员工分批查询上月考勤信息
List<List<StaffBeisenBaseInfo>> beiSenEmployeeInfoBatches = new ArrayList<>();
for (int i = 0; i < beiSenEmployeeInfos.size(); i += EMPLOYEE_BATCH_SIZE) {
beiSenEmployeeInfoBatches.add(new ArrayList<>(beiSenEmployeeInfos.subList(
for (int i = 0; i < staffBeiSenBaseInfos.size(); i += EMPLOYEE_BATCH_SIZE) {
beiSenEmployeeInfoBatches.add(new ArrayList<>(staffBeiSenBaseInfos.subList(
i,
Math.min(i + EMPLOYEE_BATCH_SIZE, beiSenEmployeeInfos.size())
Math.min(i + EMPLOYEE_BATCH_SIZE, staffBeiSenBaseInfos.size())
)));
}
// 通过手机号查询当月考勤数据处理
for (List<StaffBeisenBaseInfo> itemList : beiSenEmployeeInfoBatches) {
List<String> mobilePhones = itemList.stream().map(StaffBeisenBaseInfo::getStaffPhone).collect(Collectors.toList());
Example staffQwClockInInfoExample = new Example(StaffQwClockInInfo.class);
String staffQwClockInInfoCondition = "(DATE_FORMAT(clock_in_date, '%Y-%m') = '{}')";
staffQwClockInInfoCondition = StrUtil.format(staffQwClockInInfoCondition, lastMonth);
staffQwClockInInfoExample.createCriteria().andIn("staffPhone", mobilePhones).andEqualTo("deletedFlag", 'N');
List<StaffQwClockInInfo> staffQwClockInInfos = staffQwClockInInfoMapper.selectByExample(staffQwClockInInfoExample);
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!