Просмотр исходного кода

模拟预警信息接口开发

gao.qiang 3 месяцев назад
Родитель
Сommit
ea827c46af

+ 12 - 0
business-service/src/main/java/com/ozs/entity/response/PreAlarmReq.java

@@ -0,0 +1,12 @@
+package com.ozs.entity.response;
+
+import lombok.Data;
+
+/**
+ * @author Administrator
+ */
+@Data
+public class PreAlarmReq {
+    private String beginTime;
+    private String endTime;
+}

+ 27 - 4
vehicle-sdk/src/main/java/com/ozs/controller/upload/GeoHazardMonitorTokenController.java

@@ -33,10 +33,7 @@ import com.ozs.entity.SkynetHeartbeatLog;
 import com.ozs.entity.SvcAddress;
 import com.ozs.entity.TerminalIgnoreAlarm;
 import com.ozs.entity.VehiclePosition;
-import com.ozs.entity.response.BaseCameraManagementReq;
-import com.ozs.entity.response.PreAlarmListResponse;
-import com.ozs.entity.response.PreAlarmResponse;
-import com.ozs.entity.response.VehicleVedioResponse;
+import com.ozs.entity.response.*;
 import com.ozs.entity.vo.AlarmFilesVo;
 import com.ozs.entity.vo.AlarmHeartbeatLog;
 import com.ozs.entity.vo.AlarmInfoVo;
@@ -105,6 +102,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
 /**
@@ -3044,4 +3042,29 @@ public class GeoHazardMonitorTokenController {
     public void ttt() {
         String cameraPreviewURL = cameraUtil.getCameraPreviewURL();
     }
+
+    @PostMapping("/api/savePreAlarm")
+    public void savePreAlarm(@RequestBody PreAlarmReq preAlarmReq){
+        List<PreAlarm> list = preAlarmService.list(new LambdaQueryWrapper<PreAlarm>()
+                .ge(PreAlarm::getPreAlarmTime, preAlarmReq.getBeginTime())
+                .le(PreAlarm::getPreAlarmTime, preAlarmReq.getEndTime()).orderByAsc(PreAlarm::getPreAlarmTime));
+        log.info("savePreAlarm---------------"+list.toString());
+        if (!ObjectUtils.isEmpty(list)){
+            for (PreAlarm preAlarm : list) {
+                try {
+                    TimeUnit.SECONDS.sleep(1);
+                    Calendar cal = Calendar.getInstance();
+                    cal.setTime(new Date());
+                    cal.set(Calendar.MILLISECOND, 0);
+                    cal.set(Calendar.MILLISECOND, 0);
+                    preAlarm.setPreAlarmTime(cal.getTime());
+                    preAlarm.setCreatedTime(new Date());
+                    boolean save = preAlarmService.save(preAlarm);
+                    log.info("savePreAlarm--------------时间-"+new Date()+"----"+save);
+                } catch (InterruptedException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
 }