|
@ -79,11 +79,11 @@ def get_report_start_end(): |
|
|
return last_month_start, this_month_start |
|
|
return last_month_start, this_month_start |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def set_paragraph_space(p): |
|
|
def set_paragraph_space(p, line_spacing=1.5): |
|
|
# 设置间距 |
|
|
# 设置间距 |
|
|
p.paragraph_format.space_before = Pt(6) # 段前 |
|
|
p.paragraph_format.space_before = Pt(6) # 段前 |
|
|
p.paragraph_format.space_after = Pt(6) # 段后 |
|
|
p.paragraph_format.space_after = Pt(6) # 段后 |
|
|
p.paragraph_format.line_spacing = 1.5 # 设置段落行距:1.5倍行距 |
|
|
p.paragraph_format.line_spacing = line_spacing # 设置段落行距:默认1.5倍行距 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def set_paragraph_format(p): |
|
|
def set_paragraph_format(p): |
|
@ -92,8 +92,8 @@ def set_paragraph_format(p): |
|
|
p.paragraph_format.first_line_indent = Inches(0.3) |
|
|
p.paragraph_format.first_line_indent = Inches(0.3) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def set_heading_format(h, r, head_level=1): |
|
|
def set_heading_format(h, r, head_level=1, line_spacing=1.5): |
|
|
set_paragraph_space(h) |
|
|
set_paragraph_space(h, line_spacing) |
|
|
r.font.name = 'Times New Roman' |
|
|
r.font.name = 'Times New Roman' |
|
|
r._element.rPr.rFonts.set(qn('w:eastAsia'), u'宋体') |
|
|
r._element.rPr.rFonts.set(qn('w:eastAsia'), u'宋体') |
|
|
r.font.size = Pt(16) if head_level == 1 else Pt(15) # 三号 -> Pt(16), 小三 -> Pt(15) |
|
|
r.font.size = Pt(16) if head_level == 1 else Pt(15) # 三号 -> Pt(16), 小三 -> Pt(15) |
|
@ -143,10 +143,10 @@ def set_table_row_shading_color(table_row, color): |
|
|
cell._tc.get_or_add_tcPr().append(shading_dict['shading_elm_' + str(i)]) |
|
|
cell._tc.get_or_add_tcPr().append(shading_dict['shading_elm_' + str(i)]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def add_heading(doc, head_level, head_content): |
|
|
def add_heading(doc, head_level, head_content, line_spacing=1.5): |
|
|
h = doc.add_heading(level=head_level) |
|
|
h = doc.add_heading(level=head_level) |
|
|
r = h.add_run(head_content) |
|
|
r = h.add_run(head_content) |
|
|
set_heading_format(h, r, head_level) |
|
|
set_heading_format(h, r, head_level, line_spacing) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_twinx_chart(department, title, filename): |
|
|
def create_twinx_chart(department, title, filename): |
|
@ -249,27 +249,31 @@ def add_section(doc, department_data): |
|
|
|
|
|
|
|
|
d_users_gt_company_avg_duration = [u[0] for u in d_users if u[2] > procinst_duration_by_company] |
|
|
d_users_gt_company_avg_duration = [u[0] for u in d_users if u[2] > procinst_duration_by_company] |
|
|
|
|
|
|
|
|
add_heading(doc, 2, '({}){}'.format(number_to_chinese(d_elapse_rank), d_name)) |
|
|
if d_elapse_rank > 1: |
|
|
|
|
|
doc.add_page_break() # 插入分页符 |
|
|
|
|
|
|
|
|
|
|
|
add_heading(doc, 2, '({}){}'.format(number_to_chinese(d_elapse_rank), d_name), line_spacing=2) |
|
|
|
|
|
|
|
|
p = doc.add_paragraph(f'部门人均处理流程平均耗时时长排名:{d_elapse_rank};', style='List Bullet') |
|
|
p = doc.add_paragraph(f'部门人均处理流程平均耗时时长排名:{d_elapse_rank};', style='List Bullet') |
|
|
set_paragraph_space(p) |
|
|
set_paragraph_space(p, line_spacing=2) |
|
|
|
|
|
|
|
|
operator = '>' if d_elapse > procinst_duration_by_company else '<' if d_elapse < procinst_duration_by_company else '==' |
|
|
operator = '>' if d_elapse > procinst_duration_by_company else '<' if d_elapse < procinst_duration_by_company else '==' |
|
|
p = doc.add_paragraph(f'部门处理流程平均耗时时长:{d_elapse}小时{operator}公司平均{procinst_duration_by_company}小时;', style='List Bullet') |
|
|
p = doc.add_paragraph(f'部门处理流程平均耗时时长:{d_elapse}小时{operator}公司平均{procinst_duration_by_company}小时;', |
|
|
set_paragraph_space(p) |
|
|
style='List Bullet') |
|
|
|
|
|
set_paragraph_space(p, line_spacing=2) |
|
|
|
|
|
|
|
|
users_count = len(d_users_gt_company_avg_duration) |
|
|
users_count = len(d_users_gt_company_avg_duration) |
|
|
p = doc.add_paragraph(style='List Bullet') |
|
|
p = doc.add_paragraph(style='List Bullet') |
|
|
p.add_run(f'部门处理流程平均耗时大于公司平均水平的有{users_count}人') |
|
|
p.add_run(f'部门处理流程平均耗时大于公司平均水平的有{users_count}人') |
|
|
p.add_run(f":{'、'.join(d_users_gt_company_avg_duration)};" if users_count > 0 else ";") |
|
|
p.add_run(f":{'、'.join(d_users_gt_company_avg_duration)};" if users_count > 0 else ";") |
|
|
set_paragraph_space(p) |
|
|
set_paragraph_space(p, line_spacing=2) |
|
|
|
|
|
|
|
|
p = doc.add_paragraph(f'人均处理流程条数排名:{d_count_rank};', style='List Bullet') |
|
|
p = doc.add_paragraph(f'人均处理流程条数排名:{d_count_rank};', style='List Bullet') |
|
|
set_paragraph_space(p) |
|
|
set_paragraph_space(p, line_spacing=2) |
|
|
|
|
|
|
|
|
operator = '>' if d_count > procinst_count_by_company else '<' if d_count < procinst_count_by_company else '==' |
|
|
operator = '>' if d_count > procinst_count_by_company else '<' if d_count < procinst_count_by_company else '==' |
|
|
p = doc.add_paragraph(f'人均处理流程条数:{d_count}条{operator}公司平均{procinst_count_by_company}条;', style='List Bullet') |
|
|
p = doc.add_paragraph(f'人均处理流程条数:{d_count}条{operator}公司平均{procinst_count_by_company}条;', style='List Bullet') |
|
|
set_paragraph_space(p) |
|
|
set_paragraph_space(p, line_spacing=2) |
|
|
|
|
|
|
|
|
pic_name = f"{d_name}-平均处理流程时间及流程处理条数.png" |
|
|
pic_name = f"{d_name}-平均处理流程时间及流程处理条数.png" |
|
|
create_twinx_chart(department_data, "部门成员平均处理流程时间及流程处理条数", pic_name) |
|
|
create_twinx_chart(department_data, "部门成员平均处理流程时间及流程处理条数", pic_name) |
|
@ -282,7 +286,8 @@ def add_section(doc, department_data): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def add_chapter_2(doc): |
|
|
def add_chapter_2(doc): |
|
|
add_heading(doc, 1, '二、各部门成员详情') |
|
|
doc.add_page_break() # 插入分页符 |
|
|
|
|
|
add_heading(doc, 1, '二、各部门成员详情', line_spacing=2) |
|
|
|
|
|
|
|
|
# 部门流程处理条数排行 |
|
|
# 部门流程处理条数排行 |
|
|
department_rank_by_count = [item[0] for item in procinst_by_department] # procinst_by_department 默认按照流程条数倒序排列 |
|
|
department_rank_by_count = [item[0] for item in procinst_by_department] # procinst_by_department 默认按照流程条数倒序排列 |
|
@ -470,6 +475,8 @@ def generate_word_report(): |
|
|
# 二、各部门成员详情 |
|
|
# 二、各部门成员详情 |
|
|
add_chapter_2(doc) |
|
|
add_chapter_2(doc) |
|
|
|
|
|
|
|
|
|
|
|
doc.add_paragraph() # 添加换行符 |
|
|
|
|
|
|
|
|
p_last = doc.add_paragraph( |
|
|
p_last = doc.add_paragraph( |
|
|
'针对以上数据,请各部门负责人认真对待并针对部门情况进行分析。' |
|
|
'针对以上数据,请各部门负责人认真对待并针对部门情况进行分析。' |
|
|
'现项企业流程效能分析是公司管理工具逐步完善尝试和摸索的阶段,评估维度、呈现形式均在调整优化中,' |
|
|
'现项企业流程效能分析是公司管理工具逐步完善尝试和摸索的阶段,评估维度、呈现形式均在调整优化中,' |
|
|