From d7a60e6154e7810ec59307faecc71280dfe25941 Mon Sep 17 00:00:00 2001
From: cl <1442464845@qq.com>
Date: 星期日, 12 四月 2026 10:47:08 +0800
Subject: [PATCH] 24小时折线图-更新

---
 src/main/java/com/zy/asrs/controller/OpenController.java |  171 +++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 148 insertions(+), 23 deletions(-)

diff --git a/src/main/java/com/zy/asrs/controller/OpenController.java b/src/main/java/com/zy/asrs/controller/OpenController.java
index ca3fb5e..0578025 100644
--- a/src/main/java/com/zy/asrs/controller/OpenController.java
+++ b/src/main/java/com/zy/asrs/controller/OpenController.java
@@ -57,6 +57,8 @@
     private MatService matService;
 
     @Autowired
+    private LocMastService locMastService;
+    @Autowired
     private ReportQueryMapper reportQueryMapper;
 //    @PostMapping("/order/matSync/default/v1")
 ////    @AppAuth(memo = "鍟嗗搧淇℃伅鍚屾鎺ュ彛")
@@ -151,6 +153,7 @@
 
     private void auth(String appkey, Object obj, HttpServletRequest request) {
         log.info("{}鎺ュ彛琚闂紱appkey:{}锛涜姹傛暟鎹細{}", "open/sensorType/list/auth/v1", appkey, JSON.toJSONString(obj));
+        log.info("[auth] cache: {}", obj == null ? "null" : JSON.toJSONString(obj));
         request.setAttribute("cache", obj);
         if (!auth) {
             return;
@@ -396,8 +399,12 @@
 
     @PostMapping("/order/matSync/default/v2")
 //    @AppAuth(memo = "鍟嗗搧淇℃伅鍚屾鎺ュ彛")
-    public synchronized R syncMatInfoV2(@RequestBody(required = false) List<MatSyncParam.MatParam> param){
-
+    public synchronized R syncMatInfoV2(@RequestBody(required = false) List<MatSyncParam.MatParam> param,
+                                        HttpServletRequest request) {
+        if (request != null) {
+            log.info("[syncMatInfoV2] cache: {}", param == null ? "null" : JSON.toJSONString(param));
+            request.setAttribute("cache", param);
+        }
         System.out.println(param);
         if (Cools.isEmpty(param)) {
             return R.parse(BaseRes.PARAM);
@@ -422,7 +429,12 @@
      * return
      */
     @PostMapping("/station/all")
-    public synchronized R stationAll(){
+    public synchronized R stationAll(HttpServletRequest request) {
+        if (request != null) {
+            String cachePayload = JSON.toJSONString(Collections.singletonMap("op", "stationAll"));
+            log.info("[stationAll] cache: {}", cachePayload);
+            request.setAttribute("cache", cachePayload);
+        }
         return openService.stationAll();
     }
 
@@ -431,7 +443,11 @@
      * return
      */
     @PostMapping("/comb/auth")
-    public synchronized R comb(@RequestBody ArrayList<MesToCombParam> param){
+    public synchronized R comb(@RequestBody ArrayList<MesToCombParam> param, HttpServletRequest request) {
+        if (request != null) {
+            log.info("[comb] cache: {}", param == null ? "null" : JSON.toJSONString(param));
+            request.setAttribute("cache", param);
+        }
         List<MesToCombParam> errorComb = Lists.newArrayList();
         List<MesToCombParam> validComb = Lists.newArrayList();
         for (MesToCombParam mesToCombParam : param) {
@@ -475,10 +491,12 @@
      */
 
     @PostMapping("/outOrder")
-    public synchronized R outOrder (@RequestBody ArrayList<OutTaskParam> params){
+    public synchronized R outOrder(@RequestBody ArrayList<OutTaskParam> params, HttpServletRequest request) {
         if (Cools.isEmpty(params)) {
             return R.error("璇锋眰鍙傛暟涓嶈兘涓虹┖");
         }
+        log.info("[outOrder] cache: {}", JSON.toJSONString(params));
+        request.setAttribute("cache", params);
         Set<String> orderIds = new LinkedHashSet<>();
         for (OutTaskParam outTaskParam : params) {
             if (Cools.isEmpty(outTaskParam) || Cools.isEmpty(outTaskParam.getOrderId())) {
@@ -486,6 +504,38 @@
             }
             orderIds.add(outTaskParam.getOrderId());
         }
+
+        Map<String, List<OutTaskParam>> linesByOrder = new LinkedHashMap<>();
+        for (OutTaskParam outTaskParam : params) {
+            linesByOrder.computeIfAbsent(outTaskParam.getOrderId(), k -> new ArrayList<>()).add(outTaskParam);
+        }
+        for (Map.Entry<String, List<OutTaskParam>> entry : linesByOrder.entrySet()) {
+            String oid = entry.getKey();
+            List<OutTaskParam> lines = entry.getValue();
+            List<Integer> seqs = new ArrayList<>(lines.size());
+            for (OutTaskParam line : lines) {
+                if (line.getSeq() == null) {
+                    return R.error("鍑哄簱鍗曘��" + oid + "銆嶅簭鍙蜂笉鑳戒负绌�");
+                }
+                seqs.add(line.getSeq());
+            }
+            Collections.sort(seqs);
+            for (int i = 0; i < seqs.size(); i++) {
+                if (!String.valueOf(seqs.get(i)).equals(String.valueOf(i + 1))) {
+                    return R.error("鍑哄簱鍗曘��" + oid + "銆嶅簭鍙蜂笉杩炶疮");
+                }
+            }
+        }
+
+        Set<String> seenPallet = new LinkedHashSet<>();
+        for (OutTaskParam outTaskParam : params) {
+            String pid = outTaskParam.getPalletId();
+            String palletKey = pid == null ? "" : pid;
+            if (!seenPallet.add(palletKey)) {
+                return R.error("鎵樼洏鍙烽噸澶嶏細" + (Cools.isEmpty(pid) ? "锛堢┖锛�" : pid));
+            }
+        }
+
 //        if (!orderIds.isEmpty()) {
 //            Set<String> existedOrderIds = new LinkedHashSet<>();
 //            List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().in("user_no", orderIds));
@@ -505,37 +555,48 @@
 //            }
 //        }
 
-        List<OutTaskParam> errorOutOrders = Lists.newArrayList();
-        List<OutTaskParam> validOutOrders = Lists.newArrayList();
+        List<OutTaskParam> missingStock = Lists.newArrayList();
+        List<OutTaskParam> missingLoc = Lists.newArrayList();
         for (OutTaskParam outTaskParam : params) {
-            // TODO:寰呮脯瑭︼紝鏍¢搴瓨淇℃伅锛屼笉瀛樺湪鍓囪繑鍥�
             int countLoc = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet", outTaskParam.getPalletId()));
-            if (countLoc == 0){
-                errorOutOrders.add(outTaskParam);
+            if (countLoc == 0) {
+                missingStock.add(outTaskParam);
                 continue;
             }
-            validOutOrders.add(outTaskParam);
-        }
-
-        for (OutTaskParam outTaskParam : validOutOrders) {
-            R r = openService.outOrder(outTaskParam,validOutOrders.size());
-            if (!r.get("code").equals(200)){
-                return r;
+            LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_sts", "F").eq("barcode", outTaskParam.getPalletId()));
+            if (locMast == null) {
+                missingLoc.add(outTaskParam);
             }
         }
-
-        if(errorOutOrders.size() > 0) {
-            return R.error("搴撳瓨涓笉瀛樺湪璇ユ墭鐩�").add(errorOutOrders);
+        if (!missingStock.isEmpty()) {
+            List<String> missingPalletIds = new ArrayList<>(missingStock.size());
+            for (OutTaskParam p : missingStock) {
+                String pid = p.getPalletId();
+                missingPalletIds.add(Cools.isEmpty(pid) ? "锛堢┖锛�" : pid);
+            }
+            return R.error("搴撳瓨涓笉瀛樺湪璇ユ墭鐩橈細" + String.join("锛�", missingPalletIds)).add(missingStock);
+        }
+        if (!missingLoc.isEmpty()) {
+            List<String> badPalletIds = new ArrayList<>(missingLoc.size());
+            for (OutTaskParam p : missingLoc) {
+                String pid = p.getPalletId();
+                badPalletIds.add(Cools.isEmpty(pid) ? "锛堢┖锛�" : pid);
+            }
+            return R.error("娌℃湁鎵惧埌鎵樼洏鐮佸搴斿簱浣嶏細" + String.join("锛�", badPalletIds)).add(missingLoc);
         }
 
-        return R.ok();
+        return openService.outOrderBatch(params);
     }
 
     /**
      * pause out order
      */
     @PostMapping("/order/pakout/pause/default/v1")
-    public synchronized R pakoutOrderPause(@RequestBody OpenOrderPakoutPauseParam param){
+    public synchronized R pakoutOrderPause(@RequestBody OpenOrderPakoutPauseParam param, HttpServletRequest request) {
+        if (request != null) {
+            log.info("[pakoutOrderPause] cache: {}", param == null ? "null" : JSON.toJSONString(param));
+            request.setAttribute("cache", param);
+        }
         if (Cools.isEmpty(param) || Cools.isEmpty(param.getOrderId())) {
             return R.error("orderNo is empty");
         }
@@ -605,6 +666,66 @@
     }
 
     /**
+     * 杩�24灏忔椂鍏ュ嚭搴撴姌绾匡紙妯酱灏忔椂锛夛紝涓庢寜鏃� {@link #locIoLineCharts()} 鏁版嵁鍙e緞涓嶅悓锛屼緵鐢佃鏈恒�屼綔涓氭晥鐜囥�嶄娇鐢�
+     */
+    @GetMapping("/line/charts/hourly")
+    public R locIoLineChartsHourly() {
+        Map<String, Object> map = new HashMap<>();
+        List<AxisBean> list = new ArrayList<>();
+
+        List<WorkChartAxis> listChart = reportQueryMapper.getChartAxisHourly();
+        if (listChart == null) {
+            listChart = Collections.emptyList();
+        }
+
+        ArrayList<Integer> data1 = new ArrayList<>();
+        ArrayList<Integer> data2 = new ArrayList<>();
+        List<String> categories = new ArrayList<>();
+
+        SimpleDateFormat sfKey = new SimpleDateFormat("yyyy-MM-dd HH");
+        SimpleDateFormat sfLabel = new SimpleDateFormat("HH:00");
+        Calendar calendar = Calendar.getInstance();
+        calendar.set(Calendar.MINUTE, 0);
+        calendar.set(Calendar.SECOND, 0);
+        calendar.set(Calendar.MILLISECOND, 0);
+        calendar.add(Calendar.HOUR_OF_DAY, -23);
+
+        for (int i = 0; i < 24; i++) {
+            String key = sfKey.format(calendar.getTime());
+            categories.add(sfLabel.format(calendar.getTime()));
+
+            int inV = 0;
+            int outV = 0;
+            for (WorkChartAxis w : listChart) {
+                if (w.getYmd() != null && key.equals(w.getYmd().trim())) {
+                    inV = w.getInqty();
+                    outV = w.getOutqty();
+                    break;
+                }
+            }
+            data1.add(inV);
+            data2.add(outV);
+            calendar.add(Calendar.HOUR_OF_DAY, 1);
+        }
+
+        AxisBean inqty = new AxisBean();
+        inqty.setName("鍏ュ簱鏁伴噺");
+        Integer[] array1 = new Integer[data1.size()];
+        inqty.setData(data1.toArray(array1));
+        list.add(inqty);
+
+        AxisBean outqty = new AxisBean();
+        outqty.setName("鍑哄簱鏁伴噺");
+        Integer[] array2 = new Integer[data2.size()];
+        outqty.setData(data2.toArray(array2));
+        list.add(outqty);
+
+        map.put("categories", categories);
+        map.put("rows", list);
+        return R.ok(map);
+    }
+
+    /**
      * 搴撳瓨淇℃伅鏌ヨ鎺ュ彛
      */
     @GetMapping("/queryLoc")
@@ -657,7 +778,11 @@
      * 浠诲姟鏌ヨ鎺ュ彛
      */
     @PostMapping("/queryTask")
-    public synchronized R queryTask(@RequestBody QueryTaskParam param) {
+    public synchronized R queryTask(@RequestBody QueryTaskParam param, HttpServletRequest request) {
+        if (request != null) {
+            log.info("[queryTask] cache: {}", param == null ? "null" : JSON.toJSONString(param));
+            request.setAttribute("cache", param);
+        }
         if (Cools.isEmpty(param)) {
             return R.parse(BaseRes.PARAM);
         }

--
Gitblit v1.9.1