From 3d665d84b1a4ffd6749ca9354247838ce0622f4b Mon Sep 17 00:00:00 2001
From: jinpengyong <jpy123456>
Date: Tue, 13 Dec 2022 13:47:53 +0800
Subject: [PATCH] 修改sql语句问题
---
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