| | |
| | | import com.dji.sample.manage.model.dto.DeviceDictionaryDTO; |
| | | import com.dji.sample.manage.model.dto.DevicePayloadDTO; |
| | | import com.dji.sample.manage.model.entity.DevicePayloadEntity; |
| | | import com.dji.sample.manage.model.enums.DeviceDomainEnum; |
| | | import com.dji.sample.manage.model.receiver.DevicePayloadReceiver; |
| | | import com.dji.sample.manage.model.receiver.FirmwareVersionReceiver; |
| | | import com.dji.sample.manage.service.ICapacityCameraService; |
| | |
| | | @Autowired |
| | | private ICapacityCameraService capacityCameraService; |
| | | |
| | | @Autowired |
| | | private RedisOpsUtils redisOps; |
| | | |
| | | @Override |
| | | public Integer checkPayloadExist(String payloadSn) { |
| | | DevicePayloadEntity devicePayload = mapper.selectOne( |
| | |
| | | |
| | | String deviceSn = payloadReceiverList.get(0).getDeviceSn(); |
| | | String key = RedisConst.DEVICE_ONLINE_PREFIX + deviceSn; |
| | | DeviceDTO device = (DeviceDTO) redisOps.get(key); |
| | | DeviceDTO device = (DeviceDTO) RedisOpsUtils.get(key); |
| | | List<DevicePayloadDTO> payloads = new ArrayList<>(); |
| | | |
| | | for (DevicePayloadReceiver payloadReceiver : payloadReceiverList) { |
| | |
| | | payloads = this.getDevicePayloadEntitiesByDeviceSn(deviceSn); |
| | | } |
| | | device.setPayloadsList(payloads); |
| | | redisOps.setWithExpire(RedisConst.DEVICE_ONLINE_PREFIX + device.getDeviceSn(), device, RedisConst.DEVICE_ALIVE_SECOND); |
| | | RedisOpsUtils.setWithExpire(RedisConst.DEVICE_ONLINE_PREFIX + device.getDeviceSn(), device, RedisConst.DEVICE_ALIVE_SECOND); |
| | | return true; |
| | | } |
| | | |
| | |
| | | String deviceSn = payloadReceiverList.stream().findAny().get().getDeviceSn(); |
| | | String key = RedisConst.STATE_PAYLOAD_PREFIX + deviceSn; |
| | | // Solve timing problems |
| | | long last = (long) Objects.requireNonNullElse(redisOps.get(key), 0L); |
| | | long last = (long) Objects.requireNonNullElse(RedisOpsUtils.get(key), 0L); |
| | | if (last > timestamp) { |
| | | return; |
| | | } |
| | |
| | | // Save the new payload information. |
| | | boolean isSave = this.savePayloadDTOs(needToSave); |
| | | if (isSave) { |
| | | redisOps.setWithExpire(key, timestamp, RedisConst.DEVICE_ALIVE_SECOND); |
| | | RedisOpsUtils.setWithExpire(key, timestamp, RedisConst.DEVICE_ALIVE_SECOND); |
| | | } |
| | | log.debug("The result of saving the payloads is {}.", isSave); |
| | | } |
| | |
| | | |
| | | if (arr.length == 3) { |
| | | Optional<DeviceDictionaryDTO> dictionaryOpt = dictionaryService |
| | | .getOneDictionaryInfoByTypeSubType(arr[0], arr[1]); |
| | | .getOneDictionaryInfoByTypeSubType(DeviceDomainEnum.PAYLOAD.getVal(), arr[0], arr[1]); |
| | | dictionaryOpt.ifPresent(dictionary -> |
| | | builder.payloadName(dictionary.getDeviceName()) |
| | | .payloadDesc(dictionary.getDeviceDesc())); |