first commit
Some checks failed
Java CI with Maven / build (11) (push) Has been cancelled
Java CI with Maven / build (17) (push) Has been cancelled
Java CI with Maven / build (8) (push) Has been cancelled

This commit is contained in:
lzh
2025-12-31 11:48:19 +08:00
commit 8ccfafe2bb
4541 changed files with 372105 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
spring:
main:
lazy-initialization: true # 开启懒加载,加快速度
banner-mode: off # 单元测试,禁用 Banner
# 数据源配置项
datasource:
name: ruoyi-vue-pro
url: jdbc:h2:mem:testdb;MODE=MYSQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=value; # MODE 使用 MySQL 模式DATABASE_TO_UPPER 配置表和字段使用小写
driver-class-name: org.h2.Driver
username: sa
password:
druid:
async-init: true # 单元测试,异步初始化 Druid 连接池,提升启动速度
initial-size: 1 # 单元测试,配置为 1提升启动速度
sql:
init:
schema-locations: classpath:/sql/create_tables.sql
mybatis-plus:
lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试
type-aliases-package: ${viewsh.info.base-package}.module.*.dal.dataobject
# 日志配置
logging:
level:
com.viewsh.module.iot.service.rule.scene.matcher: DEBUG
com.viewsh.module.iot.service.rule.scene.matcher.IotSceneRuleMatcherManager: INFO
com.viewsh.module.iot.service.rule.scene.matcher.condition: DEBUG
com.viewsh.module.iot.service.rule.scene.matcher.trigger: DEBUG
root: WARN
--- #################### 定时任务相关配置 ####################
--- #################### 配置中心相关配置 ####################
--- #################### 服务保障相关配置 ####################
# Lock4j 配置项(单元测试,禁用 Lock4j
--- #################### 监控相关配置 ####################
--- #################### 芋道相关配置 ####################
# 芋道配置项,设置当前项目所有自定义的配置
viewsh:
info:
base-package: com.viewsh
tenant: # 多租户相关配置项
enable: true
xss:
enable: false
demo: false # 关闭演示模式

View File

@@ -0,0 +1,37 @@
<configuration>
<!-- 引用 Spring Boot 的 logback 基础配置 -->
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
<!-- 控制台输出 -->
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<!-- 设置特定包的日志级别 -->
<logger name="com.viewsh.module.iot.service.rule.scene.matcher" level="DEBUG" additivity="false">
<appender-ref ref="CONSOLE"/>
</logger>
<!-- 设置 IotSceneRuleMatcherManager 的日志级别 -->
<logger name="com.viewsh.module.iot.service.rule.scene.matcher.IotSceneRuleMatcherManager" level="INFO"
additivity="false">
<appender-ref ref="CONSOLE"/>
</logger>
<!-- 设置所有匹配器的日志级别 -->
<logger name="com.viewsh.module.iot.service.rule.scene.matcher.condition" level="DEBUG" additivity="false">
<appender-ref ref="CONSOLE"/>
</logger>
<logger name="com.viewsh.module.iot.service.rule.scene.matcher.trigger" level="DEBUG" additivity="false">
<appender-ref ref="CONSOLE"/>
</logger>
<!-- 根日志级别 -->
<root level="WARN">
<appender-ref ref="CONSOLE"/>
</root>
</configuration>

View File

@@ -0,0 +1,10 @@
DELETE FROM "iot_scene_rule";
DELETE FROM "iot_product";
DELETE FROM "iot_device";
DELETE FROM "iot_thing_model";
DELETE FROM "iot_device_data";
DELETE FROM "iot_alert_config";
DELETE FROM "iot_alert_record";
DELETE FROM "iot_ota_firmware";
DELETE FROM "iot_ota_task";
DELETE FROM "iot_ota_record";

View File

