-- ============================================
-- HR 績效評核系統 - 初始資料
-- Database: db_A102
-- Version: 1.0
-- Created: 2025-12-03
-- ============================================

USE db_A102;

-- ============================================
-- 一、系統角色初始資料
-- ============================================

INSERT INTO hr_system_roles (role_code, role_name_zh, role_name_en, permissions) VALUES
('ADMIN', '系統管理員', 'System Administrator', '{"all": true}'),
('HR', '人力資源', 'HR Manager', '{"view_all": true, "manage_settings": true, "manage_competency_dict": true}'),
('MANAGER', '部門主管', 'Department Manager', '{"view_team": true, "approve": true, "review": true}'),
('EMPLOYEE', '一般員工', 'Employee', '{"view_self": true, "self_review": true}');

-- ============================================
-- 二、職級初始資料
-- ============================================

INSERT INTO hr_job_levels (level_code, level_name_zh, level_name_en, level_order, is_management) VALUES
('L1', '助理專員', 'Junior Associate', 1, FALSE),
('L2', '專員', 'Associate', 2, FALSE),
('L3', '資深專員', 'Senior Associate', 3, FALSE),
('L4', '副理', 'Assistant Manager', 4, TRUE),
('L5', '經理', 'Manager', 5, TRUE),
('L6', '資深經理', 'Senior Manager', 6, TRUE),
('L7', '協理', 'Director', 7, TRUE),
('L8', '副總經理', 'Vice President', 8, TRUE),
('L9', '總經理', 'General Manager', 9, TRUE);

-- ============================================
-- 三、職能分類初始資料
-- ============================================

INSERT INTO hr_competency_categories (category_code, category_name_zh, category_name_en, category_type, display_order) VALUES
('CORE', '通用職能', 'Core Competencies', 'core', 1),
('MGMT', '管理職能', 'Management Competencies', 'management', 2),
('PROF', '專業職能', 'Professional Competencies', 'professional', 3);

-- ============================================
-- 四、職能字典初始資料 - 通用職能
-- ============================================

INSERT INTO hr_competency_dictionary (competency_code, category_id, competency_name_zh, competency_name_en, definition_zh, definition_en) VALUES
('CORE-001', 1, '溝通協調', 'Communication & Coordination',
'能夠清晰表達想法，有效傾聽他人意見，並促進團隊成員間的理解與協作',
'Ability to clearly express ideas, actively listen to others, and facilitate understanding and collaboration among team members'),

('CORE-002', 1, '團隊合作', 'Teamwork',
'願意與他人合作，主動支援團隊目標，並在團隊中發揮正向影響力',
'Willingness to collaborate with others, proactively support team goals, and create positive impact within the team'),

('CORE-003', 1, '問題解決', 'Problem Solving',
'能夠識別問題核心，運用邏輯思維分析問題，並提出有效的解決方案',
'Ability to identify core issues, apply logical thinking to analyze problems, and propose effective solutions'),

('CORE-004', 1, '執行力', 'Execution',
'能夠按時完成任務，對工作結果負責，並持續追蹤直到目標達成',
'Ability to complete tasks on time, take ownership of work results, and persistently track progress until goals are achieved'),

('CORE-005', 1, '學習成長', 'Learning Agility',
'保持開放心態學習新知，從經驗中反思改進，並持續提升個人能力',
'Maintain an open mindset for learning, reflect and improve from experiences, and continuously enhance personal capabilities');

-- ============================================
-- 五、職能字典初始資料 - 管理職能
-- ============================================

INSERT INTO hr_competency_dictionary (competency_code, category_id, competency_name_zh, competency_name_en, definition_zh, definition_en) VALUES
('MGMT-001', 2, '策略思維', 'Strategic Thinking',
'能夠從全局角度思考，預見未來趨勢，並制定符合組織目標的策略方向',
'Ability to think from a holistic perspective, anticipate future trends, and develop strategic directions aligned with organizational goals'),

