Commit 773bd917 authored by hongguangwu's avatar hongguangwu

Merge remote-tracking branch 'origin/MVP1.7.23' into MVP1.7.23

parents 31402687 189b8b73
......@@ -18,6 +18,7 @@
package com.yifu.cloud.plus.v1.yifu.archives.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.HeadFontStyle;
import com.alibaba.excel.annotation.write.style.HeadStyle;
......@@ -25,6 +26,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
......@@ -34,6 +36,7 @@ import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
/**
......@@ -107,6 +110,7 @@ public class TAutoMainRelExportVo implements Serializable {
* 非数据库字段,查询时动态生成
*/
@TableField(exist = false)
@ExcelProperty("限制项")
@Schema(description = "限制项显示(拼接后的服务项目名称)")
private String restrictItemsDisplay;
......@@ -116,4 +120,14 @@ public class TAutoMainRelExportVo implements Serializable {
@Schema(description = "自动化配置项列表(记录配置了哪些服务项目)")
private String autoConfigItemsDisplay;
}
\ No newline at end of file
/**
* 创建时间
*/
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("创建时间")
@Schema(description = "创建时间")
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
@ColumnWidth(18)
private LocalDateTime createTime;
}
......@@ -2177,6 +2177,7 @@ private R<Boolean> checkItemRepeat(List<SysAutoDictItem> autoDictItems, Map<Stri
ErrorMessage errorMessage = excelUtil.checkEntity(excel, rowNum);
if (Common.isNotNull(errorMessage)) {
errorMessage.setData(excel);
errorMessageList.add(errorMessage);
continue;
}
......@@ -2232,9 +2233,43 @@ private R<Boolean> checkItemRepeat(List<SysAutoDictItem> autoDictItems, Map<Stri
// 获取当前要设置的值(使用Excel中的值,如果为null则使用实体当前值)
String newAutoFlag = Common.isNotNull(excel.getAutoFlag()) ? excel.getAutoFlag() : entity.getAutoFlag();
String newRestrictArchive = null ==excel.getRestrictArchive()?CommonConstants.ZERO_STRING:excel.getRestrictArchive();
String newRestrictInsurance = null == excel.getRestrictInsurance() ? CommonConstants.ZERO_STRING : excel.getRestrictInsurance();
String newRestrictContract = null == excel.getRestrictContract()?CommonConstants.ZERO_STRING:excel.getRestrictContract();
String newRestrictSocialFund = null == excel.getRestrictSocialFund()? CommonConstants.ZERO_STRING : excel.getRestrictSocialFund();
String newRestrictInsurance = excel.getRestrictInsurance();
String newRestrictContract = excel.getRestrictContract();
String newRestrictSocialFund = excel.getRestrictSocialFund();
// 校验autoFlag的值必须为0或1
if (!CommonConstants.ZERO_STRING.equals(newAutoFlag) && !CommonConstants.ONE_STRING.equals(newAutoFlag)) {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(),
"是否限制值不合法,必须为0或1",excel));
return;
}
// 校验restrictInsurance的值必须为0或1
if (Common.isNotNull(newRestrictInsurance) &&
!CommonConstants.ZERO_STRING.equals(newRestrictInsurance) &&
!CommonConstants.ONE_STRING.equals(newRestrictInsurance)) {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(),
"商险限制值不合法,必须为0或1",excel));
return;
}
// 校验restrictContract的值必须为0或1
if (Common.isNotNull(newRestrictContract) &&
!CommonConstants.ZERO_STRING.equals(newRestrictContract) &&
!CommonConstants.ONE_STRING.equals(newRestrictContract)) {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(),
"合同限制值不合法,必须为0或1",excel));
return;
}
// 校验restrictSocialFund的值必须为0或1
if (Common.isNotNull(newRestrictSocialFund) &&
!CommonConstants.ZERO_STRING.equals(newRestrictSocialFund) &&
!CommonConstants.ONE_STRING.equals(newRestrictSocialFund)) {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(),
"社保公积金限制值不合法,必须为0或1",excel));
return;
}
// 业务规则:如果是否限制为"是"(0),各限制分项不能为空,且至少有一项为限制(1)
if (CommonConstants.ZERO_STRING.equals(newAutoFlag)) {
......
......@@ -188,7 +188,7 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr
return R.failed(CommonConstants.USER_FAIL);
}
TSettleDomain domain = tSettleDomainService.getById(tEmployeeContractInfo.getSettleDomain());
if (Common.isNotNull(user) && !CommonConstants.ZERO_STRING.equals(user.getSystemFlag()) && null != domain) {
if (Common.isNotNull(user) && null != domain) {
// 超管放行,不进行自动化限制检查
if (!isSuperAdmin(user)) {
String deptNo = domain.getDepartNo();
......@@ -1428,6 +1428,8 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr
* 项目编码自动化校验缓存,key: deptNo, value: true-已纳入自动化, false-未纳入
*/
private Map<String, Boolean> autoCheckCache = new HashMap<>();
private boolean notSuperAdmin = !isSuperAdmin(user);
@Override
public void invoke(EmployeeContractVO data, AnalysisContext context) {
......@@ -1440,7 +1442,7 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr
} else {
// 导入时的自动化校验
String deptNo = data.getDeptNo();
if (Common.isNotNull(deptNo) && !isSuperAdmin(user)) {
if (Common.isNotNull(deptNo) && notSuperAdmin) {
// 先从缓存中获取
Boolean isAuto = autoCheckCache.get(deptNo);
if (isAuto == null) {
......
......@@ -89,6 +89,11 @@
<if test="tAutoMainRel.createTime != null">
AND a.CREATE_TIME = #{tAutoMainRel.createTime}
</if>
<!-- 创建时间区间查询 -->
<if test="tAutoMainRel.createTimes != null and tAutoMainRel.createTimes.length == 2">
AND a.CREATE_TIME &gt;= #{tAutoMainRel.createTimes[0]}
AND a.CREATE_TIME &lt;= #{tAutoMainRel.createTimes[1]}
</if>
<if test="tAutoMainRel.updateBy != null and tAutoMainRel.updateBy.trim() != ''">
AND a.UPDATE_BY = #{tAutoMainRel.updateBy}
</if>
......@@ -245,6 +250,7 @@
SELECT
a.RULE_UPDATE_TIME,
a.RULE_UPDATE_PERSON,
a.CREATE_TIME,
b.DEPART_NAME,
IFNULL(b.cs_name,'') csUserName,
b.DEPART_NO dept_NO,
......
......@@ -490,6 +490,11 @@ public interface ErrorCodes {
* 派增异常: 社保各项基数不一致,委托备注必填
*/
String EMP_DISPATCH_SOCIAL_BASE_LIMIT_ERROR = "emp.dispatch.social.base.limit.error";
/**
* 派增异常: 社保各项基数与备案基数不一致,自定义类型 备案基数需要与各项基数一致(不含大病)
*/
String EMP_DISPATCH_SOCIAL_BASE_RECORD_ERROR = "emp.dispatch.social.base.record.error";
/**
* 派增异常: 社保各项起缴日不一致,委托备注必填
*/
......
......@@ -178,6 +178,8 @@ emp.dispatch.fund.limit.error=\u6D3E\u589E\u5F02\u5E38\uFF1A \u516C\u79EF\u91D1\
emp.dispatch.social.base.limit.error=\u6D3E\u589E\u5F02\u5E38\uFF1A \u5907\u6848\u57FA\u6570\u4E0E\u793E\u4FDD\u4EFB\u610F\u57FA\u6570\u4E0D\u4E00\u81F4\uFF0C\u59D4\u6258\u5907\u6CE8\u5FC5\u586B
emp.dispatch.social.base.record.error=\u6D3E\u589E\u5F02\u5E38\uFF1A \u793E\u4FDD\u5404\u9879\u57FA\u6570\u4E0E\u5907\u6848\u57FA\u6570\u4E0D\u4E00\u81F4\uFF0C\u81EA\u5B9A\u4E49\u7C7B\u578B \u5907\u6848\u57FA\u6570\u9700\u8981\u4E0E\u5404\u9879\u57FA\u6570\u4E00\u81F4\uFF08\u4E0D\u542B\u5927\u75C5\uFF09
emp.dispatch.social.date.limit.error=\u6D3E\u589E\u5F02\u5E38\uFF1A \u793E\u4FDD\u9669\u79CD\u8D77\u7F34\u65E5\u671F\u4E0D\u4E00\u81F4\u65F6\uFF0C\u201C\u59D4\u6258\u5907\u6CE8\u201D\u5217\u5FC5\u586B\uFF0C\u4E0D\u53EF\u4E3A\u7A7A
emp.dispatch.social.date.limit.error2=\u6D3E\u589E\u5F02\u5E38\uFF1A \u5408\u540C\u8D77\u59CB\u65E5\u671F\u4E0E\u793E\u4FDD\u8D77\u7F34\u65E5\u671F\u4E0D\u4E00\u81F4\u65F6\uFF0C\u201C\u59D4\u6258\u5907\u6CE8\u201D\u5217\u5FC5\u586B\uFF0C\u4E0D\u53EF\u4E3A\u7A7A
......
......@@ -117,9 +117,9 @@ public class SecurityUtils {
if (roleList == null || roleList.isEmpty()) {
return false;
}
// SSC开发组-1668092146875969537L 超管1
// 超管1
for (Long role : roleList) {
if (role == 1668092146875969537L || role == 1L) {
if (role == 1L) {
return true;
}
}
......
......@@ -19,6 +19,8 @@ public class RegistConstants {
public static final String EMP_PROJECT_EXIT_CHECK = "未找到该人员对应的在项信息!";
public static final String EMP_PROJECT_IS_EXIT_CHECK = "该人员存在在项的项目档案!";
public static final String EMP_CONTRACT_EXIT_CHECK = "已存在流程中的合同待签订数据!";
public static final String CONFIRM_SUBMIT = "确认接收";
......
......@@ -2156,22 +2156,25 @@ public class EmployeeRegistrationServiceImpl extends ServiceImpl<EmployeeRegistr
.eq(EmployeeRegistration::getEmpIdcard, registration.getEmpIdcard())
.eq(EmployeeRegistration::getDeptNo, registration.getDeptNo())
.eq(EmployeeRegistration::getFeedbackType, registration.getFeedbackType())
.orderByDesc(EmployeeRegistration::getCreateTime)
.in(EmployeeRegistration::getProcessStatus, CommonConstants.processStatus)
.last(CommonConstants.LAST_ONE_SQL));
if (Common.isNotNull(exit)) {
return RegistConstants.REGIST_SAME_CHECK;
}
//针对入职的判断是否存在流程中的合同待签订数据
//针对入职的判断
if (CommonConstants.ONE_STRING.equals(registration.getFeedbackType())) {
int nowDay = Integer.parseInt(DateUtil.getThisDay());
if (Common.isNot16Age(registration.getEmpIdcard(), nowDay)) {
return CommonConstants.UNDER_16_ERROR;
}
//针对入职的判断是否存在在项项目档案
EmpProjectStatusVo vo = new EmpProjectStatusVo();
vo.setEmpIdcard(registration.getEmpIdcard());
vo.setDeptNo(registration.getDeptNo());
if (Boolean.TRUE.equals(checkContractPreIsExit(vo))) {
return RegistConstants.EMP_CONTRACT_EXIT_CHECK;
EmpProjectStatusVo exitProject = getEmpProjectStatus(vo);
if (!Common.isEmpty(exitProject)) {
return RegistConstants.EMP_PROJECT_IS_EXIT_CHECK;
}
}
//针对离职的判断人员项目档案状态是否正常
......@@ -3187,33 +3190,25 @@ public class EmployeeRegistrationServiceImpl extends ServiceImpl<EmployeeRegistr
}
//该人员入职/离职数据已登记,请勿重复操作
if (CommonConstants.TWO_STRING.equals(insert.getFeedbackType())){
exit = baseMapper.selectOne(Wrappers.<EmployeeRegistration>query().lambda()
.eq(EmployeeRegistration::getEmpIdcard, insert.getEmpIdcard())
.eq(EmployeeRegistration::getDeptNo, insert.getDeptNo())
.eq(EmployeeRegistration::getFeedbackType, insert.getFeedbackType())
.in(EmployeeRegistration::getProcessStatus, CommonConstants.processStatus)
.last(CommonConstants.LAST_ONE_SQL));
} else {
// v1.7.23 新增:已处理 也要拒绝入职
exit = baseMapper.selectOne(Wrappers.<EmployeeRegistration>query().lambda()
.eq(EmployeeRegistration::getEmpIdcard, insert.getEmpIdcard())
.eq(EmployeeRegistration::getDeptNo, insert.getDeptNo())
.eq(EmployeeRegistration::getFeedbackType, insert.getFeedbackType())
.in(EmployeeRegistration::getProcessStatus, Stream.of("0","1").collect(Collectors.toList()))
.last(CommonConstants.LAST_ONE_SQL));
}
exit = baseMapper.selectOne(Wrappers.<EmployeeRegistration>query().lambda()
.eq(EmployeeRegistration::getEmpIdcard, insert.getEmpIdcard())
.eq(EmployeeRegistration::getDeptNo, insert.getDeptNo())
.eq(EmployeeRegistration::getFeedbackType, insert.getFeedbackType())
.in(EmployeeRegistration::getProcessStatus, CommonConstants.processStatus)
.orderByDesc(EmployeeRegistration::getCreateTime)
.last(CommonConstants.LAST_ONE_SQL));
if (Common.isNotNull(exit)) {
errorList.add(RegistConstants.REGIST_SAME_CHECK);
}
//针对入职的判断是否存在流程中的合同待签订数据
//针对入职的判断是否存在在项项目档案
if (CommonConstants.ONE_STRING.equals(insert.getFeedbackType())) {
EmpProjectStatusVo vo = new EmpProjectStatusVo();
vo.setEmpIdcard(insert.getEmpIdcard());
vo.setDeptNo(insert.getDeptNo());
if (Boolean.TRUE.equals(checkContractPreIsExit(vo))) {
errorList.add(RegistConstants.EMP_CONTRACT_EXIT_CHECK);
EmpProjectStatusVo exitProject = getEmpProjectStatus(vo);
if (!Common.isEmpty(exitProject)) {
errorList.add(RegistConstants.EMP_PROJECT_IS_EXIT_CHECK);
}
}
......
......@@ -2855,13 +2855,32 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
}
}
if (Common.isNotNull(excel.getSocialHousehold())) {
// 各个社保基数和日期空 默认养老日期和基数
// 校验备案基数范围(不含大病)
if (validateRecordBaseRange(errorMessageList, excel, socialSet)) {
return true;
}
// 自定义 各项基数配置与备案基数不一致,就提示(不含大病)
if (CommonConstants.ONE_STRING.equals(excel.getPaymentType())) {
boolean flag = Common.isBlankToBigDecimalZero(excel.getPensionCardinal()).compareTo(excel.getRecordBase()) != CommonConstants.ZERO_INT
|| Common.isBlankToBigDecimalZero(excel.getMedicalCardinal()).compareTo(excel.getRecordBase()) != CommonConstants.ZERO_INT
|| Common.isBlankToBigDecimalZero(excel.getUnemploymentCardinal()).compareTo(excel.getRecordBase()) != CommonConstants.ZERO_INT
|| Common.isBlankToBigDecimalZero(excel.getWorkInjuryCardinal()).compareTo(excel.getRecordBase()) != CommonConstants.ZERO_INT
|| Common.isBlankToBigDecimalZero(excel.getBirthCardinal()).compareTo(excel.getRecordBase()) != CommonConstants.ZERO_INT;
if (flag) {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), MsgUtils.getMessage(ErrorCodes.EMP_DISPATCH_SOCIAL_BASE_RECORD_ERROR)));
return true;
}
}
// 根据缴纳类型赋值各险种基数(不含大病)
assignSocialCardinalByPaymentType(excel, socialSet);
// 各个社保基数和日期空 默认养老日期和基数(兜底逻辑,包含大病)
initExcelBaseAndDate(excel);
// 校验各项起缴日期 查看是否符合社保补缴政策
if (validSocialStartDate(errorMessageList, excel, socialSet)) {
return true;
}
//校验各项基数
// 校验社保日期相关信息(含委托备注判断 + 大病校验原有逻辑)
if (validSocialBaseInfo(errorMessageList, excel, empVo, socialSet, contractDateTemp)) {
return true;
}
......@@ -2995,7 +3014,8 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
}
private boolean validSocialBaseInfo(List<ErrorMessage> errorMessageList, TDispatchImportVo excel, DispatchEmpVo empVo, SysBaseSetInfo socialSet, Date contractDateTemp) {
if (Common.isNotNull(socialSet) && CommonConstants.ONE_STRING.equals(excel.getPaymentType())) {
// 删除: 自定义类型的各险种范围校验(已迁移到 validateCustomBase 方法)
/*if (Common.isNotNull(socialSet) && CommonConstants.ONE_STRING.equals(excel.getPaymentType())) {
if (Common.isNotNull(excel.getPensionCardinal())
&& (excel.getPensionCardinal().compareTo(socialSet.getUpPersion()) > CommonConstants.ZERO_INT
|| excel.getPensionCardinal().compareTo(socialSet.getLowerPersion()) < CommonConstants.ZERO_INT)) {
......@@ -3026,6 +3046,10 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), MsgUtils.getMessage(ErrorCodes.BIR_DISPATCH_SOCIAL_LIMIT_ERROR)));
return true;
}
}*/
// ✅ 保留: 大病基数校验(原有逻辑,保持不变)
if (Common.isNotNull(socialSet) && CommonConstants.ONE_STRING.equals(excel.getPaymentType())) {
if (Common.isNotNull(excel.getBigailmentCardinal()) && CommonConstants.ONE_STRING.equals(socialSet.getCollectType())
&& CommonConstants.ONE_STRING.equals(socialSet.getValueType())
&& (excel.getBigailmentCardinal().compareTo(socialSet.getUpBig()) > CommonConstants.ZERO_INT
......@@ -3036,27 +3060,6 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
}
// 备案基数和养老基数 养老起缴日期 必填在前面已必填校验,这里不重复校验
if (Common.isNotNull(excel.getRecordBase()) && Common.isNotNull(excel.getSocialHousehold())) {
// 自定义 只要有一个不相同的 日期或基数 就要提示
if (CommonConstants.ONE_STRING.equals(excel.getPaymentType()) && Common.isEmpty(excel.getTrustRemark())) {
boolean flag = (Common.isNotNull(excel.getPensionCardinal())
&& excel.getPensionCardinal().compareTo(excel.getRecordBase()) != CommonConstants.ZERO_INT)
|| (Common.isNotNull(excel.getMedicalCardinal())
&& excel.getMedicalCardinal().compareTo(excel.getRecordBase()) != CommonConstants.ZERO_INT)
|| (Common.isNotNull(excel.getUnemploymentCardinal())
&& excel.getUnemploymentCardinal().compareTo(excel.getRecordBase()) != CommonConstants.ZERO_INT)
|| (Common.isNotNull(excel.getWorkInjuryCardinal())
&& excel.getWorkInjuryCardinal().compareTo(excel.getRecordBase()) != CommonConstants.ZERO_INT)
|| (Common.isNotNull(excel.getBirthCardinal())
&& excel.getBirthCardinal().compareTo(excel.getRecordBase()) != CommonConstants.ZERO_INT)
|| (Common.isNotNull(excel.getBigailmentCardinal())
&& CommonConstants.ONE_STRING.equals(socialSet.getCollectType())
&& CommonConstants.ONE_STRING.equals(socialSet.getValueType())
&& excel.getBigailmentCardinal().compareTo(excel.getRecordBase()) != CommonConstants.ZERO_INT);
if (flag) {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), MsgUtils.getMessage(ErrorCodes.EMP_DISPATCH_SOCIAL_BASE_LIMIT_ERROR)));
return true;
}
}
Date temp;
if (Common.isEmpty(empVo)) {
temp = excel.getContractStart();
......@@ -3080,14 +3083,15 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), MsgUtils.getMessage(ErrorCodes.EMP_DISPATCH_SOCIAL_DATE_LIMIT_ERROR2)));
return true;
}
if (CommonConstants.ZERO_STRING.equals(excel.getPaymentType())) {
// 删除: 最低/最高类型的赋值逻辑(已迁移到 assignSocialCardinalByPaymentType 方法)
/*if (CommonConstants.ZERO_STRING.equals(excel.getPaymentType())) {
excel.setPensionCardinal(socialSet.getLowerPersion());
}
if (CommonConstants.TWO_STRING.equals(excel.getPaymentType())) {
excel.setPensionCardinal(socialSet.getUpPersion());
}
}*/
//最低最高时候去校验时候去校验
if (Common.isEmpty(excel.getTrustRemark()) && ((CommonConstants.ZERO_STRING.equals(excel.getPaymentType())
/*if (Common.isEmpty(excel.getTrustRemark()) && ((CommonConstants.ZERO_STRING.equals(excel.getPaymentType())
&& (socialSet.getLowerPersion().compareTo(excel.getRecordBase()) != CommonConstants.ZERO_INT ||
socialSet.getLowerMedical().compareTo(excel.getRecordBase()) != CommonConstants.ZERO_INT ||
socialSet.getLowerUnemployment().compareTo(excel.getRecordBase()) != CommonConstants.ZERO_INT ||
......@@ -3107,7 +3111,7 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
socialSet.getUpBig().compareTo(excel.getRecordBase()) != CommonConstants.ZERO_INT))))) {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), MsgUtils.getMessage(ErrorCodes.EMP_DISPATCH_SOCIAL_BASE_LIMIT_ERROR)));
return true;
}
}*/
}
return false;
}
......@@ -9367,4 +9371,242 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
}
}
}
// ==================== 备案基数校验相关方法(新增) ====================
/**
* 校验备案基数范围(仅校验养老、医疗、失业、工伤、生育,❌ 不包含大病)
* @param errorMessageList 错误信息列表
* @param excel 派单导入数据
* @param socialSet 社保户配置
* @return true-校验失败, false-校验通过
*/
private boolean validateRecordBaseRange(List<ErrorMessage> errorMessageList,
TDispatchImportVo excel,
SysBaseSetInfo socialSet) {
// 无备案基数,跳过校验
if (Common.isEmpty(excel.getRecordBase())) {
return false;
}
String paymentType = excel.getPaymentType();
BigDecimal recordBase;
try {
recordBase = Common.isBlankToBigDecimalZero(excel.getRecordBase());
} catch (NumberFormatException e) {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), "备案基数格式不正确,请输入有效的数字格式"));
return true;
}
R<Boolean> validateResult = null;
// 根据缴纳类型进行范围校验
if (CommonConstants.ZERO_STRING.equals(paymentType)) {
// 最低基数场景
validateResult = validateMinBase(recordBase, socialSet);
} else if (CommonConstants.TWO_STRING.equals(paymentType)) {
// 最高基数场景
validateResult = validateMaxBase(recordBase, socialSet);
} else if (CommonConstants.ONE_STRING.equals(paymentType)) {
// 自定义场景
validateResult = validateCustomBase(recordBase, socialSet);
}
// 校验失败,添加错误信息
if (validateResult != null && !R.isSuccess(validateResult)) {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), validateResult.getMsg()));
return true;
}
return false; // 校验通过
}
/**
* 校验最低基数: 备案基数 <= 养老、医疗、失业、工伤、生育最低基数的最小值(❌ 不含大病)
*/
private R<Boolean> validateMinBase(BigDecimal recordBase, SysBaseSetInfo socialSet) {
BigDecimal minLowerLimit;
if (CommonConstants.ZERO_STRING.equals(socialSet.getIsSameBase())) {
// 五险合一: 直接使用统一最低基数
minLowerLimit = socialSet.getLowerLimit();
} else {
// 分险种: 取养老、医疗、失业、工伤、生育最低基数中的最小值(不含大病)
minLowerLimit = getMinLowerLimitWithoutBig(socialSet);
}
if (recordBase.compareTo(minLowerLimit) > 0) {
return R.failed("备案基数需小于等于最低缴纳基数(" + minLowerLimit + ")");
}
return null; // 校验通过
}
/**
* 校验最高基数: 备案基数 >= 养老、医疗、失业、工伤、生育最高基数的最大值(❌ 不含大病)
*/
private R<Boolean> validateMaxBase(BigDecimal recordBase, SysBaseSetInfo socialSet) {
BigDecimal maxUpperLimit;
if (CommonConstants.ZERO_STRING.equals(socialSet.getIsSameBase())) {
// 五险合一: 直接使用统一最高基数
maxUpperLimit = socialSet.getUpperLimit();
} else {
// 分险种: 取养老、医疗、失业、工伤、生育最高基数中的最大值( 不含大病)
maxUpperLimit = getMaxUpperLimitWithoutBig(socialSet);
}
if (recordBase.compareTo(maxUpperLimit) < 0) {
return R.failed("备案基数需大于等于最高缴纳基数(" + maxUpperLimit + ")");
}
return null; // 校验通过
}
/**
* 校验自定义基数: 备案基数在养老、医疗、失业、工伤、生育的有效范围内(不含大病)
*/
private R<Boolean> validateCustomBase(BigDecimal recordBase, SysBaseSetInfo socialSet) {
List<String> invalidRanges = new ArrayList<>();
if (CommonConstants.ZERO_STRING.equals(socialSet.getIsSameBase())) {
// 五险合一: 直接校验统一基数
if (recordBase.compareTo(socialSet.getLowerLimit()) < 0
|| recordBase.compareTo(socialSet.getUpperLimit()) > 0) {
invalidRanges.add("社保基数[" + socialSet.getLowerLimit() + "-" + socialSet.getUpperLimit() + "]");
}
} else {
// 分险种: 逐个险种校验(不含大病)
checkInsuranceRange(recordBase, "养老", socialSet.getLowerPersion(), socialSet.getUpPersion(), invalidRanges);
checkInsuranceRange(recordBase, "医疗", socialSet.getLowerMedical(), socialSet.getUpMedical(), invalidRanges);
checkInsuranceRange(recordBase, "失业", socialSet.getLowerUnemployment(), socialSet.getUpUnemployment(), invalidRanges);
checkInsuranceRange(recordBase, "工伤", socialSet.getLowerInjury(), socialSet.getUpInjury(), invalidRanges);
checkInsuranceRange(recordBase, "生育", socialSet.getLowerBirth(), socialSet.getUpBirth(), invalidRanges);
// 不校验大病,保持原有逻辑(在第3029-3034行)
}
// 如果有超出范围的险种,返回错误提示
if (!invalidRanges.isEmpty()) {
String message = "备案基数需在" + String.join("、", invalidRanges) + "范围之内(含最低/最高)";
return R.failed(message);
}
return null; // 校验通过
}
/**
* 检查单个险种的基数范围
*/
private void checkInsuranceRange(BigDecimal recordBase, String insuranceName,
BigDecimal lowerLimit, BigDecimal upperLimit,
List<String> invalidRanges) {
if (Common.isNotNull(lowerLimit) && Common.isNotNull(upperLimit)) {
if (recordBase.compareTo(lowerLimit) < 0 || recordBase.compareTo(upperLimit) > 0) {
invalidRanges.add(insuranceName + "基数[" + lowerLimit + "-" + upperLimit + "]");
}
}
}
/**
* 获取养老、医疗、失业、工伤、生育最低基数中的最小值(❌ 不含大病)
*/
private BigDecimal getMinLowerLimitWithoutBig(SysBaseSetInfo socialSet) {
List<BigDecimal> lowerLimits = new ArrayList<>();
if (Common.isNotNull(socialSet.getLowerPersion())) {
lowerLimits.add(socialSet.getLowerPersion());
}
if (Common.isNotNull(socialSet.getLowerMedical())) {
lowerLimits.add(socialSet.getLowerMedical());
}
if (Common.isNotNull(socialSet.getLowerBirth())) {
lowerLimits.add(socialSet.getLowerBirth());
}
if (Common.isNotNull(socialSet.getLowerInjury())) {
lowerLimits.add(socialSet.getLowerInjury());
}
if (Common.isNotNull(socialSet.getLowerUnemployment())) {
lowerLimits.add(socialSet.getLowerUnemployment());
}
// 不加入大病最低基数,保持原有逻辑
if (lowerLimits.isEmpty()) {
throw new IllegalArgumentException("社保户未配置最低基数");
}
return Collections.min(lowerLimits);
}
/**
* 获取养老、医疗、失业、工伤、生育最高基数中的最大值(不含大病)
*/
private BigDecimal getMaxUpperLimitWithoutBig(SysBaseSetInfo socialSet) {
List<BigDecimal> upperLimits = new ArrayList<>();
if (Common.isNotNull(socialSet.getUpPersion())) {
upperLimits.add(socialSet.getUpPersion());
}
if (Common.isNotNull(socialSet.getUpMedical())) {
upperLimits.add(socialSet.getUpMedical());
}
if (Common.isNotNull(socialSet.getUpBirth())) {
upperLimits.add(socialSet.getUpBirth());
}
if (Common.isNotNull(socialSet.getUpInjury())) {
upperLimits.add(socialSet.getUpInjury());
}
if (Common.isNotNull(socialSet.getUpUnemployment())) {
upperLimits.add(socialSet.getUpUnemployment());
}
// 不加入大病最高基数,保持原有逻辑
if (upperLimits.isEmpty()) {
throw new IllegalArgumentException("社保户未配置最高基数");
}
return Collections.max(upperLimits);
}
/**
* 根据缴纳类型赋值各险种基数(仅赋值养老、医疗、失业、工伤、生育,❌ 不包含大病)
*/
private void assignSocialCardinalByPaymentType(TDispatchImportVo excel, SysBaseSetInfo socialSet) {
String paymentType = excel.getPaymentType();
if (CommonConstants.ZERO_STRING.equals(paymentType)) {
// 最低: 5个险种基数 = 对应险种的最低基数(不含大病)
excel.setPensionCardinal(socialSet.getLowerPersion());
excel.setMedicalCardinal(socialSet.getLowerMedical());
excel.setUnemploymentCardinal(socialSet.getLowerUnemployment());
excel.setWorkInjuryCardinal(socialSet.getLowerInjury());
excel.setBirthCardinal(socialSet.getLowerBirth());
// 不赋值大病基数,保持原有逻辑(在第1902-1951行)
} else if (CommonConstants.TWO_STRING.equals(paymentType)) {
// 最高: 5个险种基数 = 对应险种的最高基数(不含大病)
excel.setPensionCardinal(socialSet.getUpPersion());
excel.setMedicalCardinal(socialSet.getUpMedical());
excel.setUnemploymentCardinal(socialSet.getUpUnemployment());
excel.setWorkInjuryCardinal(socialSet.getUpInjury());
excel.setBirthCardinal(socialSet.getUpBirth());
// 不赋值大病基数,保持原有逻辑(在第1902-1951行)
} else if (CommonConstants.ONE_STRING.equals(paymentType)) {
// 自定义: 5个险种基数 = 备案基数(不含大病)
BigDecimal recordBase = Common.isBlankToBigDecimalZero(excel.getRecordBase());
excel.setPensionCardinal(recordBase);
excel.setMedicalCardinal(recordBase);
excel.setUnemploymentCardinal(recordBase);
excel.setWorkInjuryCardinal(recordBase);
excel.setBirthCardinal(recordBase);
// 不赋值大病基数,保持原有逻辑(在第1902-1951行)
}
}
}
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