From e55c8b0a92eb9715edd90c31dfd4de51a47b588b Mon Sep 17 00:00:00 2001
From: liuhaonan <31457034@qq.com>
Date: 星期五, 04 十一月 2022 17:40:08 +0800
Subject: [PATCH] changes

---
 ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleService.java |  101 ++++++++++++++++++++++++--------------------------
 1 files changed, 49 insertions(+), 52 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 fd3dbab..7d542dc 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
@@ -129,24 +129,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);
     }
 
 
@@ -369,9 +371,9 @@
         BaseConditionVO baseConditionVO = new BaseConditionVO();
         baseConditionVO.setPageNo(1);
         baseConditionVO.setPageSize(999);
-        System.out.println("鍗曠伅鏁呴殰缁熻鏃堕棿: "+ LocalDateTime.now());
+        System.out.println("鍗曠伅鏁呴殰缁熻鏃堕棿: " + LocalDateTime.now());
         CommonPage commonPage = SpringContextHolder.getBean(LightReportErrorService.class).queryErrorCode(baseConditionVO);
-        System.out.println("鍗曠伅鏁呴殰缁熻鏃堕棿: "+ LocalDateTime.now());
+        System.out.println("鍗曠伅鏁呴殰缁熻鏃堕棿: " + LocalDateTime.now());
         new Thread(new Runnable() {
             @Override
             public void run() {
@@ -379,7 +381,6 @@
                 AtomicInteger onLine = new AtomicInteger(0);
                 AtomicInteger offLine = new AtomicInteger(0);
                 AtomicInteger error = new AtomicInteger(commonPage.getList().size());
-
 
 
                 DeviceOnLineCountVO light = new DeviceOnLineCountVO();
@@ -426,20 +427,19 @@
                 DeviceOnLineCountVO c3m = new DeviceOnLineCountVO();
                 c3mChargings.forEach(
                         device -> {
-//                            RedisUtils.getBean().set(C3mRedisConstant.C3_STATUS.getCode() + heartbeatReportInnerFrame.getHeartBeatDataPackage().getC3Mac()
-//                                    , heartbeatReportInnerFrame.getHeartBeatDataPackage(), 300L);
                             String s = redisUtils.get(C3mRedisConstant.C3_STATUS.getCode() + device.getC3Mac());
                             RedisDeviceStatus redisDeviceStatus = new RedisDeviceStatus();
                             redisDeviceStatus.setDeviceId(device.getC3Id().toString());
                             if (s != null) {
                                 A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage heartBeatDataPackage = JSON.parseObject(s, A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage.class);
+                                //  鍏呯數妗╁彛鐘舵�佷綅  1.绌洪棽 2.鍏呯數涓� 3.鍏呯數涓柇锛岀瓑寰呮湇鍔″櫒纭 4.鍏呯數缁撴潫锛岀瓑寰呮湇鍔″櫒纭 5.鏈夋晠闅� 6.涓庡厖鐢垫々瀵规帴涓�
                                 if ("5".equals(heartBeatDataPackage.getStatusBit())) {
-                                    //鍦ㄧ嚎
-                                    onLine.getAndIncrement();
-                                } else {
                                     //鏁呴殰
                                     onLine.getAndIncrement();
                                     error.getAndIncrement();
+                                } else {
+                                    //鍦ㄧ嚎
+                                    onLine.getAndIncrement();
                                 }
                             } else {
                                 //绂荤嚎
@@ -473,7 +473,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) {
@@ -729,25 +729,24 @@
      * @param param
      * @return
      */
-    public List<Pole> isBind(List<Pole> list, PoleStatesParam param) {
-        List<Pole> bindList = new ArrayList<>();//宸茬粦瀹氬鎴�
-        List<Pole> unbindList = new ArrayList<>();//鏈粦瀹氬鎴�
-        list.forEach(bindwarpper -> {
-//                Long clientId = bindwarpper.getClientId();
-            if (bindwarpper.getClientId() == null) {//鍒ゆ柇鏄惁缁戝畾
-                unbindList.add(bindwarpper);
-            } else {
-                bindList.add(bindwarpper);
-            }
-        });
-        if (param.getBingStates() == 0) {
-            return bindList;
-        } else if (param.getBingStates() == 1) {
-            return unbindList;
-        }
-        return list;
-    }
-
+//    public List<Pole> isBind(List<Pole> list, PoleStatesParam param) {
+//        List<Pole> bindList = new ArrayList<>();//宸茬粦瀹氬鎴�
+//        List<Pole> unbindList = new ArrayList<>();//鏈粦瀹氬鎴�
+//        list.forEach(bindwarpper -> {
+////                Long clientId = bindwarpper.getClientId();
+//            if (bindwarpper.getClientId() == null) {//鍒ゆ柇鏄惁缁戝畾
+//                unbindList.add(bindwarpper);
+//            } else {
+//                bindList.add(bindwarpper);
+//            }
+//        });
+//        if (param.getBingStates() == 0) {
+//            return bindList;
+//        } else if (param.getBingStates() == 1) {
+//            return unbindList;
+//        }
+//        return list;
+//    }
     public List<Pole> isTrue(List<Pole> list, PoleStatesParam param) {
         //瀹炰綋鐏潌
         List<Pole> isTrue = new ArrayList<>();
@@ -866,8 +865,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);
     }
 
 
@@ -884,7 +883,7 @@
         }
         String deviceName = byId.getDeviceCode();
         if (deviceName.isEmpty()) {
-            throw new BusinessException("璇ョ伅鏉哅ca涓虹┖");
+            throw new BusinessException("璇ョ伅鏉哅ac涓虹┖");
         }
         IRequestFrame build = FrameBuilder.builderA5().orderType(A5OrderEnum.REQUEST_LIGHT_DATA.getCode()).innerFrame(new A5LightResetReqInnerFrame()).build();
         CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(deviceName, build);
@@ -1111,7 +1110,11 @@
             if (pole == null) {
                 throw new BusinessException("鐏潌涓嶅瓨鍦�");
             }
+
+            //涓�绾у鎴�   -1   userId
+            //浜岀骇瀹㈡埛   涓婄骇瀹㈡埛id  userId
             pole.setClientId(-1L);
+            pole.setUserId(-1L);
             r = updateById(pole);
 
             if (!r) {
@@ -1125,22 +1128,15 @@
 
     public List<Pole> getOwnerPole(BaseConditionVO baseConditionVO, String keyword, Long cilentId) {
         LambdaQueryWrapper<Pole> eq;
-//        if(SecurityUtils.getClientId()!=null){
-        PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
         if (clientService.findClientId(cilentId)) {
-            eq = Wrappers.lambdaQuery(Pole.class).eq(Pole::getUserId, cilentId);
+            eq = Wrappers.lambdaQuery(Pole.class).eq(Pole::getClientId, cilentId);
         } else {
-            PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
             eq = Wrappers.lambdaQuery(Pole.class).eq(Pole::getClientId, cilentId).or(pole -> {
                 pole.eq(Pole::getUserId, cilentId);
             });
         }
 
-//        }else {
-//            PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
-//            eq = Wrappers.lambdaQuery(Pole.class);
-//        }
-        PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
+
         if (!keyword.isEmpty()) {
             eq.like(Pole::getPoleName, keyword).or(code -> {
                 code.like(Pole::getPoleCode, keyword);
@@ -1148,6 +1144,7 @@
                 deviceCode.like(Pole::getDeviceCode, keyword);
             });
         }
+        PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
         List<Pole> list;
         list = list(eq);
         setCount(list);
@@ -1307,16 +1304,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);
@@ -1339,7 +1336,7 @@
         }
 
         //璁剧疆瑙﹀彂鏉′欢    瀛樺叆Redis  15鍒嗛挓瓒呮椂   15鍒嗛挓鍐呭啀娆¤皟鐢ㄧ洿鎺ヨ繑鍥�
-        redisUtils.set("redisStatusKeyTimeout", System.currentTimeMillis(), 60*15);
+        redisUtils.set("redisStatusKeyTimeout", System.currentTimeMillis(), 60 * 15);
 
         CountDownLatch countDownLatch = new CountDownLatch(7);//todo
         //鑾峰彇涓�涓�7浣嶉殢鏈烘暟

--
Gitblit v1.9.3