Commit 5acd40f1 authored by huyuchen's avatar huyuchen

实缴导入校验项目

parent f3c6dda7
...@@ -800,8 +800,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -800,8 +800,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
redisUtil.set(importSuccessKey, maerialRatio, 360L); redisUtil.set(importSuccessKey, maerialRatio, 360L);
try { try {
// 1.list.size()不足partSize,直接执行 // 1.list.size()不足100时直接执行
if (list.size() < partSize) { if (list.size() < 100) {
CompletableFuture<List<ErrorDetailVO>> listCompletableFuture = CompletableFuture.supplyAsync(() -> CompletableFuture<List<ErrorDetailVO>> listCompletableFuture = CompletableFuture.supplyAsync(() ->
executeImportSocialList(user, list, areaMap, areaMap2,domainMap, executeImportSocialList(user, list, areaMap, areaMap2,domainMap,
paymentInfoPensionMap, paymentInfoBigMap, paymentInfoBirMap, paymentInfoPensionMap, paymentInfoBigMap, paymentInfoBirMap,
...@@ -810,65 +810,20 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -810,65 +810,20 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
injuryMoneyMap, medicalMoneyMap, accrualMoneyMap, paymentInfoaccrualMap injuryMoneyMap, medicalMoneyMap, accrualMoneyMap, paymentInfoaccrualMap
), yfSocialImportThreadPoolExecutor); ), yfSocialImportThreadPoolExecutor);
completableFutureList.add(listCompletableFuture); completableFutureList.add(listCompletableFuture);
} } else {
int j = 25;
// 2.list.size()大于partSize,循环分批执行 for (int i = 0; i < 100; i = i + 25) {
int lastIdx = 0; // 单个线程每次执行25条
if (partSize <= list.size()) { final List<TPaymentInfoVo> finalList = list.subList(i,i+j);
// 处理第一个0位元素 CompletableFuture<List<ErrorDetailVO>> listCompletableFuture = CompletableFuture.supplyAsync(() ->
final List<TPaymentInfoVo> finalList = list.subList(0, 1); executeImportSocialList(user, finalList, areaMap, areaMap2,domainMap,
CompletableFuture<List<ErrorDetailVO>> listCompletableFuture = CompletableFuture.supplyAsync(() -> paymentInfoPensionMap, paymentInfoBigMap, paymentInfoBirMap,
executeImportSocialList(user, finalList, areaMap, areaMap2,domainMap, paymentInfoMedicalMap, paymentInfoUnEmpMap, paymentInfoInjuryMap,
paymentInfoPensionMap, paymentInfoBigMap, paymentInfoBirMap, errorMessageList, pensionMoneyMap, bigMoneyMap, unEmpMoneyMap, birMoneyMap,
paymentInfoMedicalMap, paymentInfoUnEmpMap, paymentInfoInjuryMap, injuryMoneyMap, medicalMoneyMap, accrualMoneyMap, paymentInfoaccrualMap
errorMessageList, pensionMoneyMap, bigMoneyMap, unEmpMoneyMap, birMoneyMap, ), yfSocialImportThreadPoolExecutor);
injuryMoneyMap, medicalMoneyMap, accrualMoneyMap, paymentInfoaccrualMap completableFutureList.add(listCompletableFuture);
), 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; boolean computeFlag;
...@@ -2116,7 +2071,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -2116,7 +2071,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
redisUtil.set(importSuccessKey, maerialRatio, 360L); redisUtil.set(importSuccessKey, maerialRatio, 360L);
try { try {
// 1.list.size()不足partSize,直接执行 // 1.list.size()不足100时直接执行
if (list.size() < 100) { if (list.size() < 100) {
CompletableFuture<ConcurrentHashMap<String, ErrorDetailVO>> listCompletableFuture = CompletableFuture.supplyAsync(() CompletableFuture<ConcurrentHashMap<String, ErrorDetailVO>> listCompletableFuture = CompletableFuture.supplyAsync(()
-> executeImportSocialListThree(list, areaMap, areaMap2, -> executeImportSocialListThree(list, areaMap, areaMap2,
...@@ -2129,7 +2084,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -2129,7 +2084,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
} else { } else {
int j = 25; int j = 25;
for (int i = 0; i < 100; i = i + 25) { for (int i = 0; i < 100; i = i + 25) {
// partSize数量的list为一个执行单元 // 单个线程每次执行25条
List<TPaymentHeFeiVo> finalTempList1 = list.subList(i,i+j); List<TPaymentHeFeiVo> finalTempList1 = list.subList(i,i+j);
CompletableFuture<ConcurrentHashMap<String, ErrorDetailVO>> listCompletableFuture = CompletableFuture.supplyAsync(() CompletableFuture<ConcurrentHashMap<String, ErrorDetailVO>> listCompletableFuture = CompletableFuture.supplyAsync(()
-> executeImportSocialListThree(finalTempList1 -> 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