Browse Source

天网相机心跳监测接口定义

gao.qiang 1 year atrás
parent
commit
755fa1d895

+ 60 - 0
business-service/src/main/java/com/ozs/entity/SkynetHeartbeatLog.java

@@ -0,0 +1,60 @@
+package com.ozs.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.ozs.common.annotation.Excel;
+import com.ozs.common.core.domain.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * <p>
+ * 天网相机心跳监测日志表
+ * </p>
+ *
+ * @author ozs
+ * @since 2023-02-17
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+@ApiModel("天网相机心跳监测日志表")
+public class SkynetHeartbeatLog extends BaseEntity implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键ID
+     */
+    private Long id;
+
+    /**
+     * 相机编码
+     */
+    private String cameraCode;
+
+    /**
+     * 线路编码
+     */
+    private String railwayCode;
+    
+
+    /**
+     * 行别(1上行2下行)
+     */
+    private Integer lineDir;
+
+    /**
+     * 监控相机安装里程位置
+     */
+    private Integer installMile;
+   
+}

+ 16 - 0
business-service/src/main/java/com/ozs/entity/vo/SkynetHeartbeatVo.java

@@ -0,0 +1,16 @@
+package com.ozs.entity.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class SkynetHeartbeatVo implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    private Integer installMile;
+    private Integer lineDir;
+    private String railwayCode;
+    private String cameraCode;
+}

+ 19 - 0
business-service/src/main/java/com/ozs/mapper/SkynetHeartbeatLogMapper.java

@@ -0,0 +1,19 @@
+package com.ozs.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ozs.entity.SkynetHeartbeatLog;
+import org.apache.ibatis.annotations.Mapper;
+
+
+/**
+ * <p>
+ * 天网相机心跳监测日志表 Mapper 接口
+ * </p>
+ *
+ * @author ozs
+ * @since 2023-02-17
+ */
+@Mapper
+public interface SkynetHeartbeatLogMapper extends BaseMapper<SkynetHeartbeatLog> {
+    
+}

+ 4 - 0
business-service/src/main/resources/mapper/SkynetHeartbeatLogMapper.xml

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ozs.mapper.SynetHeartbeatLogMapper">
+</mapper>

+ 88 - 5
vehicle-admin/src/main/java/com/ozs/web/controller/sdk/GeoHazardMonitorTokenController.java

@@ -20,6 +20,7 @@ import com.ozs.entity.MsgAlarm;
 import com.ozs.entity.MsgAlarmExt;
 import com.ozs.entity.MsgAlarmFrequency;
 import com.ozs.entity.SvcAddress;
+import com.ozs.entity.SkynetHeartbeatLog;
 import com.ozs.entity.TerminalIgnoreAlarm;
 import com.ozs.entity.VehiclePosition;
 import com.ozs.entity.vo.AlarmFilesVo;
@@ -37,9 +38,10 @@ import com.ozs.entity.vo.RespAlarmList;
 import com.ozs.entity.vo.RespCameraVo;
 import com.ozs.entity.vo.RespGeoHazardMonitorVo;
 import com.ozs.entity.vo.RespHeartbeatVo;
-import com.ozs.entity.vo.RespMsgAlarmVo;
+import com.ozs.entity.vo.SkynetHeartbeatVo;
 import com.ozs.entity.vo.TerminalIgnoreVo;
 import com.ozs.framework.config.ServerConfig;
+import com.ozs.mapper.SkynetHeartbeatLogMapper;
 import com.ozs.service.BaseCameraManagementService;
 import com.ozs.service.BaseRailwayManagementService;
 import com.ozs.service.BaseVehicleTerminalService;
@@ -132,6 +134,8 @@ public class GeoHazardMonitorTokenController {
     private SysUserMapper sysUserMapper;
     @Autowired
     WebSocketCommon webSocketCommon;
+    @Resource
+    private SkynetHeartbeatLogMapper synetHeartbeatLogMapper;
     @Value("${base.env}")
     private String env;
 
@@ -1151,6 +1155,85 @@ public class GeoHazardMonitorTokenController {
         }
     }
 
