|
@@ -3,18 +3,18 @@ package com.jjt.order.service.impl;
|
|
|
import cn.hutool.json.JSONArray;
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
-import com.jjt.common.constant.CacheConstants;
|
|
|
import com.jjt.common.core.redis.RedisCache;
|
|
|
import com.jjt.common.core.text.Convert;
|
|
|
import com.jjt.common.utils.DateUtils;
|
|
|
import com.jjt.common.utils.StringUtils;
|
|
|
import com.jjt.nccloud.utils.NccloudUtils;
|
|
|
-import com.jjt.order.domain.*;
|
|
|
+import com.jjt.order.domain.TwinBom;
|
|
|
+import com.jjt.order.domain.TwinOrder;
|
|
|
+import com.jjt.order.domain.TwinOrderDetail;
|
|
|
import com.jjt.order.mapper.TwinOrderMapper;
|
|
|
import com.jjt.order.service.ITwinBomService;
|
|
|
import com.jjt.order.service.ITwinOrderDetailService;
|
|
|
import com.jjt.order.service.ITwinOrderService;
|
|
|
-import com.jjt.utils.MssqlUtil;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
@@ -23,8 +23,10 @@ import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.LocalTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
-import java.util.*;
|
|
|
-import java.util.concurrent.atomic.AtomicLong;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -41,8 +43,6 @@ public class TwinOrderServiceImpl implements ITwinOrderService {
|
|
|
private ITwinBomService bomService;
|
|
|
@Resource
|
|
|
private ITwinOrderDetailService detailService;
|
|
|
- @Resource
|
|
|
- private RedisCache redisCache;
|
|
|
|
|
|
/**
|
|
|
* 查询销售订单信息
|
|
@@ -204,86 +204,6 @@ public class TwinOrderServiceImpl implements ITwinOrderService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 获取当前库存
|
|
|
- */
|
|
|
- @Override
|
|
|
- public void currStock() {
|
|
|
- //减少7个小时,班组统计时间
|
|
|
- LocalDate localDate = LocalDateTime.now().minusHours(7).toLocalDate();
|
|
|
- List<MesStock> list = MssqlUtil.mesStock(localDate);
|
|
|
- Map<String, Double> currStock = MssqlUtil.currStock();
|
|
|
- HashMap<String, Object> initMap = new HashMap<>(16);
|
|
|
- initMap.put("d-in", 0L);
|
|
|
- initMap.put("d-out", 0L);
|
|
|
- initMap.put("m-in", 0L);
|
|
|
- initMap.put("m-out", 0L);
|
|
|
- Map<String, Object> mapping = new HashMap<>(16);
|
|
|
- mapping.put("WH01", "ycl");
|
|
|
- mapping.put("WH03", "pt");
|
|
|
- mapping.put("WH04", "bpb");
|
|
|
- mapping.put("WH08", "cp");
|
|
|
- Map<String, Object> result = new HashMap<>(16);
|
|
|
- result.put("ycl", initMap.clone());
|
|
|
- result.put("cp", initMap.clone());
|
|
|
- result.put("bpb", initMap.clone());
|
|
|
- result.put("pt", initMap.clone());
|
|
|
-
|
|
|
- for (String key : currStock.keySet()) {
|
|
|
- HashMap<String, Object> map = (HashMap<String, Object>) result.get(key);
|
|
|
- map.put("curr", currStock.get(key));
|
|
|
- }
|
|
|
-
|
|
|
- //先按仓库分组
|
|
|
- Map<String, List<MesStock>> codeMap = list.stream().collect(Collectors.groupingBy(MesStock::getCode));
|
|
|
-
|
|
|
- codeMap.forEach((code, codeList) -> {
|
|
|
- //按时间分组
|
|
|
- Map<String, Object> map = (Map<String, Object>) result.get(mapping.get(code));
|
|
|
- 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();
|
|
|
-
|
|
|
- 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);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
* 新增销售订单明细信息信息
|
|
|
*
|
|
|
* @param twinOrder 销售订单信息对象
|