From 03267d87fade82578087123a1be515b6fde20bfb Mon Sep 17 00:00:00 2001
From: zhanzhiqin <895896009@qq.com>
Date: 星期二, 17 五月 2022 14:19:01 +0800
Subject: [PATCH] 日志

---
 ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleService.java |  156 +++++++++++++++++++++++++++-------------------------
 1 files changed, 81 insertions(+), 75 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 f892597..770f415 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
@@ -15,7 +15,6 @@
 import com.sandu.common.util.SpringContextHolder;
 import com.sandu.ximon.admin.dto.DeviceStatus;
 import com.sandu.ximon.admin.dto.WaterQualityDataDto;
-import com.sandu.ximon.admin.entity.Command;
 import com.sandu.ximon.admin.manager.iot.frame.A1Frame;
 import com.sandu.ximon.admin.manager.iot.frame.FrameBuilder;
 import com.sandu.ximon.admin.manager.iot.frame.IRequestFrame;
@@ -35,6 +34,7 @@
 import com.sandu.ximon.admin.utils.LightemitUtils;
 import com.sandu.ximon.admin.utils.ListPagingUtils;
 import com.sandu.ximon.admin.utils.RedisUtils;
+import com.sandu.ximon.admin.utils.StoreOperationRecordsUtils;
 import com.sandu.ximon.admin.utils.response.VnnoxResult;
 import com.sandu.ximon.admin.vo.PoleBindVO;
 import com.sandu.ximon.dao.bo.*;
@@ -70,7 +70,17 @@
         BeanUtils.copyProperties(param, pole);
         pole.setPoleCode(generatePoleCode());
         pole.setDeviceType(-1);
-        return save(pole);
+        boolean save = save(pole);
+
+        /**
+         * 鏂板铏氭嫙鐏潌鏃ュ織璁板綍寮�濮�
+         */
+        String content = "{鐏潌ID锛�" + pole.getId() + "锛� 鐏潌鍚嶏細" + param.getPoleName() + "}";
+        StoreOperationRecordsUtils.storeOperationData(null, null, "鏂板铏氭嫙鐏潌", content);
+        /**
+         * 鏂板铏氭嫙鐏潌鏃ュ織璁板綍缁撴潫
+         */
+        return save;
     }
 
     public boolean updatePole(Long poleId, PoleParam param) {
@@ -88,6 +98,14 @@
         Pole update = new Pole();
         BeanUtils.copyProperties(param, update);
         update.setId(poleId);
+        /**
+         * 淇敼鐏潌鏃ュ織璁板綍寮�濮�
+         */
+        String content = "缂栬緫鐏潌锛�" + poleId;
+        StoreOperationRecordsUtils.storeOperationData(null, null, "缂栬緫鐏潌", content);
+        /**
+         * 淇敼鐏潌鏃ュ織璁板綍缁撴潫
+         */
         return updateById(update);
     }
 
@@ -101,6 +119,16 @@
         }
         // 鍒犻櫎鐏潌缁戝畾鍏崇郴
         poleBindingService.remove(Wrappers.<PoleBinding>lambdaQuery().eq(PoleBinding::getPoleId, poleId));
+
+        /**
+         * 鍒犻櫎鐏潌鏃ュ織璁板綍寮�濮�
+         */
+        String content = "{鐏潌Code锛�" + pole.getDeviceCode() + "锛� 鐏潌鍚嶇О锛�" + pole.getPoleName() + " }";
+
+        StoreOperationRecordsUtils.storeOperationData(null, null, "鍒犻櫎鐏潌", content);
+        /**
+         * 鍒犻櫎鐏潌鏃ュ織璁板綍缁撴潫
+         */
         return removeById(poleId);
     }
 
@@ -135,10 +163,9 @@
         if (SecurityUtils.getClientId() == null) {
             wrapper = Wrappers.lambdaQuery(Pole.class);
         } else {
-            wrapper = Wrappers.lambdaQuery(Pole.class).eq(Pole::getClientId, SecurityUtils.getUserId()).or(
-                    w -> {
-                        w.eq(Pole::getUserId, SecurityUtils.getUserId());
-                    });
+            wrapper = Wrappers.lambdaQuery(Pole.class).eq(Pole::getClientId, SecurityUtils.getUserId()).or(w -> {
+                w.eq(Pole::getUserId, SecurityUtils.getUserId());
+            });
         }
         //鐏潌
         List<Pole> list = list(wrapper);
@@ -162,8 +189,7 @@
         BroadcastTerminalV2Param broadcastTerminalV2Param = new BroadcastTerminalV2Param();
         broadcastTerminalV2Param.setBindingState(2);
         broadcastTerminalV2Param.setWorkState(2);
