feat(ops): 巡检表结构新增检查项描述、照片字段并补齐 AUTO_INCREMENT

- ops_inspection_template 新增 item_description 字段(合格标准说明)
- ops_inspection_record 新增 photos 字段 varchar(4096),存储巡检照片 URL
- 三张巡检表 id 补 AUTO_INCREMENT
- 包含建表语句和增量 ALTER 语句

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
lzh
2026-03-22 14:58:55 +08:00
parent f9d0562a49
commit 41e9cb4d4e

View File

@@ -7,9 +7,10 @@
-- ----------------------------
DROP TABLE IF EXISTS `ops_inspection_template`;
CREATE TABLE `ops_inspection_template` (
`id` bigint NOT NULL COMMENT '模板ID',
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '模板ID',
`function_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '功能类型(关联 ops_bus_area.function_type',
`item_title` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '检查项标题',
`item_description` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '检查项描述(合格标准说明)',
`sort_order` int NOT NULL DEFAULT 0 COMMENT '排序序号',
`is_active` bit(1) NOT NULL DEFAULT b'1' COMMENT '是否启用',
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '创建者',
@@ -27,7 +28,7 @@ CREATE TABLE `ops_inspection_template` (
-- ----------------------------
DROP TABLE IF EXISTS `ops_inspection_record`;
CREATE TABLE `ops_inspection_record` (
`id` bigint NOT NULL COMMENT '巡检记录ID',
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '巡检记录ID',
`area_id` bigint NOT NULL COMMENT '区域ID',
`inspector_id` bigint NOT NULL COMMENT '巡检员用户ID',
`is_location_exception` tinyint NOT NULL DEFAULT 0 COMMENT '位置是否异常0正常 1异常',
@@ -38,6 +39,7 @@ CREATE TABLE `ops_inspection_record` (
`attribution_result` tinyint COMMENT '归属判定结果1个人责任 2突发状况 3正常',
`generated_order_id` bigint COMMENT '整改工单ID',
`tags` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '快捷标签JSON数组',
`photos` varchar(4096) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '巡检照片URL列表JSON数组',
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '创建者',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '更新者',
@@ -55,7 +57,7 @@ CREATE TABLE `ops_inspection_record` (
-- ----------------------------
DROP TABLE IF EXISTS `ops_inspection_record_item`;
CREATE TABLE `ops_inspection_record_item` (
`id` bigint NOT NULL COMMENT '明细ID',
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '明细ID',
`record_id` bigint NOT NULL COMMENT '巡检记录ID',
`template_id` bigint NOT NULL COMMENT '模板检查项ID',
`is_passed` bit(1) NOT NULL DEFAULT b'1' COMMENT '是否合格',
@@ -77,3 +79,20 @@ CREATE TABLE `ops_inspection_record_item` (
-- ----------------------------
ALTER TABLE `ops_inspection_record` ADD COLUMN `tags` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '快捷标签JSON数组';
ALTER TABLE `ops_inspection_record_item` ADD COLUMN `tags` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '快捷标签JSON数组';
-- ----------------------------
-- 增量变更:巡检模板新增检查项描述字段
-- ----------------------------
ALTER TABLE `ops_inspection_template` ADD COLUMN `item_description` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '检查项描述(合格标准说明)' AFTER `item_title`;
-- ----------------------------
-- 增量变更:巡检记录新增照片字段
-- ----------------------------
ALTER TABLE `ops_inspection_record` ADD COLUMN `photos` varchar(4096) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '巡检照片URL列表JSON数组';
-- ----------------------------
-- 增量变更:三张表 id 字段补 AUTO_INCREMENT
-- ----------------------------
ALTER TABLE `ops_inspection_template` MODIFY COLUMN `id` bigint NOT NULL AUTO_INCREMENT COMMENT '模板ID';
ALTER TABLE `ops_inspection_record` MODIFY COLUMN `id` bigint NOT NULL AUTO_INCREMENT COMMENT '巡检记录ID';
ALTER TABLE `ops_inspection_record_item` MODIFY COLUMN `id` bigint NOT NULL AUTO_INCREMENT COMMENT '明细ID';