Browse Source

获取机车前向视频开发

gao.qiang 6 months ago
parent
commit
014486d889

+ 8 - 1
business-service/src/main/java/com/ozs/entity/BaseCameraManagement.java

@@ -221,5 +221,12 @@ public class BaseCameraManagement extends BaseEntity implements Serializable {
      */
     @Excel(name = "排序")
     private String sort;
-    
+    /**
+     * 显卡的使用(为了充分使用正式服务器的四张显卡)
+     */
+    private String graphicsCard;
+    /**
+     * 车号
+     */
+    private String trainNum;
 }

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

@@ -34,4 +34,26 @@ public class BaseTerminalLog extends BaseEntity implements Serializable {
      *终端编码
      */
     private String terminalCode;
+
+    /**
+     * 终端经度
+     */
+    @TableField(exist = false)
+    private String terminalLongitude;
+
+    /**
+     * 终端纬度
+     */
+    @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 Integer trainNum;
+}

+ 98 - 0
business-service/src/main/java/com/ozs/mapper/BaseDictDataMapper.java

@@ -0,0 +1,98 @@
+package com.ozs.mapper;
+
+import com.ozs.common.core.domain.entity.SysDictData;
+import icu.mhb.mybatisplus.plugln.base.mapper.JoinBaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 字典表 数据层
+ *
+ * @author hx
+ */
+@Mapper
+public interface BaseDictDataMapper extends JoinBaseMapper<SysDictData> {
+    /**
+     * 根据条件分页查询字典数据
+     *
+     * @param dictData 字典数据信息
+     * @return 字典数据集合信息
+     */
+    public List<SysDictData> selectDictDataList(SysDictData dictData);
+
+    /**
+     * 根据字典类型查询字典数据
+     *
+     * @param dictType 字典类型
+     * @return 字典数据集合信息
+     */
+    public List<SysDictData> selectDictDataByType(String dictType);
+
+    /**
+     * 根据字典类型和字典键值查询字典数据信息
+     *
+     * @param dictType  字典类型
+     * @param dictValue 字典键值
+     * @return 字典标签
+     */
+    public String selectDictLabel(@Param("dictType") String dictType, @Param("dictValue") String dictValue);
+
+    /**
+     * 根据字典数据ID查询信息
+     *
+     * @param dictCode 字典数据ID
+     * @return 字典数据
+     */
+    public SysDictData selectDictDataById(Long dictCode);
+
+    /**
+     * 查询字典数据
+     *
+     * @param dictType 字典类型
+     * @return 字典数据
+     */
+    public int countDictDataByType(String dictType);
+
+    /**
+     * 通过字典ID删除字典数据信息
+     *
+     * @param dictCode 字典数据ID
+     * @return 结果
+     */
+    public int deleteDictDataById(Long dictCode);
+
+    /**
+     * 批量删除字典数据信息
+     *
+     * @param dictCodes 需要删除的字典数据ID
+     * @return 结果
+     */
+    public int deleteDictDataByIds(Long[] dictCodes);
+
+    /**
+     * 新增字典数据信息
+     *
+     * @param dictData 字典数据信息
+     * @return 结果
+     */
+    public int insertDictData(SysDictData dictData);
+
+    /**
+     * 修改字典数据信息
+     *
+     * @param dictData 字典数据信息
+     * @return 结果
+     */
+    public int updateDictData(SysDictData dictData);
+
+    /**
+     * 同步修改字典类型
+     *
+     * @param oldDictType 旧字典类型
+     * @param newDictType 新旧字典类型
+     * @return 结果
+     */
+    public int updateDictDataType(@Param("oldDictType") String oldDictType, @Param("newDictType") String newDictType);
+}

+ 72 - 2
vehicle-sdk/src/main/java/com/ozs/controller/upload/GeoHazardMonitorTokenController.java

@@ -35,6 +35,7 @@ import com.ozs.entity.VehiclePosition;
 import com.ozs.entity.BaseVideoTrains;
 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;
@@ -1736,8 +1737,23 @@ public class GeoHazardMonitorTokenController {
                 AjaxResults1 = new AjaxResults(0, "终端编码不能为空");
                 return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
             }
-            if (baseTerminalLogService.save(baseTerminalLog)) {
-                AjaxResults1 = new AjaxResults(1, "ok");
+            BaseTerminal baseTerminal1 = new BaseTerminal();
+            baseTerminal1.setTerminalLatitude(baseTerminalLog.getTerminalLatitude());
+            baseTerminal1.setTerminalLongitude(baseTerminalLog.getTerminalLongitude());
+            baseTerminal1.setStatus(1);
+            LambdaQueryWrapper<BaseTerminal> terminal = new LambdaQueryWrapper<>();
+            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);
+                }else {
+                    AjaxResults1 = new AjaxResults(1, "ok");
+                }
                 return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
             } else {
                 AjaxResults1 = new AjaxResults(0, "新增失败");
@@ -1749,6 +1765,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("1111");
+                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);
+        }
+    }
+
 
     /**
      * 预警信息接口定义