Merge remote-tracking branch 'origin/cjl' into qa
| | |
| | | |
| | | // 修改设备状态 |
| | | private void judgeDeviceState(String mac,Map<String, Object> dataMap){ |
| | | List<String> sensorList = Arrays.asList("a34004","a34002","a21026","a21004","a21005","a05024","a99054"); |
| | | Device device = (Device) redisTemplate.opsForHash().get(RedisConstants.DEVICE_INFO, mac); |
| | | List<Sensor> sensors = device.getVersion().getSensors(); |
| | | Expression expression; |
| | | int state = 1; |
| | | for (Sensor sensor : sensors) { |
| | | if(!sensorList.contains(sensor.getCode())){ |
| | | continue; |
| | | } |
| | | //因子报警等级 |
| | | String alarmLevel = sensor.getAlarmLevel(); |
| | | if (StringUtils.isEmpty(alarmLevel)) { |
| | |
| | | public void listenSecond(ConsumerRecord<String, String> record, Acknowledgment ack) { |
| | | String msg = record.value(); |
| | | try { |
| | | |
| | | ack.acknowledge(); |
| | | Map<String, Object> data = JSON.parseObject(msg, Map.class); |
| | | Object mac = data.get("mac"); |
| | | Object time = data.get("DataTime"); |
| | | if (ObjectUtils.isEmpty(time) || ObjectUtils.isEmpty(mac)) { |
| | | log.warn("some properties is null, param{}", msg); |
| | | ack.acknowledge(); |
| | | return; |
| | | } |
| | | List<String> listDictDevice = Arrays.asList(deviceList.split(",")); |
| | | if(!listDictDevice.contains(mac.toString())){ |
| | | ack.acknowledge(); |
| | | } |
| | | //数据过滤 |
| | | data.remove("time"); |
| | | data.remove("entryTime"); |
| | | |
| | | data.put("DataTime", time); |
| | | List<String> listDictDevice = Arrays.asList(deviceList.split(",")); |
| | | if(listDictDevice.contains(mac.toString())){ |
| | | //判断并修改设备状态 |
| | | data.put("mac", mac); |
| | | deviceService.judgeDeviceState(data); |
| | | } |
| | | //数据校准 |
| | | //data = deviceService.adjustDeviceData(data,"0"); |
| | | //存入redis |
| | | data.put("DataTime", time); |
| | | //redisTemplate.opsForHash().put(RedisConstants.DATA_SECOND, mac, data); |
| | | //判断并修改设备状态 |
| | | data.put("mac", mac); |
| | | ack.acknowledge(); |
| | | deviceService.judgeDeviceState(data); |
| | | |
| | | }catch (CommitFailedException e){ |
| | | log.error("param{}" + msg); |
| | | } catch (Exception e) { |
| | |
| | | map.put("cel",1); |
| | | } |
| | | }else { |
| | | if (code.equals("a99054")){ |
| | | if (code.equals("a99054")&& !value.contains("+")){ |
| | | String[] split = value.split("\\*"); |
| | | map.put("cel",Double.parseDouble(split[1])); |
| | | }else { |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void judgeDeviceState(Map<String, Object> deviceData) { |
| | | String mac = deviceData.remove("mac").toString(); |
| | | Device device = (Device) redisTemplate.opsForHash().get(RedisConstants.DEVICE_INFO, mac); |
| | |
| | | } |
| | | } |
| | | //修改设备状态 |
| | | UpdateWrapper<Device> updateWrapper = new UpdateWrapper<>(); |
| | | updateWrapper.eq("id", device.getId()).set("state", String.valueOf(state)); |
| | | deviceMapper.update(null, updateWrapper); |
| | | Device device1 = new Device(); |
| | | device1.setId(device.getId()); |
| | | device1.setState(String.valueOf(state)); |
| | | deviceMapper.updateById(device1); |
| | | } |
| | | |
| | | @Override |