-        List<BroadcastTerminalV2EntityBo> broadcastTerminalList
-                = SpringContextHolder.getBean(IpVolumeService.class).getBroadcastTerminalList(null, broadcastTerminalV2Param);
+        List<BroadcastTerminalV2EntityBo> broadcastTerminalList = SpringContextHolder.getBean(IpVolumeService.class).getBroadcastTerminalList(null, broadcastTerminalV2Param);
         for (BroadcastTerminalV2EntityBo bean : broadcastTerminalList) {
             if (bean.getStatus() == 1 || bean.getStatus() == 0) {
                 number++;
@@ -228,12 +254,10 @@
         result.put("AirEquipmentNongGengTotalCount", airEquipmentNongGengBos.size());
         //姘磋川
         number = 0;
-        List<WaterQualityEquipmentBo> waterQualityEquipments
-                = SpringContextHolder.getBean(WaterQualityEquipmentService.class).listWaterQualityEquipmentByKeyword(null, null);
+        List<WaterQualityEquipmentBo> waterQualityEquipments = SpringContextHolder.getBean(WaterQualityEquipmentService.class).listWaterQualityEquipmentByKeyword(null, null);
 
         for (WaterQualityEquipmentBo waterQualityEquipmentBo : waterQualityEquipments) {
-            WaterQualityDataDto waterQualityDataDto
-                    = SpringContextHolder.getBean(WaterQualityDataService.class).getWaterQualityDataInfo(waterQualityEquipmentBo.getWaterQualityEquipmentCode());
+            WaterQualityDataDto waterQualityDataDto = SpringContextHolder.getBean(WaterQualityDataService.class).getWaterQualityDataInfo(waterQualityEquipmentBo.getWaterQualityEquipmentCode());
             if (waterQualityDataDto != null) {
                 number++;
             }
@@ -242,8 +266,7 @@
         result.put("WaterQualityEquipmentTotalCount", waterQualityEquipments.size());
         //鐏潌鍊炬枩
         number = 0;
-        List<LightPoleHeeling> lightPoleHeelings
-                = SpringContextHolder.getBean(LightPoleHeelingService.class).listLightPoleHeelingByKeyword(null, null);
+        List<LightPoleHeeling> lightPoleHeelings = SpringContextHolder.getBean(LightPoleHeelingService.class).listLightPoleHeelingByKeyword(null, null);
 
         for (LightPoleHeeling lightPoleHeeling : lightPoleHeelings) {
             if (RedisUtils.getBean().get(LightPoleHeelingEnum.LIGHT_POLE_HEELING_STATE.getCode() + lightPoleHeeling.getMac()) != null) {
@@ -451,11 +474,9 @@
             wrapper = Wrappers.lambdaQuery(Pole.class).eq(Pole::getClientId, SecurityUtils.getUserId());
         }
         if (!keyword.isEmpty()) {
-            wrapper.like(Pole::getPoleCode, keyword).or(
-                    wrappers -> {
-                        wrappers.like(Pole::getPoleName, keyword);
-                    }
-            );
+            wrapper.like(Pole::getPoleCode, keyword).or(wrappers -> {
+                wrappers.like(Pole::getPoleName, keyword);
+            });
         }
         list = list(wrapper);
         List<String> MacCodes = new ArrayList<>();
@@ -519,19 +540,12 @@
         if (deviceName.isEmpty()) {
             throw new BusinessException("璇ョ伅鏉哅ca涓虹┖");
         }
-        IRequestFrame build = FrameBuilder.builderA5()
-                .orderType(A5OrderEnum.REQUEST_LIGHT_DATA.getCode())
-                .innerFrame(new A5LightResetReqInnerFrame())
-                .build();
-        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance()
-                .sendRRPC(deviceName, build);
+        IRequestFrame build = FrameBuilder.builderA5().orderType(A5OrderEnum.REQUEST_LIGHT_DATA.getCode()).innerFrame(new A5LightResetReqInnerFrame()).build();
+        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(deviceName, build);
 
         System.out.println(commonFrame.toString());
 
-        CommonFrame rebootFrame = MainBoardInvokeSyncService.getInstance()
-                .sendRRPC(deviceName,
-                        FrameBuilder.builderA2().innerFrame(new EmptyRequestInnerFrame())
-                                .orderType(A2OrderEnum.REQUEST_MAIN_BOARD_RESET.getCode()).build());
+        CommonFrame rebootFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(deviceName, FrameBuilder.builderA2().innerFrame(new EmptyRequestInnerFrame()).orderType(A2OrderEnum.REQUEST_MAIN_BOARD_RESET.getCode()).build());
 
 
         boolean b = false;
@@ -540,6 +554,14 @@
             b = updateById(byId);
             System.out.println("閲嶅惎鎴愬姛");
         }
+        /**
+         * 鐏潌鎭㈠鍑哄巶璁剧疆鏃ュ織璁板綍寮�濮�
+         */
+        String content = "{鐏潌ID锛�" + id + " }";
+        StoreOperationRecordsUtils.storeOperationData(null, null, "鐏潌鎭㈠鍑哄巶璁剧疆", content);
+        /**
+         * 鐏潌鎭㈠鍑哄巶璁剧疆鏃ュ織璁板綍缁撴潫
+         */
         return b;
     }
 
@@ -557,8 +579,7 @@
         boolean setMac = false;
         //String baseMac = "baseDevice";
         A1Frame a1Frame = new A1Frame(A1OrderEnum.REQUEST_READ_DEVICE_UNIQUE_MAC.getCode(), new EmptyRequestInnerFrame());
-        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance()
-                .sendRRPC(baseMac, a1Frame);
+        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(baseMac, a1Frame);
         if (commonFrame == null) {
             throw new BusinessException("璇诲彇璁惧鍞竴ID澶辫触");
         }
@@ -583,33 +604,21 @@
         log.info(deviceDetail.toString());
 
         // 4   閰嶇疆Mac鈶�
-        WrapResponseCommonFrame<A1TernaryCodeRespInnerFrame> productKeyResp = MainBoardInvokeSyncService.getInstance()
-                .sendRRPC(baseMac,
-                        FrameBuilder.builderA1().innerFrame(new A1TernaryCodeReqInnerFrame(MainBoardInvokeSyncService.getInstance().getProductKey()))
-                                .orderType(A1OrderEnum.REQUEST_SET_PRODUCT_KEY.getCode()).build(),
-                        A1TernaryCodeRespInnerFrame.class);
+        WrapResponseCommonFrame<A1TernaryCodeRespInnerFrame> productKeyResp = MainBoardInvokeSyncService.getInstance().sendRRPC(baseMac, FrameBuilder.builderA1().innerFrame(new A1TernaryCodeReqInnerFrame(MainBoardInvokeSyncService.getInstance().getProductKey())).orderType(A1OrderEnum.REQUEST_SET_PRODUCT_KEY.getCode()).build(), A1TernaryCodeRespInnerFrame.class);
         A1TernaryCodeRespInnerFrame responseInnerFrame = productKeyResp.getResponseInnerFrame();
         if (!MainBoardInvokeSyncService.getInstance().getProductKey().equals(responseInnerFrame.getTernaryCode())) {
             throw new BusinessException("璁惧閰嶇疆ProductKey澶辫触");
         }
 
         // 5   閰嶇疆Mac鈶�
-        WrapResponseCommonFrame<A1TernaryCodeRespInnerFrame> responseCommonFrame = MainBoardInvokeSyncService.getInstance()
-                .sendRRPC(baseMac,
-                        FrameBuilder.builderA1().innerFrame(new A1TernaryCodeReqInnerFrame(uniqueMac))
-                                .orderType(A1OrderEnum.REQUEST_SET_DEVICE_NAME.getCode()).build(),
-                        A1TernaryCodeRespInnerFrame.class);
+        WrapResponseCommonFrame<A1TernaryCodeRespInnerFrame> responseCommonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(baseMac, FrameBuilder.builderA1().innerFrame(new A1TernaryCodeReqInnerFrame(uniqueMac)).orderType(A1OrderEnum.REQUEST_SET_DEVICE_NAME.getCode()).build(), A1TernaryCodeRespInnerFrame.class);
         A1TernaryCodeRespInnerFrame deviceNameFrame = responseCommonFrame.getResponseInnerFrame();
         if (!uniqueMac.equals(deviceNameFrame.getTernaryCode())) {
             throw new BusinessException("璁惧閰嶇疆鍚嶅け璐�");
         }
 
         // 6  閰嶇疆Mac鈶�
-        WrapResponseCommonFrame<A1TernaryCodeRespInnerFrame> wrapResponseCommonFrame = MainBoardInvokeSyncService.getInstance()
-                .sendRRPC(baseMac,
-                        FrameBuilder.builderA1().innerFrame(new A1TernaryCodeReqInnerFrame(deviceDetail.getDeviceSecret()))
-                                .orderType(A1OrderEnum.REQUEST_SET_DEVICE_SECRET.getCode()).build(),
-                        A1TernaryCodeRespInnerFrame.class);
+        WrapResponseCommonFrame<A1TernaryCodeRespInnerFrame> wrapResponseCommonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(baseMac, FrameBuilder.builderA1().innerFrame(new A1TernaryCodeReqInnerFrame(deviceDetail.getDeviceSecret())).orderType(A1OrderEnum.REQUEST_SET_DEVICE_SECRET.getCode()).build(), A1TernaryCodeRespInnerFrame.class);
         A1TernaryCodeRespInnerFrame deviceSecretFrame = wrapResponseCommonFrame.getResponseInnerFrame();
         if (!deviceDetail.getDeviceSecret().equals(deviceSecretFrame.getTernaryCode())) {
             throw new BusinessException("璁惧瀵嗛挜澶辫触");
@@ -617,10 +626,7 @@
 
 
         // 7  閲嶅惎璁惧  骞朵娇鐢ㄦ柊鐨凪ac
-        CommonFrame rebootFrame = MainBoardInvokeSyncService.getInstance()
-                .sendRRPC(baseMac,
-                        FrameBuilder.builderA2().innerFrame(new EmptyRequestInnerFrame())
-                                .orderType(A2OrderEnum.REQUEST_MAIN_BOARD_RESET.getCode()).build());
+        CommonFrame rebootFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(baseMac, FrameBuilder.builderA2().innerFrame(new EmptyRequestInnerFrame()).orderType(A2OrderEnum.REQUEST_MAIN_BOARD_RESET.getCode()).build());
         if ("00".equals(rebootFrame.getPayload())) {
             //  pole.setDeviceCode(uniqueMac);
 
@@ -629,7 +635,11 @@
             System.out.println("閲嶅惎鎴愬姛");
         }
 
-        Pole pole = new Pole();
+
+        Pole pole = getOne(Wrappers.lambdaQuery(Pole.class).eq(Pole::getDeviceCode, uniqueMac));
+        if (pole == null) {
+            pole = new Pole();
+        }
       /*  String type = uniqueMac.substring(uniqueMac.length() - 2, uniqueMac.length());
         String Code = uniqueMac.substring(0, uniqueMac.length() - 2);*/
         pole.setDeviceCode(uniqueMac);
@@ -642,16 +652,20 @@
         }
 
         pole.setPoleCode(generatePoleCode());
-        Pole one = getOne(Wrappers.lambdaQuery(Pole.class).eq(Pole::getDeviceCode, uniqueMac));
 //        setMac = save(pole);
-        if (one == null) {
-            return save(pole);
-        } else {
-            pole.setId(one.getId());
-            return updateById(pole);
-        }
 
+        boolean result = saveOrUpdate(pole);
 
+        /**
+         * 瀹炰綋鐏潌娉ㄥ唽鏃ュ織璁板綍寮�濮�
+         */
+        String content = "{鐏潌ID锛�" + pole.getId() + ",鐏潌缂栧彿锛�" + pole.getPoleCode() + ",鐏潌鍚嶇О锛�" + pole.getPoleName() + ",鐏潌绫诲瀷锛�" + pole.getDeviceType() + ",鐏潌MAC锛�" + pole.getDeviceCode() + " }";
+        StoreOperationRecordsUtils.storeOperationData(null, null, "瀹炰綋鐏潌娉ㄥ唽", content);
+        /**
+         * 瀹炰綋鐏潌娉ㄥ唽鏃ュ織璁板綍缁撴潫
+         */
+
+        return result;
     }
 
     public List<String> listDeviceCodeByIds(List<Long> poleIdList) {
@@ -659,8 +673,7 @@
             return null;
         }
         List<Pole> list = list(Wrappers.lambdaQuery(Pole.class).in(Pole::getId, poleIdList).select(Pole::getDeviceCode));
-        return list
-                .stream().filter(Objects::nonNull).map(Pole::getDeviceCode).filter(StrUtil::isNotEmpty).collect(Collectors.toList());
+        return list.stream().filter(Objects::nonNull).map(Pole::getDeviceCode).filter(StrUtil::isNotEmpty).collect(Collectors.toList());
     }
 
     /**
@@ -724,12 +737,9 @@
             eq = Wrappers.lambdaQuery(Pole.class).eq(Pole::getUserId, cilentId);
         } else {
             PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
-            eq = Wrappers.lambdaQuery(Pole.class).eq(Pole::getClientId, cilentId)
-                    .or(
-                            pole -> {
-                                pole.eq(Pole::getUserId, cilentId);
-                            }
-                    );
+            eq = Wrappers.lambdaQuery(Pole.class).eq(Pole::getClientId, cilentId).or(pole -> {
+                pole.eq(Pole::getUserId, cilentId);
+            });
         }
 
 //        }else {
@@ -738,15 +748,11 @@
 //        }
         PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
         if (!keyword.isEmpty()) {
-            eq.like(Pole::getPoleName, keyword).or(
-                    code -> {
-                        code.like(Pole::getPoleCode, keyword);
-                    }
-            ).or(
-                    deviceCode -> {
-                        deviceCode.like(Pole::getDeviceCode, keyword);
-                    }
-            );
+            eq.like(Pole::getPoleName, keyword).or(code -> {
+                code.like(Pole::getPoleCode, keyword);
+            }).or(deviceCode -> {
+                deviceCode.like(Pole::getDeviceCode, keyword);
+            });
         }
         List<Pole> list;
         list = list(eq);

--
Gitblit v1.9.3