浏览代码

中心端识别程序心跳接口开发

gao.qiang 1 周之前
父节点
当前提交
0fd60950a5

+ 23 - 0
business-service/src/main/java/com/ozs/service/entity/CloudState.java

@@ -0,0 +1,23 @@
+package com.ozs.service.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+@Data
+public class CloudState implements Serializable {
+
+    /**
+     * 主键ID
+     */
+    @TableId(type = IdType.AUTO)
+    private Long id;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+
+}

+ 9 - 0
business-service/src/main/java/com/ozs/service/mapper/CloudStateMapper.java

@@ -0,0 +1,9 @@
+package com.ozs.service.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ozs.service.entity.CloudState;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface CloudStateMapper extends BaseMapper<CloudState> {
+}

+ 7 - 0
business-service/src/main/java/com/ozs/service/service/CloudStateService.java

@@ -0,0 +1,7 @@
+package com.ozs.service.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ozs.service.entity.CloudState;
+
+public interface CloudStateService  extends IService<CloudState> {
+}

+ 14 - 0
business-service/src/main/java/com/ozs/service/service/impl/CloudStateServiceImpl.java

@@ -0,0 +1,14 @@
+package com.ozs.service.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ozs.service.entity.CloudState;
+import com.ozs.service.mapper.CloudStateMapper;
+import com.ozs.service.service.CloudStateService;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author Administrator
+ */
+@Service
+public class CloudStateServiceImpl extends ServiceImpl<CloudStateMapper, CloudState> implements CloudStateService {
+}

+ 34 - 10
hazard-sdk/src/main/java/com/ozs/controller/upload/GeoHazardMonitorTokenController.java

@@ -13,12 +13,7 @@ import com.ozs.common.utils.HttpClientUtil;
 import com.ozs.common.utils.StringUtils;
 import com.ozs.common.utils.http.HttpUtils;
 import com.ozs.common.utils.stateSecrets.SM4Utils;
-import com.ozs.service.entity.BaseCameraManagement;
-import com.ozs.service.entity.BaseDeviceDynamicManagement;
-import com.ozs.service.entity.BaseUser;
-import com.ozs.service.entity.MsgAlarm;
-import com.ozs.service.entity.MsgAlarmFrequency;
-import com.ozs.service.entity.SvcAddress;
+import com.ozs.service.entity.*;
 import com.ozs.service.entity.vo.BaseCameraVO;
 import com.ozs.service.service.*;
 import com.ozs.service.utils.PublishClient;
@@ -32,10 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.ObjectUtils;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
@@ -85,6 +77,8 @@ public class GeoHazardMonitorTokenController {
     private String wsUrl;
     @Value("${base.recordUrl}")
     private String recordUrl;
+    @Autowired
+    private CloudStateService cloudStateService;
 
     /**
      * 获取web访问令牌
@@ -345,6 +339,36 @@ public class GeoHazardMonitorTokenController {
     }
 
 
+    /**
+     * 中心端识别程序心跳接口
+     *
+     * @return
+     */
+    @GetMapping("/cloud/state")
+    public String cloudState(HttpServletRequest request){
+        JSONObject jsonObject = new JSONObject();
+        String token = apiTokenUtils.getGeoHazardMonitorToken(request);
+        log.info("token:{}", token);
+        if (StringUtils.isNotEmpty(token)) {
+            CloudState cloudState = new CloudState();
+            cloudState.setCreateTime(new Date());
+            if (cloudStateService.save(cloudState)){
+                jsonObject.put("resultCode", 1);
+                jsonObject.put("message", "成功");
+                return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), "4370780c9a8c43e5");
+            }else {
+                jsonObject.put("resultCode", 0);
+                jsonObject.put("message", "新增数据失败");
+                return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), "4370780c9a8c43e5");
+            }
+        } else {
+            jsonObject.put("resultCode", 2);
+            jsonObject.put("message", "token验证失败");
+            return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), "4370780c9a8c43e5");
+        }
+    }
+
+
     /**
      * 报警视频回放新
      *