|
@@ -14,7 +14,7 @@ import requests
|
|
|
from django.db import transaction
|
|
|
import logging
|
|
|
from rest_framework import status
|
|
|
-from .models import ContainerListModel,ContainerDetailModel,ContainerOperationModel,ContainerWCSModel,TaskModel,out_batch_detail,ContainerDetailLogModel
|
|
|
+from .models import ContainerListModel,ContainerDetailModel,ContainerOperationModel,ContainerWCSModel,TaskModel,out_batch_detail,ContainerDetailLogModel,batchLogModel
|
|
|
from bound.models import BoundDetailModel,BoundListModel,OutBoundDetailModel
|
|
|
from bin.views import LocationAllocation,base_location
|
|
|
from bin.models import LocationModel,LocationContainerLink,LocationGroupModel
|
|
@@ -27,7 +27,8 @@ from .serializers import TaskGetSerializer,TaskPostSerializer
|
|
|
from .serializers import WCSTaskGetSerializer
|
|
|
from .serializers import OutBoundFullDetailSerializer,OutBoundDetailSerializer
|
|
|
from .serializers import ContainerDetailLogSerializer
|
|
|
-from .filter import ContainerDetailFilter,ContainerListFilter,ContainerOperationFilter,TaskFilter,WCSTaskFilter,ContainerDetailLogFilter
|
|
|
+from .serializers import batchLogModelSerializer
|
|
|
+from .filter import ContainerDetailFilter,ContainerListFilter,ContainerOperationFilter,TaskFilter,WCSTaskFilter,ContainerDetailLogFilter,batchLogFilter
|
|
|
|
|
|
from rest_framework.permissions import AllowAny
|
|
|
import threading
|
|
@@ -38,6 +39,71 @@ from django.db.models import Sum
|
|
|
from staff.models import ListModel as StaffListModel
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
+# 托盘流水汇总批次流水
|
|
|
+class batchLogModelViewSet(viewsets.ModelViewSet):
|
|
|
+
|
|
|
+ """
|
|
|
+ retrieve:
|
|
|
+ Response a data list(get)
|
|
|
+ list:
|
|
|
+ Response a data list(all)
|
|
|
+ create:
|
|
|
+ Create a data line(post)
|
|
|
+
|
|
|
+ delete:
|
|
|
+ Delete a data line(delete)
|
|
|
+
|
|
|
+
|
|
|
+ """
|
|
|
+ pagination_class = MyPageNumberPagination
|
|
|
+ filter_backends = [DjangoFilterBackend, OrderingFilter, ]
|
|
|
+ ordering_fields = ['id', "create_time", "update_time", ]
|
|
|
+ filter_class = batchLogFilter
|
|
|
+
|
|
|
+ def get_project(self):
|
|
|
+ try:
|
|
|
+ id = self.kwargs.get('pk')
|
|
|
+ return id
|
|
|
+ except:
|
|
|
+ return None
|
|
|
+
|
|
|
+ def get_queryset(self):
|
|
|
+ id = self.get_project()
|
|
|
+ if self.request.user:
|
|
|
+ if id is None:
|
|
|
+ return batchLogModel.objects.filter()
|
|
|
+ else:
|
|
|
+ return batchLogModel.objects.filter(id=id)
|
|
|
+ else:
|
|
|
+ return batchLogModel.objects.none()
|
|
|
+
|
|
|
+ def get_serializer_class(self):
|
|
|
+ if self.action in ['list', 'destroy','retrieve']:
|
|
|
+ return batchLogModelSerializer
|
|
|
+ else:
|
|
|
+ return self.http_method_not_allowed(request=self.request)
|
|
|
+
|
|
|
+ def create(self, request, *args, **kwargs):
|
|
|
+ data = self.request.data
|
|
|
+ return Response(data, status=200, headers=headers)
|
|
|
+
|
|
|
+ def update(self, request, pk):
|
|
|
+ qs = self.get_object()
|
|
|
+ data = self.request.data
|
|
|
+ serializer = self.get_serializer(qs, data=data)
|
|
|
+ serializer.is_valid(raise_exception=True)
|
|
|
+ serializer.save()
|
|
|
+ headers = self.get_success_headers(serializer.data)
|
|
|
+ return Response(serializer.data, status=200, headers=headers)
|
|
|
+
|
|
|
+ def get_container_operation_log(self,request):
|
|
|
+ batchlog_id = self.request.query_params.get('batchlog_id')
|
|
|
+ batch_obj = batchLogModel.objects.get(id=batchlog_id)
|
|
|
+ container_operation_log = batch_obj.detail_logs.all()
|
|
|
+ serializer = ContainerDetailLogSerializer(container_operation_log, many=True)
|
|
|
+ return Response(serializer.data, status=200)
|
|
|
+
|
|
|
+
|
|
|
# 进出库log查看
|
|
|
class ContainerDetailLogModelViewSet(viewsets.ModelViewSet):
|
|
|
"""
|
|
@@ -460,7 +526,7 @@ class ContainerWCSViewSet(viewsets.ModelViewSet):
|
|
|
self.generate_task_no_batch(container, start_location, allocation_target_location,batch_id,location_min_value.c_number)
|
|
|
self.generate_container_operate_no_batch(container_obj, batch_id, allocation_target_location)
|
|
|
elif batch_info['class'] == 3:
|
|
|
- self.generate_task_no_batch(container, target_location, allocation_target_location,batch_id,location_min_value.c_number)
|
|
|
+ self.generate_task_no_batch(container, start_location, allocation_target_location,batch_id,location_min_value.c_number)
|
|
|
self.generate_move_container_operate(container_obj, allocation_target_location)
|
|
|
else:
|
|
|
self.generate_task(container, start_location, allocation_target_location,batch_id,location_min_value.c_number) # 生成任务
|
|
@@ -2402,11 +2468,12 @@ class OutDetailViewSet(viewsets.ModelViewSet):
|
|
|
container_obj = ContainerListModel.objects.filter(container_code=container_code).first()
|
|
|
if not container_obj:
|
|
|
return Response({"code": "500", "message": f"托盘 {container_code} 不存在"}, status=status.HTTP_200_OK)
|
|
|
- out_batch_detail_all = out_batch_detail.objects.filter(container=container_obj,working=1,is_delete=False).all()
|
|
|
+ out_batch_detail_all = out_batch_detail.objects.filter(container=container_obj,working=1,is_delete=False).order_by('-id').all()
|
|
|
if not out_batch_detail_all:
|
|
|
return Response({"code": "500", "message": f"托盘 {container_code} 无出库明细"}, status=status.HTTP_200_OK)
|
|
|
for obj in out_batch_detail_all:
|
|
|
obj.container_detail.goods_out_qty = obj.last_out_goods_qty
|
|
|
+ # print(f"取消出库托盘 {container_code} 批次 {obj.container_detail.batch.id},详情 {obj.container_detail.id} 变化前数量 {obj.container_detail.goods_out_qty} 变化后数量 {obj.last_out_goods_qty}")
|
|
|
obj.container_detail.save()
|
|
|
obj.is_delete = True
|
|
|
obj.working = 0
|