| | |
| | | package com.moral.controller;
|
| | |
|
| | | import java.io.OutputStream;
|
| | | import java.text.ParseException;
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Calendar;
|
| | | import java.util.Collections;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.time.LocalDateTime;
|
| | | import java.time.format.DateTimeFormatter;
|
| | | import java.util.*;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import javax.servlet.ServletOutputStream;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | |
|
| | | import com.moral.service.*;
|
| | | import com.moral.util.DatesUtil;
|
| | | import org.apache.commons.collections.CollectionUtils;
|
| | | import org.apache.commons.lang.StringUtils;
|
| | | import org.apache.commons.lang3.time.DateUtils;
|
| | | import org.springframework.util.ObjectUtils;
|
| | | import org.springframework.web.bind.annotation.CrossOrigin;
|
| | | import org.springframework.web.bind.annotation.GetMapping;
|
| | |
| | | import com.moral.entity.charts.LineChartCriteria;
|
| | | import com.moral.security.auth.JwtAuthenticationToken;
|
| | | import com.moral.security.model.UserContext;
|
| | | import com.moral.service.AlarmDailyService;
|
| | | import com.moral.service.HistoryDailyService;
|
| | | import com.moral.service.HistoryMinutelyService;
|
| | | import com.moral.service.MonitorPointService;
|
| | | import com.moral.service.SensorService;
|
| | |
|
| | | import cn.hutool.core.io.IoUtil;
|
| | | import cn.hutool.poi.excel.ExcelWriter;
|
| | |
| | | @Resource
|
| | | private SensorService sensorService;
|
| | |
|
| | | @Resource
|
| | | private HistoryService historyService;
|
| | |
|
| | | @GetMapping("compare")
|
| | | public ResultBean<Map<String, List>> getCompareReport(HttpServletRequest request) throws Exception {
|
| | | Map<String, Object> parameters = getParametersStartingWith(request, null);
|
| | |
| | | List<Map<String, Object>> list = historyMinutelyService.getMonitorPointOrDeviceAvgData(parameters);
|
| | | List<String> sensors = (List<String>) parameters.get("sensors");
|
| | | String[][] exportColumn = new String[sensors.size() + 1][];
|
| | | System.out.println(list.toString());
|
| | | exportColumn[0] = new String[]{"时间", "20", "time"};
|
| | | for (int index = 0; index < sensors.size(); index++) {
|
| | | String[] split = sensors.get(index).split("-");
|
| | |
| | | outputStream.close();
|
| | | return new ResultBean<Boolean>(true);
|
| | | }
|
| | |
|
| | | //计算臭氧平缓平均值并导出
|
| | | @GetMapping("O3Excel")
|
| | | public ResultBean<Boolean> getO3ExcelReport(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
| | | Map<String, Object> parameters = getParametersStartingWith(request, null);
|
| | | List<Map<String,Object>> maxList=historyService.getO3AVG(parameters);
|
| | | String[][] exportColumn = new String[2][];
|
| | | exportColumn[0] = new String[]{"时间", "20", "time"};
|
| | | String name = "O3浓度";
|
| | | String key = "e15";
|
| | | String unit = "ug/m³";
|
| | | if (!ObjectUtils.isEmpty(unit) && !"null".equals(unit)) {
|
| | | name += "-" + unit;
|
| | | }
|
| | | exportColumn[1] = new String[]{name, "10", key};
|
| | | OutputStream outputStream = exportData(response, "Excel数据", maxList, exportColumn);
|
| | | outputStream.flush();
|
| | | outputStream.close();
|
| | | return new ResultBean<Boolean>(true);
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | | @GetMapping("newExcel")
|
| | | public ResultBean<Boolean> getNExcelReport(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
| | |
| | | @GetMapping("custom-made-excel")
|
| | | public ResultBean<Boolean> getCustomMadeExcelReport(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
| | | Map<String, Object> parameters = getParametersStartingWith(request, null);
|
| | | System.out.println(parameters.toString());
|
| | | ParameterUtils.getTimeType4Time(parameters);
|
| | | String sensorsInfo = parameters.get("sensors").toString();
|
| | | String sensorsInfoNew = StringUtils.strip(sensorsInfo, "[]");
|