| 
					
				 | 
			
			
				@@ -0,0 +1,110 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+package com.ozs.web.controller.shotschedule; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ozs.common.utils.MinioUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ozs.common.utils.uuid.IdUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ozs.service.entity.BaseCameraManagement; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ozs.service.entity.MsgAlarm; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ozs.service.service.BaseCameraManagementService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ozs.service.service.MsgAlarmService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ozs.service.service.impl.CameraCaptureService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ozs.system.service.ISysDictDataService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import lombok.extern.slf4j.Slf4j; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.beans.factory.annotation.Value; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.scheduling.annotation.Async; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.util.CollectionUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.util.ObjectUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import javax.annotation.Resource; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.io.ByteArrayInputStream; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.io.IOException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.net.MalformedURLException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.net.URL; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.text.SimpleDateFormat; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.Date; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.Objects; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.concurrent.CompletableFuture; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.stream.Collectors; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * @author wyy 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * @subject 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * @creat 2024/3/1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+@Slf4j 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+@Service 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+public class TaskService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Resource 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    BaseCameraManagementService baseCameraManagementService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Resource 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    MsgAlarmService msgAlarmService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Resource 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    CameraCaptureService cameraCaptureService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private ISysDictDataService dictDataService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private  static SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Value("${shot.urlAddress}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private String urlAddress; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Resource 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    MinioUtils minioUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void getNormalPicture() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<BaseCameraManagement> list = msgAlarmService.getBaseCameraManagementsByLockedMsgAlarms(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!CollectionUtils.isEmpty(list) && Objects.nonNull(list.get(0))) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            list.forEach(l -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                String uuid = IdUtils.fastSimpleUUID(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (!ObjectUtils.isEmpty(l.getCameraCode()) && !ObjectUtils.isEmpty(l.getChannel())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        System.out.println(urlAddress + l.getCameraCode() + "/" + l.getChannel()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        log.info("请求url======" + urlAddress + l.getCameraCode() + "/" + l.getChannel()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        URL url = new URL(urlAddress + l.getCameraCode() + "/" + l.getChannel()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        String root = dictDataService.selectDictLabel("shot_address", String.valueOf(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        String dateString = format.format(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        String fileName = root + "/" + "normal" + "/" + dateString + "/" + uuid + ".jpeg"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        log.info("fileName======" + fileName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        log.info("调用图片生成服务开始"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        cameraCaptureService.getCapture(url,fileName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        log.info("调用图片生成服务结束"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } catch (MalformedURLException e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } catch (IOException e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void getAlarmPicture() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<BaseCameraManagement> msgAlarmList = msgAlarmService.getBaseCameraManagementsByLockedMsgAlarms(2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(!CollectionUtils.isEmpty(msgAlarmList) && Objects.nonNull(msgAlarmList.get(0))){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            msgAlarmList.forEach(l -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                String uuid = IdUtils.fastSimpleUUID(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                QueryWrapper<BaseCameraManagement> wrapper = new QueryWrapper<BaseCameraManagement>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                wrapper.lambda().eq(BaseCameraManagement::getCameraCode,l.getCameraCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                BaseCameraManagement baseCameraManagement = baseCameraManagementService.getOne(wrapper); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(!ObjectUtils.isEmpty(l.getCameraCode()) &&!ObjectUtils.isEmpty(baseCameraManagement)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        System.out.println(urlAddress+l.getCameraCode()+"/"+baseCameraManagement.getChannel()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        log.info("请求url======"+urlAddress+l.getCameraCode()+"/"+baseCameraManagement.getChannel()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        URL url = new URL(urlAddress+l.getCameraCode()+"/"+baseCameraManagement.getChannel()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        String root = dictDataService.selectDictLabel("shot_address", String.valueOf(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        String dateString = format.format(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        String fileName = root + "/"+"alarm"+"/" + dateString + "/" + uuid + ".jpeg"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        log.info("fileName======"+fileName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        log.info("报警摄像头截图开始"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        cameraCaptureService.getCapture(url,fileName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        log.info("报警摄像头截图结束"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } catch (Throwable e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        log.error(e.getMessage()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 |