From b72d894a637ef343d524c48cec2b27174bbeabae Mon Sep 17 00:00:00 2001 From: P3ngSaM <61768364+P3ngSaM@users.noreply.github.com> Date: Thu, 24 Feb 2022 16:15:04 +0800 Subject: [PATCH] =?UTF-8?q?update=20ESG=E4=B8=BB=E9=A1=B5=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=B1=95=E7=A4=BA=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- company/company_impl.py | 18 ++++++++++++++++++ company/company_obj.py | 5 ++++- company/company_routes.py | 16 ++++++++++++++++ esg/esg_impl.py | 18 ++++++++++++++++++ 4 files changed, 56 insertions(+), 1 deletion(-) diff --git a/company/company_impl.py b/company/company_impl.py index 730be12..dec290b 100644 --- a/company/company_impl.py +++ b/company/company_impl.py @@ -92,3 +92,21 @@ def industry_analysis_impl(cid): return data + +def esg_analysis_impl(cid): + """ + ESG要素分析数据 + Parameters: + cid: str 企业ID + Returns: + Case Success: + data: dict ESG分析数据 + Case Fail: + data: dict 空字典 + """ + data = FIND_DATA_IN_COMPANY('ESG要素分析',{"企业ID": cid}) + + if data is False: + return {} + + return data \ No newline at end of file diff --git a/company/company_obj.py b/company/company_obj.py index 6cf9c03..1b2c738 100644 --- a/company/company_obj.py +++ b/company/company_obj.py @@ -1,5 +1,5 @@ from company.company_impl import find_company_data_scripts, find_financial_index_detail_scripts, get_head_info_impl, \ - industry_analysis_impl + industry_analysis_impl, esg_analysis_impl class CompanyIndex: @@ -33,3 +33,6 @@ class CompanyIndex: def industry_analysis(self): return industry_analysis_impl(self.cid) + + def esg_analysis(self): + return esg_analysis_impl(self.cid) diff --git a/company/company_routes.py b/company/company_routes.py index 9645445..7ff1d7e 100644 --- a/company/company_routes.py +++ b/company/company_routes.py @@ -50,3 +50,19 @@ def industry_analysis_route(**kwargs): ci.cid = kwargs['cid'] result = ci.industry_analysis() return {"info": "查询成功", "result": result} + + +@company_route.route('/esg_analysis', methods=['GET']) +@verify_token +def esg_analysis_route(**kwargs): + """ + ESG分析数据 + Parameters: + param desc + Returns: + res: desc + """ + ci = CompanyIndex() + ci.cid = kwargs['cid'] + result = ci.esg_analysis() + return {"info": "查询成功", "result": result} diff --git a/esg/esg_impl.py b/esg/esg_impl.py index 7f3b785..f2167ae 100644 --- a/esg/esg_impl.py +++ b/esg/esg_impl.py @@ -140,6 +140,7 @@ def start_esg_rating_script(cid): new_input[sheets]['近三年公司数据'][i]['年份'] = report_dates[i] # 生成新评价记录 + rating_json = '/static/template/rating.json' with open(os.path.dirname(__file__) + rating_json, "r", encoding='utf-8') as f: rating = json.load(f) @@ -239,12 +240,29 @@ def exec_esg_rating_scripts(cid): else: return False + # 生成企业主页数据 + def esg_index(): + url = "http://139.9.249.34:51011/etl_tfse/company/esg_index_etl" + token = "dmfd7FshT!5Wng9^gcCcQV7T6FBnVgl4" + headers = {'token': token, "Content-Type": "application/json;charset=UTF-8"} + data = { + "rid": rating_inputs['评价ID'] + } + res = requests.post(url, headers=headers, data=json.dumps(data)) + if res.status_code == 200: + return True + else: + return False + if not esg_model(): return False, "打分失败" if not gen_report(): return False, "生成报告失败" + if not esg_index(): + return False, "准备主页数据失败" + update_rating_records({"评价ID": rid}, {"进行状态": "完成"}) return True, "执行成功"