| | |
| | | import static com.moral.common.util.WebUtils.getParametersStartingWith;
|
| | |
|
| | | import java.io.OutputStream;
|
| | | import java.util.ArrayList;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.Set;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | |
| | |
|
| | | import com.moral.common.bean.ResultBean;
|
| | | import com.moral.entity.charts.LineChartCriteria;
|
| | | import com.moral.service.AlarmService;
|
| | | import com.moral.service.HistoryMinutelyService;
|
| | |
|
| | | @SuppressWarnings("unchecked")
|
| | | @SuppressWarnings({ "unchecked", "rawtypes" })
|
| | | @RestController
|
| | | @RequestMapping("report")
|
| | | @CrossOrigin(origins = "*", maxAge = 3600)
|
| | |
| | | @Resource
|
| | | private HistoryMinutelyService historyMinutelyService;
|
| | |
|
| | | @Resource
|
| | | private AlarmService alarmService;
|
| | | |
| | | @GetMapping("compare")
|
| | | public ResultBean<Map<String, List<Object>>> getCompareReport(HttpServletRequest request) throws Exception {
|
| | | public ResultBean<Map<String, List>> getCompareReport(HttpServletRequest request) throws Exception {
|
| | | Map<String, Object> parameters = getParametersStartingWith(request, null);
|
| | | Map<String, List<Object>> demo = historyMinutelyService.getCompareReport(parameters);
|
| | | return new ResultBean<Map<String, List<Object>>>(demo);
|
| | | Map<String, List> demo = historyMinutelyService.getCompareReport(parameters);
|
| | | return new ResultBean<Map<String, List>>(demo);
|
| | | }
|
| | |
|
| | | @PostMapping("line-chart")
|
| | |
| | | public ResultBean<Boolean> getExcelReport(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
| | | Map<String, Object> parameters = getParametersStartingWith(request, null);
|
| | | List<Map<String, Object>> list = historyMinutelyService.getMonitorPointOrDeviceAvgData(parameters);
|
| | | List<String> sensors= new ArrayList<String>((Set<String>) parameters.get("sensors"));
|
| | | List<String> sensors = (List<String>) parameters.get("sensors");
|
| | | String[][] exportColumn = new String[sensors.size() + 1][];
|
| | | exportColumn[0] = new String[] { "时间", "20", "time" };
|
| | | for (int index = 0; index < sensors.size(); index++) {
|
| | |
| | | String name = split[1];
|
| | | String key = split[0];
|
| | | String unit = split[2];
|
| | | if (!ObjectUtils.isEmpty(unit) && !"null".equals(unit) ) {
|
| | | if (!ObjectUtils.isEmpty(unit) && !"null".equals(unit)) {
|
| | | name += "-" + unit;
|
| | | } |
| | | exportColumn[index + 1] = new String[] { name , "10", key };
|
| | | }
|
| | | exportColumn[index + 1] = new String[] { name, "10", key };
|
| | | }
|
| | | OutputStream outputStream = exportData(response, "Excel数据", list, exportColumn);
|
| | | outputStream.flush();
|
| | | outputStream.close();
|
| | | return new ResultBean<Boolean>(true);
|
| | | }
|
| | | |
| | | @GetMapping("pie")
|
| | | public ResultBean<Map<String, Object>> getPieData(HttpServletRequest request) throws Exception {
|
| | | Map<String, Object> parameters = getParametersStartingWith(request, null);
|
| | | Map pieData = alarmService.getPieData(parameters);
|
| | | |
| | | return new ResultBean<Map<String, Object>>(pieData);
|
| | | }
|
| | |
|
| | | }
|