From 652bbc43722b3eed164609d10dc6967989b253d5 Mon Sep 17 00:00:00 2001
From: liuhaonan <konodioda2333@vip.qq.com>
Date: 星期一, 18 四月 2022 17:38:32 +0800
Subject: [PATCH] 节目/文件归属问题

---
 ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightService.java |   33 ++++++++++++++++++++++++++++++++-
 1 files changed, 32 insertions(+), 1 deletions(-)

diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightService.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightService.java
index 65aeaad..fa7e706 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightService.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightService.java
@@ -22,6 +22,8 @@
 import com.sandu.ximon.dao.bo.LightBo;
 import com.sandu.ximon.dao.domain.Light;
 import com.sandu.ximon.dao.domain.LightReportData;
+import com.sandu.ximon.dao.domain.Pole;
+import com.sandu.ximon.dao.domain.PoleBinding;
 import com.sandu.ximon.dao.enums.DeviceRespStatusEnums;
 import com.sandu.ximon.dao.mapper.LightMapper;
 import lombok.AllArgsConstructor;
@@ -46,6 +48,8 @@
 
     private final RedisService redisService;
     private final LightReportDataService lightReportDataService;
+    private final PoleBindingService bindingService;
+    private final PoleService poleService;
 
     /**
      * 褰曞叆褰撳墠璁惧鐮佺殑璺伅鏁版嵁
@@ -94,6 +98,17 @@
         if (CollectionUtil.isNotEmpty(deviceCodeList)) {
             List<LightReportData> reportDataList = lightReportDataService.getNewestReportByDeviceCode(deviceCodeList);
             for (LightBo lightBo : listLight) {
+                deviceCodeList.forEach(code -> {
+                            PoleBinding bind = bindingService.getPoleIdByMac(code);
+                            if (bind != null&&lightBo.getDeviceCode().equals(bind.getDeviceCode())) {
+                                Long poleId = bind.getPoleId();
+                                    Pole pole = poleService.getById(poleId);
+                                    lightBo.setPoleId(pole.getId());
+                                    lightBo.setPoleCode(pole.getDeviceCode());
+                                    lightBo.setPoleName(pole.getPoleName());
+                            }
+                        }
+                );
                 for (LightReportData lightReportData : reportDataList) {
                     if (StrUtil.equals(lightBo.getDeviceCode(), lightReportData.getDeviceCode())) {
                         lightBo.setReportTime(lightReportData.getCreateTime());
@@ -104,6 +119,22 @@
         }
 
         return listLight;
+    }
+
+    /**
+     * 鑾峰彇鍗曚釜璺伅淇℃伅
+     * @param deviceCode 璁惧鐮�
+     * @return
+     */
+    public Light getLight(String deviceCode) {
+        Light one = getOne(Wrappers.<Light>lambdaQuery().eq(Light::getDeviceCode, deviceCode));
+        Object o = redisService.get(LightKey.REPORT_MAC.key(deviceCode));
+        if (o != null) {
+            one.setOnlineStatus(1);
+        }else {
+            one.setOnlineStatus(0);
+        }
+        return one;
     }
 
     public boolean addRemark(LightRemarkParam param) {
@@ -152,7 +183,7 @@
                     light.setLightPercent(param.getBrightness());
                     update(light, Wrappers.lambdaUpdate(Light.class).eq(Light::getDeviceCode, param.getDeviceCode()));
                 }
-            }catch (BusinessException e){
+            } catch (BusinessException e) {
                 map.put("status", DeviceRespStatusEnums.OTHER_ERROR.getCode());
                 resultList.add(map);
             }

--
Gitblit v1.9.3