From e54bc01ed3a571abc9de4dd4c32893e8741bb0f0 Mon Sep 17 00:00:00 2001
From: jpy <812110275@qq.com>
Date: Sat, 27 May 2023 15:13:28 +0800
Subject: [PATCH] test

---
 screen-api/src/main/java/com/moral/api/service/impl/DataDisplayServiceImpl.java |   38 +++++++++++++++++++++++++++++++++++++-
 1 files changed, 37 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..543886e 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);
@@ -272,6 +299,15 @@
         for (String sensor : sensors) {
             SensorComparisonDisplayDTO dto = new SensorComparisonDisplayDTO();
             List<Map<String, Object>> dtoTimeValueList = new ArrayList<>();
+            if(sensor.equals("a00e12") || sensor.equals("a00e03")){
+                dto.setCode("1");
+            }else if (sensor.equals("a01006")){
+                dto.setCode("2");
+            }else if (sensor.equals("a99054") || sensor.equals("a21005")){
+                dto.setCode("3");
+            }else {
+                dto.setCode("0");
+            }
             dto.setSensorCode(sensor);
             timeValueMap.forEach((time, valueJson) -> {
                 Map<String, Object> listMap = new HashMap<>();

--
Gitblit v1.8.0