Browse Source

PDA过账

flower_bs 2 weeks ago
parent
commit
c5f20b6e07
3 changed files with 57 additions and 2 deletions
  1. 3 1
      bound/urls.py
  2. 53 0
      bound/views.py
  3. 1 1
      templates/src/i18n/zh-hans/index.js

+ 3 - 1
bound/urls.py

@@ -55,6 +55,8 @@ re_path(r'^outbatch/(?P<pk>\d+)/$', views.OutBoundBatchViewSet.as_view({
     'delete': 'destroy',
 }), name="outboundbatch_1"),
 
-path(r'batchlog/', views.BoundBatchLogViewSet.as_view({"get": "list", "post": "create" }), name="boundbatchlog"), 
+path(r'batchlog/', views.BoundBatchLogViewSet.as_view({"get": "list", "post": "create" }), name="boundbatchlog"),
+path(r'batchinout/', views.BoundBatchViewSet.as_view({ "post": "batchinout" }), name="batchinout"),
+
 
 ]

+ 53 - 0
bound/views.py

@@ -609,6 +609,59 @@ class BoundBatchViewSet(viewsets.ModelViewSet):
             headers = self.get_success_headers(serializer.data)
             return Response(serializer.data, status=200, headers=headers)
 
+    def batchinout(self, request, *args, **kwargs):
+        from container.models import ContainerDetailModel, ContainerListModel
+        from decimal import Decimal
+        
+        batch_number = request.data.get('batch_number')
+        batch_in_qty = request.data.get('batch_in_qty')
+        
+        if not batch_number:
+            return Response({"code": 200,"message": "批次号不能为空","data": "批次进出库数目:{batch_in_qty}"}, status=200)
+            
+        try:
+            batch_obj = BoundBatchModel.objects.get(bound_number=batch_number, is_delete=False)
+        except BoundBatchModel.DoesNotExist:
+            return Response({"code": 200,"message": "批次号不存在","data": "批次进出库数目:{batch_in_qty}"}, status=200)
+
+
+        
+        if batch_in_qty:
+
+            # 获取或创建虚拟容器
+            virtual_container, created = ContainerListModel.objects.get_or_create(
+                container_code=1
+       
+            )
+            
+
+            # 使用 update_or_create 避免并发问题
+            virtual_container_detail = ContainerDetailModel.objects.create(
+                month=timezone.now().strftime('%Y%m'),
+                container= virtual_container,
+                batch= batch_obj,
+                goods_class= 1,  # 成品
+                goods_code= batch_obj.goods_code,
+                goods_desc= batch_obj.goods_desc,
+                goods_qty= Decimal(batch_in_qty),
+                goods_out_qty= Decimal(0),
+                goods_weight= batch_obj.goods_weight,
+                status= 2,  # 在库
+                creater=  "system",
+                create_time= timezone.now(),
+                update_time= timezone.now(),
+                is_delete= False   )
+
+            virtual_container_detail.save()
+
+            virtual_container_detail.goods_out_qty = batch_in_qty
+            virtual_container_detail.save()
+
+        
+        return Response({"code": 200,"message": "操作成功","data": "批次进出库数目:{batch_in_qty}"}, status=200)
+
+   
+
 # 入库明细类视图      
 class BoundDetailViewSet(viewsets.ModelViewSet):
     """

+ 1 - 1
templates/src/i18n/zh-hans/index.js

@@ -9,7 +9,7 @@ export default {
   success: 'Action was successful',
   index: {
     GreaterWMS_hello: '欢迎使用仓库管理系统',
-    developer: 'GreaterWMS_**智能科技有限责任公司',
+    developer: '成都欧康医药股份有限公司',
     operation: '操作手册',
     app_store: '商用授权',
     app_title: 'APP 名称',