| | |
| | | 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 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;
|
| | |
| | | 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);
|
| | | String mac= (String) parameters.get("mac");
|
| | | String stime= (String) parameters.get("time");
|
| | | SimpleDateFormat format=new SimpleDateFormat("yyyy-MM");
|
| | | Date time =format.parse(stime);
|
| | | List<String> stringListDate = DatesUtil.getAllTheDateOftheMonth(time);
|
| | | List<Map<String,Object>> maxList=new ArrayList<Map<String,Object>>();
|
| | | for (String sld : stringListDate) {
|
| | | Map<String,Object> avgMap=new HashMap<String,Object>();
|
| | | List<String> listavg=new ArrayList<String>();
|
| | | String s1="";
|
| | | for(int i=0;i<24;i++){
|
| | | if (i<10){
|
| | | sld=sld.substring(0,10);
|
| | | sld=sld+" 0"+i+":00:00";
|
| | | s1=DatesUtil.pinDate(sld);
|
| | | }else {
|
| | | sld=sld.substring(0,10);
|
| | | sld=sld+" "+i+":00:00";
|
| | | s1=DatesUtil.pinDate(sld);
|
| | | }
|
| | | System.out.println(sld+" "+s1);
|
| | | Map<String, Object> parm = new HashMap<String, Object>();
|
| | | parm.put("frontTime", sld);
|
| | | parm.put("afterTime", s1);
|
| | | parm.put("mac", mac);
|
| | | String avg = historyService.getO3AVG(parm);
|
| | | if (avg!=null){
|
| | | listavg.add(avg);
|
| | | }
|
| | | }
|
| | | String maxO3="";
|
| | | if (listavg.size()!=0){
|
| | | String subs=sld.substring(0,10);
|
| | | String timef=subs+" 00:00:00";
|
| | | String timea=subs+" 23:59:59";
|
| | | int num=historyService.getNum(timef,timea);
|
| | | if (num==0){
|
| | | maxO3="";
|
| | | }else {
|
| | | maxO3= Collections.max(listavg);
|
| | | }
|
| | | }
|
| | | avgMap.put("time",sld.substring(0,10));
|
| | | avgMap.put("e15",maxO3);
|
| | | maxList.add(avgMap);
|
| | | }
|
| | | List<Map<String,Object>> maxList=historyService.getO3AVG(parameters);
|
| | | String[][] exportColumn = new String[2][];
|
| | | exportColumn[0] = new String[]{"时间", "20", "time"};
|
| | | String name = "O3浓度";
|
| | |
| | | outputStream.flush();
|
| | | outputStream.close();
|
| | | return new ResultBean<Boolean>(true);
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | | @GetMapping("newExcel")
|