From 6f6707c0242890d1f99fda3cb0aa50095ecbdf14 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Tue, 1 Mar 2022 13:21:01 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=86=E6=96=99=E6=9B=B4=E6=96=B0=E8=BD=A6?= =?UTF-8?q?=E9=97=B4=E7=89=A9=E6=96=99=E6=97=B6=E5=8F=AA=E5=A4=84=E7=90=86?= =?UTF-8?q?=E7=89=A9=E6=96=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb_server/apps/mtm/views.py | 4 ++-- hb_server/apps/wpm/serializers.py | 19 ++++++++++--------- hb_server/apps/wpm/views.py | 2 ++ 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/hb_server/apps/mtm/views.py b/hb_server/apps/mtm/views.py index 4a972cf..2862a39 100644 --- a/hb_server/apps/mtm/views.py +++ b/hb_server/apps/mtm/views.py @@ -77,8 +77,8 @@ class StepViewSet(OptimizationMixin, CreateUpdateModelAMixin, ModelViewSet): """ 子工序-增删改查 """ - perms_map = {'get':'*', 'post':'step_create', - 'put':'step_update', 'delete':'step_delete'} + perms_map = {'get':'*', 'post':'process_update', + 'put':'process_update', 'delete':'process_update'} queryset = Step.objects.all() serializer_class = StepSerializer search_fields = ['name', 'number'] diff --git a/hb_server/apps/wpm/serializers.py b/hb_server/apps/wpm/serializers.py index 61ae4b5..79b4234 100644 --- a/hb_server/apps/wpm/serializers.py +++ b/hb_server/apps/wpm/serializers.py @@ -93,15 +93,16 @@ class PickSerializer(serializers.Serializer): FIFOItemProduct.objects.bulk_create(mls) # 更新车间物料 - wm, _ = WMaterial.objects.get_or_create(material=i['material'], batch=i['batch'], \ - subproduction_plan=sp,defaults={ - 'material':i['material'], - 'batch':i['batch'], - 'subproduction_plan':sp, - 'count':0 - }) - wm.count = wm.count + i['count'] - wm.save() + if i['material'].type != Material.MA_TYPE_HALFGOOD: + wm, _ = WMaterial.objects.get_or_create(material=i['material'], batch=i['batch'], \ + subproduction_plan=sp,defaults={ + 'material':i['material'], + 'batch':i['batch'], + 'subproduction_plan':sp, + 'count':0 + }) + wm.count = wm.count + i['count'] + wm.save() # 更新子计划物料情况 spp = SubProductionProgress.objects.get(material=i['material'], subproduction_plan=sp, type=SubprodctionMaterial.SUB_MA_TYPE_IN) spp.count_pick = spp.count_pick + i['count'] diff --git a/hb_server/apps/wpm/views.py b/hb_server/apps/wpm/views.py index 59a4086..d7b1480 100644 --- a/hb_server/apps/wpm/views.py +++ b/hb_server/apps/wpm/views.py @@ -281,6 +281,8 @@ class WProductViewSet(ListModelMixin, RetrieveModelMixin, GenericViewSet): ip = {} ip['fifoitem'] = fifoitem ip['wproduct'] = i + if i.number is None: + raise exceptions.APIException('缺少编号') ip['number'] = i.number ip['material'] = i.material ips.append(FIFOItemProduct(**ip))