| | |
| | | package com.moral.controller;
|
| | |
|
| | | import static com.moral.common.util.ExportExcelUtils.exportData;
|
| | | import static com.moral.common.util.WebUtils.getParametersStartingWith;
|
| | |
|
| | | import java.io.OutputStream;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Arrays;
|
| | | import java.util.LinkedHashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | |
| | | import javax.servlet.http.HttpServletRequest;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | |
|
| | | import org.apache.commons.collections.CollectionUtils;
|
| | | import org.springframework.util.ObjectUtils;
|
| | | import org.springframework.web.bind.annotation.CrossOrigin;
|
| | | import org.springframework.web.bind.annotation.GetMapping;
|
| | |
| | | import org.springframework.web.bind.annotation.RestController;
|
| | |
|
| | | import com.moral.common.bean.ResultBean;
|
| | | import com.moral.common.util.ParameterUtils;
|
| | | import com.moral.common.util.WebUtils;
|
| | | import com.moral.entity.Device;
|
| | | import com.moral.entity.MonitorPoint;
|
| | | 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 static com.moral.common.util.ExportExcelUtils.exportData;
|
| | | import static com.moral.common.util.WebUtils.getParametersStartingWith;
|
| | |
|
| | | @SuppressWarnings({ "unchecked", "rawtypes" })
|
| | | @RestController
|
| | |
| | |
|
| | | @Resource
|
| | | private AlarmDailyService alarmDailyService;
|
| | |
|
| | | @Resource
|
| | | private MonitorPointService monitorPointService;
|
| | |
|
| | | @GetMapping("compare")
|
| | | public ResultBean<Map<String, List>> getCompareReport(HttpServletRequest request) throws Exception {
|
| | |
| | | Map result = historyDailyService.getOverproofData(parameters);
|
| | | return new ResultBean<Map>(result);
|
| | | }
|
| | |
|
| | | @GetMapping("custom-made-excel")
|
| | | public ResultBean<Boolean> getCustomMadeExcelReport(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
| | | Map<String, Object> parameters = getParametersStartingWith(request, null);
|
| | | ParameterUtils.getTimeType4Time(parameters);
|
| | | Object sensorKey = parameters.get("sensorKey");
|
| | | String sensorInfo = parameters.get("sensorInfo").toString();
|
| | | parameters.put("sensorKeys", Arrays.asList(sensorKey));
|
| | | List<String> macList = new ArrayList<>();
|
| | | List<MonitorPoint> monitorPoints = monitorPointService.getMonitorPointsAndDevicesByRegion(parameters);
|
| | | for (MonitorPoint m : monitorPoints) {
|
| | | for (Device d : m.getDevices()) {
|
| | | macList.add(d.getMac());
|
| | | }
|
| | | }
|
| | | parameters.put("macs", macList);
|
| | | List<Map<String, Object>> list = new ArrayList<>();
|
| | | if (!CollectionUtils.isEmpty(macList)) {
|
| | | list = historyMinutelyService.getDevicesAvgDataToExcel(parameters);
|
| | | }
|
| | | Map<String, Object> map = list.get(0);
|
| | | Map<Integer, String> mapNew = new LinkedHashMap<>();
|
| | | int i = 0;
|
| | | for (String key : map.keySet()) {
|
| | | if (!("monitorPointName".equals(key) || "name".equals(key))) {
|
| | | mapNew.put(i, key);
|
| | | i++;
|
| | | }
|
| | | }
|
| | | String[][] exportColumn = new String[map.size()][];
|
| | | exportColumn[0] = new String[]{"站点名称-" + sensorInfo, "30", "monitorPointName"};
|
| | | exportColumn[1] = new String[]{"设备名称", "20", "name"};
|
| | | for (int index = 0; index < map.size() - 2; index++) {
|
| | | exportColumn[index + 2] = new String[]{mapNew.get(index), "20", mapNew.get(index)};
|
| | | }
|
| | | OutputStream outputStream = exportData(response, "Excel数据", list, exportColumn);
|
| | | outputStream.flush();
|
| | | outputStream.close();
|
| | | return new ResultBean<Boolean>(true);
|
| | | }
|
| | |
|
| | | }
|