bug_fix:按照iso标准计算周数
This commit is contained in:
parent
a7e0a76c7c
commit
ccbd60cf58
15
gen_word.py
15
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,7 +78,7 @@ 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()
|
||||
@ -100,8 +106,9 @@ class WEEK_REPORT:
|
||||
table.Cell(Row=i, Column=3).Range.Text = table.Cell(Row=i, Column=3).Range.Text.upper()
|
||||
|
||||
# 额外工作记录
|
||||
str_tmp = "\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)
|
||||
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".join(["{}(xx%)".format(i) for i in self.project_name]) + "\n其他(研究、学习、培训、交流、出差)\n"
|
||||
|
Loading…
x
Reference in New Issue
Block a user