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