fix: mtask_submit时导致重复计算

This commit is contained in:
caoqianming 2023-12-27 09:03:12 +08:00
parent 4697f30ef1
commit 03d6a6c99f
2 changed files with 5 additions and 1 deletions

View File

@ -261,7 +261,7 @@ class PmService:
from apps.wpm.services import mlog_submit, update_mtask
now = timezone.now()
if mtask.state == Mtask.MTASK_ASSGINED:
mlogs = Mlog.objects.filter(mtask=mtask)
mlogs = Mlog.objects.filter(mtask=mtask, submit_time=None)
if mlogs.count() == 0:
raise ParseError(f'{mtask.mgroup.name}_未填写日志')
for mlog in mlogs:

View File

@ -140,6 +140,8 @@ def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
"""
生产日志提交后需要执行的操作
"""
if mlog.submit_time is not None:
return
if now is None:
now = timezone.now()
if now.date() < mlog.handle_date:
@ -186,6 +188,8 @@ def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
def mlog_revert(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
"""日志撤回
"""
if mlog.submit_time is None:
return
if now is None:
now = timezone.now()
belong_dept = mlog.mgroup.belong_dept