From 756f2efc5661009e064024f117a1cc57245fb899 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Mon, 27 Dec 2021 15:49:32 +0800 Subject: [PATCH] =?UTF-8?q?wpm=20update=20=E4=B8=8D=E8=A7=A6=E5=8F=91singa?= =?UTF-8?q?l/=20pm=20process=5Fjson=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb_server/apps/pm/serializers.py | 13 ++++++++----- hb_server/apps/pm/services.py | 2 +- hb_server/apps/pm/signals.py | 3 ++- hb_server/apps/wpm/services.py | 9 +++++---- hb_server/apps/wpm/signals.py | 6 ++++-- hb_server/apps/wpm/views.py | 6 ++++-- 6 files changed, 24 insertions(+), 15 deletions(-) diff --git a/hb_server/apps/pm/serializers.py b/hb_server/apps/pm/serializers.py index 5a5b099..3f88285 100644 --- a/hb_server/apps/pm/serializers.py +++ b/hb_server/apps/pm/serializers.py @@ -48,11 +48,7 @@ class SubProductionPlanUpdateSerializer(serializers.ModelSerializer): class GenSubPlanSerializer(serializers.Serializer): pass -class SubProductionProgressSerializer(serializers.ModelSerializer): - material_ = MaterialSimpleSerializer(source='material', read_only=True) - class Meta: - model = SubProductionProgress - fields = '__all__' + class PickNeedSerializer(serializers.Serializer): warehouse = serializers.IntegerField(label="仓库ID") @@ -64,3 +60,10 @@ class SubproductionPlanSimpleSerializer(serializers.ModelSerializer): class Meta: model = SubProductionPlan fields = ['id', 'number'] + +class SubProductionProgressSerializer(serializers.ModelSerializer): + material_ = MaterialSimpleSerializer(source='material', read_only=True) + subproduction_plan_ = SubproductionPlanSimpleSerializer(source='subproduction_plan', read_only=True) + class Meta: + model = SubProductionProgress + fields = '__all__' \ No newline at end of file diff --git a/hb_server/apps/pm/services.py b/hb_server/apps/pm/services.py index abcf581..a3771c9 100644 --- a/hb_server/apps/pm/services.py +++ b/hb_server/apps/pm/services.py @@ -1,6 +1,6 @@ from django.db.models.aggregates import Sum from apps.pm.models import ProductionPlan, SubProductionPlan -import math + class PmService: @classmethod diff --git a/hb_server/apps/pm/signals.py b/hb_server/apps/pm/signals.py index b3cc7bb..afd8411 100644 --- a/hb_server/apps/pm/signals.py +++ b/hb_server/apps/pm/signals.py @@ -14,6 +14,7 @@ def update_subplan_main(sender, instance, created, **kwargs): if created: subplan.main_product = instance.material subplan.main_count = instance.count + subplan.main_count_real = instance.count_real subplan.main_count_ok = instance.count_ok if instance.count_ok >= instance.count and instance.count_ok > 0: @@ -27,7 +28,7 @@ def update_subplan_main(sender, instance, created, **kwargs): plan.count_real = subplan.main_count_real plan.count_ok = subplan.main_count_ok plan.save() - # 更新子计划工序统计字段 + # 更新计划工序统计字段 PmService.update_plan_process_json(subplan.production_plan) diff --git a/hb_server/apps/wpm/services.py b/hb_server/apps/wpm/services.py index 8dcde40..04b8e87 100644 --- a/hb_server/apps/wpm/services.py +++ b/hb_server/apps/wpm/services.py @@ -57,12 +57,13 @@ class WpmServies(object): wproduct.number = 'WP'+ranstr(7) # 更新子计划合格进度 - SubProductionProgress.objects.filter(subproduction_plan=wproduct.subproduction_plan, - is_main=True, type=SubprodctionMaterial.SUB_MA_TYPE_OUT).update(count_ok=F('count_ok')+1) - + ins = SubProductionProgress.objects.get(subproduction_plan=wproduct.subproduction_plan, + is_main=True, type=SubprodctionMaterial.SUB_MA_TYPE_OUT) + ins.count_ok = ins.count_ok + 1 + ins.save() else:# 如果不合格 wproduct.act_state = WProduct.WPR_ACT_STATE_NOTOK # 需要走不合格品审理的工单 wproduct.update_by = user wproduct.test = None - wproduct.save() \ No newline at end of file + wproduct.save() diff --git a/hb_server/apps/wpm/signals.py b/hb_server/apps/wpm/signals.py index e7e07e4..6c61165 100644 --- a/hb_server/apps/wpm/signals.py +++ b/hb_server/apps/wpm/signals.py @@ -70,8 +70,10 @@ def handleTicket(sender, instance, created, **kwargs): wp.save() # 更新子计划合格进度 if sp != wt.subproduction_plan: - SubProductionProgress.objects.filter(subproduction_plan=sp, - is_main=True, type=SubprodctionMaterial.SUB_MA_TYPE_OUT).update(count_ok=F('count_ok')-1) + ins = SubProductionProgress.objects.filter(subproduction_plan=sp, + is_main=True, type=SubprodctionMaterial.SUB_MA_TYPE_OUT) + ins.count_ok = ins.count_ok - 1 + ins.save() else: raise exceptions.APIException('返回步骤点错误') diff --git a/hb_server/apps/wpm/views.py b/hb_server/apps/wpm/views.py index de6ca2c..8cfb65c 100644 --- a/hb_server/apps/wpm/views.py +++ b/hb_server/apps/wpm/views.py @@ -544,8 +544,10 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd # 更新子计划生产进度 # 如果产品有返工标记不做计算 if wp.ng_sign not in [WProduct.NG_BACK_FIX, WProduct.NG_BACK_WORK]: - SubProductionProgress.objects.filter(subproduction_plan=wsp, - is_main=True, type=SubprodctionMaterial.SUB_MA_TYPE_OUT).update(count_real=F('count_real')+1) + ins = SubProductionProgress.objects.filter(subproduction_plan=wsp, + is_main=True, type=SubprodctionMaterial.SUB_MA_TYPE_OUT) + ins.count_real = ins.count_real + 1 + ins.save() wp.operation = None wp.update_by = request.user wp.save()