-- ---------------------------------------------------
-- aiot-platform-cloud 保洁工单智能调度系统
-- 数据库表结构设计
-- 版本: v1.0
-- 日期: 2025-01-04
-- ---------------------------------------------------

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for ops_order
-- 通用工单表（支持多业务线）
-- ----------------------------
DROP TABLE IF EXISTS `ops_order`;
CREATE TABLE `ops_order` (
  `id` bigint NOT NULL COMMENT '工单ID',
  `order_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '工单编号（WO202501040001）',
  `order_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '工单类型（CLEAN=保洁/REPAIR=维修/SECURITY=安保/SERVICE=客服）',
  `source_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '来源（TRAFFIC=系统触发/INSPECTION=巡检发现/MANUAL=手动创建/SCHEDULE=定时排班）',
  `title` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '工单标题',
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '工单描述/详情',
  `priority` tinyint NOT NULL DEFAULT 2 COMMENT '优先级（0=P0紧急 1=P1重要 2=P2普通）',
  `status` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'PENDING' COMMENT '工单状态（PENDING待分配/ASSIGNED已分配/ARRIVED已到岗/PAUSED已暂停/COMPLETED已完成/CANCELLED已取消）',
  `area_id` bigint COMMENT '区域ID',
  `location` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '具体位置描述（冗余，便于查询）',
  `urgent_reason` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '加急原因',
  `assignee_id` bigint COMMENT '当前执行人ID',
  `inspector_id` bigint COMMENT '巡检员ID（发起人）',
  `start_time` datetime COMMENT '工单开始时间（ARRIVED状态时间）',
  `end_time` datetime COMMENT '工单结束时间（COMPLETED状态时间）',
  `inspector_accept_time` datetime COMMENT '巡检员验收时间',
  `quality_score` tinyint COMMENT '验收评分（1-5星）',
  `quality_comment` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '���收评语',
  `response_seconds` int COMMENT '响应耗时（秒，派单到接单）',
  `completion_seconds` int COMMENT '完成耗时（秒，接单到完成）',
  `flow_instance_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT 'Flowable流程实例ID（预留）',
  `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 '更新者',
  `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`),
  UNIQUE KEY `uk_order_code` (`order_code`, `deleted`),
  KEY `idx_order_type` (`order_type`),
  KEY `idx_status` (`status`),
  KEY `idx_priority` (`priority`),
  KEY `idx_assignee` (`assignee_id`),
  KEY `idx_area` (`area_id`),
  KEY `idx_create_time` (`create_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='通用工单';

-- ----------------------------
-- Table structure for ops_order_clean_ext
-- 保洁工单扩展表
-- ----------------------------
DROP TABLE IF EXISTS `ops_order_clean_ext`;
CREATE TABLE `ops_order_clean_ext` (
  `id` bigint NOT NULL COMMENT '主键',
  `ops_order_id` bigint NOT NULL COMMENT '工单ID',
  `is_auto` tinyint DEFAULT 1 COMMENT '是否自动工单（1=自动 0=手动）',
  `expected_duration` int COMMENT '预计作业时长（分钟）',
  `arrived_time` datetime COMMENT '实际到岗时间',
  `completed_time` datetime COMMENT '实际完成时间',
  `pause_start_time` datetime COMMENT '暂停开始时间',
  `pause_end_time` datetime COMMENT '暂停结束时间',
  `total_pause_seconds` int DEFAULT 0 COMMENT '累计暂停时长（秒）',
  `cleaning_type` varchar(32) COMMENT '保洁类型（ROUTINE=日常/DEEP=深度/SPOT=点状/EMERGENCY=应急）',
  `difficulty_level` tinyint COMMENT '难度等级（1-5级）',
  `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 '更新者',
  `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`),
  UNIQUE KEY `uk_ops_order_id` (`ops_order_id`, `deleted`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='保洁工单扩展';

-- ----------------------------
-- Table structure for ops_order_event
-- FSM 事件流表（记录所有状态变更）
-- ----------------------------
DROP TABLE IF EXISTS `ops_order_event`;
CREATE TABLE `ops_order_event` (
  `id` bigint NOT NULL COMMENT '事件ID',
  `ops_order_id` bigint NOT NULL COMMENT '工单ID',
  `from_status` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '原状态',
  `to_status` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '新状态',
  `event_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '事件类型（CREATE/ASSIGN/ACCEPT/ARRIVE/PAUSE/RESUME/COMPLETE/CANCEL）',
  `operator_type` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'SYSTEM' COMMENT '操作人类型（SYSTEM=系统/CLEANER=保洁员/INSPECTOR=巡检员）',
  `operator_id` bigint COMMENT '操作人ID',
  `operator_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '操作人姓名（冗余）',
  `event_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '发生时间',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '说明',
  `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 '更新者',
  `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`),
  KEY `idx_ops_order_id` (`ops_order_id`),
  KEY `idx_event_time` (`event_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='FSM 事件流';

-- ----------------------------
-- Table structure for ops_order_dispatch
-- 工单分派决策表
-- ----------------------------
DROP TABLE IF EXISTS `ops_order_dispatch`;
CREATE TABLE `ops_order_dispatch` (
  `id` bigint NOT NULL COMMENT '派单ID',
  `ops_order_id` bigint NOT NULL COMMENT '工单ID',
  `user_id` bigint NOT NULL COMMENT '保洁员用户ID',
  `priority` tinyint COMMENT '优先级（0=P0紧急 1=P1重要 2=P2普通）',
  `dispatch_mode` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '派单模式（NORMAL=普通/SILENT=静默/URGENT=紧急插队）',
  `dispatch_reason` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '派单原因（AUTO=自动派单/INSPECT_URGE=巡检催办/MANUAL=手动指派）',
  `dispatch_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '派单时间',
  `accepted_time` datetime COMMENT '接单时间',
  `response_seconds` int COMMENT '响应耗时（秒）',
  `device_id` bigint COMMENT '工牌设备ID',
  `device_response_time` datetime COMMENT '工牌响应时间（播报/震动）',
  `notification_method` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '通知方式（VOICE_ONLY=仅语音/VIBRATE_ONLY=仅震动/BOTH=语音+震动）',
  `event_message` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '可读日志内容',
  `event_payload` json COMMENT '结构化上下文',
  `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 '更新者',
  `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`),
  KEY `idx_ops_order_id` (`ops_order_id`),
  KEY `idx_user_id` (`user_id`),
  KEY `idx_dispatch_time` (`dispatch_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='工单分派决策';

-- ----------------------------
-- Table structure for ops_order_queue
-- 工单排队队列表
-- ----------------------------
DROP TABLE IF EXISTS `ops_order_queue`;
CREATE TABLE `ops_order_queue` (
  `id` bigint NOT NULL COMMENT '队列ID',
  `user_id` bigint NOT NULL COMMENT '保洁员用户ID',
  `ops_order_id` bigint NOT NULL COMMENT '工单ID',
  `queue_index` int NOT NULL COMMENT '队列顺序（1表示最高优先级）',
  `priority` tinyint NOT NULL DEFAULT 2 COMMENT '优先级（0=P0紧急 1=P1重要 2=P2普通）',
  `queue_status` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'WAITING' COMMENT '队列状态（WAITING=等待中/EXECUTING=执行中/PAUSED=已暂停/CANCELLED=已取消）',
  `enqueue_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '入队时间',
  `dequeue_time` datetime COMMENT '出队时间（工单开始执行）',
  `paused_duration` int DEFAULT 0 COMMENT '累计暂停时长（���）',
  `device_id` bigint COMMENT '工牌设备ID',
  `event_message` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '可读日志内容',
  `event_payload` json COMMENT '结构化上下文',
  `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 '更新者',
  `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`),
  UNIQUE KEY `uk_user_order` (`user_id`, `ops_order_id`, `deleted`),
  KEY `idx_user_priority` (`user_id`, `priority`, `queue_status`),
  KEY `idx_enqueue_time` (`enqueue_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='工单排队队列';

-- ----------------------------
-- Table structure for cleaner_status
-- 保洁员实时状态表
-- ----------------------------
DROP TABLE IF EXISTS `ops_cleaner_status`;
CREATE TABLE `ops_cleaner_status` (
  `id` bigint NOT NULL COMMENT '状态ID',
  `user_id` bigint NOT NULL COMMENT '保洁员用户ID',
  `status` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'IDLE' COMMENT '当前状态（IDLE=空闲/BUSY=忙碌/OFFLINE=离线/PAUSED=暂停）',
  `current_ops_order_id` bigint COMMENT '当前正在执行的工单ID',
  `current_area_id` bigint COMMENT '当前位置区域ID',
  `device_id` bigint COMMENT '工牌设备ID',
  `battery_level` tinyint COMMENT '工牌电量（0-100）',
  `last_heartbeat_time` datetime COMMENT '最后心跳时间',
  `status_change_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '状态变更时间',
  `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 '更新者',
  `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`),
  UNIQUE KEY `uk_user_id` (`user_id`, `deleted`),
  KEY `idx_status` (`status`),
  KEY `idx_area` (`current_area_id`),
  KEY `idx_heartbeat` (`last_heartbeat_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='保洁员实时状态';



-- ----------------------------
-- Table structure for ops_order_clean_log
-- 保洁业务日志表
-- ----------------------------
DROP TABLE IF EXISTS `ops_order_clean_log`;
CREATE TABLE `ops_order_clean_log` (
  `id` bigint NOT NULL COMMENT '日志ID',
  `event_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '事件发生时间',
  `event_level` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'INFO' COMMENT '日志级别（INFO=信息/WARN=警告/ERROR=错误）',
  `event_domain` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '领域（RULE=规则引擎/DISPATCH=调度/BADGE=工牌/BEACON=信标/SYSTEM=系统）',
  `event_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '事件类型',
  `ops_order_id` bigint COMMENT '关联工单ID',
  `area_id` bigint COMMENT '区域ID',
  `cleaner_id` bigint COMMENT '保洁员ID',
  `device_id` bigint COMMENT '设备ID（工牌/信标）',
  `event_message` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '可读日志内容',
  `event_payload` json COMMENT '结构化上下文',
  `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 '更新者',
  `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`),
  KEY `idx_event_time` (`event_time`),
  KEY `idx_ops_order_id` (`ops_order_id`),
  KEY `idx_cleaner_id` (`cleaner_id`),
  KEY `idx_event_domain_type` (`event_domain`, `event_type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='保洁业务日志';

-- ----------------------------
-- Table structure for ops_bus_area
-- 业务区域表（园区/楼栋/楼层/功能区域）
-- ----------------------------
DROP TABLE IF EXISTS `ops_bus_area`;
CREATE TABLE `ops_bus_area` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '区域ID，主键',
  `parent_id` bigint unsigned DEFAULT NULL COMMENT '父级区域ID，用于构建区域树',
  `parent_path` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '父级路径（如：1/2/3，便于查询所有子区域）',
  `area_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '区域名称',
  `area_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '区域业务编码（可选，全局唯一）',
  `area_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '区域层级类型（PARK=园区/BUILDING=楼栋/FLOOR=楼层/FUNCTION=功能区域）',
  `function_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '功能类型（MALE_TOILET=男卫/FEMALE_TOILET=女卫/PUBLIC=公共区/ELEVATOR=电梯厅等）',
  `floor_no` int DEFAULT NULL COMMENT '楼层号（如：2、-1）',
  `cleaning_frequency` int DEFAULT 1 COMMENT '保洁频率（次/天）',
  `standard_duration` int COMMENT '标准保洁时长（分钟）',
  `area_level` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '区域等级（HIGH=高优先级/MEDIUM=中/LOW=低）',
  `is_active` bit(1) NOT NULL DEFAULT b'1' COMMENT '是否启用',
  `sort` int NOT NULL DEFAULT 0 COMMENT '显示排序',
  `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 '更新者',
  `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`),
  UNIQUE KEY `uk_area_code` (`area_code`, `deleted`),
  KEY `idx_parent_id` (`parent_id`),
  KEY `idx_area_type` (`area_type`),
  KEY `idx_floor_no` (`floor_no`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='业务区域';

-- ----------------------------
-- Table structure for ops_cleaner_performance_monthly
-- 保洁员绩效月度汇总表
-- ----------------------------
DROP TABLE IF EXISTS `ops_cleaner_performance_monthly`;
CREATE TABLE `ops_cleaner_performance_monthly` (
  `id` bigint NOT NULL COMMENT '汇总ID',
  `user_id` bigint NOT NULL COMMENT '保洁员用户ID',
  `year_month` varchar(7) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '年月（2025-01）',
  `total_orders` int DEFAULT 0 COMMENT '总工单数',
  `p0_orders` int DEFAULT 0 COMMENT 'P0紧急工单数',
  `p1_orders` int DEFAULT 0 COMMENT 'P1重要工单数',
  `p2_orders` int DEFAULT 0 COMMENT 'P2普通工单数',
  `avg_response_seconds` int COMMENT '平均响应时长（秒）',
  `avg_completion_seconds` int COMMENT '平均完成时长（秒）',
  `avg_quality_score` decimal(3,2) COMMENT '平均质量评分（1-5）',
  `total_work_seconds` bigint DEFAULT 0 COMMENT '总作业时长（秒）',
  `total_pause_seconds` bigint DEFAULT 0 COMMENT '总暂停时长（秒）',
  `attendance_rate` decimal(5,2) COMMENT '出勤率（百分比）',
  `performance_score` decimal(5,2) COMMENT '绩效总分',
  `rank_in_team` int COMMENT '团队排名',
  `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 '更新者',
  `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`),
  UNIQUE KEY `uk_user_month` (`user_id`, `year_month`, `deleted`),
  KEY `idx_performance_score` (`performance_score`),
  KEY `idx_year_month` (`year_month`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='保洁员绩效月度汇总';

SET FOREIGN_KEY_CHECKS = 1;
