From cdcfbf35ef9f5383b6c6d5f74949a30d8c7eead8 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Tue, 29 Oct 2024 14:50:19 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20SPLIT=5FFIELD=20=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=20#?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/cm/views.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/cm/views.py b/apps/cm/views.py index f05b6a4c..30b3e0ed 100644 --- a/apps/cm/views.py +++ b/apps/cm/views.py @@ -8,6 +8,7 @@ from rest_framework.response import Response from apps.utils.viewsets import CustomGenericViewSet, RetrieveModelMixin, CustomListModelMixin # Create your views here. +SPLIT_FIELD = "#" class LableMatViewSet(CustomListModelMixin, RetrieveModelMixin, CustomGenericViewSet): perms_map = {"post": "*", "get": "*"} @@ -29,7 +30,7 @@ class LableMatViewSet(CustomListModelMixin, RetrieveModelMixin, CustomGenericVie raise NotFound("仓库明细不存在") obj, _ = LableMat.objects.get_or_create(state=10, material=mb.material, batch=mb.batch, defaults={"supplier": mb.supplier}) rdata = LabelMatSerializer(obj).data - rdata["code_label"] = f"mat:{obj.id}" + rdata["code_label"] = f"mat{SPLIT_FIELD}{obj.id}" return Response(rdata) @action(methods=["post"], detail=False, serializer_class=TidSerializer) @@ -46,7 +47,7 @@ class LableMatViewSet(CustomListModelMixin, RetrieveModelMixin, CustomGenericVie raise NotFound("车间库存不存在") obj, _ = LableMat.objects.get_or_create(state=wm.state, material=wm.material, batch=wm.batch, notok_sign=wm.notok_sign, material_origin=wm.material_origin) rdata = LabelMatSerializer(obj).data - rdata["code_label"] = f"mat:{obj.id}" + rdata["code_label"] = f"mat{SPLIT_FIELD}{obj.id}" return Response(rdata) @action(methods=["post"], detail=False, serializer_class=TidSerializer) @@ -63,5 +64,5 @@ class LableMatViewSet(CustomListModelMixin, RetrieveModelMixin, CustomGenericVie raise NotFound("出入库明细不存在") obj, _ = LableMat.objects.get_or_create(state=10, material=mioitem.material, batch=mioitem.batch, defaults={"supplier": mioitem.mio.supplier}) rdata = LabelMatSerializer(obj).data - rdata["code_label"] = f"mat:{obj.id}" + rdata["code_label"] = f"mat{SPLIT_FIELD}{obj.id}" return Response(rdata) From 8859cc01a6506622bccfae3f3609cdda1deabe04 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Thu, 31 Oct 2024 15:51:01 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20mtask=E5=A2=9E=E5=8A=A0route=5F=5Fs?= =?UTF-8?q?ort=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/pm/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/pm/views.py b/apps/pm/views.py index 956263a8..2c76fce5 100644 --- a/apps/pm/views.py +++ b/apps/pm/views.py @@ -144,7 +144,7 @@ class MtaskViewSet(CustomModelViewSet): select_related_fields = ['material_in', 'material_out', 'mgroup'] prefetch_related_fields = ['mlog_mtask', 'b_mtask'] ordering_fields = ['start_date', 'mgroup__process__sort', 'create_time'] - ordering = ['-start_date', 'mgroup__process__sort', '-create_time'] + ordering = ['-start_date', 'route__sort', 'mgroup__process__sort', '-create_time'] @action(methods=['post'], detail=False, perms_map={'post': '*'}, serializer_class=MtaskDaySerializer) @transaction.atomic