Commit 887900f8 authored by fangxinjiang's avatar fangxinjiang

批量确认接收计算预计收集时间-fxj

parent 357e0afc
......@@ -76,6 +76,9 @@ public class EmployeeRegistrationPreVo implements Serializable {
@Schema(description = "推送时间")
private String pushDate;
//0入职日期 1 入职前第3个工作日、2 入职前第5个工作日
@Schema(description = "推送日期类型")
private String pushType;
@Schema(description = "状态,0短信待发送,1信息待填写,2信息待审核,3拒绝入职,4已完成")
private String processStatus;
......
......@@ -43,6 +43,7 @@ import com.yifu.cloud.plus.v1.yifu.common.dapr.util.*;
import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.TEmployeeInsurancePre;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.TInsuranceDetail;
import com.yifu.cloud.plus.v1.yifu.insurances.util.LocalDateUtil;
import com.yifu.cloud.plus.v1.yifu.insurances.util.ValidityUtil;
import com.yifu.cloud.plus.v1.yifu.insurances.vo.TEmployeeInsurancePreVo;
import com.yifu.cloud.plus.v1.yifu.insurances.vo.TEmployeeInsuranceSelectVo;
......@@ -2129,10 +2130,29 @@ public class EmployeeRegistrationServiceImpl extends ServiceImpl<EmployeeRegistr
preVo.setCreateName(user.getNickname());
preVo.setUpdateBy(user.getId());
preVo.setProcessStatus(status);
if (Common.isNotNull(preVo.getPushDate())) {
preVo.setExpectedCollectionTime(DateUtil.parseDate(DateUtil.dateToString(
registration.getJoinLeaveDate(), DateUtil.ISO_EXPANDED_DATE_FORMAT) + " " + preVo.getPushDate(), DateUtil.DATETIME_PATTERN_MINUTE));
// 预计收集时间为空且配置的推送时间不为空 计算预计收集时间
if (null == preVo.getExpectedCollectionTime() && Common.isNotNull(preVo.getPushDate())) {
String pushType = preVo.getPushType();
try {
// 推送日期类型:0 入职日期
if (CommonConstants.ZERO_STRING.equals(pushType)) {
preVo.setExpectedCollectionTime(DateUtil.parseDate(DateUtil.dateToString(
registration.getJoinLeaveDate(), DateUtil.ISO_EXPANDED_DATE_FORMAT) + " " + preVo.getPushDate(),
DateUtil.DATETIME_PATTERN_MINUTE));
}
// 推送日期类型:1 入职前第 3 个工作日--含入职日期;2 入职前第 5 个工作日--含入职日期
else if ((CommonConstants.ONE_STRING.equals(pushType) || CommonConstants.TWO_STRING.equals(pushType))
&& registration.getJoinLeaveDate() != null) {
int workDaysBefore = CommonConstants.ONE_STRING.equals(pushType) ? 3 : 5;
LocalDate tempDate = parseContractEndDate(registration.getJoinLeaveDate(), preVo.getPushDate());
tempDate = calculateReminderWorkDaysBefore(tempDate, workDaysBefore, 1);
preVo.setExpectedCollectionTime(DateUtil.getDateByLocalDate(tempDate));
}
} catch (Exception e){
throw new RuntimeException("预期收款日期计算失败");
}
}
//附件赋值
List<TCspAttaInfo> attaInfoList = tAttaInfoService.list(Wrappers.<TCspAttaInfo>query().lambda().eq(TCspAttaInfo::getDomainId, registration.getId()));
if (attaInfoList != null && !attaInfoList.isEmpty()) {
......@@ -2639,4 +2659,59 @@ public class EmployeeRegistrationServiceImpl extends ServiceImpl<EmployeeRegistr
}
}
/**
* 解析合同结束日期
*/
private LocalDate parseContractEndDate(Date contractEnd,String pushDate) {
try {
return LocalDateUtil.parseLocalDate(DateUtil.dateToString(contractEnd, DateUtil.ISO_EXPANDED_DATE_FORMAT) + " " + pushDate);
} catch (Exception e) {
return null;
}
}
/**
* @Author fxj
* @Description 往前找指定个工作日 含当前日期 --- 不好提炼为工具类
* @param type 0 往前 1 往后
* @Date 19:24 2026/2/26
* @return
**/
private LocalDate calculateReminderWorkDaysBefore(LocalDate lastDay,int count,int type) {
LocalDate currentDate = lastDay;
int workDayCount = 0;
// 往前找3个工作日
while (workDayCount < count) {
// 检查当前日期是否为工作日
if (isWorkDay(currentDate)) {
workDayCount++;
}
if (workDayCount == count){
return currentDate;
}
// 往前一天
currentDate = currentDate.minusDays(0==type?1:-1);
}
return currentDate;
}
/**
* 判断指定日期是否为工作日
* @param date 要检查的日期
* @return true-工作日,false-非工作日
*/
private boolean isWorkDay(LocalDate date) {
TEmployeeInsuranceWorkDayVo workDayVo = new TEmployeeInsuranceWorkDayVo();
workDayVo.setRegistDate(LocalDateTimeUtils.convertLDToDate(date));
// 使用 THolidayInfoService 的 checkIsWorkDay 方法判断是否为假期
// 如果是假期则不是工作日,否则是工作日
R<Boolean> res = socialDaprUtils.checkIsWorkDay(workDayVo);
// 添加空值检查,避免 NPE,并提高代码可读性
if (res == null || res.getData() == null) {
log.warn("checkIsWorkDay 返回结果为空,默认视为非工作日");
return false;
}
// res.getData() 为 true 表示是假期(非工作日),为 false 表示是工作日
return !res.getData();
}
}
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