-- ---------------------------------------------------------------------------
-- Aegis 示范/模拟数据（在 01-ruoyi、02-quartz、03-aegis 之后执行）
--
-- 【重要】MySQL 官方镜像只在「数据目录为空、首次启动」时执行
-- /docker-entrypoint-initdb.d 下脚本。若你第一次起库时还没有本文件，之后
-- 仅 restart 或加文件后 up，不会自动执行本文件。处理方式二选一：
--   1) docker compose down -v  删除 mysql 卷后  docker compose up  （会重建库并跑 01~04）
--   2) 已有库时手工补导：见 deployment/apply-seed.ps1 或
--      Get-Content deployment/mysql/04-aegis-seed-data.sql -Raw -Encoding UTF8 |
--        docker exec -i mysql mysql -uroot -paegis --default-character-set=utf8mb4
-- ---------------------------------------------------------------------------

SET NAMES utf8mb4;
USE `aegis`;

SET @seed_time := '2026-01-10 10:00:00';

-- =========================
-- 文件、知识库
-- =========================
INSERT INTO `sys_file_info` (
  `id`, `file_path`, `original_name`, `file_size`, `file_type`, `mime_type`, `upload_user_id`, `upload_user_name`, `file_category`, `status`, `download_count`, `remark`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`
) VALUES
(1001, '/profile/upload/2026/01/seed/emergency_law_overview.pdf', '应急管理法规摘要.pdf', 256000, 'pdf', 'application/pdf', 1, '若依', 'document', 'normal', 12, '示范文件', 'admin', @seed_time, 'admin', @seed_time, '0'),
(1002, '/profile/upload/2026/01/seed/response_flow.jpg', '处置流程图.jpg', 89000, 'jpg', 'image/jpeg', 1, '若依', 'image', 'normal', 3, '示范图片', 'admin', @seed_time, 'admin', @seed_time, '0'),
(1003, '/profile/upload/2026/01/seed/checklist.xlsx', '物资盘点表.xlsx', 64000, 'xlsx', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 1, '若依', 'document', 'normal', 5, '示范表格', 'admin', @seed_time, 'admin', @seed_time, '0');

INSERT INTO `knowledge_category` (
  `id`, `name`, `code`, `parent_id`, `sort_order`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `remark`
) VALUES
(1, '法规与政策', 'LAW', 0, 1, '法律法规、政策解读', 'admin', @seed_time, 'admin', @seed_time, '0', '示范分类'),
(2, '处置指引', 'GUIDE', 0, 2, '现场处置与标准作业', 'admin', @seed_time, 'admin', @seed_time, '0', '示范分类'),
(3, '应急预案参考', 'PLAN_REF', 0, 3, '历年预案要点摘录', 'admin', @seed_time, 'admin', @seed_time, '0', '示范分类'),
(4, '交通专题', 'TRAFFIC', 1, 10, '隶属于法规的专题', 'admin', @seed_time, 'admin', @seed_time, '0', '示范子分类');

INSERT INTO `knowledge_document` (
  `id`, `title`, `category_id`, `file_id`, `file_name`, `file_size`, `file_type`, `tags`, `keywords`, `summary`, `view_count`, `download_count`, `is_featured`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `remark`
) VALUES
(1, '生产安全事故应急条例导读', 1, 1001, '应急管理法规摘要.pdf', 256000, 'pdf', '法规,应急,条例', '应急,生产安全,条例', '条文解读与交通领域适用要点。', 128, 8, 1, 'admin', @seed_time, 'admin', @seed_time, '0', '示范文档'),
(2, '多车追尾现场分级处置图', 2, 1002, '处置流程图.jpg', 89000, 'jpg', '交通,追尾,图文', '追尾,分流,警示', '现场布防与分流示意。', 64, 2, 0, 'admin', @seed_time, 'admin', @seed_time, '0', '示范图文'),
(3, '恶劣天气下高速公路封控要点', 3, NULL, NULL, NULL, NULL, '气象,封控,高速', '封控,分流,气象', '简要文字条目（无实体文件亦可搜索）。', 32, 0, 0, 'admin', @seed_time, 'admin', @seed_time, '0', '纯文字条目'),
(4, '突发大客流应急检查表', 2, 1003, '物资盘点表.xlsx', 64000, 'xlsx', '大客流,检查,表格', '客流,检查,物资', '人员、物资、通道三类检查。', 45, 6, 1, 'admin', @seed_time, 'admin', @seed_time, '0', '示范关联表'),
(5, '重点车辆盘查执法程序（节选）', 4, NULL, NULL, NULL, NULL, '执法,盘查', '盘查,执法,重点车', '盘查程序与证据固定注意事项。', 20, 0, 0, 'admin', @seed_time, 'admin', @seed_time, '0', '专题条目');

-- =========================
-- 资源：队伍、专家、仓库、物资、车辆、装备、供应商
-- =========================
INSERT INTO `resource_team` (
  `id`, `team_name`, `team_type`, `belong_org_name`, `belong_org_type`, `external_flag`, `status`, `capabilities`, `contact_person`, `contact_phone`, `contact_address`, `location_name`, `longitude`, `latitude`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `remark`
) VALUES
(1, '市交通综合应急机动队', '综合', '市交通运输局', 'transportation', 'N', 'available', '["rescue","traffic","tow"]', '刘刚', '13800001001', '市府路 1 号', '市应急物资库前坪', 116.4040000, 39.9150000, 'admin', @seed_time, 'admin', @seed_time, '0', '示范'),
(2, '公安交警铁骑一队', '交警', '市公安局交警支队', 'police', 'N', 'busy', '["escort","closure"]', '陈静', '13800001002', '黄兴路 9 号', '高架桥北向匝道口', 116.4120000, 39.9200000, 'admin', @seed_time, 'admin', @seed_time, '0', '示范'),
(3, '医疗院前救护小组 A', '医疗', '市第一人民医院', 'medical', 'Y', 'available', '["triage","first_aid"]', '王晓', '13800001003', '学院路 88 号', '急诊前广场', 116.4000000, 39.9100000, 'admin', @seed_time, 'admin', @seed_time, '0', '示范联动'),
(4, '民间救援志愿队-蓝天', '志愿', '蓝天志愿服务中心', 'company', 'Y', 'offline', '["search","rope"]', '赵力', '13800001004', '郊区产业园 5 栋', '产业园库房', 116.3800000, 39.9000000, 'admin', @seed_time, 'admin', @seed_time, '0', '外协示范');

INSERT INTO `resource_team_member` (
  `id`, `team_id`, `user_id`, `member_name`, `member_code`, `phone`, `position`, `specialty`, `status`, `join_date`, `remark`, `create_by`, `create_time`, `update_by`, `update_time`
) VALUES
(1, 1, 1, '李调度', 'TM-001', '13600002001', '带队', '综合调度', 'active', '2019-03-01', '关联用户 admin', 'admin', @seed_time, 'admin', @seed_time),
(2, 1, 2, '周员工', 'TM-002', '13600002002', '文员', '文书', 'active', '2021-05-20', '关联用户 ry', 'admin', @seed_time, 'admin', @seed_time),
(3, 1, NULL, '赵临聘', 'TM-003', '13600002003', '司机', '大车', 'active', '2022-11-10', '未绑定系统账号', 'admin', @seed_time, 'admin', @seed_time),
(4, 2, NULL, '吴警员', 'PM-001', '13600002004', '铁骑', '路控', 'active', '2018-01-01', '示范成员', 'admin', @seed_time, 'admin', @seed_time);

INSERT INTO `resource_team_log` (
  `id`, `team_id`, `action`, `from_status`, `to_status`, `member_id`, `operator_id`, `operator_name`, `remark`, `created_at`
) VALUES
(1, 1, 'create', NULL, NULL, NULL, 1, '若依', '队伍初始化', '2025-12-20 08:00:00'),
(2, 1, 'member_add', NULL, NULL, 3, 1, '若依', '临聘司机入队', '2025-12-20 08:10:00'),
(3, 2, 'status_change', 'available', 'busy', NULL, 1, '若依', '参加演练占用', '2025-12-25 16:00:00');

INSERT INTO `resource_expert` (
  `id`, `expert_name`, `expert_code`, `organization`, `specialties`, `phone`, `email`, `sys_user_id`, `status`, `rating`, `capabilities`, `location_name`, `longitude`, `latitude`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `remark`
) VALUES
(1, '张高工', 'EXP-2024-0001', '市交通科学研究院', '["emergency_rescue","transportation"]', '13500003001', 'zg@example.com', NULL, 'active', 5, '["review","advisory"]', '市科学院 3 楼', 116.4050000, 39.9150000, 'admin', @seed_time, 'admin', @seed_time, '0', '纯专家账户不绑用户'),
(2, '刘医生', 'EXP-2024-0002', '市急救中心', '["medical_rescue","public_health"]', '13500003002', 'liu@example.com', NULL, 'active', 5, '["triage","training"]', '急救中心', 116.4020000, 39.9120000, 'admin', @seed_time, 'admin', @seed_time, '0', '示范专家'),
(3, '孙高级工程师', 'EXP-2024-0003', '省交通规划院', '["construction","transportation"]', '13500003003', 'sun@example.com', NULL, 'inactive', 4, '["structural","detour"]', '省规划院', 116.4200000, 39.9300000, 'admin', @seed_time, 'admin', @seed_time, '0', '停用状态示范'),
(4, '钱气象', 'EXP-2024-0004', '市气象台', '["meteorology"]', '13500003004', 'qian@example.com', NULL, 'active', 4, '["nowcast"]', '气象台', 116.4000000, 39.9080000, 'admin', @seed_time, 'admin', @seed_time, '0', '示范专家');

INSERT INTO `resource_warehouse` (
  `id`, `warehouse_code`, `warehouse_name`, `warehouse_type`, `belong_org_name`, `belong_org_type`, `address`, `longitude`, `latitude`, `manager`, `contact_phone`, `capacity`, `status`, `remark`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`
) VALUES
(1, 'WH-CENTER-01', '市本级应急物资中心仓', 'emergency', '市应急局', 'emergency', '迎宾路 200 号', 116.4030000, 39.9150000, '马仓库', '13600004001', 5000.00, '0', '示范主仓', 'admin', @seed_time, 'admin', @seed_time, '0'),
(2, 'WH-OUT-02', '东部枢纽临时仓', 'temporary', '市交通局', 'transportation', '东部枢纽 P2 层', 116.4500000, 39.9400000, '杨库', '13600004002', 800.00, '0', '临近高速口', 'admin', @seed_time, 'admin', @seed_time, '0');

