Commit f36dc400 authored by hongguangwu's avatar hongguangwu

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

parents 31c62238 15fe9ecc
...@@ -17,7 +17,7 @@ import lombok.Data; ...@@ -17,7 +17,7 @@ import lombok.Data;
@Schema(description = "项目配置限制项批量导入") @Schema(description = "项目配置限制项批量导入")
public class TAutoMainRelRestrictImportVo extends RowIndex { public class TAutoMainRelRestrictImportVo extends RowIndex {
@ExcelProperty("项目编码(必填)") @ExcelProperty("项目编码")
@Schema(description = "项目编码") @Schema(description = "项目编码")
@ExcelAttribute(name = "项目编码", isNotEmpty = true, errorInfo = "项目编码不能为空", maxLength = 50) @ExcelAttribute(name = "项目编码", isNotEmpty = true, errorInfo = "项目编码不能为空", maxLength = 50)
private String deptNo; private String deptNo;
...@@ -26,28 +26,28 @@ public class TAutoMainRelRestrictImportVo extends RowIndex { ...@@ -26,28 +26,28 @@ public class TAutoMainRelRestrictImportVo extends RowIndex {
@Schema(description = "项目名称") @Schema(description = "项目名称")
private String departName; private String departName;
@ExcelProperty("是否限制(0限制/1不限制)") @ExcelProperty("限制仅在自动化作业")
@Schema(description = "是否限制:0-限制(仅自动化入口),1-不限制") @Schema(description = "是否限制:0-限制(仅自动化入口),1-不限制")
@ExcelAttribute(name = "是否限制",isNotEmpty = true, errorInfo = "是否限制不能为空", readConverterExp = "0=限制,1=不限制") @ExcelAttribute(name = "是否限制",isNotEmpty = true, errorInfo = "是否限制不能为空", readConverterExp = "0=限制,1=不限制")
private String autoFlag; private String autoFlag;
@ExcelProperty("是否限制档案(0不限制/1限制)") @ExcelProperty("档案")
@Schema(description = "是否限制档案") @Schema(description = "是否限制档案")
@ExcelAttribute(name = "是否限制档案", readConverterExp = "0=不限制,1=限制") @ExcelAttribute(name = "档案", readConverterExp = "0=不限制,1=限制")
private String restrictArchive; private String restrictArchive;
@ExcelProperty("是否限制商险(0不限制/1限制)") @ExcelProperty("商险")
@Schema(description = "是否限制商险") @Schema(description = "是否限制商险")
@ExcelAttribute(name = "是否限制商险", readConverterExp = "0=不限制,1=限制") @ExcelAttribute(name = "商险", readConverterExp = "0=不限制,1=限制")
private String restrictInsurance; private String restrictInsurance;
@ExcelProperty("是否限制合同(0不限制/1限制)") @ExcelProperty("合同")
@Schema(description = "是否限制合同") @Schema(description = "是否限制合同")
@ExcelAttribute(name = "是否限制合同", readConverterExp = "0=不限制,1=限制") @ExcelAttribute(name = "合同", readConverterExp = "0=不限制,1=限制")
private String restrictContract; private String restrictContract;
@ExcelProperty("是否限制社保公积金(0不限制/1限制)") @ExcelProperty("社保公积金")
@Schema(description = "是否限制社保公积金") @Schema(description = "是否限制社保公积金")
@ExcelAttribute(name = "是否限制社保公积金", readConverterExp = "0=不限制,1=限制") @ExcelAttribute(name = "社保公积金", readConverterExp = "0=不限制,1=限制")
private String restrictSocialFund; private String restrictSocialFund;
} }
\ No newline at end of file
...@@ -29,6 +29,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; ...@@ -29,6 +29,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.icbc.api.request.EiopCustomerGroupSaveRequestV1;
import com.yifu.cloud.plus.v1.yifu.archives.entity.*; import com.yifu.cloud.plus.v1.yifu.archives.entity.*;
import com.yifu.cloud.plus.v1.yifu.archives.mapper.*; import com.yifu.cloud.plus.v1.yifu.archives.mapper.*;
import com.yifu.cloud.plus.v1.yifu.archives.service.TAutoMainRelService; import com.yifu.cloud.plus.v1.yifu.archives.service.TAutoMainRelService;
...@@ -1605,60 +1606,273 @@ private R<Boolean> checkItemRepeat(List<SysAutoDictItem> autoDictItems, Map<Stri ...@@ -1605,60 +1606,273 @@ private R<Boolean> checkItemRepeat(List<SysAutoDictItem> autoDictItems, Map<Stri
if (Common.isNotNull(errorMessage)){ if (Common.isNotNull(errorMessage)){
return R.failed(errorMessage.getMessage()); return R.failed(errorMessage.getMessage());
} }
//针对"备案基数类型"为"固定值"时,"备案基数"必填,"缴纳类型"为"最高或最低" // 备案基数校验(核心逻辑)
//时,配置提交时,会将"备案基数"同该社保户对应的最高或最低的基数进行对比,"备案基 R<Boolean> validateResult = validateRecordBase(rel);
//数"等于社保户的最高或最低基数 if (validateResult != null && !R.isSuccess(validateResult)){
if (CommonConstants.ZERO_STRING.equals(rel.getRecordBaseType())){ return validateResult;
if (!Common.isNotNull(rel.getRecordBase())){
return R.failed("备案基数不可空");
} }
if ((CommonConstants.ZERO_STRING.equals(rel.getPaymentType()) }
|| CommonConstants.TWO_STRING.equals(rel.getPaymentType()))){ // 校验socialRuleRels 配置名称是否重复
R<SysBaseSetInfoVo> resR = socialDaprUtils.getSocialHouseBaseSet(rel.getConfigHouseId()); Set<String> names = socialRuleRels.stream().map(TAutoSocialRuleRel::getConfigName).collect(Collectors.toSet());
if (Common.isNotNull(resR) && resR.getData() != null) { if (names.size() != socialRuleRels.size()) {
return R.failed(schemeNameRepeat);
}
}
return null;
}
/**
* 校验备案基数
* @param rel 社保规则明细
* @return 校验结果,null表示通过,非null表示失败
*/
private R<Boolean> validateRecordBase(TAutoSocialRuleRel rel) {
String recordBaseType = rel.getRecordBaseType();
String paymentType = rel.getPaymentType();
String recordBase = rel.getRecordBase();
String configHouseId = rel.getConfigHouseId();
// 获取社保户配置信息
R<SysBaseSetInfoVo> resR = socialDaprUtils.getSocialHouseBaseSet(configHouseId);
if (Common.isEmpty(resR) || resR.getData() == null) {
return R.failed("获取社保配置信息失败!");
}
SysBaseSetInfoVo setInfo = resR.getData(); SysBaseSetInfoVo setInfo = resR.getData();
if (Common.isNotNull(setInfo)) { if (Common.isEmpty(setInfo)) {
return R.failed("获取社保配置信息失败!");
}
// 场景1: 固定值类型
if (CommonConstants.ZERO_STRING.equals(recordBaseType)) {
// 必填校验
if (!Common.isNotNull(recordBase)) {
return R.failed("备案基数不能为空,请输入备案基数");
}
// 格式校验
BigDecimal recordBaseDecimal;
try { try {
// 添加了异常处理,避免 recordBase 不是合法数字格式时程序崩溃 recordBaseDecimal = new BigDecimal(recordBase);
if (CommonConstants.ZERO_STRING.equals(rel.getPaymentType())){ } catch (NumberFormatException e) {
BigDecimal recordBaseDecimal = new BigDecimal(rel.getRecordBase()); return R.failed("备案基数格式不正确,请输入有效的数字格式");
if (CommonConstants.ZERO_STRING.equals(setInfo.getIsSameBase())){
if (recordBaseDecimal.compareTo(setInfo.getLowerLimit()) > 0) {
return R.failed("备案基数不大于配置名称("+rel.getConfigName()+")最低基数:"+setInfo.getLowerLimit());
} }
}else {
if (recordBaseDecimal.compareTo(setInfo.getLowerPersion()) > 0) { // 根据缴纳类型进行范围校验
return R.failed("备案基数不大于配置名称("+rel.getConfigName()+")最低基数:"+setInfo.getLowerPersion()); if (CommonConstants.ZERO_STRING.equals(paymentType)) {
}else if (recordBaseDecimal.compareTo(setInfo.getLowerMedical()) > 0) { // 最低基数场景
return R.failed("备案基数不大于配置名称("+rel.getConfigName()+")最低基数:"+setInfo.getLowerMedical()); return validateMinBase(recordBaseDecimal, setInfo, rel.getConfigName());
}else if (recordBaseDecimal.compareTo(setInfo.getLowerBirth()) > 0) { } else if (CommonConstants.ONE_STRING.equals(paymentType)) {
return R.failed("备案基数不大于配置名称("+rel.getConfigName()+")最低基数:"+setInfo.getLowerBirth()); // 自定义场景
}else if (recordBaseDecimal.compareTo(setInfo.getLowerInjury()) > 0) { return validateActualBase(recordBaseDecimal, setInfo, rel.getConfigName());
return R.failed("备案基数不大于配置名称("+rel.getConfigName()+")最低基数:"+setInfo.getLowerInjury()); } else if (CommonConstants.TWO_STRING.equals(paymentType)) {
}else if (recordBaseDecimal.compareTo(setInfo.getLowerUnemployment()) > 0) { // 最高基数场景
return R.failed("备案基数不大于配置名称("+rel.getConfigName()+")最低基数:"+setInfo.getLowerUnemployment()); return validateMaxBase(recordBaseDecimal, setInfo, rel.getConfigName());
}
}
// 场景2: 自定义类型 无备案基数可填写(页面自定义类型时 备案基数 隐藏)
return null; // 校验通过
}
/**
* 校验最低基数场景:备案基数 <= 所有险种最低基数的最小值
*/
private R<Boolean> validateMinBase(BigDecimal recordBase, SysBaseSetInfoVo setInfo, String configName) {
BigDecimal minLowerLimit;
if (CommonConstants.ZERO_STRING.equals(setInfo.getIsSameBase())) {
// 五险合一:直接使用统一最低基数
minLowerLimit = setInfo.getLowerLimit();
} else {
// 分险种:取所有险种最低基数中的最小值
minLowerLimit = getMinLowerLimit(setInfo);
} }
if (recordBase.compareTo(minLowerLimit) > 0) {
return R.failed("备案基数需小于等于最低缴纳基数(" + minLowerLimit + ")");
} }
return null; // 校验通过
} }
} catch (NumberFormatException e) {
return R.failed("备案基数格式不正确"); /**
* 校验最高基数场景:备案基数 >= 所有险种最高基数的最大值
*/
private R<Boolean> validateMaxBase(BigDecimal recordBase, SysBaseSetInfoVo setInfo, String configName) {
BigDecimal maxUpperLimit;
if (CommonConstants.ZERO_STRING.equals(setInfo.getIsSameBase())) {
// 五险合一:直接使用统一最高基数
maxUpperLimit = setInfo.getUpperLimit();
} else {
// 分险种:取所有险种最高基数中的最大值
maxUpperLimit = getMaxUpperLimit(setInfo);
} }
if (recordBase.compareTo(maxUpperLimit) < 0) {
return R.failed("备案基数需大于等于最高缴纳基数(" + maxUpperLimit + ")");
} }
}else {
return R.failed("获取社保配置信息失败!"); return null; // 校验通过
} }
/**
* 校验实际工资场景:备案基数需在所有险种的基数范围内
*/
private R<Boolean> validateActualBase(BigDecimal recordBase, SysBaseSetInfoVo setInfo, String configName) {
List<String> invalidRanges = new ArrayList<>();
if (CommonConstants.ZERO_STRING.equals(setInfo.getIsSameBase())) {
// 五险合一:直接校验统一基数
if (recordBase.compareTo(setInfo.getLowerLimit()) < 0
|| recordBase.compareTo(setInfo.getUpperLimit()) > 0) {
invalidRanges.add("社保基数[" + setInfo.getLowerLimit() + "-" + setInfo.getUpperLimit() + "]");
} }
} else {
// 分险种:逐个险种校验
checkInsuranceRange(recordBase, "养老", setInfo.getLowerPersion(), setInfo.getUpPersion(), invalidRanges);
checkInsuranceRange(recordBase, "医疗", setInfo.getLowerMedical(), setInfo.getUpMedical(), invalidRanges);
checkInsuranceRange(recordBase, "生育", setInfo.getLowerBirth(), setInfo.getUpBirth(), invalidRanges);
checkInsuranceRange(recordBase, "工伤", setInfo.getLowerInjury(), setInfo.getUpInjury(), invalidRanges);
checkInsuranceRange(recordBase, "失业", setInfo.getLowerUnemployment(), setInfo.getUpUnemployment(), invalidRanges);
} }
// 如果有超出范围的险种,返回错误提示
if (!invalidRanges.isEmpty()) {
String message = "备案基数需在" + String.join("、", invalidRanges) + "范围之内(含最低/最高)";
return R.failed(message);
} }
// 校验socialRuleRels 配置名称是否重复
Set<String> names = socialRuleRels.stream().map(TAutoSocialRuleRel::getConfigName).collect(Collectors.toSet()); return null; // 校验通过
if (names.size() != socialRuleRels.size()) {
return R.failed(schemeNameRepeat);
} }
/**
* 检查单个险种的基数范围
*/
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 + "]");
} }
return null; }
}
/**
* 获取所有险种最低基数中的最小值(用于最低基数场景)
*/
private BigDecimal getMinLowerLimit(SysBaseSetInfoVo setInfo) {
List<BigDecimal> lowerLimits = new ArrayList<>();
if (Common.isNotNull(setInfo.getLowerPersion())) {
lowerLimits.add(setInfo.getLowerPersion());
}
if (Common.isNotNull(setInfo.getLowerMedical())) {
lowerLimits.add(setInfo.getLowerMedical());
}
if (Common.isNotNull(setInfo.getLowerBirth())) {
lowerLimits.add(setInfo.getLowerBirth());
}
if (Common.isNotNull(setInfo.getLowerInjury())) {
lowerLimits.add(setInfo.getLowerInjury());
}
if (Common.isNotNull(setInfo.getLowerUnemployment())) {
lowerLimits.add(setInfo.getLowerUnemployment());
}
if (lowerLimits.isEmpty()) {
throw new IllegalArgumentException("社保户未配置最低基数");
}
return Collections.min(lowerLimits);
}
/**
* 获取所有险种最高基数中的最大值(用于最高基数场景)
*/
private BigDecimal getMaxUpperLimit(SysBaseSetInfoVo setInfo) {
List<BigDecimal> upperLimits = new ArrayList<>();
if (Common.isNotNull(setInfo.getUpPersion())) {
upperLimits.add(setInfo.getUpPersion());
}
if (Common.isNotNull(setInfo.getUpMedical())) {
upperLimits.add(setInfo.getUpMedical());
}
if (Common.isNotNull(setInfo.getUpBirth())) {
upperLimits.add(setInfo.getUpBirth());
}
if (Common.isNotNull(setInfo.getUpInjury())) {
upperLimits.add(setInfo.getUpInjury());
}
if (Common.isNotNull(setInfo.getUpUnemployment())) {
upperLimits.add(setInfo.getUpUnemployment());
}
if (upperLimits.isEmpty()) {
throw new IllegalArgumentException("社保户未配置最高基数");
}
return Collections.max(upperLimits);
}
/**
* 获取所有险种最低基数中的最大值(用于实际工资场景的下限)
*/
private BigDecimal getMaxLowerLimit(SysBaseSetInfoVo setInfo) {
List<BigDecimal> lowerLimits = new ArrayList<>();
if (Common.isNotNull(setInfo.getLowerPersion())) {
lowerLimits.add(setInfo.getLowerPersion());
}
if (Common.isNotNull(setInfo.getLowerMedical())) {
lowerLimits.add(setInfo.getLowerMedical());
}
if (Common.isNotNull(setInfo.getLowerBirth())) {
lowerLimits.add(setInfo.getLowerBirth());
}
if (Common.isNotNull(setInfo.getLowerInjury())) {
lowerLimits.add(setInfo.getLowerInjury());
}
if (Common.isNotNull(setInfo.getLowerUnemployment())) {
lowerLimits.add(setInfo.getLowerUnemployment());
}
if (lowerLimits.isEmpty()) {
throw new IllegalArgumentException("社保户未配置最低基数");
}
return Collections.max(lowerLimits);
}
/**
* 获取所有险种最高基数中的最小值(用于实际工资场景的上限)
*/
private BigDecimal getMinUpperLimit(SysBaseSetInfoVo setInfo) {
List<BigDecimal> upperLimits = new ArrayList<>();
if (Common.isNotNull(setInfo.getUpPersion())) {
upperLimits.add(setInfo.getUpPersion());
}
if (Common.isNotNull(setInfo.getUpMedical())) {
upperLimits.add(setInfo.getUpMedical());
}
if (Common.isNotNull(setInfo.getUpBirth())) {
upperLimits.add(setInfo.getUpBirth());
}
if (Common.isNotNull(setInfo.getUpInjury())) {
upperLimits.add(setInfo.getUpInjury());
}
if (Common.isNotNull(setInfo.getUpUnemployment())) {
upperLimits.add(setInfo.getUpUnemployment());
}
if (upperLimits.isEmpty()) {
throw new IllegalArgumentException("社保户未配置最高基数");
}
return Collections.min(upperLimits);
} }
/** /**
...@@ -1813,6 +2027,8 @@ private R<Boolean> checkItemRepeat(List<SysAutoDictItem> autoDictItems, Map<Stri ...@@ -1813,6 +2027,8 @@ private R<Boolean> checkItemRepeat(List<SysAutoDictItem> autoDictItems, Map<Stri
if (Common.isEmpty(entity)) { if (Common.isEmpty(entity)) {
return R.failed(CommonConstants.PARAM_INFO_ERROR); return R.failed(CommonConstants.PARAM_INFO_ERROR);
} }
//档案默认不限制
entity.setRestrictArchive(CommonConstants.ZERO_STRING);
// 保存旧数据用于日志记录 // 保存旧数据用于日志记录
TAutoMainRel oldEntity = new TAutoMainRel(); TAutoMainRel oldEntity = new TAutoMainRel();
BeanUtils.copyProperties(entity, oldEntity); BeanUtils.copyProperties(entity, oldEntity);
...@@ -1820,17 +2036,14 @@ private R<Boolean> checkItemRepeat(List<SysAutoDictItem> autoDictItems, Map<Stri ...@@ -1820,17 +2036,14 @@ private R<Boolean> checkItemRepeat(List<SysAutoDictItem> autoDictItems, Map<Stri
// 获取当前要设置的值(使用VO中的值,如果为null则使用实体当前值) // 获取当前要设置的值(使用VO中的值,如果为null则使用实体当前值)
String newAutoFlag = vo.getAutoFlag(); String newAutoFlag = vo.getAutoFlag();
String newRestrictArchive = vo.getRestrictArchive(); String newRestrictArchive = null == vo.getRestrictArchive()? CommonConstants.ZERO_STRING:vo.getRestrictArchive();
String newRestrictInsurance = vo.getRestrictInsurance(); String newRestrictInsurance = null == vo.getRestrictInsurance()? CommonConstants.ZERO_STRING:vo.getRestrictInsurance();
String newRestrictContract = vo.getRestrictContract(); String newRestrictContract = null == vo.getRestrictContract()? CommonConstants.ZERO_STRING:vo.getRestrictContract();
String newRestrictSocialFund = vo.getRestrictSocialFund(); String newRestrictSocialFund = null == vo.getRestrictSocialFund()? CommonConstants.ZERO_STRING:vo.getRestrictSocialFund();
// 业务规则:如果是否限制为"是"(0),各限制分项不能为空,且至少有一项为限制(1) // 业务规则:如果是否限制为"是"(0),各限制分项不能为空,且至少有一项为限制(1)
if (CommonConstants.ZERO_STRING.equals(newAutoFlag)) { if (CommonConstants.ZERO_STRING.equals(newAutoFlag)) {
// 限制分项不能为空校验 // 限制分项不能为空校验
if (Common.isEmpty(newRestrictArchive)) {
return R.failed("是否限制为是时,限制档案不能为空");
}
if (Common.isEmpty(newRestrictInsurance)) { if (Common.isEmpty(newRestrictInsurance)) {
return R.failed("是否限制为是时,限制商险不能为空"); return R.failed("是否限制为是时,限制商险不能为空");
} }
...@@ -2011,24 +2224,20 @@ private R<Boolean> checkItemRepeat(List<SysAutoDictItem> autoDictItems, Map<Stri ...@@ -2011,24 +2224,20 @@ private R<Boolean> checkItemRepeat(List<SysAutoDictItem> autoDictItems, Map<Stri
"项目编码不存在: " + excel.getDeptNo(),excel)); "项目编码不存在: " + excel.getDeptNo(),excel));
return; return;
} }
//档案默认不限制
entity.setRestrictArchive(CommonConstants.ZERO_STRING);
// 保存旧数据用于日志记录 // 保存旧数据用于日志记录
TAutoMainRel oldEntity = new TAutoMainRel(); TAutoMainRel oldEntity = new TAutoMainRel();
BeanUtils.copyProperties(entity, oldEntity); BeanUtils.copyProperties(entity, oldEntity);
// 获取当前要设置的值(使用Excel中的值,如果为null则使用实体当前值) // 获取当前要设置的值(使用Excel中的值,如果为null则使用实体当前值)
String newAutoFlag = Common.isNotNull(excel.getAutoFlag()) ? excel.getAutoFlag() : entity.getAutoFlag(); String newAutoFlag = Common.isNotNull(excel.getAutoFlag()) ? excel.getAutoFlag() : entity.getAutoFlag();
String newRestrictArchive = excel.getRestrictArchive(); String newRestrictArchive = null ==excel.getRestrictArchive()?CommonConstants.ZERO_STRING:excel.getRestrictArchive();
String newRestrictInsurance = excel.getRestrictInsurance(); String newRestrictInsurance = null == excel.getRestrictInsurance() ? CommonConstants.ZERO_STRING : excel.getRestrictInsurance();
String newRestrictContract = excel.getRestrictContract(); String newRestrictContract = null == excel.getRestrictContract()?CommonConstants.ZERO_STRING:excel.getRestrictContract();
String newRestrictSocialFund = excel.getRestrictSocialFund(); String newRestrictSocialFund = null == excel.getRestrictSocialFund()? CommonConstants.ZERO_STRING : excel.getRestrictSocialFund();
// 业务规则:如果是否限制为"是"(0),各限制分项不能为空,且至少有一项为限制(1) // 业务规则:如果是否限制为"是"(0),各限制分项不能为空,且至少有一项为限制(1)
if (CommonConstants.ZERO_STRING.equals(newAutoFlag)) { if (CommonConstants.ZERO_STRING.equals(newAutoFlag)) {
// 限制分项不能为空校验
if (Common.isEmpty(newRestrictArchive)) {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(),
"是否限制为是时,限制档案不能为空",excel));
return;
}
if (Common.isEmpty(newRestrictInsurance)) { if (Common.isEmpty(newRestrictInsurance)) {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), errorMessageList.add(new ErrorMessage(excel.getRowIndex(),
"是否限制为是时,限制商险不能为空",excel)); "是否限制为是时,限制商险不能为空",excel));
......
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