From 605be0c8702fc7bfe4f7fcdd397c9f0d40722b69 Mon Sep 17 00:00:00 2001
From: zwl <1051256694@qq.com>
Date: 星期四, 09 四月 2026 15:19:43 +0800
Subject: [PATCH] 1.商品档案新增最大限制和最小限制 2.mes空桶/余料回库修复

---
 src/main/java/com/zy/api/service/impl/HmesApiServiceImpl.java |   54 +++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 45 insertions(+), 9 deletions(-)

diff --git a/src/main/java/com/zy/api/service/impl/HmesApiServiceImpl.java b/src/main/java/com/zy/api/service/impl/HmesApiServiceImpl.java
index 045807b..74c3361 100644
--- a/src/main/java/com/zy/api/service/impl/HmesApiServiceImpl.java
+++ b/src/main/java/com/zy/api/service/impl/HmesApiServiceImpl.java
@@ -251,18 +251,54 @@
     }
 
     @Override
-    public R getDeviceFreezeStatus() {
-        List<BasDevice> devices = basDeviceService.selectList(new EntityWrapper<BasDevice>()
-                .eq("status", 1)
-                .orderBy("dev_no", true));
+    @Transactional(rollbackFor = Exception.class)
+    public R releaseAllLocks() {
+        EntityWrapper<LocAroundBind> frozenWrapper = new EntityWrapper<>();
+        frozenWrapper.eq("freeze", 1);
+        int frozenCount = locAroundBindService.selectCount(frozenWrapper);
+        if (frozenCount <= 0) {
+            return R.ok("鍏ㄩ儴鏈哄彴宸ヤ綅鍧囨湭鍐荤粨");
+        }
+
+        LocAroundBind updateEntity = new LocAroundBind();
+        updateEntity.setFreeze(0);
+        EntityWrapper<LocAroundBind> updateWrapper = new EntityWrapper<>();
+        updateWrapper.eq("freeze", 1);
+        if (!locAroundBindService.update(updateEntity, updateWrapper)) {
+            throw new CoolException("鍏ㄩ儴鏈哄彴宸ヤ綅瑙e喕澶辫触锛岃妫�鏌ュ悗鍐嶆搷浣滐紒锛�");
+        }
+        return R.ok("鍏ㄩ儴鏈哄彴宸ヤ綅瑙e喕鎴愬姛锛屽叡澶勭悊" + frozenCount + "涓伐浣�");
+    }
+
+    @Override
+    public R getDeviceFreezeStatus(String devNo) {
+        EntityWrapper<BasDevice> deviceWrapper = new EntityWrapper<>();
+        deviceWrapper.eq("status", 1);
+        deviceWrapper.orderBy("dev_no", true);
+        if (!Cools.isEmpty(devNo)) {
+            deviceWrapper.eq("dev_no", devNo.trim());
+        }
+        List<BasDevice> devices = basDeviceService.selectList(deviceWrapper);
         if (Cools.isEmpty(devices)) {
+            if (!Cools.isEmpty(devNo)) {
+                return R.error("鏈哄彴[" + devNo + "]涓嶅瓨鍦ㄦ垨宸茬鐢�");
+            }
             return R.ok(Collections.emptyList());
         }
 
-        List<LocAroundBind> binds = locAroundBindService.selectList(new EntityWrapper<LocAroundBind>()
-                .orderBy("dev_no", true)
-                .orderBy("order_no", true)
-                .orderBy("id", true));
+        Set<String> deviceTypes = devices.stream()
+                .map(BasDevice::getType)
+                .filter(type -> !Cools.isEmpty(type))
+                .collect(Collectors.toCollection(LinkedHashSet::new));
+
+        EntityWrapper<LocAroundBind> bindWrapper = new EntityWrapper<>();
+        bindWrapper.orderBy("dev_no", true);
+        bindWrapper.orderBy("order_no", true);
+        bindWrapper.orderBy("id", true);
+        if (!Cools.isEmpty(deviceTypes)) {
+            bindWrapper.in("dev_no", deviceTypes);
+        }
+        List<LocAroundBind> binds = locAroundBindService.selectList(bindWrapper);
         Map<String, List<LocAroundBind>> bindMap = new HashMap<>();
         if (!Cools.isEmpty(binds)) {
             bindMap = binds.stream()
@@ -305,7 +341,7 @@
         }
 
         workService.updateWrkIsSuplus(String.valueOf(mast.getWrkNo()), HMES_USER_ID, backType);
-        return workService.backLocOperation(String.valueOf(mast.getWrkNo()), HMES_USER_ID);
+        return R.ok();
     }
 
     private HmesStationFreezeStatusDto buildStationFreezeStatus(LocAroundBind bind) {

--
Gitblit v1.9.1