Files
oneos-backend/yudao-module-asset/sql/mysql/2026-03-13-inspection-tables.sql
kkfluous 1dca703caa feat(asset): add inspection template and record system for vehicle checks
Implement the shared inspection template system backend (Chunk 1) including:
- 4 database tables: template, template_item, record, record_item
- 3 enums: InspectionSourceType, InspectionStatus, InspectionResult
- 4 DO classes, 4 Mapper classes with query methods
- 6 VO classes for request/response
- MapStruct converter for DO/VO conversions
- Template service: CRUD, match by bizType+vehicleType
- Record service: create from template, clone, update items, complete
- 2 REST controllers with permission annotations
- Error codes for inspection and replacement modules

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 10:02:19 +08:00

89 lines
5.2 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- =============================================
-- 验车模板与验车记录表
-- 创建时间: 2026-03-13
-- =============================================
-- 验车模板
CREATE TABLE IF NOT EXISTS `asset_inspection_template` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`code` varchar(50) NOT NULL COMMENT '模板编码',
`name` varchar(100) NOT NULL COMMENT '模板名称',
`biz_type` tinyint NOT NULL COMMENT '业务类型1=备车 2=交车 3=还车)',
`vehicle_type` varchar(50) DEFAULT NULL COMMENT '车辆类型',
`status` tinyint DEFAULT 1 COMMENT '状态0=禁用 1=启用)',
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
`creator` varchar(64) DEFAULT '' COMMENT '创建者',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updater` varchar(64) DEFAULT '' COMMENT '更新者',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='验车模板';
-- 验车模板检查项
CREATE TABLE IF NOT EXISTS `asset_inspection_template_item` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`template_id` bigint NOT NULL COMMENT '模板ID',
`category` varchar(50) NOT NULL COMMENT '分类',
`item_name` varchar(100) NOT NULL COMMENT '检查项名称',
`item_code` varchar(50) NOT NULL COMMENT '检查项编码',
`input_type` varchar(20) DEFAULT 'checkbox' COMMENT '输入类型',
`sort` int DEFAULT 0 COMMENT '排序',
`required` tinyint DEFAULT 1 COMMENT '是否必填0=否 1=是)',
`creator` varchar(64) DEFAULT '' COMMENT '创建者',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updater` varchar(64) DEFAULT '' COMMENT '更新者',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
PRIMARY KEY (`id`),
INDEX `idx_template_id` (`template_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='验车模板检查项';
-- 验车记录
CREATE TABLE IF NOT EXISTS `asset_inspection_record` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`record_code` varchar(50) NOT NULL COMMENT '记录编码',
`template_id` bigint NOT NULL COMMENT '模板ID',
`source_type` tinyint NOT NULL COMMENT '来源类型1=备车 2=交车 3=还车)',
`source_id` bigint NOT NULL COMMENT '来源ID',
`vehicle_id` bigint NOT NULL COMMENT '车辆ID',
`inspector_name` varchar(50) DEFAULT NULL COMMENT '检查人',
`inspection_time` datetime DEFAULT NULL COMMENT '检查时间',
`status` tinyint DEFAULT 0 COMMENT '状态0=待检 1=检查中 2=已完成)',
`overall_result` tinyint DEFAULT NULL COMMENT '总体结果1=通过 2=不通过 3=不适用)',
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
`cloned_from_id` bigint DEFAULT NULL COMMENT '克隆来源记录ID',
`creator` varchar(64) DEFAULT '' COMMENT '创建者',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updater` varchar(64) DEFAULT '' COMMENT '更新者',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
PRIMARY KEY (`id`),
INDEX `idx_vehicle_source` (`vehicle_id`, `source_type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='验车记录';
-- 验车记录检查项
CREATE TABLE IF NOT EXISTS `asset_inspection_record_item` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`record_id` bigint NOT NULL COMMENT '记录ID',
`item_code` varchar(50) NOT NULL COMMENT '检查项编码',
`category` varchar(50) NOT NULL COMMENT '分类',
`item_name` varchar(100) NOT NULL COMMENT '检查项名称',
`input_type` varchar(20) DEFAULT 'checkbox' COMMENT '输入类型',
`result` tinyint DEFAULT NULL COMMENT '检查结果1=通过 2=不通过 3=不适用)',
`value` varchar(200) DEFAULT NULL COMMENT '检查值',
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
`image_urls` varchar(2000) DEFAULT NULL COMMENT '图片URL列表',
`creator` varchar(64) DEFAULT '' COMMENT '创建者',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updater` varchar(64) DEFAULT '' COMMENT '更新者',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
PRIMARY KEY (`id`),
INDEX `idx_record_id` (`record_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='验车记录检查项';