From 9b6a4a0030e30728fe18e4e05c9b2549eddef02c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=80=9D=E5=B7=9D?= Date: Fri, 24 Dec 2021 16:59:37 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=95=B4=E5=90=88=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=B8=B4=E6=97=B6=E5=AD=98=E5=82=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- input/scripts.py | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/input/scripts.py b/input/scripts.py index 0c3be9e..064f6cb 100644 --- a/input/scripts.py +++ b/input/scripts.py @@ -216,21 +216,26 @@ def exec_general_rating_scripts(cid): risks["风险数据"].pop('评价ID') rating_inputs = {**inputs, **risks} - # main - url = "http://139.9.249.34:51012/tfse_rating/rating/general_model" - token = "X0gSlC!YE8jmr2jJr&ilcjS83j!tsoh5" - headers = {'token': token, "Content-Type": "application/json;charset=UTF-8"} - data = json.dumps({"input_data": rating_inputs}) - res = requests.post(url, headers=headers, data=data) - if res.status_code == 200: - update_data = { - "评价结果": json.loads(res.text)['result'], - "评价时间": time.strftime("%Y-%m-%d", time.localtime()), - "进行状态": "完成", - "报告fid": "xxx", - "证书fid": "xxx" - } - update_rating_records({"评价ID": rid}, update_data) - return True - else: - return False + # 打分模型 + def general_model(): + url = "http://139.9.249.34:51012/tfse_rating/rating/general_model" + token = "X0gSlC!YE8jmr2jJr&ilcjS83j!tsoh5" + headers = {'token': token, "Content-Type": "application/json;charset=UTF-8"} + data = json.dumps({"input_data": rating_inputs}) + res = requests.post(url, headers=headers, data=data) + if res.status_code == 200: + update_data = { + "评价结果": json.loads(res.text)['result'], + "评价时间": time.strftime("%Y-%m-%d", time.localtime()), + "进行状态": "完成", + "报告fid": None, + "证书fid": None + } + update_rating_records({"评价ID": rid}, update_data) + return True + else: + return False + + # 生成报告 + def gen_report(): + pass From 074fc8e047a147eb5cab8f09b12c722d65ef9368 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=80=9D=E5=B7=9D?= Date: Mon, 27 Dec 2021 16:30:57 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BC=81=E4=B8=9A=E4=B8=BB=E9=A1=B5=20?= =?UTF-8?q?=E5=A4=B4=E9=83=A8=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/scripts.py | 12 ++++++++++++ company/CompanyIndex.py | 6 +++++- company/routes.py | 11 ++++++++++- company/scripts.py | 18 ++++++++++++++++++ 4 files changed, 45 insertions(+), 2 deletions(-) diff --git a/common/scripts.py b/common/scripts.py index 2097ad3..4d04850 100644 --- a/common/scripts.py +++ b/common/scripts.py @@ -83,3 +83,15 @@ def make_verify_code(): ch = chr(random.randrange(ord('0'), ord('9') + 1)) code += ch return code + + +def sub_dict(param1, param2): + """ + 获取字典的子集 + Parameters: + param1: 原字典 + param2: 子集字段 + Returns: + 子集 + """ + return dict((key, value) for key, value in param1.items() if key in param2) diff --git a/company/CompanyIndex.py b/company/CompanyIndex.py index 32efa02..e8a5033 100644 --- a/company/CompanyIndex.py +++ b/company/CompanyIndex.py @@ -1,4 +1,4 @@ -from company.scripts import find_company_data_scripts, find_financial_index_detail_scripts +from company.scripts import find_company_data_scripts, find_financial_index_detail_scripts, find_head_info_scripts class CompanyIndex: @@ -21,3 +21,7 @@ class CompanyIndex: return '查询成功', result else: return '无数据', {} + + def head_info_obj(self): + result = find_head_info_scripts(self.cid) + return "查询成功", result diff --git a/company/routes.py b/company/routes.py index 2b973ea..762a689 100644 --- a/company/routes.py +++ b/company/routes.py @@ -23,4 +23,13 @@ def company_page(**kwargs): info, result = company_index.get_company_data_obj() else: info, result = company_index.get_index_detail_obj() - return {"info": info, "result": result} + return {"info": info, "result": result}, 200 + + +@company_route.route('/head_info', methods=['GET']) +@verify_token +def head_info(**kwargs): + company_index = CompanyIndex() + company_index.cid = kwargs['cid'] + info, result = company_index.head_info_obj() + return {"info": info, "result": result}, 200 diff --git a/company/scripts.py b/company/scripts.py index a49a5a4..8465b6c 100644 --- a/company/scripts.py +++ b/company/scripts.py @@ -1,6 +1,7 @@ import json import pandas as pd +from common.scripts import sub_dict from company.db import find_data_in_company @@ -8,6 +9,23 @@ def find_company_data_scripts(table, cid): return find_data_in_company(table, {"企业ID": cid}) +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 + + def find_financial_index_detail_scripts(table, cid): df = pd.DataFrame(find_data_in_company(table, {"企业ID": cid})).sort_values('年报期', ascending=False) cols = [