-- =====================================================
-- SRM 模块测试数据
-- 运行前请先确保 srm_init.sql 已执行
-- =====================================================

-- 1. 供应商测试数据
INSERT INTO srm_supplier (id, code, name, type, status, contact_name, contact_mobile, contact_email, address, bank_name, bank_account, tax_no, remark, create_time, update_time, creator, updater, deleted)
VALUES
(1001, 'SUP-20240001', '江苏智能制造有限公司', 1, 1, '张三', '13800001111', 'zhangsan@test.com', '江苏省南京市江宁区xx路100号', '中国银行南京分行', '6222024301000000001', '91320115MA1XXXXXX1', '优质供应商', NOW(), NOW(), 'admin', 'admin', 0),
(1002, 'SUP-20240002', '上海贸易进出口公司', 2, 1, '李四', '13800002222', 'lisi@test.com', '上海市浦东新区xx路200号', '工商银行上海分行', '1002024301000000002', '91310115MA2XXXXXX2', '长期合作', NOW(), NOW(), 'admin', 'admin', 0),
(1003, 'SUP-20240003', '深圳科技服务有限公司', 3, 1, '王五', '13800003333', 'wangwu@test.com', '深圳市南山区xx路300号', '招商银行深圳分行', '6225884301000000003', '91440300MA3XXXXXX3', '新供应商', NOW(), NOW(), 'admin', 'admin', 0),
(1004, 'SUP-20240004', '浙江精密机械有限公司', 1, 0, '赵六', '13800004444', 'zhaoliu@test.com', '浙江省杭州市西湖区xx路400号', '建设银行杭州分行', '6227004301000000004', '91330100MA4XXXXXX4', '暂停合作', NOW(), NOW(), 'admin', 'admin', 0);

-- 2. 供应商联系人
INSERT INTO srm_supplier_contact (id, supplier_id, name, mobile, email, position, is_primary, remark, create_time, update_time, creator, updater, deleted)
VALUES
(2001, 1001, '张三', '13800001111', 'zhangsan@test.com', '采购经理', 1, '主要联系人', NOW(), NOW(), 'admin', 'admin', 0),
(2002, 1001, '张三丰', '13800001112', 'zhangsanfeng@test.com', '技术总监', 0, '技术对接', NOW(), NOW(), 'admin', 'admin', 0),
(2003, 1002, '李四', '13800002222', 'lisi@test.com', '总经理', 1, NULL, NOW(), NOW(), 'admin', 'admin', 0);

-- 3. 供应商分类关联
INSERT INTO srm_supplier_category (id, supplier_id, category_id, category_name, create_time, update_time, creator, updater, deleted)
VALUES
(3001, 1001, 1, '机械加工', NOW(), NOW(), 'admin', 'admin', 0),
(3002, 1001, 2, '精密制造', NOW(), NOW(), 'admin', 'admin', 0),
(3003, 1002, 3, '贸易服务', NOW(), NOW(), 'admin', 'admin', 0);

-- 4. 供应商准入申请
INSERT INTO srm_supplier_apply (id, apply_no, supplier_name, contact_name, contact_mobile, contact_email, address, bank_name, bank_account, tax_no, apply_status, audit_comment, remark, create_time, update_time, creator, updater, deleted)
VALUES
(4001, 'AP2024010001', '江苏智能制造有限公司', '张三', '13800001111', 'zhangsan@test.com', '江苏省南京市江宁区xx路100号', '中国银行南京分行', '6222024301000000001', '91320115MA1XXXXXX1', 4, '资质齐全，审批通过', NULL, NOW(), NOW(), 'admin', 'admin', 0),
(4002, 'AP2024020002', '北京新科技有限公司', '刘七', '13800005555', 'liuqi@test.com', '北京市海淀区xx路500号', '农业银行北京分行', '6228484301000000005', '91110108MA5XXXXXX5', 1, NULL, '待审核', NOW(), NOW(), 'admin', 'admin', 0);

-- 5. 供应商资质证书
INSERT INTO srm_supplier_certificate (id, supplier_id, certificate_name, certificate_no, certificate_type, issuing_authority, issue_date, expire_date, remark, create_time, update_time, creator, updater, deleted)
VALUES
(5001, 1001, 'ISO9001质量管理体系证书', 'ISO9001-2024-001', 1, 'SGS认证机构', '2024-01-15', '2027-01-14', '三年有效期', NOW(), NOW(), 'admin', 'admin', 0),
(5002, 1001, 'ISO14001环境管理体系证书', 'ISO14001-2024-002', 2, 'TUV认证机构', '2024-03-01', '2027-02-28', NULL, NOW(), NOW(), 'admin', 'admin', 0),
(5003, 1002, '进出口贸易许可证', 'TRADE-2024-001', 4, '商务部', '2024-02-01', '2025-01-31', '即将到期', NOW(), NOW(), 'admin', 'admin', 0);

