From 8a5b6b092754685b4da940d2a35a855832f92465 Mon Sep 17 00:00:00 2001
From: zhanzhiqin <895896009@qq.com>
Date: 星期五, 22 四月 2022 16:10:46 +0800
Subject: [PATCH] fix

---
 ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleBindingService.java |   26 +++++++++++++++++++++++++-
 1 files changed, 25 insertions(+), 1 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 ee3bd4c..1b9f5df 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
@@ -4,12 +4,15 @@
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.sandu.common.execption.BusinessException;
 import com.sandu.common.service.impl.BaseServiceImpl;
+import com.sandu.common.util.SpringContextHolder;
 import com.sandu.ximon.admin.param.PoleBindingParam;
+import com.sandu.ximon.dao.domain.Pole;
 import com.sandu.ximon.dao.domain.PoleBinding;
 import com.sandu.ximon.dao.mapper.PoleBindingMapper;
 import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
 
+import javax.swing.*;
 import java.util.List;
 
 /**
@@ -37,7 +40,8 @@
         List<PoleBinding> list = list(eq);
         if (list.size() != 0) {
             for (PoleBinding poleBinding : list) {
-                if (poleBinding.getDeviceType().equals(deviceType)) {
+                //鍏呯數妗╃殑缁戝畾鏄綉缁滆姹傛槸甯﹁繃鏉ョ殑鐏潌淇℃伅锛岃鍏佽鐩存帴淇敼
+                if (poleBinding.getDeviceType().equals(deviceType) && deviceType != 2) {
                     throw new BusinessException("璇ョ伅鏉嗗凡缁戝畾杩囩浉鍚岀被鍨嬭澶�");
                 }
             }
@@ -52,8 +56,18 @@
             poleBinding.setDeviceCode(param.getDeviceCode());
             return save(poleBinding);
         } else {
+            //鍒犻櫎鐏潌鐨刣evicescode
+            PoleService poleService = SpringContextHolder.getBean(PoleService.class);
+            Pole pole = poleService.getOne(Wrappers.lambdaQuery(Pole.class).eq(Pole::getId, one.getPoleId()));
+            if (pole != null) {
+                pole.setDeviceCode(null);
+                poleService.updateById(pole);
+            }
+
             one.setPoleId(poleId);
             one.setDeviceType(param.getDeviceType());
+            one.setDeviceName(param.getDeviceName());
+            one.setDeviceCode(param.getDeviceCode());
             return updateById(one);
         }
     }
@@ -73,6 +87,16 @@
             one = getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getDeviceCode, deviceCode));
         } else {
             one = getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getDeviceCode, deviceCode).eq(PoleBinding::getPoleId, poleId));
+
+            //鍒犻櫎鐏潌鐨刣evicescode
+            PoleService poleService = SpringContextHolder.getBean(PoleService.class);
+            Pole pole = poleService.getOne(Wrappers.lambdaQuery(Pole.class).eq(Pole::getId, poleId));
+            if (pole != null) {
+                pole.setDeviceCode(null);
+                poleService.updateById(pole);
+            }
+
+
         }
         if (one != null) {
             return removeById(one.getId());

--
Gitblit v1.9.3