|
@@ -1,8 +1,11 @@
|
|
|
package org.jeecg.modules.projectImportList.readListener;
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.collection.ListUtil;
|
|
|
import com.alibaba.excel.context.AnalysisContext;
|
|
|
import com.alibaba.excel.event.AnalysisEventListener;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.ArrayUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.jeecg.common.util.RedisUtil;
|
|
|
import org.jeecg.modules.Index.util.CacheKey;
|
|
@@ -28,7 +31,9 @@ import org.jeecg.modules.projectImportList.service.impl.ProjectImportListService
|
|
|
import org.jeecg.modules.projectKmbh.entity.KzksProjectKmbh;
|
|
|
import org.jeecg.modules.projectKmbh.service.IKzksProjectKmbhService;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
|
|
|
import java.util.concurrent.*;
|
|
@@ -67,9 +72,9 @@ public class ProjectChbImportReadListener extends AnalysisEventListener<ProjectC
|
|
|
private final RedisUtil redisUtil;
|
|
|
private static final AtomicInteger overTaskCount = new AtomicInteger();
|
|
|
|
|
|
- private final ThreadPoolExecutor threadPoolExecutor;
|
|
|
+ private final ExecutorService threadPoolExecutor;
|
|
|
|
|
|
- public ProjectChbImportReadListener(IKzksProjectKmbhService kmbhService, IProjectChbSwfService swfService, IProjectChbZyfService zyfService, IKzksProjectChbRdfService rdfService, IKzksProjectChbZjfService zjfService, IKzksProjectChbGlfService glfService, IKzksProjectChbRgfService rgfService, IProjectChbSxfService sxfService, IProjectChbWxfService wxfService, RedisUtil redisUtil, ThreadPoolExecutor threadPoolExecutor) {
|
|
|
+ public ProjectChbImportReadListener(IKzksProjectKmbhService kmbhService, IProjectChbSwfService swfService, IProjectChbZyfService zyfService, IKzksProjectChbRdfService rdfService, IKzksProjectChbZjfService zjfService, IKzksProjectChbGlfService glfService, IKzksProjectChbRgfService rgfService, IProjectChbSxfService sxfService, IProjectChbWxfService wxfService, RedisUtil redisUtil, ExecutorService threadPoolExecutor) {
|
|
|
this.kmbhService = kmbhService;
|
|
|
this.swfService = swfService;
|
|
|
this.zyfService = zyfService;
|
|
@@ -86,52 +91,29 @@ public class ProjectChbImportReadListener extends AnalysisEventListener<ProjectC
|
|
|
@Override
|
|
|
public void invoke(ProjectChb projectChb, AnalysisContext analysisContext) {
|
|
|
try {
|
|
|
- //String sheetName = analysisContext.readSheetHolder().getSheetName();
|
|
|
- //Integer rowIndex = analysisContext.readRowHolder().getRowIndex();
|
|
|
- //log.info("当前读的是{},第{}行", sheetName, rowIndex);
|
|
|
+// String sheetName = analysisContext.readSheetHolder().getSheetName();
|
|
|
+// Integer rowIndex = analysisContext.readRowHolder().getRowIndex();
|
|
|
+// log.info("当前读的是{},第{}行", sheetName, rowIndex);
|
|
|
String taskno = projectChb.getTaskno();
|
|
|
String nd = projectChb.getNd();
|
|
|
String kmbh = projectChb.getKmbh();
|
|
|
if (StringUtils.isEmpty(taskno) || StringUtils.isEmpty(nd) || StringUtils.isEmpty(kmbh)) return;
|
|
|
- if (!taskno.equals("") && !nd.equals("") && !kmbh.equals("")) {
|
|
|
- String fylb = (String) redisUtil.hget(CacheKey.ND_KMBH_MONEY_TYPE + ":" + nd, kmbh);
|
|
|
- if (StringUtils.isEmpty(fylb)) return;
|
|
|
- switch (fylb) {
|
|
|
- case "事务费":
|
|
|
- swfList.add(CHBConvert.INSTANCE.toSWF(projectChb));
|
|
|
- swfDe.add(nd);
|
|
|
- break;
|
|
|
- case "专用费":
|
|
|
- zyfList.add(CHBConvert.INSTANCE.toZYF(projectChb));
|
|
|
- zyfDe.add(nd);
|
|
|
- break;
|
|
|
- case "外协费":
|
|
|
- wxfList.add(CHBConvert.INSTANCE.toWXF(projectChb));
|
|
|
- wxfDe.add(nd);
|
|
|
- break;
|
|
|
- case "燃动费":
|
|
|
- rdfList.add(CHBConvert.INSTANCE.toRDF(projectChb));
|
|
|
- rdfDe.add(nd);
|
|
|
- break;
|
|
|
- case "折旧费":
|
|
|
- zjfList.add(CHBConvert.INSTANCE.toZJF(projectChb));
|
|
|
- zjfDe.add(nd);
|
|
|
- break;
|
|
|
- case "管理费":
|
|
|
- glfList.add(CHBConvert.INSTANCE.toGLF(projectChb));
|
|
|
- glfDe.add(nd);
|
|
|
- break;
|
|
|
- case "人工费":
|
|
|
- rgfList.add(CHBConvert.INSTANCE.toRGF(projectChb));
|
|
|
- rgfDe.add(nd);
|
|
|
- break;
|
|
|
- case "筛选费":
|
|
|
- sxfList.add(CHBConvert.INSTANCE.toSXF(projectChb));
|
|
|
- sxfDe.add(nd);
|
|
|
- break;
|
|
|
+ String[] split = taskno.split("/");
|
|
|
+ List<String> chbs = Arrays.asList(split);
|
|
|
+ if (chbs.size() == 1) {
|
|
|
+ chbConvert(projectChb, nd, kmbh);
|
|
|
+ } else {
|
|
|
+ for (String chb : chbs) {
|
|
|
+ ProjectChb newChbs = new ProjectChb();
|
|
|
+ BeanUtil.copyProperties(projectChb, newChbs);
|
|
|
+ newChbs.setTaskno(chb);
|
|
|
+ newChbs.setJe(projectChb.getJe().divide(BigDecimal.valueOf(chbs.size()), 2, BigDecimal.ROUND_HALF_UP));
|
|
|
+ newChbs.setFzje(projectChb.getFzje().divide(BigDecimal.valueOf(chbs.size()), 2, BigDecimal.ROUND_HALF_UP));
|
|
|
+ chbConvert(newChbs, nd, kmbh);
|
|
|
}
|
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
+ } catch (
|
|
|
+ Exception e) {
|
|
|
e.printStackTrace();
|
|
|
clear();
|
|
|
throw new RuntimeException(e);
|
|
@@ -141,7 +123,7 @@ public class ProjectChbImportReadListener extends AnalysisEventListener<ProjectC
|
|
|
@Override
|
|
|
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
|
|
|
try {
|
|
|
- log.info("{}执行完毕",analysisContext.readSheetHolder().getSheetName());
|
|
|
+ log.info("{}执行完毕", analysisContext.readSheetHolder().getSheetName());
|
|
|
int taskCount = ProjectImportListServiceImpl.taskCount;
|
|
|
int ovTaskCount = overTaskCount.incrementAndGet();
|
|
|
if (taskCount != ovTaskCount) return;
|
|
@@ -160,15 +142,6 @@ public class ProjectChbImportReadListener extends AnalysisEventListener<ProjectC
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (!swfList.isEmpty()) {
|
|
|
- List<List<ProjectChbSwf>> lists = splitList(swfList);
|
|
|
- for (List<ProjectChbSwf> list : lists) {
|
|
|
- threadPoolExecutor.submit(() -> {
|
|
|
- swfService.saveBatch(list);
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
if (!zyfDe.isEmpty()) {
|
|
|
for (String nd : zyfDe) {
|
|
|
int count = zyfService.getIfHaveThisNd(nd);
|
|
@@ -177,14 +150,6 @@ public class ProjectChbImportReadListener extends AnalysisEventListener<ProjectC
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (!zyfList.isEmpty()) {
|
|
|
- List<List<ProjectChbZyf>> lists = splitList(zyfList);
|
|
|
- for (List<ProjectChbZyf> list : lists) {
|
|
|
- threadPoolExecutor.submit(() -> {
|
|
|
- zyfService.saveBatch(list);
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
if (!wxfDe.isEmpty()) {
|
|
|
for (String nd : wxfDe) {
|
|
|
int count = wxfService.getIfHaveThisNd(nd);
|
|
@@ -193,14 +158,6 @@ public class ProjectChbImportReadListener extends AnalysisEventListener<ProjectC
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (!wxfList.isEmpty()) {
|
|
|
- List<List<ProjectChbWxf>> lists = splitList(wxfList);
|
|
|
- for (List<ProjectChbWxf> list : lists) {
|
|
|
- threadPoolExecutor.submit(() -> {
|
|
|
- wxfService.saveBatch(list);
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
if (!rdfDe.isEmpty()) {
|
|
|
for (String nd : rdfDe) {
|
|
|
int count = rdfService.getIfHaveThisNd(nd);
|
|
@@ -209,16 +166,6 @@ public class ProjectChbImportReadListener extends AnalysisEventListener<ProjectC
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- if (!rdfList.isEmpty()) {
|
|
|
- List<List<ProjectChbRdf>> lists = splitList(rdfList);
|
|
|
- for (List<ProjectChbRdf> list : lists) {
|
|
|
- threadPoolExecutor.submit(() -> {
|
|
|
- rdfService.saveBatch(list);
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
if (!zjfDe.isEmpty()) {
|
|
|
for (String nd : zjfDe) {
|
|
|
int count = zjfService.getIfHaveThisNd(nd);
|
|
@@ -227,15 +174,6 @@ public class ProjectChbImportReadListener extends AnalysisEventListener<ProjectC
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (!zjfList.isEmpty()) {
|
|
|
- List<List<ProjectChbZjf>> lists = splitList(zjfList);
|
|
|
- for (List<ProjectChbZjf> list : lists) {
|
|
|
- threadPoolExecutor.submit(() -> {
|
|
|
- zjfService.saveBatch(list);
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
if (!glfDe.isEmpty()) {
|
|
|
for (String nd : glfDe) {
|
|
|
int count = glfService.getIfHaveThisNd(nd);
|
|
@@ -244,15 +182,6 @@ public class ProjectChbImportReadListener extends AnalysisEventListener<ProjectC
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (!glfList.isEmpty()) {
|
|
|
- List<List<ProjectChbGlf>> lists = splitList(glfList);
|
|
|
- for (List<ProjectChbGlf> list : lists) {
|
|
|
- threadPoolExecutor.submit(() -> {
|
|
|
- glfService.saveBatch(list);
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
if (!rgfDe.isEmpty()) {
|
|
|
for (String nd : rgfDe) {
|
|
|
int count = rgfService.getIfHaveThisNd(nd);
|
|
@@ -261,15 +190,6 @@ public class ProjectChbImportReadListener extends AnalysisEventListener<ProjectC
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (!rgfList.isEmpty()) {
|
|
|
- List<List<ProjectChbRgf>> lists = splitList(rgfList);
|
|
|
- for (List<ProjectChbRgf> list : lists) {
|
|
|
- threadPoolExecutor.submit(() -> {
|
|
|
- rgfService.saveBatch(list);
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
if (!sxfDe.isEmpty()) {
|
|
|
for (String nd : sxfDe) {
|
|
|
int count = sxfService.getIfHaveThisNd(nd);
|
|
@@ -279,6 +199,76 @@ public class ProjectChbImportReadListener extends AnalysisEventListener<ProjectC
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if (!swfList.isEmpty()) {
|
|
|
+ List<List<ProjectChbSwf>> lists = splitList(swfList);
|
|
|
+ for (List<ProjectChbSwf> list : lists) {
|
|
|
+ threadPoolExecutor.submit(() -> {
|
|
|
+ swfService.saveBatch(list);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!zyfList.isEmpty()) {
|
|
|
+ List<List<ProjectChbZyf>> lists = splitList(zyfList);
|
|
|
+ for (List<ProjectChbZyf> list : lists) {
|
|
|
+ threadPoolExecutor.submit(() -> {
|
|
|
+ zyfService.saveBatch(list);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!wxfList.isEmpty()) {
|
|
|
+ List<List<ProjectChbWxf>> lists = splitList(wxfList);
|
|
|
+ for (List<ProjectChbWxf> list : lists) {
|
|
|
+ threadPoolExecutor.submit(() -> {
|
|
|
+ wxfService.saveBatch(list);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!rdfList.isEmpty()) {
|
|
|
+ List<List<ProjectChbRdf>> lists = splitList(rdfList);
|
|
|
+ for (List<ProjectChbRdf> list : lists) {
|
|
|
+ threadPoolExecutor.submit(() -> {
|
|
|
+ try {
|
|
|
+ rdfService.saveBatch(list);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!zjfList.isEmpty()) {
|
|
|
+ List<List<ProjectChbZjf>> lists = splitList(zjfList);
|
|
|
+ for (List<ProjectChbZjf> list : lists) {
|
|
|
+ threadPoolExecutor.submit(() -> {
|
|
|
+ zjfService.saveBatch(list);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!glfList.isEmpty()) {
|
|
|
+ List<List<ProjectChbGlf>> lists = splitList(glfList);
|
|
|
+ for (List<ProjectChbGlf> list : lists) {
|
|
|
+ threadPoolExecutor.submit(() -> {
|
|
|
+ try {
|
|
|
+ glfService.saveBatch(list);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!rgfList.isEmpty()) {
|
|
|
+ List<List<ProjectChbRgf>> lists = splitList(rgfList);
|
|
|
+ for (List<ProjectChbRgf> list : lists) {
|
|
|
+ threadPoolExecutor.submit(() -> {
|
|
|
+ try {
|
|
|
+ rgfService.saveBatch(list);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
if (!sxfList.isEmpty()) {
|
|
|
List<List<ProjectChbSxf>> lists = splitList(sxfList);
|
|
|
for (List<ProjectChbSxf> list : lists) {
|
|
@@ -302,7 +292,7 @@ public class ProjectChbImportReadListener extends AnalysisEventListener<ProjectC
|
|
|
public void initRedisCache() {
|
|
|
List<KzksProjectKmbh> kmbhs = kmbhService.getAll();
|
|
|
for (KzksProjectKmbh kmbh : kmbhs) {
|
|
|
- redisUtil.hset(CacheKey.ND_KMBH_MONEY_TYPE + ":" + kmbh.getYear(), kmbh.getKemuNo(), kmbh.getMoneyType(),60*120);
|
|
|
+ redisUtil.hset(CacheKey.ND_KMBH_MONEY_TYPE + ":" + kmbh.getYear(), kmbh.getKemuNo(), kmbh.getMoneyType(), 60 * 120);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -349,4 +339,45 @@ public class ProjectChbImportReadListener extends AnalysisEventListener<ProjectC
|
|
|
return lists;
|
|
|
}
|
|
|
|
|
|
+ public void chbConvert(ProjectChb newChbs, String nd, String kmbh) {
|
|
|
+ String fylb = (String) redisUtil.hget(CacheKey.ND_KMBH_MONEY_TYPE + ":" + nd, kmbh);
|
|
|
+ if (StringUtils.isEmpty(fylb)) return;
|
|
|
+ switch (fylb) {
|
|
|
+ case "事务费":
|
|
|
+ swfList.add(CHBConvert.INSTANCE.toSWF(newChbs));
|
|
|
+ swfDe.add(nd);
|
|
|
+ break;
|
|
|
+ case "专用费":
|
|
|
+ zyfList.add(CHBConvert.INSTANCE.toZYF(newChbs));
|
|
|
+ zyfDe.add(nd);
|
|
|
+ break;
|
|
|
+ case "外协费":
|
|
|
+ wxfList.add(CHBConvert.INSTANCE.toWXF(newChbs));
|
|
|
+ wxfDe.add(nd);
|
|
|
+ break;
|
|
|
+ case "燃动费":
|
|
|
+ rdfList.add(CHBConvert.INSTANCE.toRDF(newChbs));
|
|
|
+ rdfDe.add(nd);
|
|
|
+ break;
|
|
|
+ case "固资费":
|
|
|
+ case "折旧费":
|
|
|
+ zjfList.add(CHBConvert.INSTANCE.toZJF(newChbs));
|
|
|
+ zjfDe.add(nd);
|
|
|
+ break;
|
|
|
+ case "管理费":
|
|
|
+ glfList.add(CHBConvert.INSTANCE.toGLF(newChbs));
|
|
|
+ glfDe.add(nd);
|
|
|
+ break;
|
|
|
+ case "人工费":
|
|
|
+ rgfList.add(CHBConvert.INSTANCE.toRGF(newChbs));
|
|
|
+ rgfDe.add(nd);
|
|
|
+ break;
|
|
|
+ case "筛选费":
|
|
|
+ sxfList.add(CHBConvert.INSTANCE.toSXF(newChbs));
|
|
|
+ sxfDe.add(nd);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|