Initial commit: 教务系统在线平台
- 包含4个产业方向的前端项目:智能开发、智能制造、大健康、财经商贸 - 已清理node_modules、.yoyo等大文件,项目大小从2.6GB优化至631MB - 配置完善的.gitignore文件 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
175
frontend_财经商贸/updateExpertSupportData.js
Normal file
175
frontend_财经商贸/updateExpertSupportData.js
Normal file
@@ -0,0 +1,175 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
// 读取财经商贸问答内容数据
|
||||
const financeQAData = JSON.parse(
|
||||
fs.readFileSync(path.join(__dirname, '网页未导入数据/财经商贸产业/财经商贸问答内容.json'), 'utf-8')
|
||||
);
|
||||
|
||||
// 转换数据格式
|
||||
const conversations = financeQAData.map((item, index) => {
|
||||
const messages = [];
|
||||
|
||||
// 添加流程1(用户问题)
|
||||
if (item["问题_流程1"]) {
|
||||
messages.push({
|
||||
type: "user",
|
||||
content: item["问题_流程1"],
|
||||
time: item["流程1_时间"]
|
||||
});
|
||||
}
|
||||
|
||||
// 添加流程2(助手回答)
|
||||
if (item["回答_流程2"]) {
|
||||
const isAIAnswer = item["问答类型"] === "智能客服";
|
||||
messages.push({
|
||||
type: "assistant",
|
||||
content: item["回答_流程2"],
|
||||
mentor: isAIAnswer ? "多多畅职机器人" : item["查询导师名称"] + "老师",
|
||||
time: item["流程2_时间"],
|
||||
mentorAvatar: isAIAnswer
|
||||
? "https://ddcz-1315997005.cos.ap-nanjing.myqcloud.com/static/img/teach_sys_icon/recuWmDuekBTlr.png"
|
||||
: getMentorAvatar(item["查询导师名称"])
|
||||
});
|
||||
}
|
||||
|
||||
// 添加流程3(用户问题)
|
||||
if (item["问题_流程3"]) {
|
||||
messages.push({
|
||||
type: "user",
|
||||
content: item["问题_流程3"],
|
||||
time: item["流程3_时间"]
|
||||
});
|
||||
}
|
||||
|
||||
// 添加流程4(助手回答)
|
||||
if (item["回答_流程4"]) {
|
||||
const isAIAnswer = item["问答类型"] === "智能客服";
|
||||
messages.push({
|
||||
type: "assistant",
|
||||
content: item["回答_流程4"],
|
||||
mentor: isAIAnswer ? "多多畅职机器人" : item["查询导师名称"] + "老师",
|
||||
time: item["流程4_时间"],
|
||||
mentorAvatar: isAIAnswer
|
||||
? "https://ddcz-1315997005.cos.ap-nanjing.myqcloud.com/static/img/teach_sys_icon/recuWmDuekBTlr.png"
|
||||
: getMentorAvatar(item["查询导师名称"])
|
||||
});
|
||||
}
|
||||
|
||||
// 添加流程5(用户问题)
|
||||
if (item["问题_流程5"]) {
|
||||
messages.push({
|
||||
type: "user",
|
||||
content: item["问题_流程5"],
|
||||
time: item["流程5_时间"]
|
||||
});
|
||||
}
|
||||
|
||||
// 添加流程6(助手回答)
|
||||
if (item["回答_流程6"]) {
|
||||
const isAIAnswer = item["问答类型"] === "智能客服";
|
||||
messages.push({
|
||||
type: "assistant",
|
||||
content: item["回答_流程6"],
|
||||
mentor: isAIAnswer ? "多多畅职机器人" : item["查询导师名称"] + "老师",
|
||||
time: item["流程6_时间"],
|
||||
mentorAvatar: isAIAnswer
|
||||
? "https://ddcz-1315997005.cos.ap-nanjing.myqcloud.com/static/img/teach_sys_icon/recuWmDuekBTlr.png"
|
||||
: getMentorAvatar(item["查询导师名称"])
|
||||
});
|
||||
}
|
||||
|
||||
// 过滤掉空内容的消息
|
||||
const validMessages = messages.filter(msg => msg.content);
|
||||
|
||||
// 按时间排序消息(确保对话的时间顺序正确)
|
||||
validMessages.sort((a, b) => {
|
||||
const timeA = new Date(a.time.replace(/\//g, '-'));
|
||||
const timeB = new Date(b.time.replace(/\//g, '-'));
|
||||
return timeA - timeB;
|
||||
});
|
||||
|
||||
// 从第一条消息时间提取年月
|
||||
const firstTime = validMessages[0]?.time || "2024/1/1 00:00";
|
||||
const [datePart] = firstTime.split(' ');
|
||||
const [year, month] = datePart.split('/');
|
||||
const dateStr = `${year}年${month}月`;
|
||||
|
||||
return {
|
||||
id: index + 1,
|
||||
title: item["问题标题"],
|
||||
status: "finish",
|
||||
date: dateStr,
|
||||
type: item["问题类型"],
|
||||
messages: validMessages
|
||||
};
|
||||
});
|
||||
|
||||
// 导师头像映射(使用真实的导师头像URL)
|
||||
function getMentorAvatar(mentorName) {
|
||||
const mentorAvatars = {
|
||||
"刘红梅": "https://ddcz-1315997005.cos.ap-nanjing.myqcloud.com/static/img/teach_sys_teacher-avatar/recuW7dxJ5wnh1.png",
|
||||
"朱琳琳": "https://ddcz-1315997005.cos.ap-nanjing.myqcloud.com/static/img/teach_sys_teacher-avatar/recuW7dxJ5J6yn.png",
|
||||
"马国栋": "https://ddcz-1315997005.cos.ap-nanjing.myqcloud.com/static/img/teach_sys_teacher-avatar/recuW7dxJ5fgO2.jpeg",
|
||||
"徐明辉": "https://ddcz-1315997005.cos.ap-nanjing.myqcloud.com/static/img/teach_sys_teacher-avatar/recuW7dxJ5j6oq.png",
|
||||
"李奇": "https://ddcz-1315997005.cos.ap-nanjing.myqcloud.com/static/img/teach_sys_teacher-avatar/recuUpJBMNLZL5.png" // 李奇是AI答疑,保持原头像
|
||||
};
|
||||
|
||||
return mentorAvatars[mentorName] || "https://ddcz-1315997005.cos.ap-nanjing.myqcloud.com/static/img/teach_sys_teacher-avatar/recuUpJBMNLZL5.png";
|
||||
}
|
||||
|
||||
// 构建完整的数据结构
|
||||
const expertSupportData = {
|
||||
conversations: conversations
|
||||
};
|
||||
|
||||
// 备份原文件
|
||||
const backupPath = path.join(__dirname, 'src/data', `expertSupportData.js.backup_${new Date().toISOString().replace(/[:.]/g, '-')}`);
|
||||
fs.copyFileSync(
|
||||
path.join(__dirname, 'src/data/expertSupportData.js'),
|
||||
backupPath
|
||||
);
|
||||
console.log(`备份已创建: ${backupPath}`);
|
||||
|
||||
// 生成新的文件内容
|
||||
const fileContent = `// 从财经商贸问答内容.json转换的专家支持中心数据
|
||||
const expertSupportData = ${JSON.stringify(expertSupportData, null, 2)};
|
||||
|
||||
export default expertSupportData;`;
|
||||
|
||||
// 写入文件
|
||||
fs.writeFileSync(
|
||||
path.join(__dirname, 'src/data/expertSupportData.js'),
|
||||
fileContent,
|
||||
'utf-8'
|
||||
);
|
||||
|
||||
console.log(`成功更新专家支持中心数据,共 ${conversations.length} 个对话`);
|
||||
|
||||
// 统计信息
|
||||
const typeStats = {};
|
||||
conversations.forEach(conv => {
|
||||
typeStats[conv.type] = (typeStats[conv.type] || 0) + 1;
|
||||
});
|
||||
|
||||
console.log('\n问题类型统计:');
|
||||
Object.entries(typeStats).forEach(([type, count]) => {
|
||||
console.log(` ${type}: ${count} 个`);
|
||||
});
|
||||
|
||||
// 统计导师参与情况
|
||||
const mentorStats = {};
|
||||
financeQAData.forEach(item => {
|
||||
if (item["查询导师名称"]) {
|
||||
mentorStats[item["查询导师名称"]] = (mentorStats[item["查询导师名称"]] || 0) + 1;
|
||||
}
|
||||
});
|
||||
|
||||
console.log('\n导师参与统计:');
|
||||
Object.entries(mentorStats).forEach(([mentor, count]) => {
|
||||
console.log(` ${mentor}: ${count} 个对话`);
|
||||
});
|
||||
Reference in New Issue
Block a user