INSERT INTO `resource_material_category` (
  `id`, `parent_id`, `ancestors`, `category_code`, `category_name`, `order_num`, `status`, `remark`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`
) VALUES
(1, 0, '0', 'M-CAT-TRAFFIC', '交通专用物资', 1, '0', '示范分类', 'admin', @seed_time, 'admin', @seed_time, '0'),
(2, 0, '0', 'M-CAT-MED', '医疗救护', 2, '0', '示范分类', 'admin', @seed_time, 'admin', @seed_time, '0'),
(3, 1, '0,1', 'M-CAT-TRAFFIC-CONS', '交通-养护材料', 1, '0', '子分类', 'admin', @seed_time, 'admin', @seed_time, '0');

INSERT INTO `resource_material` (
  `id`, `material_code`, `material_name`, `category_id`, `unit`, `spec`, `brand`, `batch_no`, `expire_date`, `reusable`, `recycle_policy`, `sterilize_required`, `threshold`, `locked_qty`, `used_qty`, `remark`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`
) VALUES
(1, 'MAT-TL-0001', '便携式交通锥 70cm', 1, 'piece', '高强度反光', '路安', 'B-2025-10', '2027-10-01', 1, '清洗后归库', 0, 50.00, 5.00, 12.00, '示范', 'admin', @seed_time, 'admin', @seed_time, '0'),
(2, 'MAT-TL-0002', '水马隔离墩', 3, 'piece', '1.2m 注水', '泰通', 'S-2025-08', NULL, 1, '检查后归库', 0, 30.00, 0.00, 0.00, '示范', 'admin', @seed_time, 'admin', @seed_time, '0'),
(3, 'MAT-MED-0001', '户外急救包', 2, 'item', '20 人份', '康护', 'M-2025-12', '2026-12-01', 0, NULL, 1, 5.00, 0.00, 0.00, '示范', 'admin', @seed_time, 'admin', @seed_time, '0'),
(4, 'MAT-POW-0001', '移动照明灯 500W', 1, 'item', '柴汽油两用', '亮能', 'L-2024-11', NULL, 1, '归库', 0, 2.00, 0.00, 0.00, '示范', 'admin', @seed_time, 'admin', @seed_time, '0');

