Commit 27f36a3a authored by huyuchen's avatar huyuchen

优化修改

parent 57b0a72f
......@@ -48,7 +48,6 @@ public class TPaymentInfo extends BaseEntity {
/**
* 主键
*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description ="主键")
private String id;
......
......@@ -1429,13 +1429,13 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
redisUtil.remove(importSuccessKey);
}
//养老插入的集合
List<TPaymentInfo> batchYlInsertList = new ArrayList<>();
ConcurrentHashMap<String,TPaymentInfo> batchYlInsertList = new ConcurrentHashMap<>();
//工伤插入的集合
List<TPaymentInfo> batchGsInsertList = new ArrayList<>();
ConcurrentHashMap<String,TPaymentInfo> batchGsInsertList = new ConcurrentHashMap<>();
//失业插入的集合
List<TPaymentInfo> batchSyInsertList = new ArrayList<>();
ConcurrentHashMap<String,TPaymentInfo> batchSyInsertList = new ConcurrentHashMap<>();
//医疗插入的集合
List<TPaymentInfo> batchYyInsertList = new ArrayList<>();
ConcurrentHashMap<String,TPaymentInfo> batchYyInsertList = new ConcurrentHashMap<>();
//获取所有项目信息
Map<String, TSettleDomainSelectVo> domainMap = this.getSelectVoMapById();
//地区数据
......@@ -1522,21 +1522,34 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
areaMap2.clear();
domainMap.clear();
//批量插入数据
//养老
List<TPaymentInfo> list;
if (!batchYlInsertList.isEmpty()) {
this.saveBatch(batchYlInsertList);
list = new ArrayList<>(batchYlInsertList.values());
this.saveBatch(list);
batchYlInsertList.clear();
list.clear();
}
//工伤
if (!batchGsInsertList.isEmpty()) {
this.saveBatch(batchGsInsertList);
list = new ArrayList<>(batchYlInsertList.values());
this.saveBatch(list);
batchGsInsertList.clear();
list.clear();
}
//医疗
if (!batchYyInsertList.isEmpty()) {
this.saveBatch(batchYyInsertList);
list = new ArrayList<>(batchYlInsertList.values());
this.saveBatch(list);
batchYyInsertList.clear();
list.clear();
}
//失业
if (!batchSyInsertList.isEmpty()) {
this.saveBatch(batchSyInsertList);
list = new ArrayList<>(batchYlInsertList.values());
this.saveBatch(list);
batchSyInsertList.clear();
list.clear();
}
} catch (Exception e) {
log.error(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR, e);
......@@ -1809,7 +1822,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
paymentInfo.setProvidentHousehold(tProvidentFund.getProvidentHouseholdName());
}
if (Common.isNotNull(tProvidentFund)) {
paymentInfo.setInauguralTeam(Common.isEmpty(tProvidentFund.getInauguralTeam()) ? tProvidentFund.getInauguralTeam(): "");
paymentInfo.setInauguralTeam(Common.isNotNull(tProvidentFund.getInauguralTeam()) ? tProvidentFund.getInauguralTeam(): "");
paymentInfo.setEmpNo(tProvidentFund.getEmpNo());
} else {
paymentInfo.setInauguralTeam("");
......@@ -1875,10 +1888,10 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
ConcurrentHashMap<String, BigDecimal> injuryMoneyMap,
ConcurrentHashMap<String, BigDecimal> medicalMoneyMap,
String sumNumKey, String importSuccessKey,
List<TPaymentInfo> batchGsInsertList,
List<TPaymentInfo> batchSyInsertList,
List<TPaymentInfo> batchYlInsertList,
List<TPaymentInfo> batchYyInsertList,
ConcurrentHashMap<String,TPaymentInfo> batchGsInsertList,
ConcurrentHashMap<String,TPaymentInfo> batchSyInsertList,
ConcurrentHashMap<String,TPaymentInfo> batchYlInsertList,
ConcurrentHashMap<String,TPaymentInfo> batchYyInsertList,
HashMap<String, String> areaMap,
HashMap<String, String> areaMap2,Map<String,TSettleDomainSelectVo> domainMap) {
......@@ -2034,8 +2047,6 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
// -----------------------------生成paymentInfoMap本段结束--------------------------------
// -----------------------------线程池处理list,批量保存社保信息开始--------------------------------
List<TPaymentHeFeiVo> tempList = new ArrayList<>();
List<CompletableFuture<List<ErrorDetailVO>>> completableFutureList = new ArrayList<>();
// 创建一个数值格式化对象
......@@ -2065,7 +2076,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
try {
// 1.list.size()不足partSize,直接执行
if (list.size() < partSize) {
if (list.size() < 100) {
CompletableFuture<List<ErrorDetailVO>> listCompletableFuture = CompletableFuture.supplyAsync(()
-> executeImportSocialListThree(list, areaMap, areaMap2,
paymentInfoPensionMap, paymentInfoMedicalMap, paymentInfoUnEmpMap, paymentInfoInjuryMap,
......@@ -2074,65 +2085,21 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
batchSyInsertList, batchYlInsertList, batchYyInsertList,domainMap),
yfSocialImportThreadPoolExecutor);
completableFutureList.add(listCompletableFuture);
}
// 2.list.size()大于partSize,循环分批执行
int lastIdx = 0;
if (partSize <= list.size()) {
// 处理第一个0位元素
final List<TPaymentHeFeiVo> finalList = list.subList(0, 1);
CompletableFuture<List<ErrorDetailVO>> oneCompletableFuture = CompletableFuture.supplyAsync(()
-> executeImportSocialListThree(finalList, areaMap,
areaMap2, paymentInfoPensionMap, paymentInfoMedicalMap, paymentInfoUnEmpMap,
paymentInfoInjuryMap, paymentInfoBigMap, type,
errorMessageList, pensionMoneyMap, bigMoneyMap, unEmpMoneyMap, injuryMoneyMap,
medicalMoneyMap,batchGsInsertList, batchSyInsertList, batchYlInsertList,
batchYyInsertList,domainMap), yfSocialImportThreadPoolExecutor);
completableFutureList.add(oneCompletableFuture);
lastIdx = 1;
for (int i = 1; i < list.size(); i++) {
} else {
int j = 25;
for (int i = 0; i < 100; i = i + 25) {
// partSize数量的list为一个执行单元
tempList.add(list.get(i));
if (i % partSize == 0) {
lastIdx = i;
List<TPaymentHeFeiVo> finalTempList1 = tempList;
List<TPaymentHeFeiVo> finalTempList1 = list.subList(i,i+j);
CompletableFuture<List<ErrorDetailVO>> listCompletableFuture = CompletableFuture.supplyAsync(()
-> executeImportSocialListThree(finalTempList1
, areaMap, areaMap2, paymentInfoPensionMap, paymentInfoMedicalMap,
paymentInfoUnEmpMap, paymentInfoInjuryMap, paymentInfoBigMap, type,
errorMessageList, pensionMoneyMap, bigMoneyMap, unEmpMoneyMap,
injuryMoneyMap, medicalMoneyMap,batchGsInsertList, batchSyInsertList,
batchYlInsertList, batchYyInsertList,domainMap),
injuryMoneyMap, medicalMoneyMap, batchGsInsertList, batchSyInsertList,
batchYlInsertList, batchYyInsertList, domainMap),
yfSocialImportThreadPoolExecutor);
completableFutureList.add(listCompletableFuture);
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<TPaymentHeFeiVo> finalTempList = tempList;
CompletableFuture<List<ErrorDetailVO>> listCompletableFuture = CompletableFuture.supplyAsync(()
-> executeImportSocialListThree(finalTempList, areaMap,
areaMap2, paymentInfoPensionMap, paymentInfoMedicalMap, paymentInfoUnEmpMap,
paymentInfoInjuryMap, paymentInfoBigMap, type, errorMessageList, pensionMoneyMap,
bigMoneyMap, unEmpMoneyMap, injuryMoneyMap, medicalMoneyMap,batchGsInsertList,
batchSyInsertList, batchYlInsertList, batchYyInsertList,domainMap)
, yfSocialImportThreadPoolExecutor);
completableFutureList.add(listCompletableFuture);
}
// 阻塞当前线程,等待所有的线程执行完毕
......@@ -2146,8 +2113,18 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
}
} while (computeFlag);
paymentInfoBigMap.clear();
paymentInfoInjuryMap.clear();
paymentInfoUnEmpMap.clear();
paymentInfoPensionMap.clear();
paymentInfoMedicalMap.clear();
} catch (Exception e) {
log.error("社保缴费库数据批量导入异常:" + e);
paymentInfoBigMap.clear();
paymentInfoInjuryMap.clear();
paymentInfoUnEmpMap.clear();
paymentInfoPensionMap.clear();
paymentInfoMedicalMap.clear();
}
}
}
......@@ -2167,10 +2144,10 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
ConcurrentHashMap<String, BigDecimal> unEmpMoneyMap,
ConcurrentHashMap<String, BigDecimal> injuryMoneyMap,
ConcurrentHashMap<String, BigDecimal> medicalMoneyMap,
List<TPaymentInfo> batchGsInsertList,
List<TPaymentInfo> batchSyInsertList,
List<TPaymentInfo> batchYlInsertList,
List<TPaymentInfo> batchYyInsertList,
ConcurrentHashMap<String, TPaymentInfo> batchGsInsertList,
ConcurrentHashMap<String, TPaymentInfo> batchSyInsertList,
ConcurrentHashMap<String, TPaymentInfo> batchYlInsertList,
ConcurrentHashMap<String, TPaymentInfo> batchYyInsertList,
Map<String,TSettleDomainSelectVo> domainMap) {
if (Common.isNotNull(list)) {
TPaymentInfo payExists;
......@@ -2250,6 +2227,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
"的社保数据(请查验社保缴纳地)"));
continue;
}
} else {
tSocialInfo = null;
}
//判断是否存在养老缴费数据
......@@ -2458,10 +2437,10 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
payExists.setEmpIdcard(socialInfo.getEmpIdcard());
payExists.setEmpName(socialInfo.getEmpName());
payExists.setSettleDomainId(socialInfo.getSettleDomain());
payExists.setSettleDomainCode(Common.isEmpty(socialInfo.getSettleDomainCode()) ? socialInfo.getSettleDomainCode(): "");
payExists.setUnitId(Common.isEmpty(socialInfo.getUnitId()) ? socialInfo.getUnitId(): "");
payExists.setSettleDomainName(Common.isEmpty(socialInfo.getSettleDomainName()) ? socialInfo.getSettleDomainName(): "");
payExists.setUnitName(Common.isEmpty(socialInfo.getUnitName()) ? socialInfo.getUnitName(): "");
payExists.setSettleDomainCode(Common.isNotNull(socialInfo.getSettleDomainCode()) ? socialInfo.getSettleDomainCode(): "");
payExists.setUnitId(Common.isNotNull(socialInfo.getUnitId()) ? socialInfo.getUnitId(): "");
payExists.setSettleDomainName(Common.isNotNull(socialInfo.getSettleDomainName()) ? socialInfo.getSettleDomainName(): "");
payExists.setUnitName(Common.isNotNull(socialInfo.getUnitName()) ? socialInfo.getUnitName(): "");
payExists.setSocialProvince(socialInfo.getSocialProvince());
payExists.setSocialCity(socialInfo.getSocialCity());
payExists.setSocialTown(socialInfo.getSocialTown());
......@@ -2477,10 +2456,10 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
domain = null;
}
if (Common.isNotNull(domain)) {
payExists.setSettleDomainName(Common.isEmpty(domain.getDepartName()) ? domain.getDepartName(): "");
payExists.setSettleDomainCode(Common.isEmpty(domain.getDepartNo()) ? domain.getDepartNo(): "");
payExists.setUnitId(Common.isEmpty(domain.getCustomerId()) ? domain.getCustomerId(): "");
payExists.setUnitName(Common.isEmpty(domain.getCustomerName()) ? domain.getCustomerName(): "");
payExists.setSettleDomainName(domain.getDepartName());
payExists.setSettleDomainCode(domain.getDepartNo());
payExists.setUnitId(domain.getCustomerId());
payExists.setUnitName(domain.getCustomerName());
} else {
payExists.setSettleDomainName("");
payExists.setSettleDomainCode("");
......@@ -2493,7 +2472,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
payExists.setSocialHousehold(tSocialInfo.getSocialHouseholdName());
}
if (Common.isNotNull(tSocialInfo)) {
payExists.setInauguralTeam(Common.isEmpty(tSocialInfo.getInauguralTeam()) ? tSocialInfo.getInauguralTeam(): "");
payExists.setInauguralTeam(Common.isNotNull(tSocialInfo.getInauguralTeam()) ? tSocialInfo.getInauguralTeam(): "");
payExists.setEmpNo(tSocialInfo.getEmpNo());
} else {
payExists.setInauguralTeam("");
......@@ -2535,7 +2514,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
payExists.setSocialSecurityPersonalSum(BigDecimalUtils.safeAdd(payExists.getPersonalPensionMoney()
, payExists.getSocialSecurityPersonalSum()));
payExists.setSocialSum(BigDecimalUtils.safeAdd(payExists.getUnitSocialSum(), payExists.getSocialSecurityPersonalSum()));
batchYlInsertList.add(payExists);
batchYlInsertList.put(UUID.randomUUID().toString(),payExists);
}
if (PaymentConstants.UNEMPLOYEEMENT_RISK.equals(infoVo.getRiskType())) {
payExists.setUnitUnemploymentMoney(infoVo.getUnitMoney());
......@@ -2546,7 +2525,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
payExists.setSocialSecurityPersonalSum(BigDecimalUtils.safeAdd(payExists.getPersonalUnemploymentMoney()
, payExists.getSocialSecurityPersonalSum()));
payExists.setSocialSum(BigDecimalUtils.safeAdd(payExists.getUnitSocialSum(), payExists.getSocialSecurityPersonalSum()));
batchSyInsertList.add(payExists);
batchSyInsertList.put(UUID.randomUUID().toString(),payExists);
}
if (PaymentConstants.INJURY_RISK.equals(infoVo.getRiskType())) {
payExists.setUnitInjuryMoney(infoVo.getUnitMoney());
......@@ -2554,7 +2533,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
payExists.setUnitSocialSum(BigDecimalUtils.safeAdd(payExists.getUnitInjuryMoney()
, payExists.getUnitSocialSum()));
payExists.setSocialSum(BigDecimalUtils.safeAdd(payExists.getUnitSocialSum(), payExists.getSocialSecurityPersonalSum()));
batchGsInsertList.add(payExists);
batchGsInsertList.put(UUID.randomUUID().toString(),payExists);
}
if (CommonConstants.ONE_STRING.equals(type)) {
payExists.setUnitMedicalMoney(infoVo.getUnitMedicalMoney());
......@@ -2571,7 +2550,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
, payExists.getPersonalBigmailmentMoney()
, payExists.getSocialSecurityPersonalSum()));
payExists.setSocialSum(BigDecimalUtils.safeAdd(payExists.getUnitSocialSum(), payExists.getSocialSecurityPersonalSum()));
batchYyInsertList.add(payExists);
batchYyInsertList.put(UUID.randomUUID().toString(),payExists);
}
}
}
......
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