Commit 01ce233f authored by hongguangwu's avatar hongguangwu

每个险种一个起缴时间

parent 5ce087f7
......@@ -26,15 +26,12 @@ import com.yifu.cloud.plus.v1.yifu.common.security.annotation.Inner;
import com.yifu.cloud.plus.v1.yifu.social.entity.TForecastLibrary;
import com.yifu.cloud.plus.v1.yifu.social.service.TForecastLibraryService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
......@@ -47,7 +44,6 @@ import java.util.List;
@RequiredArgsConstructor
@RequestMapping("/tforecastlibrary")
@Tag(name = "预估费用管理")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class TForecastLibraryController {
private final TForecastLibraryService tForecastLibraryService;
......
......@@ -777,11 +777,11 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
private void initLibrayOfPersonal(TForecastLibrary library, TSocialFundInfo socialInfo
, SysBaseSetInfo sysBaseSetInfo, TForecastLibrary historyLibrary) {
// 个人养老基数
BigDecimal personalPersionBase = BigDecimal.ZERO;
BigDecimal personalPersionBase;
// 个人医疗基数
BigDecimal personalMedicalBase = BigDecimal.ZERO;
BigDecimal personalMedicalBase;
// 个人失业基数
BigDecimal personalUnemploymentBase = BigDecimal.ZERO;
BigDecimal personalUnemploymentBase;
// 个人养老比例
BigDecimal personalPersionPro = BigDecimal.ZERO;
// 个人医疗比例
......@@ -822,40 +822,47 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
personalMedicalPro = socialInfo.getPersonalMedicalPer();
personalUnemploymentPro = socialInfo.getPersonalUnemploymentPer();
}
personalPersionMoney = BigDecimalUtils.safeMultiply(personalPersionBase, personalPersionPro,
CommonConstants.ONE_OF_PERCENT);
personalMedicalMoney = BigDecimalUtils.safeMultiply(personalMedicalBase, personalMedicalPro,
CommonConstants.ONE_OF_PERCENT);
personalUnemploymentMoney = BigDecimalUtils.safeMultiply(personalUnemploymentBase, personalUnemploymentPro,
CommonConstants.ONE_OF_PERCENT);
if (library.getSocialPayMonth() != null) {
int libraryPayMonth = Integer.parseInt(library.getSocialPayMonth());
if (socialInfo.getPensionStart() != null && libraryPayMonth >= DateUtil.formatDateInt(socialInfo.getPensionStart())) {
library.setPersonalPensionBase(personalPersionBase);
library.setPersonalPersionPro(personalPersionPro);
library.setPersonalPensionFee(personalPersionMoney);
}
if (socialInfo.getMedicalStart() != null && libraryPayMonth >= DateUtil.formatDateInt(socialInfo.getMedicalStart())) {
library.setPersonalMedicalBase(personalMedicalBase);
library.setPersonalMedicalPro(personalMedicalPro);
library.setPersonalMedicalFee(personalMedicalMoney);
}
if (socialInfo.getUnemployStart() != null && libraryPayMonth >= DateUtil.formatDateInt(socialInfo.getUnemployStart())) {
library.setPersonalUnemploymentBase(personalUnemploymentBase);
library.setPersonalUnemploymentPro(personalUnemploymentPro);
library.setPersonalUnemploymentFee(personalUnemploymentMoney);
}
}
}
personalPersionMoney = BigDecimalUtils.safeMultiply(personalPersionBase, personalPersionPro,
CommonConstants.ONE_OF_PERCENT);
personalMedicalMoney = BigDecimalUtils.safeMultiply(personalMedicalBase, personalMedicalPro,
CommonConstants.ONE_OF_PERCENT);
personalUnemploymentMoney = BigDecimalUtils.safeMultiply(personalUnemploymentBase, personalUnemploymentPro,
CommonConstants.ONE_OF_PERCENT);
library.setPersonalPensionBase(personalPersionBase);
library.setPersonalMedicalBase(personalMedicalBase);
library.setPersonalUnemploymentBase(personalUnemploymentBase);
library.setPersonalPersionPro(personalPersionPro);
library.setPersonalMedicalPro(personalMedicalPro);
library.setPersonalUnemploymentPro(personalUnemploymentPro);
library.setPersonalMedicalFee(personalMedicalMoney);
library.setPersonalPensionFee(personalPersionMoney);
library.setPersonalUnemploymentFee(personalUnemploymentMoney);
}
private void initLibraryOfUnit(TForecastLibrary library, TSocialFundInfo socialInfo
, SysBaseSetInfo sysBaseSetInfo, TForecastLibrary historyLibrary) {
// 单位养老基数
BigDecimal unitPersionBase = BigDecimal.ZERO;
BigDecimal unitPersionBase;
// 单位医疗基数
BigDecimal unitMedicalBase = BigDecimal.ZERO;
BigDecimal unitMedicalBase;
// 单位失业基数
BigDecimal unitUnemploymentBase = BigDecimal.ZERO;
BigDecimal unitUnemploymentBase;
// 单位工伤基数
BigDecimal unitInjuryBase = BigDecimal.ZERO;
BigDecimal unitInjuryBase;
// 单位生育基数
BigDecimal unitBirthBase = BigDecimal.ZERO;
BigDecimal unitBirthBase;
// 单位养老比例
BigDecimal unitPersionPro = BigDecimal.ZERO;
......@@ -918,36 +925,46 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
unitInjuryPro = socialInfo.getUnitWorkUnjuryPer();
unitBirthPro = socialInfo.getUnitBirthPer();
}
unitPersionMoney = BigDecimalUtils.safeMultiply(unitPersionBase, unitPersionPro,
CommonConstants.ONE_OF_PERCENT);
unitMedicalMoney = BigDecimalUtils.safeMultiply(unitMedicalBase, unitMedicalPro,
CommonConstants.ONE_OF_PERCENT);
unitUnemploymentMoney = BigDecimalUtils.safeMultiply(unitUnemploymentBase, unitUnemploymentPro,
CommonConstants.ONE_OF_PERCENT);
unitInjuryMoney = BigDecimalUtils.safeMultiply(unitInjuryBase, unitInjuryPro,
CommonConstants.ONE_OF_PERCENT);
unitBirthMoney = BigDecimalUtils.safeMultiply(unitBirthBase, unitBirthPro,
CommonConstants.ONE_OF_PERCENT);
if (library.getSocialPayMonth() != null) {
int libraryPayMonth = Integer.parseInt(library.getSocialPayMonth());
if (socialInfo.getPensionStart() != null && libraryPayMonth >= DateUtil.formatDateInt(socialInfo.getPensionStart())) {
library.setUnitPensionBase(unitPersionBase);
library.setUnitPersionPro(unitPersionPro);
library.setUnitPensionFee(unitPersionMoney);
}
if (socialInfo.getMedicalStart() != null && libraryPayMonth >= DateUtil.formatDateInt(socialInfo.getMedicalStart())) {
library.setUnitMedicalBase(unitMedicalBase);
library.setUnitMedicalPro(unitMedicalPro);
library.setUnitMedicalFee(unitMedicalMoney);
}
if (socialInfo.getUnemployStart() != null && libraryPayMonth >= DateUtil.formatDateInt(socialInfo.getUnemployStart())) {
library.setUnitUnemploymentBase(unitUnemploymentBase);
library.setUnitUnemploymentPro(unitUnemploymentPro);
library.setUnitUnemploymentFee(unitUnemploymentMoney);
}
if (socialInfo.getWorkInjuryStart() != null && libraryPayMonth >= DateUtil.formatDateInt(socialInfo.getWorkInjuryStart())) {
library.setUnitInjuryBase(unitInjuryBase);
library.setUnitInjuryPro(unitInjuryPro);
library.setUnitWorkInjuryFee(unitInjuryMoney);
}
if (socialInfo.getBirthStart() != null && libraryPayMonth >= DateUtil.formatDateInt(socialInfo.getBirthStart())) {
library.setUnitBirthBase(unitBirthBase);
library.setUnitBirthPro(unitBirthPro);
library.setUnitBirthFee(unitBirthMoney);
}
}
}
unitPersionMoney = BigDecimalUtils.safeMultiply(unitPersionBase, unitPersionPro,
CommonConstants.ONE_OF_PERCENT);
unitMedicalMoney = BigDecimalUtils.safeMultiply(unitMedicalBase, unitMedicalPro,
CommonConstants.ONE_OF_PERCENT);
unitUnemploymentMoney = BigDecimalUtils.safeMultiply(unitUnemploymentBase, unitUnemploymentPro,
CommonConstants.ONE_OF_PERCENT);
unitInjuryMoney = BigDecimalUtils.safeMultiply(unitInjuryBase, unitInjuryPro,
CommonConstants.ONE_OF_PERCENT);
unitBirthMoney = BigDecimalUtils.safeMultiply(unitBirthBase, unitBirthPro,
CommonConstants.ONE_OF_PERCENT);
library.setUnitPensionBase(unitPersionBase);
library.setUnitMedicalBase(unitMedicalBase);
library.setUnitUnemploymentBase(unitUnemploymentBase);
library.setUnitInjuryBase(unitInjuryBase);
library.setUnitBirthBase(unitBirthBase);
library.setUnitPersionPro(unitPersionPro);
library.setUnitMedicalPro(unitMedicalPro);
library.setUnitUnemploymentPro(unitUnemploymentPro);
library.setUnitInjuryPro(unitInjuryPro);
library.setUnitBirthPro(unitBirthPro);
library.setUnitPensionFee(unitPersionMoney);
library.setUnitMedicalFee(unitMedicalMoney);
library.setUnitUnemploymentFee(unitUnemploymentMoney);
library.setUnitBirthFee(unitBirthMoney);
library.setUnitWorkInjuryFee(unitInjuryMoney);
}
/**
......@@ -1559,7 +1576,10 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
return R.failed("同步预估库,doMonth格式错误:" + doMonth);
}
} else {
monthDiff = DateUtil.getMonthDiff(socialFundInfo.getSocialStartDate(), new Date()) + 2;
// 获取最小的起缴月
Date minStartDate = this.getMinDate(socialFundInfo);
// 再计算月份
monthDiff = DateUtil.getMonthDiff(minStartDate, new Date()) + 2;
}
List<String> payMonthList = new ArrayList<>();
for (int i = 0; i < monthDiff; i++) {
......@@ -1648,6 +1668,33 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
}
}
/**
* @param socialFundInfo
* @Description: 获取最小起缴日
* @Author: hgw
* @Date: 2022/7/29 11:06
* @return: java.util.Date
**/
private Date getMinDate(TSocialFundInfo socialFundInfo) {
Date minStartDate = socialFundInfo.getSocialStartDate();
if (socialFundInfo.getUnitPersionMoney() != null && socialFundInfo.getPensionStart() != null && socialFundInfo.getPensionStart().before(minStartDate)) {
minStartDate = socialFundInfo.getPensionStart();
}
if (socialFundInfo.getUnitMedicalMoney() != null && socialFundInfo.getMedicalStart() != null && socialFundInfo.getMedicalStart().before(minStartDate)) {
minStartDate = socialFundInfo.getMedicalStart();
}
if (socialFundInfo.getUnitUnemploymentMoney() != null && socialFundInfo.getUnemployStart() != null && socialFundInfo.getUnemployStart().before(minStartDate)) {
minStartDate = socialFundInfo.getUnemployStart();
}
if (socialFundInfo.getUnitInjuryMoney() != null && socialFundInfo.getWorkInjuryStart() != null && socialFundInfo.getWorkInjuryStart().before(minStartDate)) {
minStartDate = socialFundInfo.getWorkInjuryStart();
}
if (socialFundInfo.getUnitBirthMoney() != null && socialFundInfo.getBirthStart() != null && socialFundInfo.getBirthStart().before(minStartDate)) {
minStartDate = socialFundInfo.getBirthStart();
}
return minStartDate;
}
/**
* @Description: 核心刷新
* @Author: hgw
......@@ -1666,10 +1713,12 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
String sfMapKey;
TForecastLibrary tForecastLibrary;
String diffType;
Date minStartDate;
for (String payMonth : payMonthList) {
//封装社保预估数据
if (Common.isNotNull(socialInfoList)) {
for (TSocialFundInfo tSocialInfo : socialInfoList) {
minStartDate = this.getMinDate(tSocialInfo);
createMonth = ServiceUtil.initCreateMonth(tSocialInfo.getCreateTime(), payMonth);
sfMapKey = this.getMapKey(tSocialInfo.getEmpIdcard(), tSocialInfo.getSettleDomain(), payMonth, createMonth);
......@@ -1685,12 +1734,12 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
continue;
}
//起缴月份在要生成的月份前不处理 || 截止月份在要生成的月份后不处理
if (Integer.parseInt(payMonth) < DateUtil.formatDateInt(tSocialInfo.getSocialStartDate())
if (Integer.parseInt(payMonth) < DateUtil.formatDateInt(minStartDate)
|| (Common.isNotNull(tSocialInfo.getSocialReduceDate())
&& Integer.parseInt(payMonth) > DateUtil.formatDateInt(tSocialInfo.getSocialReduceDate()))) {
continue;
}
flag = CommonConstants.ZERO_STRING.equals(tSocialInfo.getCanOverpay()) && (null == tSocialInfo.getOverpayNumber() || null == tSocialInfo.getHaveThisMonth() || null == tSocialInfo.getSocialStartDate());
flag = CommonConstants.ZERO_STRING.equals(tSocialInfo.getCanOverpay()) && (null == tSocialInfo.getOverpayNumber() || null == tSocialInfo.getHaveThisMonth() || null == minStartDate);
if (flag) {
return R.failed("员工" + tSocialInfo.getEmpName() + ":" + tSocialInfo.getEmpIdcard() + SocialConstants.SOCIAL_SET_ERROR);
} else {
......
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