ESG评价分析
This commit is contained in:
parent
8c9f749910
commit
9bc3865bba
|
@ -138,3 +138,23 @@ class CompanyImpl(Company):
|
||||||
cc_rating.history_level = history_level
|
cc_rating.history_level = history_level
|
||||||
|
|
||||||
self.cc_rating_result = cc_rating
|
self.cc_rating_result = cc_rating
|
||||||
|
|
||||||
|
def get_esg_rating_result(self):
|
||||||
|
"""ESG评价分析"""
|
||||||
|
result = self.db.find_single_data_with_single_sort(
|
||||||
|
"企业数据",
|
||||||
|
"ESG评价分析",
|
||||||
|
{"企业ID": self.cid},
|
||||||
|
["评价ID", "更新日期", "ESG评级", "维度得分情况"],
|
||||||
|
{"更新日期": -1}
|
||||||
|
)
|
||||||
|
|
||||||
|
esg_rating = ESGRating()
|
||||||
|
|
||||||
|
if result:
|
||||||
|
esg_rating.rid = result['评价ID']
|
||||||
|
esg_rating.update_time = result["更新日期"]
|
||||||
|
esg_rating.esg_level = self.dict_to_set(instance=ESGRating.ESGLevel, data=result['ESG评级'])
|
||||||
|
esg_rating.factors_score = self.instance_list_to_set(instance=ESGRating.FactorsScore, data=result['维度得分情况'])
|
||||||
|
|
||||||
|
self.esg_rating_result = esg_rating
|
||||||
|
|
|
@ -72,90 +72,6 @@ class MainMember(SpecObject):
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class BalanceSheet(SpecObject):
|
|
||||||
"""资产负债表"""
|
|
||||||
accounts_receivable = ValidateAttr(field='accounts_receivable', type=float)
|
|
||||||
stock = ValidateAttr(field='stock', type=float)
|
|
||||||
total_current_assets = ValidateAttr(field='total_current_assets', type=float)
|
|
||||||
total_assets = ValidateAttr(field='total_assets', type=float)
|
|
||||||
short_loan = ValidateAttr(field='short_loan', type=float)
|
|
||||||
one_year_liabilities = ValidateAttr(field='one_year_liabilities', type=float)
|
|
||||||
total_current_liabilities = ValidateAttr(field='total_current_liabilities', type=float)
|
|
||||||
long_term_loan = ValidateAttr(field='long_term_loan', type=float)
|
|
||||||
total_liabilities = ValidateAttr(field='total_liabilities', type=float)
|
|
||||||
total_owners_equity = ValidateAttr(field='total_owners_equity', type=float)
|
|
||||||
|
|
||||||
fields_map = {
|
|
||||||
'accounts_receivable': '应收账款',
|
|
||||||
'stock': '存货',
|
|
||||||
'total_current_assets': '流动资产合计',
|
|
||||||
'total_assets': '资产总计',
|
|
||||||
'short_loan': '短期借款',
|
|
||||||
'one_year_liabilities': '一年内到期非流动负债',
|
|
||||||
'total_current_liabilities': '流动负债合计',
|
|
||||||
'long_term_loan': '长期借款',
|
|
||||||
'total_liabilities': '负债合计',
|
|
||||||
'total_owners_equity': '所有者权益合计'
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class ProfitSheet(SpecObject):
|
|
||||||
"""利润表"""
|
|
||||||
operating_income = ValidateAttr(field='operating_income', type=float)
|
|
||||||
operating_cost = ValidateAttr(field='operating_cost', type=float)
|
|
||||||
total_profit = ValidateAttr(field='total_profit', type=float)
|
|
||||||
net_profit = ValidateAttr(field='net_profit', type=float)
|
|
||||||
|
|
||||||
fields_map = {
|
|
||||||
'operating_income': '营业收入',
|
|
||||||
'operating_cost': '营业成本',
|
|
||||||
'total_profit': '利润总额',
|
|
||||||
'net_profit': '净利润'
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class AppendixDataSheet(SpecObject):
|
|
||||||
"""补充数据表"""
|
|
||||||
rd_expenses = ValidateAttr(field='rd_expenses', type=float)
|
|
||||||
interest_disbursement = ValidateAttr(field='interest_disbursement', type=float)
|
|
||||||
interest_expense = ValidateAttr(field='interest_expense', type=float)
|
|
||||||
|
|
||||||
fields_map = {
|
|
||||||
'rd_expenses': '研发费用异常',
|
|
||||||
'interest_disbursement': '计入财务费的利息支出异常',
|
|
||||||
'interest_expense': '资本化利息支出异常'
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class FinancialIndex(SpecObject):
|
|
||||||
"""财务指标"""
|
|
||||||
roe = ValidateAttr(field="roe", type=float)
|
|
||||||
inventory_turnover = ValidateAttr(field="inventory_turnover", type=float)
|
|
||||||
interest_multiple = ValidateAttr(field="interest_multiple", type=float)
|
|
||||||
accounts_receivable_turnover = ValidateAttr(field="accounts_receivable_turnover", type=float)
|
|
||||||
total_asset_turnover = ValidateAttr(field="total_asset_turnover", type=float)
|
|
||||||
total_asset_growth_rate = ValidateAttr(field="total_asset_growth_rate", type=float)
|
|
||||||
roa = ValidateAttr(field="roa", type=float)
|
|
||||||
technology_investment_ratio = ValidateAttr(field="technology_investment_ratio", type=float)
|
|
||||||
operating_growth_rate = ValidateAttr(field="operating_growth_rate", type=float)
|
|
||||||
assets_and_liabilities = ValidateAttr(field="assets_and_liabilities", type=float)
|
|
||||||
quick_ratio = ValidateAttr(field="quick_ratio", type=float)
|
|
||||||
|
|
||||||
fields_map = {
|
|
||||||
"roe": "净资产收益率",
|
|
||||||
"inventory_turnover": "存货周转率",
|
|
||||||
"interest_multiple": "已获利息倍数",
|
|
||||||
"accounts_receivable_turnover": "应收账款周转率",
|
|
||||||
"total_asset_turnover": "总资产周转率",
|
|
||||||
"total_asset_growth_rate": "总资产增长率",
|
|
||||||
"roa": "总资产报酬率",
|
|
||||||
"technology_investment_ratio": "技术投入比率",
|
|
||||||
"operating_growth_rate": "营业增长率",
|
|
||||||
"assets_and_liabilities": "资产负债率",
|
|
||||||
"quick_ratio": "速动比率"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class HeadInfo(SpecObject):
|
class HeadInfo(SpecObject):
|
||||||
""""""
|
""""""
|
||||||
|
|
||||||
|
@ -351,6 +267,54 @@ class CCRating(SpecObject):
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class ESGRating(SpecObject):
|
||||||
|
"""ESG评价分析"""
|
||||||
|
|
||||||
|
class ESGLevel(SpecObject):
|
||||||
|
"""ESG评级"""
|
||||||
|
|
||||||
|
esg_level = ValidateAttr(field='esg_level', type=str, in_list=["A", "B", "C", "D", "E"])
|
||||||
|
esg_score = ValidateAttr(field='esg_score', type=[int, float])
|
||||||
|
industry = ValidateAttr(field='industry', type=str)
|
||||||
|
|
||||||
|
fields_map = {
|
||||||
|
"esg_level": "ESG评级",
|
||||||
|
"esg_score": "ESG综合得分",
|
||||||
|
"industry": "行业"
|
||||||
|
}
|
||||||
|
|
||||||
|
class FactorsScore(SpecObject):
|
||||||
|
"""维度得分"""
|
||||||
|
|
||||||
|
dimension = ValidateAttr(field='dimension', type=str)
|
||||||
|
weight = ValidateAttr(field='weight', type=str)
|
||||||
|
score = ValidateAttr(field='score', type=str)
|
||||||
|
delta = ValidateAttr(field='delta', type=str)
|
||||||
|
industry_average = ValidateAttr(field='industry_average', type=str)
|
||||||
|
|
||||||
|
fields_map = {
|
||||||
|
"dimension": "维度",
|
||||||
|
"weight": "权重",
|
||||||
|
"score": "公司得分",
|
||||||
|
"delta": "得分变化",
|
||||||
|
"industry_average": "行业均分"
|
||||||
|
}
|
||||||
|
|
||||||
|
cid = ValidateAttr(field='cid', type=str, length=8)
|
||||||
|
update_time = ValidateAttr(field='update_time', func=Validate.time_format)
|
||||||
|
rid = ValidateAttr(field='rid', type=str, default='')
|
||||||
|
esg_level = ValidateAttr(field='esg_level', type=ESGLevel, default={})
|
||||||
|
factors_score = ValidateAttr(field='factors_score', instance_list=FactorsScore, default=[])
|
||||||
|
|
||||||
|
fields_map = {
|
||||||
|
"cid": "企业ID",
|
||||||
|
"update_time": "更新日期",
|
||||||
|
"rid": "评价ID",
|
||||||
|
"esg_level": "ESG评级",
|
||||||
|
"factors_score": "维度得分情况"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class Company(SpecObject):
|
class Company(SpecObject):
|
||||||
"""企业"""
|
"""企业"""
|
||||||
|
|
||||||
|
@ -361,13 +325,8 @@ class Company(SpecObject):
|
||||||
basic_info = ValidateAttr(field='basic_info', type=BasicInfo)
|
basic_info = ValidateAttr(field='basic_info', type=BasicInfo)
|
||||||
share_holder = ValidateAttr(field='share_holders', instance_list=ShareHolder)
|
share_holder = ValidateAttr(field='share_holders', instance_list=ShareHolder)
|
||||||
main_members = ValidateAttr(field="main_members", instance_list=MainMember)
|
main_members = ValidateAttr(field="main_members", instance_list=MainMember)
|
||||||
balance_sheet = ValidateAttr(field='balance_sheet', type=BalanceSheet)
|
|
||||||
profit_sheet = ValidateAttr(field='profit_sheet', type=ProfitSheet)
|
|
||||||
# income_sheet = {}
|
|
||||||
appendix_sheet = ValidateAttr(field='appendix_sheet', type=AppendixDataSheet)
|
|
||||||
fin_index = ValidateAttr(field='fin_index', type=FinancialIndex)
|
|
||||||
cc_rating_result = ValidateAttr(field='cc_rating_result', type=CCRating)
|
cc_rating_result = ValidateAttr(field='cc_rating_result', type=CCRating)
|
||||||
esg_rating_result = ValidateAttr(field='esg_rating_result', type=dict)
|
esg_rating_result = ValidateAttr(field='esg_rating_result', type=ESGRating)
|
||||||
update_time = ValidateAttr(field='update_time', type=dict)
|
update_time = ValidateAttr(field='update_time', type=dict)
|
||||||
|
|
||||||
fields_map = {
|
fields_map = {
|
||||||
|
@ -378,11 +337,6 @@ class Company(SpecObject):
|
||||||
"basic_info": "工商信息",
|
"basic_info": "工商信息",
|
||||||
"share_holders": "股东信息",
|
"share_holders": "股东信息",
|
||||||
"main_members": "主要成员",
|
"main_members": "主要成员",
|
||||||
"balance_sheet": "资产负债表",
|
|
||||||
"profit_sheet": "利润表",
|
|
||||||
"income_sheet": "现金流量表",
|
|
||||||
"appendix_sheet": "财务补充数据",
|
|
||||||
"fin_index": "财务指标",
|
|
||||||
"cc_rating_result": "综信评价结果",
|
"cc_rating_result": "综信评价结果",
|
||||||
"esg_rating_result": "ESG评价结果",
|
"esg_rating_result": "ESG评价结果",
|
||||||
"update_time": "更新时间"
|
"update_time": "更新时间"
|
||||||
|
@ -399,3 +353,6 @@ class Company(SpecObject):
|
||||||
|
|
||||||
def get_cc_rating_result(self):
|
def get_cc_rating_result(self):
|
||||||
"""综合信用评价"""
|
"""综合信用评价"""
|
||||||
|
|
||||||
|
def get_esg_rating_result(self):
|
||||||
|
"""ESG评价分析"""
|
||||||
|
|
|
@ -74,7 +74,20 @@ def cc_rating_route(**kwargs):
|
||||||
@verify_token
|
@verify_token
|
||||||
def esg_rating_route(**kwargs):
|
def esg_rating_route(**kwargs):
|
||||||
"""ESG评价分析"""
|
"""ESG评价分析"""
|
||||||
return {"info": "查询结果", "result": {}}, 200
|
try:
|
||||||
|
impl = CompanyImpl()
|
||||||
|
impl.cid = kwargs['cid']
|
||||||
|
impl.get_esg_rating_result()
|
||||||
|
if impl.esg_rating_result:
|
||||||
|
result = impl.esg_rating_result.dict_to_show(columns=['更新日期', "ESG评级", "维度得分情况"])
|
||||||
|
return {"info": "查询结果", "result": result}, 200
|
||||||
|
else:
|
||||||
|
return {"info": "查询结果", "result": {}}, 200
|
||||||
|
except ReturnConditionCheckFailed as e:
|
||||||
|
e.log_error()
|
||||||
|
return {"info": e.failed_info}, e.status_code
|
||||||
|
# except KeyError:
|
||||||
|
# return {"info": "参数异常"}, 400
|
||||||
|
|
||||||
|
|
||||||
@company_route.route('/financial_elements', methods=['GET'])
|
@company_route.route('/financial_elements', methods=['GET'])
|
||||||
|
|
Loading…
Reference in New Issue