From 1bcef6a688ffbee58c347bbd87e1b5db08075041 Mon Sep 17 00:00:00 2001
From: zhanzhiqin <895896009@qq.com>
Date: 星期三, 13 四月 2022 18:25:02 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleBindingService.java | 45 ++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 42 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 3fc0a04..e6ae5f0 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,14 +1,16 @@
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;
import com.sandu.ximon.admin.param.PoleBindingParam;
import com.sandu.ximon.dao.domain.PoleBinding;
-import com.sandu.ximon.dao.enums.PoleBindingEnums;
import com.sandu.ximon.dao.mapper.PoleBindingMapper;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
+
+import java.util.List;
/**
* @author chenjiantian
@@ -31,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) {
@@ -50,16 +61,44 @@
*
* @param deviceCode
*/
+ public boolean unBindPole(Long poleId, String deviceCode) {
+ if (deviceCode == null) {
+ throw new BusinessException("璁惧缂栧彿涓嶈兘涓虹┖");
+ }
+ PoleBinding one;
+ //鐩存帴鍒犻櫎璁惧涓嶉渶瑕佺伅鏉咺D
+ if (poleId == null) {
+ 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));
+ }
+ if (one != null) {
+ return removeById(one.getId());
+ } else {
+ throw new BusinessException("璁惧涓嶅瓨鍦ㄧ粦瀹氭儏鍐垫垨鐏潌ID涓嶆纭�");
+ }
+ }
+
+ /**
+ * 璁惧鍒犻櫎,鐩存帴瑙g粦璁惧鐩稿叧缁戝畾鏁版嵁
+ *
+ * @param deviceCode
+ */
public boolean unBindPole(String deviceCode) {
if (deviceCode == null) {
throw new BusinessException("璁惧缂栧彿涓嶈兘涓虹┖");
}
-
+ //鐩存帴鍒犻櫎璁惧涓嶉渶瑕佺伅鏉咺D
PoleBinding one = getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getDeviceCode, deviceCode));
+
if (one != null) {
return removeById(one.getId());
} else {
- throw new BusinessException("璁惧涓嶅瓨鍦ㄧ粦瀹氭儏鍐�");
+ return false;
}
}
+
+ public PoleBinding getPoleIdByMac(String deviceCode) {
+ return getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getDeviceCode, deviceCode));
+ }
}
--
Gitblit v1.9.3