Compare commits
10 Commits
3d1939330f
...
95fab6ac26
Author | SHA1 | Date | |
---|---|---|---|
95fab6ac26 | |||
ccbd60cf58 | |||
a7e0a76c7c | |||
1e83c98883 | |||
c47e49baaf | |||
d18d600334 | |||
951a0fa586 | |||
1771ba8d0c | |||
8f32921aae | |||
6efaafc23f |
Binary file not shown.
52
ReadMe.md
52
ReadMe.md
@ -1,34 +1,44 @@
|
||||
## 功能列表
|
||||
|
||||
- 根据上一周的周报,自动生成这周的周报。
|
||||
> 替换对应的日期,不会修改工作内容
|
||||
>
|
||||
- 根据指定的模板和参数,自动生成这周的周报。以下字段会更新
|
||||
- 工作周
|
||||
- 日期
|
||||
- 所在项目
|
||||
- 项目负责人
|
||||
- 报告人
|
||||
- 删除上周工作内容、额外工作记录情况、工作完成情况、困难问题、经验教训及建议、下周工作重点
|
||||
- 若已经存在同名文档,则不执行
|
||||
- 添加 `auto_run_python.bat`,双击即可执行python脚本
|
||||
- 支持跨年
|
||||
- 支持
|
||||
|
||||
## 待添加功能
|
||||
## 快速开始
|
||||
|
||||
* [ ] 下周一也可以运行
|
||||
1. 安装依赖
|
||||
|
||||
## 运行程序
|
||||
```powershell
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
1. ```powershell
|
||||
python gen_word.py
|
||||
```
|
||||
2. 双击 `auto_run_python.bat`
|
||||
2. 运行程序
|
||||
|
||||
```powershell
|
||||
python gen_word.py
|
||||
```
|
||||
|
||||
或双击 `auto_run_python.bat`
|
||||
|
||||
### 成功运行的log
|
||||
3. 生成桌面快捷方式
|
||||
|
||||
双击`创建桌面快捷方式.bat`
|
||||
|
||||
```powshell
|
||||
pre file name: 2023WW32周工作报告_冯博涵.doc;
|
||||
new file name: 2023WW33周工作报告_冯博涵.doc;
|
||||
已复制 1 个文件。
|
||||
pre_str: 8.7~8.11
|
||||
str: 8.14~8.18
|
||||
```
|
||||
## 其他
|
||||
|
||||
## 注意
|
||||
- 成功运行的log
|
||||
|
||||
1. `创建桌面快捷方式.bat`该文件是 `GBK`编码。
|
||||
```powshell
|
||||
2024-01-02 16:48:24,745 - c:\Users\fengbohan\Documents\周工作报告\gen_word.py - 50 -INFO: template_file_name: 2017WWXX周工作报告样本.doc
|
||||
2024-01-02 16:48:24,745 - c:\Users\fengbohan\Documents\周工作报告\gen_word.py - 51 -INFO: new file name: 2024WW01周工作报告_冯博涵.doc;
|
||||
2024-01-02 16:48:24,745 - c:\Users\fengbohan\Documents\周工作报告\gen_word.py - 58 -INFO: process: copy file ...
|
||||
2024-01-02 16:48:24,763 - c:\Users\fengbohan\Documents\周工作报告\gen_word.py - 62 -INFO: process: open file ...
|
||||
2024-01-02 16:48:25,550 - c:\Users\fengbohan\Documents\周工作报告\gen_word.py - 71 -INFO: process: edit file ...
|
||||
```
|
@ -1,4 +1,4 @@
|
||||
@REM @echo off
|
||||
call .\week_report\Scripts\activate
|
||||
call .\env\Scripts\activate
|
||||
python gen_word.py
|
||||
pause
|
||||
|
@ -1,4 +1,4 @@
|
||||
user_name: 冯博涵
|
||||
project_name: nb2337
|
||||
project_leader: 罗伟
|
||||
template_file_name: 2017WWXX周工作报告样本.doc
|
||||
project_name: [nb2426]
|
||||
project_leader: [李夏禹]
|
||||
template_file_name: 2017WWXX周工作报告样本.doc
|
38
gen_word.py
38
gen_word.py
@ -19,6 +19,8 @@ class WEEK_REPORT:
|
||||
project_name = ""
|
||||
project_leader = ""
|
||||
template_file_name = ""
|
||||
week = ""
|
||||
year = ""
|
||||
|
||||
def __init__(self):
|
||||
with open("config.yaml", "r", encoding="UTF-8") as f1:
|
||||
@ -29,6 +31,10 @@ class WEEK_REPORT:
|
||||
self.project_name = data["project_name"]
|
||||
self.project_leader = data["project_leader"]
|
||||
self.template_file_name = data["template_file_name"]
|
||||
|
||||
now = datetime.datetime.now()
|
||||
self.week = f"{now.isocalendar()[1]:02d}"
|
||||
self.year = f"{now.isocalendar()[0]}"
|
||||
self.get_name()
|
||||
|
||||
def get_current_week(self, date=None):
|
||||
@ -46,7 +52,7 @@ class WEEK_REPORT:
|
||||
logger.debug("str: {}".format(self.str))
|
||||
|
||||
def get_name(self):
|
||||
self.file_name = "{}WW{}周工作报告_{}.doc".format(time.strftime('%Y'), time.strftime('%W'), self.user_name)
|
||||
self.file_name = "{}WW{}周工作报告_{}.doc".format(self.year, self.week, self.user_name)
|
||||
logger.info("template_file_name: {}".format(self.template_file_name))
|
||||
logger.info("new file name: {};".format(self.file_name))
|
||||
if os.path.isfile(self.file_name):
|
||||
@ -72,17 +78,17 @@ class WEEK_REPORT:
|
||||
table = self.doc.Tables(1)
|
||||
|
||||
# 工作周
|
||||
table.Cell(Row=1, Column=2).Range.Text = "{}WW{}".format(time.strftime('%Y'), time.strftime('%W'))
|
||||
table.Cell(Row=1, Column=2).Range.Text = "{}WW{}".format(self.year, self.week)
|
||||
|
||||
# 日期
|
||||
self.get_current_week()
|
||||
table.Cell(Row=1, Column=4).Range.Text = self.str
|
||||
|
||||
# 所在项目
|
||||
table.Cell(Row=2, Column=2).Range.Text = self.project_name
|
||||
table.Cell(Row=2, Column=2).Range.Text = "、".join(self.project_name)
|
||||
|
||||
# 项目负责人
|
||||
table.Cell(Row=2, Column=4).Range.Text = self.project_leader
|
||||
table.Cell(Row=2, Column=4).Range.Text = "、".join(self.project_leader)
|
||||
|
||||
# 报告人
|
||||
table.Cell(Row=3, Column=2).Range.Text = self.user_name
|
||||
@ -90,20 +96,34 @@ class WEEK_REPORT:
|
||||
# 删除上周工作内容
|
||||
for i in range(7,12):
|
||||
|
||||
table.Cell(Row=i, Column=2).Range.Text = ''
|
||||
table.Cell(Row=i, Column=3).Range.Text = ''
|
||||
table.Cell(Row=i, Column=2).Range.Text = "\n".join(["{}:".format(i) for i in self.project_name])
|
||||
table.Cell(Row=i, Column=3).Range.Text = "\n".join(["{}:".format(i) for i in self.project_name])
|
||||
# table.Cell(Row=i, Column=2).Range.Font.Bold = True
|
||||
# table.Cell(Row=i, Column=3).Range.Font.Bold = True
|
||||
table.Cell(Row=i, Column=2).Range.Font.Name = "Times New Roman"
|
||||
table.Cell(Row=i, Column=3).Range.Font.Name = "Times New Roman"
|
||||
table.Cell(Row=i, Column=2).Range.Text = table.Cell(Row=i, Column=2).Range.Text.upper()
|
||||
table.Cell(Row=i, Column=3).Range.Text = table.Cell(Row=i, Column=3).Range.Text.upper()
|
||||
|
||||
# 额外工作记录
|
||||
table.Cell(Row=13, Column=1).Range.Text = '1,周一:'
|
||||
str_tmp = "\n" + " ;\n".join([" {}:".format(i) for i in self.project_name]);
|
||||
# table.Cell(Row=13, Column=1).Range.Text = "周一(0h){0}\n周二(0h){0}\n周三(0h){0}\n周四(0h){0}\n周五(0h){0}\n周六(0h){0}\n周日(0h){0}\n".format(str_tmp)
|
||||
table.Cell(Row=13, Column=1).Range.Text = "周一{0}\n周二{0}\n周三{0}\n周四{0}\n周五{0}\n周六(0h){0}\n周日(0h){0}\n".format(str_tmp)
|
||||
|
||||
# 工作完成情况
|
||||
table.Cell(Row=15, Column=1).Range.Text = "项目工作:\n{}\n1,\n其他(非项目工作)\n\n".format(self.project_name)
|
||||
table.Cell(Row=15, Column=1).Range.Text = "\n".join(["{}(xx%)".format(i) for i in self.project_name]) + "\n其他(研究、学习、培训、交流、出差)\n"
|
||||
#table.Cell(Row=15, Column=1).Range.Font.Bold = True
|
||||
table.Cell(Row=15, Column=1).Range.Font.Name = "Times New Roman"
|
||||
table.Cell(Row=15, Column=1).Range.Text = table.Cell(Row=15, Column=1).Range.Text.upper()
|
||||
|
||||
# 困难问题、经验教训及建议
|
||||
table.Cell(Row=17, Column=1).Range.Text = ''
|
||||
|
||||
# 下周工作重点
|
||||
table.Cell(Row=19, Column=1).Range.Text = ''
|
||||
table.Cell(Row=19, Column=1).Range.Text = "\n".join(["{}:".format(i) for i in self.project_name])
|
||||
#table.Cell(Row=19, Column=1).Range.Font.Bold = True
|
||||
table.Cell(Row=19, Column=1).Range.Font.Name = "Times New Roman"
|
||||
table.Cell(Row=19, Column=1).Range.Text = table.Cell(Row=19, Column=1).Range.Text.upper()
|
||||
|
||||
def close_file(self):
|
||||
logger.info("process: copy file ...")
|
||||
|
4
requirements.txt
Normal file
4
requirements.txt
Normal file
@ -0,0 +1,4 @@
|
||||
docx==0.2.4
|
||||
python_docx==1.1.0
|
||||
pywin32==306
|
||||
ruamel.base==1.0.0
|
15
time.py
Normal file
15
time.py
Normal file
@ -0,0 +1,15 @@
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
def hours_until_5_20():
|
||||
now = datetime.now()
|
||||
target_time = datetime(now.year, now.month, now.day, 17, 20) # 设置目标时间为当天的17:20
|
||||
|
||||
#if now > target_time: # 如果当前时间已经过了今天的目标时间
|
||||
# target_time += timedelta(days=1) # 将目标时间设置为明天的同一时间
|
||||
|
||||
time_difference = now -target_time
|
||||
hours_difference = time_difference.total_seconds() / 3600 # 将时间差转换为小时
|
||||
return hours_difference
|
||||
|
||||
# 调用函数并打印结果
|
||||
print("Time until 5:20 is: {0:.2f} h".format(hours_until_5_20()))
|
9
week.py
Normal file
9
week.py
Normal file
@ -0,0 +1,9 @@
|
||||
import datetime
|
||||
|
||||
# 获取当前日期时间
|
||||
now = datetime.datetime.now()
|
||||
|
||||
# 使用 isocalendar() 获取当前周数
|
||||
week_number = now.isocalendar()[1]
|
||||
|
||||
print(f"当前是第 {week_number} 周")
|
30
创建桌面快捷方式.bat
30
创建桌面快捷方式.bat
@ -1,38 +1,38 @@
|
||||
chcp 936
|
||||
REM 设置936编码防止某些中文路径导致批处理失效
|
||||
REM 设置936编码防止某些中文路径导致批处理失效
|
||||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
mode con cols=94 lines=30&color 0a&title 创建桌面快捷方式
|
||||
mode con cols=94 lines=30&color 0a&title 创建桌面快捷方式
|
||||
echo.
|
||||
echo [+] 获得当前路径:%~dp0
|
||||
echo [+] 获得当前路径:%~dp0
|
||||
set path=%~dp0auto_run_python.bat
|
||||
echo.
|
||||
if exist %path% (
|
||||
echo [+] 发现脚本auto_run_python.bat
|
||||
echo [+] 发现脚本auto_run_python.bat
|
||||
echo.
|
||||
echo [+] 启动脚本路径:
|
||||
echo [+] 启动脚本路径:
|
||||
echo.
|
||||
echo [+] %path%
|
||||
echo.
|
||||
goto :creat
|
||||
) else (
|
||||
echo [-] 注意,未发现启动脚本发现脚本auto_run_python.bat,请注意是否改名,程序退出...
|
||||
echo [-] 注意,未发现启动脚本发现脚本auto_run_python.bat,请注意是否改名,程序退出...
|
||||
echo.
|
||||
pause
|
||||
exit
|
||||
)
|
||||
:creat
|
||||
echo [+] 开始创建快捷方式...
|
||||
echo [+] 开始创建快捷方式...
|
||||
echo.
|
||||
rem 设置程序的完整路径(必要)
|
||||
rem 设置程序的完整路径(必要)
|
||||
set Program=%path%
|
||||
rem 设置快捷方式名字(必要)
|
||||
set LinkName=写周报了
|
||||
rem 程序工作路径
|
||||
rem 设置快捷方式名字(必要)
|
||||
set LinkName=写周报了
|
||||
rem 程序工作路径
|
||||
set WorkDir=%~dp0
|
||||
rem 设置快捷方式说明
|
||||
set Desc=写周报了
|
||||
rem 设置快捷方式图标
|
||||
rem 设置快捷方式说明
|
||||
set Desc=写周报了
|
||||
rem 设置快捷方式图标
|
||||
set icon=%~dp0/auto_run_python_favicon.ico
|
||||
if not defined WorkDir call:GetWorkDir "%Program%"
|
||||
(echo Set WshShell=CreateObject("WScript.Shell"^)
|
||||
@ -44,7 +44,7 @@ echo oShellLink.WindowStyle=1
|
||||
echo oShellLink.Description="%Desc%"
|
||||
echo oShellLink.IconLocation="%icon%"
|
||||
echo oShellLink.Save)>makelnk.vbs
|
||||
echo [+] 桌面快捷方式创建成功!!
|
||||
echo [+] 桌面快捷方式创建成功!!
|
||||
echo.
|
||||
makelnk.vbs
|
||||
del /f /q makelnk.vbs
|
||||
|
Loading…
x
Reference in New Issue
Block a user