Commit 4ced80a2 authored by fangxinjiang's avatar fangxinjiang

社保公积金期缴日期计算如果是1号不再减1天-fxj

parent 31454e80
......@@ -759,13 +759,13 @@ public class TEmployeePreLogServiceImpl extends ServiceImpl<TEmployeePreLogMappe
public Date addYearsMonths(TEmployeeContractDateVo vo) {
if (vo == null || vo.getRegistDate() == null) return null;
// 转换为LocalDate(自动处理时区)
// 转换为 LocalDate(自动处理时区)
LocalDate localDate = vo.getRegistDate().toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDate();
// 添加年数和月数
if (vo.getMonthAfter() ==0 && vo.getYearAfter() ==0) {
// 转回Date类型
// 转回 Date 类型
return Date.from(localDate.atStartOfDay()
.atZone(ZoneId.systemDefault())
.toInstant());
......@@ -774,7 +774,45 @@ public class TEmployeePreLogServiceImpl extends ServiceImpl<TEmployeePreLogMappe
.plusYears(vo.getYearAfter())
.plusMonths(vo.getMonthAfter())
.minusDays(1);
// 转回Date类型
// 转回 Date 类型
return Date.from(localDate.atStartOfDay()
.atZone(ZoneId.systemDefault())
.toInstant());
}
}
/**
* @Description: 添加年数和月数,如果结果为月份 1 号则不减 1 天
* @Author: system
* @Date: 2026/03/19
* @param: vo - 包含注册日期、年数、月数的对象
* @return: java.util.Date
**/
public Date addYearsMonthsKeepFirstDay(TEmployeeContractDateVo vo) {
if (vo == null || vo.getRegistDate() == null) return null;
// 转换为 LocalDate(自动处理时区)
LocalDate localDate = vo.getRegistDate().toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDate();
// 添加年数和月数
if (vo.getMonthAfter() == 0 && vo.getYearAfter() == 0) {
// 转回 Date 类型
return Date.from(localDate.atStartOfDay()
.atZone(ZoneId.systemDefault())
.toInstant());
} else {
// 先计算加年加月后的日期
localDate = localDate
.plusYears(vo.getYearAfter())
.plusMonths(vo.getMonthAfter());
// 如果计算后的日期不是月份 1 号,则减 1 天;如果是 1 号则保持不变
if (localDate.getDayOfMonth() != 1) {
localDate = localDate.minusDays(1);
}
// 转回 Date 类型
return Date.from(localDate.atStartOfDay()
.atZone(ZoneId.systemDefault())
.toInstant());
......@@ -1139,7 +1177,7 @@ public class TEmployeePreLogServiceImpl extends ServiceImpl<TEmployeePreLogMappe
vo.setMonthAfter(Integer.parseInt(preVo.getSocialDateType()));
vo.setYearAfter(0);
vo.setRegistDate(pre.getJoinLeaveDate());
Date date = this.addYearsMonths(vo);
Date date = this.addYearsMonthsKeepFirstDay(vo);
preVo.setSocialStartDate(date);
}else {
preVo.setSocialStartDate(pre.getJoinLeaveDate());
......
......@@ -395,6 +395,19 @@ public class EmployeeRegistrationController {
return R.ok(employeeRegistrationService.addYearsMonths(vo));
}
/**
* 查询多少年多少月后对应的日期(如果日期为 1 号不做减 1 天操作)
*
* @author system
* @date 2026-03-19
**/
@Operation(summary = "查询多少年多少月后对应的日期(1 号不减 1 天)")
@SysLog("查询多少年多少月后对应的日期(1 号不减 1 天)")
@PostMapping("/addYearsMonthsKeepFirstDay")
public R addYearsMonthsKeepFirstDay(@RequestBody TEmployeeContractDateVo vo) {
return R.ok(employeeRegistrationService.addYearsMonthsKeepFirstDay(vo));
}
/**
* @param vo
* @Description: 根据项目编码查询项目信息
......
......@@ -186,6 +186,15 @@ public interface EmployeeRegistrationService extends IService<EmployeeRegistrati
Date addYearsMonths(TEmployeeContractDateVo vo);
/**
* @Description: 添加年数和月数,如果结果为月份 1 号则不减 1 天
* @Author: system
* @Date: 2026/03/19
* @param: vo - 包含注册日期、年数、月数的对象
* @return: java.util.Date
**/
Date addYearsMonthsKeepFirstDay(TEmployeeContractDateVo vo);
EkpDeptContractInfoVo selectContractInfoByDetptNo(EkpDeptContractInfoVo vo);
R refuseOffer(EmployeeRegistration employeeRegistration);
......
......@@ -958,7 +958,7 @@ public class EmployeeRegistrationServiceImpl extends ServiceImpl<EmployeeRegistr
initDate.setMonthAfter(Integer.parseInt(preVo.getFundDateType()));
initDate.setYearAfter(0);
initDate.setRegistDate(preVo.getJoinLeaveDate());
Date date = this.addYearsMonths(initDate);
Date date = this.addYearsMonthsKeepFirstDay(initDate);
preVo.setFundStartDate(date);
}
}
......@@ -1983,7 +1983,45 @@ public class EmployeeRegistrationServiceImpl extends ServiceImpl<EmployeeRegistr
.plusYears(vo.getYearAfter())
.plusMonths(vo.getMonthAfter())
.minusDays(1);
// 转回Date类型
// 转回 Date 类型
return Date.from(localDate.atStartOfDay()
.atZone(ZoneId.systemDefault())
.toInstant());
}
}
/**
* @Description: 添加年数和月数,如果结果为月份 1 号则不减 1 天
* @Author: system
* @Date: 2026/03/19
* @param: vo - 包含注册日期、年数、月数的对象
* @return: java.util.Date
**/
public Date addYearsMonthsKeepFirstDay(TEmployeeContractDateVo vo) {
if (vo == null || vo.getRegistDate() == null) return null;
// 转换为 LocalDate(自动处理时区)
LocalDate localDate = vo.getRegistDate().toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDate();
// 添加年数和月数
if (vo.getMonthAfter() == 0 && vo.getYearAfter() == 0) {
// 转回 Date 类型
return Date.from(localDate.atStartOfDay()
.atZone(ZoneId.systemDefault())
.toInstant());
} else {
// 先计算加年加月后的日期
localDate = localDate
.plusYears(vo.getYearAfter())
.plusMonths(vo.getMonthAfter());
// 如果计算后的日期不是月份 1 号,则减 1 天;如果是 1 号则保持不变
if (localDate.getDayOfMonth() != 1) {
localDate = localDate.minusDays(1);
}
// 转回 Date 类型
return Date.from(localDate.atStartOfDay()
.atZone(ZoneId.systemDefault())
.toInstant());
......@@ -2249,7 +2287,7 @@ public class EmployeeRegistrationServiceImpl extends ServiceImpl<EmployeeRegistr
vo.setMonthAfter(Integer.parseInt(preVo.getSocialDateType()));
vo.setYearAfter(0);
vo.setRegistDate(registration.getJoinLeaveDate());
Date date = this.addYearsMonths(vo);
Date date = this.addYearsMonthsKeepFirstDay(vo);
preVo.setSocialStartDate(date);
}else {
preVo.setSocialStartDate(registration.getJoinLeaveDate());
......
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