Browse Source

预警信息接口定义接口开发

gao.qiang 9 months ago
parent
commit
ba3d3ecb5a

+ 53 - 0
business-service/src/main/java/com/ozs/entity/PreAlarm.java

@@ -0,0 +1,53 @@
+package com.ozs.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ozs.common.core.domain.BaseEntity;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @author Administrator
+ * 预警信息
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+public class PreAlarm extends BaseEntity implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键ID
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+    /**
+     * 车号
+     */
+    private Integer  trainId;
+    /**
+     * 预警类型
+     */
+    private Integer  preAlarmType;
+    /**
+     * 预警时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date preAlarmTime;
+    /**
+     * 预警目标个数
+     */
+    private Integer preAlarmNum;
+    /**
+     * 预警目标数据组
+     */
+    private String preAlarmList;
+}

+ 53 - 0
business-service/src/main/java/com/ozs/entity/response/PreAlarmResponse.java

@@ -0,0 +1,53 @@
+package com.ozs.entity.response;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @author Administrator
+ */
+@Data
+public class PreAlarmResponse {
+    /**
+     * 机车号
+     */
+    private Integer trainId;
+    /**
+     * 预警病害类型
+     */
+    private Integer preAlarmType;
+    /**
+     * 预警目标个数
+     */
+    private Integer preAlarmNum;
+    /**
+     * 预警时间
+     */
+    private Long preAlarmTime;
+    /**
+     * 预警目标集合
+     */
+    private List<PreAlarmList> preAlarmList;
+
+
+    @Data
+    public static class  PreAlarmList{
+        /**
+         * 预警目标点类型
+         */
+        private Integer targetType;
+        /**
+         * 预警级别
+         */
+        private Integer level;
+        /**
+         * 目标点离机车的距离
+         */
+        private Integer distance;
+        /**
+         * 预警内容
+         */
+        private String  content;
+    }
+}

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

@@ -1,98 +0,0 @@
-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);
-}

+ 13 - 0
business-service/src/main/java/com/ozs/mapper/PreAlarmMapper.java

@@ -0,0 +1,13 @@
+package com.ozs.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ozs.entity.PreAlarm;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * @author Administrator
+ * 预警信息
+ */
+@Mapper
+public interface PreAlarmMapper extends BaseMapper<PreAlarm> {
+}

+ 11 - 0
business-service/src/main/java/com/ozs/service/PreAlarmService.java

@@ -0,0 +1,11 @@
+package com.ozs.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ozs.entity.PreAlarm;
+
+/**
+ * @author Administrator
+ * 预警信息
+ */
+public interface PreAlarmService extends IService<PreAlarm> {
+}

+ 15 - 0
business-service/src/main/java/com/ozs/service/impl/PreAlarmServiceImpl.java

@@ -0,0 +1,15 @@
+package com.ozs.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ozs.entity.PreAlarm;
+import com.ozs.mapper.PreAlarmMapper;
+import com.ozs.service.PreAlarmService;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author Administrator
+ * 预警信息
+ */
+@Service
+public class PreAlarmServiceImpl extends ServiceImpl<PreAlarmMapper, PreAlarm> implements PreAlarmService {
+}

+ 4 - 0
business-service/src/main/resources/mapper/PreAlarmMapper.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.PreAlarmMapper">
+</mapper>

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

@@ -1,4 +1,4 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?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">
 <!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 namespace="com.ozs.mapper.SkynetHeartbeatLogMapper">
 </mapper>
 </mapper>

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

@@ -25,10 +25,12 @@ import com.ozs.entity.MsgAlarm;
 import com.ozs.entity.MsgAlarmExt;
 import com.ozs.entity.MsgAlarmExt;
 import com.ozs.entity.MsgAlarmFrequency;
 import com.ozs.entity.MsgAlarmFrequency;
 import com.ozs.entity.MsgHeartbeatAlarmMessage;
 import com.ozs.entity.MsgHeartbeatAlarmMessage;
+import com.ozs.entity.PreAlarm;
 import com.ozs.entity.SkynetHeartbeatLog;
 import com.ozs.entity.SkynetHeartbeatLog;
 import com.ozs.entity.SvcAddress;
 import com.ozs.entity.SvcAddress;
 import com.ozs.entity.TerminalIgnoreAlarm;
 import com.ozs.entity.TerminalIgnoreAlarm;
 import com.ozs.entity.VehiclePosition;
 import com.ozs.entity.VehiclePosition;
+import com.ozs.entity.response.PreAlarmResponse;
 import com.ozs.entity.vo.AlarmFilesVo;
 import com.ozs.entity.vo.AlarmFilesVo;
 import com.ozs.entity.vo.AlarmHeartbeatLog;
 import com.ozs.entity.vo.AlarmHeartbeatLog;
 import com.ozs.entity.vo.AlarmInfoVo;
 import com.ozs.entity.vo.AlarmInfoVo;