('MGMT-002', 2, '團隊領導', 'Team Leadership',
'能夠激勵團隊成員，建立信任關係，並帶領團隊達成目標',
'Ability to motivate team members, build trust relationships, and lead teams to achieve goals'),

('MGMT-003', 2, '橫向整合力', 'Cross-functional Integration',
'能夠跨部門協調資源，整合不同觀點，並促進組織整體效能',
'Ability to coordinate resources across departments, integrate diverse perspectives, and enhance overall organizational effectiveness'),

('MGMT-004', 2, '決策判斷', 'Decision Making',
'能夠在不確定情境中做出明智決策，權衡利弊並承擔決策責任',
'Ability to make sound decisions in uncertain situations, weigh pros and cons, and take responsibility for decisions'),

('MGMT-005', 2, '人才培育', 'People Development',
'能夠識別團隊成員潛力，提供發展機會，並有效輔導人才成長',
'Ability to identify team members\' potential, provide development opportunities, and effectively coach talent growth');

-- ============================================
-- 六、職能行為指標初始資料 - 溝通協調 (CORE-001)
-- ============================================

INSERT INTO hr_competency_behaviors (competency_id, level_num, behavior_description_zh, behavior_description_en) VALUES
(1, 1, '能夠清楚表達自己的想法，聆聽他人意見，在簡單情境中進行基本溝通',
'Can clearly express own ideas, listen to others, and perform basic communication in simple situations'),
(1, 2, '能夠依據對象調整溝通方式，在日常工作中有效傳遞資訊並確認理解',
'Can adjust communication style based on audience, effectively convey information and confirm understanding in daily work'),
(1, 3, '能夠促進團隊成員間的溝通，協調不同意見，並在衝突情境中尋求共識',
'Can facilitate communication among team members, coordinate different opinions, and seek consensus in conflict situations'),
(1, 4, '能夠在複雜情境中進行跨部門溝通，有效整合多方觀點並推動決策',
'Can conduct cross-departmental communication in complex situations, effectively integrate multiple perspectives and drive decisions'),
(1, 5, '能夠建立組織溝通機制，培養他人溝通能力，並在關鍵時刻發揮影響力',
'Can establish organizational communication mechanisms, develop others\' communication skills, and exert influence at critical moments');

-- ============================================
-- 七、職能行為指標初始資料 - 團隊合作 (CORE-002)
-- ============================================

INSERT INTO hr_competency_behaviors (competency_id, level_num, behavior_description_zh, behavior_description_en) VALUES
(2, 1, '願意配合團隊需要，接受任務分配，並在團隊中扮演支持角色',
'Willing to accommodate team needs, accept task assignments, and play a supportive role in the team'),
(2, 2, '主動分享資訊與資源，協助團隊成員解決問題，並維持良好團隊氛圍',
'Proactively share information and resources, help team members solve problems, and maintain positive team atmosphere'),
(2, 3, '能夠在團隊中發揮協調作用，促進成員間合作，並為團隊目標貢獻想法',
'Can play a coordinating role in the team, facilitate member collaboration, and contribute ideas to team goals'),
(2, 4, '能夠跨團隊建立合作關係，整合不同專業，並帶動團隊創新',
'Can build collaborative relationships across teams, integrate different expertise, and drive team innovation'),
(2, 5, '能夠塑造合作文化，培養團隊協作能力，並成為組織協作的典範',
'Can shape collaborative culture, develop team collaboration capabilities, and become an organizational collaboration role model');

-- ============================================
-- 八、職能行為指標初始資料 - 問題解決 (CORE-003)
-- ============================================

INSERT INTO hr_competency_behaviors (competency_id, level_num, behavior_description_zh, behavior_description_en) VALUES
(3, 1, '能夠發現明顯問題，依據指導尋找解決方法，並執行基本的問題處理',
'Can identify obvious problems, seek solutions with guidance, and execute basic problem handling'),
(3, 2, '能夠分析問題成因，運用既有方法解決問題，並從中學習改進',
'Can analyze problem causes, apply existing methods to solve problems, and learn for improvement'),
(3, 3, '能夠系統化分析複雜問題，提出創新解決方案，並評估方案可行性',
'Can systematically analyze complex problems, propose innovative solutions, and evaluate solution feasibility'),
(3, 4, '能夠處理高度複雜問題，整合多方資源找出最佳解，並預防問題再發生',
'Can handle highly complex problems, integrate multiple resources to find optimal solutions, and prevent recurrence'),
(3, 5, '能夠建立問題解決機制，培養組織解決問題能力，並推動持續改善文化',
'Can establish problem-solving mechanisms, develop organizational problem-solving capabilities, and drive continuous improvement culture');

