diff --git a/apps/wpm/views.py b/apps/wpm/views.py index fff09aff..d1fd6331 100644 --- a/apps/wpm/views.py +++ b/apps/wpm/views.py @@ -40,6 +40,8 @@ from datetime import datetime, timedelta from apps.utils.lock import lock_model_record_d_method from apps.em.models import Equipment from django.db.models import Prefetch +from drf_yasg.utils import swagger_auto_schema +from drf_yasg import openapi @@ -212,6 +214,14 @@ class MlogViewSet(CustomModelViewSet): return MlogSerializer return super().get_serializer_class() + @swagger_auto_schema(manual_parameters=[ + openapi.Parameter(name="query", in_=openapi.IN_QUERY, description="定制返回数据", + type=openapi.TYPE_STRING, required=False), + openapi.Parameter(name="with_children", in_=openapi.IN_QUERY, description="带有children(yes/no/count)", + type=openapi.TYPE_STRING, required=False), + openapi.Parameter(name="with_wpr", in_=openapi.IN_QUERY, description="带有wpr(yes/no)", + type=openapi.TYPE_STRING, required=False), + ]) def list(self, request, *args, **kwargs): from django.db import connection from django.conf import settings @@ -261,6 +271,8 @@ class MlogViewSet(CustomModelViewSet): # if item.get("material_out", None): # data_dict[item_dict["mlog"]]["mlogb"].append(item_dict) # data = list(data_dict.values()) + if self.request.query_params.get('with_wpr', False) == 'yes': + pass return data @lock_model_record_d_method(Mlog) @@ -859,7 +871,8 @@ class MlogbInViewSet(CreateModelMixin, UpdateModelMixin, DestroyModelMixin, Cust c_year2 = str(c_year)[-2:] c_month = now.month m_model = material_out.model - wpr = Wpr.objects.filter(material_start=material_out, create_time__year=c_year, create_time__month=c_month).order_by("number").last() + # 不按产品走,只按生产日期走 + wpr = Wpr.objects.filter(create_time__year=c_year, create_time__month=c_month).order_by("number").last() cq_w = 4 if '02d' in rule: cq_w = 2