guzhi/.trae/documents/修复计算任务的NameError并确保步骤入库与日志可见.md
邹方成 cc352d3184 feat: 重构后端服务并添加新功能
refactor: 优化API路由和响应模型
feat(admin): 添加App用户管理接口
feat(sms): 实现阿里云短信服务集成
feat(email): 添加SMTP邮件发送功能
feat(upload): 支持文件上传接口
feat(rate-limiter): 实现手机号限流器
fix: 修复计算步骤入库问题
docs: 更新API文档和测试计划
chore: 更新依赖和配置
2025-11-19 19:36:03 +08:00

23 lines
1.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## 问题
- 后台任务在提取B1参数时引用未定义函数calculate_popularity_score、calculate_patent_score导致计算中止步骤未入库。
## 修复方案
1) 移除未定义函数引用,在 `_extract_calculation_params_b1` 内实现本地计算:
- 普及地域分mapping {全球覆盖:10全国覆盖:7区域覆盖:4}默认7
- 专利分:按剩余年限近似 {>10年:105-10年:7<5年:3}用已有 `calculate_total_years(data_list)` 近似转换
- 保留创新投入比与搜索指数行业均值等现有逻辑
- 增加logger输出popularity_scoreinnovation_ratiopatent_score
2) 确保步骤写入链路
- 计算入口先创建估值记录取 `valuation_id` `valuation_id` 传入统一计算器计算后用 `ValuationAssessmentUpdate` 更新记录
- 模型B汇总对经济B1文化B2风险B3的计算改为 `await` 并传 `valuation_id`
- 市场C与风险B3保持原有按 `valuation_id` 写入
3) 日志增强
- 在步骤创建与更新时写入日志calcstep.create/update/list
- 在估值初始化与更新时写入日志valuation.init_created/updated
## 验证
- 重启服务运行脚本查看服务日志应出现calcstep.create/update/list与valuation.updatedAdmin脚本打印后台估值计算步骤”。
——确认后我将按以上方案进行代码调整并回填日志