fengxiang
2018-03-19 00d2837b0056d84394df6ebcb4e779698c283c0d
src/main/java/com/moral/controller/ReportController.java
@@ -12,13 +12,13 @@
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")
@@ -26,25 +26,27 @@
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("-");
@@ -56,6 +58,7 @@
      } 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();