Commit 10b6d962 by 林冲

判断选中日期是否可补填日报

1 parent c4c0d184
package cn.com.glsx.dj.staff.dto.salaryappealapply;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* 日报补填校验DTO
*/
@Data
public class DailyReportFillCheckDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("补填的日期 yyyy-MM-dd")
private String fillDate;
@ApiModelProperty("员工手机号")
private String staffPhone;
@ApiModelProperty("是否超级管理员")
private Boolean isSuper;
@ApiModelProperty("登录角色")
private Integer loginRole;
}
...@@ -24,6 +24,12 @@ public class StaffSalaryAppealSummaryDTO implements Serializable { ...@@ -24,6 +24,12 @@ public class StaffSalaryAppealSummaryDTO implements Serializable {
@ApiModelProperty("实际出勤天数") @ApiModelProperty("实际出勤天数")
private BigDecimal actualAttendanceDays; private BigDecimal actualAttendanceDays;
@ApiModelProperty("是否超级管理员")
private Boolean isSuper;
@ApiModelProperty("登录角色")
private Integer loginRole;
@ApiModelProperty("日报完成天数") @ApiModelProperty("日报完成天数")
private Integer dailyReportDays; private Integer dailyReportDays;
......
package cn.com.glsx.dj.staff.remote.salaryappealapply; package cn.com.glsx.dj.staff.remote.salaryappealapply;
import cn.com.glsx.dj.staff.dto.StaffSalaryAppealApplyRecordDTO; import cn.com.glsx.dj.staff.dto.StaffSalaryAppealApplyRecordDTO;
import cn.com.glsx.dj.staff.dto.salaryappealapply.DailyReportFillCheckDTO;
import cn.com.glsx.dj.staff.dto.salaryappealapply.StaffSalaryAppealOrderStatDTO; import cn.com.glsx.dj.staff.dto.salaryappealapply.StaffSalaryAppealOrderStatDTO;
import cn.com.glsx.dj.staff.dto.salaryappealapply.StaffSalaryAppealSummaryDTO; import cn.com.glsx.dj.staff.dto.salaryappealapply.StaffSalaryAppealSummaryDTO;
import cn.com.glsx.framework.core.annotation.ApiService; import cn.com.glsx.framework.core.annotation.ApiService;
...@@ -56,4 +57,9 @@ public interface StaffSalaryAppealApplyRecordRemote { ...@@ -56,4 +57,9 @@ public interface StaffSalaryAppealApplyRecordRemote {
* 查询员工工资申诉订单统计 * 查询员工工资申诉订单统计
*/ */
RpcResponse<StaffSalaryAppealOrderStatDTO> orderStatistics(StaffSalaryAppealOrderStatDTO dto); RpcResponse<StaffSalaryAppealOrderStatDTO> orderStatistics(StaffSalaryAppealOrderStatDTO dto);
/**
* 判断选中日期是否可补填日报
*/
RpcResponse<Boolean> isDailyReportFillAllowed(DailyReportFillCheckDTO dto);
} }
package cn.com.glsx.dj.staff.remote.salaryappealapply; package cn.com.glsx.dj.staff.remote.salaryappealapply;
import cn.com.glsx.dj.staff.dto.StaffSalaryAppealApplyRecordDTO; import cn.com.glsx.dj.staff.dto.StaffSalaryAppealApplyRecordDTO;
import cn.com.glsx.dj.staff.dto.salaryappealapply.DailyReportFillCheckDTO;
import cn.com.glsx.dj.staff.dto.salaryappealapply.StaffSalaryAppealOrderStatDTO; import cn.com.glsx.dj.staff.dto.salaryappealapply.StaffSalaryAppealOrderStatDTO;
import cn.com.glsx.dj.staff.dto.salaryappealapply.StaffSalaryAppealSummaryDTO; import cn.com.glsx.dj.staff.dto.salaryappealapply.StaffSalaryAppealSummaryDTO;
import cn.com.glsx.dj.staff.service.StaffSalaryAppealApplyRecordService; import cn.com.glsx.dj.staff.service.StaffSalaryAppealApplyRecordService;
...@@ -131,4 +132,16 @@ public class StaffSalaryAppealApplyRecordRemoteImpl implements StaffSalaryAppeal ...@@ -131,4 +132,16 @@ public class StaffSalaryAppealApplyRecordRemoteImpl implements StaffSalaryAppeal
return RpcResponse.error(e); return RpcResponse.error(e);
} }
} }
@Override
public RpcResponse<Boolean> isDailyReportFillAllowed(DailyReportFillCheckDTO dto) {
try {
log.info("isDailyReportFillAllowed start, dto:{}", dto);
Boolean result = staffSalaryAppealApplyRecordService.isDailyReportFillAllowed(dto);
return RpcResponse.success(result);
} catch (Exception e) {
log.error(e.getMessage(),e);
return RpcResponse.error(e);
}
}
} }
...@@ -9,6 +9,7 @@ import cn.com.glsx.dj.staff.dto.MerchantInfo; ...@@ -9,6 +9,7 @@ import cn.com.glsx.dj.staff.dto.MerchantInfo;
import cn.com.glsx.dj.staff.dto.SalaryAppealApplyAttachmentDTO; import cn.com.glsx.dj.staff.dto.SalaryAppealApplyAttachmentDTO;
import cn.com.glsx.dj.staff.dto.StaffSalaryAppealApplyRecordDTO; import cn.com.glsx.dj.staff.dto.StaffSalaryAppealApplyRecordDTO;
import cn.com.glsx.dj.staff.dto.performance.PerformanceTimeCycleDTO; import cn.com.glsx.dj.staff.dto.performance.PerformanceTimeCycleDTO;
import cn.com.glsx.dj.staff.dto.salaryappealapply.DailyReportFillCheckDTO;
import cn.com.glsx.dj.staff.dto.salaryappealapply.StaffSalaryAppealOrderStatDTO; import cn.com.glsx.dj.staff.dto.salaryappealapply.StaffSalaryAppealOrderStatDTO;
import cn.com.glsx.dj.staff.dto.salaryappealapply.StaffSalaryAppealSummaryDTO; import cn.com.glsx.dj.staff.dto.salaryappealapply.StaffSalaryAppealSummaryDTO;
import cn.com.glsx.dj.staff.enums.PerformanceTimeCycleCodeEnum; import cn.com.glsx.dj.staff.enums.PerformanceTimeCycleCodeEnum;
...@@ -496,11 +497,25 @@ public class StaffSalaryAppealApplyRecordService { ...@@ -496,11 +497,25 @@ public class StaffSalaryAppealApplyRecordService {
} }
// 5. 判断可申诉(T3申诉,只允许申诉上个月的)、补日报日期(T1-T5可补,也只能补上个月的) // 5. 判断可申诉(T3申诉,只允许申诉上个月的)、补日报日期(T1-T5可补,也只能补上个月的)
setAppealAvailability(dto, result, appealMonth);
log.info("summary end, result:{}", result);
return result;
}
private void setAppealAvailability(StaffSalaryAppealSummaryDTO dto, StaffSalaryAppealSummaryDTO result, String appealMonth) {
if (dto.getIsSuper() != null && dto.getIsSuper() || Objects.equals(dto.getLoginRole(), 3)) {
result.setAttendanceAppealable(false);
result.setPadAppealable(false);
result.setDailyReportable(false);
return;
}
// 获取上个月月份字符串 // 获取上个月月份字符串
String lastMonth = DateUtils.getLastMonthString(new Date()); String lastMonth = DateUtils.getLastMonthString(new Date());
// 判断appealMonth是否等于上个月 // 判断appealMonth是否等于上个月
boolean isLastMonth = Objects.equals(appealMonth, lastMonth); boolean isLastMonth = Objects.equals(appealMonth, lastMonth);
// 获取T3时间配置(考勤申诉周期) // 获取T3时间配置(考勤申诉周期)
PerformanceTimeCycleDTO t3Cycle = PerformanceTimeCycleDTO t3Cycle =
performanceTimeCycleService.selectByCode(PerformanceTimeCycleCodeEnum.T3.getCode()); performanceTimeCycleService.selectByCode(PerformanceTimeCycleCodeEnum.T3.getCode());
...@@ -545,8 +560,6 @@ public class StaffSalaryAppealApplyRecordService { ...@@ -545,8 +560,6 @@ public class StaffSalaryAppealApplyRecordService {
result.setAppealStartTime(sdf.format(t3Cycle.getStartDate())); result.setAppealStartTime(sdf.format(t3Cycle.getStartDate()));
result.setAppealEndTime(sdf.format(t3Cycle.getEndDate())); result.setAppealEndTime(sdf.format(t3Cycle.getEndDate()));
} }
log.info("summary end, result:{}", result);
return result;
} }
private StaffMonthBdmCount getStaffMonthBdmCount(String staffPhone, String appealMonth) { private StaffMonthBdmCount getStaffMonthBdmCount(String staffPhone, String appealMonth) {
...@@ -653,4 +666,73 @@ public class StaffSalaryAppealApplyRecordService { ...@@ -653,4 +666,73 @@ public class StaffSalaryAppealApplyRecordService {
throw new RpcServiceException(RpcErrorEnum.DATA_INVALID_WITH_SPECIFIC_MSG, "申请月份格式错误"); throw new RpcServiceException(RpcErrorEnum.DATA_INVALID_WITH_SPECIFIC_MSG, "申请月份格式错误");
} }
} }
/**
* 判断选中日期是否可补填日报
* @param dto 包含补填日期、员工信息等
* @return true-可以补填,false-不可以补填
*/
public Boolean isDailyReportFillAllowed(DailyReportFillCheckDTO dto) {
log.info("isDailyReportFillAllowed start, dto:{}", dto);
// 1. 校验参数
if (dto == null || dto.getFillDate() == null) {
log.error("参数不能为空");
return false;
}
// 2. 超级管理员和角色3不允许补填日报
if (dto.getIsSuper() != null && dto.getIsSuper() || Objects.equals(dto.getLoginRole(), 3)) {
log.info("超级管理员或角色3不允许补填日报");
return false;
}
try {
// 3. 解析补填日期,获取所属月份 yyyy-MM
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date fillDate = sdf.parse(dto.getFillDate());
SimpleDateFormat monthFormat = new SimpleDateFormat("yyyy-MM");
String fillMonth = monthFormat.format(fillDate);
// 4. 获取上个月月份字符串
String lastMonth = DateUtils.getLastMonthString(new Date());
// 5. 判断fillMonth是否等于上个月
boolean isLastMonth = Objects.equals(fillMonth, lastMonth);
if (!isLastMonth) {
log.info("补填日期{}不是上个月,不允许补填", dto.getFillDate());
return false;
}
// 6. 检查是否在T1到T5的任意一个周期内
String[] tCodes = {
PerformanceTimeCycleCodeEnum.T1.getCode(),
PerformanceTimeCycleCodeEnum.T2.getCode(),
PerformanceTimeCycleCodeEnum.T3.getCode(),
PerformanceTimeCycleCodeEnum.T4.getCode(),
PerformanceTimeCycleCodeEnum.T5.getCode()
};
Date now = new Date();
Map<String, PerformanceTimeCycleDTO> cycleMap = performanceTimeCycleService.list().stream()
.collect(Collectors.toMap(PerformanceTimeCycleDTO::getCycleCode, Function.identity()));
for (String tCode : tCodes) {
PerformanceTimeCycleDTO cycle = cycleMap.get(tCode);
if (cycle != null && cycle.getStartDate() != null && cycle.getEndDate() != null) {
if (!now.before(cycle.getStartDate()) && !now.after(cycle.getEndDate())) {
log.info("当前时间在{}周期内,允许补填日报", tCode);
return true;
}
}
}
log.info("当前时间不在T1-T5周期内,不允许补填日报");
return false;
} catch (ParseException e) {
log.error("日期格式解析异常,fillDate:{}", dto.getFillDate(), e);
return false;
}
}
} }
\ No newline at end of file \ 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!