From 4e76b9737e036c18e8a9e840dc443615ffcec348 Mon Sep 17 00:00:00 2001
From: zhanzhiqin <895896009@qq.com>
Date: 星期四, 20 十月 2022 12:20:18 +0800
Subject: [PATCH] 大气农耕
---
ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleBindingService.java | 34 ++++++++++++++++++++++++++++++----
1 files changed, 30 insertions(+), 4 deletions(-)
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 bb83b59..e3c312e 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
@@ -101,12 +101,24 @@
PoleBinding one = getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getDeviceCode, param.getDeviceCode()));
if (one == null) {
+ //鍏呯數妗╀繚瀛樼粦瀹氬叧绯婚渶瑕佸厛鍒ゆ柇鏄笉鏄纭殑鐏潌
+ if (deviceType == 2) {
+ C3mCharging mCharging = SpringContextHolder.getBean(C3ChargingService.class).
+ getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getMcuUdid, param.getDeviceCode()));
+ Pole poleInfo = SpringContextHolder.getBean(PoleService.class).getById(poleId);
+
+ if (!mCharging.getPoleDevicesCode().equals(poleInfo.getDeviceCode())) {
+ throw new BusinessException("缁戝畾鍑洪敊锛佽鍏呯數妗╃‖浠剁粦瀹氱殑鐏潌mac涓猴細" + mCharging.getPoleDevicesCode());
+ }
+
+ }
PoleBinding poleBinding = new PoleBinding();
poleBinding.setPoleId(poleId);
poleBinding.setDeviceType(deviceType);
poleBinding.setDeviceName(param.getDeviceName());
poleBinding.setDeviceCode(param.getDeviceCode());
return save(poleBinding);
+
} else {
//淇敼鍗曠伅鐨勭粦瀹氬叧绯荤殑鏃跺�欒棰濆澶勭悊鐨勪簨鍔�
// 鍒犻櫎鐏潌鐨刣evicescode
@@ -117,6 +129,18 @@
pole.setDeviceCode(null);
poleService.updateById(pole);
}
+ }
+
+ //鍏呯數妗╀繚瀛樼粦瀹氬叧绯婚渶瑕佸厛鍒ゆ柇鏄笉鏄纭殑鐏潌
+ if (deviceType == 2) {
+ C3mCharging mCharging = SpringContextHolder.getBean(C3ChargingService.class).
+ getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getMcuUdid, param.getDeviceCode()));
+ Pole poleInfo = SpringContextHolder.getBean(PoleService.class).getById(poleId);
+
+ if (!mCharging.getPoleDevicesCode().equals(poleInfo.getDeviceCode())) {
+ throw new BusinessException("缁戝畾鍑洪敊锛佽鍏呯數妗╃‖浠剁粦瀹氱殑鐏潌mac涓猴細" + mCharging.getPoleDevicesCode());
+ }
+
}
one.setPoleId(poleId);
@@ -159,10 +183,12 @@
if (deviceCode == null) {
throw new BusinessException("璁惧缂栧彿涓嶈兘涓虹┖");
}
- //鏌ョ伅鏉嗗綊灞炲叧绯�
- boolean belong = isBelong(deviceCode, null);
- if(!belong){
- throw new BusinessException("璇ョ伅鏉嗕笉灞炰簬鎮紝鏃犳硶瑙g粦锛�");
+ if (SecurityUtils.getClientId() != null) {
+ //鏌ョ伅鏉嗗綊灞炲叧绯�
+ boolean belong = isBelong(deviceCode, null);
+ if (!belong) {
+ throw new BusinessException("璇ョ伅鏉嗕笉灞炰簬鎮紝鏃犳硶瑙g粦锛�");
+ }
}
//鐩存帴鍒犻櫎璁惧涓嶉渶瑕佺伅鏉咺D
PoleBinding one = getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getDeviceCode, deviceCode));
--
Gitblit v1.9.3