Commit 5acd40f1 authored by huyuchen's avatar huyuchen

实缴导入校验项目

parent f3c6dda7
......@@ -800,8 +800,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
redisUtil.set(importSuccessKey, maerialRatio, 360L);
try {
// 1.list.size()不足partSize,直接执行
if (list.size() < partSize) {
// 1.list.size()不足100时直接执行
if (list.size() < 100) {
CompletableFuture<List<ErrorDetailVO>> listCompletableFuture = CompletableFuture.supplyAsync(() ->
executeImportSocialList(user, list, areaMap, areaMap2,domainMap,
paymentInfoPensionMap, paymentInfoBigMap, paymentInfoBirMap,
......@@ -810,13 +810,11 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
injuryMoneyMap, medicalMoneyMap, accrualMoneyMap, paymentInfoaccrualMap
), yfSocialImportThreadPoolExecutor);
completableFutureList.add(listCompletableFuture);
}
// 2.list.size()大于partSize,循环分批执行
int lastIdx = 0;
if (partSize <= list.size()) {
// 处理第一个0位元素
final List<TPaymentInfoVo> finalList = list.subList(0, 1);
} else {
int j = 25;
for (int i = 0; i < 100; i = i + 25) {
// 单个线程每次执行25条
final List<TPaymentInfoVo> finalList = list.subList(i,i+j);
CompletableFuture<List<ErrorDetailVO>> listCompletableFuture = CompletableFuture.supplyAsync(() ->
executeImportSocialList(user, finalList, areaMap, areaMap2,domainMap,
paymentInfoPensionMap, paymentInfoBigMap, paymentInfoBirMap,
......@@ -825,50 +823,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
injuryMoneyMap, medicalMoneyMap, accrualMoneyMap, paymentInfoaccrualMap
), yfSocialImportThreadPoolExecutor);
completableFutureList.add(listCompletableFuture);
lastIdx = 1;
for (int i = 1; i < list.size(); i++) {
// partSize数量的list为一个执行单元
tempList.add(list.get(i));
if (i % partSize == 0) {
lastIdx = i;
List<TPaymentInfoVo> finalTempList = tempList;
CompletableFuture<List<ErrorDetailVO>> oneCompletableFuture = CompletableFuture.supplyAsync(() ->
executeImportSocialList(user, finalTempList, areaMap, areaMap2,domainMap,
paymentInfoPensionMap, paymentInfoBigMap, paymentInfoBirMap,
paymentInfoMedicalMap, paymentInfoUnEmpMap, paymentInfoInjuryMap,
errorMessageList, pensionMoneyMap, bigMoneyMap, unEmpMoneyMap, birMoneyMap,
injuryMoneyMap, medicalMoneyMap, accrualMoneyMap, paymentInfoaccrualMap
), yfSocialImportThreadPoolExecutor);
completableFutureList.add(oneCompletableFuture);
tempList = new ArrayList<>();
}
}
}
// 3.第2种方式执行完后,有余数的情况下,执行3
if (lastIdx != 0) {
tempList = new ArrayList<>();
if (lastIdx == 1) {
for (int i = lastIdx; i < list.size(); i++) {
tempList.add(list.get(i));
}
} else {
for (int i = lastIdx + 1; i < list.size(); i++) {
tempList.add(list.get(i));
}
lastIdx += 1;
}
List<TPaymentInfoVo> finalTempList = tempList;
CompletableFuture<List<ErrorDetailVO>> listCompletableFuture = CompletableFuture.supplyAsync(() ->
executeImportSocialList(user, finalTempList, areaMap, areaMap2,domainMap,
paymentInfoPensionMap, paymentInfoBigMap, paymentInfoBirMap,
paymentInfoMedicalMap, paymentInfoUnEmpMap, paymentInfoInjuryMap,
errorMessageList, pensionMoneyMap, bigMoneyMap, unEmpMoneyMap, birMoneyMap,
injuryMoneyMap, medicalMoneyMap, accrualMoneyMap, paymentInfoaccrualMap
), yfSocialImportThreadPoolExecutor);
completableFutureList.add(listCompletableFuture);
}
// 阻塞当前线程,等待所有的线程执行完毕
boolean computeFlag;
......@@ -2116,7 +2071,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
redisUtil.set(importSuccessKey, maerialRatio, 360L);
try {
// 1.list.size()不足partSize,直接执行
// 1.list.size()不足100时直接执行
if (list.size() < 100) {
CompletableFuture<ConcurrentHashMap<String, ErrorDetailVO>> listCompletableFuture = CompletableFuture.supplyAsync(()
-> executeImportSocialListThree(list, areaMap, areaMap2,
......@@ -2129,7 +2084,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
} else {
int j = 25;
for (int i = 0; i < 100; i = i + 25) {
// partSize数量的list为一个执行单元
// 单个线程每次执行25条
List<TPaymentHeFeiVo> finalTempList1 = list.subList(i,i+j);
CompletableFuture<ConcurrentHashMap<String, ErrorDetailVO>> listCompletableFuture = CompletableFuture.supplyAsync(()
-> executeImportSocialListThree(finalTempList1
......
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