| | |
| | | .forEach(hmsReceiver -> { |
| | | final DeviceHmsEntity hms = entity.clone(); |
| | | this.fillEntity(hms, hmsReceiver, device); |
| | | this.fillMessage(hms, hmsReceiver.getArgs()); |
| | | // The same unread hms are no longer incremented. |
| | | if (hmsMap.contains(hms.getHmsKey())) { |
| | | // 修改已存在数据的创建时间,先查询到已存在记录,再修改。 |
| | | DeviceHmsEntity exisHms=getDeviceHmsEntity(hms); |
| | | if (exisHms != null) { |
| | | LambdaUpdateWrapper<DeviceHmsEntity> updateWrapper = new LambdaUpdateWrapper<>(); |
| | | updateWrapper.set(DeviceHmsEntity::getCreateTime, hms.getCreateTime()); |
| | | updateWrapper.eq(DeviceHmsEntity::getId, exisHms.getId()); |
| | | |
| | | mapper.update(exisHms, updateWrapper); |
| | | } |
| | | return; |
| | | } |
| | | this.fillMessage(hms, hmsReceiver.getArgs()); |
| | | unReadList.add(entity2Dto(hms)); |
| | | mapper.insert(hms); |
| | | }); |
| | |
| | | if (unReadList.isEmpty()) { |
| | | return; |
| | | } |
| | | RedisOpsUtils.listRPush(key, (Object) unReadList.stream().map(DeviceHmsDTO::getKey).toArray(String[]::new)); |
| | | // RedisOpsUtils.listRPush(key, (Object) unReadList.stream().map(DeviceHmsDTO::getKey).toArray(String[]::new)); |
| | | // 修正后:直接传入String数组,每个元素单独存 |
| | | List<String> newHmsKeys = unReadList.stream() |
| | | .map(DeviceHmsDTO::getKey) |
| | | .collect(Collectors.toList()); |
| | | RedisOpsUtils.listRPush(key, newHmsKeys.toArray(new String[0])); |
| | | // push to the web |
| | | // Collection<ConcurrentWebSocketSession> sessions = webSocketManageService.getValueWithWorkspaceAndUserType( |
| | | // device.getWorkspaceId(), UserTypeEnum.WEB.getVal()); |
| | |
| | | |
| | | if(deviceDTO.getDomain() == DeviceDomainEnum.DOCK.getVal()) { |
| | | dto.setHmsKey(HmsEnum.HmsFaqIdEnum.DOCK_TIP.getText() + receiver.getCode()); |
| | | log.info("SN:{}的Hms匹配拼接规则值为:{}",deviceDTO.getDeviceSn(), HmsEnum.HmsFaqIdEnum.DOCK_TIP.getText() + receiver.getCode()); |
| | | // log.info("SN:{}的Hms匹配拼接规则值为:{}",deviceDTO.getDeviceSn(), HmsEnum.HmsFaqIdEnum.DOCK_TIP.getText() + receiver.getCode()); |
| | | return; |
| | | } |
| | | // if (HmsEnum.DomainType.DRONE_NEST.getDomain().equals(receiver.getDomainType())) { |
| | |
| | | key.append(HmsEnum.IN_THE_SKY.getText()); |
| | | } |
| | | dto.setHmsKey(key.toString()); |
| | | log.info("SN:{}的Hms匹配拼接规则值为:{}",deviceDTO.getDeviceSn(), key.toString()); |
| | | // log.info("SN:{}的Hms匹配拼接规则值为:{}",deviceDTO.getDeviceSn(), key.toString()); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 按条件查询返回最新的一条数据 |
| | | * */ |
| | | public DeviceHmsEntity getDeviceHmsEntity(DeviceHmsEntity deviceHmsEntity) { |
| | | List <DeviceHmsEntity> lstHms = mapper.selectList(new LambdaQueryWrapper<DeviceHmsEntity>() |
| | | .eq(DeviceHmsEntity::getHmsKey, deviceHmsEntity.getHmsKey()) |
| | | .eq(DeviceHmsEntity::getSn, deviceHmsEntity.getSn()) |
| | | .eq(DeviceHmsEntity::getUpdateTime,0) |
| | | .orderByDesc(DeviceHmsEntity::getCreateTime) |
| | | ); |
| | | |
| | | return lstHms.isEmpty() ? null : lstHms.get(0); |
| | | } |
| | | } |