| | |
| | | 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;
|
| | |
| | | @GetMapping("newExcel")
|
| | | public ResultBean<Boolean> getNExcelReport(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
| | | Map<String, Object> parameters = getParametersStartingWith(request, null);
|
| | | List<Map<String, Object>> list = historyMinutelyService.getMonitorPointOrDeviceAvgData(parameters);
|
| | | ArrayList<String> sensorKeys = (ArrayList<String>) parameters.get("sensorKeys");
|
| | | for (Map<String, Object> map : list) {
|
| | | for (String sensorKey : sensorKeys) {
|
| | | if (map.get(sensorKey) == null) {
|
| | | map.put(sensorKey, "");
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | String type = parameters.get("type").toString();
|
| | | String time = parameters.get("time").toString();
|
| | | String timeb = "";
|
| | | String timeb;
|
| | | if (parameters.get("timeb") == null) {
|
| | | timeb = parameters.get("time").toString();
|
| | | } else {
|
| | | timeb = parameters.get("timeb").toString();
|
| | | timeb = time;
|
| | | }else {
|
| | | timeb=parameters.get("timeb").toString();
|
| | | }
|
| | |
|
| | | String[] endTimes = timeb.split("-");
|
| | |
| | | String beginTime = "";
|
| | | String endTime = "";
|
| | | List<String> monthList1 = new ArrayList<>();
|
| | | monthList1.add("01");
|
| | | monthList1.add("03");
|
| | | monthList1.add("05");
|
| | | monthList1.add("07");
|
| | | monthList1.add("08");
|
| | | monthList1.add("10");
|
| | | monthList1.add("12");
|
| | | Collections.addAll(monthList1,"01","03","05","07","08","10","12");
|
| | | List<String> monthList2 = new ArrayList<>();
|
| | | monthList2.add("04");
|
| | | monthList2.add("06");
|
| | | monthList2.add("09");
|
| | | monthList2.add("11");
|
| | | Collections.addAll(monthList2,"04","06","09","11");
|
| | |
|
| | | Integer year = Integer.valueOf(endTimes[0]);
|
| | | int i = 0;
|
| | |
|
| | | if (type.equals("year")) {
|
| | | dateFormat = "yyyy-MM";
|
| | | beginTime = time + "-01";
|
| | |
| | | beginTime = time + " 00";
|
| | | endTime = timeb + " 23";
|
| | | i = Calendar.HOUR_OF_DAY;
|
| | | } else if (type.equals("hour")) {
|
| | | dateFormat = "yyyy-MM-dd HH:mm";
|
| | | beginTime = time + ":00:00";
|
| | | endTime = timeb + ":59:00";
|
| | | i = Calendar.MINUTE;
|
| | | }else if(type.equals("hour")){
|
| | | dateFormat="yyyy-MM-dd HH:mm";
|
| | | beginTime=time+":00:00";
|
| | | endTime=timeb+":59:00";
|
| | | i=Calendar.MINUTE;
|
| | | }
|
| | |
|
| | | SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
|
| | |
| | | resultList.add(map);
|
| | | }
|
| | |
|
| | | if(type.equals("year")){
|
| | | SimpleDateFormat sd = new SimpleDateFormat("yyyy");
|
| | | Date dt = sd.parse(timeb);
|
| | | Calendar calendar = Calendar.getInstance();
|
| | | calendar.setTime(dt);
|
| | | calendar.add(Calendar.YEAR, 1);
|
| | | Date dt1 = calendar.getTime();
|
| | | timeb = sd.format(dt1);
|
| | | }else if(type.equals("month")){
|
| | | SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM");
|
| | | Date dt = sd.parse(timeb);
|
| | | Calendar calendar = Calendar.getInstance();
|
| | | calendar.setTime(dt);
|
| | | calendar.add(Calendar.MONTH, 1);
|
| | | Date dt1 = calendar.getTime();
|
| | | timeb = sd.format(dt1);
|
| | | }else if(type.equals("day")){
|
| | | SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
|
| | | Date dt = sd.parse(timeb);
|
| | | Calendar calendar = Calendar.getInstance();
|
| | | calendar.setTime(dt);
|
| | | calendar.add(Calendar.DAY_OF_MONTH, 1);
|
| | | Date dt1 = calendar.getTime();
|
| | | timeb = sd.format(dt1);
|
| | | }else if(type.equals("hour")){
|
| | | SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH");
|
| | | Date dt = sd.parse(timeb);
|
| | | Calendar calendar = Calendar.getInstance();
|
| | | calendar.setTime(dt);
|
| | | calendar.add(Calendar.HOUR_OF_DAY, 1);
|
| | | Date dt1 = calendar.getTime();
|
| | | timeb = sd.format(dt1);
|
| | | }
|
| | | parameters.put("timeb",timeb);
|
| | | List<Map<String, Object>> list = historyMinutelyService.getMonitorPointOrDeviceAvgData(parameters);
|
| | | ArrayList<String> sensorKeys = (ArrayList<String>)parameters.get("sensorKeys");
|
| | | for (Map<String, Object> map : list) {
|
| | | for (String sensorKey : sensorKeys) {
|
| | | if(map.get(sensorKey)==null){
|
| | | map.put(sensorKey,"");
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | for (Map<String, Object> map : resultList) {
|
| | | for (Map<String, Object> resultMap : list) {
|
| | | if (resultMap.get("time").equals(map.get("time"))) {
|