From f736df1648a4d9bb8620d38cf4421cf36eacdfc0 Mon Sep 17 00:00:00 2001
From: liuhaonan <konodioda2333@vip.qq.com>
Date: 星期五, 04 三月 2022 14:37:39 +0800
Subject: [PATCH] 功能完善

---
 ximon-admin/src/main/java/com/sandu/ximon/admin/controller/PoleController.java |  102 ++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 84 insertions(+), 18 deletions(-)

diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/controller/PoleController.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/controller/PoleController.java
index 172a6be..5bfeea4 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/controller/PoleController.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/controller/PoleController.java
@@ -13,12 +13,16 @@
 import com.sandu.ximon.admin.param.PoleBindParam;
 import com.sandu.ximon.admin.param.PoleBindingParam;
 import com.sandu.ximon.admin.param.PoleParam;
+import com.sandu.ximon.admin.param.PoleStatesParam;
+import com.sandu.ximon.admin.service.AirEquipmentService;
+import com.sandu.ximon.admin.service.MonitorService;
 import com.sandu.ximon.admin.service.PoleService;
 import com.sandu.ximon.dao.domain.Pole;
 import lombok.AllArgsConstructor;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
+import javax.validation.constraints.NotEmpty;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
@@ -34,6 +38,8 @@
 public class PoleController {
 
     private final PoleService poleService;
+    private MonitorService monitorService;
+    private AirEquipmentService airEquipmentService;
 
     @PostMapping("/add")
     public ResponseVO<Object> addPole(@RequestBody @Validated PoleParam param) {
@@ -50,25 +56,18 @@
         return ResponseUtil.success(poleService.deletePole(poleId));
     }
 
-    @GetMapping("/list")
-    public ResponseVO<Object> listPole(BaseConditionVO baseConditionVO, @RequestParam(value = "keyword", required = false) String keyword) {
+    @GetMapping("/listPoleAndState")//鍙互鏁村悎//宸叉暣鍚� 寮冪敤
+    public ResponseVO<Object> listPole(BaseConditionVO baseConditionVO, @RequestBody PoleStatesParam param) {
         PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
-        LambdaQueryWrapper<Pole> wrapper = Wrappers.lambdaQuery(Pole.class).orderByDesc(Pole::getId);
-        if (StrUtil.isNotBlank(keyword)) {
-            wrapper.like(Pole::getPoleCode, keyword)
-                    .or(lampPostLambdaQueryWrapper -> {
-                        lampPostLambdaQueryWrapper.like(Pole::getPoleName, keyword);
-                    });
-        }
-        List<Pole> list = poleService.list(wrapper);
-        return ResponseUtil.successPage(list);
+        List<Pole> poles = poleService.queryAllStatesAndList(baseConditionVO.getPageNo(), baseConditionVO.getPageSize(),param);
+        return ResponseUtil.success(poles);
     }
 
-    @GetMapping("/listPoleAndState")
-    public ResponseVO<Object> listPoleAndState(BaseConditionVO baseConditionVO, @RequestParam(value = "keyword", required = false) String keyword) {
+    @GetMapping("/list")
+    public ResponseVO<Object> listPoleAndState(BaseConditionVO baseConditionVO, @RequestParam(value = "keyword", required = false) String keyword,
+                                               @RequestParam(value = "groupid", required = false) Long groupid) {
         PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
-
-        List<Pole> poles = poleService.queryStatesAndList(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
+        List<Pole> poles = poleService.queryStatesAndList(baseConditionVO.getPageNo(), baseConditionVO.getPageSize(),keyword,groupid);
         return ResponseUtil.successPage(poles);
     }
 
@@ -78,9 +77,9 @@
      */
     @PostMapping("/setMac/{baseMac}")
     public ResponseVO<Object> setMac(@PathVariable String baseMac) {
-    //public ResponseVO<Object> setMac() {
+        //public ResponseVO<Object> setMac() {
         return ResponseUtil.success(poleService.setMac(baseMac));
-       // return ResponseUtil.success(poleService.setMac());
+        // return ResponseUtil.success(poleService.setMac());
     }
 
     /**
@@ -91,7 +90,7 @@
         return ResponseUtil.success(poleService.poleReset(poleId));
     }
 
-
+//TODO  璁惧鐨勭粦瀹氳В缁戦兘瑕佸崟鐙噸鏂板鐞�
     /**
      * 鐏潌缁戝畾璁惧
      */
@@ -99,12 +98,79 @@
     public ResponseVO<Object> bindPole(@PathVariable Long poleId, @RequestBody @Validated PoleBindingParam param) {
         boolean result = poleService.bindPole(poleId, param);
         if (result) {
+            //璁惧绫诲瀷锛�0璺伅锛�1led灞忓箷锛�2鍏呯數妗╋紝3澶ф皵鐩戞祴锛�4姘磋川鐩戞祴锛�5ip闊虫煴锛�6lcd骞垮憡鏈猴紝7鎽勫儚澶达紝8鏉嗕綋鍊炬祴锛�9涓�閿晳鍔�
+            switch (param.getDeviceType()) {
+                case 0:
+                    break;
+                case 1:
+                    break;
+                case 2:
+                    break;
+                case 3:
+                    break;
+                case 4:
+                    break;
+                case 5:
+                    break;
+                case 6:
+                    break;
+                case 7:
+                    monitorService.updateBingdingState(true, param.getDeviceCode());
+                    break;
+                case 8:
+                    break;
+                case 9:
+                    break;
+                default:
+                    break;
+            }
+
             return ResponseUtil.success("缁戝畾鎴愬姛");
         } else {
             return ResponseUtil.fail("缁戝畾澶辫触");
         }
     }
 
+    /**
+     * 鐏潌缁戝畾璁惧
+     */
+    @PostMapping("/unBind/{poleId}")
+    public ResponseVO<Object> unBindPole(@PathVariable Long poleId, @RequestBody  @Validated PoleBindingParam param) {
+        boolean result = poleService.unBindPole(param.getDeviceCode());
+        if (result) {
+            //璁惧绫诲瀷锛�0璺伅锛�1led灞忓箷锛�2鍏呯數妗╋紝3澶ф皵鐩戞祴锛�4姘磋川鐩戞祴锛�5ip闊虫煴锛�6lcd骞垮憡鏈猴紝7鎽勫儚澶达紝8鏉嗕綋鍊炬祴锛�9涓�閿晳鍔�
+            switch (param.getDeviceType()) {
+                case 0:
+                    break;
+                case 1:
+                    break;
+                case 2:
+                    break;
+                case 3:
+                    break;
+                case 4:
+                    break;
+                case 5:
+                    break;
+                case 6:
+                    break;
+                case 7:
+                    monitorService.updateBingdingState(false, param.getDeviceCode());
+                    break;
+                case 8:
+                    break;
+                case 9:
+                    break;
+                default:
+                    break;
+            }
+
+            return ResponseUtil.success("瑙g粦鎴愬姛");
+        } else {
+            return ResponseUtil.fail("瑙g粦澶辫触");
+        }
+    }
+
     @PostMapping("/listStatusByDeviceCode")
     public ResponseVO<Object> getStatusById(@RequestBody String[] deviceCodeList) {
         for (String s : deviceCodeList) {

--
Gitblit v1.9.3