diff --git a/Implements/Company/Index.py b/Implements/Company/IndexImpl.py similarity index 99% rename from Implements/Company/Index.py rename to Implements/Company/IndexImpl.py index 84147c5..8ef973d 100644 --- a/Implements/Company/Index.py +++ b/Implements/Company/IndexImpl.py @@ -78,20 +78,22 @@ class CompanyIndexImpl(CompanyIndex): self.business_info = business_info - def get_industry_analysis(self): - """企业主页 行业分析""" - + def get_industry_type(self): industry = self.db.find_single_column( "企业数据", "企业数据_更新汇总", {"企业ID": self.cid}, "一级行业" ) + self.industry = industry + + def get_industry_analysis(self): + """企业主页 行业分析""" result = self.db.find_single_data( "行业数据", "行业分析", - {"行业": industry}, + {"行业": self.industry}, ["行业", "行业简介", "更新时间", "正面因素", "负面因素", "增长趋势", "规模分布"] ) diff --git a/Implements/Industry/IndustryImpl.py b/Implements/Industry/IndustryImpl.py new file mode 100644 index 0000000..414fc07 --- /dev/null +++ b/Implements/Industry/IndustryImpl.py @@ -0,0 +1,19 @@ +from DBHelper.MongoHelper import MongoHelper +from ObjectsInProject.Industry.Industry import IndustryReportRecord + + +class IndustryReportRecordImpl(IndustryReportRecord): + + db = MongoHelper("tfse_v0.21") + + def get_latest_fid(self): + + result = self.db.find_single_data_with_single_sort( + "行业数据", + "行业报告", + {"一级行业": self.industry}, + ["报告fid"], + {"上传日期": -1} + ) + + self.fid = result['报告fid'] diff --git a/Implements/Industry/__init__.py b/Implements/Industry/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Implements/Others/TFSEFileImpl.py b/Implements/Others/TFSEFileImpl.py index e4a5565..8dc36ba 100644 --- a/Implements/Others/TFSEFileImpl.py +++ b/Implements/Others/TFSEFileImpl.py @@ -1,10 +1,10 @@ from flask import Response from DBHelper.MongoHelper import MongoHelper -from ObjectsCommon.Others.FECRFile import FECRFile +from ObjectsInProject.Other.TFSEFile import TFSEFile -class TFSEFileImpl(FECRFile): +class TFSEFileImpl(TFSEFile): """文件类实现""" db = MongoHelper("tfse_v0.21") diff --git a/ObjectsInProject/Company/Index.py b/ObjectsInProject/Company/Index.py index df2b046..3bd272b 100644 --- a/ObjectsInProject/Company/Index.py +++ b/ObjectsInProject/Company/Index.py @@ -80,6 +80,7 @@ class CompanyIndex(SpecObject): cid = ValidateAttr(field='cid', type=str, length=8) name = ValidateAttr(field='name', type=str) + industry = ValidateAttr(field='industry', type=str) head_info = ValidateAttr(field='head_info', type=HeadInfo) business_info = ValidateAttr(field='business_info', type=BasicBusinessInfo) industry_analysis = ValidateAttr(field='industry_analysis', type=IndustryAnalysis) @@ -91,6 +92,7 @@ class CompanyIndex(SpecObject): fields_map = { "cid": "企业ID", "name": "企业名称", + "industry": "行业", "head_info": "工商信息", "business_info": "股东信息", "industry_analysis": "主要成员", @@ -106,6 +108,9 @@ class CompanyIndex(SpecObject): def get_business_info(self): """获取 工商基本信息""" + def get_industry_type(self): + """获取行业类型""" + def get_industry_analysis(self): """获取 行业分析数据""" diff --git a/ObjectsInProject/Industry/Industry.py b/ObjectsInProject/Industry/Industry.py new file mode 100644 index 0000000..11c026b --- /dev/null +++ b/ObjectsInProject/Industry/Industry.py @@ -0,0 +1,21 @@ +from Utils.ObjUtil import SpecObject +from Utils.ValidateUtil import ValidateAttr + + +class IndustryReportRecord(SpecObject): + """行业""" + + industry = ValidateAttr(field='industry', type=str) + title = ValidateAttr(field='title', type=str) + update_time = ValidateAttr(field='update_time', type=str) + fid = ValidateAttr(field='fid', type=str) + + fields_map = { + "industry": "一级行业", + "title": "报告标题", + "update_time": "上传日期", + "fid": "报告fid" + } + + def get_latest_fid(self): + """获取最新一期报告""" diff --git a/ObjectsInProject/Industry/__init__.py b/ObjectsInProject/Industry/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ObjectsCommon/Others/FECRFile.py b/ObjectsInProject/Other/TFSEFile.py similarity index 83% rename from ObjectsCommon/Others/FECRFile.py rename to ObjectsInProject/Other/TFSEFile.py index 2130600..9a71055 100644 --- a/ObjectsCommon/Others/FECRFile.py +++ b/ObjectsInProject/Other/TFSEFile.py @@ -4,11 +4,11 @@ from Utils.ObjUtil import SpecObject from Utils.ValidateUtil import ValidateAttr -class FECRFile(SpecObject): +class TFSEFile(SpecObject): """文件类""" file_id = ValidateAttr(field='file_id', type=str) - file_bucket = ValidateAttr(field='file_bucket', in_list=["综信报告", "综信证书", "ESG报告", "ESG证书"]) + file_bucket = ValidateAttr(field='file_bucket', in_list=["综信报告", "综信证书", "ESG报告", "ESG证书", "行业分析报告"]) file_body = ValidateAttr(field='file_body', type=Response, default=None) fields_map = { diff --git a/ObjectsInProject/Other/__init__.py b/ObjectsInProject/Other/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Routes/Company/Index.py b/Routes/Company/IndexRoute.py similarity index 98% rename from Routes/Company/Index.py rename to Routes/Company/IndexRoute.py index 1aebc79..1251fcf 100644 --- a/Routes/Company/Index.py +++ b/Routes/Company/IndexRoute.py @@ -4,7 +4,7 @@ from flask import Blueprint from Utils.AuthUtil import verify_token from Utils.ErrorUtil import ReturnConditionCheckFailed -from Implements.Company.Index import CompanyIndexImpl +from Implements.Company.IndexImpl import CompanyIndexImpl company_route = Blueprint('company', __name__) @@ -49,6 +49,7 @@ def industry_analysis_route(**kwargs): try: impl = CompanyIndexImpl() impl.cid = kwargs['cid'] + impl.get_industry_type() impl.get_industry_analysis() if impl.industry_analysis: result = impl.industry_analysis.dict_to_show() diff --git a/Routes/Other/TFSEFileRoute.py b/Routes/Other/TFSEFileRoute.py index 70527d1..8f937c6 100644 --- a/Routes/Other/TFSEFileRoute.py +++ b/Routes/Other/TFSEFileRoute.py @@ -1,5 +1,7 @@ from flask import Blueprint, request, Response +from Implements.Company.IndexImpl import CompanyIndexImpl +from Implements.Industry.IndustryImpl import IndustryReportRecordImpl from Implements.Others.TFSEFileImpl import TFSEFileImpl from Utils.AuthUtil import verify_token, verify_report_view_auth @@ -62,3 +64,25 @@ def get_esg_rating_certificate_route(**kwargs): return impl.dict_to_return() else: return {"info": "文件不存在"}, 200 + + +@file_route.route('/get_industry_report', methods=['GET']) +@verify_token +def get_industry_report_route(**kwargs): + """获取行业报告""" + company_impl = CompanyIndexImpl() + company_impl.cid = kwargs['cid'] + company_impl.get_industry_type() + + industry_impl = IndustryReportRecordImpl() + industry_impl.industry = company_impl.industry + industry_impl.get_latest_fid() + + file_impl = TFSEFileImpl() + file_impl.file_bucket = '行业分析报告' + file_impl.file_id = industry_impl.fid + file_impl.get_pdf() + if file_impl.file_body: + return file_impl.dict_to_return() + else: + return {"info": "文件不存在"}, 200 diff --git a/app.py b/app.py index b4d5249..b9eb8f5 100644 --- a/app.py +++ b/app.py @@ -2,7 +2,7 @@ from flask import Flask from flask_cors import * -from Routes.Company.Index import company_route +from Routes.Company.IndexRoute import company_route from Routes.Other.EmailNoticeRoute import email_route from Routes.Other.TFSEFileRoute import file_route from Routes.User.TFSECompanyUserRoute import company_user_route