From 5e2fe6ce6e80dea99f6eda304dba6fafbb30ad63 Mon Sep 17 00:00:00 2001
From: zhanzhiqin <895896009@qq.com>
Date: 星期五, 09 九月 2022 11:34:13 +0800
Subject: [PATCH] 灯杆解绑fix
---
ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleService.java | 48 ++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 40 insertions(+), 8 deletions(-)
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 9cf84ce..9263b66 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
@@ -643,10 +643,13 @@
boolean result = saveOrUpdate(pole);
if (result) {
- Light light = new Light();
- light.setDeviceCode(uniqueMac);
- light.setLightCount(2);
- SpringContextHolder.getBean(LightService.class).save(light);
+ Light light = SpringContextHolder.getBean(LightService.class).getOne(Wrappers.lambdaQuery(Light.class).eq(Light::getDeviceCode, pole.getDeviceCode()).last("limit 1"));
+ if (light == null) {
+ light = new Light();
+ light.setDeviceCode(uniqueMac);
+ light.setLightCount(2);
+ SpringContextHolder.getBean(LightService.class).save(light);
+ }
}
/**
@@ -713,10 +716,37 @@
if (pole == null) {
throw new BusinessException("鐏潌涓嶅瓨鍦�");
}
- pole.setUserId(clientId);
+ pole.setClientId(clientId);
if (!clientService.findClientId(clientId)) {
- pole.setClientId(clientService.getClientId(clientId));
+ pole.setUserId(clientService.getClientId(clientId));
+
}
+ r = updateById(pole);
+
+ if (!r) {
+ throw new BusinessException("鐏潌ID涓�" + poleId + "璁剧疆澶辫触,鑷姩鍋滄");
+ }
+
+ }
+ return r;
+ }
+
+ /**
+ * 鐢ㄦ埛瑙g粦鐏潌
+ *
+ * @param clientId
+ * @param poleIds
+ * @return
+ */
+ public boolean ClientUnBindingPole(long clientId, int[] poleIds) {
+ boolean r = false;
+ for (int poleId : poleIds) {
+ Pole pole = getById(poleId);
+ if (pole == null) {
+ throw new BusinessException("鐏潌涓嶅瓨鍦�");
+ }
+ pole.setUserId(-1L);
+ pole.setClientId(-1L);
r = updateById(pole);
if (!r) {
@@ -899,8 +929,10 @@
throw new BusinessException("璁惧涓嶅瓨鍦�");
}
//鍏抽棴鎺ㄩ��
- SpringContextHolder.getBean(LightemitUtils.class).clear(xixun.getDeviceCode());
-
+ String clear = SpringContextHolder.getBean(LightemitUtils.class).clear(xixun.getDeviceCode());
+ if (clear.contains("is not") || clear.contains("does not")) {
+ throw new BusinessException("璁惧涓嶅湪绾挎垨璁惧鏈瓨鍦ㄤ簬鏈嶅姟鍣�");
+ }
}
/**
--
Gitblit v1.9.3