| | |
| | | import com.moral.service.DeviceService; |
| | | import com.moral.service.HistoryHourlyService; |
| | | import com.moral.service.SensorService; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | @Service |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> getPollutionSourceDataByHour(Map<String, Object> parameters) throws Exception { |
| | | List<Sensor> sensors = sensorMapper.getSensorsByMac(parameters); |
| | | List<String> sensorKeys = new ArrayList<>(); |
| | | for (Sensor sensor : sensors) { |
| | | sensorKeys.add(sensor.getSensorKey()); |
| | | } |
| | | parameters.put("sensorKeys", sensorKeys); |
| | | Map<String, Object> pollutionSourceData = historyHourlyMapper.getPollutionSourceDataByHour(parameters); |
| | | if (MapUtils.isNotEmpty(pollutionSourceData)) { |
| | | Map<String, String> sensorsMap = sensorService.getSensorsMap(parameters); |
| | | String selectSensorKey = parameters.get("sensorKey").toString(); |
| | | for (Map.Entry<String, String> s : sensorsMap.entrySet()) { |
| | | if (selectSensorKey.equals(s.getKey())) { |
| | | selectSensorKey = s.getValue(); |
| | | } |
| | | } |
| | | pollutionSourceData.put("selectSensorKey", selectSensorKey); |
| | | } |
| | | return pollutionSourceData; |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> getPollutionSourceDataAll(Map<String, Object> parameters) throws Exception { |
| | | List<Sensor> sensors = sensorMapper.getSensorsByMac(parameters); |
| | | List<String> sensorKeys = new ArrayList<>(); |
| | | for (Sensor sensor : sensors) { |
| | | sensorKeys.add(sensor.getSensorKey()); |
| | | } |
| | | parameters.put("sensorKeys", sensorKeys); |
| | | Map<String, Object> pollutionSourceData = historyHourlyMapper.getPollutionSourceDataAll(parameters); |
| | | if (MapUtils.isNotEmpty(pollutionSourceData)) { |
| | | Map<String, String> sensorsMap = sensorService.getSensorsMap(parameters); |
| | | String selectSensorKey = parameters.get("sensorKey").toString(); |
| | | for (Map.Entry<String, String> s : sensorsMap.entrySet()) { |
| | | if (selectSensorKey.equals(s.getKey())) { |
| | | selectSensorKey = s.getValue(); |
| | | } |
| | | } |
| | | pollutionSourceData.put("selectSensorKey", selectSensorKey); |
| | | } |
| | | return pollutionSourceData; |
| | | } |
| | | |
| | | @Override |
| | | public Point getDirPoint(Map<String, Object> parameters) throws Exception { |
| | | Map<String, Object> pollutionSourceData = getPollutionSourceData(parameters); |
| | | Map<String, Object> pollutionSourceData = getPollutionSourceDataByHour(parameters); |
| | | if (MapUtils.isEmpty(pollutionSourceData)) { |
| | | pollutionSourceData = getPollutionSourceDataAll(parameters); |
| | | } |
| | | String mac = parameters.get("mac").toString(); |
| | | Device device = deviceService.getDeviceByMac(mac, false); |
| | | Point pointEnd = new Point(); |