| | |
| | | import com.ard.device.camera.domain.ArdCamera; |
| | | import com.ard.device.camera.service.IArdCameraService; |
| | | import com.ard.device.channel.domain.ArdChannel; |
| | | import com.ard.sample.component.websocket.enums.MessageType; |
| | | import com.ard.sample.component.websocket.handler.DockWebSocketHandler; |
| | | import com.ard.sample.component.websocket.handler.LiveStreamHandler; |
| | | import com.ard.system.authorize.service.AuthorizeService; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | |
| | | import com.fasterxml.jackson.databind.JsonNode; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.poi.ss.formula.functions.T; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Qualifier; |
| | | import org.springframework.integration.annotation.ServiceActivator; |
| | | import org.springframework.integration.mqtt.support.MqttHeaders; |
| | | import org.springframework.messaging.Message; |
| | | import org.springframework.messaging.MessageHeaders; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | |
| | | import java.time.ZoneId; |
| | | import java.util.*; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.ard.sample.component.mqtt.model.TopicConst.*; |
| | |
| | | @Slf4j |
| | | @Transactional |
| | | public class DeviceServiceImpl implements IDeviceService { |
| | | |
| | | @Autowired |
| | | private DockWebSocketHandler _dockWebSocketHandler; |
| | | |
| | | @Autowired |
| | | private LiveStreamHandler _liveStreamHandler; |
| | |
| | | for(ArdChannel ardChannel : ardCamera1.getChannelList()) { |
| | | if(ardChannel.getChanNo() == 1) { |
| | | // 修改列表中外接相机地址 |
| | | updateCameraWebrtcUrl(devices.getDeviceSn(), ardChannel.getArdVtdu().getWebrtcUrl()); |
| | | updateCameraWebrtcUrl(devices.getDeviceSn(), ardChannel.getArdVtdu().getWebrtcUrl(), ardCamera1.getState()); |
| | | } |
| | | } |
| | | } |
| | |
| | | .workType(entity.getWorkType()) |
| | | .webrtcUrl(entity.getWebrtcUrl()) |
| | | .cameraWebrtcUrl(entity.getCameraWebrtcUrl()) |
| | | .cameraState(entity.getCameraState()) |
| | | .workspaceName(entity.getDeptId() != null |
| | | ? Optional.ofNullable(sysDeptService.selectDeptById(entity.getDeptId())) |
| | | .map(SysDept::getDeptName) |
| | |
| | | return update > 0; |
| | | } |
| | | |
| | | public Boolean updateCameraWebrtcUrl(String sn, String CameraWebrtcUrl){ |
| | | public Boolean updateCameraWebrtcUrl(String sn, String CameraWebrtcUrl, String state){ |
| | | LambdaUpdateWrapper<DeviceEntity> lambdaUpdateWrapper = new LambdaUpdateWrapper<>(); |
| | | lambdaUpdateWrapper.eq(DeviceEntity::getDeviceSn, sn) |
| | | .set(DeviceEntity::getCameraWebrtcUrl, CameraWebrtcUrl); |
| | | .set(DeviceEntity::getCameraWebrtcUrl, CameraWebrtcUrl) |
| | | .set(DeviceEntity::getCameraState, state); |
| | | |
| | | int update = mapper.update(null, lambdaUpdateWrapper); |
| | | return update > 0; |
| | | } |
| | |
| | | .workType(dto.getWorkType()) |
| | | .webrtcUrl(dto.getWebrtcUrl()) |
| | | .cameraWebrtcUrl(dto.getCameraWebrtcUrl()) |
| | | .cameraState(dto.getCameraState()) |
| | | .compatibleStatus(dto.getFirmwareStatus() == null ? null : |
| | | DeviceFirmwareStatusEnum.CONSISTENT_UPGRADE != DeviceFirmwareStatusEnum.find(dto.getFirmwareStatus())) |
| | | .build(); |
| | |
| | | messageSender.publish(topic, builder.build()); |
| | | } |
| | | |
| | | // @DataScopePlus(deptAlias="d") |
| | | // @Override |
| | | // public List<DeviceEntity> selectList(Wrapper<DeviceEntity> queryWrapper) { |
| | | // return mapper.selectList(queryWrapper); |
| | | // } |
| | | /** |
| | | * 定时任务,每秒钟从redis中读取信息发送机场摄像头(舱内舱外)、飞行器摄像头模式(广角、变焦、红外) |
| | | * */ |
| | | @Override |
| | | @Scheduled(initialDelay = 5, fixedRate = 1, timeUnit = TimeUnit.SECONDS) |
| | | public void sendCameraInfo() { |
| | | // 此方法修改为定时任务,每秒钟从redis中读取信息发送 |
| | | // 发送机场摄像头位置信息 |
| | | Map<Object, Object> map = RedisOpsUtils.getAllData(RedisConst.COVER_STATE_PREFIX+"*"); |
| | | map.forEach((k, v) -> { |
| | | _dockWebSocketHandler.broadcastMessageToAllClients(v.toString()); |
| | | }); |
| | | } |
| | | |
| | | // 机场直播摄像头信息存redis中,舱内、舱外 |
| | | @Override |
| | | public void setRedisCameraPosition(String sn, Integer cameraPosition) { |
| | | String liveStatus = ""; |
| | | Optional<DeviceDTO> device = getDeviceBySn(sn); |
| | | if(device.get().getDomain().equals(DeviceDomainEnum.DOCK.getVal())){ |
| | | CommonTopicReceiver<Map<String,Integer>> stateReceiver = new CommonTopicReceiver<>(); |
| | | stateReceiver.setTid(UUID.randomUUID().toString()); |
| | | stateReceiver.setBid(UUID.randomUUID().toString()); |
| | | stateReceiver.setType(MessageType.LIVESTREAM.getType()); |
| | | stateReceiver.setGateway(sn); |
| | | stateReceiver.setTimestamp(System.currentTimeMillis()); |
| | | Map<String,Integer> live_status = new HashMap<>(); |
| | | live_status.put("camera_position", cameraPosition); |
| | | stateReceiver.setData(live_status); |
| | | try{ |
| | | liveStatus=objectMapper.writeValueAsString(stateReceiver); |
| | | } |
| | | catch (Exception e){ |
| | | log.error("机场直播设备状态反馈转换异常:{}",e); |
| | | } |
| | | } |
| | | log.info("机场直播设备状态反馈存入redis中,key值:{}中:{}",RedisConst.COVER_STATE_PREFIX,liveStatus); |
| | | RedisOpsUtils.set(RedisConst.COVER_STATE_PREFIX + sn, liveStatus); |
| | | } |
| | | |
| | | public void setChildRedisCamera(String sn, String context){ |
| | | // 保存子设备信息到redis中,便于前端获取 |
| | | RedisOpsUtils.set(RedisConst.COVER_STATE_PREFIX + sn, context); |
| | | } |
| | | } |