+
+
+    /**
+     * 天网相机心跳监测接口定义
+     */
+    @PostMapping("/api/skynet/heartbeat")
+    @Transactional
+    public String skynetHeartbeat(@RequestBody ParameterVo parameterVo, HttpServletRequest request) {
+        String token = apiTokenUtils.getGeoHazardMonitorToken(request);
+        log.info("token:{}", token);
+        log.info("parameter:{}", parameterVo);
+        JSONObject jsonObject = new JSONObject();
+        if (StringUtils.isNotEmpty(token)) {
+            String[] split = token.split("-");
+            String key = split[split.length - 1];
+            String s = SM4Utils.decryptData_ECB(parameterVo.getParameter(), key);
+            SkynetHeartbeatVo skynetHeartbeatVo = JSON.parseObject(s, SkynetHeartbeatVo.class);
+            if (ObjectUtils.isEmpty(skynetHeartbeatVo.getRailwayCode())) {
+                jsonObject.put("resultCode", 0);
+                jsonObject.put("message", "失败");
+                jsonObject.put("data", "线路编码不能为空");
+                return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
+            }
+            if (ObjectUtils.isEmpty(skynetHeartbeatVo.getLineDir())) {
+                jsonObject.put("resultCode", 0);
+                jsonObject.put("message", "失败");
+                jsonObject.put("data", "行别不能为空");
+                return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
+            }
+            if (skynetHeartbeatVo.getLineDir() != 1 && skynetHeartbeatVo.getLineDir() != 2) {
+                jsonObject.put("resultCode", 0);
+                jsonObject.put("message", "失败");
+                jsonObject.put("data", "行别填写错误");
+                return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
+            }
+            if (ObjectUtils.isEmpty(skynetHeartbeatVo.getInstallMile())) {
+                jsonObject.put("resultCode", 0);
+                jsonObject.put("message", "失败");
+                jsonObject.put("data", "安装里程位置不能为空");
+                return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
+            }
+            if (!skynetHeartbeatVo.getInstallMile().toString().matches(PATTERNS)) {
+                jsonObject.put("resultCode", 0);
+                jsonObject.put("message", "失败");
+                jsonObject.put("data", "里程位置填写错误,只能填写数字");
+                return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
+            }
+            if (ObjectUtils.isEmpty(skynetHeartbeatVo.getCameraCode())) {
+                jsonObject.put("resultCode", 0);
+                jsonObject.put("message", "失败");
+                jsonObject.put("data", "相机编码不能为空");
+                return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
+            }
+            SkynetHeartbeatLog skynetHeartbeatLog =new SkynetHeartbeatLog();
+            skynetHeartbeatLog.setCameraCode(skynetHeartbeatVo.getCameraCode());
+            skynetHeartbeatLog.setInstallMile(skynetHeartbeatVo.getInstallMile());
+            skynetHeartbeatLog.setRailwayCode(skynetHeartbeatVo.getRailwayCode());
+            skynetHeartbeatLog.setLineDir(skynetHeartbeatVo.getLineDir());
+            if (synetHeartbeatLogMapper.insert(skynetHeartbeatLog)>0){
+                Map<String, Object> map = new HashMap<>();
+                map.put("cameraCode", skynetHeartbeatVo.getCameraCode());
+                jsonObject.put("resultCode", 1);
+                jsonObject.put("message", "ok");
+                jsonObject.put("data", map);
+                return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
+            }else {
+                jsonObject.put("resultCode", 0);
+                jsonObject.put("message", "失败");
+                jsonObject.put("data", "新增失败");
+                return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
+            }
+        } else {
+            jsonObject.put("resultCode", 2);
+            jsonObject.put("message", "失败");
+            jsonObject.put("data", "token验证失败");
+            return JSONObject.toJSONString(jsonObject);
+        }
+    }
+
     @GetMapping("/test/{key}")
     public void test(@PathVariable String key) {
         String heartbeat = heartbeatUtils.getHeartbeat(key);
@@ -1180,10 +1263,10 @@ public class GeoHazardMonitorTokenController {
 
     public static void main(String[] args) {
         JSONObject res = new JSONObject();
-        res.put("alarmId", "42010001541320001115");
-        res.put("releaseTime", 1681200512L);
-        res.put("releaseContent", "已处理");
-        res.put("operator", 1);
+        res.put("railwayCode", "SHTL");
+        res.put("lineDir", 1);
+        res.put("cameraCode", "42010001541320000023");
+        res.put("installMile", 3000);
         String s = SM4Utils.encryptData_ECB(JSONObject.toJSONString(res), "4370780c9a8c43e5");
         System.out.println(s);
     }