Commit 283420fd authored by huyuchen's avatar huyuchen

预派单 参数校验修改

parent 72d3d523
......@@ -38,16 +38,6 @@ import java.util.Date;
@Data
public class TPaymentInfoVo extends RowIndex implements Serializable {
/**
* 主键
*/
@TableId(type = IdType.ASSIGN_ID)
@NotBlank(message = "主键 不能为空")
@Length(max = 32, message = "主键 不能超过32 个字符")
@ExcelAttribute(name = "主键", isNotEmpty = true, errorInfo = "主键 不能为空", maxLength = 32)
@Schema(description = "主键")
@ExcelProperty("主键")
private String id;
/**
* 员工姓名
*/
......@@ -69,7 +59,7 @@ public class TPaymentInfoVo extends RowIndex implements Serializable {
*/
@NotBlank(message = "员工ID 不能为空")
@Length(max = 32, message = "员工ID 不能超过32 个字符")
@ExcelAttribute(name = "员工ID", isNotEmpty = true, errorInfo = "员工ID 不能为空", maxLength = 32)
@ExcelAttribute(name = "员工ID", maxLength = 32)
@Schema(description = "员工ID")
@ExcelProperty("员工ID")
private String empId;
......
......@@ -34,7 +34,6 @@ import com.yifu.cloud.plus.v1.yifu.social.concurrent.threadpool.YFSocialImportTh
import com.yifu.cloud.plus.v1.yifu.social.constants.PaymentConstants;
import com.yifu.cloud.plus.v1.yifu.social.constants.SocialConstants;
import com.yifu.cloud.plus.v1.yifu.social.entity.TPaymentInfo;
import com.yifu.cloud.plus.v1.yifu.social.entity.TPaymentInfoImportLog;
import com.yifu.cloud.plus.v1.yifu.social.entity.TProvidentFund;
import com.yifu.cloud.plus.v1.yifu.social.entity.TSocialInfo;
import com.yifu.cloud.plus.v1.yifu.social.mapper.TPaymentInfoMapper;
......@@ -91,7 +90,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
@Autowired
private RedisUtil redisUtil;
@Qualifier("yfSocialImportThreadPoolExecutor")
@Autowired
private YFSocialImportThreadPoolExecutor yfSocialImportThreadPoolExecutor;
@Autowired
......@@ -374,7 +373,6 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
int residualCapacity = yfSocialImportThreadPoolExecutor.getResidualCapacity();
if (taskSize > residualCapacity) {
errorMessageList.add(new ErrorMessage(-1, MsgUtils.getMessage(ErrorCodes.SOCIALINFO_LIST_NUM_LARGE)));
}
}else {
// -----------------------------生成paymentInfoMap本段开始--------------------------------
//已存在的档案数据
......@@ -482,14 +480,16 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
// -----------------------------线程池处理list,批量保存社保信息开始--------------------------------
List<TPaymentInfoVo> tempList = new ArrayList<>();
AtomicInteger atomicLine = new AtomicInteger(CommonConstants.ZERO_INT);
List<CompletableFuture<List<ErrorMessage>>> completableFutureList = new ArrayList<>();
try {
// 1.list.size()不足partSize,直接执行
if (list.size() < partSize) {
CompletableFuture.supplyAsync(() ->
CompletableFuture<List<ErrorMessage>> listCompletableFuture = CompletableFuture.supplyAsync(() ->
executeImportSocialList(user, atomicLine, random, list, areaMap, areaMap2,
paymentInfoPensionMap, paymentInfoBigMap, paymentInfoBirMap,
paymentInfoMedicalMap, paymentInfoUnEmpMap, paymentInfoInjuryMap,
CommonConstants.ONE_INT, errorMessageList), yfSocialImportThreadPoolExecutor);
completableFutureList.add(listCompletableFuture);
}
// 2.list.size()大于partSize,循环分批执行
......@@ -497,11 +497,13 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
if (partSize <= list.size()) {
// 处理第一个0位元素
final List<TPaymentInfoVo> finalList = list.subList(0, 1);
CompletableFuture.supplyAsync(() ->
CompletableFuture<List<ErrorMessage>> listCompletableFuture = CompletableFuture.supplyAsync(() ->
executeImportSocialList(user, atomicLine, random, list, areaMap, areaMap2,
paymentInfoPensionMap, paymentInfoBigMap, paymentInfoBirMap,
paymentInfoMedicalMap, paymentInfoUnEmpMap, paymentInfoInjuryMap,
CommonConstants.ONE_INT, errorMessageList), yfSocialImportThreadPoolExecutor);
completableFutureList.add(listCompletableFuture);
lastIdx = 1;
for (int i = 1; i < list.size(); i++) {
// partSize数量的list为一个执行单元
......@@ -536,12 +538,24 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
List<TPaymentInfoVo> finalTempList = tempList;
int finalLastIdx = lastIdx + 1;
CompletableFuture.supplyAsync(() ->
CompletableFuture<List<ErrorMessage>> listCompletableFuture = CompletableFuture.supplyAsync(() ->
executeImportSocialList(user, atomicLine, random, list, areaMap, areaMap2,
paymentInfoPensionMap, paymentInfoBigMap, paymentInfoBirMap,
paymentInfoMedicalMap, paymentInfoUnEmpMap, paymentInfoInjuryMap,
finalLastIdx, errorMessageList), yfSocialImportThreadPoolExecutor);
completableFutureList.add(listCompletableFuture);
}
// 阻塞当前线程,等待所有的线程执行完毕
boolean computeFlag;
do {
computeFlag = false;
for (CompletableFuture<List<ErrorMessage>> listCompletableFuture : completableFutureList) {
if (!listCompletableFuture.isDone()) {
computeFlag = true;
}
}
} while (computeFlag);
String importSuccessKey = user.getId() + CommonConstants.DOWN_LINE_STRING + CommonConstants.PAYMENT_SOCIAL_WAIT_EXPORT;
redisUtil.set(importSuccessKey, random, 1800L);
......@@ -564,6 +578,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
}
}
}
}
/**
* 转换缴纳地址为省市县ID
......@@ -723,7 +738,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
}
if (null == socialInfo || (null != socialInfo && !ServiceUtil.checkMothForPaymentImport(
socialInfo.getSocialStartDate(), infoVo.getSocialPayMonth(), socialInfo.getSocialReduceDate()))) {
if (null != socialMapTemp) {
if (socialMapTemp.size() > CommonConstants.ZERO_INT) {
socialInfo = socialMapTemp.get(infoVo.getEmpIdcard()
+ CommonConstants.DOWN_LINE_STRING + infoVo.getSocialProvince()
+ CommonConstants.DOWN_LINE_STRING + infoVo.getSocialCity()
......@@ -752,8 +767,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
}
}
if (null == socialInfo) {
errorMessageList.add(new ErrorMessage(infoVo.getRowIndex(), infoVo.getEmpIdcard() +
"无对应员工" + infoVo.getEmpIdcard() + "的社保数据(请查验社保办理状态|缴纳地|起缴月份|停缴月份)"));
errorMessageList.add(new ErrorMessage(infoVo.getRowIndex(), "无对应员工" +
infoVo.getEmpIdcard() + "的社保数据(请查验社保办理状态|缴纳地|起缴月份|停缴月份)"));
continue;
}
//如果导入项目数大于办理成功项目数给提示,少于给进,有问题自行删除后导入
......@@ -1007,7 +1022,6 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
paymentInfo.setSocialSum(BigDecimalUtils.safeAdd(
paymentInfo.getUnitSocialSum(), paymentInfo.getSocialSecurityPersonalSum()));
paymentInfo.setSumAll(paymentInfo.getSocialSum());
paymentInfo.setUpdateBy(user.getId());
if (null != paymentInfo && Common.isEmpty(paymentInfo.getSocialId())) {
paymentInfo.setSocialId(UUID.randomUUID().toString());
}
......@@ -1648,13 +1662,15 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
// -----------------------------线程池处理list,批量保存社保信息开始--------------------------------
List<TPaymentHeFeiVo> tempList = new ArrayList<>();
AtomicInteger atomicLine = new AtomicInteger(CommonConstants.ZERO_INT);
List<CompletableFuture<List<ErrorMessage>>> completableFutureList = new ArrayList<>();
try {
// 1.list.size()不足partSize,直接执行
if (list.size() < partSize) {
CompletableFuture.supplyAsync(() -> executeImportSocialListThree(
user, atomicLine, random, list, areaMap, areaMap2, paymentInfoPensionMap,
paymentInfoMedicalMap, paymentInfoUnEmpMap, paymentInfoInjuryMap,
CompletableFuture<List<ErrorMessage>> listCompletableFuture = CompletableFuture.supplyAsync(()
-> executeImportSocialListThree(user, atomicLine, random, list, areaMap, areaMap2,
paymentInfoPensionMap, paymentInfoMedicalMap, paymentInfoUnEmpMap, paymentInfoInjuryMap,
CommonConstants.ONE_INT, type, errorMessageList), yfSocialImportThreadPoolExecutor);
completableFutureList.add(listCompletableFuture);
}
// 2.list.size()大于partSize,循环分批执行
......@@ -1662,11 +1678,12 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
if (partSize <= list.size()) {
// 处理第一个0位元素
final List<TPaymentHeFeiVo> finalList = list.subList(0, 1);
CompletableFuture.supplyAsync(() -> executeImportSocialListThree(
user, atomicLine, random, finalList, areaMap, areaMap2,
paymentInfoPensionMap, paymentInfoMedicalMap, paymentInfoUnEmpMap,
CompletableFuture<List<ErrorMessage>> oneCompletableFuture = CompletableFuture.supplyAsync(()
-> executeImportSocialListThree(user, atomicLine, random, finalList, areaMap,
areaMap2, paymentInfoPensionMap, paymentInfoMedicalMap, paymentInfoUnEmpMap,
paymentInfoInjuryMap, CommonConstants.ONE_INT, type, errorMessageList)
, yfSocialImportThreadPoolExecutor);
completableFutureList.add(oneCompletableFuture);
lastIdx = 1;
for (int i = 1; i < list.size(); i++) {
// partSize数量的list为一个执行单元
......@@ -1675,11 +1692,12 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
lastIdx = i;
final int idx = i - partSize + 2;
List<TPaymentHeFeiVo> finalTempList1 = tempList;
CompletableFuture.supplyAsync(() -> executeImportSocialListThree(user
, atomicLine, random, finalTempList1, areaMap,
areaMap2, paymentInfoPensionMap, paymentInfoMedicalMap, paymentInfoUnEmpMap,
paymentInfoInjuryMap, idx, type, errorMessageList)
CompletableFuture<List<ErrorMessage>> listCompletableFuture = CompletableFuture.supplyAsync(()
-> executeImportSocialListThree(user, atomicLine, random, finalTempList1
, areaMap, areaMap2, paymentInfoPensionMap, paymentInfoMedicalMap,
paymentInfoUnEmpMap, paymentInfoInjuryMap, idx, type, errorMessageList)
, yfSocialImportThreadPoolExecutor);
completableFutureList.add(listCompletableFuture);
tempList = new ArrayList<>();
}
}
......@@ -1701,12 +1719,24 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
List<TPaymentHeFeiVo> finalTempList = tempList;
int finalLastIdx = lastIdx + 1;
CompletableFuture.supplyAsync(() -> executeImportSocialListThree(
user, atomicLine, random, finalTempList, areaMap,
CompletableFuture<List<ErrorMessage>> listCompletableFuture = CompletableFuture.supplyAsync(()
-> executeImportSocialListThree(user, atomicLine, random, finalTempList, areaMap,
areaMap2, paymentInfoPensionMap, paymentInfoMedicalMap, paymentInfoUnEmpMap,
paymentInfoInjuryMap, finalLastIdx, type, errorMessageList)
, yfSocialImportThreadPoolExecutor);
completableFutureList.add(listCompletableFuture);
}
// 阻塞当前线程,等待所有的线程执行完毕
boolean computeFlag;
do {
computeFlag = false;
for (CompletableFuture<List<ErrorMessage>> listCompletableFuture : completableFutureList) {
if (!listCompletableFuture.isDone()) {
computeFlag = true;
}
}
} while (computeFlag);
String importSuccessKey = user.getId() + CommonConstants.DOWN_LINE_STRING + CommonConstants.PAYMENT_SOCIAL_WAIT_EXPORT;
redisUtil.set(importSuccessKey, random, 1800L);
......
......@@ -87,12 +87,12 @@ public class ServiceUtil {
public static boolean checkMothForPaymentImport(Date socialStartDate, String socialPayMonth, Date reduceDate) {
if(socialStartDate != null) {
if (null == reduceDate){
if(Integer.parseInt(socialPayMonth) >= Integer.parseInt(DateUtil.dateToString(socialStartDate))){
if(Integer.parseInt(socialPayMonth) >= Integer.parseInt(DateUtil.dateToString(socialStartDate).replace("-",""))){
return true;
}
}else {
if(Integer.parseInt(socialPayMonth) >= Integer.parseInt(DateUtil.dateToString(socialStartDate))
&& Integer.parseInt(socialPayMonth) < Integer.parseInt(DateUtil.dateToString(reduceDate))){
&& Integer.parseInt(socialPayMonth) < Integer.parseInt(DateUtil.dateToString(reduceDate).replace("-",""))){
return true;
}
}
......
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.yifu.cloud.plus.v1.yifu.social.concurrent.threadpool.YFThreadPoolConfig
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