Commit 283420fd authored by huyuchen's avatar huyuchen

预派单 参数校验修改

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