From 3fa847083d45461b4e5ee7ec3dbd9247e8a5047c Mon Sep 17 00:00:00 2001
From: zhanzhiqin <895896009@qq.com>
Date: 星期三, 12 一月 2022 10:28:05 +0800
Subject: [PATCH] fix
---
ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleService.java | 35 ++++++++++++++++++++++++++---------
1 files changed, 26 insertions(+), 9 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 4a752bd..86ab0fd 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
@@ -40,6 +40,7 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
+import java.util.Objects;
import java.util.stream.Collectors;
/**
@@ -206,14 +207,14 @@
*/
- public boolean setMac(Long poleId) {
- Pole pole = getById(poleId);
- if (pole == null) {
+ public boolean setMac(String baseMac) {
+ //Pole pole = getById(poleId);
+ /* if (pole == null) {
throw new BusinessException("鏈壘鍒拌鐏潌");
- }
+ }*/
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);
@@ -224,6 +225,10 @@
log.info(commonFrame.toString());
String uniqueMac = a1DeviceMacRespInnerFrame.getMac();
uniqueMac = uniqueMac.toLowerCase();
+
+ if(uniqueMac.isEmpty()){
+ throw new BusinessException("璇诲彇璁惧鍞竴ID澶辫触!");
+ }
log.info("鍞竴鐮亄}", uniqueMac);
// 2 浠庨樋閲屾敞鍐�
@@ -276,12 +281,23 @@
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.setDeviceCode(strh);
+ pole.setPoleName(strh);
+ String strm = uniqueMac.substring(0,uniqueMac.length()-2);
+ int i = Integer.parseInt(strm);
+ pole.setPoleCode(generatePoleCode());
+ pole.setDeviceType(i);
+ setMac= save(pole);
+
return setMac;
}
@@ -289,8 +305,9 @@
if(CollectionUtil.isEmpty(poleIdList)){
return null;
}
- return list(Wrappers.lambdaQuery(Pole.class).in(Pole::getId, poleIdList).select(Pole::getDeviceCode))
- .stream().map(Pole::getDeviceCode).filter(StrUtil::isNotEmpty).collect(Collectors.toList());
+ List<Pole> list = list(Wrappers.lambdaQuery(Pole.class).in(Pole::getId, poleIdList).select(Pole::getDeviceCode));
+ return list
+ .stream().filter(Objects::nonNull).map(Pole::getDeviceCode).filter(StrUtil::isNotEmpty).collect(Collectors.toList());
}
/**
--
Gitblit v1.9.3