2021-12-24 15:24:26 +08:00
|
|
|
import json
|
|
|
|
import pandas as pd
|
|
|
|
|
2021-12-27 16:30:57 +08:00
|
|
|
from common.scripts import sub_dict
|
2021-12-21 11:06:58 +08:00
|
|
|
from company.db import find_data_in_company
|
2021-12-13 16:04:10 +08:00
|
|
|
|
|
|
|
|
2021-12-21 11:06:58 +08:00
|
|
|
def find_company_data_scripts(table, cid):
|
|
|
|
return find_data_in_company(table, {"企业ID": cid})
|
2021-12-24 15:24:26 +08:00
|
|
|
|
|
|
|
|
2021-12-27 16:30:57 +08:00
|
|
|
def find_head_info_scripts(cid):
|
|
|
|
data = find_data_in_company('综合评价分析', {"企业ID": cid})
|
|
|
|
if data:
|
|
|
|
return sub_dict(data[0], ['企业名称', '综合信用等级'])
|
|
|
|
else:
|
|
|
|
company = find_data_in_company('公司基本信息', {"企业ID": cid})[0]
|
|
|
|
result = {
|
|
|
|
"企业名称": company['企业名称'],
|
|
|
|
"综合信用等级": {
|
|
|
|
"评价时间": "N/A",
|
|
|
|
"信用等级": "N/A",
|
|
|
|
"信用评分": "N/A"
|
|
|
|
},
|
|
|
|
}
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
2021-12-24 15:24:26 +08:00
|
|
|
def find_financial_index_detail_scripts(table, cid):
|
|
|
|
df = pd.DataFrame(find_data_in_company(table, {"企业ID": cid})).sort_values('年报期', ascending=False)
|
|
|
|
cols = [
|
|
|
|
'年报期',
|
|
|
|
'净资产收益率',
|
|
|
|
'总资产报酬率',
|
|
|
|
'总资产周转率',
|
|
|
|
'应收账款周转率',
|
|
|
|
'存货周转率',
|
|
|
|
'资产负债率',
|
|
|
|
'已获利息倍数',
|
|
|
|
'速动比率',
|
|
|
|
'营业增长率',
|
|
|
|
'总资产增长率',
|
|
|
|
'技术投入比率'
|
|
|
|
]
|
|
|
|
unit_cols = [
|
|
|
|
'净资产收益率',
|
|
|
|
'总资产报酬率',
|
|
|
|
'总资产周转率',
|
|
|
|
'存货周转率',
|
|
|
|
'资产负债率',
|
|
|
|
'速动比率',
|
|
|
|
'营业增长率',
|
|
|
|
'总资产增长率',
|
|
|
|
'技术投入比率'
|
|
|
|
]
|
|
|
|
|
|
|
|
def percent_unit(param):
|
|
|
|
return param.map(lambda x: '{}%'.format(x) if (param.name in unit_cols and not pd.isna(x)) else x)
|
|
|
|
|
|
|
|
df_result = df[cols].apply(lambda x: percent_unit(x))
|
|
|
|
|
|
|
|
return list(json.loads(df_result.T.to_json()).values())
|