From d193355c76cfbec572408f9a256c970699c9a542 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期三, 18 三月 2026 15:12:55 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/ai/mcp/service/impl/WcsDataFacadeImpl.java | 153 ++++++++++++++++++++++++++++----------------------
1 files changed, 85 insertions(+), 68 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..d7fb5e7 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
@@ -6,6 +6,7 @@
import com.zy.ai.entity.DeviceConfigsData;
import com.zy.ai.log.AiLogAppender;
import com.zy.ai.mcp.service.WcsDataFacade;
+import com.zy.ai.service.MainProcessPseudocodeService;
import com.zy.asrs.entity.BasCrnp;
import com.zy.asrs.entity.BasDevp;
import com.zy.asrs.entity.BasRgv;
@@ -45,6 +46,8 @@
private WrkMastService wrkMastService;
@Autowired
private ConfigService configService;
+ @Autowired
+ private MainProcessPseudocodeService mainProcessPseudocodeService;
@Override
public Object getCrnDeviceStatus(JSONObject args) {
@@ -124,26 +127,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;
}
@@ -219,74 +279,12 @@
}
@Override
- public Object buildDiagnosisSnapshot(JSONObject args) {
- String wh = mustStr(args, "warehouseCode");
- List<String> crnDeviceNos = optStrList(args, "crnDeviceNos");
- List<String> taskIds = optStrList(args, "taskIds");
- int lookbackSeconds = optInt(args, "lookbackSeconds", 300);
- int logMaxLines = optInt(args, "logMaxLines", 600);
- boolean includeConfig = optBool(args, "includeConfig", true);
-
- long now = System.currentTimeMillis();
- long fromTs = now - lookbackSeconds * 1000L;
-
- // 1) crn devices
- JSONObject devArgs = new JSONObject();
- devArgs.put("deviceNos", crnDeviceNos);
- JSONObject devices = (JSONObject) getCrnDeviceStatus(devArgs);
-
- // 2) tasks
- JSONObject taskArgs = new JSONObject();
- taskArgs.put("warehouseCode", wh);
- taskArgs.put("taskIds", taskIds);
- taskArgs.put("limit", 200);
- JSONObject tasks = (JSONObject) getTasks(taskArgs);
-
- // 3) logs (涓�娆℃�у彇鍥烇紝鐒跺悗鍋氬垎妗�+鎺掑簭+鎴柇)
- JSONObject logArgs = new JSONObject();
- logArgs.put("warehouseCode", wh);
- logArgs.put("fromTs", fromTs);
- logArgs.put("toTs", now);
-// logArgs.put("deviceIds", deviceIds);
- logArgs.put("taskIds", taskIds);
- logArgs.put("maxLines", logMaxLines);
- JSONObject logs = (JSONObject) getLogs(logArgs);
-
- // 4) 缁撴瀯鍖栧揩鐓ц緭鍑猴紙寤鸿锛氬垎妗讹級
- JSONObject snapshot = new JSONObject();
- snapshot.put("warehouseCode", wh);
- snapshot.put("generatedTs", now);
- snapshot.put("timeRange", new JSONObject()
- .fluentPut("fromTs", fromTs)
- .fluentPut("toTs", now)
- .fluentPut("lookbackSeconds", lookbackSeconds));
-
- snapshot.put("devices", devices);
- snapshot.put("tasks", tasks);
- snapshot.put("logs", logs);
-
- JSONArray hints = new JSONArray();
- hints.add("Prefer diagnosing with snapshot.devices + snapshot.tasks + snapshot.logs");
- hints.add("Logs are already filtered by time range; if missing, expand lookbackSeconds");
- snapshot.put("hints", hints);
-
- JSONObject data = new JSONObject();
- data.put("snapshot", snapshot);
- return data;
+ public Object getSystemPseudocode(JSONObject args) {
+ boolean refresh = optBool(args, "refresh", false);
+ return mainProcessPseudocodeService.queryMainProcessPseudocode(refresh);
}
// --------- helpers ---------
-
- private String mustStr(JSONObject o, String key) {
- if (o == null || o.getString(key) == null || o.getString(key).trim().isEmpty())
- throw new IllegalArgumentException(key + " is required");
- return o.getString(key).trim();
- }
-
- private long mustLong(JSONObject o, String key) {
- if (o == null || !o.containsKey(key)) throw new IllegalArgumentException(key + " is required");
- return o.getLongValue(key);
- }
private int optInt(JSONObject o, String key, int def) {
if (o == null || !o.containsKey(key)) return def;
@@ -310,6 +308,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