From 4e53338c0c6859a43693f3f690f0c05da888a02e Mon Sep 17 00:00:00 2001
From: liuhaonan <31457034@qq.com>
Date: 星期五, 12 八月 2022 11:48:09 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightService.java |   35 ++++++++++++++++++++++++++++++++++-
 1 files changed, 34 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 3f7dc47..699e515 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
@@ -73,7 +73,7 @@
         Boolean hasKey = redisService.hasKey(LightKey.REPORT_MAC.key(deviceName));
         if (!hasKey) {
             int count = count(Wrappers.lambdaQuery(Light.class).eq(Light::getDeviceCode, deviceName));
-            log.info("redis鏌ヤ笉鍒拌矾鐏暟鎹畕}={}", count, deviceName);
+            log.info("redis鏌ヤ笉鍒拌矾鐏暟鎹� 鏁伴噺:{}={}", count, deviceName);
             // 褰撳墠璺伅琛ㄦ病鏈夊綍鍏ヨ澶囧悧
             if (count == 0) {
                 Light light = new Light();
@@ -992,6 +992,21 @@
     }
 
     /**
+     * 鐢ㄦ埛鎷ユ湁鐨勮矾鐏�(鐢ㄤ簬棣栭〉鏁版嵁缁熻)
+     *
+     * @return
+     */
+    public List<LightBo> listLightOnHome() {
+        List<LightBo> listLight;
+        if (SecurityUtils.getClientId() != null) {
+            listLight = baseMapper.listLight(SecurityUtils.getUserId(), null);
+        } else {
+            listLight = baseMapper.listLight(null, null);
+        }
+        return listLight;
+    }
+
+    /**
      * 鑾峰彇鐢ㄦ埛鎵�鏈夌殑璁惧鐮�
      */
     public CommonPage<String> listDeviceCode(int pageNo, int pageSize, String keyword, String deviceCode) {
@@ -1016,6 +1031,24 @@
         lights.forEach(light -> {
             light.setPower1(lightPowerSettingParam.getPower1());
             light.setPower2(lightPowerSettingParam.getPower2());
+            //瀛樺湪闈�0鍔熺巼  鍗充负瀛樺湪璇ョ伅澶�
+            if (lightPowerSettingParam.getPower1() != null || lightPowerSettingParam.getPower1() != 0) {
+                light.setLight1(1);
+            } else if (lightPowerSettingParam.getPower1() == 0) {
+                //鎵嬪姩璁剧疆鐏ご鍔熺巼涓�0  鍗充笉瀛樺湪璇ョ伅澶�
+                light.setLight1(0);
+            } else {
+                light.setLight1(0);
+            }
+            //瀛樺湪闈�0鍔熺巼  鍗充负瀛樺湪璇ョ伅澶�
+            if (lightPowerSettingParam.getPower2() != null || lightPowerSettingParam.getPower2() != 0) {
+                light.setLight2(1);
+            } else if (lightPowerSettingParam.getPower2() == 0) {
+                //鎵嬪姩璁剧疆鐏ご鍔熺巼涓�0  鍗充笉瀛樺湪璇ョ伅澶�
+                light.setLight2(0);
+            } else {
+                light.setLight2(0);
+            }
             light.setLightCount(lightPowerSettingParam.getLightCount());
         });
         return updateBatchById(lights);

--
Gitblit v1.9.3