gao.qiang 1 рік тому
батько
коміт
e11dd48cef

+ 3 - 0
business-service/src/main/java/com/ozs/mapper/TerminalHeartbeatLogMapper.java

@@ -5,9 +5,12 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.ozs.entity.TerminalHeartbeatLog;
 import org.apache.ibatis.annotations.Mapper;
 
+import java.util.List;
+
 /**
  * 心跳接口相机记录表 Mapper 接口
  */
 @Mapper
 public interface TerminalHeartbeatLogMapper extends BaseMapper<TerminalHeartbeatLog> {
+    List<TerminalHeartbeatLog> terminalHeartbeatLogList();
 }

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

@@ -3,6 +3,8 @@ package com.ozs.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ozs.entity.TerminalHeartbeatLog;
 
+import java.util.List;
+
 /**
  * 心跳接口相机记录表 服务类
  * @author Administrator
@@ -10,4 +12,6 @@ import com.ozs.entity.TerminalHeartbeatLog;
 public interface TerminalHeartbeatLogService extends IService<TerminalHeartbeatLog> {
 
      void add(String code,String channel);
+
+     List<TerminalHeartbeatLog> terminalHeartbeatLogList();
 }

+ 6 - 0
business-service/src/main/java/com/ozs/service/impl/TerminalHeartbeatLogServiceImpl.java

@@ -9,6 +9,7 @@ import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.util.Date;
+import java.util.List;
 
 /**
  * 心跳接口相机记录表 服务类实现类
@@ -27,4 +28,9 @@ public class TerminalHeartbeatLogServiceImpl extends ServiceImpl<TerminalHeartbe
         terminalHeartbeatLog.setCreateTime(new Date());
         baseMapper.insert(terminalHeartbeatLog);
     }
+
+    @Override
+    public List<TerminalHeartbeatLog> terminalHeartbeatLogList() {
+        return baseMapper.terminalHeartbeatLogList();
+    }
 }

+ 9 - 0
business-service/src/main/resources/mapper/TerminalHeartbeatLogMapper.xml

@@ -2,4 +2,13 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ozs.mapper.TerminalHeartbeatLogMapper">
 
+    <select id="terminalHeartbeatLogList" resultType="com.ozs.entity.TerminalHeartbeatLog">
+        SELECT camera_code
+FROM (
+    SELECT DISTINCT camera_code
+    FROM terminal_heartbeat_log
+    LIMIT 4
+) AS subquery
+ORDER BY camera_code DESC;
+    </select>
 </mapper>

+ 2 - 6
vehicle-admin/src/main/java/com/ozs/web/controller/accountmanagment/BaseCameraManagementController.java

@@ -1033,12 +1033,8 @@ public class BaseCameraManagementController extends BaseController {
 
     @GetMapping(value = "/terminalHeartbeatLog")
     public AjaxResult terminalHeartbeatLog() {
-        TerminalHeartbeatLog terminalHeartbeatLog=new TerminalHeartbeatLog();
-        terminalHeartbeatLog.setId(terminalHeartbeatLogService.count()+1);
-        terminalHeartbeatLog.setCameraCode("111");
-        terminalHeartbeatLog.setCreateTime(new Date());
-        boolean save = terminalHeartbeatLogService.save(terminalHeartbeatLog);
-        return AjaxResult.success(save);
+       List<TerminalHeartbeatLog>  list=terminalHeartbeatLogService.terminalHeartbeatLogList();
+        return AjaxResult.success(list);
     }
 }