INSERT INTO `resource_material_inventory` (
  `id`, `material_id`, `warehouse_id`, `total_qty`, `available_qty`, `locked_qty`, `used_qty`, `version`, `remark`, `create_by`, `create_time`, `update_by`, `update_time`
) VALUES
(1, 1, 1, 500.00, 470.00, 20.00, 10.00, 1, '市本级', 'admin', @seed_time, 'admin', @seed_time),
(2, 2, 1, 120.00, 100.00, 10.00, 10.00, 1, '市本级', 'admin', @seed_time, 'admin', @seed_time),
(3, 3, 1, 40.00, 30.00, 5.00, 5.00, 1, '市本级', 'admin', @seed_time, 'admin', @seed_time),
(4, 1, 2, 100.00, 95.00, 0.00, 5.00, 1, '东部枢纽', 'admin', @seed_time, 'admin', @seed_time),
(5, 4, 2, 5.00, 5.00, 0.00, 0.00, 1, '临时仓', 'admin', @seed_time, 'admin', @seed_time);

INSERT INTO `resource_material_usage` (
  `id`, `material_id`, `warehouse_id`, `event_id`, `task_id`, `qty`, `action`, `remark`, `created_at`
) VALUES
(1, 1, 1, NULL, NULL, 20.00, 'consume', '演练占用（示范）', '2025-12-28 09:00:00'),
(2, 3, 1, NULL, NULL, 2.00, 'return', '演练归还', '2025-12-28 18:00:00');

INSERT INTO `resource_vehicle` (
  `id`, `vehicle_name`, `plate_no`, `vehicle_type`, `team_id`, `status`, `capabilities`, `device_id`, `device_provider`, `gps_lat`, `gps_lng`, `last_seen_at`, `remark`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`
) VALUES
(1, '综合抢险清障车-01', '京A90001', 'wrecker', 1, 'available', '["tow","lift"]', 'GNSS-0001', 'amap', 39.9150000, 116.4040000, @seed_time, '市机动队', 'admin', @seed_time, 'admin', @seed_time, '0'),
(2, '交警巡逻二轮-12', '京A12012', 'motor', 2, 'busy', '["patrol","closure"]', 'GNSS-0002', 'amap', 39.9200000, 116.4120000, @seed_time, '铁骑', 'admin', @seed_time, 'admin', @seed_time, '0'),
(3, '救护车-07', '京A70707', 'ambulance', 3, 'available', '["first_aid"]', NULL, NULL, 39.9100000, 116.4000000, @seed_time, '院前', 'admin', @seed_time, 'admin', @seed_time, '0'),
(4, '应急指挥面包-03', '京A30003', 'van', 1, 'maintenance', '["command","radio"]', 'GNSS-0004', 'amap', 39.9080000, 116.3980000, '2025-12-10 10:00:00', '维修中示范', 'admin', @seed_time, 'admin', @seed_time, '0');

INSERT INTO `resource_equipment` (
  `id`, `equipment_code`, `equipment_name`, `equipment_type`, `brand`, `model`, `team_id`, `warehouse_id`, `status`, `capabilities`, `purchase_date`, `warranty_date`, `remark`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`
) VALUES
(1, 'EQ-COMM-2001', '宽带自组网基站', 'communication', '中讯', 'B500', 1, 1, 'available', '["mesh","4g"]', '2022-01-10', '2025-12-31', '示范', 'admin', @seed_time, 'admin', @seed_time, '0'),
(2, 'EQ-RS-3002', '液压扩剪器', 'rescue', '天盾', 'HS-2', 1, 1, 'available', '["rescue","vehicle"]', '2020-05-20', '2024-12-01', '示范', 'admin', @seed_time, 'admin', @seed_time, '0'),
(3, 'EQ-MON-1003', '有毒气体检测仪', 'monitoring', '理研', 'GX-8000', NULL, 2, 'available', '["h2s","co"]', '2021-11-11', '2025-11-11', '枢纽备用', 'admin', @seed_time, 'admin', @seed_time, '0');

INSERT INTO `resource_equipment_log` (
  `id`, `equipment_id`, `action`, `from_status`, `to_status`, `dispatch_id`, `event_id`, `operator_id`, `operator_name`, `created_at`, `remark`
) VALUES
(1, 1, 'assign', 'available', 'busy', NULL, NULL, 1, '若依', '2025-12-20 10:00:00', '演练占用'),
(2, 1, 'release', 'busy', 'available', NULL, NULL, 1, '若依', '2025-12-20 20:00:00', '演练释放');

