-- 创建今日检查项提交相关表

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for daily_inspection_submission
-- ----------------------------
DROP TABLE IF EXISTS `daily_inspection_submission`;
CREATE TABLE `daily_inspection_submission` (
  `submission_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '提交ID',
  `project_id` bigint(20) NOT NULL COMMENT '项目ID',
  `submission_date` date NOT NULL COMMENT '提交日期',
  `submission_status` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT '0' COMMENT '提交状态：0草稿，1已提交',
  `total_items` int(11) DEFAULT 0 COMMENT '检查项总数',
  `completed_items` int(11) DEFAULT 0 COMMENT '已完成检查项数',
  `submitter` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '提交人',
  `submit_time` datetime(0) DEFAULT NULL COMMENT '提交时间',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '备注',
  `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT '0' COMMENT '删除标志（0代表存在 2代表删除）',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT '' COMMENT '创建者',
  `create_time` datetime(0) DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT '' COMMENT '更新者',
  `update_time` datetime(0) DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`submission_id`) USING BTREE,
  UNIQUE KEY `uk_project_date` (`project_id`, `submission_date`, `del_flag`) USING BTREE COMMENT '项目ID和日期的唯一索引',
  INDEX `idx_project_id` (`project_id`) USING BTREE,
  INDEX `idx_submission_date` (`submission_date`) USING BTREE,
  INDEX `idx_del_flag` (`del_flag`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '今日检查项提交表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for daily_inspection_item
-- ----------------------------
DROP TABLE IF EXISTS `daily_inspection_item`;
CREATE TABLE `daily_inspection_item` (
  `item_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '检查项ID',
  `submission_id` bigint(20) NOT NULL COMMENT '提交ID',
  `template_item_id` bigint(20) DEFAULT NULL COMMENT '模板检查项ID（关联风险管控卡检查项）',
  `item_description` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '检查项描述',
  `check_result` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '检查结果：合格、不合格',
  `sort_order` int(11) DEFAULT 0 COMMENT '排序号',
  `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT '0' COMMENT '删除标志（0代表存在 2代表删除）',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT '' COMMENT '创建者',
  `create_time` datetime(0) DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT '' COMMENT '更新者',
  `update_time` datetime(0) DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`item_id`) USING BTREE,
  INDEX `idx_submission_id` (`submission_id`) USING BTREE,
  INDEX `idx_template_item_id` (`template_item_id`) USING BTREE,
  INDEX `idx_del_flag` (`del_flag`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '今日检查项明细表' ROW_FORMAT = Dynamic;

SET FOREIGN_KEY_CHECKS = 1;
