feat: utask mtask状态submit调整
This commit is contained in:
parent
4916ae5cff
commit
128dc2a7e3
|
@ -38,7 +38,7 @@ class UtaskFilter(filters.FilterSet):
|
|||
|
||||
|
||||
class MtaskFilter(filters.FilterSet):
|
||||
tag = filters.CharFilter(method='filter_tag')
|
||||
tag = filters.CharFilter(method='filter_tag', label='done, not_done')
|
||||
|
||||
class Meta:
|
||||
model = Mtask
|
||||
|
@ -60,13 +60,17 @@ class MtaskFilter(filters.FilterSet):
|
|||
}
|
||||
|
||||
def filter_tag(self, queryset, name, value):
|
||||
now = timezone.now()
|
||||
day7_after = now + timedelta(days=7)
|
||||
if value == 'near_done':
|
||||
queryset = queryset.filter(count_ok__lt=F('count'),
|
||||
end_date__lte=day7_after.date(),
|
||||
end_date__gte=now.date())
|
||||
elif value == 'out_done':
|
||||
queryset = queryset.filter(count_ok__lt=F('count'),
|
||||
end_date__lt=now.date())
|
||||
# now = timezone.now()
|
||||
# day7_after = now + timedelta(days=7)
|
||||
# if value == 'near_done':
|
||||
# queryset = queryset.filter(count_ok__lt=F('count'),
|
||||
# end_date__lte=day7_after.date(),
|
||||
# end_date__gte=now.date())
|
||||
# elif value == 'out_done':
|
||||
# queryset = queryset.filter(count_ok__lt=F('count'),
|
||||
# end_date__lt=now.date())
|
||||
if value == 'done':
|
||||
queryset = queryset.filter(count_ok__gte=F('count'))
|
||||
elif value == 'not_done':
|
||||
queryset = queryset.filter(count_ok__lt=F('count'))
|
||||
return queryset
|
||||
|
|
|
@ -19,14 +19,14 @@ class Utask(CommonBDModel):
|
|||
UTASK_ASSGINED = 20
|
||||
UTASK_WORKING = 30
|
||||
UTASK_STOP = 34
|
||||
UTASK_DONE = 40
|
||||
UTASK_SUBMIT = 40
|
||||
UTASK_STATES = (
|
||||
(UTASK_CREATED, '创建中'),
|
||||
(UTASK_DECOMPOSE, '已分解'),
|
||||
(UTASK_ASSGINED, '已下达'),
|
||||
(UTASK_WORKING, '生产中'),
|
||||
(UTASK_STOP, '已停止'),
|
||||
(UTASK_DONE, '已提交')
|
||||
(UTASK_SUBMIT, '已提交')
|
||||
)
|
||||
type = models.CharField('任务类型', max_length=10,
|
||||
help_text=str(TASK_TYPE), default='mass')
|
||||
|
@ -55,12 +55,12 @@ class Mtask(CommonADModel):
|
|||
MTASK_CREATED = 10
|
||||
MTASK_ASSGINED = 20
|
||||
MTASK_STOP = 34
|
||||
MTASK_DONE = 40
|
||||
MTASK_SUBMIT = 40
|
||||
MTASK_STATES = (
|
||||
(MTASK_CREATED, '创建中'),
|
||||
(MTASK_ASSGINED, '已下达'),
|
||||
(MTASK_STOP, '已停止'),
|
||||
(MTASK_DONE, '已提交')
|
||||
(MTASK_SUBMIT, '已提交')
|
||||
)
|
||||
type = models.CharField('任务类型', max_length=10,
|
||||
help_text=str(TASK_TYPE), default='mass')
|
||||
|
|
|
@ -267,7 +267,7 @@ class PmService:
|
|||
for mlog in mlogs:
|
||||
mlog_submit(mlog, user, now)
|
||||
update_mtask(mtask)
|
||||
mtask.state = Mtask.MTASK_DONE
|
||||
mtask.state = Mtask.MTASK_SUBMIT
|
||||
mtask.submit_time = now
|
||||
mtask.submit_user = user
|
||||
mtask.save()
|
||||
|
|
|
@ -202,8 +202,8 @@ def update_mtask(mtask: Mtask):
|
|||
utask.count_notok = res2['sum_count_notok'] if res2['sum_count_notok'] else 0
|
||||
if utask.count_ok > 0 and utask.state == Utask.UTASK_ASSGINED:
|
||||
utask.state = Utask.UTASK_WORKING
|
||||
if Mtask.objects.filter(utask=utask).exclude(state=Mtask.MTASK_DONE).count() == 0:
|
||||
utask.state = Utask.UTASK_DONE
|
||||
if Mtask.objects.filter(utask=utask).exclude(state=Mtask.MTASK_SUBMIT).count() == 0:
|
||||
utask.state = Utask.UTASK_SUBMIT
|
||||
utask.save()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue