From 836df57f8158c86d0e4825b07cf745faa27d7389 Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期二, 21 一月 2025 11:35:17 +0800 Subject: [PATCH] 修改bug --- guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/PatrolTaskServiceImpl.java | 156 +++++++++++++++------------------------------------ 1 files changed, 47 insertions(+), 109 deletions(-) diff --git a/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/PatrolTaskServiceImpl.java b/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/PatrolTaskServiceImpl.java index d50f66b..9fda054 100644 --- a/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/PatrolTaskServiceImpl.java +++ b/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/PatrolTaskServiceImpl.java @@ -2,6 +2,7 @@ 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; @@ -35,10 +36,7 @@ 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; @@ -133,6 +131,7 @@ //添加任务车船视频通道关系数据 List<Integer> videoChannel = vo.getVideoChannel(); + List<TaskDetailVehiclesChannel> list = new ArrayList<>(); for (Integer s : videoChannel) { TaskDetailVehiclesChannel taskDetailVehiclesChannel = new TaskDetailVehiclesChannel(); taskDetailVehiclesChannel.setPatrolTaskId(patrolTask.getId()); @@ -140,8 +139,9 @@ taskDetailVehiclesChannel.setTaskDetailVehiclesId(taskDetailVehicles.getId()); taskDetailVehiclesChannel.setVideoChannel(s); taskDetailVehiclesChannel.setSysStatus(1); - taskDetailVehiclesChannelService.insert(taskDetailVehiclesChannel); + list.add(taskDetailVehiclesChannel); } + taskDetailVehiclesChannelService.insertBatch(list); } //添加定时任务 @@ -241,111 +241,51 @@ String terminalId = vehicleOnline1.getTerminalId(); for (TaskDetailVehiclesChannel taskDetailVehiclesChannel : taskDetailVehiclesChannels) { Integer videoChannel = taskDetailVehiclesChannel.getVideoChannel(); - - 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秒 - 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); - } + try { + if("1".equals(vehicleGpsProtocol)){ + //2018 协议 + String fileId = VideoGateway.cameraShot2018(terminalId, videoChannel, 0); + if(ToolUtil.isNotEmpty(fileId)){ + //等待30秒 + Thread.sleep(30000); + String fileUrl = VideoGateway.getCameraShotByFileId2018(terminalId, fileId, 0); + if(ToolUtil.isNotEmpty(fileUrl)){ + 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{ - 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{ + //2023 协议 + String fileId = VideoGateway.cameraShot2023(vehicleId, vehicleType, terminalId, videoChannel, 0); + if(ToolUtil.isNotEmpty(fileId)){ + //等待30秒 + Thread.sleep(30000); + String fileUrl = VideoGateway.getCameraShotByFileId2023(fileId, 0); + if(ToolUtil.isNotEmpty(fileUrl)){ + 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{ - //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秒 - 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{ - 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{ - 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); - } - } + }catch (Exception e){ + taskDetailVehiclesChannel.setResult(e.getMessage()); + taskDetailVehiclesChannelService.updateById(taskDetailVehiclesChannel); } } taskDetailVehicle.setEndExecutionTime(LocalDateTime.now()); @@ -359,8 +299,6 @@ taskDetailVehiclesService.updateById(taskDetailVehicle); } } - - //当前线程执行完成后减少等待数 countDownLatch.countDown(); } -- Gitblit v1.7.1