feat(hw-rfid): pom、新增RFID业务模块及数据库结构调整

- 在ruoyi-modules中添加hw-rfid模块,并配置相关依赖
- 在ruoyi-admin中新增hw-rfid依赖,支持RFID业务功能接入
- 创建hw-rfid模块pom.xml,整合多项公共依赖模块
- 数据库脚本调整rfid_location表,新增ancestors字段,修改location_type默认值
- 统一rfid_read_record表device_id字段注释,明确为设备id
- 编写RFID.md文档,规范连表查询、前端类型同步和接口设计等开发细节
- 规范主子表删除事务一致性及树形结构父子关系维护逻辑
main
zangch@mesnac.com 3 weeks ago
parent fcaaab147d
commit 883d0e54c4

@ -1,5 +1,54 @@
# 主要展示(其余字段在前端暂时隐藏或注释掉)
- 位置信息:标识、位置编号、位置别名、父级编号、是否标识、备注、创建人、创建时间、更新人、更新时间
- 设备信息:标识、设备编号、设备名称、所在位置、设备地址、设备端口、读取频率、是否标识、备注、创建人、创建时间、更新人、更新时间
- 读取记录:标识、设备编号、读取状态(1-成功;0-失败)、条码信息、记录时间
- **代码注意事项**
1. ** 连表查询规范**
使用 `mybatis-plus`做连表查询时:
- 在实体类和 `VO` 中添加连表字段,实体类字段需加 `@TableField(exist = false)` 注解。
- `MybatisPlus`自带方法不支持连表查询需要在mapper.xml中编写sql语句
2. **types 同步维护**
连表查询得到的字段,需要同步补充到前端 `types.ts` 中,保证类型定义完整。
3. **接口前缀规范**
参考同模块下已有接口前缀,统一后台 `@RequestMapping` 前缀。
4. **前端列表 / 表单字段规范**
- 只展示业务字段,技术字段仅用于内部关联(连表查询得到名称字段),若无关联则隐藏技术字段(前端在 `columns` 中设为 `false`
- 业务字段不显示多余的说明文字,例如字典字段的括号以及括号的字典数据
- 列表不直接展示主键,使用“序号”列(`index`)替代。
- 注释掉不合理的搜索条件,对话框中注释掉不合理的输入字段。
- 数字字段使用数字输入框;
- 新增对话框时,前端激活标识 `isMarked` 默认为 `1`
- 需要绑定其他表字段时,通过下拉框选择,表单字段使用 `get${ClassName}List` 接口获取不分页的全部数据。
5. **主子表 List 字段**
主子表结构时,需要在主表实体中将子表作为 `List` 类型字段,便于提交新增/修改、返回数据和删除时统一处理,保证事务一致性。
6. **字典使用规范**
- 后端只返回字典键值。
- 前端列表通过 `dict-tag` 组件展示字典文本。
- 前端需要显式声明字典,例如:
`const { project_category, change_type, project_phases } = toRefs<any>(proxy?.useDict('project_category', 'change_type', 'project_phases'));`
7. **实体字段类型规范**
- 数据库 `int` → Java `Integer`
- `decimal``BigDecimal`
- `bigint``Long`
- `double``Double`
- `float``Float`
11. **主子表删除规范**
- 主子表删除时,必须在同一事务中同时删除主表与子表记录,保证数据一致性。
12. **接口合并与聚合**
- 前端调用接口应尽量合并:同一模块或同一功能点优先通过单个接口组装返回所需数据,减少多次请求。
13. **前端 columns 配置规则**
- `columns``key` 必须从 `0` 开始,不间断完整自增。
- 对比实际表格列与 `columns` 配置,第 `0` 列使用“序号”(`index` 列)而不是主键。
- 将“项目ID”等技术列从 `columns` 中完全移除(而不是隐藏),去掉租户编号等无业务意义的字段,其他字段根据实际情况调整,确保 `columns.key` 连续从 `0` 自增且与表格实际列一一对应。
14. **名称获取规范**
- 所有创建人名称、部门名称必须通过后端连表查询得到,而不是前端拼接或本地缓存获取。
15. **业务编号规范**
- 业务编号应该唯一。
16. **树形结构规范**
- 树形结构的parent_id和ancestors字段的逻辑需要完善若parent_id和ancestors为0则为顶级节点0是必须有的。
17. **更新子节点的ancestors**
- 更新子节点的ancestors时需要更新所有子节点的ancestors而不是只更新当前节点的ancestors。
18. **前端树形结构的新增或修改**
- 前端对话框第一行必须是先选择父节点!

@ -93,6 +93,13 @@
<artifactId>ruoyi-workflow</artifactId>
</dependency>
<!-- RFID 业务模块 -->
<dependency>
<groupId>org.dromara</groupId>
<artifactId>hw-rfid</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>

@ -0,0 +1,105 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.dromara</groupId>
<artifactId>ruoyi-modules</artifactId>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>hw-rfid</artifactId>
<description>
hw-rfid模块
</description>
<dependencies>
<!-- 通用工具-->
<dependency>
<groupId>org.dromara</groupId>
<artifactId>ruoyi-common-core</artifactId>
</dependency>
<dependency>
<groupId>org.dromara</groupId>
<artifactId>ruoyi-common-doc</artifactId>
</dependency>
<dependency>
<groupId>org.dromara</groupId>
<artifactId>ruoyi-common-mybatis</artifactId>
</dependency>
<dependency>
<groupId>org.dromara</groupId>
<artifactId>ruoyi-common-translation</artifactId>
</dependency>
<!-- OSS功能模块 -->
<dependency>
<groupId>org.dromara</groupId>
<artifactId>ruoyi-common-oss</artifactId>
</dependency>
<dependency>
<groupId>org.dromara</groupId>
<artifactId>ruoyi-common-log</artifactId>
</dependency>
<!-- excel-->
<dependency>
<groupId>org.dromara</groupId>
<artifactId>ruoyi-common-excel</artifactId>
</dependency>
<!-- SMS功能模块 -->
<dependency>
<groupId>org.dromara</groupId>
<artifactId>ruoyi-common-sms</artifactId>
</dependency>
<dependency>
<groupId>org.dromara</groupId>
<artifactId>ruoyi-common-tenant</artifactId>
</dependency>
<dependency>
<groupId>org.dromara</groupId>
<artifactId>ruoyi-common-security</artifactId>
</dependency>
<dependency>
<groupId>org.dromara</groupId>
<artifactId>ruoyi-common-web</artifactId>
</dependency>
<dependency>
<groupId>org.dromara</groupId>
<artifactId>ruoyi-common-idempotent</artifactId>
</dependency>
<dependency>
<groupId>org.dromara</groupId>
<artifactId>ruoyi-common-sensitive</artifactId>
</dependency>
<dependency>
<groupId>org.dromara</groupId>
<artifactId>ruoyi-common-encrypt</artifactId>
</dependency>
<dependency>
<groupId>org.dromara</groupId>
<artifactId>ruoyi-common-websocket</artifactId>
</dependency>
<dependency>
<groupId>org.dromara</groupId>
<artifactId>ruoyi-common-sse</artifactId>
</dependency>
</dependencies>
</project>

@ -15,6 +15,7 @@
<module>ruoyi-job</module>
<module>ruoyi-system</module>
<module>ruoyi-workflow</module>
<module>hw-rfid</module>
</modules>
<artifactId>ruoyi-modules</artifactId>

@ -6,8 +6,9 @@ create table rfid_location (
id bigint(20) not null auto_increment comment '标识',
location_code varchar(64) not null comment '位置编号',
location_alias varchar(128) default null comment '位置别名',
location_type char(1) not null comment '位置类型(1-车间;2-工序;3-工位)',
location_type char(1) default null comment '位置类型(1-车间;2-工序;3-工位)',
parent_id bigint(20) default null comment '父级编号对应本表id',
ancestors varchar(512) default '0' comment '祖级列表',
is_marked char(1) not null default '1' comment '是否标识(1-是;0-否)',
remark varchar(255) default null comment '备注',
created_by varchar(64) default '' comment '创建人',
@ -46,7 +47,7 @@ create table rfid_device (
drop table if exists rfid_read_record;
create table rfid_read_record (
id bigint(20) not null auto_increment comment '标识',
device_id bigint(20) not null comment '设备编号对应rfid_device.id',
device_id bigint(20) not null comment '设备id对应rfid_device.id',
read_status char(1) not null comment '读取状态(1-成功;0-失败)',
barcode varchar(128) not null comment '条码信息',
record_time datetime not null comment '记录时间',

Loading…
Cancel
Save