From 52eb3f0befcb397d2fdd645c8d7471d6ee477f87 Mon Sep 17 00:00:00 2001
From: zhanzhiqin <895896009@qq.com>
Date: 星期一, 09 五月 2022 16:36:38 +0800
Subject: [PATCH] 权限

---
 ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleService.java |   86 ++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 81 insertions(+), 5 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 e317fe5..223503d 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
@@ -17,6 +17,7 @@
 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;
+import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5AtmosphereHeartbeatReportInnerFrame;
 import com.sandu.ximon.admin.manager.iot.frame.inner.request.A1TernaryCodeReqInnerFrame;
 import com.sandu.ximon.admin.manager.iot.frame.inner.request.A5LightResetReqInnerFrame;
 import com.sandu.ximon.admin.manager.iot.frame.inner.request.EmptyRequestInnerFrame;
@@ -29,11 +30,12 @@
 import com.sandu.ximon.admin.param.*;
 import com.sandu.ximon.admin.redis.LightKey;
 import com.sandu.ximon.admin.security.SecurityUtils;
+import com.sandu.ximon.admin.utils.LightemitUtils;
 import com.sandu.ximon.admin.utils.RedisUtils;
+import com.sandu.ximon.admin.utils.response.VnnoxResult;
 import com.sandu.ximon.admin.vo.PoleBindVO;
 import com.sandu.ximon.dao.bo.*;
 import com.sandu.ximon.dao.domain.*;
-import com.sandu.ximon.dao.mapper.MonitorMapper;
 import com.sandu.ximon.dao.mapper.PoleMapper;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
@@ -165,9 +167,9 @@
         MonitorParam monitorParam = new MonitorParam();
         monitorParam.setEquipmentState(2);
         monitorParam.setBindingState(2);
-        List<MonitorBo> monitorBos = SpringContextHolder.getBean(MonitorService.class).listMonitorByKeyword(null, monitorParam);
+        List<MonitorBo> monitorBos = SpringContextHolder.getBean(MonitorService.class).listMonitorByKeyword(null, monitorParam).getList();
         monitorParam.setEquipmentState(1);
-        List<MonitorBo> online = SpringContextHolder.getBean(MonitorService.class).listMonitorByKeyword(null, monitorParam);
+        List<MonitorBo> online = SpringContextHolder.getBean(MonitorService.class).listMonitorByKeyword(null, monitorParam).getList();
         result.put("monitorOnlineCount", online.size());
         result.put("monitorTotalCount", monitorBos.size());
 
@@ -198,7 +200,7 @@
         number = 0;
         List<AirEquipmentBo> airEquipments = SpringContextHolder.getBean(AirEquipmentService.class).listAirEquipmentByKeyword(null, null);
         for (AirEquipmentBo airEquipmentBo : airEquipments) {
-            if (RedisUtils.getBean().get(AtmoFunctionCode.AIR_HEARTBEAT.getCode() + airEquipmentBo.getMac()) != null) {
+            if (RedisUtils.getBean().get(AtmoFunctionCode.AIR_HEARTBEAT_STATE.getCode() + airEquipmentBo.getMac()) != null) {
                 number++;
             }
         }
@@ -208,7 +210,7 @@
         number = 0;
         List<AirEquipmentNongGengBo> airEquipmentNongGengBos = SpringContextHolder.getBean(AirEquipmentNongGengService.class).listAirEquipmentByKeyword(null, null);
         for (AirEquipmentNongGengBo airEquipmentNongGengBo : airEquipmentNongGengBos) {
-            if (RedisUtils.getBean().get(AtmoFunctionCode.AIR_HEARTBEAT_NONG_GENG.getCode() + airEquipmentNongGengBo.getMac()) != null) {
+            if (RedisUtils.getBean().get(AtmoFunctionCode.AIR_HEARTBEAT_NONG_GENG_STATE.getCode() + airEquipmentNongGengBo.getMac()) != null) {
                 number++;
             }
         }
@@ -866,4 +868,78 @@
         return poleMapper.updateDeviceCode(poleId);
     }
 
+
+    /**
+     * 鎺ㄩ�佸ぇ姘旂洃娴嬫暟鎹埌novaLED
+     */
+    public boolean pushAirDataToXiXun(Long poleId) {
+        Pole pole = getById(poleId);
+        //鍒ゆ柇褰掑睘鏉�
+        if (SecurityUtils.getClientId() != null) {
+            if (!pole.getClientId().equals(SecurityUtils.getUserId()) && !pole.getUserId().equals(SecurityUtils.getUserId())) {
+                throw new BusinessException("鏃犳潈闄愭搷浣�");
+            }
+        }
+        PoleBinding air = poleBindingService.getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getPoleId, poleId).eq(PoleBinding::getDeviceType, 3));
+        PoleBinding xixun = poleBindingService.getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getPoleId, poleId).eq(PoleBinding::getDeviceType, 10));
+        if (pole == null) {
+            throw new BusinessException("鐏潌涓嶅瓨鍦�");
+        }
+        if (air == null) {
+            throw new BusinessException("鏈粦瀹氬ぇ姘旂洃娴嬭澶�");
+        }
+        if (xixun == null) {
+            throw new BusinessException("鏈粦瀹歺ixun璁惧");
+        }
+        //鑾峰彇澶ф皵鐩戞祴鏁版嵁
+        A5AtmosphereHeartbeatReportInnerFrame.HeartBeatDataPackage data = SpringContextHolder.getBean(AirDataService.class).getDataByPoleid(poleId);
+        //鎺ㄩ�佹暟鎹�
+        return SpringContextHolder.getBean(XiXunPlayerService.class).pushWeather(xixun.getDeviceCode(), data, pole);
+    }
+
+
+    /**
+     * 鍏抽棴鐔欒澶ф皵鎺ㄩ��
+     */
+    public void closeXiXunAirPush(Long poleId) {
+        Pole pole = getById(poleId);
+        if (SecurityUtils.getClientId() != null) {
+            if (!pole.getClientId().equals(SecurityUtils.getUserId()) && !pole.getUserId().equals(SecurityUtils.getUserId())) {
+                throw new BusinessException("鏃犳潈闄愭搷浣�");
+            }
+        }
+        PoleBinding air = poleBindingService.getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getPoleId, poleId).eq(PoleBinding::getDeviceType, 3));
+        PoleBinding xixun = poleBindingService.getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getPoleId, poleId).eq(PoleBinding::getDeviceType, 10));
+        if (pole == null || air == null || xixun == null) {
+            throw new BusinessException("璁惧涓嶅瓨鍦�");
+        }
+        //鍏抽棴鎺ㄩ��
+        SpringContextHolder.getBean(LightemitUtils.class).clear(xixun.getDeviceCode());
+
+    }
+
+    /**
+     * 鎺ㄩ�佸ぇ姘旂洃娴嬫暟鎹埌novaLED
+     */
+    public VnnoxResult pushAirDataToNova(Long poleId) {
+        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("鏈粦瀹氬ぇ姘旂洃娴嬭澶�");
+        }
+        if (nova == null) {
+            throw new BusinessException("鏈粦瀹歯ova璁惧");
+        }
+        //鑾峰彇澶ф皵鐩戞祴鏁版嵁
+        A5AtmosphereHeartbeatReportInnerFrame.HeartBeatDataPackage data = SpringContextHolder.getBean(AirDataService.class).getDataByPoleid(poleId);
+        //鎺ㄩ�佹暟鎹�
+        return SpringContextHolder.getBean(VnnoxService.class).publishWaterData(LED.getPlayerId(), data);
+    }
+
+
 }
\ No newline at end of file

--
Gitblit v1.9.3