From cfb17d6e329f3cc7afe3018d6cc8784ebafd5965 Mon Sep 17 00:00:00 2001
From: liuhaonan <31457034@qq.com>
Date: 星期三, 14 九月 2022 16:08:57 +0800
Subject: [PATCH] changes

---
 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