Explorar o código

获取机车前向视频开发

gao.qiang hai 6 meses
pai
achega
8af2c39e46

+ 4 - 0
business-service/src/main/java/com/ozs/entity/BaseCameraManagement.java

@@ -225,4 +225,8 @@ public class BaseCameraManagement extends BaseEntity implements Serializable {
      * 显卡的使用(为了充分使用正式服务器的四张显卡)
      */
     private String graphicsCard;
+    /**
+     * 车号
+     */
+    private String trainNum;
 }

+ 10 - 0
business-service/src/main/java/com/ozs/entity/BaseTerminalLog.java

@@ -46,4 +46,14 @@ public class BaseTerminalLog extends BaseEntity implements Serializable {
      */
     @TableField(exist = false)
     private String terminalLatitude;
+    /**
+     * 当前机车车号
+     */
+    @TableField(exist = false)
+    private String trainNum;
+    /**
+     * 前方机车车号
+     */
+    @TableField(exist = false)
+    private String frontTrainNum;
 }

+ 18 - 0
business-service/src/main/java/com/ozs/entity/response/VehicleVedioResponse.java

@@ -0,0 +1,18 @@
+package com.ozs.entity.response;
+
+import lombok.Data;
+
+/**
+ * @author Administrator
+ */
+@Data
+public class VehicleVedioResponse {
+    /**
+     * 车载终端编码
+     */
+    private String terminalCode;
+    /**
+     * 车号
+     */
+    private String trainNum;
+}

+ 62 - 0
vehicle-sdk/src/main/java/com/ozs/controller/upload/GeoHazardMonitorTokenController.java

@@ -35,6 +35,7 @@ import com.ozs.entity.TerminalIgnoreAlarm;
 import com.ozs.entity.VehiclePosition;
 import com.ozs.entity.response.PreAlarmListResponse;
 import com.ozs.entity.response.PreAlarmResponse;
+import com.ozs.entity.response.VehicleVedioResponse;
 import com.ozs.entity.vo.AlarmFilesVo;
 import com.ozs.entity.vo.AlarmHeartbeatLog;
 import com.ozs.entity.vo.AlarmInfoVo;
@@ -2230,6 +2231,13 @@ public class GeoHazardMonitorTokenController {
             terminal.eq(BaseTerminal::getTerminalCode, baseTerminalLog.getTerminalCode());
             boolean update = baseTerminalService.update(baseTerminal1, terminal);
             if (baseTerminalLogService.save(baseTerminalLog) && update) {
+                if (!ObjectUtils.isEmpty(baseTerminalLog.getTrainNum())&&!ObjectUtils.isEmpty(baseTerminalLog.getFrontTrainNum())){
+                    VehiclePosition vehiclePosition = vehiclePositionService.getOne(new LambdaQueryWrapper<VehiclePosition>().eq(VehiclePosition::getVehicleCode, baseTerminalLog.getTrainNum()).orderByDesc(VehiclePosition::getCreateTime).last("limit 1"));
+                    VehiclePosition positionServiceOne = vehiclePositionService.getOne(new LambdaQueryWrapper<VehiclePosition>().eq(VehiclePosition::getVehicleCode, baseTerminalLog.getFrontTrainNum()).orderByDesc(VehiclePosition::getCreateTime).last("limit 1"));
+                    Map<String, Object> map = new HashMap<>();
+                    map.put("frontVehicleDistance", vehiclePosition.getTravelMile()-positionServiceOne.getTravelMile());
+                    AjaxResults1 = new AjaxResults(1, "ok", map);
+                }
                 AjaxResults1 = new AjaxResults(1, "ok");
                 return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
             } else {
@@ -2242,6 +2250,60 @@ public class GeoHazardMonitorTokenController {
         }
     }
 
+    /**
+     * 获取机车前向摄像机视频
+     */
+    @PostMapping("/api/vehicle/vedio")
+    public String vehicleVedio(@RequestBody ParameterVo parameterVo, HttpServletRequest request) {
+        String token = apiTokenUtils.getGeoHazardMonitorToken(request);
+        log.info("token:{}", token);
+        log.info("parameterVo:{}", parameterVo);
+        AjaxResults AjaxResults1 = null;
+        if (StringUtils.isNotEmpty(token)) {
+            String[] split = token.split("-");
+            String key = split[split.length - 1];
+            if (ObjectUtils.isEmpty(parameterVo)) {
+                AjaxResults1 = new AjaxResults(0, "parameterVo参数不能为空");
+                return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
+            }
+            String s = SM4Utils.decryptData_ECB(parameterVo.getParameter(), key);
+            VehicleVedioResponse vehicleVedioResponse = JSON.parseObject(s, VehicleVedioResponse.class);
+            if (ObjectUtils.isEmpty(vehicleVedioResponse.getTerminalCode())) {
+                AjaxResults1 = new AjaxResults(0, "终端编码不能为空");
+                return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
+            }
+            if (ObjectUtils.isEmpty(vehicleVedioResponse.getTrainNum())) {
+                AjaxResults1 = new AjaxResults(0, "车号不能为空");
+                return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
+            }
+            BaseCameraManagement baseCameraManagement = baseCameraManagementService.getOne(new LambdaQueryWrapper<BaseCameraManagement>().eq(BaseCameraManagement::getTrainNum, vehicleVedioResponse.getTrainNum()));
+            if (!ObjectUtils.isEmpty(baseCameraManagement)) {
+                CompletableFuture.runAsync(() -> {
+                    String playFlv = cameraUtil.heartbeatgetPlayFlv(baseCameraManagement.getCameraCode(), baseCameraManagement.getGraphicsCard(), true);
+                    log.info("-------playFlv--------" + playFlv);
+                    if (StringUtils.isEmpty(playFlv)) {
+                        try {
+                            cameraUtil.heartbeatgetUrl(baseCameraManagement.getCameraCode(), baseCameraManagement.getGraphicsCard(),true, httpUrl);
+                        } catch (Exception e) {
+                            e.printStackTrace();
+                        }
+                    }
+                });
+                CameraVos cameraVos = new CameraVos();
+                cameraVos.setCameraCode(baseCameraManagement.getCameraCode());
+                cameraVos.setCurrentStream(CameraUtil.getPlayFlvRtsp(baseCameraManagement.getCameraCode(), baseCameraManagement.getGraphicsCard(), true, httpUrl));
+                AjaxResults1 = new AjaxResults(1, "ok",cameraVos);
+                return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
+            } else {
+                AjaxResults1 = new AjaxResults(0, "未查询到改车号的相机信息");
+                return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
+            }
+        } else {
+            AjaxResults1 = new AjaxResults(2, "token验证失败");
+            return JSONObject.toJSONString(AjaxResults1);
+        }
+    }
+
 
     /**
      * 预警信息接口定义