From 75499090564614ed79f31a61c2434699882ee29d Mon Sep 17 00:00:00 2001 From: ‘liusuyi’ <1951119284@qq.com> Date: 星期五, 02 六月 2023 17:31:14 +0800 Subject: [PATCH] 优化 --- ard-work/src/main/java/com/ruoyi/inspect/service/IArdVideoInspectTaskService.java | 5 ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/PatrolInspectionTask.java | 264 ----------------------------- ruoyi-admin/pom.xml | 20 ++ ard-work/src/main/java/com/ruoyi/inspect/controller/TaskController.java | 19 + ard-work/src/main/java/com/ruoyi/inspect/service/impl/ArdVideoInspectTaskServiceImpl.java | 209 +++++++++++++++------- ruoyi-admin/Dockerfile | 7 6 files changed, 185 insertions(+), 339 deletions(-) diff --git a/ard-work/src/main/java/com/ruoyi/inspect/controller/TaskController.java b/ard-work/src/main/java/com/ruoyi/inspect/controller/TaskController.java index 5fb815a..c3ab320 100644 --- a/ard-work/src/main/java/com/ruoyi/inspect/controller/TaskController.java +++ b/ard-work/src/main/java/com/ruoyi/inspect/controller/TaskController.java @@ -2,6 +2,7 @@ import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.inspect.service.IArdVideoInspectTaskService; import com.ruoyi.inspect.service.impl.InspectionTaskManager; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -26,14 +27,24 @@ public class TaskController { @Autowired private InspectionTaskManager inspectionTaskManager; - + @Autowired + IArdVideoInspectTaskService ardVideoInspectTaskService; @PreAuthorize("@ss.hasPermi('inspect:control:manual')") @GetMapping("/startTask/{taskId}") @ApiOperation("鎵嬪姩寮�鍚贰妫�") AjaxResult startTask(@PathVariable String taskId) { - // 寮�鍚贰妫�浠诲姟 - inspectionTaskManager.startInspectionTask(taskId); - return AjaxResult.success(); + boolean enablemanualTask = ardVideoInspectTaskService.isEnablemanualTask(taskId); + if (enablemanualTask) + { + // 寮�鍚贰妫�浠诲姟 + inspectionTaskManager.startInspectionTask(taskId); + return AjaxResult.success(); + } + else + { + return AjaxResult.error(); + } + } @PreAuthorize("@ss.hasPermi('inspect:control:manual')") diff --git a/ard-work/src/main/java/com/ruoyi/inspect/service/IArdVideoInspectTaskService.java b/ard-work/src/main/java/com/ruoyi/inspect/service/IArdVideoInspectTaskService.java index 6cf5539..ba1fe73 100644 --- a/ard-work/src/main/java/com/ruoyi/inspect/service/IArdVideoInspectTaskService.java +++ b/ard-work/src/main/java/com/ruoyi/inspect/service/IArdVideoInspectTaskService.java @@ -77,7 +77,10 @@ * 鎵嬪姩宸℃浠诲姟 */ public void manualTaskRun(String TaskId); - + /** + * 鍒ゆ柇褰撳墠鐩告満鑳藉惁寮�鍚墜鍔� + */ + public boolean isEnablemanualTask(String TaskId); /** * 宸℃浠诲姟 */ diff --git a/ard-work/src/main/java/com/ruoyi/inspect/service/impl/ArdVideoInspectTaskServiceImpl.java b/ard-work/src/main/java/com/ruoyi/inspect/service/impl/ArdVideoInspectTaskServiceImpl.java index 3f1c570..b9329bb 100644 --- a/ard-work/src/main/java/com/ruoyi/inspect/service/impl/ArdVideoInspectTaskServiceImpl.java +++ b/ard-work/src/main/java/com/ruoyi/inspect/service/impl/ArdVideoInspectTaskServiceImpl.java @@ -2,6 +2,7 @@ import java.text.SimpleDateFormat; import java.util.*; + import com.ruoyi.alarmpoints.well.domain.ArdAlarmpointsWell; import com.ruoyi.alarmpoints.well.mapper.ArdAlarmpointsWellMapper; import com.ruoyi.common.utils.DateUtils; @@ -46,19 +47,17 @@ private IHikClientService hikClientService; @PostConstruct - public void initTask() - { + public void initTask() { List<ArdVideoInspectTask> ardVideoInspectTasks = ardVideoInspectTaskMapper.selectArdVideoInspectTaskList(new ArdVideoInspectTask()); /*鍚姩鍚庡皢鎵�鏈夋墜鍔ㄤ换鍔$疆涓哄叧闂�*/ - for(ArdVideoInspectTask ardVideoInspectTask:ardVideoInspectTasks) - { - if(ardVideoInspectTask.getInspectMode().equals("鎵嬪姩")) - { + for (ArdVideoInspectTask ardVideoInspectTask : ardVideoInspectTasks) { + if (ardVideoInspectTask.getInspectMode().equals("鎵嬪姩")) { ardVideoInspectTask.setMenualSwitch("鍏�"); ardVideoInspectTaskMapper.updateArdVideoInspectTask(ardVideoInspectTask); } } } + /** * 鏌ヨ瑙嗛宸℃浠诲姟 * @@ -184,35 +183,75 @@ */ @Override public void manualTaskRun(String TaskId) { - ArdVideoInspectTask videoInspectTask = ardVideoInspectTaskMapper.selectArdVideoInspectTaskById(TaskId); - if (videoInspectTask.getArdVideoInspectTaskStepList().size() == 0) { - return; - } - String currentStepId = videoInspectTask.getCurrentStepId(); - String currentStepStartTime = videoInspectTask.getCurrentStepStartTime(); - if (StringUtils.isNull(currentStepId)||StringUtils.isEmpty(currentStepId)) { - //浠�1鍙锋楠ゅ紑濮� - videoInspectTask.setCurrentStepId(videoInspectTask.getArdVideoInspectTaskStepList().get(0).getId()); - if(InspectionTaskManager.taskMap.containsKey(TaskId)) { - startRunStep(videoInspectTask); + try { + ArdVideoInspectTask videoInspectTask = ardVideoInspectTaskMapper.selectArdVideoInspectTaskById(TaskId); + if (videoInspectTask.getArdVideoInspectTaskStepList().size() == 0) { + return; } - } else /*褰撳墠浠诲姟宸茬粡鎵ц锛屽垽鏂槸鍚﹀埌鏈�*/ { - if (StringUtils.isNull(currentStepStartTime)||StringUtils.isEmpty(currentStepStartTime)) { - //褰撳墠浠诲姟鍚姩鏃堕棿涓簄ull锛屽垯璇存槑褰撳墠姝ラ琚腑鏂紝鐩存帴鍚姩褰撳墠姝ラ - startRunStep(videoInspectTask); - } else { - boolean expird = isExpirdStep(videoInspectTask); /*鍒ゆ柇褰撳墠姝ラ鏃堕棿鏄惁杩囨湡*/ - if (expird) { - //鍋滄褰曞儚 - stopRunStep(videoInspectTask); - //鍒囨崲姝ラ - String nextStepId = changeNextStep(videoInspectTask); - //寮�濮嬩笅涓�姝ラ - videoInspectTask.setCurrentStepId(nextStepId); + String currentStepId = videoInspectTask.getCurrentStepId(); + String currentStepStartTime = videoInspectTask.getCurrentStepStartTime(); + if (StringUtils.isNull(currentStepId) || StringUtils.isEmpty(currentStepId)) { + //浠�1鍙锋楠ゅ紑濮� + videoInspectTask.setCurrentStepId(videoInspectTask.getArdVideoInspectTaskStepList().get(0).getId()); + if (InspectionTaskManager.taskMap.containsKey(TaskId)) { startRunStep(videoInspectTask); + } + } else /*褰撳墠浠诲姟宸茬粡鎵ц锛屽垽鏂槸鍚﹀埌鏈�*/ { + if (StringUtils.isNull(currentStepStartTime) || StringUtils.isEmpty(currentStepStartTime)) { + //褰撳墠浠诲姟鍚姩鏃堕棿涓簄ull锛屽垯璇存槑褰撳墠姝ラ琚腑鏂紝鐩存帴鍚姩褰撳墠姝ラ + startRunStep(videoInspectTask); + } else { + boolean expird = isExpirdStep(videoInspectTask); /*鍒ゆ柇褰撳墠姝ラ鏃堕棿鏄惁杩囨湡*/ + if (expird) { + //鍋滄褰曞儚 + stopRunStep(videoInspectTask); + //鍒囨崲姝ラ + String nextStepId = changeNextStep(videoInspectTask); + //寮�濮嬩笅涓�姝ラ + videoInspectTask.setCurrentStepId(nextStepId); + startRunStep(videoInspectTask); + } + } + } + } catch (Exception ex) { + log.error("鎵嬪姩宸℃寮傚父锛�" + ex.getMessage()); + } + } + + /** + * 鍒ゆ柇褰撳墠鎵嬪姩浠诲姟鑳藉惁寮�鍚� + */ + @Override + public boolean isEnablemanualTask(String TaskId) { + /*鎵弿褰撳墠鎵嬪姩寮�鐨勪换鍔★紝鑾峰彇鎵嬪姩鎺у埗鐨勭浉鏈篿dList*/ + List<String> menualCameraId = new ArrayList<>(); + ArdVideoInspectTask menualTask = new ArdVideoInspectTask(); + menualTask.setInspectMode("鎵嬪姩"); + List<ArdVideoInspectTask> menualTasks = ardVideoInspectTaskMapper.selectArdVideoInspectTaskList(menualTask); + if (menualTasks.size() > 0) { + for (ArdVideoInspectTask task : menualTasks) { + if (StringUtils.isNull(task.getCameraId()) || StringUtils.isEmpty(task.getCameraId())) { + continue; + } + if (!menualCameraId.contains(task.getCameraId())) { + menualCameraId.add(task.getCameraId()); } } } + /*鍒ゆ柇鐩告満鏄惁宸茬粡琚汉鎵嬪姩鎺у埗*/ + ArdVideoInspectTask videoInspectTask = ardVideoInspectTaskMapper.selectArdVideoInspectTaskById(TaskId); + if (StringUtils.isNull(videoInspectTask)) { + return false; + } + String cameraId = videoInspectTask.getCameraId(); + if (StringUtils.isEmpty(cameraId)) { + return false; + } + if (menualCameraId.contains(cameraId)) { + /*濡傛灉褰撳墠浠诲姟鍏宠仈鐨勭浉鏈哄凡缁忔湁浜烘墜鍔ㄦ帶鍒讹紝鍒欎笉鍏佽鎺у埗*/ + return false; + } + return true; } /** @@ -220,48 +259,80 @@ */ @Override public void autoTaskRun() { - /*鎵弿鎵�鏈夊彲鎵ц浠诲姟1-鏃堕棿婊¤冻2-鑷姩*/ - ArdVideoInspectTask ardVideoInspectTask = new ArdVideoInspectTask(); - ardVideoInspectTask.setInspectMode("鑷姩"); - List<ArdVideoInspectTask> ardVideoInspectTasks = ardVideoInspectTaskMapper.selectArdVideoInspectTaskList(ardVideoInspectTask); - for (ArdVideoInspectTask videoInspectTask : ardVideoInspectTasks) { - /*閬嶅巻鎵�鏈夋椂闂存弧瓒崇殑鑷姩浠诲姟*/ - boolean timeCompare = DateUtils.TimeCompare(videoInspectTask.getStartTime(), videoInspectTask.getEndTime()); - if (timeCompare) { - //log.info("鑷姩浠诲姟鍚姩锛�" + videoInspectTask.getId()); - /*鑾峰彇褰撳墠浠诲姟鐨勬墍鏈夊贰妫�姝ラ*/ - List<ArdVideoInspectTaskStep> ardVideoInspectTaskStepList = ardVideoInspectTaskMapper.selectArdVideoInspectTaskById(videoInspectTask.getId()).getArdVideoInspectTaskStepList(); - if (ardVideoInspectTaskStepList.size() == 0) { - continue; - } - videoInspectTask.setArdVideoInspectTaskStepList(ardVideoInspectTaskStepList); - String currentStepId = videoInspectTask.getCurrentStepId(); - String currentStepStartTime = videoInspectTask.getCurrentStepStartTime(); - if (StringUtils.isNull(currentStepId)||StringUtils.isEmpty(currentStepId)) { - //寮�濮嬪綋鍓嶄换鍔$殑绗竴涓楠� - videoInspectTask.setCurrentStepId(ardVideoInspectTaskStepList.get(0).getId()); - startRunStep(videoInspectTask); - } else /*褰撳墠浠诲姟宸茬粡鎵ц锛屽垽鏂槸鍚﹀埌鏈�*/ { - if (StringUtils.isNull(currentStepStartTime)||StringUtils.isEmpty(currentStepStartTime)) { - //褰撳墠浠诲姟鍚姩鏃堕棿涓虹┖锛屽垯璇存槑褰撳墠姝ラ琚腑鏂紝鐩存帴鍚姩褰撳墠姝ラ - startRunStep(videoInspectTask); - } else { - //鍒ゆ柇褰撳墠姝ラ鏃堕棿鏄惁杩囨湡 - boolean expird = isExpirdStep(videoInspectTask); - if (expird) { - //鍋滄褰曞儚 - stopRunStep(videoInspectTask); - //鍒囨崲姝ラ - String nextStepId = changeNextStep(videoInspectTask); - //寮�濮嬩笅涓�姝ラ - videoInspectTask.setCurrentStepId(nextStepId); - startRunStep(videoInspectTask); - } + try { + /*鎵弿褰撳墠鎵嬪姩寮�鐨勪换鍔★紝鑾峰彇鎵嬪姩鎺у埗鐨勭浉鏈篿dList*/ + List<String> menualCameraId = new ArrayList<>(); + ArdVideoInspectTask menualTask = new ArdVideoInspectTask(); + menualTask.setInspectMode("鎵嬪姩"); + List<ArdVideoInspectTask> menualTasks = ardVideoInspectTaskMapper.selectArdVideoInspectTaskList(menualTask); + if (menualTasks.size() > 0) { + for (ArdVideoInspectTask task : menualTasks) { + if (StringUtils.isNull(task.getCameraId()) || StringUtils.isEmpty(task.getCameraId())) { + continue; + } + if (!menualCameraId.contains(task.getCameraId())) { + menualCameraId.add(task.getCameraId()); } } } + + /*鎵弿鎵�鏈夎嚜鍔ㄤ换鍔�*/ + ArdVideoInspectTask autoTask = new ArdVideoInspectTask(); + autoTask.setInspectMode("鑷姩"); + List<ArdVideoInspectTask> ardVideoInspectTasks = ardVideoInspectTaskMapper.selectArdVideoInspectTaskList(autoTask); + for (ArdVideoInspectTask videoInspectTask : ardVideoInspectTasks) { + /*閬嶅巻鎵�鏈夋椂闂存弧瓒崇殑鑷姩浠诲姟*/ + boolean timeCompare = DateUtils.TimeCompare(videoInspectTask.getStartTime(), videoInspectTask.getEndTime()); + if (timeCompare) { + if (menualCameraId.contains(videoInspectTask.getCameraId())) { + /*鑻ュ綋鍓嶇浉鏈烘鍦ㄦ湁浠诲姟鎵嬪姩鎵ц锛屽垯涓嶆墽琛�*/ + continue; + } + /*鑾峰彇褰撳墠浠诲姟鐨勬墍鏈夊贰妫�姝ラ*/ + List<ArdVideoInspectTaskStep> ardVideoInspectTaskStepList = ardVideoInspectTaskMapper.selectArdVideoInspectTaskById(videoInspectTask.getId()).getArdVideoInspectTaskStepList(); + if (ardVideoInspectTaskStepList.size() == 0) { + continue; + } + videoInspectTask.setArdVideoInspectTaskStepList(ardVideoInspectTaskStepList); + String currentStepId = videoInspectTask.getCurrentStepId(); + String currentStepStartTime = videoInspectTask.getCurrentStepStartTime(); + if (StringUtils.isNull(currentStepId) || StringUtils.isEmpty(currentStepId)) { + //寮�濮嬪綋鍓嶄换鍔$殑绗竴涓楠� + videoInspectTask.setCurrentStepId(ardVideoInspectTaskStepList.get(0).getId()); + startRunStep(videoInspectTask); + } else /*褰撳墠浠诲姟宸茬粡鎵ц锛屽垽鏂槸鍚﹀埌鏈�*/ { + if (StringUtils.isNull(currentStepStartTime) || StringUtils.isEmpty(currentStepStartTime)) { + //褰撳墠浠诲姟鍚姩鏃堕棿涓虹┖锛屽垯璇存槑褰撳墠姝ラ琚腑鏂紝鐩存帴鍚姩褰撳墠姝ラ + startRunStep(videoInspectTask); + } else { + //鍒ゆ柇褰撳墠姝ラ鏃堕棿鏄惁杩囨湡 + boolean expird = isExpirdStep(videoInspectTask); + if (expird) { + //鍋滄褰曞儚 + stopRunStep(videoInspectTask); + //鍒囨崲姝ラ + String nextStepId = changeNextStep(videoInspectTask); + //寮�濮嬩笅涓�姝ラ + videoInspectTask.setCurrentStepId(nextStepId); + startRunStep(videoInspectTask); + } + } + } + } else { + if (StringUtils.isEmpty(videoInspectTask.getCurrentStepId()) || StringUtils.isEmpty(videoInspectTask.getCurrentStepStartTime())) { + continue; + } + /*杩囨湡鐨勪换鍔℃竻绌哄綋鍓嶆楠や俊鎭�*/ + videoInspectTask.setCurrentStepId(""); + videoInspectTask.setCurrentStepStartTime(""); + ardVideoInspectTaskMapper.updateArdVideoInspectTask(videoInspectTask); + } + } + } catch (Exception ex) { + log.error("鑷姩宸℃浠诲姟寮傚父锛�" + ex.getMessage()); } } + /** * 鑷姩鎵嬪姩鍚堝苟锛屾壂搴撴柟寮忥紝鐩墠涓嶄娇鐢� */ @@ -288,12 +359,12 @@ videoInspectTask.setArdVideoInspectTaskStepList(ardVideoInspectTaskStepList); String currentStepId = videoInspectTask.getCurrentStepId();//褰撳墠姝ラid String currentStepStartTime = videoInspectTask.getCurrentStepStartTime();//褰撳墠姝ラ鍚姩鏃堕棿 - if (StringUtils.isNull(currentStepId)||StringUtils.isEmpty(currentStepId)) { + if (StringUtils.isNull(currentStepId) || StringUtils.isEmpty(currentStepId)) { //寮�濮嬬涓�涓楠� videoInspectTask.setCurrentStepId(ardVideoInspectTaskStepList.get(0).getId()); startRunStep(videoInspectTask); } else { - if (StringUtils.isNull(currentStepStartTime)||StringUtils.isEmpty(currentStepStartTime)) { + if (StringUtils.isNull(currentStepStartTime) || StringUtils.isEmpty(currentStepStartTime)) { //褰撳墠浠诲姟鍚姩鏃堕棿涓虹┖锛屽垯璇存槑褰撳墠姝ラ琚腑鏂紝鐩存帴鍚姩褰撳墠姝ラ startRunStep(videoInspectTask); } else { diff --git a/ruoyi-admin/Dockerfile b/ruoyi-admin/Dockerfile new file mode 100644 index 0000000..cf735a9 --- /dev/null +++ b/ruoyi-admin/Dockerfile @@ -0,0 +1,7 @@ +FROM openjdk:8-jdk-alpine +ARG JAR_FILE=target/*.jar +COPY ${JAR_FILE} ruoyi-admin.jar +ENV TimeZone=Asia/Shanghai +# 浣跨敤杞繛鎺ワ紝骞朵笖灏嗘椂鍖洪厤缃鐩�/etc/timezone +RUN ln -snf /usr/share/zoneinfo/$TimeZone /etc/localtime && echo $TimeZone > /etc/timezone +ENTRYPOINT ["java","-jar","/ruoyi-admin.jar"] \ No newline at end of file diff --git a/ruoyi-admin/pom.xml b/ruoyi-admin/pom.xml index ee560f9..3c953da 100644 --- a/ruoyi-admin/pom.xml +++ b/ruoyi-admin/pom.xml @@ -14,6 +14,9 @@ <description> web鏈嶅姟鍏ュ彛 </description> + <properties> + <docker.image.prefix>ruoyi</docker.image.prefix> + </properties> <dependencies> @@ -99,7 +102,22 @@ <failOnMissingWebXml>false</failOnMissingWebXml> <warName>${project.artifactId}</warName> </configuration> - </plugin> + </plugin> + <plugin> + <groupId>com.spotify</groupId> + <artifactId>dockerfile-maven-plugin</artifactId> + <version>1.3.6</version> + <configuration> + <repository>${docker.image.prefix}/${project.artifactId}</repository> + <buildArgs> + <JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE> + </buildArgs> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + </plugin> </plugins> <finalName>${project.artifactId}</finalName> </build> diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/PatrolInspectionTask.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/PatrolInspectionTask.java index da32f82..6837327 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/PatrolInspectionTask.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/PatrolInspectionTask.java @@ -40,268 +40,4 @@ public void scanRun() { ardVideoInspectTaskService.autoTaskRun(); } - - //鑷姩宸℃浠诲姟 -// public void scanRun() { -// /*鎵弿鎵�鏈夊彲鎵ц浠诲姟1-鏃堕棿婊¤冻2-鑷姩*/ -// ArdVideoInspectTask ardVideoInspectTask = new ArdVideoInspectTask(); -// ardVideoInspectTask.setInspectMode("鑷姩"); -// List<ArdVideoInspectTask> ardVideoInspectTasks = ardVideoInspectTaskService.selectArdVideoInspectTaskList(ardVideoInspectTask); -// for (ArdVideoInspectTask videoInspectTask : ardVideoInspectTasks) { -// /*閬嶅巻鎵�鏈夋椂闂存弧瓒崇殑鑷姩浠诲姟*/ -// boolean timeCompare = DateUtils.TimeCompare(videoInspectTask.getStartTime(), videoInspectTask.getEndTime()); -// if (timeCompare) { -// /*鑾峰彇褰撳墠浠诲姟鐨勬墍鏈夊贰妫�姝ラ*/ -// List<ArdVideoInspectTaskStep> ardVideoInspectTaskStepList = ardVideoInspectTaskService.selectArdVideoInspectTaskById(videoInspectTask.getId()).getArdVideoInspectTaskStepList(); -// if (ardVideoInspectTaskStepList.size() == 0) { -// continue; -// } -// videoInspectTask.setArdVideoInspectTaskStepList(ardVideoInspectTaskStepList); -// String currentStepId = videoInspectTask.getCurrentStepId(); -// if (StringUtils.isNull(currentStepId)) { -// videoInspectTask.setCurrentStepId(ardVideoInspectTaskStepList.get(0).getId()); -// startRunStep(videoInspectTask);//寮�濮嬪綋鍓嶄换鍔$殑绗竴涓楠� -// } else /*褰撳墠浠诲姟宸茬粡鎵ц锛屽垽鏂槸鍚﹀埌鏈�*/ { -// if (StringUtils.isNull(videoInspectTask.getCurrentStepStartTime())) { -// //褰撳墠浠诲姟鍚姩鏃堕棿涓簄ull锛屽垯璇存槑褰撳墠姝ラ琚腑鏂紝鐩存帴鍚姩褰撳墠姝ラ -// startRunStep(videoInspectTask); -// } else { -// boolean expird = isExpirdStep(videoInspectTask); /*鍒ゆ柇褰撳墠姝ラ鏃堕棿鏄惁杩囨湡*/ -// if (expird) { -// //鍋滄褰曞儚 -// stopRunStep(videoInspectTask); -// //鍒囨崲姝ラ -// String nextStepId = changeNextStep(videoInspectTask); -// //寮�濮嬩笅涓�姝ラ -// videoInspectTask.setCurrentStepId(nextStepId); -// startRunStep(videoInspectTask); -// } -// } -// } -// } -// } -// } - -// //鎵嬪姩宸℃浠诲姟 -// public void ManualTaskRun(String taskId) { -// Timer timer = new Timer(); -// // 5s鍚庢墽琛� -// // timer.schedule(new MyTask(), 5000); -// // 椹笂鎵ц浠诲姟,姣忛殧2000鎵ц涓�娆� -// timerTask = new TimerTask() { -// @Override -// public void run() { -// ArdVideoInspectTask videoInspectTask = ardVideoInspectTaskService.selectArdVideoInspectTaskById(taskId); -// /*鑾峰彇褰撳墠浠诲姟鐨勬墍鏈夊贰妫�姝ラ*/ -// List<ArdVideoInspectTaskStep> ardVideoInspectTaskStepList = ardVideoInspectTaskService.selectArdVideoInspectTaskById(videoInspectTask.getId()).getArdVideoInspectTaskStepList(); -// if (ardVideoInspectTaskStepList.size() == 0) { -// log.error("褰撳墠浠诲姟娌℃湁鍙戠幇鎵ц姝ラ"); -// return; -// } -// videoInspectTask.setArdVideoInspectTaskStepList(ardVideoInspectTaskStepList); -// String currentStepId = videoInspectTask.getCurrentStepId(); -// if (StringUtils.isNull(currentStepId)) { -// videoInspectTask.setCurrentStepId(ardVideoInspectTaskStepList.get(0).getId()); -// startRunStep(videoInspectTask);//寮�濮嬪綋鍓嶄换鍔$殑绗竴涓楠� -// } else /*褰撳墠浠诲姟宸茬粡鎵ц锛屽垽鏂槸鍚﹀埌鏈�*/ { -// if (StringUtils.isNull(videoInspectTask.getCurrentStepStartTime())) { -// //褰撳墠浠诲姟鍚姩鏃堕棿涓簄ull锛屽垯璇存槑褰撳墠姝ラ琚腑鏂紝鐩存帴鍚姩褰撳墠姝ラ -// startRunStep(videoInspectTask); -// } else { -// boolean expird = isExpirdStep(videoInspectTask); /*鍒ゆ柇褰撳墠姝ラ鏃堕棿鏄惁杩囨湡*/ -// if (expird) { -// //鍋滄褰曞儚 -// stopRunStep(videoInspectTask); -// //鍒囨崲姝ラ -// String nextStepId = changeNextStep(videoInspectTask); -// //寮�濮嬩笅涓�姝ラ -// videoInspectTask.setCurrentStepId(nextStepId); -// startRunStep(videoInspectTask); -// } -// } -// } -// } -// }; -// timer.scheduleAtFixedRate(timerTask, new Date(), 2000); -// } -// -// //姝ラ寮�濮� -// private void startRunStep(ArdVideoInspectTask ardVideoInspectTask) { -// try { -// String currentStepId = ardVideoInspectTask.getCurrentStepId(); -// if (StringUtils.isNull(currentStepId)) { -// log.info("褰撳墠寮�濮嬪贰妫�姝ラid涓虹┖"); -// return; -// } -// log.info("姝ラ锛�" + currentStepId + "寮�濮�"); -// String cameraId = ardVideoInspectTask.getCameraId(); -// Integer channel = ardVideoInspectTask.getChannel(); -// Optional<ArdVideoInspectTaskStep> objectOptional = ardVideoInspectTask.getArdVideoInspectTaskStepList().stream() -// .filter(obj -> obj.getId().equals(currentStepId)) -// .findFirst(); -// if (objectOptional.isPresent()) { -// ArdVideoInspectTaskStep step = objectOptional.get(); -// String wellId = step.getWellId(); -// if (!StringUtils.isNull(wellId)) { -// /*鑾峰彇浜曞潗鏍�*/ -// ArdAlarmpointsWell ardAlarmpointsWell = ardAlarmpointsWellService.selectArdAlarmpointsWellById(wellId); -// double[] targetPositon = new double[3]; -// targetPositon[0] = ardAlarmpointsWell.getLongitude(); -// targetPositon[1] = ardAlarmpointsWell.getLatitude(); -// targetPositon[2] = ardAlarmpointsWell.getAltitude(); -// /*鑾峰彇鐩告満鍧愭爣*/ -// ArdCameras cameras = ardCamerasService.selectArdCamerasById(cameraId); -// double[] cameraPositon = new double[3]; -// cameraPositon[0] = cameras.getLongitude(); -// cameraPositon[1] = cameras.getLatitude(); -// cameraPositon[2] = cameras.getAltitude(); -// /*鎺у埗鐩告満宸℃*/ -// CameraCmd cmd = new CameraCmd(); -// cmd.setCameraId(cameraId); -// cmd.setChannelNum(channel); -// cmd.setCamPosition(cameraPositon); -// cmd.setTargetPosition(targetPositon); -// cmd.setOperator("sys_patrol_inspect"); -// cmd.setExpired(step.getRecordingTime()); -// boolean setTargetPosition = hikClientService.setTargetPosition(cmd); -// if (setTargetPosition) { -// /*鎺у埗鐩告満宸℃鎴愬姛锛屽紑濮嬪綍鍍�*/ -// cmd.setEnable(true);//鍚姩褰曞儚 -// hikClientService.recordToMinio(cmd); -// /*鏇存柊浠诲姟褰撳墠姝ラid鍜屾楠ゅ惎鍔ㄦ椂闂�*/ -// ArdVideoInspectTask avit = new ArdVideoInspectTask(); -// avit.setId(ardVideoInspectTask.getId()); -// avit.setCurrentStepId(step.getId()); -// avit.setCurrentStepStartTime(DateUtils.getTime()); -// ardVideoInspectTaskService.updateArdVideoInspectTaskNoUpdater(avit); -// } else { -// cmd.setEnable(false);//鍋滄褰曞儚 -// hikClientService.recordToMinio(cmd); -// /*鎺у埗澶辫触,褰撳墠姝ラ鍚姩鏃堕棿缃畁ull*/ -// ArdVideoInspectTask avit = new ArdVideoInspectTask(); -// avit.setId(ardVideoInspectTask.getId()); -// avit.setCurrentStepId(step.getId()); -// avit.setCurrentStepStartTime(null); -// ardVideoInspectTaskService.updateArdVideoInspectTaskNoUpdater(avit); -// } -// } -// } -// } catch (Exception ex) { -// log.error("宸℃寮�濮嬪紓甯革細" + ex.getMessage()); -// } -// } -// -// //姝ラ鍋滄 -// private void stopRunStep(ArdVideoInspectTask ardVideoInspectTask) { -// try { -// String currentStepId = ardVideoInspectTask.getCurrentStepId(); -// log.info("姝ラ锛�" + currentStepId + "鍋滄"); -// if (StringUtils.isNull(currentStepId)) { -// log.info("褰撳墠鍋滄宸℃姝ラid涓虹┖"); -// return; -// } -// String currentStepStartTime = ardVideoInspectTask.getCurrentStepStartTime(); -// String cameraId = ardVideoInspectTask.getCameraId(); -// Integer channel = ardVideoInspectTask.getChannel(); -// Optional<ArdVideoInspectTaskStep> objectOptional = ardVideoInspectTask.getArdVideoInspectTaskStepList().stream() -// .filter(obj -> obj.getId().equals(currentStepId)) -// .findFirst(); -// if (objectOptional.isPresent()) { -// ArdVideoInspectTaskStep step = objectOptional.get(); -// /*鍋滄褰曞儚*/ -// CameraCmd cmd = new CameraCmd(); -// cmd.setCameraId(cameraId); -// cmd.setChannelNum(channel); -// cmd.setOperator("sys_patrol_inspect"); -// cmd.setEnable(false);//鍋滄褰曞儚 -// String uuid = UUID.randomUUID().toString().replace("-", ""); -// String time = new SimpleDateFormat("yyyyMMdd").format(new Date()); -// String recordName = cameraId + "/" + time + "/" + uuid + ".mp4"; -// cmd.setRecordBucketName("record"); -// cmd.setRecordObjectName(recordName); -// hikClientService.recordToMinio(cmd); -// /*鎻掑叆宸℃璁板綍*/ -// ArdVideoInspectRecord ardVideoInspectRecord = new ArdVideoInspectRecord(); -// ardVideoInspectRecord.setStepId(step.getId()); -// Date currentStepStartDate = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, currentStepStartTime); -// Date currentStepStopDate = DateUtils.addMinutes(currentStepStartDate, step.getRecordingTime()); -// ardVideoInspectRecord.setStartTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, currentStepStartDate)); -// ardVideoInspectRecord.setEndTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, currentStepStopDate)); -// String url = MinioClientSingleton.domainUrl + "/" + cmd.getRecordBucketName() + "/" + recordName; -// ardVideoInspectRecord.setRecordFilePath(url); -// ardVideoInspectRecordService.insertArdVideoInspectRecord(ardVideoInspectRecord); -// } -// } catch (Exception ex) { -// log.error("宸℃鍋滄寮傚父:" + ex.getMessage()); -// } -// } -// -// //姝ラ鍒ゆ柇鏄惁杩囨湡 -// private boolean isExpirdStep(ArdVideoInspectTask ardVideoInspectTask) { -// try { -// List<ArdVideoInspectTaskStep> ardVideoInspectTaskStepList = ardVideoInspectTask.getArdVideoInspectTaskStepList(); -// /*鑾峰彇褰撳墠浠诲姟姝e湪鎵ц鐨勬楠ゅ拰褰撳墠姝ラ寮�濮嬬殑鏃堕棿*/ -// String currentStepId = ardVideoInspectTask.getCurrentStepId(); -// String currentStepStartTime = ardVideoInspectTask.getCurrentStepStartTime(); -// Optional<ArdVideoInspectTaskStep> objectOptional = ardVideoInspectTaskStepList.stream() -// .filter(ardVideoInspectTaskStep -> ardVideoInspectTaskStep.getId().equals(currentStepId)) -// .findFirst(); -// if (objectOptional.isPresent()) { -// /*鑾峰彇褰撳墠姝ラ淇℃伅*/ -// ArdVideoInspectTaskStep currentStep = objectOptional.get(); -// /*鑾峰彇鍒板綋鍓嶆楠ょ殑寮�濮嬪拰缁撴潫鏃堕棿*/ -// Date currentStepStartDate = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, currentStepStartTime); -// Date currentStepStopDate = DateUtils.addMinutes(currentStepStartDate, currentStep.getRecordingTime()); -// /*鍒ゆ柇褰撳墠姝ラ鏃堕棿鏄惁杩囨湡*/ -// if (!DateUtils.TimeCompare(currentStepStartDate, currentStepStopDate)) { -// return true; -// } else { -// return false; -// } -// } else { -// return false; -// } -// } catch (Exception ex) { -// log.error("鍒ゆ柇宸℃姝ラ杩囨湡寮傚父锛�" + ex.getMessage()); -// return false; -// } -// } -// -// //姝ラ鍒囨崲 -// private String changeNextStep(ArdVideoInspectTask ardVideoInspectTask) { -// try { -// String currentStepId = ardVideoInspectTask.getCurrentStepId(); -// Optional<ArdVideoInspectTaskStep> objectOptional = ardVideoInspectTask.getArdVideoInspectTaskStepList().stream() -// .filter(obj -> obj.getId().equals(currentStepId)) -// .findFirst(); -// if (objectOptional.isPresent()) { -// ArdVideoInspectTaskStep step = objectOptional.get(); -// Integer currentStepOrderNumber = step.getOrderNumber(); -// /*鍒ゆ柇褰撳墠姝ラ搴忓彿鏄惁灏忎簬姝ラ鎬绘暟*/ -// if (currentStepOrderNumber < ardVideoInspectTask.getArdVideoInspectTaskStepList().size()) { -// /*灏忎簬鍒欐墽琛屼笅涓�姝ラ*/ -// currentStepOrderNumber++; -// } else { -// /*鍚﹀垯浠�1寮�濮嬫墽琛�*/ -// currentStepOrderNumber = 1; -// } -// Integer nextStepOrderNumber = currentStepOrderNumber; -// /*鏇存柊褰撳墠浠诲姟鍒囨崲鏂版楠�*/ -// ArdVideoInspectTask avit = new ArdVideoInspectTask(); -// avit.setId(ardVideoInspectTask.getId()); -// String nextStepId = ardVideoInspectTask.getArdVideoInspectTaskStepList().stream() -// .filter(obj -> obj.getOrderNumber() == nextStepOrderNumber) -// .map(ArdVideoInspectTaskStep::getId) -// .findFirst() -// .orElse(null); -// avit.setCurrentStepId(nextStepId); -// ardVideoInspectTaskService.updateArdVideoInspectTaskNoUpdater(avit); -// log.info("姝ラ锛�" + currentStepId + "鍒囨崲涓�" + nextStepId); -// return nextStepId; -// } -// } catch (Exception ex) { -// log.error("宸℃姝ラ鍒囨崲寮傚父锛�" + ex.getMessage()); -// } -// return ""; -// } } -- Gitblit v1.9.3