-- ============================================
-- 九、職能行為指標初始資料 - 執行力 (CORE-004)
-- ============================================

INSERT INTO hr_competency_behaviors (competency_id, level_num, behavior_description_zh, behavior_description_en) VALUES
(4, 1, '能夠按照指示完成任務，遵守時程與品質要求，並主動回報進度',
'Can complete tasks as instructed, comply with timeline and quality requirements, and proactively report progress'),
(4, 2, '能夠獨立規劃工作，有效管理時間與優先順序，並確保任務如期達成',
'Can independently plan work, effectively manage time and priorities, and ensure tasks are completed on schedule'),
(4, 3, '能夠在多任務情境中保持專注，克服障礙推動執行，並達成挑戰性目標',
'Can stay focused in multi-tasking situations, overcome obstacles to drive execution, and achieve challenging goals'),
(4, 4, '能夠帶領團隊高效執行專案，監控進度並即時調整，確保目標達成',
'Can lead teams to execute projects efficiently, monitor progress and adjust in time, ensuring goal achievement'),
(4, 5, '能夠建立執行管理機制，提升組織執行效能，並塑造結果導向文化',
'Can establish execution management mechanisms, enhance organizational execution effectiveness, and shape results-oriented culture');

-- ============================================
-- 十、職能行為指標初始資料 - 學習成長 (CORE-005)
-- ============================================

INSERT INTO hr_competency_behaviors (competency_id, level_num, behavior_description_zh, behavior_description_en) VALUES
(5, 1, '願意學習新知識與技能，接受回饋並嘗試改進，保持積極學習態度',
'Willing to learn new knowledge and skills, accept feedback and try to improve, maintain positive learning attitude'),
(5, 2, '主動尋求學習機會，從工作經驗中反思，並將所學應用於實務工作',
'Proactively seek learning opportunities, reflect from work experiences, and apply learning to practical work'),
(5, 3, '能夠快速掌握新領域知識，跨領域學習並整合應用，持續提升專業能力',
'Can quickly master new domain knowledge, learn across fields and integrate applications, continuously enhance professional capabilities'),
(5, 4, '能夠引領團隊學習，分享知識與經驗，並建立學習型團隊文化',
'Can lead team learning, share knowledge and experiences, and build learning team culture'),
(5, 5, '能夠推動組織學習與創新，建立知識管理機制，並培養組織學習能力',
'Can drive organizational learning and innovation, establish knowledge management mechanisms, and cultivate organizational learning capabilities');

-- ============================================
-- 十一、職能行為指標初始資料 - 管理職能 (簡化版)
-- ============================================

-- 策略思維 (MGMT-001)
INSERT INTO hr_competency_behaviors (competency_id, level_num, behavior_description_zh, behavior_description_en) VALUES
(6, 1, '能夠理解部門目標，並將其與個人工作連結', 'Can understand department goals and connect them with personal work'),
(6, 2, '能夠掌握業務全貌，識別關鍵成功因素', 'Can grasp business overview and identify key success factors'),
(6, 3, '能夠分析市場趨勢，制定部門策略方向', 'Can analyze market trends and develop department strategic direction'),
(6, 4, '能夠整合內外部資源，推動組織策略執行', 'Can integrate internal and external resources to drive organizational strategy execution'),
(6, 5, '能夠制定公司級策略，引領組織轉型創新', 'Can develop company-level strategy and lead organizational transformation and innovation');

