From 8fa5a6dd8045fb298e391498e2ef2cd904dade45 Mon Sep 17 00:00:00 2001
From: zhanzhiqin <895896009@qq.com>
Date: 星期四, 14 四月 2022 10:56:22 +0800
Subject: [PATCH] fix
---
ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleBindingService.java | 20 +++++++++++++++++---
1 files changed, 17 insertions(+), 3 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 4716a7e..ee3bd4c 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
@@ -1,5 +1,6 @@
package com.sandu.ximon.admin.service;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.sandu.common.execption.BusinessException;
import com.sandu.common.service.impl.BaseServiceImpl;
@@ -8,6 +9,8 @@
import com.sandu.ximon.dao.mapper.PoleBindingMapper;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
+
+import java.util.List;
/**
* @author chenjiantian
@@ -30,6 +33,15 @@
Integer deviceType = param.getDeviceType();
// if (PoleBindingEnums.LIGHT.getCode().equals(deviceType)) {
// }
+ LambdaQueryWrapper<PoleBinding> eq = Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getPoleId, poleId);
+ List<PoleBinding> list = list(eq);
+ if (list.size() != 0) {
+ for (PoleBinding poleBinding : list) {
+ if (poleBinding.getDeviceType().equals(deviceType)) {
+ throw new BusinessException("璇ョ伅鏉嗗凡缁戝畾杩囩浉鍚岀被鍨嬭澶�");
+ }
+ }
+ }
PoleBinding one = getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getDeviceCode, param.getDeviceCode()));
if (one == null) {
@@ -40,7 +52,9 @@
poleBinding.setDeviceCode(param.getDeviceCode());
return save(poleBinding);
} else {
- throw new BusinessException("璇ヨ澶囧凡缁戝畾杩�");
+ one.setPoleId(poleId);
+ one.setDeviceType(param.getDeviceType());
+ return updateById(one);
}
}
@@ -86,7 +100,7 @@
}
}
- public PoleBinding getPoleIdByMac(String deviceCode){
- return getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getDeviceCode, deviceCode));
+ public PoleBinding getPoleIdByMac(String deviceCode) {
+ return getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getDeviceCode, deviceCode));
}
}
--
Gitblit v1.9.3