From f92e7a801cb5e59bd2391641eccad67036513b8a Mon Sep 17 00:00:00 2001
From: zhanzhiqin <895896009@qq.com>
Date: 星期五, 15 四月 2022 15:00:14 +0800
Subject: [PATCH] fix
---
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightService.java | 33 ++++++++++++++++++++++++++++++++-
1 files changed, 32 insertions(+), 1 deletions(-)
diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightService.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightService.java
index 65aeaad..fa7e706 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightService.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightService.java
@@ -22,6 +22,8 @@
import com.sandu.ximon.dao.bo.LightBo;
import com.sandu.ximon.dao.domain.Light;
import com.sandu.ximon.dao.domain.LightReportData;
+import com.sandu.ximon.dao.domain.Pole;
+import com.sandu.ximon.dao.domain.PoleBinding;
import com.sandu.ximon.dao.enums.DeviceRespStatusEnums;
import com.sandu.ximon.dao.mapper.LightMapper;
import lombok.AllArgsConstructor;
@@ -46,6 +48,8 @@
private final RedisService redisService;
private final LightReportDataService lightReportDataService;
+ private final PoleBindingService bindingService;
+ private final PoleService poleService;
/**
* 褰曞叆褰撳墠璁惧鐮佺殑璺伅鏁版嵁
@@ -94,6 +98,17 @@
if (CollectionUtil.isNotEmpty(deviceCodeList)) {
List<LightReportData> reportDataList = lightReportDataService.getNewestReportByDeviceCode(deviceCodeList);
for (LightBo lightBo : listLight) {
+ deviceCodeList.forEach(code -> {
+ PoleBinding bind = bindingService.getPoleIdByMac(code);
+ if (bind != null&&lightBo.getDeviceCode().equals(bind.getDeviceCode())) {
+ Long poleId = bind.getPoleId();
+ Pole pole = poleService.getById(poleId);
+ lightBo.setPoleId(pole.getId());
+ lightBo.setPoleCode(pole.getDeviceCode());
+ lightBo.setPoleName(pole.getPoleName());
+ }
+ }
+ );
for (LightReportData lightReportData : reportDataList) {
if (StrUtil.equals(lightBo.getDeviceCode(), lightReportData.getDeviceCode())) {
lightBo.setReportTime(lightReportData.getCreateTime());
@@ -104,6 +119,22 @@
}
return listLight;
+ }
+
+ /**
+ * 鑾峰彇鍗曚釜璺伅淇℃伅
+ * @param deviceCode 璁惧鐮�
+ * @return
+ */
+ public Light getLight(String deviceCode) {
+ Light one = getOne(Wrappers.<Light>lambdaQuery().eq(Light::getDeviceCode, deviceCode));
+ Object o = redisService.get(LightKey.REPORT_MAC.key(deviceCode));
+ if (o != null) {
+ one.setOnlineStatus(1);
+ }else {
+ one.setOnlineStatus(0);
+ }
+ return one;
}
public boolean addRemark(LightRemarkParam param) {
@@ -152,7 +183,7 @@
light.setLightPercent(param.getBrightness());
update(light, Wrappers.lambdaUpdate(Light.class).eq(Light::getDeviceCode, param.getDeviceCode()));
}
- }catch (BusinessException e){
+ } catch (BusinessException e) {
map.put("status", DeviceRespStatusEnums.OTHER_ERROR.getCode());
resultList.add(map);
}
--
Gitblit v1.9.3