diff --git a/apps/em/views.py b/apps/em/views.py index 3060bb0e..2f4f98e2 100644 --- a/apps/em/views.py +++ b/apps/em/views.py @@ -105,6 +105,11 @@ class EquipmentViewSet(CustomModelViewSet): count_stop=Count(Case(When(running_state=30, then=1), output_field=IntegerField())), count_fail=Count(Case(When(running_state=40, then=1), output_field=IntegerField())), count_offline=Count(Case(When(running_state=50, then=1), output_field=IntegerField())), + count_ok=Count(Case(When(state=Equipment.EQUIP_STATE_OK, then=1), output_field=IntegerField())), + count_limit=Count(Case(When(state=Equipment.EQUIP_STATE_LIMIT, then=1), output_field=IntegerField())), + count_fix=Count(Case(When(state=Equipment.EQUIP_STATE_FIX, then=1), output_field=IntegerField())), + count_disable=Count(Case(When(state=Equipment.EQUIP_STATE_DISABLE, then=1), output_field=IntegerField())), + count_scrap=Count(Case(When(state=Equipment.EQUIP_STATE_SCRAP, then=1), output_field=IntegerField())), ) json_result = { "count": result["count"], @@ -113,6 +118,11 @@ class EquipmentViewSet(CustomModelViewSet): "count_stop": result["count_stop"], "count_fail": result["count_fail"], "count_offline": result["count_offline"], + "count_ok": result["count_ok"], + "count_limit": result["count_limit"], + "count_fix": result["count_fix"], + "count_disable": result["count_disable"], + "count_scrap": result["count_scrap"] } return Response(json_result) diff --git a/apps/wpm/serializers.py b/apps/wpm/serializers.py index 6a7f95e2..2ac94141 100644 --- a/apps/wpm/serializers.py +++ b/apps/wpm/serializers.py @@ -286,6 +286,9 @@ class MlogSerializer(CustomModelSerializer): def create(self, validated_data): material_out = validated_data['material_out'] + mtask:Mtask = validated_data.get('mtask', None) + if mtask and mtask.state != Mtask.MTASK_ASSGINED: + raise ParseError('该任务非下达中不可选择') with transaction.atomic(): mlogb = validated_data.pop('mlogb', []) instance: Mlog = super().create(validated_data)