From 606c896c1b7c9d986cfb13d8464f3482160a1389 Mon Sep 17 00:00:00 2001 From: fengxiang <110431245@qq.com> Date: Tue, 08 May 2018 09:47:40 +0800 Subject: [PATCH] 手机 设备 保存 api --- src/main/java/com/moral/controller/ReportController.java | 47 +++++++++++++++++++++++++++++++++++++---------- 1 files changed, 37 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/moral/controller/ReportController.java b/src/main/java/com/moral/controller/ReportController.java index ed398a7..b95ea24 100644 --- a/src/main/java/com/moral/controller/ReportController.java +++ b/src/main/java/com/moral/controller/ReportController.java @@ -4,10 +4,8 @@ import static com.moral.common.util.WebUtils.getParametersStartingWith; import java.io.OutputStream; -import java.util.ArrayList; import java.util.List; import java.util.Map; -import java.util.Set; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; @@ -23,9 +21,10 @@ import com.moral.common.bean.ResultBean; import com.moral.entity.charts.LineChartCriteria; +import com.moral.service.AlarmDailyService; import com.moral.service.HistoryMinutelyService; -@SuppressWarnings("unchecked") +@SuppressWarnings({ "unchecked", "rawtypes" }) @RestController @RequestMapping("report") @CrossOrigin(origins = "*", maxAge = 3600) @@ -34,11 +33,14 @@ @Resource private HistoryMinutelyService historyMinutelyService; + @Resource + private AlarmDailyService alarmDailyService; + @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") @@ -50,7 +52,7 @@ 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= (List<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++) { @@ -58,14 +60,39 @@ 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 = alarmDailyService.getPieData(parameters); + + return new ResultBean<Map<String, Object>>(pieData); + } + + @GetMapping("alarm-year") + public ResultBean<List<Integer>> getAlarmDataByYear(HttpServletRequest request) throws Exception { + Map<String, Object> parameters = getParametersStartingWith(request, null); + List<Integer> result = alarmDailyService.getAlarmDataByYear(parameters); + + return new ResultBean<List<Integer>>(result); + } + + @GetMapping("alarm-month") + public ResultBean<List<Map<String, Object>>> getAlarmDataByMonth(HttpServletRequest request) throws Exception { + Map<String, Object> parameters = getParametersStartingWith(request, null); + List<Map<String, Object>> result = alarmDailyService.getAlarmDataByMonth(parameters); + + return new ResultBean<List<Map<String, Object>>>(result); + } + } -- Gitblit v1.8.0