24 lines
628 B
Python
24 lines
628 B
Python
# Create your tasks here
|
|
from __future__ import absolute_import, unicode_literals
|
|
from apps.rpm.models import Rpj
|
|
from apps.utils.tasks import CustomTask
|
|
from celery import shared_task
|
|
from django.utils import timezone
|
|
|
|
|
|
@shared_task(base=CustomTask)
|
|
def close_rpj_by_leave_time():
|
|
"""
|
|
定时关闭相关方入厂项目
|
|
"""
|
|
now = timezone.now()
|
|
# 正常结束/其他关闭
|
|
rpjs = Rpj.objects.filter(leave_time__lt=now)
|
|
for i in rpjs:
|
|
if i.state == Rpj.RPJ_WORKING:
|
|
i.state = Rpj.RPJ_DONE
|
|
i.save()
|
|
else:
|
|
i.state = Rpj.RPJ_CLOSE
|
|
i.save()
|