@@ -61,6 +63,7 @@ import com.ozs.service.BaseVehicleTerminalService;
 import com.ozs.service.MsgAlarmExtService;
 import com.ozs.service.MsgAlarmExtService;
 import com.ozs.service.MsgAlarmFrequencyService;
 import com.ozs.service.MsgAlarmFrequencyService;
 import com.ozs.service.MsgAlarmService;
 import com.ozs.service.MsgAlarmService;
+import com.ozs.service.PreAlarmService;
 import com.ozs.service.SvcAddressService;
 import com.ozs.service.SvcAddressService;
 import com.ozs.service.TerminalIgnoreAlarmService;
 import com.ozs.service.TerminalIgnoreAlarmService;
 import com.ozs.service.VehiclePositionService;
 import com.ozs.service.VehiclePositionService;
@@ -152,6 +155,8 @@ public class GeoHazardMonitorTokenController {
     private ISysDictTypeService dictTypeService;
     private ISysDictTypeService dictTypeService;
     @Resource
     @Resource
     private BaseTerminalLogService baseTerminalLogService;
     private BaseTerminalLogService baseTerminalLogService;
+    @Resource
+    private PreAlarmService preAlarmService;
 
 
     /**
     /**
      * 获取web访问令牌
      * 获取web访问令牌
@@ -1296,6 +1301,82 @@ public class GeoHazardMonitorTokenController {
         }
         }
     }
     }
 
 
+
+    /**
+     * 预警信息接口定义
+     */
+    @PostMapping("/api/preAlarm")
+    public String preAlarm(@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);
+            PreAlarmResponse preAlarmResponse = JSON.parseObject(s, PreAlarmResponse.class);
+            if (ObjectUtils.isEmpty(preAlarmResponse.getTrainId())) {
+                AjaxResults1 = new AjaxResults(0, "机车号不能为空");
+                return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
+            }
+            if (ObjectUtils.isEmpty(preAlarmResponse.getPreAlarmType())) {
+                AjaxResults1 = new AjaxResults(0, "预警病害类型不能为空");
+                return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
+            }
+            if (ObjectUtils.isEmpty(preAlarmResponse.getPreAlarmNum())) {
+                AjaxResults1 = new AjaxResults(0, "预警目标个数不难为空");
+                return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
+            }
+            if (ObjectUtils.isEmpty(preAlarmResponse.getPreAlarmTime())) {
+                AjaxResults1 = new AjaxResults(0, "预警时间不难为空");
+                return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
+            }
+            if (ObjectUtils.isEmpty(preAlarmResponse.getPreAlarmList())) {
+                AjaxResults1 = new AjaxResults(0, "预警目标集合不难为空");
+                return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
+            }
+            for (PreAlarmResponse.PreAlarmList preAlarmList : preAlarmResponse.getPreAlarmList()) {
+                if (ObjectUtils.isEmpty(preAlarmList.getContent())) {
+                    AjaxResults1 = new AjaxResults(0, "预警内容不难为空");
+                    return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
+                }
+                if (ObjectUtils.isEmpty(preAlarmList.getDistance())) {
+                    AjaxResults1 = new AjaxResults(0, "目标点离机车的距离不难为空");
+                    return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
+                }
+                if (ObjectUtils.isEmpty(preAlarmList.getLevel())) {
+                    AjaxResults1 = new AjaxResults(0, "预警级别不难为空");
+                    return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
+                }
+                if (ObjectUtils.isEmpty(preAlarmList.getTargetType())) {
+                    AjaxResults1 = new AjaxResults(0, "预警目标点类型不难为空");
+                    return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
+                }
+            }
+            PreAlarm preAlarm = new PreAlarm();
+            preAlarm.setTrainId(preAlarmResponse.getTrainId());
+            preAlarm.setPreAlarmNum(preAlarmResponse.getPreAlarmNum());
+            preAlarm.setPreAlarmTime(new Date(preAlarmResponse.getPreAlarmTime()));
+            preAlarm.setPreAlarmType(preAlarmResponse.getPreAlarmType());
+            preAlarm.setPreAlarmList(JSON.toJSONString(preAlarmResponse.getPreAlarmList()));
+            if (preAlarmService.save(preAlarm)) {
+                AjaxResults1 = new AjaxResults(1, "ok");
+                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);
+        }
+    }
+
     @GetMapping("/test/{key}")
     @GetMapping("/test/{key}")
     public void test(@PathVariable String key) {
     public void test(@PathVariable String key) {
         String heartbeat = heartbeatUtils.getHeartbeat(key);
         String heartbeat = heartbeatUtils.getHeartbeat(key);