From 9330e9b0e4e70151d36084ecb5695b818cfda2db Mon Sep 17 00:00:00 2001
From: liuhaonan <konodioda2333@vip.qq.com>
Date: 星期二, 19 四月 2022 16:07:32 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightService.java | 86 ++++++++++++++++++++++++++++++++++++++-----
1 files changed, 76 insertions(+), 10 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 49f4dac..481e2fa 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
@@ -1,6 +1,8 @@
package com.sandu.ximon.admin.service;
import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.HexUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -30,6 +32,7 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
+import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -87,10 +90,7 @@
* @return 杩斿洖缁勫悎鏁版嵁dto
*/
public List<LightBo> listLight(int pageNo, int pageSize, String keyword) {
- Long clientId=null;
- if(SecurityUtils.getClientId()!=null){
- clientId = SecurityUtils.getClientId();
- }
+ Long clientId = SecurityUtils.getClientId();
PageHelper.startPage(pageNo, pageSize);
@@ -103,12 +103,12 @@
for (LightBo lightBo : listLight) {
deviceCodeList.forEach(code -> {
PoleBinding bind = bindingService.getPoleIdByMac(code);
- if (bind != null&&lightBo.getDeviceCode().equals(bind.getDeviceCode())) {
+ 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());
+ Pole pole = poleService.getById(poleId);
+ lightBo.setPoleId(pole.getId());
+ lightBo.setPoleCode(pole.getDeviceCode());
+ lightBo.setPoleName(pole.getPoleName());
}
}
);
@@ -126,6 +126,7 @@
/**
* 鑾峰彇鍗曚釜璺伅淇℃伅
+ *
* @param deviceCode 璁惧鐮�
* @return
*/
@@ -134,7 +135,7 @@
Object o = redisService.get(LightKey.REPORT_MAC.key(deviceCode));
if (o != null) {
one.setOnlineStatus(1);
- }else {
+ } else {
one.setOnlineStatus(0);
}
return one;
@@ -194,4 +195,69 @@
return resultList;
}
+
+ /**
+ * 鍗曠伅鑺傝兘鐜�
+ *
+ * @return
+ */
+ public List<LightReportData> controlEnergySaving() {
+ Long clientId = SecurityUtils.getClientId();
+// List<LightBo> listLight = baseMapper.listLight(clientId, null);
+// List<String> deviceCodeList = listLight.stream().map(LightBo::getDeviceCode).collect(Collectors.toList());
+ List<String> deviceCodeList = new ArrayList<>();
+ deviceCodeList.add("32313243305005ffa633ffff");
+// DateTime startDate = DateUtil.date();
+// DateTime endDate = DateUtil.offsetDay(startDate, 3);
+// if (CollectionUtil.isNotEmpty(deviceCodeList)) {
+//
+// List<LightReportDataBo> reportDataList = lightReportDataService.reportDataList(deviceCodeList, startDate, endDate);
+// }
+
+ //鑾峰彇鐢ㄦ埛鏈�杩�7澶╃殑鍗曠伅鏁版嵁
+ List<LightReportData> reportDataList = lightReportDataService.list(Wrappers.<LightReportData>lambdaQuery()
+ .in(LightReportData::getDeviceCode, deviceCodeList)
+ .ge(LightReportData::getCreateTime, DateUtil.offsetDay(DateUtil.yesterday(), -7))
+ .orderByDesc(LightReportData::getCreateTime));
+
+
+ LocalDateTime dateTime = LocalDateTime.now();
+ dateTime.plusDays(7L);
+ reportDataList.forEach(
+ reportData -> {
+ LocalDateTime createTime = reportData.getCreateTime();
+ if(dateTime.plusDays(-1L).getDayOfMonth()==createTime.getDayOfMonth()){
+
+ }
+ }
+ );
+
+
+ Map map = new HashMap();
+ map.put("-1", null);
+
+
+ return reportDataList;
+ }
+
+ /**
+ * 鐢ㄦ埛鎷ユ湁鐨勮矾鐏�
+ *
+ * @return
+ */
+ public List<Light> listLight() {
+ List<LightBo> listLight;
+ if (SecurityUtils.getClientId() != null) {
+ listLight = baseMapper.listLight(SecurityUtils.getUserId(), null);
+ } else {
+ listLight = baseMapper.listLight(null, null);
+ }
+ List<Light> lightList = new ArrayList<>();
+ for (LightBo bean : listLight) {
+ Light light = getLight(bean.getDeviceCode());
+ lightList.add(light);
+ }
+ return lightList;
+ }
+
}
--
Gitblit v1.9.3