Merge remote-tracking branch 'remotes/origin/feature/v2-welfareBaseLimit-1104' into release/2.1.2.2211.01

This commit is contained in:
sy 2022-11-02 17:30:37 +08:00
commit d3a9d71942
6 changed files with 123 additions and 14 deletions

View File

@ -62,6 +62,8 @@ import weaver.hrm.User;
import java.math.BigDecimal;
import java.util.*;
import java.util.function.Function;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@ -86,6 +88,10 @@ public class SIArchivesBiz {
return MapperProxyFactory.getProxy(InsuranceBaseInfoMapper.class);
}
private InsuranceSchemeDetailMapper getInsuranceSchemeDetailMapper() {
return MapperProxyFactory.getProxy(InsuranceSchemeDetailMapper.class);
}
/**
* @param welfareType
* @param employeeId
@ -627,7 +633,7 @@ public class SIArchivesBiz {
InsuranceArchivesOtherSchemePO updateOtherInfo =
InsuranceArchivesOtherSchemePO.builder()
.id(oldOtherInfo.getId())
.otherSchemeId(param.getOtherName())
.otherSchemeId(param.getOtherSchemeId())
.otherStartTime(param.getOtherStartTime())
.underTake(param.getUnderTake())
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
@ -641,6 +647,10 @@ public class SIArchivesBiz {
.paymentOrganization(param.getPaymentOrganization())
.otherPaymentBaseString(paramReq.getPaymentForm())
.build();
//校验福利基数是否符合上下限要求
if (!checkWelBaseLimit(updateOtherInfo.getOtherSchemeId(),updateOtherInfo.getOtherPaymentBaseString())) {
throw new SalaryRunTimeException("其他福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!");
}
InsuranceArchivesOtherSchemePOEncrypt.encryptItem(updateOtherInfo);
otherSchemeMapper.updateById(updateOtherInfo);
sqlSession.commit();
@ -673,7 +683,7 @@ public class SIArchivesBiz {
InsuranceArchivesFundSchemePO oldFundInfo = oldFundInfoList.get(0);
InsuranceArchivesFundSchemePO updateFundInfo = InsuranceArchivesFundSchemePO.builder()
.id(oldFundInfo.getId())
.fundSchemeId(param.getFundName())
.fundSchemeId(param.getFundSchemeId())
.fundAccount(param.getFundAccount())
.fundEndTime(param.getFundEndTime())
.fundStartTime(param.getFundStartTime())
@ -689,6 +699,10 @@ public class SIArchivesBiz {
.welfareType(paramReq.getWelfareType().getValue())
.employeeId(param.getEmployeeId())
.build();
//校验福利基数是否符合上下限要求
if (!checkWelBaseLimit(updateFundInfo.getFundSchemeId(),updateFundInfo.getFundPaymentBaseString())) {
throw new SalaryRunTimeException("公积金福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!");
}
InsuranceArchivesFundSchemePOEncrypt.encryptItem(updateFundInfo);
fundSchemeMapper.updateById(updateFundInfo);
@ -734,7 +748,7 @@ public class SIArchivesBiz {
.welfareType(paramReq.getWelfareType().getValue())
.deleteType(DeleteTypeEnum.NOT_DELETED.getValue())
.socialPaymentBaseString(paramReq.getPaymentForm())
.socialSchemeId(param.getSocialName())
.socialSchemeId(param.getSocialSchemeId())
.socialEndTime(param.getSocialEndTime())
.socialStartTime(param.getSocialStartTime())
.creator(employeeId)
@ -746,6 +760,10 @@ public class SIArchivesBiz {
.socialAccount(param.getSchemeAccount())
.paymentOrganization(param.getPaymentOrganization())
.build();
//校验福利基数是否符合上下限要求
if (!checkWelBaseLimit(updateSocialInfo.getSocialSchemeId(),updateSocialInfo.getSocialPaymentBaseString())) {
throw new SalaryRunTimeException("社保福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!");
}
InsuranceArchivesSocialSchemePOEncrypt.encryptItem(updateSocialInfo);
socialSchemeMapper.updateById(updateSocialInfo);
@ -759,6 +777,54 @@ public class SIArchivesBiz {
}
}
/**
* 校验福利基数是否符合上下限要求
* @param primaryId
* @param paymentBaseString
* @return
*/
public Boolean checkWelBaseLimit(Long primaryId, String paymentBaseString) {
if (primaryId ==null || paymentBaseString == null) {
return true;
}
//设置缴纳对象
Integer paymentScope = 2;
Map<String, String> paymentBaseJson = JSON.parseObject(paymentBaseString, new HashMap<String, String>().getClass());
if (paymentBaseJson == null) {
return true;
}
for (Map.Entry<String, String> entry : paymentBaseJson.entrySet()) {
//判断福利值是否为空/数字
if (entry.getValue() == null || entry.getValue().length() == 0) {
continue;
} else if (!isNumeric(entry.getValue())) {
return false;
}
//根据福利方案id险种id缴纳对象查询明细
InsuranceSchemeDetailPO insuranceSchemeDetailPO = getInsuranceSchemeDetailMapper().getByPPI(primaryId, paymentScope, Long.valueOf(entry.getKey()));
if (insuranceSchemeDetailPO == null) {
return false;
}
InsuranceSchemeDetailPOEncrypt.decryptItem(insuranceSchemeDetailPO);
String lowerLimit = "0.000".equals(insuranceSchemeDetailPO.getLowerLimit()) ? null : insuranceSchemeDetailPO.getLowerLimit();
String upperLimit = "0.000".equals(insuranceSchemeDetailPO.getUpperLimit()) ? null : insuranceSchemeDetailPO.getUpperLimit();
if (lowerLimit != null && lowerLimit.length() > 0 && Double.parseDouble(entry.getValue()) < Double.parseDouble(lowerLimit)) {
//数值低于对应福利明细下限
return false;
}
if (upperLimit != null && upperLimit.length() > 0 && Double.parseDouble(entry.getValue()) > Double.parseDouble(upperLimit)) {
//数值高于对应福利明细上限
return false;
}
}
return true;
}
/**
* 档案列表
* <p>
@ -840,8 +906,8 @@ public class SIArchivesBiz {
SocialSchemeMapper socialSchemeMapper = sqlSession.getMapper(SocialSchemeMapper.class);
List<InsuranceArchivesEmployeePO> page = new ArrayList<>();
PageInfo<InsuranceArchivesEmployeePO> pageInfo = new PageInfo<>(InsuranceArchivesEmployeePO.class);
//生成福利档案历史基础信息在福利档案基础信息表为空时
createOldInsuranceBaseInfo(operateId);
// //生成福利档案历史基础信息在福利档案基础信息表为空时
// createOldInsuranceBaseInfo(operateId);
//获取福利档案列表数据
if (needAuth) {
Collection<Long> taxAgentEmployeeIds = param.getTaxAgentEmployeeIds();
@ -1343,7 +1409,7 @@ public class SIArchivesBiz {
/**
* 判断是否需要生成历史福利档案基本信息
*/
private void createOldInsuranceBaseInfo(Long creator) {
public void createOldInsuranceBaseInfo(Long creator) {
List<InsuranceArchivesBaseInfoPO> nowBaseInfoList = getInsuranceBaseInfoMapper().getInsuranceBaseInfoList();
if (nowBaseInfoList.size() == 0) {
List<InsuranceArchivesBaseInfoPO> addBaseInfoList = new ArrayList<>();
@ -1369,4 +1435,18 @@ public class SIArchivesBiz {
}
/**
* 判断字符串是否为整数或者小数或者负数
*/
public static boolean isNumeric(String str){
Pattern pattern = Pattern.compile("^-?\\d+(\\.\\d+)?$");
Matcher isNum = pattern.matcher(str);
if (!isNum.matches()) {
return false;
}
return true;
}
}

View File

@ -38,8 +38,8 @@ public class InsuranceArchivesFundSaveParam {
//公积金方案id
private Long fundSchemeId;
//公积金方案id
private Long fundName;
//公积金方案名称
private String fundName;
//公积金账号
private String fundAccount;

View File

@ -39,8 +39,8 @@ public class InsuranceArchivesOtherSaveParam {
//其他福利方案id
private Long otherSchemeId;
//其他福利方案id")
private Long otherName;
//其他福利方案名称
private String otherName;
//其他福利缴纳组织
private Long paymentOrganization;

View File

@ -39,9 +39,8 @@ public class InsuranceArchivesSocialSaveParam {
//社保方案id
private Long socialSchemeId;
//社保方案id
//todo 前端需要调整
private Long socialName;
//社保方案名称
private String socialName;
//社保账号
private String schemeAccount;

View File

@ -134,6 +134,8 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService
public Map<String, Object> listPage(InsuranceArchivesListParam param) {
long currentEmployeeId = user.getUID();
// 1.历史数据处理
siArchivesBiz.createOldInsuranceBaseInfo(currentEmployeeId);
// 2.待减员自动处理
handleStayDelData(currentEmployeeId);
// 3.增量数据处理

View File

@ -64,6 +64,7 @@ import org.apache.commons.lang3.math.NumberUtils;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.util.IOUtils;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.xpath.operations.Bool;
import weaver.file.ImageFileManager;
import weaver.hrm.User;
@ -935,7 +936,34 @@ public class SISchemeServiceImpl extends Service implements SISchemeService {
insuranceArchivesAccountPO.setFund(insuranceArchivesFundSchemePO);
insuranceArchivesAccountPO.setOther(insuranceArchivesOtherSchemePO);
insuranceArchivesAccountPO.setBaseInfo(insuranceArchivesBaseInfoPO);
insuranceArchivesAccountPOS.add(insuranceArchivesAccountPO);
//校验福利基数是否符合上下限要求
Boolean socialCheckBase = siArchivesBiz.checkWelBaseLimit(insuranceArchivesSocialSchemePO.getSocialSchemeId(), insuranceArchivesSocialSchemePO.getSocialPaymentBaseString());
Boolean fundCheckBase = siArchivesBiz.checkWelBaseLimit(insuranceArchivesFundSchemePO.getFundSchemeId(), insuranceArchivesFundSchemePO.getFundPaymentBaseString());
Boolean otherCheckBase = siArchivesBiz.checkWelBaseLimit(insuranceArchivesOtherSchemePO.getOtherSchemeId(), insuranceArchivesOtherSchemePO.getOtherPaymentBaseString());
if (socialCheckBase && fundCheckBase && otherCheckBase) {
insuranceArchivesAccountPOS.add(insuranceArchivesAccountPO);
} else {
String checkMessage = "该条数据中";
if (!socialCheckBase) {
checkMessage = checkMessage + "社保福利基数、";
}
if (!fundCheckBase) {
checkMessage = checkMessage + "公积金福利基数、";
}
if (!otherCheckBase) {
checkMessage = checkMessage + "其他福利基数、";
}
checkMessage = checkMessage.substring(0, checkMessage.length() - 1);
Map<String, String> errorMessageMap = Maps.newHashMap();
errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100312, checkMessage + "数值超出相关福利方案的基数上下限要求,不可导入!"));
excelComments.add(errorMessageMap);
isError = true;
}
}
return isError;
}