主要更新: - 更新所有12个产业的教务系统数据和功能 - 删除所有 node_modules 文件夹(节省3.7GB) - 删除所有 .yoyo 缓存文件夹(节省1.2GB) - 删除所有 dist 构建文件(节省55MB) 项目优化: - 项目大小从 8.1GB 减少到 3.2GB(节省60%空间) - 保留完整的源代码和配置文件 - .gitignore 已配置,防止再次提交大文件 启动脚本: - start-industry.sh/bat/ps1 脚本会自动检测并安装依赖 - 首次启动时自动运行 npm install - 支持单个或批量启动产业系统 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
171 lines
5.7 KiB
Python
171 lines
5.7 KiB
Python
#!/usr/bin/env python3
|
||
# -*- coding: utf-8 -*-
|
||
|
||
import json
|
||
from datetime import datetime
|
||
|
||
# 读取大健康问答内容数据
|
||
with open('/Users/apple/Documents/cursor/教务系统/frontend_大健康/网页未导入数据/大健康产业/大健康问答内容.json', 'r', encoding='utf-8') as f:
|
||
health_qa_data = json.load(f)
|
||
|
||
# 导师头像映射
|
||
mentor_avatars = {
|
||
"李奇": "https://ddcz-1315997005.cos.ap-nanjing.myqcloud.com/static/img/teach_sys_teacher-avatar/recuW7dDIg60Tg.png",
|
||
"宋积极(配方师gigi)": "https://ddcz-1315997005.cos.ap-nanjing.myqcloud.com/static/img/teach_sys_teacher-avatar/recuW7dxJ5E4Al.png",
|
||
"吴兰": "https://ddcz-1315997005.cos.ap-nanjing.myqcloud.com/static/img/teach_sys_teacher-avatar/recuW7dxJ5t1Ii.jpeg",
|
||
# 其他导师可以添加更多映射
|
||
}
|
||
|
||
# 默认机器人头像
|
||
robot_avatar = "https://ddcz-1315997005.cos.ap-nanjing.myqcloud.com/static/img/teach_sys_icon/recuWmDuekBTlr.png"
|
||
|
||
# 转换为专家支持中心格式
|
||
conversations = []
|
||
|
||
for idx, item in enumerate(health_qa_data, 1):
|
||
messages = []
|
||
|
||
# 构建对话消息
|
||
# 流程1 - 用户问题
|
||
if item.get("问题_流程1"):
|
||
messages.append({
|
||
"type": "user",
|
||
"content": item["问题_流程1"],
|
||
"time": item["流程1_时间"]
|
||
})
|
||
|
||
# 流程2 - 助手回答
|
||
if item.get("回答_流程2"):
|
||
mentor_name = item.get("查询导师名称", "多多畅职机器人")
|
||
if item.get("问答类型") == "AI答疑":
|
||
mentor_name = "多多畅职机器人"
|
||
mentor_avatar = robot_avatar
|
||
else:
|
||
mentor_avatar = mentor_avatars.get(mentor_name, robot_avatar)
|
||
if mentor_name != "多多畅职机器人":
|
||
mentor_name += "老师"
|
||
|
||
messages.append({
|
||
"type": "assistant",
|
||
"content": item["回答_流程2"],
|
||
"mentor": mentor_name,
|
||
"time": item["流程2_时间"],
|
||
"mentorAvatar": mentor_avatar
|
||
})
|
||
|
||
# 流程3 - 用户问题
|
||
if item.get("问题_流程3"):
|
||
messages.append({
|
||
"type": "user",
|
||
"content": item["问题_流程3"],
|
||
"time": item["流程3_时间"]
|
||
})
|
||
|
||
# 流程4 - 助手回答
|
||
if item.get("回答_流程4"):
|
||
mentor_name = item.get("查询导师名称", "多多畅职机器人")
|
||
if item.get("问答类型") == "AI答疑":
|
||
mentor_name = "多多畅职机器人"
|
||
mentor_avatar = robot_avatar
|
||
else:
|
||
mentor_avatar = mentor_avatars.get(mentor_name, robot_avatar)
|
||
if mentor_name != "多多畅职机器人":
|
||
mentor_name += "老师"
|
||
|
||
messages.append({
|
||
"type": "assistant",
|
||
"content": item["回答_流程4"],
|
||
"mentor": mentor_name,
|
||
"time": item["流程4_时间"],
|
||
"mentorAvatar": mentor_avatar
|
||
})
|
||
|
||
# 流程5 - 用户问题
|
||
if item.get("问题_流程5"):
|
||
messages.append({
|
||
"type": "user",
|
||
"content": item["问题_流程5"],
|
||
"time": item["流程5_时间"]
|
||
})
|
||
|
||
# 流程6 - 助手回答
|
||
if item.get("回答_流程6"):
|
||
mentor_name = item.get("查询导师名称", "多多畅职机器人")
|
||
if item.get("问答类型") == "AI答疑":
|
||
mentor_name = "多多畅职机器人"
|
||
mentor_avatar = robot_avatar
|
||
else:
|
||
mentor_avatar = mentor_avatars.get(mentor_name, robot_avatar)
|
||
if mentor_name != "多多畅职机器人":
|
||
mentor_name += "老师"
|
||
|
||
messages.append({
|
||
"type": "assistant",
|
||
"content": item["回答_流程6"],
|
||
"mentor": mentor_name,
|
||
"time": item["流程6_时间"],
|
||
"mentorAvatar": mentor_avatar
|
||
})
|
||
|
||
# 获取对话日期(从第一条消息的时间提取年月)
|
||
if messages:
|
||
first_time = messages[0]["time"]
|
||
try:
|
||
# 解析时间格式 "2023/9/12 9:23"
|
||
date_obj = datetime.strptime(first_time, "%Y/%m/%d %H:%M")
|
||
conversation_date = f"{date_obj.year}年{date_obj.month}月"
|
||
except:
|
||
conversation_date = "2024年"
|
||
|
||
# 确定问答类型
|
||
qa_type = item.get("问答类型", "常规问题")
|
||
if qa_type == "导师问答":
|
||
qa_type = "专业知识"
|
||
elif qa_type == "AI答疑":
|
||
qa_type = "AI答疑"
|
||
else:
|
||
qa_type = "常规问题"
|
||
|
||
# 构建对话对象
|
||
if messages:
|
||
conversation = {
|
||
"id": idx,
|
||
"title": item.get("问题标题(AI)", f"问题{idx}"),
|
||
"status": "finish",
|
||
"date": conversation_date,
|
||
"type": qa_type,
|
||
"messages": messages
|
||
}
|
||
conversations.append(conversation)
|
||
|
||
# 按时间排序(从最早的第一条消息时间开始)
|
||
def get_first_message_time(conv):
|
||
if conv["messages"]:
|
||
time_str = conv["messages"][0]["time"]
|
||
try:
|
||
return datetime.strptime(time_str, "%Y/%m/%d %H:%M")
|
||
except:
|
||
return datetime.now()
|
||
return datetime.now()
|
||
|
||
# 按时间升序排序(早的在前)
|
||
conversations.sort(key=get_first_message_time)
|
||
|
||
# 构建最终的数据结构
|
||
expert_support_data = {
|
||
"conversations": conversations
|
||
}
|
||
|
||
# 生成JS文件内容
|
||
js_content = f"""// 从大健康问答内容.json转换的专家支持中心数据
|
||
const expertSupportData = {json.dumps(expert_support_data, ensure_ascii=False, indent=2)};
|
||
|
||
export default expertSupportData;"""
|
||
|
||
# 保存到文件
|
||
output_path = 'src/data/expertSupportData.js'
|
||
with open(output_path, 'w', encoding='utf-8') as f:
|
||
f.write(js_content)
|
||
|
||
print(f"✅ 成功转换 {len(conversations)} 条对话数据")
|
||
print(f"✅ 已保存到 {output_path}") |