| | |
| | | import com.moral.entity.charts.DataCondition;
|
| | | import com.moral.entity.charts.LineChartCriteria;
|
| | | import com.moral.entity.charts.TimePeriod;
|
| | | import com.moral.mapper.AlarmDailyMapper;
|
| | | import com.moral.mapper.AlarmMapper;
|
| | | import com.moral.mapper.DeviceMapper;
|
| | | import com.moral.mapper.HistoryMinutelyMapper;
|
| | |
| | | private SensorMapper sensorMapper;
|
| | |
|
| | | @Resource
|
| | | private AlarmMapper alarmMapper;
|
| | | private AlarmDailyMapper alarmDailyMapper;
|
| | |
|
| | | @Override
|
| | | public Map<String, Object> getDayAQIByDevice(Map<String, Object> parameters) {
|
| | | ValidateUtil.notNull(parameters.get("mac"), "param.is.null");
|
| | | //ValidateUtil.notNull(parameters.get("mac"), "param.is.null");
|
| | | LocalDate localDate = LocalDate.now();
|
| | | // 昨日00:00:00
|
| | | parameters.put("start", localDate.minusDays(1));
|
| | |
| | | Map<String, BigDecimal> mapData = (Map<String, BigDecimal>) obj;
|
| | | BigDecimal sum = mapData.remove("sum");
|
| | | for (Entry<String, BigDecimal> entry : mapData.entrySet()) {
|
| | | sortMap.put(entry.getKey() + "-" + index, new BigDecimal(100).multiply(entry.getValue())
|
| | | .divide(sum, 2, BigDecimal.ROUND_HALF_UP).doubleValue());
|
| | | if (!"name".equals(entry.getKey())) {
|
| | | sortMap.put(entry.getKey() + "-" + index, new BigDecimal(100).multiply(entry.getValue())
|
| | | .divide(sum, 2, BigDecimal.ROUND_HALF_UP).doubleValue());
|
| | | |
| | | }
|
| | | }
|
| | | }
|
| | | break;
|
| | |
| | | Object type = parameters.get("type");
|
| | | if ("year".equals(type) || "month".equals(type)) {
|
| | | parameters.put("sensorKeys", Arrays.asList("e1", "e2", "e10", "e11", "e15", "e16"));
|
| | | resultMap.put("alarmData" + part, alarmMapper.getAlarmData(parameters).get(0));
|
| | | resultMap.put("alarmData" + part, alarmDailyMapper.getAlarmData(parameters).get(0));
|
| | | }
|
| | | return resultMap;
|
| | | }
|
| | |
| | |
|
| | | @Override
|
| | | public Map<String, Object> getMonthAverageBySensor(Map<String, Object> parameters) {
|
| | | ValidateUtil.notNull(parameters.get("mac"), "param.is.null");
|
| | | ValidateUtil.notNull(parameters.get("macKey"), "param.is.null");
|
| | | //ValidateUtil.notNull(parameters.get("mac"), "param.is.null");
|
| | | Object sensorKey = parameters.remove("macKey");
|
| | | ValidateUtil.notNull(sensorKey, "param.is.null");
|
| | | Map<String, Object> result = new HashMap<String, Object>();
|
| | | LocalDate end = LocalDate.now(),start;
|
| | | // 每月一日的数据取上月的数据
|
| | |
| | | }
|
| | | parameters.put("start", start);
|
| | | parameters.put("end", end);
|
| | | String sensorKey = (String) parameters.remove("macKey");
|
| | | List<String> sensorKeys = new ArrayList<String>();
|
| | | sensorKeys.add(sensorKey);
|
| | | parameters.put("sensorKeys", sensorKeys);
|
| | | parameters.put("sensorKeys", Arrays.asList(sensorKey));
|
| | |
|
| | | Map<String, Double> average = historyMinutelyMapper.getSersionAvgByDevice(parameters);
|
| | | if (isEmpty(average)) {
|