From ec63fb17c5ba3e5b2a5a4106c25b4e249a2f980f Mon Sep 17 00:00:00 2001
From: liuhaonan <31457034@qq.com>
Date: 星期二, 22 十一月 2022 18:44:51 +0800
Subject: [PATCH] changes

---
 ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleService.java |   54 ++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 36 insertions(+), 18 deletions(-)

diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleService.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleService.java
index ad0af4e..0de67ea 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleService.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleService.java
@@ -60,6 +60,8 @@
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.Collectors;
 
+import static com.sandu.ximon.admin.localMQTT.callback.StatusMqttCallBack.localMqttConnectStatusMap;
+
 /**
  * 鐏潌鐩稿叧
  *
@@ -129,24 +131,26 @@
     /**
      * 鍒犻櫎鐏潌
      */
-    public boolean deletePole(Long poleId) {
-        Pole pole = getById(poleId);
-        if (pole == null) {
+    public boolean deletePole(List<Long> poleIds) {
+        List<Pole> poles = listByIds(poleIds);
+        if (poles.isEmpty()) {
             throw new BusinessException("鏈壘鍒拌鐏潌");
         }
         // 鍒犻櫎鐏潌缁戝畾鍏崇郴
-        poleBindingService.remove(Wrappers.<PoleBinding>lambdaQuery().eq(PoleBinding::getPoleId, poleId));
+        poleBindingService.remove(Wrappers.<PoleBinding>lambdaQuery().in(PoleBinding::getPoleId, poleIds));
+        SpringContextHolder.getBean(LightTaskPoleRelationService.class)
+                .remove(Wrappers.lambdaQuery(LightTaskPoleRelation.class).in(LightTaskPoleRelation::getPoleId, poleIds));
 
         /**
          * 鍒犻櫎鐏潌鏃ュ織璁板綍寮�濮�
          */
-        String content = "{鐏潌Code锛�" + pole.getDeviceCode() + "锛� 鐏潌鍚嶇О锛�" + pole.getPoleName() + " }";
+        String content = "{鐏潌id锛�" + poles + " }";
 
         StoreOperationRecordsUtils.storeOperationData(null, null, "鍒犻櫎鐏潌", content);
         /**
          * 鍒犻櫎鐏潌鏃ュ織璁板綍缁撴潫
          */
-        return removeById(poleId);
+        return removeByIds(poleIds);
     }
 
 
@@ -471,7 +475,7 @@
                 DeviceOnLineCountVO air = new DeviceOnLineCountVO();
                 airEquipments.forEach(
                         device -> {
-                            String s = redisUtils.get(DeviceRedisKey.AIR + device.getAirMac());
+                            String s = redisUtils.get(DeviceRedisKey.AIR + device.getMac());
                             if (s != null) {
                                 RedisDeviceStatus redisDeviceStatus = JSON.parseObject(s, RedisDeviceStatus.class);
                                 if (redisDeviceStatus.getStatus() == 0) {
@@ -745,7 +749,6 @@
 //        }
 //        return list;
 //    }
-
     public List<Pole> isTrue(List<Pole> list, PoleStatesParam param) {
         //瀹炰綋鐏潌
         List<Pole> isTrue = new ArrayList<>();
@@ -864,8 +867,8 @@
      *
      * @return 鏄惁鎴愬姛
      */
-    public boolean unBindPole(Long poleId, String deviceCode) {
-        return poleBindingService.unBindPole(poleId, deviceCode);
+    public boolean unBindPole(Long poleId, String deviceCode, Integer deviceType) {
+        return poleBindingService.unBindPole(poleId, deviceCode, deviceType);
     }
 
 
@@ -1049,7 +1052,7 @@
      * @return 璁惧鐘舵�佸垪琛�
      */
     public List<DeviceStatus> listStatusByDeviceCode(ArrayList<String> deviceCodeList) {
-        // 鏈�澶у彧鑳芥煡50涓�
+//         鏈�澶у彧鑳芥煡50涓�
         List<List<String>> split = CollectionUtil.split(deviceCodeList, 50);
         List<DeviceStatus> statusList = new ArrayList<>();
         for (List<String> list : split) {
@@ -1063,6 +1066,21 @@
                 }
             }
         }
+//        List<DeviceStatus> statusList = new ArrayList<>();
+//
+//        deviceCodeList.forEach(l -> {
+//                    DeviceStatus deviceStatus = new DeviceStatus();
+//                    deviceStatus.setDeviceCode(l);
+//
+//            if (localMqttConnectStatusMap.get(l)!=null &&
+//                    localMqttConnectStatusMap.get(l)== 1){
+//                deviceStatus.setStatus(1);
+//            }else {
+//                deviceStatus.setStatus(0);
+//            }
+//            statusList.add(deviceStatus);
+//        });
+
         return statusList;
     }
 
@@ -1303,16 +1321,16 @@
         Long poleId = param.getPoleId();
         Pole pole = getById(poleId);
         PoleBinding air = poleBindingService.getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getPoleId, poleId).eq(PoleBinding::getDeviceType, 3));
-        PoleBinding nova = poleBindingService.getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getPoleId, poleId).eq(PoleBinding::getDeviceType, 1));
-        LedPlayerEntity LED = SpringContextHolder.getBean(LedPlayerEntityService.class).getOne(Wrappers.lambdaQuery(LedPlayerEntity.class).eq(LedPlayerEntity::getSn, nova.getDeviceCode()));
-        if (pole == null) {
-            throw new BusinessException("鐏潌涓嶅瓨鍦�");
-        }
         if (air == null) {
             throw new BusinessException("鏈粦瀹氬ぇ姘旂洃娴嬭澶�");
         }
+        PoleBinding nova = poleBindingService.getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getPoleId, poleId).eq(PoleBinding::getDeviceType, 1));
         if (nova == null) {
             throw new BusinessException("鏈粦瀹歯ova璁惧");
+        }
+        LedPlayerEntity LED = SpringContextHolder.getBean(LedPlayerEntityService.class).getOne(Wrappers.lambdaQuery(LedPlayerEntity.class).eq(LedPlayerEntity::getSn, nova.getDeviceCode()));
+        if (pole == null) {
+            throw new BusinessException("鐏潌涓嶅瓨鍦�");
         }
         //鑾峰彇澶ф皵鐩戞祴鏁版嵁
         A5AtmosphereHeartbeatReportInnerFrame.HeartBeatDataPackage data = SpringContextHolder.getBean(AirDataService.class).getDataByPoleid(poleId);
@@ -1337,7 +1355,7 @@
         //璁剧疆瑙﹀彂鏉′欢    瀛樺叆Redis  15鍒嗛挓瓒呮椂   15鍒嗛挓鍐呭啀娆¤皟鐢ㄧ洿鎺ヨ繑鍥�
         redisUtils.set("redisStatusKeyTimeout", System.currentTimeMillis(), 60 * 15);
 
-        CountDownLatch countDownLatch = new CountDownLatch(7);//todo
+        CountDownLatch countDownLatch = new CountDownLatch(7);//todo 鍑犱釜璁惧璁剧疆涓哄嚑
         //鑾峰彇涓�涓�7浣嶉殢鏈烘暟
         String str = RandomStringUtils.randomAlphanumeric(7);
         countDownLatchUtil.push(str, countDownLatch);
@@ -1418,4 +1436,4 @@
 
     }
 
-}
\ No newline at end of file
+}

--
Gitblit v1.9.3