| | |
| | | import javax.servlet.http.HttpServletRequest;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | |
|
| | | import org.springframework.web.bind.annotation.CrossOrigin;
|
| | | import org.springframework.web.bind.annotation.GetMapping;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RestController;
|
| | | import com.alibaba.fastjson.JSON;
|
| | | import com.moral.entity.charts.LineChartCriteria;
|
| | | import com.moral.entity.charts.PairData;
|
| | | import org.springframework.web.bind.annotation.*;
|
| | |
|
| | | import com.moral.common.bean.ResultBean;
|
| | | import com.moral.service.DataService;
|
| | | import com.moral.service.HistoryMinutelyService;
|
| | |
|
| | | @RestController
|
| | | @RequestMapping("report")
|
| | |
| | | public class ReportController {
|
| | |
|
| | | @Resource
|
| | | private DataService dataService;
|
| | | private HistoryMinutelyService historyMinutelyService;
|
| | |
|
| | | @GetMapping("compare")
|
| | | public ResultBean<Map<String, List<Object>>> getCompareReport(HttpServletRequest request) throws Exception {
|
| | | Map<String, Object> parameters = getParametersStartingWith(request, null);
|
| | | Map<String, List<Object>> demo = dataService.getCompareReport(parameters); |
| | | Map<String, List<Object>> demo = historyMinutelyService.getCompareReport(parameters); |
| | | return new ResultBean<Map<String,List<Object>>>(demo);
|
| | | }
|
| | |
|
| | | @PostMapping("line-chart")
|
| | | public ResultBean <Map<String, List<List<PairData>>>> lineChart(@RequestBody LineChartCriteria lineChartCriteria){
|
| | | return new ResultBean<>(historyMinutelyService.queryLineChartDateByCrieria(lineChartCriteria));
|
| | | }
|
| | | @GetMapping("excel")
|
| | | public ResultBean<Boolean> getExcelReport(HttpServletRequest request,HttpServletResponse response) throws Exception {
|
| | | Map<String, Object> parameters = getParametersStartingWith(request, null);
|
| | | List<Map<String, Object>> list = dataService.getMonitorPointOrDeviceAvgData4Excel(parameters); |
| | | List<Map<String, Object>> list = historyMinutelyService.getMonitorPointOrDeviceAvgData(parameters); |
| | | String[][] exportColumn = new String[2][];
|
| | | exportColumn[0] = new String[] { "时间", "20", "time" };
|
| | | if (parameters.containsKey("sensors")) {
|
| | | Set<String> sensors = (Set<String>) parameters.get("sensors");
|
| | | exportColumn = new String[sensors.size() + 1][];
|
| | | exportColumn[0] = new String[] { "时间", "20", "time" };
|
| | | // exportColumn[0] = new String[] { "时间", "20", "time" };
|
| | | int index = 1;
|
| | | for (String sensorKey : sensors) {
|
| | | String[] split = sensorKey.split("-");
|
| | |
| | | } else {
|
| | | exportColumn[1] = new String[] { (String) parameters.get("sensorName"), "10", (String) parameters.get("sensorKey") };
|
| | | }
|
| | | exportColumn[0] = new String[] { "时间", "20", "time" };
|
| | |
|
| | | OutputStream outputStream = exportData(response, "Excel数据", list, exportColumn);
|
| | | outputStream.flush();
|