feat: dpm checkwork增加字段
This commit is contained in:
parent
63dbc00a12
commit
dc5be36e78
|
@ -0,0 +1,23 @@
|
|||
# Generated by Django 3.2.12 on 2024-06-12 02:42
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('dpm', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='checkwork',
|
||||
name='usable',
|
||||
field=models.BooleanField(default=True, verbose_name='是否可用'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='checkwork',
|
||||
name='time_end',
|
||||
field=models.DateTimeField(blank=True, null=True, verbose_name='关闭时间'),
|
||||
),
|
||||
]
|
|
@ -4,25 +4,29 @@ from celery import shared_task
|
|||
from apps.dpm.models import CheckTaskSet, CheckWork
|
||||
from django.utils import timezone
|
||||
from datetime import timedelta
|
||||
from django.db import transaction
|
||||
|
||||
|
||||
@shared_task(base=CustomTask)
|
||||
def dispath_checkwork_task(checktaskset: str):
|
||||
cts = CheckTaskSet.objects.get(id=checktaskset)
|
||||
cw = CheckWork()
|
||||
cw.type = 20
|
||||
cw.checktaskset = cts
|
||||
cw.name = '风险点检查(自动派发)'
|
||||
now = timezone.now()
|
||||
cw.time_start = now
|
||||
expire_hour = cts.expire if cts.expire else 24
|
||||
cw.time_end = now + timedelta(hours=expire_hour)
|
||||
cw.user_duty = cts.user_duty
|
||||
cw.riskpoint = cts.riskpoint
|
||||
cw.note = cts.note
|
||||
cw.save()
|
||||
# 发送通知
|
||||
pass
|
||||
with transaction.atomic():
|
||||
CheckWork.objects.filter(checktaskset=cts).update(usable=False)
|
||||
cw = CheckWork()
|
||||
cw.type = 20
|
||||
cw.checktaskset = cts
|
||||
now = timezone.now()
|
||||
cw.time_start = now
|
||||
local_time = timezone.localtime(now)
|
||||
cw.name = f'风险点排查_{local_time.strftime('%Y%m%d%H%M%S')}'
|
||||
if cts.expire:
|
||||
cw.time_end = now + timedelta(hours=cts.expire)
|
||||
cw.user_duty = cts.user_duty
|
||||
cw.riskpoint = cts.riskpoint
|
||||
cw.note = cts.note
|
||||
cw.save()
|
||||
# 发送通知
|
||||
pass
|
||||
|
||||
|
||||
@shared_task(base=CustomTask)
|
||||
|
|
Loading…
Reference in New Issue