From 7e52962b703cdb572885cc394d039bc635d979fd Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期五, 13 三月 2026 13:27:22 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/ai/mcp/service/impl/WcsDataFacadeImpl.java |   82 +++++++++++++++++++++++++++++++++++++++-
 1 files changed, 79 insertions(+), 3 deletions(-)

diff --git a/src/main/java/com/zy/ai/mcp/service/impl/WcsDataFacadeImpl.java b/src/main/java/com/zy/ai/mcp/service/impl/WcsDataFacadeImpl.java
index 5b65c21..2efa2a0 100644
--- a/src/main/java/com/zy/ai/mcp/service/impl/WcsDataFacadeImpl.java
+++ b/src/main/java/com/zy/ai/mcp/service/impl/WcsDataFacadeImpl.java
@@ -124,26 +124,83 @@
     @Override
     public Object getTasks(JSONObject args) {
         int crnNo = optInt(args, "crnNo", -1);
+        int dualCrnNo = optInt(args, "dualCrnNo", -1);
         int rgvNo = optInt(args, "rgvNo", -1);
-        List<Integer> taskNos = optIntList(args, "taskNos");
+        int sourceStaNo = optInt(args, "sourceStaNo", -1);
+        int staNo = optInt(args, "staNo", -1);
+        List<Integer> wrkNos = optIntList(args, "wrkNos");
+        if (wrkNos.isEmpty()) {
+            wrkNos = optIntList(args, "taskNos");
+        }
+        List<String> wmsWrkNos = optStrList(args, "wmsWrkNos");
+        List<Long> wrkStsList = optLongList(args, "wrkStsList");
+        List<Integer> ioTypeList = optIntList(args, "ioTypeList");
+        String barcode = optStr(args, "barcode");
+        String batch = optStr(args, "batch");
+        String sourceLocNo = optStr(args, "sourceLocNo");
+        String locNo = optStr(args, "locNo");
         int limit = optInt(args, "limit", 200);
 
         QueryWrapper<WrkMast> wrapper = new QueryWrapper<>();
-        if (taskNos != null && taskNos.size() > 0) {
-            wrapper.in("wrk_no", taskNos);
+        if (!wrkNos.isEmpty()) {
+            wrapper.in("wrk_no", wrkNos);
+        }
+
+        if (!wmsWrkNos.isEmpty()) {
+            wrapper.in("wms_wrk_no", wmsWrkNos);
+        }
+
+        if (!wrkStsList.isEmpty()) {
+            wrapper.in("wrk_sts", wrkStsList);
+        }
+
+        if (!ioTypeList.isEmpty()) {
+            wrapper.in("io_type", ioTypeList);
         }
 
         if (crnNo != -1) {
             wrapper.eq("crn_no", crnNo);
         }
 
+        if (dualCrnNo != -1) {
+            wrapper.eq("dual_crn_no", dualCrnNo);
+        }
+
         if (rgvNo != -1) {
             wrapper.eq("rgv_no", rgvNo);
         }
 
+        if (sourceStaNo != -1) {
+            wrapper.eq("source_sta_no", sourceStaNo);
+        }
+
+        if (staNo != -1) {
+            wrapper.eq("sta_no", staNo);
+        }
+
+        if (barcode != null) {
+            wrapper.like("barcode", barcode);
+        }
+
+        if (batch != null) {
+            wrapper.like("batch", batch);
+        }
+
+        if (sourceLocNo != null) {
+            wrapper.like("source_loc_no", sourceLocNo);
+        }
+
+        if (locNo != null) {
+            wrapper.like("loc_no", locNo);
+        }
+
+        int safeLimit = Math.max(1, Math.min(limit, 500));
+        wrapper.orderByDesc("io_time").orderByDesc("appe_time").last("limit " + safeLimit);
+
         List<WrkMast> tasks = wrkMastService.list(wrapper);
         JSONObject data = new JSONObject();
         data.put("tasks", tasks);
+        data.put("count", tasks.size());
         return data;
     }
 
@@ -310,6 +367,25 @@
         return list;
     }
 
+    private String optStr(JSONObject o, String key) {
+        if (o == null || !o.containsKey(key)) return null;
+        String value = o.getString(key);
+        if (value == null || value.trim().isEmpty()) return null;
+        return value.trim();
+    }
+
+    private List<Long> optLongList(JSONObject o, String key) {
+        if (o == null || !o.containsKey(key)) return Collections.emptyList();
+        JSONArray arr = o.getJSONArray(key);
+        if (arr == null) return Collections.emptyList();
+        List<Long> list = new ArrayList<>();
+        for (int i = 0; i < arr.size(); i++) {
+            String s = arr.getString(i);
+            if (s != null && !s.trim().isEmpty()) list.add(Long.parseLong(s.trim()));
+        }
+        return list;
+    }
+
     private List<Integer> optIntList(JSONObject o, String key) {
         if (o == null || !o.containsKey(key)) return Collections.emptyList();
         JSONArray arr = o.getJSONArray(key);

--
Gitblit v1.9.1