全国人民代表大会常务委员会关于实施渐进式延迟法定退休年龄的决定
/*固定日期 来自上述连接中的表格
* @Author QH
* @Description 计算延迟退休几个月 0为新的退休政策
* @Date 9:23 2024/12/17
* @Param TODO:startDate 固定日期 男1965-01-01 女1970-01-01 endDate 固定日期 男1976-12-31 女1981-12-31 targetDate:人员出生日期 tag:延期规则 每4个月延迟一个月或每2个月延迟一个月
* @return int
**/
public static int getRetireMonth2(String startDate,String endDate,String targetDate,int tag){
try {
Date startDates = DateUtils.parseDate(startDate,YYYY_MM_DD);
Date endDates = DateUtils.parseDate(targetDate,YYYY_MM_DD);
boolean b = checkBetween(startDate, endDate, targetDate);
if (b){
//计算传入的日期与startDates 相差的月数
long l = betweenMonth(startDates, endDates, false) + 1;
BigDecimal bigDecimal = new BigDecimal(l);
BigDecimal divide = bigDecimal.divide(new BigDecimal(tag), 0, ROUND_UP);
return divide.intValue();
}else {
//1977年1月开始计算的日期
return 0;
}
} catch (ParseException e) {
throw new RuntimeException(e);
}
}
/*
* @Author QH
* @Description 获取延迟退休的时间
* @Date 10:26 2024/12/17
* @Param TODO:deferMonth:延迟月份 deferYear:退休年龄 targetDate:出生日期
* @return Date
**/
public static Date getgetRetireDate(int deferMonth,int deferYear,String targetDate) throws ParseException {
LocalDate targetDates = LocalDate.parse(targetDate, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
int i = deferYear * 12;
int i1 = i + deferMonth;
String string = targetDates.plusMonths(i1).toString();
Date date = DateUtils.parseDate(string, YYYY_MM_DD);
return date;
}
/*
* @Author QH
* @Description 校验target日期 是否再startDate和endDate之间 包含关系
* @Date 10:27 2024/12/17
* @Param
* @return
**/
public static boolean checkBetween(String startDate,String endDate,String target){
LocalDate startDates = LocalDate.parse(startDate);
LocalDate endDates = LocalDate.parse(endDate);
LocalDate targetDates = LocalDate.parse(target);
boolean b = !targetDates.isBefore(startDates) && !targetDates.isAfter(endDates);
return b;
}
public static void main(String[] args) throws ParseException {
//男职工延迟法定退休年龄(每四个月延迟一个月)
int retireDate = getRetireMonth2("1965-01-01", "1976-12-31", "1965-01-04",4);
System.out.println("男:延迟月份是:"+retireDate);
//原法定退休55周岁的女职工延迟法定退休年龄(每四个月延迟一个月)
int retireDates = getRetireMonth2("1970-01-01", "1981-12-31", "1976-05-04",4);
System.out.println("女:55周岁延迟月份是s:"+retireDates);
//原法定退休50周岁的女职工延迟法定退休年龄(每两个月延迟一个月)
int retireDatesS = getRetireMonth2("1975-01-01", "1984-12-31", "1976-05-04",2);
System.out.println("女:50周岁延迟月份是ss:"+retireDatesS);
Date date = getgetRetireDate(retireDate, 60, "1965-01-04");
System.out.println("男:延迟退休时间"+parseDateToStr(YYYY_MM_DD,date));
Date dates = getgetRetireDate(retireDates, 55, "1976-05-04");
System.out.println("女:55周岁延迟退休时间"+parseDateToStr(YYYY_MM_DD,dates));
Date datess = getgetRetireDate(retireDatesS, 50, "1976-05-04");
System.out.println("女:50周岁延迟退休时间"+parseDateToStr(YYYY_MM_DD,datess));
}
原法定退休55周岁的女职工延迟法定退休年龄(每四个月延迟一个月)
我们的业务需求每个月进行一次计算
/*
* @Author QH
* @Description 定时任务-计算人员退休日期 每月1号凌晨3点执行一次 @Scheduled(cron = "0/30 * * * * ? ")
* @Date 10:28 2024/12/17
* @Param
* @return
**/
@Scheduled(cron = "0 0 3 1 * ? ")
@Async(ServerConfig.serviceName + "_threadPool")
public void getUserRetireDate() {
try {
List<EmpBasic> select = empBasicMapper.select();
List<EmpBasic> updateList = new ArrayList<>();
for (EmpBasic empBasic : select) {
Date retireDate1 = empBasic.getRetireDate();
if (ObjectUtils.isNotEmpty(retireDate1)) {
continue;
}
String birthday = empBasic.getBirthday();
String gender = empBasic.getGender();
if (StringUtils.isEmpty(birthday) || StringUtils.isEmpty(gender)){
continue;
}
String s = DateUtils.convertToDateString(birthday);
if (StringUtils.isEmpty(s)){continue;}
if(StringUtils.equals(Constants.GENDER_WOMAN,gender)){
Date retireDate = getRetireDate(Constants.WOMAN_RETIRE_START, Constants.WOMAN_RETIRE_END, s, gender);
empBasic.setRetireDate(retireDate);
}else {
Date retireDate = getRetireDate(Constants.MAN_RETIRE_START, Constants.MAN_RETIRE_END, s, gender);
empBasic.setRetireDate(retireDate);
}
updateList.add(empBasic);
}
if (updateList.size()>0){
empBasicMapper.jwInsertBatchReplace(updateList);
logger.info("[getUserRetireDate]人员退休日期计算成功!本次计算人数"+updateList.size());
}
logger.info("[getUserRetireDate]人员退休日期无需更新!");
}catch (Exception e){
logger.info("[getUserRetireDate]人员退休日期计算异常!",e.getMessage());
}
}
public Date getRetireDate(String startDate, String endDate, String targetDate,String gender) throws ParseException {
boolean b = DateUtils.checkBetween(startDate, endDate, targetDate);
if (b){
int retireMonth = getRetireMonth(startDate, endDate, targetDate);
if (retireMonth == 0){
Date date = DateUtils.getgetRetireDate(0, StringUtils.equals(Constants.GENDER_MAN,gender)?Constants.MAN_RETIRE_NEW_AGE:Constants.WOMAN_RETIRE_NEW_AGE, targetDate);
return date;
}else {
Date date = DateUtils.getgetRetireDate(retireMonth, StringUtils.equals(Constants.GENDER_MAN,gender)?Constants.MAN_RETIRE_AGE:Constants.WOMAN_RETIRE_AGE, targetDate);
return date;
}
}else {
Date date = DateUtils.getgetRetireDate(0, StringUtils.equals(Constants.GENDER_MAN,gender)?Constants.MAN_RETIRE_NEW_AGE:Constants.WOMAN_RETIRE_NEW_AGE, targetDate);
return date;
}
}