diff --git a/hb_server/apps/mtm/filters.py b/hb_server/apps/mtm/filters.py index b4a2976..6f6b28b 100644 --- a/hb_server/apps/mtm/filters.py +++ b/hb_server/apps/mtm/filters.py @@ -6,7 +6,7 @@ from apps.mtm.models import TechDoc class TechDocFilterset(filters.FilterSet): # operation = filters.NumberFilter(method='filter_operation') - operation = filters.NumberFilter(field_name="subproduction__subplan_subprod__ow_subplan__operation") + operation = filters.CharFilter(field_name="subproduction__subplan_subprod__ow_subplan__operation") class Meta: model = TechDoc fields = ['subproduction', 'operation'] diff --git a/hb_server/apps/pm/models.py b/hb_server/apps/pm/models.py index 9cdd6c1..6a06c29 100644 --- a/hb_server/apps/pm/models.py +++ b/hb_server/apps/pm/models.py @@ -18,6 +18,8 @@ class ProductionPlan(CommonAModel): order = models.ForeignKey(Order, verbose_name='关联订单', null=True, blank=True, on_delete=models.SET_NULL) product = models.ForeignKey(Material, verbose_name='生产产品', on_delete=models.CASCADE) count = models.IntegerField('生产数量', default=1) + count_real = models.IntegerField('实际产出数', default=0) + count_ok = models.IntegerField('合格数', default=0) start_date = models.DateField('计划开工日期') end_date = models.DateField('计划完工日期') is_planed = models.BooleanField('是否已排产', default=False) diff --git a/hb_server/apps/pm/signals.py b/hb_server/apps/pm/signals.py index e1876a9..e5cc595 100644 --- a/hb_server/apps/pm/signals.py +++ b/hb_server/apps/pm/signals.py @@ -1,5 +1,6 @@ from django.db.models.signals import post_save from django.dispatch import receiver +from apps.mtm.models import Material from apps.pm.models import SubProductionPlan, SubProductionProgress @receiver(post_save, sender=SubProductionProgress) @@ -18,6 +19,13 @@ def update_subplan_main(sender, instance, created, **kwargs): subplan.state = SubProductionPlan.SUBPLAN_STATE_DONE elif instance.count_ok < instance.count and instance.count_ok > 0: subplan.state = SubProductionPlan.SUBPLAN_STATE_WORKING - subplan.save() + subplan.save() + if subplan.main_product.type == Material.MA_TYPE_GOOD: + # 如果是产品,更新主计划进度 + plan = subplan.production_plan + plan.count_real = subplan.count_real + plan.count_ok = subplan.count_ok + plan.save() + diff --git a/hb_server/apps/wpm/views.py b/hb_server/apps/wpm/views.py index 9db3504..c5e78ac 100644 --- a/hb_server/apps/wpm/views.py +++ b/hb_server/apps/wpm/views.py @@ -684,7 +684,7 @@ class OperationMaterialInputViewSet(ListModelMixin, CreateModelMixin, DestroyMod """ 批量创建消耗物料 """ - serializer = OperationMaterialCreate1ListSerailizer(data=request.data, many=True) + serializer = OperationMaterialCreate1ListSerailizer(data=request.data) serializer.is_valid(raise_exception=True) serializer.save() return Response() @@ -719,7 +719,7 @@ class OperationMaterialOutputViewSet(ListModelMixin, CreateModelMixin, DestroyMo """ 批量创建产出物料 """ - serializer = OperationMaterialCreate2ListSerailizer(data=request.data, many=True) + serializer = OperationMaterialCreate2ListSerailizer(data=request.data) serializer.is_valid(raise_exception=True) serializer.save() return Response()