feat: 添加合规

This commit is contained in:
zdl
2025-10-20 21:25:33 +08:00
parent d695f8ff7b
commit 6c96299b8f
42 changed files with 7118 additions and 289 deletions

View File

@@ -3,6 +3,7 @@
import { http, HttpResponse } from 'msw';
import { getEventRelatedStocks } from '../data/events';
import { getMockFutureEvents, getMockEventCountsForMonth } from '../data/account';
// 模拟网络延迟
const delay = (ms = 300) => new Promise(resolve => setTimeout(resolve, ms));
@@ -36,4 +37,718 @@ export const eventHandlers = [
);
}
}),
// 获取事件传导链分析数据
http.get('/api/events/:eventId/transmission', async ({ params }) => {
await delay(500);
const { eventId } = params;
console.log('[Mock] 获取事件传导链分析, eventId:', eventId);
// Mock数据事件传导链
const mockTransmissionData = {
success: true,
data: {
nodes: [
{
id: '1',
name: '主要事件',
category: '事件',
value: 50,
extra: {
node_type: 'event',
description: '这是主要事件节点',
importance_score: 50,
is_main_event: true
}
},
{
id: '2',
name: '半导体行业',
category: '行业',
value: 40,
extra: {
node_type: 'industry',
description: '受影响的半导体行业',
importance_score: 40,
is_main_event: false
}
},
{
id: '3',
name: '芯片制造',
category: '行业',
value: 35,
extra: {
node_type: 'industry',
description: '芯片制造产业链',
importance_score: 35,
is_main_event: false
}
},
{
id: '4',
name: 'A公司',
category: '公司',
value: 30,
extra: {
node_type: 'company',
description: '龙头企业A',
importance_score: 30,
stock_code: '600000',
is_main_event: false
}
},
{
id: '5',
name: 'B公司',
category: '公司',
value: 25,
extra: {
node_type: 'company',
description: '龙头企业B',
importance_score: 25,
stock_code: '600001',
is_main_event: false
}
},
{
id: '6',
name: '相关政策',
category: '政策',
value: 30,
extra: {
node_type: 'policy',
description: '国家产业政策支持',
importance_score: 30,
is_main_event: false
}
}
],
edges: [
{
source: '1',
target: '2',
value: 0.8,
extra: {
transmission_strength: 0.8,
transmission_type: '直接影响',
description: '主事件对半导体行业的直接影响'
}
},
{
source: '2',
target: '3',
value: 0.7,
extra: {
transmission_strength: 0.7,
transmission_type: '产业链传导',
description: '半导体到芯片制造的传导'
}
},
{
source: '3',
target: '4',
value: 0.6,
extra: {
transmission_strength: 0.6,
transmission_type: '企业影响',
description: '对龙头企业A的影响'
}
},
{
source: '3',
target: '5',
value: 0.5,
extra: {
transmission_strength: 0.5,
transmission_type: '企业影响',
description: '对龙头企业B的影响'
}
},
{
source: '6',
target: '1',
value: 0.7,
extra: {
transmission_strength: 0.7,
transmission_type: '政策驱动',
description: '政策对主事件的推动作用'
}
},
{
source: '6',
target: '2',
value: 0.6,
extra: {
transmission_strength: 0.6,
transmission_type: '政策支持',
description: '政策对行业的支持'
}
}
],
categories: ['事件', '行业', '公司', '政策', '技术', '市场', '其他']
},
message: '获取成功'
};
return HttpResponse.json(mockTransmissionData);
}),
// 获取桑基图数据
http.get('/api/events/:eventId/sankey-data', async ({ params }) => {
await delay(300);
const { eventId } = params;
console.log('[Mock] 获取桑基图数据, eventId:', eventId);
const mockSankeyData = {
success: true,
data: {
nodes: [
{
name: '相关政策',
type: 'policy',
level: 0,
color: '#10ac84'
},
{
name: '主要事件',
type: 'event',
level: 0,
color: '#ff4757'
},
{
name: '半导体行业',
type: 'industry',
level: 1,
color: '#00d2d3'
},
{
name: '芯片制造',
type: 'industry',
level: 2,
color: '#00d2d3'
},
{
name: 'A公司',
type: 'company',
level: 3,
color: '#54a0ff'
},
{
name: 'B公司',
type: 'company',
level: 3,
color: '#54a0ff'
}
],
links: [
{ source: 0, target: 1, value: 7 }, // 相关政策 -> 主要事件
{ source: 0, target: 2, value: 6 }, // 相关政策 -> 半导体行业
{ source: 1, target: 2, value: 8 }, // 主要事件 -> 半导体行业
{ source: 2, target: 3, value: 7 }, // 半导体行业 -> 芯片制造
{ source: 3, target: 4, value: 6 }, // 芯片制造 -> A公司
{ source: 3, target: 5, value: 5 } // 芯片制造 -> B公司
]
},
message: '获取成功'
};
return HttpResponse.json(mockSankeyData);
}),
// 获取传导链节点详情
http.get('/api/events/:eventId/chain-node/:nodeId', async ({ params }) => {
await delay(300);
const { eventId, nodeId } = params;
console.log('[Mock] 获取节点详情, eventId:', eventId, 'nodeId:', nodeId);
// 根据节点ID返回不同的详细信息
const nodeDetailsMap = {
'1': {
success: true,
data: {
node: {
id: '1',
name: '主要事件',
type: 'event',
description: '这是影响整个产业链的重大事件,涉及政策调整和技术突破,对下游产业产生深远影响。',
importance_score: 50,
total_connections: 2,
incoming_connections: 1,
outgoing_connections: 1
},
parents: [
{
id: '6',
name: '相关政策',
transmission_mechanism: {
data: [
{
author: "国务院",
sentences: "为加快实施创新驱动发展战略推动产业转型升级国家将对重点领域给予财政补贴支持单个项目最高补贴金额可达5000万元同时享受研发费用加计扣除175%的税收优惠政策",
query_part: "国家财政补贴最高5000万元研发费用加计扣除175%",
match_score: "好",
declare_date: "2024-01-15T00:00:00",
report_title: "关于促进产业高质量发展的若干政策措施"
},
{
author: "工信部",
sentences: "根据《重点产业扶持目录》,对符合条件的企业和项目,将优先纳入政府采购名单,并提供专项资金支持,确保政策红利直接惠及实体经济",
query_part: "政府采购优先支持,专项资金直达企业",
match_score: "好",
declare_date: "2024-01-20T00:00:00",
report_title: "工业和信息化部关于落实产业扶持政策的通知"
}
]
},
direction: 'positive',
strength: 70,
is_circular: false
}
],
children: [
{
id: '2',
name: '半导体行业',
transmission_mechanism: {
data: [
{
author: "中国电子信息产业发展研究院",
sentences: "在技术突破和应用场景快速扩张的双重驱动下国内半导体市场呈现爆发式增长态势。据统计2024年上半年半导体市场规模达到1.2万亿元同比增长32%其中新能源汽车和AI算力芯片需求贡献了超过60%的增量",
query_part: "技术突破和需求激增推动半导体市场增长32%",
match_score: "好",
declare_date: "2024-07-10T00:00:00",
report_title: "2024年上半年中国半导体产业发展报告"
},
{
author: "工信部电子信息司",
sentences: "随着5G、人工智能、物联网等新一代信息技术的快速发展半导体作为数字经济的基石正迎来前所未有的发展机遇。预计未来三年国内半导体市场年均增速将保持在25%以上",
query_part: "新兴技术推动半导体产业高速增长",
match_score: "好",
declare_date: "2024-05-20T00:00:00",
report_title: "新一代信息技术产业发展白皮书"
}
]
},
direction: 'positive',
strength: 80,
is_circular: false
}
]
}
},
'2': {
success: true,
data: {
node: {
id: '2',
name: '半导体行业',
type: 'industry',
description: '半导体行业是现代科技产业的基础,受到主事件和政策的双重推动,迎来新一轮发展机遇。',
importance_score: 40,
total_connections: 3,
incoming_connections: 2,
outgoing_connections: 1
},
parents: [
{
id: '1',
name: '主要事件',
transmission_mechanism: {
data: [
{
author: "中国半导体行业协会",
sentences: "受益于新能源汽车、5G通信等新兴应用领域的爆发式增长国内半导体市场需求持续旺盛2024年Q1市场规模同比增长28%,创历史新高",
query_part: "新兴应用推动半导体需求增长28%",
match_score: "好",
declare_date: "2024-04-05T00:00:00",
report_title: "2024年Q1中国半导体行业景气度报告"
}
]
},
direction: 'positive',
strength: 80,
is_circular: false
},
{
id: '6',
name: '相关政策',
transmission_mechanism: {
data: [
{
author: "国家发改委",
sentences: "《国家集成电路产业发展推进纲要》明确提出到2025年半导体产业自给率要达到70%以上国家将设立专项基金规模超过3000亿元重点支持半导体设备、材料、设计等关键环节",
query_part: "半导体自给率目标70%专项基金3000亿",
match_score: "好",
declare_date: "2024-02-01T00:00:00",
report_title: "国家集成电路产业发展推进纲要2024-2030"
}
]
},
direction: 'positive',
strength: 60,
is_circular: false
}
],
children: [
{
id: '3',
name: '芯片制造',
transmission_mechanism: {
data: [
{
author: "张明",
sentences: "在半导体行业景气度持续提升的背景下下游芯片制造企业订单饱满产能利用率达到历史新高预计2024年产能扩张将达到30%以上技术工艺也将从28nm向14nm升级",
query_part: "半导体行业繁荣带动芯片制造产能扩张30%",
match_score: "好",
declare_date: "2024-03-15T00:00:00",
report_title: "半导体行业深度报告:产业链景气度传导分析"
},
{
author: "李华",
sentences: "芯片制造环节作为半导体产业链核心,受益于上游材料供应稳定和下游应用需求旺盛,技术迭代速度明显加快,先进制程占比持续提升",
query_part: "技术迭代加快,先进制程占比提升",
match_score: "好",
declare_date: "2024-02-28T00:00:00",
report_title: "芯片制造行业跟踪报告"
}
]
},
direction: 'positive',
strength: 70,
is_circular: false
}
]
}
},
'3': {
success: true,
data: {
node: {
id: '3',
name: '芯片制造',
type: 'industry',
description: '芯片制造作为半导体产业链的核心环节,在上游需求推动下,产能利用率提升,技术迭代加快。',
importance_score: 35,
total_connections: 3,
incoming_connections: 1,
outgoing_connections: 2
},
parents: [
{
id: '2',
name: '半导体行业',
transmission_mechanism: {
data: [
{
author: "张明",
sentences: "在半导体行业景气度持续提升的背景下下游芯片制造企业订单饱满产能利用率达到历史新高预计2024年产能扩张将达到30%以上技术工艺也将从28nm向14nm升级",
query_part: "半导体行业繁荣带动芯片制造产能扩张30%",
match_score: "好",
declare_date: "2024-03-15T00:00:00",
report_title: "半导体行业深度报告:产业链景气度传导分析"
},
{
author: "李华",
sentences: "芯片制造环节作为半导体产业链核心,受益于上游材料供应稳定和下游应用需求旺盛,技术迭代速度明显加快,先进制程占比持续提升",
query_part: "技术迭代加快,先进制程占比提升",
match_score: "好",
declare_date: "2024-02-28T00:00:00",
report_title: "芯片制造行业跟踪报告"
}
]
},
direction: 'positive',
strength: 70,
is_circular: false
}
],
children: [
{
id: '4',
name: 'A公司',
transmission_mechanism: {
data: [
{
author: "王芳",
sentences: "A公司作为国内芯片制造龙头企业在手订单已排至2024年Q4预计全年营收增长45%净利润增长60%以上。公司28nm及以下先进制程产能占比已达到40%,技术实力行业领先",
query_part: "A公司在手订单充足预计营收增长45%",
match_score: "好",
declare_date: "2024-04-10T00:00:00",
report_title: "A公司深度研究受益芯片制造景气周期"
}
]
},
direction: 'positive',
strength: 60,
is_circular: false
},
{
id: '5',
name: 'B公司',
transmission_mechanism: {
data: [
{
author: "赵强",
sentences: "随着芯片制造产能的大规模扩张上游设备和材料供应商迎来历史性机遇。B公司作为核心配套企业订单量同比增长55%产品供不应求预计2024年营收将突破百亿大关。公司在封装测试领域的市场份额已提升至国内第二位",
query_part: "B公司订单增长55%,营收将破百亿",
match_score: "好",
declare_date: "2024-05-08T00:00:00",
report_title: "B公司跟踪报告芯片产业链配套龙头崛起"
},
{
author: "国信证券",
sentences: "B公司深度受益于芯片制造产业链的景气度传导。公司凭借先进的封装技术和完善的产能布局成功绑定多家头部芯片制造企业形成稳定的供应关系。随着下游客户产能持续扩张公司业绩增长确定性强",
query_part: "B公司受益产业链景气度业绩增长确定性强",
match_score: "好",
declare_date: "2024-06-01T00:00:00",
report_title: "半导体封装测试行业专题:产业链景气度传导分析"
}
]
},
direction: 'positive',
strength: 50,
is_circular: false
}
]
}
},
'4': {
success: true,
data: {
node: {
id: '4',
name: 'A公司',
type: 'company',
description: 'A公司是行业龙头企业拥有先进的芯片制造技术和完整的产业链布局在本轮产业升级中占据有利位置。',
importance_score: 30,
stock_code: '600000',
total_connections: 1,
incoming_connections: 1,
outgoing_connections: 0
},
parents: [
{
id: '3',
name: '芯片制造',
transmission_mechanism: {
data: [
{
author: "王芳",
sentences: "A公司作为国内芯片制造龙头企业在手订单已排至2024年Q4预计全年营收增长45%净利润增长60%以上。公司28nm及以下先进制程产能占比已达到40%,技术实力行业领先",
query_part: "A公司在手订单充足预计营收增长45%",
match_score: "好",
declare_date: "2024-04-10T00:00:00",
report_title: "A公司深度研究受益芯片制造景气周期"
}
]
},
direction: 'positive',
strength: 60,
is_circular: false
}
],
children: []
}
},
'5': {
success: true,
data: {
node: {
id: '5',
name: 'B公司',
type: 'company',
description: 'B公司专注于芯片封装测试领域随着上游制造产能释放公司订单饱满业绩稳步增长。',
importance_score: 25,
stock_code: '600001',
total_connections: 1,
incoming_connections: 1,
outgoing_connections: 0
},
parents: [
{
id: '3',
name: '芯片制造',
transmission_mechanism: {
data: [
{
author: "赵强",
sentences: "随着芯片制造产能的大规模扩张上游设备和材料供应商迎来历史性机遇。B公司作为核心配套企业订单量同比增长55%产品供不应求预计2024年营收将突破百亿大关",
query_part: "B公司订单增长55%,营收将破百亿",
match_score: "好",
declare_date: "2024-05-08T00:00:00",
report_title: "B公司跟踪报告芯片产业链配套龙头崛起"
}
]
},
direction: 'positive',
strength: 50,
is_circular: false
}
],
children: []
}
},
'6': {
success: true,
data: {
node: {
id: '6',
name: '相关政策',
type: 'policy',
description: '国家出台了一系列产业扶持政策,包括财政补贴、税收减免和研发支持,旨在推动产业自主创新和进口替代。',
importance_score: 30,
total_connections: 2,
incoming_connections: 0,
outgoing_connections: 2
},
parents: [],
children: [
{
id: '1',
name: '主要事件',
transmission_mechanism: {
data: [
{
author: "国务院",
sentences: "为加快实施创新驱动发展战略推动产业转型升级国家将对重点领域给予财政补贴支持单个项目最高补贴金额可达5000万元同时享受研发费用加计扣除175%的税收优惠政策",
query_part: "国家财政补贴最高5000万元研发费用加计扣除175%",
match_score: "好",
declare_date: "2024-01-15T00:00:00",
report_title: "关于促进产业高质量发展的若干政策措施"
},
{
author: "工信部",
sentences: "将重点支持关键核心技术攻关和产业化应用建立产业发展专项基金规模达到1000亿元引导社会资本共同参与产业发展",
query_part: "设立1000亿元产业发展专项基金",
match_score: "好",
declare_date: "2024-02-01T00:00:00",
report_title: "产业发展专项基金管理办法"
}
]
},
direction: 'positive',
strength: 70,
is_circular: false
},
{
id: '2',
name: '半导体行业',
transmission_mechanism: {
data: [
{
author: "国家发改委",
sentences: "《国家集成电路产业发展推进纲要》明确提出到2025年半导体产业自给率要达到70%以上国家将设立专项基金规模超过3000亿元重点支持半导体设备、材料、设计等关键环节。同时通过进口替代战略加快培育本土产业链",
query_part: "半导体自给率目标70%专项基金3000亿",
match_score: "好",
declare_date: "2024-02-01T00:00:00",
report_title: "国家集成电路产业发展推进纲要2024-2030"
},
{
author: "工信部",
sentences: "将重点支持关键核心技术攻关和产业化应用建立产业发展专项基金规模达到1000亿元引导社会资本共同参与产业发展。通过税收优惠、研发补贴等政策工具为半导体行业创造良好的发展环境",
query_part: "设立1000亿元产业发展专项基金",
match_score: "好",
declare_date: "2024-02-01T00:00:00",
report_title: "产业发展专项基金管理办法"
}
]
},
direction: 'positive',
strength: 60,
is_circular: false
}
]
}
}
};
// 返回对应节点的详情,如果不存在则返回默认数据
const nodeDetail = nodeDetailsMap[nodeId] || {
success: true,
data: {
node: {
id: nodeId,
name: '未知节点',
type: 'other',
description: '该节点暂无详细信息',
importance_score: 0,
total_connections: 0,
incoming_connections: 0,
outgoing_connections: 0
},
parents: [],
children: []
}
};
return HttpResponse.json(nodeDetail);
}),
// ==================== 投资日历相关 ====================
// 获取月度事件统计
http.get('/api/v1/calendar/event-counts', async ({ request }) => {
await delay(300);
const url = new URL(request.url);
const year = parseInt(url.searchParams.get('year'));
const month = parseInt(url.searchParams.get('month'));
console.log('[Mock] 获取月度事件统计:', { year, month });
const eventCounts = getMockEventCountsForMonth(year, month);
return HttpResponse.json({
success: true,
data: eventCounts
});
}),
// 获取指定日期的事件列表
http.get('/api/v1/calendar/events', async ({ request }) => {
await delay(300);
const url = new URL(request.url);
const dateStr = url.searchParams.get('date');
const type = url.searchParams.get('type') || 'all';
console.log('[Mock] 获取日历事件列表:', { date: dateStr, type });
if (!dateStr) {
return HttpResponse.json({
success: false,
error: 'Date parameter required'
}, { status: 400 });
}
const events = getMockFutureEvents(dateStr, type);
return HttpResponse.json({
success: true,
data: events
});
}),
// 切换未来事件关注状态
http.post('/api/v1/calendar/events/:eventId/follow', async ({ params }) => {
await delay(300);
const { eventId } = params;
console.log('[Mock] 切换事件关注状态, eventId:', eventId);
// 简单返回成功,实际状态管理可以后续完善
return HttpResponse.json({
success: true,
data: {
is_following: true,
message: '关注成功'
}
});
}),
];