Merge branch 'master' of https://e.coding.net/ctcdevteam/ehs/ehs_server
This commit is contained in:
commit
5fe86c3e98
|
|
@ -8,6 +8,7 @@ from rest_framework.response import Response
|
||||||
from apps.utils.viewsets import CustomGenericViewSet, RetrieveModelMixin, CustomListModelMixin
|
from apps.utils.viewsets import CustomGenericViewSet, RetrieveModelMixin, CustomListModelMixin
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
|
|
||||||
|
SPLIT_FIELD = "#"
|
||||||
|
|
||||||
class LableMatViewSet(CustomListModelMixin, RetrieveModelMixin, CustomGenericViewSet):
|
class LableMatViewSet(CustomListModelMixin, RetrieveModelMixin, CustomGenericViewSet):
|
||||||
perms_map = {"post": "*", "get": "*"}
|
perms_map = {"post": "*", "get": "*"}
|
||||||
|
|
@ -29,7 +30,7 @@ class LableMatViewSet(CustomListModelMixin, RetrieveModelMixin, CustomGenericVie
|
||||||
raise NotFound("仓库明细不存在")
|
raise NotFound("仓库明细不存在")
|
||||||
obj, _ = LableMat.objects.get_or_create(state=10, material=mb.material, batch=mb.batch, defaults={"supplier": mb.supplier})
|
obj, _ = LableMat.objects.get_or_create(state=10, material=mb.material, batch=mb.batch, defaults={"supplier": mb.supplier})
|
||||||
rdata = LabelMatSerializer(obj).data
|
rdata = LabelMatSerializer(obj).data
|
||||||
rdata["code_label"] = f"mat:{obj.id}"
|
rdata["code_label"] = f"mat{SPLIT_FIELD}{obj.id}"
|
||||||
return Response(rdata)
|
return Response(rdata)
|
||||||
|
|
||||||
@action(methods=["post"], detail=False, serializer_class=TidSerializer)
|
@action(methods=["post"], detail=False, serializer_class=TidSerializer)
|
||||||
|
|
@ -46,7 +47,7 @@ class LableMatViewSet(CustomListModelMixin, RetrieveModelMixin, CustomGenericVie
|
||||||
raise NotFound("车间库存不存在")
|
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)
|
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 = LabelMatSerializer(obj).data
|
||||||
rdata["code_label"] = f"mat:{obj.id}"
|
rdata["code_label"] = f"mat{SPLIT_FIELD}{obj.id}"
|
||||||
return Response(rdata)
|
return Response(rdata)
|
||||||
|
|
||||||
@action(methods=["post"], detail=False, serializer_class=TidSerializer)
|
@action(methods=["post"], detail=False, serializer_class=TidSerializer)
|
||||||
|
|
@ -63,5 +64,5 @@ class LableMatViewSet(CustomListModelMixin, RetrieveModelMixin, CustomGenericVie
|
||||||
raise NotFound("出入库明细不存在")
|
raise NotFound("出入库明细不存在")
|
||||||
obj, _ = LableMat.objects.get_or_create(state=10, material=mioitem.material, batch=mioitem.batch, defaults={"supplier": mioitem.mio.supplier})
|
obj, _ = LableMat.objects.get_or_create(state=10, material=mioitem.material, batch=mioitem.batch, defaults={"supplier": mioitem.mio.supplier})
|
||||||
rdata = LabelMatSerializer(obj).data
|
rdata = LabelMatSerializer(obj).data
|
||||||
rdata["code_label"] = f"mat:{obj.id}"
|
rdata["code_label"] = f"mat{SPLIT_FIELD}{obj.id}"
|
||||||
return Response(rdata)
|
return Response(rdata)
|
||||||
|
|
|
||||||
|
|
@ -144,7 +144,7 @@ class MtaskViewSet(CustomModelViewSet):
|
||||||
select_related_fields = ['material_in', 'material_out', 'mgroup']
|
select_related_fields = ['material_in', 'material_out', 'mgroup']
|
||||||
prefetch_related_fields = ['mlog_mtask', 'b_mtask']
|
prefetch_related_fields = ['mlog_mtask', 'b_mtask']
|
||||||
ordering_fields = ['start_date', 'mgroup__process__sort', 'create_time']
|
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)
|
@action(methods=['post'], detail=False, perms_map={'post': '*'}, serializer_class=MtaskDaySerializer)
|
||||||
@transaction.atomic
|
@transaction.atomic
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue