feat: dpm checkwork增加字段

This commit is contained in:
caoqianming 2024-06-12 10:45:12 +08:00
parent 63dbc00a12
commit dc5be36e78
2 changed files with 41 additions and 14 deletions

View File

@ -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='关闭时间'),
),
]

View File

@ -4,19 +4,23 @@ from celery import shared_task
from apps.dpm.models import CheckTaskSet, CheckWork from apps.dpm.models import CheckTaskSet, CheckWork
from django.utils import timezone from django.utils import timezone
from datetime import timedelta from datetime import timedelta
from django.db import transaction
@shared_task(base=CustomTask) @shared_task(base=CustomTask)
def dispath_checkwork_task(checktaskset: str): def dispath_checkwork_task(checktaskset: str):
cts = CheckTaskSet.objects.get(id=checktaskset) cts = CheckTaskSet.objects.get(id=checktaskset)
with transaction.atomic():
CheckWork.objects.filter(checktaskset=cts).update(usable=False)
cw = CheckWork() cw = CheckWork()
cw.type = 20 cw.type = 20
cw.checktaskset = cts cw.checktaskset = cts
cw.name = '风险点检查(自动派发)'
now = timezone.now() now = timezone.now()
cw.time_start = now cw.time_start = now
expire_hour = cts.expire if cts.expire else 24 local_time = timezone.localtime(now)
cw.time_end = now + timedelta(hours=expire_hour) 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.user_duty = cts.user_duty
cw.riskpoint = cts.riskpoint cw.riskpoint = cts.riskpoint
cw.note = cts.note cw.note = cts.note