-- 團隊領導 (MGMT-002)
INSERT INTO hr_competency_behaviors (competency_id, level_num, behavior_description_zh, behavior_description_en) VALUES
(7, 1, '能夠在團隊中發揮正向影響力', 'Can exert positive influence within the team'),
(7, 2, '能夠帶領小型專案團隊達成目標', 'Can lead small project teams to achieve goals'),
(7, 3, '能夠有效管理團隊，激勵成員績效', 'Can effectively manage teams and motivate member performance'),
(7, 4, '能夠建立高效團隊，培養後備領導人才', 'Can build high-performing teams and develop future leaders'),
(7, 5, '能夠跨組織領導變革，建立領導梯隊', 'Can lead cross-organizational change and build leadership pipeline');

-- 橫向整合力 (MGMT-003)
INSERT INTO hr_competency_behaviors (competency_id, level_num, behavior_description_zh, behavior_description_en) VALUES
(8, 1, '能夠與其他部門建立良好工作關係', 'Can establish good working relationships with other departments'),
(8, 2, '能夠協調跨部門合作完成專案', 'Can coordinate cross-departmental collaboration to complete projects'),
(8, 3, '能夠整合跨部門資源解決複雜問題', 'Can integrate cross-departmental resources to solve complex problems'),
(8, 4, '能夠建立跨部門協作機制提升效能', 'Can establish cross-departmental collaboration mechanisms to enhance effectiveness'),
(8, 5, '能夠推動組織整體整合優化', 'Can drive overall organizational integration and optimization');

-- 決策判斷 (MGMT-004)
INSERT INTO hr_competency_behaviors (competency_id, level_num, behavior_description_zh, behavior_description_en) VALUES
(9, 1, '能夠依據標準流程做出日常決策', 'Can make daily decisions based on standard procedures'),
(9, 2, '能夠在一般情境中做出合理判斷', 'Can make reasonable judgments in general situations'),
(9, 3, '能夠在複雜情境中權衡利弊做決策', 'Can weigh pros and cons to make decisions in complex situations'),
(9, 4, '能夠在不確定性下做出關鍵決策', 'Can make critical decisions under uncertainty'),
(9, 5, '能夠做出影響組織長遠發展的戰略決策', 'Can make strategic decisions affecting long-term organizational development');

-- 人才培育 (MGMT-005)
INSERT INTO hr_competency_behaviors (competency_id, level_num, behavior_description_zh, behavior_description_en) VALUES
(10, 1, '願意協助新人適應工作環境', 'Willing to help newcomers adapt to work environment'),
(10, 2, '能夠指導同事提升工作技能', 'Can guide colleagues to improve work skills'),
(10, 3, '能夠識別人才潛力並提供發展機會', 'Can identify talent potential and provide development opportunities'),
(10, 4, '能夠系統化培育團隊人才', 'Can systematically develop team talent'),
(10, 5, '能夠建立組織人才發展體系', 'Can establish organizational talent development system');

-- ============================================
-- 十二、系統設定初始資料
-- ============================================

INSERT INTO hr_system_settings (setting_key, setting_value, setting_type, description_zh, description_en) VALUES
('goal_weight', '70.00', 'number', '目標成果權重百分比', 'Goal achievement weight percentage'),
('behavior_weight', '30.00', 'number', '行為能力權重百分比', 'Behavior competency weight percentage'),
('default_language', 'zh-TW', 'text', '系統預設語言', 'System default language'),
('enable_quarterly_review', 'true', 'boolean', '是否啟用季度評核', 'Enable quarterly review'),
('max_idp_goals', '4', 'number', 'IDP計畫最大目標數', 'Maximum IDP goals count');

-- ============================================
-- 十三、等級分界初始資料
-- ============================================

INSERT INTO hr_rating_thresholds (rating, min_score, max_score, suggested_percentage) VALUES
('A+', 90.00, 100.00, 10.00),
('A', 80.00, 89.99, 22.50),
('B+', 70.00, 79.99, 35.00),
('B', 60.00, 69.99, 22.50),
('C', 0.00, 59.99, 10.00);

-- ============================================
-- 初始資料建立完成
-- ============================================
