feat: 增加清洗数据的接口

This commit is contained in:
caoqianming 2025-01-03 15:21:16 +08:00
parent 2790bddefa
commit a151baaedd
1 changed files with 25 additions and 2 deletions

View File

@ -19,10 +19,13 @@ from apps.opm.models import Opl
from apps.third.dahua import dhClient
from apps.third.speaker import spClient
from apps.third.models import TDevice
from apps.utils.permission import RbacPermission
from apps.utils.sms import send_sms
from apps.utils.speech import generate_voice
from apps.utils.tools import get_info_from_id
import importlib
from rest_framework_simplejwt.authentication import JWTAuthentication
from rest_framework.authentication import BasicAuthentication, SessionAuthentication
from apps.utils.viewsets import CustomGenericViewSet
from apps.utils.wx import wxClient
@ -234,7 +237,7 @@ class TestViewSet(CustomGenericViewSet):
authentication_classes = ()
permission_classes = ()
@action(methods=['post'], detail=False, serializer_class=SendSmsSerializer)
@action(methods=['post'], detail=False, serializer_class=SendSmsSerializer, authentication_classes=())
def send_sms(self, request, pk=None):
"""发送短信测试
@ -561,7 +564,9 @@ class TestViewSet(CustomGenericViewSet):
# tr.save()
return Response()
@action(methods=['post'], detail=False, serializer_class=CleanDataSerializer, permission_classes=[])
@action(methods=['post'], detail=False, serializer_class=CleanDataSerializer,
authentication_classes=[JWTAuthentication, BasicAuthentication, SessionAuthentication],
permission_classes=[IsAdminUser])
def clean_data(self, request, pk=None):
"""清空数据
@ -608,6 +613,24 @@ class TestViewSet(CustomGenericViewSet):
from django_celery_results.models import TaskResult
TaskResult.objects.filter(task_name__in=['apps.vm.tasks.close_visit_by_leave_time',
'apps.rpm.tasks.close_rpj_by_leave_time']).delete()
if 'mes' in datas:
from apps.inm.models import MaterialBatch, MIO
from apps.wpmw.models import Wpr
from apps.wpm.models import WMaterial, Mlog
from apps.pum.models import PuOrder
from apps.sam.models import Order
from apps.pm.models import Utask, Mtask
from apps.wpm.models import Handover
MaterialBatch.objects.all().delete()
MIO.objects.all().delete()
Wpr.objects.all().delete()
WMaterial.objects.all().delete()
Utask.objects.all().delete()
Mtask.objects.all().delete()
Mlog.objects.all().delete()
PuOrder.objects.get_queryset(all=True).delete()
Order.objects.get_queryset(all=True).delete()
Handover.objects.all().delete()
return Response()
@action(methods=['post'], detail=False, serializer_class=Serializer, permission_classes=[])