From d5dab0a85de9573ff61e20794af04129dd4b2f87 Mon Sep 17 00:00:00 2001
From: zhanzhiqin <895896009@qq.com>
Date: 星期一, 01 八月 2022 18:30:24 +0800
Subject: [PATCH] 大气设备

---
 ximon-admin/src/main/java/com/sandu/ximon/admin/service/AirEquipmentService.java |  156 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 155 insertions(+), 1 deletions(-)

diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/AirEquipmentService.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/AirEquipmentService.java
index 268fc5d..0cc94e5 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/AirEquipmentService.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/AirEquipmentService.java
@@ -5,7 +5,16 @@
 import com.sandu.common.execption.BusinessException;
 import com.sandu.common.object.BaseConditionVO;
 import com.sandu.common.service.impl.BaseServiceImpl;
+import com.sandu.common.util.SpringContextHolder;
+import com.sandu.ximon.admin.manager.iot.frame.A5Frame;
+import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5AtmosphereHeartBeatTimeReportInnerFrame;
+import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5AtmosphereOperationReportInnerFrame;
+import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5AtmosphereQuerySensorInfoReportInnerFrame;
+import com.sandu.ximon.admin.manager.iot.frame.inner.request.*;
+import com.sandu.ximon.admin.manager.iot.rrpc.dto.CommonFrame;
+import com.sandu.ximon.admin.manager.iot.rrpc.enums.A5OrderEnum;
 import com.sandu.ximon.admin.manager.iot.rrpc.enums.AtmoFunctionCode;
+import com.sandu.ximon.admin.manager.iot.rrpc.mainboard.MainBoardInvokeSyncService;
 import com.sandu.ximon.admin.security.SecurityUtils;
 import com.sandu.ximon.admin.utils.RedisUtils;
 import com.sandu.ximon.admin.utils.StoreOperationRecordsUtils;
@@ -98,7 +107,7 @@
         /**
          * 鍒犻櫎澶ф皵璁惧 鏃ュ織璁板綍寮�濮�
          */
-        List<String> listCode=new ArrayList<>(1);
+        List<String> listCode = new ArrayList<>(1);
         listCode.add(airEquipment.getMac());
         String content = "{璁惧code锛�" + airEquipment.getMac() + "}";
 
@@ -132,4 +141,149 @@
         }
         return equipmentInfo;
     }
