| | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.system.model.PatrolTask; |
| | | import com.stylefeng.guns.modular.system.model.TaskDetail; |
| | | import com.stylefeng.guns.modular.system.model.TaskDetailVehicles; |
| | |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.*; |
| | | import java.util.concurrent.CountDownLatch; |
| | | import java.util.concurrent.LinkedBlockingQueue; |
| | | import java.util.concurrent.ThreadPoolExecutor; |
| | |
| | | |
| | | //添加任务车船视频通道关系数据 |
| | | List<Integer> videoChannel = vo.getVideoChannel(); |
| | | List<TaskDetailVehiclesChannel> list = new ArrayList<>(); |
| | | for (Integer s : videoChannel) { |
| | | TaskDetailVehiclesChannel taskDetailVehiclesChannel = new TaskDetailVehiclesChannel(); |
| | | taskDetailVehiclesChannel.setPatrolTaskId(patrolTask.getId()); |
| | |
| | | taskDetailVehiclesChannel.setTaskDetailVehiclesId(taskDetailVehicles.getId()); |
| | | taskDetailVehiclesChannel.setVideoChannel(s); |
| | | taskDetailVehiclesChannel.setSysStatus(1); |
| | | taskDetailVehiclesChannelService.insert(taskDetailVehiclesChannel); |
| | | list.add(taskDetailVehiclesChannel); |
| | | } |
| | | taskDetailVehiclesChannelService.insertBatch(list); |
| | | } |
| | | |
| | | //添加定时任务 |
| | |
| | | String terminalId = vehicleOnline1.getTerminalId(); |
| | | for (TaskDetailVehiclesChannel taskDetailVehiclesChannel : taskDetailVehiclesChannels) { |
| | | Integer videoChannel = taskDetailVehiclesChannel.getVideoChannel(); |
| | | |
| | | try { |
| | | if("1".equals(vehicleGpsProtocol)){ |
| | | //2018 协议 |
| | | String fileId = VideoGateway.cameraShot2018(terminalId, videoChannel, 0); |
| | | if(null == fileId){ |
| | | log.error("2018年协议发送拍摄指令失败:terminalId-->{},videoChannel-->{}", terminalId, videoChannel); |
| | | throw new RuntimeException("2018年协议发送拍摄指令失败:terminalId-->" + terminalId + ",videoChannel-->" + videoChannel); |
| | | }else{ |
| | | //等待15秒 |
| | | if(ToolUtil.isNotEmpty(fileId)){ |
| | | //等待30秒 |
| | | Thread.sleep(30000); |
| | | |
| | | String fileUrl = VideoGateway.getCameraShotByFileId2018(terminalId, fileId, 0); |
| | | if(null == fileUrl){ |
| | | log.error("2018年协议车辆获取拍摄图片失败:terminalId-->{},fileId-->{}", terminalId, fileId); |
| | | //重新发送拍摄指令,如果还是没有获取到图片,标注失败 |
| | | fileId = VideoGateway.cameraShot2018(terminalId, videoChannel, 0); |
| | | if(null == fileId){ |
| | | log.error("2018年协议发送拍摄指令失败:terminalId-->{},videoChannel-->{}", terminalId, videoChannel); |
| | | throw new RuntimeException("2018年协议发送拍摄指令失败:terminalId-->" + terminalId + ",videoChannel-->" + videoChannel); |
| | | }else{ |
| | | //等待15秒 |
| | | Thread.sleep(30000); |
| | | |
| | | fileUrl = VideoGateway.getCameraShotByFileId2018(terminalId, fileId, 0); |
| | | if(null == fileUrl){ |
| | | log.error("2018年协议车辆获取拍摄图片失败:terminalId-->{},fileId-->{}", terminalId, fileId); |
| | | throw new RuntimeException("2018年协议车辆获取拍摄图片失败:terminalId-->" + terminalId + ",fileId-->" + fileId); |
| | | }else{ |
| | | taskDetailVehiclesChannel.setImageUrl(fileUrl); |
| | | taskDetailVehiclesChannel.setSysCreateTime(LocalDateTime.now()); |
| | | taskDetailVehiclesChannel.setArtificialStatus(1); |
| | | //开始调模型接口得出结果 |
| | | Map<String, Object> map = ImageModelUtil.modelCheck(fileUrl, ImageModelEnum.getImageModelEnum(patrolTask.getImageModel())); |
| | | Boolean b = (Boolean) map.get("b"); |
| | | String r = map.get("r").toString(); |
| | | taskDetailVehiclesChannel.setSysStatus(b ? 2 : 3); |
| | | taskDetailVehiclesChannel.setResult(r); |
| | | taskDetailVehiclesChannelService.updateById(taskDetailVehiclesChannel); |
| | | } |
| | | } |
| | | }else{ |
| | | if(ToolUtil.isNotEmpty(fileUrl)){ |
| | | taskDetailVehiclesChannel.setImageUrl(fileUrl); |
| | | taskDetailVehiclesChannel.setSysCreateTime(LocalDateTime.now()); |
| | | taskDetailVehiclesChannel.setArtificialStatus(1); |
| | |
| | | }else{ |
| | | //2023 协议 |
| | | String fileId = VideoGateway.cameraShot2023(vehicleId, vehicleType, terminalId, videoChannel, 0); |
| | | if(null == fileId){ |
| | | log.error("2023年协议发送拍摄指令失败:terminalId-->{},videoChannel-->{}", terminalId, videoChannel); |
| | | throw new RuntimeException("2023年协议发送拍摄指令失败:terminalId-->" + terminalId + ",videoChannel-->" + videoChannel); |
| | | }else{ |
| | | //等待15秒 |
| | | if(ToolUtil.isNotEmpty(fileId)){ |
| | | //等待30秒 |
| | | Thread.sleep(30000); |
| | | |
| | | String fileUrl = VideoGateway.getCameraShotByFileId2023(fileId, 0); |
| | | if(null == fileUrl){ |
| | | log.error("2023年协议车辆获取拍摄图片失败:terminalId-->{},fileId-->{}", terminalId, fileId); |
| | | //重新发送拍摄指令,如果还是没有获取图片,标注异常 |
| | | fileId = VideoGateway.cameraShot2023(vehicleId, vehicleType, terminalId, videoChannel, 0); |
| | | if(null == fileId){ |
| | | log.error("2023年协议发送拍摄指令失败:terminalId-->{},videoChannel-->{}", terminalId, videoChannel); |
| | | throw new RuntimeException("2023年协议发送拍摄指令失败:terminalId-->" + terminalId + ",videoChannel-->" + videoChannel); |
| | | }else{ |
| | | //等待15秒 |
| | | Thread.sleep(30000); |
| | | |
| | | fileUrl = VideoGateway.getCameraShotByFileId2023(fileId, 0); |
| | | if(null == fileUrl){ |
| | | log.error("2023年协议车辆获取拍摄图片失败:terminalId-->{},fileId-->{}", terminalId, fileId); |
| | | throw new RuntimeException("2023年协议车辆获取拍摄图片失败:terminalId-->" + terminalId + ",fileId-->" + fileId); |
| | | }else{ |
| | | if(ToolUtil.isNotEmpty(fileUrl)){ |
| | | taskDetailVehiclesChannel.setImageUrl(fileUrl); |
| | | taskDetailVehiclesChannel.setSysCreateTime(LocalDateTime.now()); |
| | | taskDetailVehiclesChannel.setArtificialStatus(1); |
| | |
| | | taskDetailVehiclesChannelService.updateById(taskDetailVehiclesChannel); |
| | | } |
| | | } |
| | | }else{ |
| | | taskDetailVehiclesChannel.setImageUrl(fileUrl); |
| | | taskDetailVehiclesChannel.setSysCreateTime(LocalDateTime.now()); |
| | | taskDetailVehiclesChannel.setArtificialStatus(1); |
| | | //开始调模型接口得出结果 |
| | | Map<String, Object> map = ImageModelUtil.modelCheck(fileUrl, ImageModelEnum.getImageModelEnum(patrolTask.getImageModel())); |
| | | Boolean b = (Boolean) map.get("b"); |
| | | String r = map.get("r").toString(); |
| | | taskDetailVehiclesChannel.setSysStatus(b ? 2 : 3); |
| | | taskDetailVehiclesChannel.setResult(r); |
| | | } |
| | | }catch (Exception e){ |
| | | taskDetailVehiclesChannel.setResult(e.getMessage()); |
| | | taskDetailVehiclesChannelService.updateById(taskDetailVehiclesChannel); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | taskDetailVehicle.setEndExecutionTime(LocalDateTime.now()); |
| | |
| | | taskDetailVehiclesService.updateById(taskDetailVehicle); |
| | | } |
| | | } |
| | | |
| | | |
| | | //当前线程执行完成后减少等待数 |
| | | countDownLatch.countDown(); |
| | | } |