guns-admin/src/main/java/com/stylefeng/guns/modular/api/PatrolTaskController.java
@@ -198,8 +198,13 @@ @PostMapping("/manualAudit") @ApiOperation(value = "人工审核视频通道数据", tags = {"任务记录"}) public ResultUtil manualAudit(@RequestBody ManualAuditVo vo){ return taskDetailService.manualAudit(vo); public ResultUtil manualAudit(@RequestBody ManualAuditVo vo, HttpServletRequest request){ String token = request.getHeader(JwtConstants.AUTH_HEADER); if (token != null && token.startsWith("Bearer ")) { token = token.substring(token.indexOf(" ") + 1); } String userId = JwtTokenUtil.getPrivateClaimFromToken(token, "userId"); return taskDetailService.manualAudit(vo, userId); } guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/TaskDetailMapper.xml
@@ -89,5 +89,6 @@ <if test="null != status"> and b.status = #{status} </if> order by b.execution_time desc </select> </mapper> guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/ITaskDetailService.java
@@ -67,7 +67,7 @@ * 人工审核 * @return */ ResultUtil manualAudit(ManualAuditVo vo); ResultUtil manualAudit(ManualAuditVo vo, String userId); /** guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/PatrolTaskServiceImpl.java
@@ -38,9 +38,12 @@ import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.CountDownLatch; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; /** * @author zhibing.pu @@ -183,8 +186,18 @@ //获取当前任务中的车船信息 List<TaskDetailVehicles> taskDetailVehicles = taskDetailVehiclesService.selectList(new EntityWrapper<TaskDetailVehicles>().eq("task_detail_id", id)); int errNum = 0; for (TaskDetailVehicles taskDetailVehicle : taskDetailVehicles) { //根据企业id分组用于定义多线上处理 Set<String> collect = taskDetailVehicles.stream().map(TaskDetailVehicles::getCompanyId).collect(Collectors.toSet()); //定义线程池 ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(collect.size(), collect.size(), 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); //定义多线程阻塞 CountDownLatch countDownLatch = new CountDownLatch(collect.size()); for (String companyId : collect) { List<TaskDetailVehicles> vehicles = taskDetailVehicles.stream().filter(s -> s.getCompanyId().equals(companyId)).collect(Collectors.toList()); threadPoolExecutor.execute(new Runnable() { @Override public void run() { for (TaskDetailVehicles taskDetailVehicle : vehicles) { try { taskDetailVehicle.setStartExecutionTime(LocalDateTime.now()); Integer taskDetailVehicleId = taskDetailVehicle.getId(); @@ -234,7 +247,7 @@ String fileId = VideoGateway.cameraShot2018(terminalId, videoChannel, 0); if(null == fileId){ log.error("2018年协议发送拍摄指令失败:terminalId-->{},videoChannel-->{}", terminalId, videoChannel); throw new RuntimeException(); throw new RuntimeException("2018年协议发送拍摄指令失败:terminalId-->" + terminalId + ",videoChannel-->" + videoChannel); }else{ //等待15秒 Thread.sleep(30000); @@ -246,7 +259,7 @@ fileId = VideoGateway.cameraShot2018(terminalId, videoChannel, 0); if(null == fileId){ log.error("2018年协议发送拍摄指令失败:terminalId-->{},videoChannel-->{}", terminalId, videoChannel); throw new Exception(); throw new RuntimeException("2018年协议发送拍摄指令失败:terminalId-->" + terminalId + ",videoChannel-->" + videoChannel); }else{ //等待15秒 Thread.sleep(30000); @@ -254,7 +267,7 @@ fileUrl = VideoGateway.getCameraShotByFileId2018(terminalId, fileId, 0); if(null == fileUrl){ log.error("2018年协议车辆获取拍摄图片失败:terminalId-->{},fileId-->{}", terminalId, fileId); throw new Exception(); throw new RuntimeException("2018年协议车辆获取拍摄图片失败:terminalId-->" + terminalId + ",fileId-->" + fileId); }else{ taskDetailVehiclesChannel.setImageUrl(fileUrl); taskDetailVehiclesChannel.setSysCreateTime(LocalDateTime.now()); @@ -286,7 +299,7 @@ String fileId = VideoGateway.cameraShot2023(vehicleId, vehicleType, terminalId, videoChannel, 0); if(null == fileId){ log.error("2023年协议发送拍摄指令失败:terminalId-->{},videoChannel-->{}", terminalId, videoChannel); throw new Exception(); throw new RuntimeException("2023年协议发送拍摄指令失败:terminalId-->" + terminalId + ",videoChannel-->" + videoChannel); }else{ //等待15秒 Thread.sleep(30000); @@ -298,7 +311,7 @@ fileId = VideoGateway.cameraShot2023(vehicleId, vehicleType, terminalId, videoChannel, 0); if(null == fileId){ log.error("2023年协议发送拍摄指令失败:terminalId-->{},videoChannel-->{}", terminalId, videoChannel); throw new Exception(); throw new RuntimeException("2023年协议发送拍摄指令失败:terminalId-->" + terminalId + ",videoChannel-->" + videoChannel); }else{ //等待15秒 Thread.sleep(30000); @@ -306,7 +319,7 @@ fileUrl = VideoGateway.getCameraShotByFileId2023(fileId, 0); if(null == fileUrl){ log.error("2023年协议车辆获取拍摄图片失败:terminalId-->{},fileId-->{}", terminalId, fileId); throw new Exception(); throw new RuntimeException("2023年协议车辆获取拍摄图片失败:terminalId-->" + terminalId + ",fileId-->" + fileId); }else{ taskDetailVehiclesChannel.setImageUrl(fileUrl); taskDetailVehiclesChannel.setSysCreateTime(LocalDateTime.now()); @@ -344,11 +357,22 @@ taskDetailVehicle.setEndExecutionTime(LocalDateTime.now()); taskDetailVehicle.setStatus(5); taskDetailVehiclesService.updateById(taskDetailVehicle); errNum++; } } taskDetail.setStatus(0 == errNum ? 3 : 4); //当前线程执行完成后减少等待数 countDownLatch.countDown(); } }); } try { countDownLatch.await(); } catch (InterruptedException e) { throw new RuntimeException(e); } int count = taskDetailVehiclesService.selectCount(new EntityWrapper<TaskDetailVehicles>().eq("task_detail_id", id).eq("status", 5)); taskDetail.setStatus(count > 0 ? 4 : 3); taskDetailService.updateById(taskDetail); } guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/TaskDetailServiceImpl.java
@@ -36,6 +36,7 @@ import java.net.URLConnection; import java.net.URLEncoder; import java.text.SimpleDateFormat; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.*; import java.util.stream.Collectors; @@ -162,16 +163,18 @@ if(null != vo.getSysStatus()){ List<TaskDetailVehiclesChannel> sys_status = taskDetailVehiclesChannelService.selectList(new EntityWrapper<TaskDetailVehiclesChannel>().eq("sys_status", vo.getSysStatus())); List<Integer> collect = sys_status.stream().map(TaskDetailVehiclesChannel::getTaskDetailVehiclesId).collect(Collectors.toList()); if(collect.size() > 0){ wrapper.in("id", collect); if(collect.size() == 0){ collect.add(-1); } wrapper.in("id", collect); } if(null != vo.getArtificialStatus()){ List<TaskDetailVehiclesChannel> sys_status = taskDetailVehiclesChannelService.selectList(new EntityWrapper<TaskDetailVehiclesChannel>().eq("artificial_status", vo.getArtificialStatus())); List<Integer> collect = sys_status.stream().map(TaskDetailVehiclesChannel::getTaskDetailVehiclesId).collect(Collectors.toList()); if(collect.size() > 0){ wrapper.in("id", collect); if(collect.size() == 0){ collect.add(-1); } wrapper.in("id", collect); } List<TaskDetailVehicles> taskDetailVehiclesList = taskDetailVehiclesService.selectList(wrapper); @@ -237,7 +240,7 @@ * @return */ @Override public ResultUtil manualAudit(ManualAuditVo vo) { public ResultUtil manualAudit(ManualAuditVo vo, String userId) { List<TaskDetailVehiclesChannel> taskDetailVehiclesChannels = taskDetailVehiclesChannelService.selectBatchIds(vo.getId()); for (TaskDetailVehiclesChannel taskDetailVehiclesChannel : taskDetailVehiclesChannels) { if(null != taskDetailVehiclesChannel.getArtificialStatus() && 1 != taskDetailVehiclesChannel.getArtificialStatus()){ @@ -245,6 +248,8 @@ } taskDetailVehiclesChannel.setArtificialStatus(vo.getStatus()); taskDetailVehiclesChannel.setRemark(vo.getRemark()); taskDetailVehiclesChannel.setArtificialCreateTime(LocalDateTime.now()); taskDetailVehiclesChannel.setArtificialUserId(Integer.valueOf(userId)); taskDetailVehiclesChannelService.updateById(taskDetailVehiclesChannel); } return ResultUtil.success(); guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/videoGateway/VideoGateway.java
@@ -501,8 +501,8 @@ // locationRealTimeInfoCache(0); List<Vehicle> 粤AFX998 = VideoGateway.getVehicleList("粤AFX998", null, null, 0); System.err.println(粤AFX998); List<VehicleOnline> vehicleOnlines = queryRuntimeInfoByCache(0); System.err.println(vehicleOnlines); } // public static void main(String[] args) {