INSERT INTO `resource_supplier` (
  `id`, `supplier_code`, `supplier_name`, `credit_code`, `category`, `area`, `contact_person`, `contact_phone`, `email`, `address`, `status`, `rating`, `remark`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`
) VALUES
(1, 'SUP-2018-0001', '远大交通设施有限公司', '91110000MA0XXXX1', 'material', 'east', '刘明', '13700005001', 'liu@yunda.cn', '浦东产业园 8 栋', 'active', 5, '主供水马/锥桶', 'admin', @seed_time, 'admin', @seed_time, '0'),
(2, 'SUP-2020-2002', '众成医疗物资供应', '91110000MA0XXXX2', 'material', 'central', '费芳', '13700005002', 'f@zc-med.cn', '高新区 66 号', 'active', 4, '急救物资', 'admin', @seed_time, 'admin', @seed_time, '0'),
(3, 'SUP-2015-0003', '鹏飞特种车辆维保', '91110000MA0XXXX3', 'service', 'south', '吴鹏', '13700005003', 'peng@pftc.cn', '产业园 3 仓', 'blacklisted', 1, '黑名单示范', 'admin', @seed_time, 'admin', @seed_time, '0');

INSERT INTO `resource_supplier_license` (
  `id`, `supplier_id`, `license_type`, `license_no`, `issuing_authority`, `valid_from`, `valid_to`, `attachment_url`, `remark`, `create_by`, `create_time`, `update_by`, `update_time`
) VALUES
(1, 1, '行业经营许可', 'JYXK-2019-0001', '市场监管', '2019-01-01', '2029-12-31', '1001', '示范资质', 'admin', @seed_time, 'admin', @seed_time),
(2, 2, '医疗器械经营', 'YJXK-2020-2002', '市药监', '2020-01-10', '2025-12-30', '1001', '示范', 'admin', @seed_time, 'admin', @seed_time);

-- 摄影机（页面列表；URL 不指向真实流）
INSERT INTO `camera` (
  `id`, `camera_code`, `camera_name`, `protocol`, `org_name`, `longitude`, `latitude`, `address`, `status`, `extra_config`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`, `del_flag`
) VALUES
(1, 'CAM-GAOJIA-01', 'G4 西段 上行 K12+200', 'rtsp', '高速养护一中心', 116.3900000, 39.9050000, 'G4 西段 K12+200', 'online', '{"zlm":true,"mock":true}', 'admin', @seed_time, 'admin', @seed_time, '示范', '0'),
(2, 'CAM-GAOJIA-02', 'G4 西段 下行 枢纽 C 口', 'rtsp', '高速养护一中心', 116.4480000, 39.9370000, '枢纽 C 口', 'online', NULL, 'admin', @seed_time, 'admin', @seed_time, '示范', '0'),
(3, 'CAM-CITY-1003', '迎宾大道与学院路交叉口', 'gb28181', '市交警', 116.4020000, 39.9110000, '路口杆件', 'offline', NULL, 'admin', @seed_time, 'admin', @seed_time, '离线示范', '0'),
(4, 'CAM-IND-2004', '产业园 3 号库外', 'onvif', '园区物业', 116.3820000, 39.9020000, '库外枪机', 'online', NULL, 'admin', @seed_time, 'admin', @seed_time, '示范', '0');

-- =========================
-- 应急预案
-- =========================
INSERT INTO `plan` (
  `id`, `plan_no`, `plan_name`, `plan_type`, `event_type`, `event_level`, `version`, `status`, `is_current`, `description`, `creator_id`, `approver_id`, `approval_time`, `publish_time`, `usage_count`, `last_used_at`, `average_rating`, `referenced_workbench`, `last_feedback_summary`, `change_log`, `remark`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`
) VALUES
(1, 'PLAN-TRAFFIC-MA-01', '高速公路多车连环追尾专项预案 v1.0', 'special', 'traffic_accident', 'II', '1.0.0', 'published', 1, '针对冬季大雾/结冰条件下的分流与清障。', 1, 1, '2025-10-20 10:00:00', '2025-10-20 10:10:00', 6, '2025-12-20 11:00:00', 4.50, 'dispatch', '实战中分流措施有效。', '首版。', '示范', 'admin', @seed_time, 'admin', @seed_time, '0'),
(2, 'PLAN-OV-2024', '市级综合应急总体预案 2024', 'overall', 'other', 'I', '2024-1', 'approving', 0, '总体原则与指挥体系。', 1, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, '待审。', '草稿流', 'admin', @seed_time, 'admin', @seed_time, '0');

INSERT INTO `plan_approval` (
  `id`, `plan_id`, `approver_id`, `approver_name`, `approval_status`, `approval_comment`, `approval_time`, `approval_order`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`
) VALUES
(1, 1, 1, '若依', 'approved', '原则同意。', '2025-10-20 10:00:00', 1, 'admin', @seed_time, 'admin', @seed_time, '0');

INSERT INTO `plan_version` (
  `id`, `plan_id`, `version`, `parent_plan_id`, `change_log`, `snapshot`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `remark`
) VALUES
(1, 1, '1.0.0', NULL, '建档。', NULL, 'admin', @seed_time, 'admin', @seed_time, '0', '示范版本');

INSERT INTO `plan_participant` (
  `id`, `plan_id`, `participant_type`, `reference_team_id`, `reference_member_id`, `reference_expert_id`, `display_name`, `role`, `contact_snapshot`, `sort_order`, `remark`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`
) VALUES
(1, 1, 'EXPERT', NULL, NULL, 1, '专家：张高工', '技术顾问', '{"phone":"13500003001"}', 1, '示范', 'admin', @seed_time, 'admin', @seed_time, '0'),
(2, 1, 'TEAM_MEMBER', 1, 1, NULL, '刘刚-机动队', '现场牵头', '{"phone":"13600002001"}', 2, '示范', 'admin', @seed_time, 'admin', @seed_time, '0'),
(3, 1, 'EXPERT', NULL, NULL, 2, '刘医生-院前', '医疗', NULL, 3, '示范', 'admin', @seed_time, 'admin', @seed_time, '0');

INSERT INTO `plan_step` (
  `id`, `plan_id`, `step_name`, `step_order`, `description`, `suggested_participant_id`, `estimated_duration`, `remark`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`
) VALUES
(1, 1, '设置上游预警与分流', 1, '锥桶、可变情报板、临时标志。', 2, 30, NULL, 'admin', @seed_time, 'admin', @seed_time, '0'),
(2, 1, '联合勘验与人员转移', 2, '路政+交警+医疗同步到场。', 3, 60, NULL, 'admin', @seed_time, 'admin', @seed_time, '0'),
(3, 1, '清障与通车评估', 3, '清障车、吊车、路面检测。', 1, 90, NULL, 'admin', @seed_time, 'admin', @seed_time, '0');