+
+    /**
+     * 鏌ヨ澶ф皵璁惧蹇冭烦鍖呮椂闂�
+     */
+    public String QueryHeartBeatTime(String mac) {
+        AirEquipment airEquipment = SpringContextHolder.getBean(AirEquipmentService.class).
+                getOne(Wrappers.lambdaQuery(AirEquipment.class).eq(AirEquipment::getMac, mac).last("limit 1"));
+
+        if (airEquipment == null) {
+            throw new BusinessException("澶ф皵璁惧涓嶅瓨鍦紒");
+        }
+
+        AtmosphereQueryHeartBeatTimeReqInnerFrame atmosphereQueryHeartBeatTimeReqInnerFrame = new AtmosphereQueryHeartBeatTimeReqInnerFrame();
+        A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_ATMOSPHERE_DATA.getCode(), atmosphereQueryHeartBeatTimeReqInnerFrame);
+        System.out.println(a5Frame + "          --------a5Frame");
+        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(mac, a5Frame);
+        System.out.println(commonFrame + "         -----------commonFrame");
+
+//        FEA504000AFE020002FFFF014062EC          --------a5Frame
+//        FEA584000CFE020004FFFF003CB081260CCC1C105D         -----------commonFrame
+        A5AtmosphereHeartBeatTimeReportInnerFrame a5AtmosphereHeartBeatTimeReportInnerFrame
+                = new A5AtmosphereHeartBeatTimeReportInnerFrame().transformFrame(commonFrame.getPayload());
+
+        if (a5AtmosphereHeartBeatTimeReportInnerFrame != null && a5AtmosphereHeartBeatTimeReportInnerFrame.isValidate()) {
+            return "璇ュぇ姘旇澶囧績璺冲寘闂撮殧鏃堕棿涓猴細" + a5AtmosphereHeartBeatTimeReportInnerFrame.getIntervalTime() + "s";
+        } else {
+            throw new BusinessException("鏁版嵁鏍¢獙寮傚父锛�");
+        }
+    }
+
+    /**
+     * 璁剧疆澶ф皵璁惧蹇冭烦鍖呴棿闅旀椂闂�
+     *
+     * @param mac
+     * @param time
+     */
+    public String setHeartBeatTime(String mac, Integer time) {
+        if (time < 30) {
+            throw new BusinessException("蹇冭烦鍖呴棿闅旀椂闂翠笉鑳藉皯浜�30s锛�");
+        }
+        AirEquipment airEquipment = SpringContextHolder.getBean(AirEquipmentService.class).
+                getOne(Wrappers.lambdaQuery(AirEquipment.class).eq(AirEquipment::getMac, mac).last("limit 1"));
+        if (airEquipment == null) {
+            throw new BusinessException("澶ф皵璁惧涓嶅瓨鍦紒");
+        }
+
+        AtmosphereSetHeartBeatTimeReqInnerFrame atmosphereSetHeartBeatTimeReqInnerFrame = new AtmosphereSetHeartBeatTimeReqInnerFrame(time);
+        A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_ATMOSPHERE_DATA.getCode(), atmosphereSetHeartBeatTimeReqInnerFrame);
+        System.out.println(a5Frame + "          --------a5Frame");
+        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(mac, a5Frame);
+        System.out.println(commonFrame + "         -----------commonFrame");
+
+        //FEA584000BFE110003FFFF00464116EC58FC0C8F
+        A5AtmosphereOperationReportInnerFrame a5AtmosphereOperationReportInnerFrame
+                = new A5AtmosphereOperationReportInnerFrame().transformFrame(commonFrame.getPayload());
+        if (a5AtmosphereOperationReportInnerFrame != null && a5AtmosphereOperationReportInnerFrame.isValidate()) {
+            return a5AtmosphereOperationReportInnerFrame.getState();
+        } else {
+            throw new BusinessException("鏁版嵁鏍¢獙寮傚父锛�");
+        }
+    }
+
+    /**
+     * 鏌ヨ浼犳劅鍣ㄦ暟閲�/鏁呴殰
+     *
+     * @param mac
+     * @return
+     */
+    public A5AtmosphereQuerySensorInfoReportInnerFrame.SensorInfoPackage QuerySensorInfo(String mac) {
+        AirEquipment airEquipment = SpringContextHolder.getBean(AirEquipmentService.class).
+                getOne(Wrappers.lambdaQuery(AirEquipment.class).eq(AirEquipment::getMac, mac).last("limit 1"));
+
+        if (airEquipment == null) {
+            throw new BusinessException("澶ф皵璁惧涓嶅瓨鍦紒");
+        }
+
+        AtmosphereQuerySensorInfoReqInnerFrame atmosphereQuerySensorInfoReqInnerFrame = new AtmosphereQuerySensorInfoReqInnerFrame();
+        A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_ATMOSPHERE_DATA.getCode(), atmosphereQuerySensorInfoReqInnerFrame);
+        System.out.println(a5Frame + "          --------a5Frame");
+        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(mac, a5Frame);
+        System.out.println(commonFrame + "         -----------commonFrame");
+
+        A5AtmosphereQuerySensorInfoReportInnerFrame atmosphereQuerySensorInfoReportInnerFrame
+                = new A5AtmosphereQuerySensorInfoReportInnerFrame().transformFrame(commonFrame.getPayload());
+
+        if (atmosphereQuerySensorInfoReportInnerFrame != null && atmosphereQuerySensorInfoReportInnerFrame.isValidate()) {
+            return atmosphereQuerySensorInfoReportInnerFrame.getSensorInfoPackage();
+        } else {
+            throw new BusinessException("鏁版嵁鏍¢獙寮傚父锛�");
+        }
+    }
+
+    /**
+     * 鏌ヨ杞‖浠剁増鏈�
+     *
+     * @param mac
+     * @return
+     */
+    public void QueryVersion(String mac) {
+        //TODO
+        AirEquipment airEquipment = SpringContextHolder.getBean(AirEquipmentService.class).
+                getOne(Wrappers.lambdaQuery(AirEquipment.class).eq(AirEquipment::getMac, mac).last("limit 1"));
+
+        if (airEquipment == null) {
+            throw new BusinessException("澶ф皵璁惧涓嶅瓨鍦紒");
+        }
+
+        AtmosphereQueryVersionReqInnerFrame atmosphereQueryVersionReqInnerFrame = new AtmosphereQueryVersionReqInnerFrame();
+        A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_ATMOSPHERE_DATA.getCode(), atmosphereQueryVersionReqInnerFrame);
+        System.out.println(a5Frame + "          --------a5Frame");
+        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(mac, a5Frame);
+        System.out.println(commonFrame + "         -----------commonFrame");
+
+//        FEA504000AFE040002FFFF8E00974C          --------a5Frame
+//        FEA584000BFE040003FFFFFF38586A49EE3EAF62         -----------commonFrame
+    }
+
+    /**
+     * 杞噸鍚�
+     *
+     * @param mac
+     * @return
+     */
+    public String Reboot(String mac) {
+        AirEquipment airEquipment = SpringContextHolder.getBean(AirEquipmentService.class).
+                getOne(Wrappers.lambdaQuery(AirEquipment.class).eq(AirEquipment::getMac, mac).last("limit 1"));
+        if (airEquipment == null) {
+            throw new BusinessException("澶ф皵璁惧涓嶅瓨鍦紒");
+        }
+
+        AtmosphereRebootReqInnerFrame atmosphereRebootReqInnerFrame = new AtmosphereRebootReqInnerFrame();
+        A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_ATMOSPHERE_DATA.getCode(), atmosphereRebootReqInnerFrame);
+        System.out.println(a5Frame + "          --------a5Frame");
+        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(mac, a5Frame);
+        System.out.println(commonFrame + "         -----------commonFrame");
+
+        A5AtmosphereOperationReportInnerFrame a5AtmosphereOperationReportInnerFrame =
+                new A5AtmosphereOperationReportInnerFrame().transformFrame(commonFrame.getPayload());
+
+        if (a5AtmosphereOperationReportInnerFrame != null && a5AtmosphereOperationReportInnerFrame.isValidate()) {
+            return a5AtmosphereOperationReportInnerFrame.getState();
+        } else {
+            throw new BusinessException("鏁版嵁鏍¢獙寮傚父锛�");
+        }
+    }
 }

--
Gitblit v1.9.3