diff --git a/Esg/scripts/environmental.py b/Esg/scripts/environmental.py index fe1d3a7..4bf658b 100644 --- a/Esg/scripts/environmental.py +++ b/Esg/scripts/environmental.py @@ -226,7 +226,7 @@ def calculation_05(param): # Parameter answer = param['环境问卷']['其他类型问卷'][0] - if answer[0] == '是' and answer[1] is not None: + if isinstance(answer, list) and len(answer) == 2: score = 1 else: score = 0 @@ -244,7 +244,7 @@ def calculation_06(param): """ answer = param['环境问卷']['其他类型问卷'][1] - if answer[0] == '是' and answer[1] is not None: + if isinstance(answer, list) and len(answer) == 2: score = 1 else: score = 0 @@ -262,7 +262,7 @@ def calculation_07(param): """ answer = param['环境问卷']['其他类型问卷'][2] - if answer[0] == '是' and answer[1] is not None: + if isinstance(answer, list) and len(answer) == 2: score = 1 else: score = 0 @@ -280,7 +280,7 @@ def calculation_08(param): """ answer = param['环境问卷']['其他类型问卷'][3] - if answer[0] == '是' and answer[1] is not None: + if isinstance(answer, list) and len(answer) == 2: score = 2 else: score = 0 @@ -298,7 +298,7 @@ def calculation_09(param): """ answer = param['环境问卷']['其他类型问卷'][4] - if answer[0] == '是': + if answer[0] == 'A': score = 'E=0' else: score = 0 @@ -316,7 +316,7 @@ def calculation_10(param): """ answer = param['环境问卷']['其他类型问卷'][5] - if answer[0] == '否': + if answer[0] == 'B': score = -2 else: score = 0 @@ -334,7 +334,7 @@ def calculation_11(param): """ answer = param['环境问卷']['其他类型问卷'][6] - if answer[0] == '是' and answer[1] is not None: + if isinstance(answer, list) and len(answer) == 2: score = 2 else: score = 0 @@ -352,7 +352,7 @@ def calculation_12(param): """ answer = param['环境问卷']['其他类型问卷'][7] - if answer[0] == '是' and answer[1] is not None: + if isinstance(answer, list) and len(answer) == 2: score = 3 else: score = 0 diff --git a/Esg/scripts/governance.py b/Esg/scripts/governance.py index 73b4f0a..49559f3 100644 --- a/Esg/scripts/governance.py +++ b/Esg/scripts/governance.py @@ -134,7 +134,7 @@ def calculation_06(param): """ answer = param['治理问卷']['其他类型问卷'][7] - if answer == '是': + if answer == 'A': score = 1 else: score = 0 diff --git a/Esg/scripts/social.py b/Esg/scripts/social.py index 41ab1e0..4b705ad 100644 --- a/Esg/scripts/social.py +++ b/Esg/scripts/social.py @@ -209,7 +209,7 @@ def calculation_07(param): """ anwser = param['社会问卷']['其他类型问卷'][0] - if anwser == '是': + if anwser == 'A': score = 1 else: score = 0 @@ -227,7 +227,7 @@ def calculation_08(param): """ anwser = param['社会问卷']['其他类型问卷'][1] - if anwser == '是': + if anwser == 'A': score = 1 else: score = 0 @@ -245,7 +245,7 @@ def calculation_09(param): """ anwser = param['社会问卷']['其他类型问卷'][2] - if anwser == '是': + if anwser == 'A': score = 1 else: score = 0 @@ -263,7 +263,7 @@ def calculation_10(param): """ anwser = param['社会问卷']['其他类型问卷'][3] - if anwser == '是': + if anwser == 'A': score = 1 else: score = 0 diff --git a/Rating/scripts/Indicators.py b/Rating/scripts/Indicators.py index 7e5bdd1..5d76e87 100644 --- a/Rating/scripts/Indicators.py +++ b/Rating/scripts/Indicators.py @@ -170,7 +170,7 @@ def qkr(param1, param2, param3): if param3 == 0: return None else: - value = (param1 - param2) / param3 * 100 + value = (param1 - param2) / param3 value = round(value, 2) return value diff --git a/Report/PdfReport.py b/Report/PdfReport.py index 45abdf0..68b0bb2 100644 --- a/Report/PdfReport.py +++ b/Report/PdfReport.py @@ -14,15 +14,13 @@ from Report.scripts.PdfStyle import cover_space, cover_company_style, cover_repo adjust_table_data, para_bold_style, para_style_esg, para_style_special from Report.scripts.path_tool import gen_pdf_path, get_pic_path from common.scripts import read_json_file -# 页码起始设置 -# offset = 3 class HeaderAndFooterCanvas(canvas.Canvas): def __init__(self, *args, **kwargs): + self.offeset = 3 canvas.Canvas.__init__(self, *args, **kwargs) self._saved_page_states = [] - self.offeset = 2 def showPage(self): self._saved_page_states.append(dict(self.__dict__)) @@ -52,6 +50,39 @@ class HeaderAndFooterCanvas(canvas.Canvas): canvas.Canvas.save(self) +class EsgHeaderAndFooterCanvas(canvas.Canvas): + def __init__(self, *args, **kwargs): + self.offeset = 2 + canvas.Canvas.__init__(self, *args, **kwargs) + self._saved_page_states = [] + + def showPage(self): + self._saved_page_states.append(dict(self.__dict__)) + self._startPage() + + def draw_header_and_footer(self, page_count): + + self.setFont("Helvetica", 7) + if self._pageNumber > self.offeset: + self.setFont('pingbold', 8) + self.setFillColor(HexColor(Seashell4)) + self.drawString(74, 805, "远东资信评估有限公司") + self.drawString(74, 40, "%d / %d" % (self._pageNumber - self.offeset, page_count - self.offeset)) + + self.setStrokeColor(darkGolden) + self.setLineWidth(2.5) + self.line(74, 820, 6.8 * inch, 820) + self.setLineWidth(1) + self.line(74, 50, 6.8 * inch, 50) + + def save(self): + num_pages = len(self._saved_page_states) + for state in self._saved_page_states: + self.__dict__.update(state) + self.draw_header_and_footer(num_pages) + canvas.Canvas.showPage(self) + canvas.Canvas.save(self) + class MyDocTemplate(BaseDocTemplate): def __init__(self, filename, **kw): self.allowSplitting = 1 @@ -92,11 +123,13 @@ class ReportGenerator: # 生成报告 def gen_report(self): if '报告类型' in self.text_model: + offeset = 2 self.gen_esg_cover() self.gen_menu() self.gen_esg_part() - self.doc.multiBuild(self.story, canvasmaker=HeaderAndFooterCanvas) + self.doc.multiBuild(self.story, canvasmaker=EsgHeaderAndFooterCanvas) else: + offeset = 3 self.gen_cover() self.gen_menu() self.gen_main_part() @@ -128,6 +161,7 @@ class ReportGenerator: self.story.append(Paragraph(data['生成日期'], cover_time_style)) self.story.append(PageBreak()) + # esg封面 def gen_esg_cover(self): data = self.text_model self.story.append(Paragraph('.', cover_space)) @@ -176,6 +210,7 @@ class ReportGenerator: td = adjust_table_data(part['表格']) self.story.append(Table(td, style=style)) + # esg正文 def gen_esg_part(self): data = self.text_model['报告内容'] for chapter in data: diff --git a/Report/static/ReportTemplates/信息技术业.json b/Report/static/ReportTemplates/信息技术业.json index 824b059..73a2ff3 100644 --- a/Report/static/ReportTemplates/信息技术业.json +++ b/Report/static/ReportTemplates/信息技术业.json @@ -403,7 +403,7 @@ "段落": "信息技术业多具有经济带动性、创新驱动性、多领域融合、质量品牌和绿色集约特征,市场认可度高,处于初创期和成长期的信息技术业企业市场份额拓展较快,成长速度很快;处于成熟期的信息技术业企业已占有较大市场份额,且通过产品多元化等方式拓展市场,成长性受到公司战略和决策能力、研发能力、研发速度、技术先进性、\n\n潜在市场空间、资金等因素影响。" }, { - "段落": "公司{degree_of_imprtance},2020年公司技术投入比为{technology_input_ratio}。技术创新对公司业务拓展的贡献{contribution},2020年公司营业收入增长率、总资产增长率分别为{growth_rate_of_operating_revenue}和{growth_rate_of_total_assets},整体成长能力{growth_ability}。" + "段落": "公司{degree_of_imprtance},2020年公司技术投入比为{technology_input_ratio}%。技术创新对公司业务拓展的贡献{contribution},2020年公司营业收入增长率、总资产增长率分别为{growth_rate_of_operating_revenue}%和{growth_rate_of_total_assets}%,整体成长能力{growth_ability}。" } ] } diff --git a/Report/static/ReportTemplates/制造业.json b/Report/static/ReportTemplates/制造业.json index bd06dcd..878b058 100644 --- a/Report/static/ReportTemplates/制造业.json +++ b/Report/static/ReportTemplates/制造业.json @@ -403,7 +403,7 @@ "段落": "先进制造业多具有经济带动性、创新驱动性、多领域融合、质量品牌和绿色集约特征,市场认可度高,处于初创期和成长期的先进制造业企业市场份额拓展较快,成长速度很快;处于成熟期的先进制造业企业已占有较大市场份额,且通过产品多元化或地域多元化等方式拓展市场,成长性受到公司战略和决策能力、研发能力、研发速度、技术先进性、潜在市场空间、资金等因素影响。传统制造业多处于成熟期或衰退期,企业成长能力较弱,各项资源向行业内龙头企业聚集,中小企业发展空间较小。" }, { - "段落": "公司{degree_of_imprtance},2020年公司技术投入比为{technology_input_ratio}。技术创新对公司业务拓展的贡献{contribution},2020年公司营业收入增长率、总资产增长率分别为{growth_rate_of_operating_revenue}和{growth_rate_of_total_assets},整体成长能力{growth_ability}。" + "段落": "公司{degree_of_imprtance},2020年公司技术投入比为{technology_input_ratio}%。技术创新对公司业务拓展的贡献{contribution},2020年公司营业收入增长率、总资产增长率分别为{growth_rate_of_operating_revenue}%和{growth_rate_of_total_assets}%,整体成长能力{growth_ability}。" } ] }