fengxiang
2018-03-26 53d155ae4b7c4d5d7258c3d15cfff78ec41561f7
src/main/java/com/moral/service/impl/HistoryMinutelyServiceImpl.java
@@ -143,13 +143,10 @@
   @Override
   public Map<String, List<Object>> getCompareReport(Map<String, Object> parameters) throws Exception {
      Map<String, List<Object>> resultMap = new HashMap<String, List<Object>>();
      List<Map<String, Object>> list = JSON.parseObject((String)parameters.get("items"), new TypeReference<List<Map<String, Object>>>() {});
      parameters.remove("items");
      Map<String, Object> timeType = JSON.parseObject((String)parameters.get("timeTypes"), new TypeReference<Map<String, Object>>() {});
      parameters.remove("timeTypes");
      List<Map<String, Object>> list = JSON.parseObject((String)parameters.remove("items"), new TypeReference<List<Map<String, Object>>>() {});
      Map<String, Object> timeType = JSON.parseObject((String)parameters.remove("timeType"), new TypeReference<Map<String, Object>>() {});
      parameters.putAll(timeType);
      parameters.put("type", parameters.get("value"));
      parameters.remove("value");
      parameters.put("type", parameters.remove("value"));
      
      ExecutorService threadPool = Executors.newCachedThreadPool();
      CompletionService<Map<String, List<Object>>> cs = new ExecutorCompletionService<Map<String, List<Object>>>(threadPool);
@@ -179,8 +176,7 @@
         if (ObjectUtils.isEmpty(map.get("mac"))) {
            map.remove("mac");
         }
         map.put("time", map.get("formatTime"));
         map.remove("formatTime");
         map.put("time", map.remove("formatTime"));
         map.putAll(parameters);
         cs.submit(new Callable<Map<String, List<Object>>>() {
            @Override
@@ -318,7 +314,7 @@
      // 监控点平均值
      if (!parameters.containsKey("mac")) {
         resultList = new ArrayList<Map<String,Object>>();
         Integer monitorPointId = Integer.valueOf(parameters.get("monitorPoint").toString());
         Integer monitorPointId = Integer.valueOf(parameters.get("monitorPointId").toString());
         List<Map<String, Object>> deviceVersions = deviceMapper.getDeviceVersionIdByMonitorPoint(monitorPointId);
         ExecutorService threadPool = Executors.newCachedThreadPool();
         CompletionService<List<Map<String, Object>>> cs = new ExecutorCompletionService<List<Map<String, Object>>>(threadPool);
@@ -349,8 +345,7 @@
         }
         Map<String, Map<String, Number[]>> result = new LinkedHashMap<String, Map<String, Number[]>>();
         for (Map<String, Object> map : list) {
            time = (String) map.get("time");
            map.remove("time");
            time = (String) map.remove("time");
            Map<String, Number[]> times = new HashMap<String, Number[]>();
            if (result.containsKey(time)) {
               times = (Map<String, Number[]>) result.get(time);
@@ -477,7 +472,7 @@
   }
   /**
    * 根据线性表单的条件规则,获取一条线性表单数据
    * 根据线性表单的条件规则,获取一条线性表单数据,包含 所有检测项目
    * @param sensorKeys
    * @param timePeriod
    * @param dataCondition
@@ -508,8 +503,12 @@
                   // list to map
                   int finalN = n;
                   sensorKeys.forEach(sensorKey -> {
                      Double sensorValue = rowData.get(sensorKey)!= null?new Double(rowData.get(sensorKey).toString()):null;
                      lineChartDatasWithEmpty.get(sensorKey).set(finalN,sensorValue);
                       Object value = rowData.get(sensorKey);
                      List<Double> lineChartDatasWithEmptyTemp = lineChartDatasWithEmpty.get(sensorKey);
                      if(finalN < lineChartDatasWithEmptyTemp.size()){
                         Double sensorValue = value!= null?new Double(value.toString()):null;
                         lineChartDatasWithEmptyTemp.set(finalN,sensorValue);
                      }
                   });
                   // 置为 -1,防止越界
                   m = m<dataLength ? m+1 : -1;