@@ -0,0 +1,182 @@
CREATE TABLE IF NOT EXISTS "iot_scene_rule" (
"id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
"name" varchar(255) NOT NULL DEFAULT '',
"description" varchar(500) DEFAULT NULL,
"status" tinyint NOT NULL DEFAULT '0',
"triggers" text,
"actions" text,
"creator" varchar(64) DEFAULT '',
"create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updater" varchar(64) DEFAULT '',
"update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
"deleted" bit NOT NULL DEFAULT FALSE,
"tenant_id" bigint NOT NULL DEFAULT '0',
PRIMARY KEY ("id")
) COMMENT 'IoT 场景联动规则表';
CREATE TABLE IF NOT EXISTS "iot_product" (
"id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
"name" varchar(255) NOT NULL DEFAULT '',
"product_key" varchar(100) NOT NULL DEFAULT '',
"protocol_type" tinyint NOT NULL DEFAULT '0',
"category_id" bigint DEFAULT NULL,
"description" varchar(500) DEFAULT NULL,
"data_format" tinyint NOT NULL DEFAULT '0',
"device_type" tinyint NOT NULL DEFAULT '0',
"net_type" tinyint NOT NULL DEFAULT '0',
"validate_type" tinyint NOT NULL DEFAULT '0',
"status" tinyint NOT NULL DEFAULT '0',
"creator" varchar(64) DEFAULT '',
"create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updater" varchar(64) DEFAULT '',
"update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
"deleted" bit NOT NULL DEFAULT FALSE,
"tenant_id" bigint NOT NULL DEFAULT '0',
PRIMARY KEY ("id")
) COMMENT 'IoT 产品表';
CREATE TABLE IF NOT EXISTS "iot_device" (
"id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
"device_name" varchar(255) NOT NULL DEFAULT '',
"product_id" bigint NOT NULL,
"device_key" varchar(100) NOT NULL DEFAULT '',
"device_secret" varchar(100) NOT NULL DEFAULT '',
"nickname" varchar(255) DEFAULT NULL,
"status" tinyint NOT NULL DEFAULT '0',
"status_last_update_time" timestamp DEFAULT NULL,
"last_online_time" timestamp DEFAULT NULL,
"last_offline_time" timestamp DEFAULT NULL,
"active_time" timestamp DEFAULT NULL,
"ip" varchar(50) DEFAULT NULL,
"firmware_version" varchar(50) DEFAULT NULL,
"device_type" tinyint NOT NULL DEFAULT '0',
"gateway_id" bigint DEFAULT NULL,
"sub_device_count" int NOT NULL DEFAULT '0',
"creator" varchar(64) DEFAULT '',
"create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updater" varchar(64) DEFAULT '',
"update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
"deleted" bit NOT NULL DEFAULT FALSE,
"tenant_id" bigint NOT NULL DEFAULT '0',
PRIMARY KEY ("id")
) COMMENT 'IoT 设备表';
CREATE TABLE IF NOT EXISTS "iot_thing_model" (
"id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
"product_id" bigint NOT NULL,
"identifier" varchar(100) NOT NULL DEFAULT '',
"name" varchar(255) NOT NULL DEFAULT '',
"description" varchar(500) DEFAULT NULL,
"type" tinyint NOT NULL DEFAULT '1',
"property" text,
"creator" varchar(64) DEFAULT '',
"create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updater" varchar(64) DEFAULT '',
"update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
"deleted" bit NOT NULL DEFAULT FALSE,
"tenant_id" bigint NOT NULL DEFAULT '0',
PRIMARY KEY ("id")
) COMMENT 'IoT 物模型表';
CREATE TABLE IF NOT EXISTS "iot_device_data" (
"id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
"device_id" bigint NOT NULL,
"product_id" bigint NOT NULL,
"identifier" varchar(100) NOT NULL DEFAULT '',
"type" tinyint NOT NULL DEFAULT '1',
"data" text,
"ts" bigint NOT NULL DEFAULT '0',
"create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY ("id")
) COMMENT 'IoT 设备数据表';
CREATE TABLE IF NOT EXISTS "iot_alert_config" (
"id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
"name" varchar(255) NOT NULL DEFAULT '',
"product_id" bigint NOT NULL,
"device_id" bigint DEFAULT NULL,
"rule_id" bigint DEFAULT NULL,
"status" tinyint NOT NULL DEFAULT '0',
"creator" varchar(64) DEFAULT '',
"create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updater" varchar(64) DEFAULT '',
"update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
"deleted" bit NOT NULL DEFAULT FALSE,
"tenant_id" bigint NOT NULL DEFAULT '0',
PRIMARY KEY ("id")
) COMMENT 'IoT 告警配置表';
CREATE TABLE IF NOT EXISTS "iot_alert_record" (
"id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
"alert_config_id" bigint NOT NULL,
"alert_name" varchar(255) NOT NULL DEFAULT '',
"product_id" bigint NOT NULL,
"device_id" bigint DEFAULT NULL,
"rule_id" bigint DEFAULT NULL,
"alert_data" text,
"alert_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
"deal_status" tinyint NOT NULL DEFAULT '0',
"deal_time" timestamp DEFAULT NULL,
"deal_user_id" bigint DEFAULT NULL,
"deal_remark" varchar(500) DEFAULT NULL,
"creator" varchar(64) DEFAULT '',
"create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updater" varchar(64) DEFAULT '',
"update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
"deleted" bit NOT NULL DEFAULT FALSE,
"tenant_id" bigint NOT NULL DEFAULT '0',
PRIMARY KEY ("id")
) COMMENT 'IoT 告警记录表';
CREATE TABLE IF NOT EXISTS "iot_ota_firmware" (
"id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
"name" varchar(255) NOT NULL DEFAULT '',
"product_id" bigint NOT NULL,
"version" varchar(50) NOT NULL DEFAULT '',
"description" varchar(500) DEFAULT NULL,
"file_url" varchar(500) DEFAULT NULL,
"file_size" bigint NOT NULL DEFAULT '0',
"status" tinyint NOT NULL DEFAULT '0',
"creator" varchar(64) DEFAULT '',
"create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updater" varchar(64) DEFAULT '',
"update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
"deleted" bit NOT NULL DEFAULT FALSE,
"tenant_id" bigint NOT NULL DEFAULT '0',
PRIMARY KEY ("id")
) COMMENT 'IoT OTA 固件表';
CREATE TABLE IF NOT EXISTS "iot_ota_task" (
"id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
"name" varchar(255) NOT NULL DEFAULT '',
"firmware_id" bigint NOT NULL,
"product_id" bigint NOT NULL,
"upgrade_type" tinyint NOT NULL DEFAULT '0',
"status" tinyint NOT NULL DEFAULT '0',
"creator" varchar(64) DEFAULT '',
"create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updater" varchar(64) DEFAULT '',
"update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
"deleted" bit NOT NULL DEFAULT FALSE,
"tenant_id" bigint NOT NULL DEFAULT '0',
PRIMARY KEY ("id")
) COMMENT 'IoT OTA 升级任务表';
CREATE TABLE IF NOT EXISTS "iot_ota_record" (
"id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
"task_id" bigint NOT NULL,
"firmware_id" bigint NOT NULL,
"device_id" bigint NOT NULL,
"status" tinyint NOT NULL DEFAULT '0',
"progress" int NOT NULL DEFAULT '0',
"error_msg" varchar(500) DEFAULT NULL,
"start_time" timestamp DEFAULT NULL,
"end_time" timestamp DEFAULT NULL,
"creator" varchar(64) DEFAULT '',
"create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updater" varchar(64) DEFAULT '',
"update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
"deleted" bit NOT NULL DEFAULT FALSE,
"tenant_id" bigint NOT NULL DEFAULT '0',
PRIMARY KEY ("id")
) COMMENT 'IoT OTA 升级记录表';