From e339c95a4dacb480dc0537468dfb525de7b0f853 Mon Sep 17 00:00:00 2001 From: Julin Date: Mon, 11 Dec 2023 10:38:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E4=BC=98=E5=8C=96=EF=BC=9A?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=A1=B5=E8=BE=B9=E8=B7=9D=E3=80=81=E8=A1=A8?= =?UTF-8?q?=E6=A0=BC=E8=A1=8C=E8=B7=9D=E3=80=81=E5=9B=BE=E7=89=87=E5=A4=A7?= =?UTF-8?q?=E5=B0=8F=E7=AD=89=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code/pep-stats-report/app/db_helper.py | 2 +- code/pep-stats-report/main.py | 22 ++++++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/code/pep-stats-report/app/db_helper.py b/code/pep-stats-report/app/db_helper.py index b57bb0a..e9a85c4 100644 --- a/code/pep-stats-report/app/db_helper.py +++ b/code/pep-stats-report/app/db_helper.py @@ -80,7 +80,7 @@ from workflow_process_achievements as wpa inner join "user" as u on wpa.deal_user_id=u.id inner join department_user as du on u.id=du."user" inner join department as d on du.department=d.id -where wpa.end_time >='{start}' and wpa.end_time < '{end}' and u.delete=0 and u.state=1 and u.active_status=1 +where wpa.end_time >='{start}' and wpa.end_time < '{end}' and d.delete=0 and u.delete=0 and u.state=1 and u.active_status=1 and d.name not in {IGNORE_DEPARTMENTS} {IGNORE_PERSONS_SUBQUERY} ''' diff --git a/code/pep-stats-report/main.py b/code/pep-stats-report/main.py index 4e23b8d..503fd43 100644 --- a/code/pep-stats-report/main.py +++ b/code/pep-stats-report/main.py @@ -118,9 +118,15 @@ def set_global_normal_style(doc): style.font.name = 'Times New Roman' # 英文、数字字体 style._element.rPr.rFonts.set(qn('w:eastAsia'), u'宋体') # 中文字体 style.font.size = Pt(14) # 四号 - style.paragraph_format.space_before = Pt(6) # 段前0.5行 - style.paragraph_format.space_after = Pt(6) # 段后0.5行 - style.paragraph_format.line_spacing_rule = WD_LINE_SPACING.ONE_POINT_FIVE # 1.5倍行距 + style.paragraph_format.space_before = 0 # 段前 + style.paragraph_format.space_after = 0 # 段后 + style.paragraph_format.line_spacing_rule = WD_LINE_SPACING.SINGLE # 单倍行距 + # 设置页边距 + section = doc.sections[0] + section.top_margin = Cm(1.27) + section.right_margin = Cm(0.5) + section.bottom_margin = Cm(1.27) + section.left_margin = Cm(0.5) # 设置单元格底纹 @@ -159,7 +165,7 @@ def create_twinx_chart(department, title, filename): bgcolor = '#d9d9d9' - fig, ax1 = plt.subplots(figsize=(8, 5), layout='constrained', facecolor=bgcolor) + fig, ax1 = plt.subplots(figsize=(10, 6), layout='constrained', facecolor=bgcolor) ax1.set_ylabel('平均处理流程时间(小时)') y1_bar = ax1.bar(x_range, y1, width=0.25, label='流程处理时间', color=(91 / 255, 155 / 255, 213 / 255)) @@ -272,7 +278,7 @@ def add_section(doc, department_data): p = doc.add_paragraph() p.alignment = WD_PARAGRAPH_ALIGNMENT.CENTER r = p.add_run() - r.add_picture('{}/{}'.format(REPORT_DIR, pic_name), width=Inches(6)) + r.add_picture('{}/{}'.format(REPORT_DIR, pic_name), width=Cm(20.27)) def add_chapter_2(doc): @@ -388,16 +394,16 @@ def add_chapter_1(doc): set_paragraph_format(p) table_data = list(map(lambda d: (d[0], d[1], d[2]), procinst_by_department)) - insert_table(doc, ['序号', '部门', '人均处理流程条数', '平均单条流程处理时间'], {0: 1.5, 1: 5.8, 2: 3.6, 3: 4.3}, table_data, 'style1') + insert_table(doc, ['序号', '部门', '人均处理流程条数', '平均单条流程处理时间'], {0: 1.8, 1: 5.8, 2: 5.9, 3: 6.8}, table_data, 'style1') add_heading(doc, 2, '(二)部门平均单一流程处理耗时排行') table_data = list(map(lambda d: (d[0], d[2]), procinst_by_department)) table_data.sort(key=lambda d: d[1], reverse=True) - insert_table(doc, ['排名', '部门', '平均单条流程处理时间'], {0: 1.5, 1: 5.8, 2: 4.3}, table_data, 'style2') + insert_table(doc, ['排名', '部门', '平均单条流程处理时间'], {0: 1.5, 1: 5.8, 2: 6.2}, table_data, 'style2') add_heading(doc, 2, '(三)部门人均处理流程平均条数排行') table_data = list(map(lambda d: (d[0], d[1]), procinst_by_department)) - insert_table(doc, ['排名', '部门', '人均处理流程条数'], {0: 1.5, 1: 5.8, 2: 4.3}, table_data, 'style3') + insert_table(doc, ['排名', '部门', '人均处理流程条数'], {0: 1.5, 1: 5.8, 2: 6.2}, table_data, 'style3') def upload_to_qiniu(filename):