up zero
This commit is contained in:
parent
029c724801
commit
8c24ff4e54
@ -79,7 +79,7 @@ async def _perform_valuation_calculation(user_id: int, data: UserValuationCreate
|
||||
# 侵权分 默认 6
|
||||
try:
|
||||
judicial_data = universal_api.query_judicial_data(data.institution)
|
||||
_data = judicial_data["data"].get("target",None) # 诉讼标的
|
||||
_data = judicial_data["data"].get("target", None) # 诉讼标的
|
||||
if _data:
|
||||
infringement_score = 0.0
|
||||
else:
|
||||
@ -103,7 +103,8 @@ async def _perform_valuation_calculation(user_id: int, data: UserValuationCreate
|
||||
# 验证 专利剩余年限
|
||||
# 发展潜力D相关参数 专利数量
|
||||
# 查询匹配申请号的记录集合
|
||||
matched = [item for item in data_list if isinstance(item, dict) and item.get("SQH") == getattr(data, 'patent_application_no', None)]
|
||||
matched = [item for item in data_list if
|
||||
isinstance(item, dict) and item.get("SQH") == getattr(data, 'patent_application_no', None)]
|
||||
if matched:
|
||||
patent_count = calculate_patent_usage_score(len(matched))
|
||||
input_data_by_b1["patent_count"] = float(patent_count)
|
||||
@ -312,7 +313,7 @@ async def _extract_calculation_params_b1(data: UserValuationCreate) -> Dict[str,
|
||||
"""
|
||||
# 基础价值B11相关参数
|
||||
# 财务价值所需数据 从近三年收益计算
|
||||
three_year_income = data.three_year_income or [0, 0, 0]
|
||||
three_year_income = [safe_float(income) for income in data.three_year_income]
|
||||
|
||||
# 法律强度L相关参数
|
||||
# 普及地域分值 默认 7分
|
||||
@ -320,8 +321,8 @@ async def _extract_calculation_params_b1(data: UserValuationCreate) -> Dict[str,
|
||||
|
||||
# 创新投入比 = (研发费用/营收) * 100
|
||||
try:
|
||||
rd_investment = float(data.rd_investment or 0)
|
||||
annual_revenue = float(data.annual_revenue or 1) # 避免除零
|
||||
rd_investment = float(data.rd_investment) or 0
|
||||
annual_revenue = float(data.annual_revenue) or 1# 避免除零
|
||||
innovation_ratio = (rd_investment / annual_revenue) * 100 if annual_revenue > 0 else 0
|
||||
except (ValueError, TypeError):
|
||||
innovation_ratio = 0.0
|
||||
@ -367,6 +368,11 @@ async def _extract_calculation_params_b1(data: UserValuationCreate) -> Dict[str,
|
||||
implementation_stage = policy_calculator.calculate_implementation_stage_score(implementation_stage_str)
|
||||
funding_support = policy_calculator.calculate_funding_support_score(funding_support_str)
|
||||
|
||||
# 获取线下账号 转发 点赞 评论信息 {kuaishou: {account: "123456789", likes: "33", comments: "33", shares: "33"}}
|
||||
platform_accounts_data = data.platform_accounts
|
||||
platform_key = next(iter(platform_accounts_data)) # 或 list(data.keys())[0]
|
||||
info = platform_accounts_data[platform_key]
|
||||
|
||||
return {
|
||||
# 基础价值B11相关参数
|
||||
'three_year_income': three_year_income,
|
||||
@ -377,11 +383,11 @@ async def _extract_calculation_params_b1(data: UserValuationCreate) -> Dict[str,
|
||||
# 流量因子B12相关参数
|
||||
'search_index_s1': search_index_s1,
|
||||
'industry_average_s2': industry_average_s2,
|
||||
'social_media_spread_s3': 0.0,
|
||||
# 'social_media_spread_s3': 0.0,
|
||||
# 这些社交数据暂未来源,置为0,后续接入API再填充
|
||||
'likes': 0,
|
||||
'comments': 0,
|
||||
'shares': 0,
|
||||
'likes': safe_float(info["likes"]),
|
||||
'comments': safe_float(info["comments"]),
|
||||
'shares': safe_float(info["shares"]),
|
||||
# followers 非当前计算用键,先移除避免干扰
|
||||
|
||||
# click_count 与 view_count 目前未参与计算,先移除
|
||||
@ -411,10 +417,17 @@ async def _extract_calculation_params_b2(data: UserValuationCreate) -> Dict[str,
|
||||
inheritor_level_coefficient = living_heritage_calculator.calculate_inheritor_level_coefficient(inheritor_level)
|
||||
|
||||
offline_sessions = int(data.offline_activities) # 线下传习次数
|
||||
platform_accounts_data = data.platform_accounts
|
||||
rs = {}
|
||||
for platform, info in platform_accounts_data.items():
|
||||
rs[platform] = {
|
||||
"likes": safe_float(info.get("likes")),
|
||||
}
|
||||
# 以下调用API douyin\bilibili\kuaishou
|
||||
douyin_views = 0
|
||||
kuaishou_views = 0
|
||||
bilibili_views = 0
|
||||
douyin_views = safe_float(rs.get("douyin",None).get("likes",0)) if rs.get("douyin",None) else 0
|
||||
kuaishou_views = safe_float(rs.get("kuaishou",None).get("likes",0)) if rs.get("kuaishou",None) else 0
|
||||
bilibili_views = safe_float(rs.get("bilibili",None).get("likes",0)) if rs.get("bilibili",None) else 0
|
||||
|
||||
# 跨界合作深度 品牌联名0.3,科技载体0.5,国家外交礼品1.0
|
||||
cross_border_depth = float(data.cooperation_depth)
|
||||
|
||||
@ -622,3 +635,10 @@ def calculate_total_years(data_list):
|
||||
return 0
|
||||
|
||||
return total_years
|
||||
|
||||
|
||||
def safe_float(v):
|
||||
try:
|
||||
return float(v)
|
||||
except (ValueError, TypeError):
|
||||
return 0.0
|
||||
|
||||
@ -68,9 +68,9 @@ class TrafficFactorB12Calculator:
|
||||
return social_media_spread
|
||||
|
||||
def calculate_interaction_index(self,
|
||||
likes: int,
|
||||
comments: int,
|
||||
shares: int) -> float:
|
||||
likes: float,
|
||||
comments: float,
|
||||
shares: float) -> float:
|
||||
"""
|
||||
计算互动量指数
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user