INSERT INTO `plan_step_resource` (
  `id`, `plan_id`, `step_id`, `resource_type`, `resource_ref_id`, `suggested_quantity`, `required`, `usage_note`, `remark`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`
) VALUES
(1, 1, 1, 'material', 1, 200, 1, '以双向布设计', '示范', 'admin', @seed_time, 'admin', @seed_time, '0'),
(2, 1, 3, 'vehicle', 1, 2, 1, '大车+小型清障', '示范', 'admin', @seed_time, 'admin', @seed_time, '0'),
(3, 1, 2, 'equipment', 1, 1, 0, '通信保障', '示范', 'admin', @seed_time, 'admin', @seed_time, '0');

-- =========================
-- 采购、征用
-- =========================
INSERT INTO `resource_procurement` (
  `id`, `procurement_no`, `title`, `urgency`, `status`, `awarded_supplier_id`, `awarded_at`, `approver_id`, `approver_name`, `approved_at`, `approval_comment`, `remark`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`
) VALUES
(1, 'PRC-2026-0001', '增配冬季防滑沙与水马', 'normal', 'received', 1, '2025-12-10 11:00:00', 1, '若依', '2025-12-05 10:00:00', '同意。', '示范采购', 'admin', @seed_time, 'admin', @seed_time, '0'),
(2, 'PRC-2026-0002', '加购户外急救包补库', 'urgent', 'in_progress', NULL, NULL, NULL, NULL, NULL, NULL, '在途', 'admin', @seed_time, 'admin', @seed_time, '0');

INSERT INTO `resource_procurement_item` (
  `id`, `procurement_id`, `category`, `spec`, `qty`, `unit`, `is_reusable`, `target_material_id`, `remark`, `create_by`, `create_time`, `update_by`, `update_time`
) VALUES
(1, 1, 'material', '水马 1.2m', 200.00, 'piece', 1, 2, '到货到 WH', 'admin', @seed_time, 'admin', @seed_time),
(2, 2, 'material', '急救包 20 人份', 20.00, 'item', 0, 3, '到货待验', 'admin', @seed_time, 'admin', @seed_time);

INSERT INTO `resource_procurement_quote` (
  `id`, `procurement_id`, `supplier_id`, `total_price`, `eta`, `note`, `is_awarded`, `create_by`, `create_time`, `update_by`, `update_time`
) VALUES
(1, 1, 1, 88000.00, '3 天内', '含搬运。', 1, 'admin', @seed_time, 'admin', @seed_time),
(2, 1, 2, 92000.00, '5 天内', '单价高。', 0, 'admin', @seed_time, 'admin', @seed_time),
(3, 2, 2, 30000.00, '1 周内', '医用耗材专供。', 0, 'admin', @seed_time, 'admin', @seed_time);

INSERT INTO `resource_requisition` (
  `id`, `team_id`, `requisition_no`, `reason`, `status`, `start_at`, `end_at`, `approver_id`, `approver_name`, `approved_at`, `approval_comment`, `remark`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`
) VALUES
(1, 4, 'REQ-2026-0001', '大型演练保障', 'ended', '2025-12-20 08:00:00', '2025-12-20 20:00:00', 1, '若依', '2025-12-18 09:00:00', '已协调。', '示范', 'admin', @seed_time, 'admin', @seed_time, '0'),
(2, 1, 'REQ-2026-0002', '实战占用（跨夜）', 'active', '2026-01-10 00:00:00', '2026-01-10 12:00:00', 1, '若依', '2026-01-09 20:00:00', '同意。', '进行中', 'admin', @seed_time, 'admin', @seed_time, '0');

INSERT INTO `resource_requisition_agreement` (
  `id`, `requisition_id`, `service_scope`, `billing_type`, `unit_price`, `currency`, `effective_from`, `effective_to`, `terms`, `attachment_url`, `remark`, `create_by`, `create_time`, `update_by`, `update_time`
) VALUES
(1, 1, '12 小时内人员+装备', 'day', 8000.00, 'CNY', '2025-12-20 00:00:00', '2025-12-20 23:59:00', '按实结算。', '1001', '示范', 'admin', @seed_time, 'admin', @seed_time);

INSERT INTO `resource_requisition_compensation` (
  `id`, `requisition_id`, `workload`, `workload_unit`, `unit_price`, `amount`, `currency`, `invoice_no`, `paid_at`, `status`, `remark`, `create_by`, `create_time`, `update_by`, `update_time`
) VALUES
(1, 1, 1.00, 'day', 8000.00, 8000.00, 'CNY', 'INV-2025-9901', '2025-12-25 10:00:00', 'settled', '已结。', 'admin', @seed_time, 'admin', @seed_time);

-- =========================
-- 排班
-- =========================
INSERT INTO `duty_shift` (
  `id`, `shift_date`, `shift_type`, `start_time`, `end_time`, `status`, `remark`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`
) VALUES
(1, '2026-01-10', 'day', '08:00:00', '20:00:00', 'active', '白班示范', 'admin', @seed_time, 'admin', @seed_time, '0'),
(2, '2026-01-10', 'night', '20:00:00', '08:00:00', 'active', '夜班示范', 'admin', @seed_time, 'admin', @seed_time, '0'),
(3, '2026-01-11', 'all', '00:00:00', '23:59:00', 'active', '周六全天', 'admin', @seed_time, 'admin', @seed_time, '0'),
(4, '2025-12-15', 'day', '08:00:00', '20:00:00', 'cancelled', '临时取消', 'admin', @seed_time, 'admin', @seed_time, '0');

