xufenglei
2019-08-12 b9c7bd2fd2953d13b24efdc2d0289dc70c0705ee
src/main/java/com/moral/service/impl/HistoryServiceImpl.java
@@ -38,6 +38,7 @@
import com.moral.service.AccountService;
import com.moral.service.HistoryService;
import com.moral.service.ProfessionService;
import com.moral.util.AQICalculation;
@Service
public class HistoryServiceImpl implements HistoryService {
@@ -286,7 +287,7 @@
         if (sensorUnits.containsKey(sensorKey)) {
            Map<String, Object> sensorUnit  = (Map<String, Object>) sensorUnits.get(sensorKey);
            String rules = sensorUnit.get("rules").toString();
            rules = rules.replace("d", "").replace("{0}", "sensorKeyValue");
            rules = rules.replace("d", "").replace("{0}", "value");
            Expression expression = AviatorEvaluator.compile(rules);
            Map<String, Object> env = new HashMap<String, Object>();
            env.put("value", Double.valueOf(sensorKeyValue.toString()));
@@ -359,6 +360,20 @@
         startTime = localDate+" "+startHour+":00:00";
      }
      Map<String, Object> map = historyMapper.getAVGValueByMacAndTimeslot(mac, startTime, endTime);
      return map;
      System.out.println(map);
      Map<String, Object> returnMap = new HashMap<>();
      if (map.isEmpty()) {
         returnMap.put("AQI", "N/V");
      } else {
         Map<String, Double> AQIMap = new HashMap<>();
         for (Map.Entry<String, Object> entry : map.entrySet()) {
            String key = entry.getKey();
            Double value = Double.parseDouble(entry.getValue().toString());
            AQIMap.put(key, value);
           }
         returnMap = AQICalculation.hourlyAQI(AQIMap);
      }
      return returnMap;
   }
}