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 | 36 ++++++++++++++++++++++++++++++++----
1 files changed, 32 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 7e7e050..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,6 +183,13 @@
if (deviceCode == null) {
throw new BusinessException("璁惧缂栧彿涓嶈兘涓虹┖");
}
+ 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));
@@ -179,12 +210,9 @@
*
* @param deviceCode 璁惧缂栧彿
* @param type 璁惧绫诲瀷
- * @return 宸茬粦瀹氳繑鍥瀟rue锛屾湭缁戝畾杩斿洖false
+ * @return 灞炰簬璇ョ敤鎴疯繑鍥瀟rue锛屼笉鏄繑鍥瀎alse
*/
public boolean isBelong(String deviceCode, String type) {
- if (type.isEmpty() || deviceCode.isEmpty()) {
- throw new BusinessException("璁惧缂栧彿鎴栫被鍨嬩笉鑳戒负绌�");
- }
Long userId = SecurityUtils.getClientId();
Pole binding = baseMapper.getPoleByBinding(type, deviceCode, userId);
if (binding != null) {
--
Gitblit v1.9.3