From c82f9100d3586218e9e41497c2cea73a2cac44fe Mon Sep 17 00:00:00 2001
From: lty <876263681@qq.com>
Date: 星期一, 20 四月 2026 15:03:32 +0800
Subject: [PATCH] #库存上下限预警导出修复

---
 src/main/java/com/zy/api/service/impl/HmesApiServiceImpl.java |   58 +++++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 47 insertions(+), 11 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..ed7dfd7 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()
@@ -298,14 +334,14 @@
 
         WrkMast mast = findBackLocWrkMast(params);
         if (Objects.isNull(mast)) {
-            return R.error("鏈煡璇㈠埌鍙洖搴撶殑浠诲姟妗�");
+            return R.error("宸插洖搴擄紝璇峰嬁閲嶅鎿嶄綔");
         }
         if (!Objects.equals(mast.getWrkSts(), 15L)) {
-            return R.error("褰撳墠浠诲姟鐘舵�佷笉鑳芥墽琛屽洖搴擄紒");
+            return R.error("褰撳墠浠诲姟鐘舵�佷笉鏄�15.鍑哄簱鏇存柊瀹屾垚,涓嶈兘鎵ц鍥炲簱锛�");
         }
 
         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