|
@@ -1,5 +1,7 @@
|
|
package org.jeecg.modules.wzOutboundOrder.controller;
|
|
package org.jeecg.modules.wzOutboundOrder.controller;
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.alibaba.fastjson.TypeReference;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -10,13 +12,14 @@ import org.jeecg.common.api.vo.Result;
|
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
|
import org.jeecg.common.system.base.controller.JeecgController;
|
|
import org.jeecg.common.system.base.controller.JeecgController;
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
|
|
+import org.jeecg.common.util.RedisUtil;
|
|
|
|
+import org.jeecg.modules.Index.util.CacheKey;
|
|
import org.jeecg.modules.wzOutboundOrder.entity.CLfCompareDO;
|
|
import org.jeecg.modules.wzOutboundOrder.entity.CLfCompareDO;
|
|
import org.jeecg.modules.wzOutboundOrder.entity.WzOutboundOrderH;
|
|
import org.jeecg.modules.wzOutboundOrder.entity.WzOutboundOrderH;
|
|
import org.jeecg.modules.wzOutboundOrder.service.IWzOutboundOrderBService;
|
|
import org.jeecg.modules.wzOutboundOrder.service.IWzOutboundOrderBService;
|
|
import org.jeecg.modules.wzOutboundOrder.service.IWzOutboundOrderHService;
|
|
import org.jeecg.modules.wzOutboundOrder.service.IWzOutboundOrderHService;
|
|
import org.jeecg.modules.wzOutboundOrder.vo.CLFCompareResultVO;
|
|
import org.jeecg.modules.wzOutboundOrder.vo.CLFCompareResultVO;
|
|
import org.jeecg.modules.wzOutboundOrder.vo.CLFCompareTaskResultVo;
|
|
import org.jeecg.modules.wzOutboundOrder.vo.CLFCompareTaskResultVo;
|
|
-import org.jeecg.modules.wzOutboundOrder.vo.CLfCompareResultListVo;
|
|
|
|
import org.jeecg.modules.wzOutboundOrder.vo.WzOutboundOrderBDetailListVO;
|
|
import org.jeecg.modules.wzOutboundOrder.vo.WzOutboundOrderBDetailListVO;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -26,7 +29,8 @@ import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
+import java.util.concurrent.*;
|
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @Description: 物资出库单
|
|
* @Description: 物资出库单
|
|
@@ -46,6 +50,8 @@ public class WzOutboundOrderHController extends JeecgController<WzOutboundOrderH
|
|
@SuppressWarnings("all")
|
|
@SuppressWarnings("all")
|
|
private IWzOutboundOrderBService bService;
|
|
private IWzOutboundOrderBService bService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private RedisUtil redisUtil;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 导出材料费详情excel
|
|
* 导出材料费详情excel
|
|
@@ -62,75 +68,183 @@ public class WzOutboundOrderHController extends JeecgController<WzOutboundOrderH
|
|
*/
|
|
*/
|
|
@ApiOperation(value = "项目成本——材料费详情对比", notes = "项目成本——材料费详情对比")
|
|
@ApiOperation(value = "项目成本——材料费详情对比", notes = "项目成本——材料费详情对比")
|
|
@GetMapping(value = "/compareCLFDetailList")
|
|
@GetMapping(value = "/compareCLFDetailList")
|
|
- public Result<CLfCompareResultListVo> compareCLFDetailList(String tasknos) {
|
|
|
|
|
|
+ public Result<IPage<CLFCompareResultVO>> compareCLFDetailList(@RequestParam String tasknos, @RequestParam(required = false) Integer pageNo,
|
|
|
|
+ @RequestParam(required = false) Integer pageSize) {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ ThreadPoolExecutor threadPoolExecutor =
|
|
|
|
+ new ThreadPoolExecutor(8, 8, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<>(100));
|
|
|
|
|
|
- int id = 0;
|
|
|
|
|
|
+ Page<CLFCompareResultVO> page = new Page<>();
|
|
|
|
+ int startId = 0;
|
|
|
|
+ int endId = 0;
|
|
|
|
+ if (pageNo != null && pageSize != null) {
|
|
|
|
+ startId = (pageNo - 1) * pageSize;
|
|
|
|
+ endId = startId + pageSize;
|
|
|
|
+ }
|
|
|
|
+ AtomicInteger id = new AtomicInteger();
|
|
|
|
|
|
- CLfCompareResultListVo result = new CLfCompareResultListVo();
|
|
|
|
- ArrayList<CLFCompareResultVO> clfCompareResultVOS = new ArrayList<>();
|
|
|
|
|
|
+ CopyOnWriteArrayList<CLFCompareResultVO> clfCompareResultVOS = new CopyOnWriteArrayList<>();
|
|
String[] tasknoArray = tasknos.split(",");
|
|
String[] tasknoArray = tasknos.split(",");
|
|
- HashMap<String, List<CLfCompareDO>> compareMap = new HashMap<>();
|
|
|
|
- for (String taskno : tasknoArray) {
|
|
|
|
- List<CLfCompareDO> Dos = wzOutboundOrderHService.getCLFCompareDoListByTaskNoList(taskno);
|
|
|
|
- if (!Dos.isEmpty()) {
|
|
|
|
- Dos.forEach(dos-> {
|
|
|
|
- String hashKey = dos.getWlbm() + dos.getWlmc() + dos.getGgxh();
|
|
|
|
- List<CLfCompareDO> cLfCompareDOS = compareMap.get(hashKey);
|
|
|
|
- if (cLfCompareDOS == null) cLfCompareDOS = new ArrayList<>();
|
|
|
|
- cLfCompareDOS.add(dos);
|
|
|
|
- compareMap.put(hashKey,cLfCompareDOS);
|
|
|
|
- });
|
|
|
|
|
|
+ if (tasknoArray.length == 0) return Result.ok("非法请求");
|
|
|
|
+
|
|
|
|
+ ArrayList<CLFCompareResultVO> redisResultList = JSONObject.parseObject(JSONObject.toJSONString(redisUtil.get(CacheKey.CLF_COMPARE_RESULT_VOS + ":" + tasknos)), new TypeReference<ArrayList<CLFCompareResultVO>>() {
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ if (redisResultList != null && !redisResultList.isEmpty()) {
|
|
|
|
+ if (startId > redisResultList.size()) return Result.ok("参数错误");
|
|
|
|
+ if (endId > redisResultList.size() || endId == 0) endId = redisResultList.size();
|
|
|
|
+ List<CLFCompareResultVO> resultList = redisResultList.subList(startId, endId);
|
|
|
|
+ if (!resultList.isEmpty()) {
|
|
|
|
+ int pages = 0;
|
|
|
|
+ if (redisResultList.size() < pageSize) {
|
|
|
|
+ pages = 1;
|
|
|
|
+ } else {
|
|
|
|
+ int i = redisResultList.size() / pageSize;
|
|
|
|
+ int o = redisResultList.size() % pageSize;
|
|
|
|
+ if (o != 0) i = i + 1;
|
|
|
|
+ pages = i;
|
|
|
|
+ }
|
|
|
|
+ page.setPages(pages);
|
|
|
|
+ page.setRecords(resultList);
|
|
|
|
+ pageNo = Optional.ofNullable(pageNo).orElse(0);
|
|
|
|
+ pageSize = Optional.ofNullable(pageSize).orElse(redisResultList.size());
|
|
|
|
+ page.setCurrent(pageNo);
|
|
|
|
+ page.setSize(pageSize);
|
|
|
|
+ page.setTotal(redisResultList.size());
|
|
|
|
+ return Result.ok(page);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if (compareMap.isEmpty()) return Result.ok("没有找到结果");
|
|
|
|
|
|
|
|
- for (String s : compareMap.keySet()) {
|
|
|
|
- List<CLfCompareDO> cLfCompareDOS = compareMap.get(s);
|
|
|
|
- CLFCompareResultVO clfCompareResultVO = new CLFCompareResultVO();
|
|
|
|
- CLfCompareDO cLfCompareDO = cLfCompareDOS.get(0);
|
|
|
|
- clfCompareResultVO.setId(String.valueOf(id));
|
|
|
|
- ++id;
|
|
|
|
- clfCompareResultVO.setWlbm(cLfCompareDO.getWlbm());
|
|
|
|
- clfCompareResultVO.setWlmc(cLfCompareDO.getWlmc());
|
|
|
|
- clfCompareResultVO.setGgxh(cLfCompareDO.getGgxh());
|
|
|
|
- ArrayList<CLFCompareTaskResultVo> taskVoList = new ArrayList<>();
|
|
|
|
- List<String> taskNoList = new ArrayList<>(Arrays.asList(tasknoArray));
|
|
|
|
-
|
|
|
|
- BigDecimal unitPrice = null;
|
|
|
|
- boolean equals = true;
|
|
|
|
-
|
|
|
|
- for (CLfCompareDO CDo : cLfCompareDOS) {
|
|
|
|
- CLFCompareTaskResultVo clfCompareTaskResultVo = new CLFCompareTaskResultVo();
|
|
|
|
- clfCompareTaskResultVo.setTaskno(CDo.getRwh());
|
|
|
|
- taskNoList.remove(CDo.getRwh());
|
|
|
|
- clfCompareTaskResultVo.setFlag("yes");
|
|
|
|
- clfCompareTaskResultVo.setTotalAmount(CDo.getTotalAmount());
|
|
|
|
- clfCompareTaskResultVo.setTotalCount(CDo.getTotalCount());
|
|
|
|
- clfCompareTaskResultVo.setUnitPrice(CDo.getUnitPrice());
|
|
|
|
- if (unitPrice == null) {
|
|
|
|
- unitPrice = CDo.getUnitPrice();
|
|
|
|
- }else {
|
|
|
|
- if (CDo.getUnitPrice().compareTo(unitPrice) != 0) equals = false;
|
|
|
|
|
|
+ ConcurrentHashMap<String, List<CLfCompareDO>> compareMap = new ConcurrentHashMap<>();
|
|
|
|
+ ArrayList<CompletableFuture<Void>> completableFutures = new ArrayList<>();
|
|
|
|
+ for (String taskno : tasknoArray) {
|
|
|
|
+ CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
|
|
|
|
+ List<CLfCompareDO> Dos = wzOutboundOrderHService.getCLFCompareDoListByTaskNoList(taskno);
|
|
|
|
+ if (!Dos.isEmpty()) {
|
|
|
|
+ Dos.forEach(dos -> {
|
|
|
|
+ String hashKey = dos.getWlbm() + dos.getWlmc() + dos.getGgxh();
|
|
|
|
+ List<CLfCompareDO> cLfCompareDOS = compareMap.get(hashKey);
|
|
|
|
+ if (cLfCompareDOS == null) cLfCompareDOS = new ArrayList<>();
|
|
|
|
+ cLfCompareDOS.add(dos);
|
|
|
|
+ compareMap.put(hashKey, cLfCompareDOS);
|
|
|
|
+ });
|
|
}
|
|
}
|
|
- taskVoList.add(clfCompareTaskResultVo);
|
|
|
|
|
|
+ }, threadPoolExecutor);
|
|
|
|
+ completableFutures.add(future);
|
|
|
|
+ }
|
|
|
|
+ CompletableFuture<Void>[] array = completableFutures.toArray(new CompletableFuture[0]);
|
|
|
|
+ CompletableFuture<Void> future = CompletableFuture.allOf(array);
|
|
|
|
+ future.join();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if (compareMap.isEmpty()) return Result.ok("没有找到结果");
|
|
|
|
+
|
|
|
|
+ ArrayList<CompletableFuture<Void>> processFutures = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ ArrayList<ConcurrentHashMap<String, List<CLfCompareDO>>> concurrentHashMaps = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ ArrayList<Map.Entry<String, List<CLfCompareDO>>> entries = new ArrayList<>(compareMap.entrySet());
|
|
|
|
+ int splitSize = 100;
|
|
|
|
+ int numOfParts = (entries.size() + splitSize - 1) / splitSize;
|
|
|
|
+
|
|
|
|
+ for (int i = 0; i < numOfParts; i++) {
|
|
|
|
+ int startIndex = i * splitSize;
|
|
|
|
+ int endIndex = Math.min(startIndex + splitSize, entries.size());
|
|
|
|
+ List<Map.Entry<String, List<CLfCompareDO>>> subList = entries.subList(startIndex, endIndex);
|
|
|
|
+
|
|
|
|
+ ConcurrentHashMap<String, List<CLfCompareDO>> subMap = new ConcurrentHashMap<>();
|
|
|
|
+ for (Map.Entry<String, List<CLfCompareDO>> entry : subList) {
|
|
|
|
+ subMap.put(entry.getKey(), entry.getValue());
|
|
}
|
|
}
|
|
- if (!taskNoList.isEmpty()){
|
|
|
|
- for (String no : taskNoList) {
|
|
|
|
- CLFCompareTaskResultVo clfCompareTaskResultVo = new CLFCompareTaskResultVo();
|
|
|
|
- clfCompareTaskResultVo.setTaskno(no);
|
|
|
|
- clfCompareTaskResultVo.setFlag("no");
|
|
|
|
- taskVoList.add(clfCompareTaskResultVo);
|
|
|
|
|
|
+ concurrentHashMaps.add(subMap);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for (ConcurrentHashMap<String, List<CLfCompareDO>> concurrentHashMap : concurrentHashMaps) {
|
|
|
|
+ CompletableFuture<Void> processFuture = CompletableFuture.runAsync(() -> {
|
|
|
|
+ for (String s : concurrentHashMap.keySet()) {
|
|
|
|
+ List<CLfCompareDO> cLfCompareDOS = concurrentHashMap.get(s);
|
|
|
|
+ CLFCompareResultVO clfCompareResultVO = new CLFCompareResultVO();
|
|
|
|
+ CLfCompareDO cLfCompareDO = cLfCompareDOS.get(0);
|
|
|
|
+ clfCompareResultVO.setId(String.valueOf(id.get()));
|
|
|
|
+ id.incrementAndGet();
|
|
|
|
+ clfCompareResultVO.setWlbm(cLfCompareDO.getWlbm());
|
|
|
|
+ clfCompareResultVO.setWlmc(cLfCompareDO.getWlmc());
|
|
|
|
+ clfCompareResultVO.setGgxh(cLfCompareDO.getGgxh());
|
|
|
|
+ ArrayList<CLFCompareTaskResultVo> taskVoList = new ArrayList<>();
|
|
|
|
+ List<String> taskNoList = new ArrayList<>(Arrays.asList(tasknoArray));
|
|
|
|
+
|
|
|
|
+ BigDecimal unitPrice = null;
|
|
|
|
+ boolean equals = true;
|
|
|
|
+
|
|
|
|
+ for (CLfCompareDO CDo : cLfCompareDOS) {
|
|
|
|
+ CLFCompareTaskResultVo clfCompareTaskResultVo = new CLFCompareTaskResultVo();
|
|
|
|
+ clfCompareTaskResultVo.setTaskno(CDo.getRwh());
|
|
|
|
+ taskNoList.remove(CDo.getRwh());
|
|
|
|
+ clfCompareTaskResultVo.setFlag("yes");
|
|
|
|
+ clfCompareTaskResultVo.setTotalAmount(CDo.getTotalAmount());
|
|
|
|
+ clfCompareTaskResultVo.setTotalCount(CDo.getTotalCount());
|
|
|
|
+ clfCompareTaskResultVo.setUnitPrice(CDo.getUnitPrice());
|
|
|
|
+ if (unitPrice == null) {
|
|
|
|
+ unitPrice = CDo.getUnitPrice();
|
|
|
|
+ } else {
|
|
|
|
+ if (CDo.getUnitPrice().compareTo(unitPrice) != 0) equals = false;
|
|
|
|
+ }
|
|
|
|
+ taskVoList.add(clfCompareTaskResultVo);
|
|
|
|
+ }
|
|
|
|
+ if (!taskNoList.isEmpty()) {
|
|
|
|
+ for (String no : taskNoList) {
|
|
|
|
+ CLFCompareTaskResultVo clfCompareTaskResultVo = new CLFCompareTaskResultVo();
|
|
|
|
+ clfCompareTaskResultVo.setTaskno(no);
|
|
|
|
+ clfCompareTaskResultVo.setFlag("no");
|
|
|
|
+ taskVoList.add(clfCompareTaskResultVo);
|
|
|
|
+ }
|
|
|
|
+ equals = false;
|
|
|
|
+ }
|
|
|
|
+ clfCompareResultVO.setEqual(equals);
|
|
|
|
+ clfCompareResultVO.setTaskVoList(taskVoList);
|
|
|
|
+ clfCompareResultVOS.add(clfCompareResultVO);
|
|
}
|
|
}
|
|
- equals = false;
|
|
|
|
|
|
+ }, threadPoolExecutor);
|
|
|
|
+ processFutures.add(processFuture);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ CompletableFuture<Void>[] processArr = processFutures.toArray(new CompletableFuture[0]);
|
|
|
|
+ CompletableFuture<Void> process = CompletableFuture.allOf(processArr);
|
|
|
|
+ process.join();
|
|
|
|
+
|
|
|
|
+ clfCompareResultVOS.sort(new Comparator<CLFCompareResultVO>() {
|
|
|
|
+ @Override
|
|
|
|
+ public int compare(CLFCompareResultVO o1, CLFCompareResultVO o2) {
|
|
|
|
+ return Integer.parseInt(o1.getId()) - Integer.parseInt(o2.getId());
|
|
}
|
|
}
|
|
- clfCompareResultVO.setEqual(equals);
|
|
|
|
- clfCompareResultVO.setTaskVoList(taskVoList);
|
|
|
|
- clfCompareResultVOS.add(clfCompareResultVO);
|
|
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ redisUtil.set(CacheKey.CLF_COMPARE_RESULT_VOS + ":" + tasknos, clfCompareResultVOS, 60 * 60 * 2);
|
|
|
|
+ if (clfCompareResultVOS.isEmpty()) return Result.ok("数据不存在");
|
|
|
|
+ int size = clfCompareResultVOS.size();
|
|
|
|
+ if (startId > size) return Result.ok("参数错误");
|
|
|
|
+ if (endId > size || endId == 0) endId = size;
|
|
|
|
+ page.setRecords(clfCompareResultVOS.subList(startId, endId));
|
|
|
|
+ pageNo = Optional.ofNullable(pageNo).orElse(0);
|
|
|
|
+ pageSize = Optional.ofNullable(pageSize).orElse(size);
|
|
|
|
+ int pages = 0;
|
|
|
|
+ if (size < pageSize) {
|
|
|
|
+ pages = 1;
|
|
|
|
+ } else {
|
|
|
|
+ int i = size / pageSize;
|
|
|
|
+ int o = size % pageSize;
|
|
|
|
+ if (o != 0) i = i + 1;
|
|
|
|
+ pages = i;
|
|
}
|
|
}
|
|
- result.setResultVOList(clfCompareResultVOS);
|
|
|
|
|
|
|
|
- return Result.OK(result);
|
|
|
|
|
|
+ page.setCurrent(pageNo);
|
|
|
|
+ page.setSize(pageSize);
|
|
|
|
+ page.setTotal(clfCompareResultVOS.size());
|
|
|
|
+ page.setPages(pages);
|
|
|
|
+ threadPoolExecutor.shutdown();
|
|
|
|
+ return Result.OK(page);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -210,7 +324,7 @@ public class WzOutboundOrderHController extends JeecgController<WzOutboundOrderH
|
|
@ApiOperation(value = "项目成本——材料费详情", notes = "项目成本——材料费详情")
|
|
@ApiOperation(value = "项目成本——材料费详情", notes = "项目成本——材料费详情")
|
|
@GetMapping(value = "/getCLFList")
|
|
@GetMapping(value = "/getCLFList")
|
|
public List<WzOutboundOrderBDetailListVO> getCLFList(String taskno) {
|
|
public List<WzOutboundOrderBDetailListVO> getCLFList(String taskno) {
|
|
- return wzOutboundOrderHService.getClfList(taskno);
|
|
|
|
|
|
+ return wzOutboundOrderHService.getClfList(taskno);
|
|
|
|
|
|
|
|
|
|
/* List<WzOutboundOrderBDetailListVO> bList = new ArrayList<>();
|
|
/* List<WzOutboundOrderBDetailListVO> bList = new ArrayList<>();
|