From 772a7baaa574d1d3c9dd14fd5d1c327a6f134d38 Mon Sep 17 00:00:00 2001
From: chen_xi <276999030@qq.com>
Date: Mon, 07 Nov 2022 15:42:32 +0800
Subject: [PATCH] 单站多因子月数据
---
screen-api/src/main/java/com/moral/api/service/impl/DataDisplayServiceImpl.java | 29 ++++++++++++++++++++++++++++-
1 files changed, 28 insertions(+), 1 deletions(-)
diff --git a/screen-api/src/main/java/com/moral/api/service/impl/DataDisplayServiceImpl.java b/screen-api/src/main/java/com/moral/api/service/impl/DataDisplayServiceImpl.java
index 7dd9839..b33e752 100644
--- a/screen-api/src/main/java/com/moral/api/service/impl/DataDisplayServiceImpl.java
+++ b/screen-api/src/main/java/com/moral/api/service/impl/DataDisplayServiceImpl.java
@@ -1,7 +1,9 @@
package com.moral.api.service.impl;
import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.moral.api.entity.*;
+import com.moral.api.mapper.HistoryMonthlyMapper;
import com.moral.api.pojo.dto.dataDisplay.MonitorPointDataDisplayDTO;
import com.moral.api.pojo.dto.dataDisplay.SensorComparisonDisplayDTO;
import com.moral.api.pojo.form.dataDisplay.MonitorPointDataDisplayForm;
@@ -32,6 +34,8 @@
HistoryDailyService historyDailyService;
@Autowired
HistoryHourlyService historyHourlyService;
+ @Autowired
+ HistoryMonthlyMapper historyMonthlyMapper;
@Autowired
HistoryWeeklyService historyWeeklyService;
@Autowired
@@ -226,8 +230,31 @@
String mac = params.get("mac").toString();
String reportType = params.get("reportType").toString();
Map<String, String> timeValueMap = new LinkedHashMap<>();//key���time���value������������json
+ //���������������
+ if (reportType.equals(Constants.MONTHLY_REPORT)) {
+ Date startDate = DateUtils.getDate(startTime,DateUtils.yyyy_MM_EN);
+ Date endDate = DateUtils.getDate(endTime,DateUtils.yyyy_MM_EN);
+ //List<HistoryHourly> hourlies = historyHourlyService.getValueByMacAndTime(mac, startDate, endDate);
+ QueryWrapper<HistoryMonthly> historyMonthlyQueryWrapper = new QueryWrapper<>();
+ historyMonthlyQueryWrapper.eq("mac",mac);
+ historyMonthlyQueryWrapper.between("time",startTime.substring(0,7)+"-01 00:00:00",endTime.substring(0,7)+"-01 00:00:00");
+ List<HistoryMonthly> monthlies = historyMonthlyMapper.selectList(historyMonthlyQueryWrapper);
+ for (HistoryMonthly historyMonthly : monthlies) {
+ Date time = historyMonthly.getTime();
+ String dateStr = DateUtils.dateToDateString(time, "yyyy-MM");
+ String value = historyMonthly.getValue();
+ timeValueMap.put(dateStr, value);
+ }
+ //���������������������
+ Date middleDate = startDate;
+ while (DateUtils.compareDateStr(DateUtils.dateToDateString(endDate,DateUtils.yyyy_MM_EN),DateUtils.dateToDateString(middleDate,DateUtils.yyyy_MM_EN),DateUtils.yyyy_MM_EN)<=0){
+ if (timeValueMap.get(DateUtils.dateToDateString(middleDate,DateUtils.yyyy_MM_EN)) == null)
+ timeValueMap.put(DateUtils.dateToDateString(middleDate,DateUtils.yyyy_MM_EN), null);
+ middleDate = DateUtils.addMonths(middleDate,1);
+ }
+ }
//������������������
- if (reportType.equals(Constants.HOURLY_REPORT)) {
+ else if (reportType.equals(Constants.HOURLY_REPORT)) {
Date startDate = DateUtils.getDate(startTime,DateUtils.yyyy_MM_dd_HH_EN);
Date endDate = DateUtils.getDate(endTime,DateUtils.yyyy_MM_dd_HH_EN);
List<HistoryHourly> hourlies = historyHourlyService.getValueByMacAndTime(mac, startDate, endDate);
--
Gitblit v1.8.0