INSERT INTO `duty_shift_member` (
  `id`, `shift_id`, `user_id`, `role`, `phone`, `check_in_time`, `check_out_time`, `remark`, `create_by`, `create_time`, `update_by`, `update_time`
) VALUES
(1, 1, 1, 'leader', '15888888888', '2026-01-10 08:00:00', '2026-01-10 20:00:00', 'admin 值班', 'admin', @seed_time, 'admin', @seed_time),
(2, 1, 2, 'member', '15666666666', '2026-01-10 08:05:00', NULL, '成员', 'admin', @seed_time, 'admin', @seed_time),
(3, 2, 1, 'leader', '15888888888', NULL, NULL, '待签到', 'admin', @seed_time, 'admin', @seed_time);

-- =========================
-- 警情 -> 事件（带一条接警转化）
-- =========================
INSERT INTO `duty_alert` (
  `id`, `alert_no`, `source_channel`, `caller_number`, `source_ext_info`, `summary`, `initial_level`, `status`, `occurred_at`, `location`, `longitude`, `latitude`, `remark`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`
) VALUES
(1, 'ALR-2026-0001', '122', '13800006001', NULL, '大雾天 G4 西段 上行多车追撞，占两条行车道。', 'level2', 'reviewed', '2026-01-08 06:20:00', 'G4 西段 上行 K12+200 附近', 116.3900000, 39.9050000, '审核通过转办。', 'admin', @seed_time, 'admin', @seed_time, '0'),
(2, 'ALR-2026-0002', '12345', '13900006002', NULL, '群众举报枢纽匝道口违停占压。', 'level3', 'pending_review', '2026-01-15 10:00:00', '东部枢纽 C 口汇入', 116.4480000, 39.9370000, '待审。', 'admin', @seed_time, 'admin', @seed_time, '0'),
(3, 'ALR-2026-0003', 'monitor', NULL, '{"dev":"CAM-GAOJIA-01"}', '摄像机触发占道预警。', 'level4', 'transferred', '2026-01-15 10:20:00', '迎宾大道路口', 116.4020000, 39.9110000, '已转警。', 'admin', @seed_time, 'admin', @seed_time, '0'),
(4, 'ALR-2026-0004', '110', '13700006004', NULL, '交通事故有人员受伤，正送往医院。', 'level2', 'closed', '2025-12-20 19:00:00', '学院路 88 号 门前', 116.4000000, 39.9100000, '已归档。', 'admin', @seed_time, 'admin', @seed_time, '0');

INSERT INTO `duty_alert_log` (
  `id`, `alert_id`, `action`, `payload`, `operator_id`, `operator_name`, `created_at`, `create_by`, `update_by`, `remark`, `update_time`
) VALUES
(1, 1, 'alert_create', '{}', 1, '若依', '2026-01-08 06:21:00', 'admin', 'admin', '接警建档', @seed_time),
(2, 1, 'alert_review_approve', '{"r":"ok"}', 1, '若依', '2026-01-08 06:30:00', 'admin', 'admin', '审核通过', @seed_time),
(3, 2, 'alert_create', '{}', 1, '若依', '2026-01-15 10:00:00', 'admin', 'admin', '12345 导入', @seed_time);

INSERT INTO `duty_alert_transfer` (
  `id`, `alert_id`, `target_org`, `contact`, `mobile`, `transfer_desc`, `transfer_time`, `feedback`, `feedback_time`, `status`, `remark`, `create_by`, `create_time`, `update_by`, `update_time`
) VALUES
(1, 3, '属地交警大队 一中队', '林队', '13900007001', '占道拖移与临管。', '2026-01-15 10:30:00', '已到场，拖移 2 台。', '2026-01-15 10:50:00', 'processed', '转办回执。', 'admin', @seed_time, 'admin', @seed_time);

-- 转化记录（先建事件 1 再写关联，见下方 UPDATE）
INSERT INTO `duty_alert_convert` (
  `id`, `alert_id`, `event_id`, `convert_time`, `convert_reason`, `operator_id`, `operator_name`, `review_required`, `review_status`, `remark`, `create_by`, `create_time`, `update_by`, `update_time`
) VALUES
(1, 1, NULL, '2026-01-08 07:00:00', '符合突发交通事件上报标准。', 1, '若依', 0, 'none', '转事立案', 'admin', @seed_time, 'admin', @seed_time);

INSERT INTO `event` (
  `id`, `event_no`, `title`, `type`, `level`, `status`, `important_flag`, `important_by`, `important_time`, `occurred_at`, `location`, `longitude`, `latitude`, `source`, `alert_id`, `summary`, `remark`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`
) VALUES
(1, 'EVT-2026-0001', 'G4 西段 上行多车追尾占道', 'traffic_accident', 'II', 'processing', 1, 'admin', '2026-01-08 07:00:00', '2026-01-08 06:20:00', 'G4 西段 上行 K12+200 附近', 116.3900000, 39.9050000, 'alert', 1, '5 台车、人员 2 轻伤，两行车道受阻。', '多车示范', 'admin', @seed_time, 'admin', @seed_time, '0'),
(2, 'EVT-2025-1002', '东部枢纽 道路结冰 预防性作业', 'natural_disaster', 'III', 'completed', 0, NULL, NULL, '2025-12-25 00:00:00', '东部枢纽上下匝道', 116.4480000, 39.9370000, 'manual', NULL, '扫雪除冰与导向完成。', '归档', 'admin', @seed_time, 'admin', @seed_time, '0'),
(3, 'EVT-2026-0003', '节前客运 大客流 演练（桌面）', 'other', 'IV', 'draft', 0, NULL, NULL, '2026-01-12 14:00:00', '指挥中心会议室', 116.4040000, 39.9150000, 'manual', NULL, '纸上推演+席位抽检。', '草稿', 'admin', @seed_time, 'admin', @seed_time, '0');

-- 回填转化记录中的 event_id
UPDATE `duty_alert_convert` SET `event_id` = 1 WHERE `id` = 1;
UPDATE `duty_alert` SET `status` = 'converted' WHERE `id` = 1;

