From e6679745b914ead22c88295276555a72745b4ba2 Mon Sep 17 00:00:00 2001
From: zhanzhiqin <895896009@qq.com>
Date: 星期三, 12 一月 2022 15:44:30 +0800
Subject: [PATCH] 灯杆绑定用户
---
ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleService.java | 43 +++++++++++++++++++++++++++++++------------
1 files changed, 31 insertions(+), 12 deletions(-)
diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleService.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleService.java
index 86ab0fd..4358388 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleService.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleService.java
@@ -35,6 +35,7 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
+import org.springframework.web.bind.annotation.RequestParam;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@@ -110,10 +111,10 @@
*
* @return
*/
- public List<Pole> queryStatesAndList(Integer pageNo,Integer pageSize) {
+ public List<Pole> queryStatesAndList(Integer pageNo, Integer pageSize) {
// List<LampPost> list = list(Wrappers.lambdaQuery(LampPost.class).eq(LampPost::getClientId, SecurityUtils.getUserId()));
//List<Pole> list = list(Wrappers.lambdaQuery(Pole.class));
- PageHelper.startPage(pageNo,pageSize);
+ PageHelper.startPage(pageNo, pageSize);
List<Pole> list = new ArrayList<>();
if (SecurityUtils.getClientId() == null) {
list = list(Wrappers.lambdaQuery(Pole.class));
@@ -214,7 +215,7 @@
}*/
boolean setMac = false;
- // String baseMac = "baseDevice";
+ // String baseMac = "baseDevice";
A1Frame a1Frame = new A1Frame(A1OrderEnum.REQUEST_READ_DEVICE_UNIQUE_MAC.getCode(), new EmptyRequestInnerFrame());
CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance()
.sendRRPC(baseMac, a1Frame);
@@ -226,7 +227,7 @@
String uniqueMac = a1DeviceMacRespInnerFrame.getMac();
uniqueMac = uniqueMac.toLowerCase();
- if(uniqueMac.isEmpty()){
+ if (uniqueMac.isEmpty()) {
throw new BusinessException("璇诲彇璁惧鍞竴ID澶辫触!");
}
log.info("鍞竴鐮亄}", uniqueMac);
@@ -281,28 +282,28 @@
FrameBuilder.builderA2().innerFrame(new EmptyRequestInnerFrame())
.orderType(A2OrderEnum.REQUEST_MAIN_BOARD_RESET.getCode()).build());
if ("00".equals(rebootFrame.getPayload())) {
- // pole.setDeviceCode(uniqueMac);
+ // pole.setDeviceCode(uniqueMac);
- // setMac = updateById(pole);
+ // setMac = updateById(pole);
System.out.println("閲嶅惎鎴愬姛");
}
- Pole pole=new Pole();
- String strh = uniqueMac.substring(uniqueMac.length() -2,uniqueMac.length());
+ Pole pole = new Pole();
+ String strh = uniqueMac.substring(uniqueMac.length() - 2, uniqueMac.length());
pole.setDeviceCode(strh);
pole.setPoleName(strh);
- String strm = uniqueMac.substring(0,uniqueMac.length()-2);
+ String strm = uniqueMac.substring(0, uniqueMac.length() - 2);
int i = Integer.parseInt(strm);
pole.setPoleCode(generatePoleCode());
pole.setDeviceType(i);
- setMac= save(pole);
+ setMac = save(pole);
return setMac;
}
public List<String> listDeviceCodeByIds(List<Long> poleIdList) {
- if(CollectionUtil.isEmpty(poleIdList)){
+ if (CollectionUtil.isEmpty(poleIdList)) {
return null;
}
List<Pole> list = list(Wrappers.lambdaQuery(Pole.class).in(Pole::getId, poleIdList).select(Pole::getDeviceCode));
@@ -312,6 +313,7 @@
/**
* 鎵归噺鑾峰彇闃块噷浜戣澶囩殑鐘舵��
+ *
* @param deviceCodeList 闃块噷浜戣澶囩爜
* @return 璁惧鐘舵�佸垪琛�
*/
@@ -321,7 +323,7 @@
List<DeviceStatus> statusList = new ArrayList<>();
for (List<String> list : split) {
List<BatchGetDeviceStateResponse.DeviceStatus> deviceStatuses = MainBoardInvokeSyncService.getInstance().batchGetDeviceState(list);
- if(CollectionUtil.isNotEmpty(deviceStatuses)){
+ if (CollectionUtil.isNotEmpty(deviceStatuses)) {
for (BatchGetDeviceStateResponse.DeviceStatus d : deviceStatuses) {
DeviceStatus deviceStatus = new DeviceStatus();
deviceStatus.setDeviceCode(d.getDeviceName());
@@ -332,4 +334,21 @@
}
return statusList;
}
+
+ /**
+ * 鐢ㄦ埛缁戝畾鐏潌
+ *
+ * @param clientId 鐢ㄦ埛ID
+ * @param poleId 鐏潌ID
+ * @return
+ */
+ public boolean ClientBindingPole(long clientId, int poleId) {
+ Pole pole = getById(poleId);
+ if (pole == null) {
+ throw new BusinessException("鐏潌涓嶅瓨鍦�");
+ }
+ pole.setClientId(clientId);
+
+ return updateById(pole);
+ }
}
--
Gitblit v1.9.3