| | |
| | | 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.springframework.util.ObjectUtils;
|
| | |
| | | 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);
|
| | | 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);
|
| | | }
|
| | | 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, "[]");
|