INSERT INTO `event_log` (
  `id`, `event_id`, `action`, `payload`, `operator_id`, `operator_name`, `created_at`
) VALUES
(1, 1, 'event_created', '{}', 1, '若依', '2026-01-08 07:01:00'),
(2, 1, 'status_changed', '{"to":"processing"}', 1, '若依', '2026-01-08 07:10:00'),
(3, 2, 'report_submitted', '{}', 1, '若依', '2025-12-26 09:00:00');

-- =========================
-- 上报模板与省厅上报
-- =========================
INSERT INTO `report_template` (
  `id`, `name`, `description`, `fields`, `del_flag`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`
) VALUES
(1, '省厅交通突发-首次', '公路交通突发的首次上报。', CAST('{"groups":[{"name":"情况概述","fields":[{"key":"time","label":"事发时刻","type":"text"},{"key":"place","label":"地点","type":"text"},{"key":"vehicles","label":"涉车台数","type":"number"}]}]}' AS JSON), '0', 'admin', @seed_time, 'admin', @seed_time, '示范'),
(2, '续报简要', '续报使用。', CAST('{"rows":["伤情","通车"]}' AS JSON), '0', 'admin', @seed_time, 'admin', @seed_time, '示范二');

INSERT INTO `event_province_report` (
  `id`, `event_id`, `template_id`, `report_type`, `report_sequence`, `fields`, `status`, `request_payload`, `response_payload`, `retry_count`, `error_message`, `remark`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`
) VALUES
(1, 1, 1, 'initial', 1, CAST('{"time":"2026-01-08T06:20:00+08:00","place":"G4西段K12+200上","vehicles":5}' AS JSON), 'success', CAST('{"mock":true}' AS JSON), CAST('{"code":0}' AS JSON), 0, NULL, '测通过', 'admin', @seed_time, 'admin', @seed_time, '0'),
(2, 1, 1, 'followup', 2, CAST('{"通车":"半幅"}' AS JSON), 'failed', NULL, NULL, 2, '连线超时', '重试示范', 'admin', @seed_time, 'admin', @seed_time, '0');

-- =========================
-- 调度任务
-- =========================
INSERT INTO `dispatch_task` (
  `id`, `task_no`, `event_id`, `name`, `status`, `plan_template_id`, `description`, `assignee_id`, `remark`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`
) VALUES
(1, 'DSP-2026-0001', 1, '「0108」西段清障通车 调度专项', 'in_progress', 1, '以预案 1 为主模板。', 1, '示范', 'admin', @seed_time, 'admin', @seed_time, '0'),
(2, 'DSP-2025-9001', 2, '枢纽防冰 保障', 'closed', NULL, '历史。', 1, '归档', 'admin', @seed_time, 'admin', @seed_time, '0');

INSERT INTO `dispatch_task_participant` (
  `id`, `task_id`, `person_id`, `team_id`, `person_snapshot`, `remark`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`
) VALUES
(1, 1, 1, 1, JSON_OBJECT('name','李调度','phone','13600002001'), '队伍 1-李', 'admin', @seed_time, 'admin', @seed_time, '0'),
(2, 1, NULL, 2, NULL, '交警铁骑到场。', 'admin', @seed_time, 'admin', @seed_time, '0'),
(3, 2, NULL, 1, NULL, '已完成', 'admin', @seed_time, 'admin', @seed_time, '0');

INSERT INTO `dispatch_task_step` (
  `id`, `task_id`, `step_order`, `title`, `description`, `status`, `executor_id`, `remark`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`
) VALUES
(1, 1, 1, '上游分流水马', 'K10-K14 布放。', 'completed', 1, NULL, 'admin', @seed_time, 'admin', @seed_time, '0'),
(2, 1, 2, '双向清障', '含拖移与路面。', 'in_progress', 1, NULL, 'admin', @seed_time, 'admin', @seed_time, '0'),
(3, 1, 3, '全线通车评估', '交警解除管制。', 'pending', 2, NULL, 'admin', @seed_time, 'admin', @seed_time, '0'),
(4, 2, 1, '完成除冰作业', NULL, 'completed', 3, NULL, 'admin', @seed_time, 'admin', @seed_time, '0');

INSERT INTO `dispatch_task_disposal` (
  `id`, `task_id`, `step_id`, `participant_id`, `description`, `outcome`, `attachment_ids`, `location_snapshot`, `remark`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`
) VALUES
(1, 1, 1, 1, '完成水马 80 公尺布放，情报板内容下发。', 'success', '[1002]', NULL, '附流程图', 'admin', @seed_time, 'admin', @seed_time, '0'),
(2, 1, 2, 1, '一辆中型货车拖移中。', 'partial', NULL, JSON_OBJECT('lat',39.9050,'lng',116.39), '仍在作业', 'admin', @seed_time, 'admin', @seed_time, '0');

INSERT INTO `dispatch_task_log` (
  `id`, `task_id`, `action`, `payload`, `operator_id`, `operator_name`, `create_time`
) VALUES
(1, 1, 'task_created', '{}', 1, '若依', '2026-01-08 07:20:00'),
(2, 1, 'step_progress', JSON_OBJECT('step',2), 1, '若依', '2026-01-08 08:00:00');

INSERT INTO `dispatch_resource_usage_link` (
  `id`, `task_id`, `step_id`, `resource_type`, `resource_id`, `usage_record_id`, `status`, `note`, `remark`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`
) VALUES
(1, 1, 1, 'material', 1, 1, 'done', '消耗 20 锥', '关联行 1 物资流水', 'admin', @seed_time, 'admin', @seed_time, '0'),
(2, 1, 2, 'vehicle', 1, NULL, 'busy', '清障 01 在点。', '示范', 'admin', @seed_time, 'admin', @seed_time, '0');

INSERT INTO `plan_usage` (
  `id`, `plan_id`, `dispatch_task_id`, `source`, `remark`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`
) VALUES
(1, 1, 1, 'dispatch', '从预案中心引入。', 'admin', @seed_time, 'admin', @seed_time, '0');

