From 636edebc2e136a45e0c53ff07a544b09e4ca0b9c Mon Sep 17 00:00:00 2001 From: P3ngSaM <61768364+P3ngSaM@users.noreply.github.com> Date: Thu, 10 Mar 2022 14:50:18 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=BF=AE=E6=94=B9=E4=BC=81=E4=B8=9A?= =?UTF-8?q?=E6=B5=8B=E8=AF=84=E6=B5=81=E7=A8=8B=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TestCenter/tc_db.py | 6 +++--- TestCenter/tc_impl.py | 27 ++++++++++++++++++++++++--- TestCenter/tc_obj.py | 2 +- TestCenter/tc_routes.py | 3 ++- 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/TestCenter/tc_db.py b/TestCenter/tc_db.py index 067de59..05eb2cf 100644 --- a/TestCenter/tc_db.py +++ b/TestCenter/tc_db.py @@ -46,14 +46,14 @@ def find_admin_data(param1, param2, param3): Returns: res: list 符合条件的数据 """ - collection = client_admin[param1][param2] + collection = client[param1][param2] res = list(collection.find(param3, {'_id': False})) return res def insert_admin_data(param1, param2, param3): """ - 根据查询条件查询符合条件的所有数据 + 插入数据(admin) Parameters: param1: str 数据库 param2: str 数据集 @@ -61,7 +61,7 @@ def insert_admin_data(param1, param2, param3): Returns: res: list 符合条件的数据 """ - collection = client_admin[param1][param2] + collection = client[param1][param2] collection.insert_one(param3) return True diff --git a/TestCenter/tc_impl.py b/TestCenter/tc_impl.py index 1287bb3..431e0d9 100644 --- a/TestCenter/tc_impl.py +++ b/TestCenter/tc_impl.py @@ -44,6 +44,7 @@ def delete_rid_cascade_scripts(rid, record, data): Returns: res: True 执行结果 """ + def delete_all_records(): """ 根据rid删除评价数据库相匹配数据 @@ -137,6 +138,7 @@ def generate_rid_information_script(rid, types): Returns: result str 生成结果 """ + def rating_script(): """ 根据rid执行综合信用评价流程 @@ -380,6 +382,7 @@ def company_verify_script(company, code, legal_person, cid): Returns: result: 认证结果 """ + def check_verified(): # 是否认证 r = find_user_info_by_cid(cid) @@ -459,6 +462,7 @@ def new_test_company_impl(email, company, code, legal_person): """ 新增一家测试企业 """ + def check_mail_fmt(): """ 邮箱地址格式校验 @@ -491,6 +495,7 @@ def new_test_company_impl(email, company, code, legal_person): Returns: new_id: 生成的企业ID """ + def make_id(num): """ 随机生成字符串 @@ -536,7 +541,7 @@ def new_test_company_impl(email, company, code, legal_person): def create_user_by_template(): file_rel_path = "/static/user.json" - with open(os.path.abspath(os.path.dirname(__file__)+file_rel_path), "r", encoding='utf-8') as f: + with open(os.path.abspath(os.path.dirname(__file__) + file_rel_path), "r", encoding='utf-8') as f: user = json.load(f) user['企业ID'] = cid @@ -570,15 +575,31 @@ def new_test_company_impl(email, company, code, legal_person): return new_company_main_process() -def get_company_process_script(rid, cid): +def get_company_process_script(types, rid, cid): """ 查询企业测评流程 Parameters: + types str 数据集名称 rid str 评价ID cid str 企业ID Returns: result dict 流程数据 """ - data = find_admin_data("看板", "评价流程", {"评价ID": rid, "企业ID": cid}) + data = find_admin_data("评价", types, {"评价ID": rid, "企业ID": cid}) return data + +if __name__ == '__main__': + insert = { + "企业ID": "QZhQ12Cw", + "评价ID": "bw1tcQfP", + "评价流程": { + "数据填报": 1, + "清洗风险数据": 1, + "模型打分": 1, + "报告生成": 1, + "证书生成": -1, + "主页ESG数据生成": 0 + } + } + insert_admin_data("评价", "ESG评价流程", insert) \ No newline at end of file diff --git a/TestCenter/tc_obj.py b/TestCenter/tc_obj.py index 09cef7b..b8068ae 100644 --- a/TestCenter/tc_obj.py +++ b/TestCenter/tc_obj.py @@ -72,5 +72,5 @@ class TestObj: """ 获取企业测评流程 """ - data = get_company_process_script(self.rid, self.cid) + data = get_company_process_script(self.types, self.rid, self.cid) return data diff --git a/TestCenter/tc_routes.py b/TestCenter/tc_routes.py index c720ea8..735d560 100644 --- a/TestCenter/tc_routes.py +++ b/TestCenter/tc_routes.py @@ -133,7 +133,7 @@ def new_company_route(**kwargs): @test_route.route('/get_company_process', methods=['POST']) -@verify_token +@api_secret def get_company_process(): """ 获取评测流程 @@ -145,6 +145,7 @@ def get_company_process(): test_obj = TestObj() test_obj.rid = request.json['rid'] test_obj.cid = request.json['cid'] + test_obj.types = request.json['types'] info = test_obj.get_company_process() status = 200 if info else 210 return {"info": info}, status