|
@@ -239,44 +239,46 @@ public class TwinOrderServiceImpl implements ITwinOrderService {
|
|
|
codeMap.forEach((code, codeList) -> {
|
|
|
//按时间分组
|
|
|
Map<String, Object> map = (Map<String, Object>) result.get(mapping.get(code));
|
|
|
- AtomicLong dIn = new AtomicLong((Long) map.get("d-in"));
|
|
|
- AtomicLong dOut = new AtomicLong((Long) map.get("d-out"));
|
|
|
- AtomicLong mIn = new AtomicLong((Long) map.get("m-in"));
|
|
|
- AtomicLong mOut = new AtomicLong((Long) map.get("m-out"));
|
|
|
+ if (map != null) {
|
|
|
+ AtomicLong dIn = new AtomicLong((Long) map.get("d-in"));
|
|
|
+ AtomicLong dOut = new AtomicLong((Long) map.get("d-out"));
|
|
|
+ AtomicLong mIn = new AtomicLong((Long) map.get("m-in"));
|
|
|
+ AtomicLong mOut = new AtomicLong((Long) map.get("m-out"));
|
|
|
|
|
|
- List<MesStockCalc> calcList = new ArrayList<>();
|
|
|
- Map<LocalDate, List<MesStock>> dateMap = codeList.stream().collect(Collectors.groupingBy(MesStock::getDate));
|
|
|
- dateMap.forEach((date, dateList) -> {
|
|
|
- List<MesStock> inList = dateList.stream().filter(MesStock::getFlag).collect(Collectors.toList());
|
|
|
- List<MesStock> outList = dateList.stream().filter(o -> !o.getFlag()).collect(Collectors.toList());
|
|
|
- //统计入库
|
|
|
- long inNum = inList.stream().mapToLong(MesStock::getTotal).sum();
|
|
|
- //统计出库
|
|
|
- long outNum = outList.stream().mapToLong(MesStock::getTotal).sum();
|
|
|
+ List<MesStockCalc> calcList = new ArrayList<>();
|
|
|
+ Map<LocalDate, List<MesStock>> dateMap = codeList.stream().collect(Collectors.groupingBy(MesStock::getDate));
|
|
|
+ dateMap.forEach((date, dateList) -> {
|
|
|
+ List<MesStock> inList = dateList.stream().filter(MesStock::getFlag).collect(Collectors.toList());
|
|
|
+ List<MesStock> outList = dateList.stream().filter(o -> !o.getFlag()).collect(Collectors.toList());
|
|
|
+ //统计入库
|
|
|
+ long inNum = inList.stream().mapToLong(MesStock::getTotal).sum();
|
|
|
+ //统计出库
|
|
|
+ long outNum = outList.stream().mapToLong(MesStock::getTotal).sum();
|
|
|
|
|
|
- MesStockCalc calc = new MesStockCalc();
|
|
|
- calc.setCode(code);
|
|
|
- calc.setDate(date);
|
|
|
- calc.setInNum(inNum);
|
|
|
- calc.setOutNum(outNum);
|
|
|
- calcList.add(calc);
|
|
|
- if (localDate.isEqual(date)) {
|
|
|
- dIn.addAndGet(inNum);
|
|
|
- dOut.addAndGet(outNum);
|
|
|
- map.put("in", inList);
|
|
|
- map.put("out", outList);
|
|
|
- }
|
|
|
- if (localDate.getYear() == date.getYear() && localDate.getMonthValue() == date.getMonthValue()) {
|
|
|
- mIn.addAndGet(inNum);
|
|
|
- mOut.addAndGet(outNum);
|
|
|
- }
|
|
|
- map.put("d-in", dIn.longValue());
|
|
|
- map.put("d-out", dOut.longValue());
|
|
|
- map.put("m-in", mIn.longValue());
|
|
|
- map.put("m-out", mOut.longValue());
|
|
|
- });
|
|
|
- calcList.sort(Comparator.comparing(MesStockCalc::getDate));
|
|
|
- map.put("trend", calcList);
|
|
|
+ MesStockCalc calc = new MesStockCalc();
|
|
|
+ calc.setCode(code);
|
|
|
+ calc.setDate(date);
|
|
|
+ calc.setInNum(inNum);
|
|
|
+ calc.setOutNum(outNum);
|
|
|
+ calcList.add(calc);
|
|
|
+ if (localDate.isEqual(date)) {
|
|
|
+ dIn.addAndGet(inNum);
|
|
|
+ dOut.addAndGet(outNum);
|
|
|
+ map.put("in", inList);
|
|
|
+ map.put("out", outList);
|
|
|
+ }
|
|
|
+ if (localDate.getYear() == date.getYear() && localDate.getMonthValue() == date.getMonthValue()) {
|
|
|
+ mIn.addAndGet(inNum);
|
|
|
+ mOut.addAndGet(outNum);
|
|
|
+ }
|
|
|
+ map.put("d-in", dIn.longValue());
|
|
|
+ map.put("d-out", dOut.longValue());
|
|
|
+ map.put("m-in", mIn.longValue());
|
|
|
+ map.put("m-out", mOut.longValue());
|
|
|
+ });
|
|
|
+ calcList.sort(Comparator.comparing(MesStockCalc::getDate));
|
|
|
+ map.put("trend", calcList);
|
|
|
+ }
|
|
|
});
|
|
|
redisCache.setCacheObject(CacheConstants.VMS_STOCK, result);
|
|
|
}
|