-- =========================
-- 消息、渠道配置
-- =========================
INSERT INTO `sys_notification_template` (
  `id`, `template_code`, `template_name`, `business_type`, `channel`, `title_template`, `content_template`, `variables`, `status`, `remark`, `create_by`, `create_time`, `update_by`, `update_time`
) VALUES
(1, 'TPL-PLAN-PUB', '预案发布-站内', 'plan_publish', 'station', '预案「${name}」已发布', '请查阅预案编号：${code}。', '["name","code"]', '0', '示范', 'admin', @seed_time, 'admin', @seed_time),
(2, 'TPL-INV-ALERT', '库存预警', 'inventory_alert', 'email', '库存低于阈值：${material}', '仓库：${wh} 物资：${material} 可用品：${qty}。', '["wh","material","qty"]', '0', '示范', 'admin', @seed_time, 'admin', @seed_time);

INSERT INTO `sys_notification_channel_config` (
  `id`, `channel`, `config_key`, `config_value`, `description`, `status`, `create_by`, `create_time`, `update_by`, `update_time`
) VALUES
(1, 'email', 'smtpHost', 'smtp.example.com:465', '开发/示范用占位', '1', 'admin', @seed_time, 'admin', @seed_time),
(2, 'sms', 'signName', '市交通指挥', '短信签名', '0', 'admin', @seed_time, 'admin', @seed_time);

INSERT INTO `sys_notification` (
  `id`, `title`, `content`, `template_id`, `channel`, `receiver_id`, `receiver_name`, `sender_id`, `sender_name`, `business_type`, `business_id`, `status`, `read_time`, `send_time`, `expire_time`, `priority`, `extra_data`, `remark`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`
) VALUES
(1, '预案已发布', '《高速公路多车追尾专项预案》已上线。', 1, 'station', 1, '若依', NULL, NULL, 'plan_publish', 1, 'read', '2026-01-08 09:00:00', '2026-01-08 08:55:00', NULL, 'normal', NULL, '示范', 'admin', @seed_time, 'admin', @seed_time, '0'),
(2, '物资库存预警', '市本级-交通锥 可用量 小于 阈值。', 2, 'email', 1, '若依', NULL, NULL, 'inventory_alert', 1, 'sent', NULL, '2026-01-09 07:00:00', '2026-01-20 00:00:00', 'high', NULL, '占位', 'admin', @seed_time, 'admin', @seed_time, '0'),
(3, '调度任务更新', '行动项 2 仍在进行。', NULL, 'station', 1, '若依', 1, '若依', 'task_update', 1, 'read', '2026-01-10 10:00:00', '2026-01-10 08:00:00', NULL, 'normal', NULL, '占位', 'admin', @seed_time, 'admin', @seed_time, '0'),
(4, '审核待办', '有 1 笔 12345 转办 警情 待审。', NULL, 'station', 1, '若依', NULL, '系统', 'plan_approve', 2, 'pending', NULL, '2026-01-12 00:00:00', '2026-01-20 00:00:00', 'urgent', NULL, '待读', 'admin', @seed_time, 'admin', @seed_time, '0');

-- =========================
-- 案例库
-- =========================
INSERT INTO `case` (
  `id`, `case_no`, `title`, `event_type`, `event_level`, `location`, `occurred_time`, `description`, `disposal_summary`, `tags`, `is_typical`, `view_count`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `remark`
) VALUES
(1, 'CASE-2024-2001', '大雾天 西段 六车 追尾 分流 处置', 'traffic_accident', 'II', 'G4 西段 上行', '2023-12-20 05:10:00', '能见度 50m，5 台小车+1 台货车，清障+分流 4 小时。', '动态情报板+分流匝道口临合流。', '大雾,追尾,分流', 1, 200, 'admin', @seed_time, 'admin', @seed_time, '0', '典型'),
(2, 'CASE-2021-0008', '暴雨 下立交 积水 临断 交通组织', 'natural_disaster', 'III', '城区下立交互通', '2021-08-10 20:00:00', '泵车不足，临时断行。', '远端绕行+地铁接驳+公交。', '暴雨,积水,绕行', 1, 80, 'admin', @seed_time, 'admin', @seed_time, '0', '参考'),
(3, 'CASE-2019-0099', '大客流 高铁站 出租车 专项', 'other', 'IV', '高铁南站北广场', '2019-10-01 10:00:00', '出租车 排队 溢出。', '专道+短途公交+人员导向。', '大客流,出租,节日', 0, 12, 'admin', @seed_time, 'admin', @seed_time, '0', '叙事');

-- =========================
-- 系统 通知公告 再补几则
-- =========================
INSERT INTO `sys_notice` (`notice_id`, `notice_title`, `notice_type`, `notice_content`, `status`, `create_by`, `create_time`, `remark`) VALUES
(3, '应急指挥 演练安排（示范）', '1', '演练事项：本月底有雨雾风险专题桌面推演。', '0', 'admin', @seed_time, '内部'),
(4, 'ZLM/摄影机 接入 说明（占位）', '2', '开发占位：不绑真实流与实摄。', '0', 'admin', @seed_time, '占位');

-- 还原自增，避免 之后 手动插入 冲突（可选）
ALTER TABLE `sys_file_info` AUTO_INCREMENT = 2000;
ALTER TABLE `knowledge_category` AUTO_INCREMENT = 200;
ALTER TABLE `knowledge_document` AUTO_INCREMENT = 200;
ALTER TABLE `resource_team` AUTO_INCREMENT = 200;
ALTER TABLE `resource_expert` AUTO_INCREMENT = 200;
ALTER TABLE `event` AUTO_INCREMENT = 200;
ALTER TABLE `dispatch_task` AUTO_INCREMENT = 200;
ALTER TABLE `case` AUTO_INCREMENT = 200;