-- 6. 供应商绩效评价
INSERT INTO srm_supplier_evaluation (id, supplier_id, evaluation_period, quality_score, delivery_score, price_score, service_score, composite_score, grade, remark, create_time, update_time, creator, updater, deleted)
VALUES
(6001, 1001, '2024-Q1', 92, 88, 85, 90, 89, 'B', '质量稳定，交付及时', NOW(), NOW(), 'admin', 'admin', 0),
(6002, 1001, '2024-Q2', 95, 92, 88, 93, 92, 'A', '各项指标优秀', NOW(), NOW(), 'admin', 'admin', 0),
(6003, 1002, '2024-Q1', 80, 75, 90, 85, 81, 'B', '价格有优势，交付略慢', NOW(), NOW(), 'admin', 'admin', 0);

-- 7. 招标项目
INSERT INTO srm_tender_project (id, tender_no, tender_name, tender_type, purchase_org, project_leader_id, project_leader_name, tender_status, budget_amount, start_time, end_time, bid_open_time, tender_desc, qualification_requirements, purchase_request_id, create_time, update_time, creator, updater, deleted)
VALUES
(7001, 'TEN-202401001', '2024年Q1原材料采购招标', 1, '采购部', 1, '管理员', 4, 5000000.00, '2024-01-01 00:00:00', '2024-01-31 23:59:59', '2024-02-01 10:00:00', '采购不锈钢板材200吨', '1. 注册资金≥500万 2. 具备ISO9001认证', NULL, NOW(), NOW(), 'admin', 'admin', 0),
(7002, 'TEN-202402002', '2024年Q2设备采购招标', 2, '设备部', 2, '王经理', 1, 2000000.00, '2024-04-01 00:00:00', '2024-04-30 23:59:59', '2024-05-01 14:00:00', '采购数控机床5台', '1. 具备设备代理资质 2. 提供售后服务承诺', NULL, NOW(), NOW(), 'admin', 'admin', 0);

-- 8. 招标物料
INSERT INTO srm_tender_material (id, tender_project_id, item_code, item_name, spec, unit, quantity, remark, create_time, update_time, creator, updater, deleted)
VALUES
(8001, 7001, 'MAT-001', '不锈钢板304', '2.0*1500*3000mm', '吨', 100, NULL, NOW(), NOW(), 'admin', 'admin', 0),
(8002, 7001, 'MAT-002', '不锈钢板316L', '1.5*1500*3000mm', '吨', 100, '耐腐蚀要求', NOW(), NOW(), 'admin', 'admin', 0),
(8003, 7002, 'MAT-003', '数控机床CNC-500', '加工范围500*400mm', '台', 5, '含安装调试', NOW(), NOW(), 'admin', 'admin', 0);

-- 9. 投标记录
INSERT INTO srm_tender_bid (id, tender_project_id, supplier_id, bid_no, bid_status, bid_time, bid_total_amount, withdraw_reason, create_time, update_time, creator, updater, deleted)
VALUES
(9001, 7001, 1001, 'BID-202401-001', 1, '2024-01-15 10:00:00', 4800000.00, NULL, NOW(), NOW(), 'admin', 'admin', 0),
(9002, 7001, 1002, 'BID-202401-002', 1, '2024-01-20 14:00:00', 4900000.00, NULL, NOW(), NOW(), 'admin', 'admin', 0);

-- 10. 供应商报价
INSERT INTO srm_supplier_quote (id, bid_id, material_id, unit_price, total_price, delivery_days, remark, create_time, update_time, creator, updater, deleted)
VALUES
(10001, 9001, 8001, 22000.00, 2200000.00, 30, NULL, NOW(), NOW(), 'admin', 'admin', 0),
(10002, 9001, 8002, 26000.00, 2600000.00, 30, '含运费', NOW(), NOW(), 'admin', 'admin', 0),
(10003, 9002, 8001, 23000.00, 2300000.00, 25, NULL, NOW(), NOW(), 'admin', 'admin', 0),
(10004, 9002, 8002, 26000.00, 2600000.00, 28, NULL, NOW(), NOW(), 'admin', 'admin', 0);

-- 11. 开标记录
INSERT INTO srm_bid_open (id, tender_project_id, open_no, open_time, bid_count, supplier_count, open_status, remark, create_time, update_time, creator, updater, deleted)
VALUES
(11001, 7001, 'OPEN-20240201', '2024-02-01 10:00:00', 2, 2, 1, '投标截止，共2家供应商参与', NOW(), NOW(), 'admin', 'admin', 0);

-- 12. 评标记录
INSERT INTO srm_bid_evaluation (id, tender_project_id, bid_id, technical_score, commercial_score, composite_score, rank, comment, create_time, update_time, creator, updater, deleted)
VALUES
(12001, 7001, 9001, 88, 85, 86, 1, '技术方案优秀，价格合理', NOW(), NOW(), 'admin', 'admin', 0),
(12002, 7001, 9002, 82, 90, 87, 2, '价格有优势，技术方案一般', NOW(), NOW(), 'admin', 'admin', 0);

-- 13. 定标记录
INSERT INTO srm_bid_award (id, tender_project_id, supplier_id, bid_id, award_no, award_status, award_amount, award_time, purchase_order_id, purchase_order_no, remark, create_time, update_time, creator, updater, deleted)
VALUES
(13001, 7001, 1001, 9001, 'AWARD-202402-001', 1, 4800000.00, '2024-02-05 16:00:00', NULL, NULL, '综合评分第一', NOW(), NOW(), 'admin', 'admin', 0);

