From da6ea6d775461e6d56eb50cbdd79e6ba3b8f41e4 Mon Sep 17 00:00:00 2001
From: zhanzhiqin <895896009@qq.com>
Date: 星期二, 01 三月 2022 14:22:30 +0800
Subject: [PATCH] 灯杆绑定设备,解绑设备
---
ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleBindingService.java | 9 ++-
ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleService.java | 25 +++++--
ximon-admin/src/main/java/com/sandu/ximon/admin/service/MonitorService.java | 25 ++++++++
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/PoleController.java | 78 +++++++++++++++++++++++++-
4 files changed, 122 insertions(+), 15 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..d6cf828 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,15 @@
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.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 +37,8 @@
public class PoleController {
private final PoleService poleService;
+ private MonitorService monitorService;
+ private AirEquipmentService airEquipmentService;
@PostMapping("/add")
public ResponseVO<Object> addPole(@RequestBody @Validated PoleParam param) {
@@ -78,9 +83,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 +96,7 @@
return ResponseUtil.success(poleService.poleReset(poleId));
}
-
+//TODO 璁惧鐨勭粦瀹氳В缁戦兘瑕佸崟鐙噸鏂板鐞�
/**
* 鐏潌缁戝畾璁惧
*/
@@ -99,12 +104,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) {
diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/MonitorService.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/MonitorService.java
index 345b129..706f23f 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/MonitorService.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/MonitorService.java
@@ -107,7 +107,7 @@
*
* @param accessToken 鎺堟潈杩囩▼鑾峰彇鐨刟ccess_token
* @param deviceSerial 璁惧搴忓垪鍙�,瀛樺湪鑻辨枃瀛楁瘝鐨勮澶囧簭鍒楀彿锛屽瓧姣嶉渶涓哄ぇ鍐�
-// * @param validateCode 璁惧楠岃瘉鐮侊紝璁惧鏈鸿韩涓婄殑鍏綅澶у啓瀛楁瘝
+ * // * @param validateCode 璁惧楠岃瘉鐮侊紝璁惧鏈鸿韩涓婄殑鍏綅澶у啓瀛楁瘝
*/
// public YSY_MonitorDto addYSYMonitor(String accessToken, String deviceSerial, String validateCode) {
public YSY_MonitorDto addYSYMonitor(String accessToken, String deviceSerial) {
@@ -222,5 +222,28 @@
}
}
+ /**
+ * 淇敼璁惧缁戝畾鐘舵��
+ *
+ * @param flag true涓虹粦瀹� false 涓鸿В缁�
+ */
+ public void updateBingdingState(boolean flag, String deviceCode) {
+ if (flag) {//缁戝畾
+ Monitor monitor = getOne(Wrappers.lambdaQuery(Monitor.class).eq(Monitor::getDeviceSerial, deviceCode));
+ if (monitor == null) {
+ return;
+ }
+ monitor.setBindingState(1);
+ updateById(monitor);
+ } else {//瑙g粦
+ Monitor monitor = getOne(Wrappers.lambdaQuery(Monitor.class).eq(Monitor::getDeviceSerial, deviceCode));
+ if (monitor == null) {
+ return;
+ }
+ monitor.setBindingState(0);
+ updateById(monitor);
+ }
+ }
+
}
diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleBindingService.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleBindingService.java
index 76c0dca..3fc0a04 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleBindingService.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleBindingService.java
@@ -50,13 +50,16 @@
*
* @param deviceCode
*/
- public void unBindPole(String deviceCode) {
- if (deviceCode == null)
+ public boolean unBindPole(String deviceCode) {
+ if (deviceCode == null) {
throw new BusinessException("璁惧缂栧彿涓嶈兘涓虹┖");
+ }
PoleBinding one = getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getDeviceCode, deviceCode));
if (one != null) {
- removeById(one.getId());
+ return removeById(one.getId());
+ } else {
+ throw new BusinessException("璁惧涓嶅瓨鍦ㄧ粦瀹氭儏鍐�");
}
}
}
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 2a6ae70..b2fe1a5 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
@@ -157,6 +157,15 @@
return poleBindingService.bindPole(poleId, param);
}
+ /**
+ * 鐏潌瑙g粦缁戝畾璁惧
+ *
+ * @return 鏄惁鎴愬姛
+ */
+ public boolean unBindPole(String deviceCode) {
+ return poleBindingService.unBindPole(deviceCode);
+ }
+
/**
* 鐏潌鎭㈠鍑哄巶璁剧疆
@@ -207,14 +216,14 @@
* 缁欑伅鏉嗘敞鍐屼笁鍏冪爜
*/
public boolean setMac(String baseMac) {
- // public boolean setMac() {
+ // public boolean setMac() {
//Pole pole = getById(poleId);
/* if (pole == null) {
throw new BusinessException("鏈壘鍒拌鐏潌");
}*/
boolean setMac = false;
- //String baseMac = "baseDevice";
+ //String baseMac = "baseDevice";
A1Frame a1Frame = new A1Frame(A1OrderEnum.REQUEST_READ_DEVICE_UNIQUE_MAC.getCode(), new EmptyRequestInnerFrame());
CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance()
.sendRRPC(baseMac, a1Frame);
@@ -338,21 +347,21 @@
* 鐢ㄦ埛缁戝畾鐏潌
*
* @param clientId 鐢ㄦ埛ID
- * @param poleIds 鐏潌ID
+ * @param poleIds 鐏潌ID
* @return
*/
public boolean ClientBindingPole(long clientId, int[] poleIds) {
- boolean r=false;
- for (int poleId:poleIds) {
+ boolean r = false;
+ for (int poleId : poleIds) {
Pole pole = getById(poleId);
if (pole == null) {
throw new BusinessException("鐏潌涓嶅瓨鍦�");
}
pole.setClientId(clientId);
- r=updateById(pole);
+ r = updateById(pole);
- if(!r){
- throw new BusinessException("鐏潌ID涓�"+poleId+"璁剧疆澶辫触,鑷姩鍋滄");
+ if (!r) {
+ throw new BusinessException("鐏潌ID涓�" + poleId + "璁剧疆澶辫触,鑷姩鍋滄");
}
}
--
Gitblit v1.9.3