-- ============================================================
-- 人员管理相关字典(前端用 getDicts() 加载,但数据库没有)
-- 1. person_type        人员类型
-- 2. certificate_type   证书类型
-- 3. insurance_status   保险状态
-- ============================================================

USE risk_control_platform;

-- ===== 1. 人员类型 =====
INSERT IGNORE INTO sys_dict_type (dict_name, dict_type, remark, create_by, create_time, update_by, update_time)
VALUES ('人员类型', 'person_type', '人员信息-人员类型', 1, NOW(), 1, NOW());

INSERT IGNORE INTO sys_dict_data (dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, remark, create_by, create_time, update_by, update_time) VALUES
(1, '员工',       '员工',       'person_type', '', 'primary', 'N', '', 1, NOW(), 1, NOW()),
(2, '管理人员',   '管理人员',   'person_type', '', 'success', 'N', '', 1, NOW(), 1, NOW()),
(3, '临时工',     '临时工',     'person_type', '', 'info',    'N', '', 1, NOW(), 1, NOW()),
(4, '实习生',     '实习生',     'person_type', '', 'warning', 'N', '', 1, NOW(), 1, NOW()),
(5, '外包人员',   '外包人员',   'person_type', '', 'danger',  'N', '', 1, NOW(), 1, NOW());

-- ===== 2. 证书类型 =====
INSERT IGNORE INTO sys_dict_type (dict_name, dict_type, remark, create_by, create_time, update_by, update_time)
VALUES ('证书类型', 'certificate_type', '人员证书-证书类型', 1, NOW(), 1, NOW());

INSERT IGNORE INTO sys_dict_data (dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, remark, create_by, create_time, update_by, update_time) VALUES
(1, '操作证',     '操作证',     'certificate_type', '', 'primary', 'N', '', 1, NOW(), 1, NOW()),
(2, '健康证',     '健康证',     'certificate_type', '', 'success', 'N', '', 1, NOW(), 1, NOW()),
(3, '职业资格证', '职业资格证', 'certificate_type', '', 'warning', 'N', '', 1, NOW(), 1, NOW()),
(4, '特种作业证', '特种作业证', 'certificate_type', '', 'danger',  'N', '', 1, NOW(), 1, NOW()),
(5, '其他',       '其他',       'certificate_type', '', 'info',    'N', '', 1, NOW(), 1, NOW());

-- ===== 3. 保险状态 =====
INSERT IGNORE INTO sys_dict_type (dict_name, dict_type, remark, create_by, create_time, update_by, update_time)
VALUES ('保险状态', 'insurance_status', '人员信息-保险状态', 1, NOW(), 1, NOW());

INSERT IGNORE INTO sys_dict_data (dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, remark, create_by, create_time, update_by, update_time) VALUES
(1, '未投保', '未投保', 'insurance_status', '', 'danger',  'Y', '默认', 1, NOW(), 1, NOW()),
(2, '已投保', '已投保', 'insurance_status', '', 'success', 'N', '', 1, NOW(), 1, NOW()),
(3, '已过期', '已过期', 'insurance_status', '', 'warning', 'N', '', 1, NOW(), 1, NOW());

-- 验证
SELECT '--- 字典统计 ---' AS info;
SELECT dict_type, COUNT(*) cnt FROM sys_dict_data
WHERE dict_type IN ('person_type', 'certificate_type', 'insurance_status')
GROUP BY dict_type;
