From 29febf388aa86d87198fe82e4af7eb88567d0d65 Mon Sep 17 00:00:00 2001
From: chenjiantian <214228265@qq.com>
Date: 星期二, 18 一月 2022 16:59:23 +0800
Subject: [PATCH] 权限管理
---
ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleService.java | 56 +++++++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 45 insertions(+), 11 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 bc8b7a7..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));
@@ -207,14 +208,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);
@@ -225,6 +226,10 @@
log.info(commonFrame.toString());
String uniqueMac = a1DeviceMacRespInnerFrame.getMac();
uniqueMac = uniqueMac.toLowerCase();
+
+ if (uniqueMac.isEmpty()) {
+ throw new BusinessException("璇诲彇璁惧鍞竴ID澶辫触!");
+ }
log.info("鍞竴鐮亄}", uniqueMac);
// 2 浠庨樋閲屾敞鍐�
@@ -277,17 +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.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;
}
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));
@@ -297,6 +313,7 @@
/**
* 鎵归噺鑾峰彇闃块噷浜戣澶囩殑鐘舵��
+ *
* @param deviceCodeList 闃块噷浜戣澶囩爜
* @return 璁惧鐘舵�佸垪琛�
*/
@@ -306,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());
@@ -317,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