From 6e18b1e086f202512eeb9aa988a8b9026cfccec3 Mon Sep 17 00:00:00 2001
From: zwl <1051256694@qq.com>
Date: 星期六, 28 三月 2026 20:28:27 +0800
Subject: [PATCH] 修复

---
 src/main/java/com/zy/api/service/impl/HmesApiServiceImpl.java |   52 ++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 44 insertions(+), 8 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..36abd52 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()

--
Gitblit v1.9.1