From c3e734b8a5370f3d4b0102a86721a98adb8e3476 Mon Sep 17 00:00:00 2001
From: liuhaonan <31457034@qq.com>
Date: 星期三, 14 九月 2022 15:28:38 +0800
Subject: [PATCH] changes

---
 ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightService.java |   45 +++++++++++++++++++++++++++++++++++++++------
 1 files changed, 39 insertions(+), 6 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 18877c6..2f08bb8 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();
@@ -81,15 +81,15 @@
                 light.setLightPercent(heartBeatDataPackage.getLightPercent());
                 light.setLight2Percent(heartBeatDataPackage.getLight2Percent());
                 save(light);
+                log.info("鏂板璺伅");
             }
             redisService.set(LightKey.REPORT_MAC.key(deviceName), 1, LightKey.REPORT_MAC.expireSeconds());
-            log.info("鏂板璺伅");
         } else {
             Light light = new Light();
             light.setLightPercent(heartBeatDataPackage.getLightPercent());
             light.setLight2Percent(heartBeatDataPackage.getLight2Percent());
-            update(light, Wrappers.lambdaUpdate(Light.class).eq(Light::getDeviceCode, deviceName));
-            log.info("鏇存柊璺伅浜害");
+            boolean update = update(light, Wrappers.lambdaUpdate(Light.class).eq(Light::getDeviceCode, deviceName));
+            log.info("鏇存柊璺伅浜害 {}", update);
         }
     }
 
@@ -992,16 +992,31 @@
     }
 
     /**
+     * 鐢ㄦ埛鎷ユ湁鐨勮矾鐏�(鐢ㄤ簬棣栭〉鏁版嵁缁熻)
+     *
+     * @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) {
+    public CommonPage<String> listDeviceCode(int pageNo, int pageSize, String keyword, String deviceCode,String orderBy) {
         List<String> list;
         if (SecurityUtils.getClientId() != null) {
             PageHelper.startPage(pageNo, pageSize);
             list = baseMapper.listCode(SecurityUtils.getUserId(), keyword, deviceCode);
         } else {
 
-            PageHelper.startPage(pageNo, pageSize);
+            PageHelper.startPage(pageNo, pageSize,orderBy);
             list = baseMapper.listCode(null, keyword, 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