提交 ea1c66c8 作者: lizhichao

update0504

上级 0298d2cf
......@@ -5,7 +5,7 @@
</component>
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="jdk" jdkName="Python 3.8 (pdf@py38)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="PyDocumentationSettings">
......
......@@ -630,6 +630,7 @@ def generate_final_report():
# document.save(send_path)
# "data/财务报告.docx"
ret_upload = client.upload_by_filename(report_processed_path)
logger.info(ret_upload)
return ret_upload["Remote file_id"]
......
......@@ -24,6 +24,8 @@ from docx.shared import Pt
start_pattern = re.compile(r'(?<=[0-9][\..]会计报表重要项目的明细信息及说明)$|(?<=[0-9][\..]会计报表重要项目的明细信息及说明。)$')
end_pattern = re.compile(r'(?<=[0-9][\..]需要说明的其他事项)$|(?<=[0-9][\..]需要说明的其他事项。)(略)$|(?<=[0-9][\..]需要说明的其他事项[。\.])$')
# start_pattern1 = re.compile(r'(?<=[0-9][\..])附件:补充报表$|(?<=[0-9][\..])附件:$')
def iter_block_items(parent):
"""
......
......@@ -22,6 +22,8 @@ from docx.text.paragraph import Paragraph
from docx.enum.section import WD_SECTION_START
from docx.enum.text import WD_BREAK
import docx
from docx.shared import Pt
# from docx.enum.text import WD_PARAGRAPH_ALIGNMENT
def iter_block_items(parent):
......@@ -154,11 +156,27 @@ def new_generate_report(table_names_data, template_document, tables_dict):
match = pattern.findall(block.text)
if match and "table" in match[0]:
table_name = match[0]
for _ in table_names_data[tables_dict[table_name]]:
# white_row = new_document()
# 在XML 级别上进行操作,即在元素之后直接添加内容,将任何尾部文本移动到新插入的元素后面,目的是使得新元素成为紧随其后的兄弟元素
# block._p.addnext(white_row)
block._p.addnext(_)
table_data = table_names_data[tables_dict[table_name]]
# print(table_names_data[tables_dict[table_name]])
if table_data:
for _ in table_data:
if table_data:
# white_row = new_document()
# 在XML 级别上进行操作,即在元素之后直接添加内容,将任何尾部文本移动到新插入的元素后面,目的是使得新元素成为紧随其后的兄弟元素
# block._p.addnext(white_row)
block._p.addnext(_)
else:
# 创建一个包含“无”字的段落并插入到当前段落之后
new_p = document.add_paragraph()
# 设置首行缩进为2个字符
new_p.paragraph_format.first_line_indent = Pt(24) # 24pt大约等于2个字符的缩进
# 创建一个运行并设置字体大小
new_r = new_p.add_run('无')
new_r.font.size = Pt(15) # 设置字体大小为24磅
# 插入新段落
block._p.addnext(new_p._p)
# 删除当前段落
p = block._element
p.getparent().remove(p)
block._p = block._element = None
......@@ -172,6 +190,7 @@ def new_generate_report(table_names_data, template_document, tables_dict):
p = block._element
p.getparent().remove(p)
block._p = block._element = None
# save_path = r"data/test_copy.docx"
# document.save(save_path)
return document
......@@ -186,20 +205,26 @@ if __name__ == '__main__':
"table3": "资产负债表续表2",
"table2": "资产负债表续表1",
"table1": "资产负债表",
"table9": "(17)其他应付款明细信息如下:",
"table8": "(9)无形资产明细信息如下:",
"table10": "(24)其他收入明细信息如下:",
"table7": "(7)固定资产明细信息如下:",
"table11": "(25)业务活动费用明细信息如下:",
"table6": "(1)货币资金明细信息如下:",
"table12": "(28)商品和服务费用明细信息如下:"
# "table9": "(17)其他应付款明细信息如下:",
# "table8": "(9)无形资产明细信息如下:",
# "table10": "(24)其他收入明细信息如下:",
"table7": "2.本年预算结余与盈余调节表",
# "table11": "(25)业务活动费用明细信息如下:",
"table6": "1.应付工程款情况表",
"table13": "以名义金额计量的资产名称、数量等情况,以及以名义金额计量理由的说明",
}
# tables_dict = {'table1': '资产负债表', 'table2': '资产负债表续表1', 'table3': '资产负债表续表2', 'table4': '收入费用表(1)', 'table5': '收入费用表(2)', 'table6': '(1)货币资金明细信息如下:',
# "table7": "(7)固定资产明细信息如下:", "table8": "(9)无形资产明细信息如下:", "table9": "(17)其他应付款明细信息如下:", "table10": "(24)其他收入明细信息如下:",
# "table11": "(25)业务活动费用明细信息如下:", "table12": "(28)商品和服务费用明细信息如下:", }
docx_file = r'data/3月23测试半成品.docx'
docx_file = r'data/待复制的表格文件.docx'
document = Document(docx_file)
template_file = r'data/模板.docx'
template_document = Document(template_file)
data_result = get_choose_table(document, list(tables_dict.values()))
print(data_result)
new_generate_report(table_names_data=data_result,
tables_dict=tables_dict,
template_document=template_document)
# generate_report(data_result, save_path=r'data/报告文件.docx', template_path=r'data/new_财务报告模板.docx', tables_dict=tables_dict)
......@@ -2496,13 +2496,15 @@ if __name__ == "__main__":
"""
}
}
half_work_path = "../data/5月9号半成品.docx"
template_path = "../data/5月9号模板.docx"
half_work_path = "../data/待复制的表格文件.docx"
template_path = "../data/模板.docx"
template_document = Document(template_path)
half_document = Document(half_work_path)
save_path = "../data" + str(datetime.datetime.now().strftime('%Y%m%d%H%M%S')) + ".docx"
tables_dict = {
"table13": "以名义金额计量的资产名称、数量等情况,以及以名义金额计量理由的说明",
"table7": "2.本年预算结余与盈余调节表",
"table6": "1.应付工程款情况表",
"table5": "收入费用表(2)",
"table4": "收入费用表(1)",
"table3": "资产负债表续表2",
......
......@@ -5,27 +5,11 @@
# echo "114.115.185.13 dfs" >>/etc/hosts
#echo "192.168.200.148 dfs" >>/etc/hosts # 测试环境
echo "192.168.1.75 dfs" >>/etc/hosts # 正式环境
start_interface() {
INTERFACE_IS_STRAT=`ps -ef | grep scbg_app_config.py | grep -v grep | wc -l`
if [ $INTERFACE_IS_STRAT -ne 0 ] ; then
sleep 30m
else
echo "=========Service Will Start=========="
echo "=========Service Will Start=========="
# cd /data/lzc/scbg-python/SCBG-PYTHON && nohup gunicorn -c scbg_app_config.py app_run:app 2>&1 &
cd /opt/SCBG-PYTHON
exec nohup gunicorn -c scbg_app_config.py app_run:app 2>&1 &
sleep 5m
exec nohup python -u main_server.py >main_server.log 2>&1 &
echo "=========Service Start Completed!========"
fi
cd /opt/SCBG-PYTHON
exec nohup gunicorn -c scbg_app_config.py app_run:app 2>&1 &
sleep 10s
exec nohup python -u main_server.py >main_server.log 2>&1 &
echo "=========Service Start Completed!========"
}
# 方法一:使用 echo 命令保持服务运行状态(容器启动时)
# 方法二: 使用自定义接口检测函数来保持服务运行状态
while true
do
echo "PYTHON SERVICE is running..."
start_interface
sleep 30m
done
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论