From 359f7a1eb37871aeb4f7d0cb044c60d6a1108672 Mon Sep 17 00:00:00 2001 From: zch Date: Sat, 24 May 2025 20:57:15 +0800 Subject: [PATCH] =?UTF-8?q?feat(ems):=20=E6=B7=BB=E5=8A=A0=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E6=8C=87=E5=AE=9A=E8=A1=A8=E6=9C=80=E6=96=B0N?= =?UTF-8?q?=E6=9D=A1=E8=AE=B0=E5=BD=95=E5=8A=9F=E8=83=BD=E5=B9=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E6=95=B0=E6=8D=AE=E5=AD=97=E5=85=B8=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 RecordIotenvInstantMapper 中添加 selectLatestRecordsFromTable 方法 - 在 RecordIotenvInstantMapper.xml 中实现该方法的 SQL 语句 - 在 RuoYiApplication 中启用定时任务调度 - 优化 SysDictTypeMapper.xml 中的字典类型查询 SQL,top(1)是SQL server独有的,现在是TiDB(兼容MySQL) --- os-admin/src/main/java/com/os/RuoYiApplication.java | 2 ++ .../ems/record/mapper/RecordIotenvInstantMapper.java | 9 +++++++++ .../mapper/ems/record/RecordIotenvInstantMapper.xml | 10 ++++++++++ .../main/resources/mapper/system/SysDictTypeMapper.xml | 3 ++- 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/os-admin/src/main/java/com/os/RuoYiApplication.java b/os-admin/src/main/java/com/os/RuoYiApplication.java index 3c55a0c..c38613a 100644 --- a/os-admin/src/main/java/com/os/RuoYiApplication.java +++ b/os-admin/src/main/java/com/os/RuoYiApplication.java @@ -3,6 +3,7 @@ package com.os; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; +import org.springframework.scheduling.annotation.EnableScheduling; /** * 启动程序 @@ -10,6 +11,7 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; * @author ruoyi */ @SpringBootApplication(exclude = { DataSourceAutoConfiguration.class }) +@EnableScheduling public class RuoYiApplication { public static void main(String[] args) diff --git a/os-ems/src/main/java/com/os/ems/record/mapper/RecordIotenvInstantMapper.java b/os-ems/src/main/java/com/os/ems/record/mapper/RecordIotenvInstantMapper.java index 0976cb1..74c3be3 100644 --- a/os-ems/src/main/java/com/os/ems/record/mapper/RecordIotenvInstantMapper.java +++ b/os-ems/src/main/java/com/os/ems/record/mapper/RecordIotenvInstantMapper.java @@ -115,4 +115,13 @@ public interface RecordIotenvInstantMapper */ int countFromTables(@Param("tableNames") List tableNames, @Param("recordIotenvInstant") RecordIotenvInstant recordIotenvInstant); + /** + * 从指定表查询最新的N条记录 + * + * @param tableName 表名 + * @param limit 限制条数 + * @return 记录列表 + */ + public List selectLatestRecordsFromTable(@Param("tableName") String tableName, + @Param("limit") int limit); } diff --git a/os-ems/src/main/resources/mapper/ems/record/RecordIotenvInstantMapper.xml b/os-ems/src/main/resources/mapper/ems/record/RecordIotenvInstantMapper.xml index c6a9404..c4ee1d5 100644 --- a/os-ems/src/main/resources/mapper/ems/record/RecordIotenvInstantMapper.xml +++ b/os-ems/src/main/resources/mapper/ems/record/RecordIotenvInstantMapper.xml @@ -296,4 +296,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ) AS total_count + + + \ No newline at end of file diff --git a/os-system/src/main/resources/mapper/system/SysDictTypeMapper.xml b/os-system/src/main/resources/mapper/system/SysDictTypeMapper.xml index 52e2207..bf0bf48 100644 --- a/os-system/src/main/resources/mapper/system/SysDictTypeMapper.xml +++ b/os-system/src/main/resources/mapper/system/SysDictTypeMapper.xml @@ -58,9 +58,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"