Commit c1d6f2fa by 张富康

feat(attendance): 优化考勤数据计算,区分试用期与转正工时

- 在calculateAttendanceData及相关方法增加employee参数,支持按员工信息计算
- 细化考勤统计,新增试用期工时及转正工时的累计与天数计算
- 各打卡策略中根据员工转正日期区分校正工时和试用期工时
- 在AttendanceSummary及ClockInResult中添加试用期、转正工时与出勤天数字段
- 修正考勤工时累计逻辑,优化申诉后工时处理
- 修正数据库字段mobilePhone为mobile_phone
- 新增自动绩效评估定时任务AutoPerfEvaluationJob及服务骨架代码
- 纠正PerformanceEvaluation中门店名称字段注释及类型定义
1 parent 9c09f7ed
......@@ -36,4 +36,24 @@ public class ClockInResult {
*/
private int normalClockCount;
/**
* 该月考勤统计-试用期出勤小时
*/
private BigDecimal probationHours;
/**
* 该月考勤统计-转正出勤小时
*/
private BigDecimal correctionHours;
/**
* 该月考勤统计-试用期出勤天数
*/
private BigDecimal probationDays;
/**
* 该月考勤统计-转正出勤天数
*/
private BigDecimal correctionDays;
}
\ No newline at end of file
......@@ -99,6 +99,49 @@ public class AttendanceSummary implements Serializable {
private BigDecimal lateEarlyHours;
/**
* 该月试用期工时统计(小时)
*/
@ApiModelProperty(notes = "该月试用期工时统计(小时)")
@Column(name = "probation_hours")
private BigDecimal probationHours;
/**
* 该月转正出勤工时统计(小时)
*/
@ApiModelProperty(notes = "该月转正出勤工时统计(小时)")
@Column(name = "correction_hours")
private BigDecimal correctionHours;
/**
* 该月考勤统计-试用期出勤天数
*/
@ApiModelProperty(notes = "该月试用期出勤天数")
@Column(name = "probation_days")
private BigDecimal probationDays;
/**
* 该月考勤统计-转正出勤天数
*/
@ApiModelProperty(notes = "该月转正出勤天数")
@Column(name = "correction_days")
private BigDecimal correctionDays;
/**
* 申诉后计算修改-试用期出勤天数
*/
@ApiModelProperty(notes = "申诉后计算修改-试用期出勤天数")
@Column(name = "appeal_probation_days")
private BigDecimal appealProbationDays;
/**
* 申诉后计算修改-转正出勤天数
*/
@ApiModelProperty(notes = "申诉后计算修改-转正出勤天数")
@Column(name = "appeal_correction_days")
private BigDecimal appealCorrectionDays;
/**
* 缺卡次数统计
*/
@ApiModelProperty(notes = "缺卡次数统计")
......
......@@ -193,11 +193,12 @@ public class PerformanceEvaluation implements Serializable {
private Integer isLeaving;
/**
* 门店id
* 门店名称
*/
@ApiModelProperty(notes = "门店id")
@Column(name = "merchant_id")
private Integer merchantId;
@ApiModelProperty(notes = "门店名称")
@Column(name = "merchant_name")
private Integer merchantName;
/**
* 自动绩效配置id
......
package cn.com.glsx.dj.staff.job;
import cn.com.glsx.dj.staff.service.perfSalary.AutoPerfEvaluationService;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import lombok.extern.slf4j.Slf4j;
import org.oreframework.boot.autoconfigure.elasticjob.annotation.ElasticJobConf;
import javax.annotation.Resource;
@Slf4j
@ElasticJobConf(name = "AutoPerfEvaluationJob", cron = "0 30 6 1 * ? ", description = "每月自动评绩效", overwrite = false)
public class AutoPerfEvaluationJob implements SimpleJob {
@Resource
private AutoPerfEvaluationService autoPerfEvaluationService;
@Override
public void execute(ShardingContext shardingContext) {
log.info("----------------每月自动评绩效开始-----------------");
try {
autoPerfEvaluationService.autoPerfEvaluation();
} catch (Exception e) {
log.error(e.getMessage(), e);
}
log.info("----------------每月自动评绩效结束-----------------");
}
}
......@@ -254,7 +254,7 @@ public class AttendanceDataCleansingService {
}
// 计算考勤数据
calculateAttendanceData(attendanceSummary, staffQwClockCleans, lastMonthYMD);
calculateAttendanceData(attendanceSummary, staffQwClockCleans, lastMonthYMD, employee);
return attendanceSummary;
}
......@@ -263,11 +263,18 @@ public class AttendanceDataCleansingService {
*/
private void calculateAttendanceData(AttendanceSummary attendanceSummary,
List<StaffQwClockClean> staffQwClockCleans,
DateTime lastMonthYMD) {
DateTime lastMonthYMD,
StaffBeisenBaseInfo employee) {
BigDecimal totalWorkHours;
BigDecimal lateEarlyHours = BigDecimal.ZERO;
BigDecimal lateEarlyMinutes = BigDecimal.ZERO;
BigDecimal workHours = BigDecimal.ZERO;
BigDecimal probationHours = BigDecimal.ZERO;
BigDecimal correctionHours = BigDecimal.ZERO;
BigDecimal probationDays;
BigDecimal correctionDays;
int normalClockCount = 0;
int expectedAttendanceDays = lastMonthYMD.getLastDayOfMonth() - 4;
List<Integer> merchantAttendanceListIds = new ArrayList<>();
......@@ -276,11 +283,13 @@ public class AttendanceDataCleansingService {
for (StaffQwClockClean clockInfo : staffQwClockCleans) {
try {
// 2. 处理每条考勤记录
ClockInResult result = processClockIn(clockInfo, lastMonthYMD);
ClockInResult result = processClockIn(clockInfo, lastMonthYMD, employee);
workHours = NumberUtil.add(workHours, result.getTotalWorkHours());
lateEarlyMinutes = NumberUtil.add(lateEarlyMinutes, result.getLateEarlyMinutes());
lateEarlyHours = new BigDecimal(Math.ceil(lateEarlyMinutes.doubleValue() / 30.0) * 0.5);
normalClockCount += result.getNormalClockCount();
probationHours = NumberUtil.add(probationHours, result.getProbationHours());
correctionHours = NumberUtil.add(correctionHours, result.getCorrectionHours());
if (ObjectUtil.isNotEmpty(result.getMerchantAttendanceListId())) {
merchantAttendanceListIds.add(result.getMerchantAttendanceListId());
}
......@@ -296,6 +305,24 @@ public class AttendanceDataCleansingService {
// 4. 计算总工时
totalWorkHours = NumberUtil.sub(workHours, lateEarlyHours);
attendanceSummary.setActualAttendanceDays(NumberUtil.div(totalWorkHours, 8));
// 判断 correctionHours 是否大于 lateEarlyHours
if (correctionHours.compareTo(lateEarlyHours) > 0) {
// 如果大于则减去 correctionHours = correctionHours - lateEarlyHours
correctionHours = NumberUtil.sub(correctionHours, lateEarlyHours);
correctionDays = NumberUtil.div(correctionHours, 8);
attendanceSummary.setCorrectionHours(correctionHours);
attendanceSummary.setCorrectionDays(correctionDays);
attendanceSummary.setProbationHours(probationHours);
attendanceSummary.setProbationDays(NumberUtil.div(probationHours, 8));
} else {
BigDecimal tempNum = NumberUtil.sub(lateEarlyHours, correctionHours);
probationHours = NumberUtil.sub(probationHours, tempNum);
probationDays = NumberUtil.div(probationHours, 8);
attendanceSummary.setCorrectionHours(BigDecimal.ZERO);
attendanceSummary.setCorrectionDays(BigDecimal.ZERO);
attendanceSummary.setProbationHours(probationHours);
attendanceSummary.setProbationDays(probationDays);
}
attendanceSummary.setLateEarlyMinutes(lateEarlyMinutes);
attendanceSummary.setLateEarlyHours(lateEarlyHours);
attendanceSummary.setTotalWorkHours(totalWorkHours);
......@@ -309,11 +336,10 @@ public class AttendanceDataCleansingService {
* 处理单条打卡记录
* 使用策略模式处理不同类型的打卡场景
*/
private ClockInResult processClockIn(StaffQwClockClean clockInfo,
DateTime lastMonthYMD) {
private ClockInResult processClockIn(StaffQwClockClean clockInfo, DateTime lastMonthYMD, StaffBeisenBaseInfo employee) {
// 1. 策略模式:根据是否有经纬度选择处理策略
ClockInStrategy strategy = determineClockInStrategy(clockInfo);
return strategy.process(clockInfo, lastMonthYMD);
return strategy.process(clockInfo, lastMonthYMD, employee);
}
/**
......@@ -690,7 +716,7 @@ public class AttendanceDataCleansingService {
* 打卡处理策略接口
*/
private interface ClockInStrategy {
ClockInResult process(StaffQwClockClean clockInfo, DateTime lastMonthYMD);
ClockInResult process(StaffQwClockClean clockInfo, DateTime lastMonthYMD, StaffBeisenBaseInfo employee);
}
/**
......@@ -698,23 +724,31 @@ public class AttendanceDataCleansingService {
*/
private class ClockInStrategyOne implements ClockInStrategy {
@Override
public ClockInResult process(StaffQwClockClean clockInfo, DateTime lastMonthYMD) {
public ClockInResult process(StaffQwClockClean clockInfo, DateTime lastMonthYMD, StaffBeisenBaseInfo employee) {
// 1. 获取最近的商户
MerchantAttendanceList merchant = findNearestMerchant(clockInfo.getClockInAddrLng(), clockInfo.getClockInAddrLat());
if (ObjectUtil.isEmpty(merchant)) {
// 如果没有找到最近的商户,使用默认策略
return new DefaultClockInStrategy().process(clockInfo, lastMonthYMD);
return new DefaultClockInStrategy().process(clockInfo, lastMonthYMD, employee);
}
// 2. 处理打卡时间
return processWithMerchant(clockInfo, merchant);
return processWithMerchant(clockInfo, merchant, employee);
}
private ClockInResult processWithMerchant(StaffQwClockClean clockInfo,
MerchantAttendanceList merchant) {
private ClockInResult processWithMerchant(StaffQwClockClean clockInfo, MerchantAttendanceList merchant, StaffBeisenBaseInfo employee) {
String clockInDate = clockInfo.getClockInDate();
String officialDate = employee.getOfficialDate();
// yyyy-MM-dd 比较clockInDate officialDate 日期大小 该打卡日期是否转正后
boolean isAfterOfficialDate = StrUtil.isNotBlank(officialDate) && DateUtil.compare(DateUtil.parse(clockInDate, "yyyy-MM-dd"), DateUtil.parse(officialDate, "yyyy-MM-dd")) >= 0;
BigDecimal totalWorkHours = BigDecimal.ZERO;
BigDecimal lateEarlyMinutes = BigDecimal.ZERO;
// todz
BigDecimal probationHours = BigDecimal.ZERO;
BigDecimal correctionHours = BigDecimal.ZERO;
int normalClockCount = 0;
// 使用临时变量跟踪迟到/早退
......@@ -735,6 +769,11 @@ public class AttendanceDataCleansingService {
// 在打卡时间范围内
normalClockCount++;
totalWorkHours = NumberUtil.add(totalWorkHours, new BigDecimal("4"));
if (isAfterOfficialDate) {
correctionHours = NumberUtil.add(correctionHours, new BigDecimal("4"));
} else {
probationHours = NumberUtil.add(probationHours, new BigDecimal("4"));
}
} else {
// 不在打卡时间范围内
if (timeRangeResult.getInRangeType() == 3) {
......@@ -774,6 +813,11 @@ public class AttendanceDataCleansingService {
// 在打卡时间范围内
normalClockCount++;
totalWorkHours = NumberUtil.add(totalWorkHours, new BigDecimal("4"));
if (isAfterOfficialDate) {
correctionHours = NumberUtil.add(correctionHours, new BigDecimal("4"));
} else {
probationHours = NumberUtil.add(probationHours, new BigDecimal("4"));
}
} else {
// 不在打卡时间范围内
if (ClockOutTimeRangeResult.getInRangeType() == 2) {
......@@ -807,6 +851,8 @@ public class AttendanceDataCleansingService {
clockInResult.setTotalWorkHours(totalWorkHours);
clockInResult.setLateEarlyMinutes(lateEarlyMinutes);
clockInResult.setNormalClockCount(normalClockCount);
clockInResult.setProbationHours(probationHours);
clockInResult.setCorrectionHours(correctionHours);
return clockInResult;
}
}
......@@ -817,22 +863,30 @@ public class AttendanceDataCleansingService {
*/
private class ClockInStrategyTwo implements ClockInStrategy {
@Override
public ClockInResult process(StaffQwClockClean clockInfo, DateTime lastMonthYMD) {
public ClockInResult process(StaffQwClockClean clockInfo, DateTime lastMonthYMD, StaffBeisenBaseInfo employee) {
// 1. 获取最近的商户
MerchantAttendanceList merchant = findNearestMerchant(clockInfo.getClockOutAddrLng(), clockInfo.getClockOutAddrLat());
if (ObjectUtil.isEmpty(merchant)) {
// 如果没有找到最近的商户,使用默认策略
return new DefaultClockInStrategy().process(clockInfo, lastMonthYMD);
return new DefaultClockInStrategy().process(clockInfo, lastMonthYMD, employee);
}
// 2. 处理打卡时间
return processWithTwo(clockInfo, merchant);
return processWithTwo(clockInfo, merchant, employee);
}
private ClockInResult processWithTwo(StaffQwClockClean clockInfo, MerchantAttendanceList merchant) {
private ClockInResult processWithTwo(StaffQwClockClean clockInfo, MerchantAttendanceList merchant, StaffBeisenBaseInfo employee) {
String clockInDate = clockInfo.getClockInDate();
String officialDate = employee.getOfficialDate();
BigDecimal totalWorkHours = BigDecimal.ZERO;
BigDecimal lateEarlyMinutes = BigDecimal.ZERO;
// todz
BigDecimal probationHours = BigDecimal.ZERO;
BigDecimal correctionHours = BigDecimal.ZERO;
// yyyy-MM-dd 比较clockInDate officialDate 日期大小 该打卡日期是否转正后
boolean isAfterOfficialDate = StrUtil.isNotBlank(officialDate) && DateUtil.compare(DateUtil.parse(clockInDate, "yyyy-MM-dd"), DateUtil.parse(officialDate, "yyyy-MM-dd")) >= 0;
int normalClockCount = 0;
JudgeResult timeRangeResult = TimeRangeChecker.getReasonForNotInRange(
......@@ -841,6 +895,12 @@ public class AttendanceDataCleansingService {
// 在打卡时间范围内
normalClockCount++;
totalWorkHours = NumberUtil.add(totalWorkHours, new BigDecimal("4"));
if (isAfterOfficialDate) {
correctionHours = NumberUtil.add(correctionHours, new BigDecimal("4"));
} else {
probationHours = NumberUtil.add(probationHours, new BigDecimal("4"));
}
}
// lateEarlyHours = new BigDecimal(Math.ceil(lateEarlyMinutes.doubleValue() / 30.0) * 0.5);
......@@ -849,6 +909,8 @@ public class AttendanceDataCleansingService {
clockInResult.setTotalWorkHours(totalWorkHours);
clockInResult.setLateEarlyMinutes(lateEarlyMinutes);
clockInResult.setNormalClockCount(normalClockCount);
clockInResult.setProbationHours(probationHours);
clockInResult.setCorrectionHours(correctionHours);
return clockInResult;
}
}
......@@ -858,11 +920,17 @@ public class AttendanceDataCleansingService {
*/
private class DefaultClockInStrategy implements ClockInStrategy {
@Override
public ClockInResult process(StaffQwClockClean clockInfo, DateTime lastMonthYMD) {
public ClockInResult process(StaffQwClockClean clockInfo, DateTime lastMonthYMD, StaffBeisenBaseInfo employee) {
String clockInDate = clockInfo.getClockInDate();
String officialDate = employee.getOfficialDate();
BigDecimal totalWorkHours = BigDecimal.ZERO;
BigDecimal lateEarlyMinutes = BigDecimal.ZERO;
// todz
BigDecimal probationHours = BigDecimal.ZERO;
BigDecimal correctionHours = BigDecimal.ZERO;
int normalClockCount = 0;
boolean isAfterOfficialDate = StrUtil.isNotBlank(officialDate) && DateUtil.compare(DateUtil.parse(clockInDate, "yyyy-MM-dd"), DateUtil.parse(officialDate, "yyyy-MM-dd")) >= 0;
// 使用临时变量跟踪迟到/早退
boolean isLate = false;
// 上班打卡缺卡
......@@ -902,6 +970,11 @@ public class AttendanceDataCleansingService {
// 在打卡时间范围内
normalClockCount++;
totalWorkHours = NumberUtil.add(totalWorkHours, new BigDecimal("4"));
if (isAfterOfficialDate) {
correctionHours = NumberUtil.add(correctionHours, new BigDecimal("4"));
} else {
probationHours = NumberUtil.add(probationHours, new BigDecimal("4"));
}
} else {
// 不在打卡时间范围内
if (ClockOutTimeRangeResult.getInRangeType() == 3) {
......@@ -930,6 +1003,8 @@ public class AttendanceDataCleansingService {
clockInResult.setTotalWorkHours(totalWorkHours);
clockInResult.setLateEarlyMinutes(lateEarlyMinutes);
clockInResult.setNormalClockCount(normalClockCount);
clockInResult.setProbationHours(probationHours);
clockInResult.setCorrectionHours(correctionHours);
return clockInResult;
} else {
// 判断下班打卡时间是否为空
......@@ -940,14 +1015,23 @@ public class AttendanceDataCleansingService {
if (timeRangeResult.getInRangeType() == 1) {
// 在打卡时间范围内
normalClockCount++;
totalWorkHours = NumberUtil.add(totalWorkHours, new BigDecimal("4"));
if (isAfterOfficialDate) {
correctionHours = NumberUtil.add(correctionHours, new BigDecimal("4"));
} else {
probationHours = NumberUtil.add(probationHours, new BigDecimal("4"));
}
}
}
ClockInResult clockInResult = new ClockInResult();
clockInResult.setTotalWorkHours(totalWorkHours);
clockInResult.setLateEarlyMinutes(lateEarlyMinutes);
clockInResult.setNormalClockCount(normalClockCount);
clockInResult.setProbationHours(probationHours);
clockInResult.setCorrectionHours(correctionHours);
return clockInResult;
}
ClockInResult clockInResult = new ClockInResult();
clockInResult.setTotalWorkHours(totalWorkHours);
clockInResult.setLateEarlyMinutes(lateEarlyMinutes);
clockInResult.setNormalClockCount(normalClockCount);
return clockInResult;
}
}
......
package cn.com.glsx.dj.staff.service.perfSalary;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Service
@Slf4j
public class AutoPerfEvaluationService {
/**
* 每月自动评绩效
*/
public void autoPerfEvaluation() {
}
}
......@@ -121,7 +121,7 @@
left join dj_car_life_staff_beisen_base_info sbbi on sas.mobile_phone = sbbi.staff_phone
and sbbi.deleted_flag = 'N'
where sas.deleted_flag = 'N'
and sas.mobilePhone = #{mobilePhone}
and sas.mobile_phone = #{mobilePhone}
and DATE_FORMAT(sas.attendance_month, '%Y-%m') = #{attendanceMonth}
</select>
</mapper>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!