From 8466d0ab76c3b6ebad1d8ff438b945f9c63f7eac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=80=9D=E5=B7=9D?= Date: Thu, 10 Mar 2022 16:43:55 +0800 Subject: [PATCH] =?UTF-8?q?esg=E9=97=AE=E5=8D=B7=EF=BC=8C=E6=89=80?= =?UTF-8?q?=E5=B1=9E=E8=A1=8C=E4=B8=9A=E8=87=AA=E5=8A=A8=E5=A1=AB=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- esg/esg_db.py | 14 ++++++++++++++ esg/esg_impl.py | 13 +++++++++++++ 2 files changed, 27 insertions(+) diff --git a/esg/esg_db.py b/esg/esg_db.py index 6e4921a..ec6a424 100644 --- a/esg/esg_db.py +++ b/esg/esg_db.py @@ -101,3 +101,17 @@ def insert_process_records(data): """ collection = client['评价']['ESG评价流程'] collection.insert_one(data) + + +def find_industry_by_cid(cid): + """ + 根据cid查询企业所属行业 + Args: + cid: 企业ID + Returns: + industry: 所属行业 + """ + collection = client['企业']['公司基本信息'] + data = collection.find({"企业ID": cid}, {'_id': False}) + industry = data[0]['工商信息']['行业'] + return industry diff --git a/esg/esg_impl.py b/esg/esg_impl.py index 48c0011..f0b5ea4 100644 --- a/esg/esg_impl.py +++ b/esg/esg_impl.py @@ -38,6 +38,18 @@ def get_current_year(): return current_year +def get_industry_type(cid): + """ + 获取行业类型 + Parameters: + cid 企业ID + Returns: + industry_type 行业类型 + """ + + return 0 + + def gen_new_rid(): """ 生成新的评价ID,如果该ID存在,则重新生成 @@ -147,6 +159,7 @@ def start_esg_rating_script(cid): new_input['企业ID'] = cid new_input['企业名称'] = company_name new_input['评价年度'] = get_current_year() + new_input['所属行业'] = get_industry_type(cid) new_input['公司当年收入(万元)'] = dict() for y in range(3): new_input['公司当年收入(万元)'][report_dates[y]] = None