生成子计划工序步骤
This commit is contained in:
parent
d56336494e
commit
fbee94806b
|
|
@ -174,7 +174,7 @@ class UsedStep(CommonAModel):
|
|||
"""
|
||||
涉及的生产子工序
|
||||
"""
|
||||
step = models.ForeignKey(Step, verbose_name='子工序', on_delete=models.CASCADE, related_name='usedsteps')
|
||||
step = models.ForeignKey(Step, verbose_name='子工序', on_delete=models.CASCADE, related_name='usedstep')
|
||||
remark = models.TextField('生产备注', null=True, blank=True)
|
||||
subproduction = models.ForeignKey(SubProduction, verbose_name='关联生产分解', on_delete=models.CASCADE)
|
||||
|
||||
|
|
|
|||
|
|
@ -35,3 +35,6 @@ class SubProductionPlanUpdateSerializer(serializers.ModelSerializer):
|
|||
class Meta:
|
||||
model = SubProductionPlan
|
||||
fields = ['start_date', 'end_date']
|
||||
|
||||
class GenSubPlanSerializer(serializers.Serializer):
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ from apps.em.models import Equipment
|
|||
from apps.em.serializers import EquipmentSerializer
|
||||
from apps.mtm.models import InputMaterial, Step, SubProduction, UsedStep
|
||||
from apps.system.mixins import CreateUpdateModelAMixin
|
||||
from apps.pm.serializers import ProductionPlanCreateFromOrderSerializer, ProductionPlanSerializer, ResourceCalListSerializer, ResourceCalSerializer, SubProductionPlanListSerializer, SubProductionPlanUpdateSerializer
|
||||
from apps.pm.serializers import GenSubPlanSerializer, ProductionPlanCreateFromOrderSerializer, ProductionPlanSerializer, ResourceCalListSerializer, ResourceCalSerializer, SubProductionPlanListSerializer, SubProductionPlanUpdateSerializer
|
||||
from rest_framework.mixins import CreateModelMixin, ListModelMixin, UpdateModelMixin
|
||||
from apps.pm.models import ProductionPlan, SubProductionPlan
|
||||
from rest_framework.viewsets import GenericViewSet, ModelViewSet
|
||||
|
|
@ -60,7 +60,7 @@ class ProductionPlanViewSet(CreateUpdateModelAMixin, ListModelMixin, CreateModel
|
|||
updateOrderPlanedCount(instance.order)
|
||||
return Response()
|
||||
|
||||
@action(methods=['post'], detail=True, perms_map={'post':'*'}, serializer_class=serializers.Serializer)
|
||||
@action(methods=['post'], detail=True, perms_map={'post':'*'}, serializer_class=GenSubPlanSerializer)
|
||||
def gen_subplan(self, request, pk=None):
|
||||
"""
|
||||
生成子计划
|
||||
|
|
@ -70,8 +70,8 @@ class ProductionPlanViewSet(CreateUpdateModelAMixin, ListModelMixin, CreateModel
|
|||
raise APIException('已生成子计划')
|
||||
subps = SubProduction.objects.filter(product=production_plan.product).order_by('process__number')
|
||||
for i in subps:
|
||||
steps = UsedStep.objects.filter(subproduction=i, is_deleted=False, subproduction__is_deleted=False, step__is_deleted=False)\
|
||||
.order_by('step__number').annotate(id=F('step__id'), number=F('step__number'), name=F('step__name')).values('id', 'number', 'name', 'remark')
|
||||
steps = Step.objects.filter(usedstep__subproduction=i, usedstep__subproduction__is_deleted=False,
|
||||
usedstep__is_deleted=False, is_deleted=False).values('id', 'number', 'name', 'usedstep__remark')
|
||||
SubProductionPlan.objects.create(production_plan=production_plan, subproduction=i,
|
||||
start_date=production_plan.start_date, end_date=production_plan.end_date,
|
||||
workshop=i.process.workshop, process=i.process, create_by=request.user,
|
||||
|
|
@ -96,6 +96,7 @@ class SubProductionPlanViewSet(CreateUpdateModelAMixin, ListModelMixin, UpdateMo
|
|||
return SubProductionPlanListSerializer
|
||||
elif self.action == 'update':
|
||||
return SubProductionPlanUpdateSerializer
|
||||
return SubProductionPlanListSerializer
|
||||
|
||||
|
||||
class ResourceViewSet(GenericViewSet):
|
||||
|
|
@ -139,7 +140,7 @@ class ResourceViewSet(GenericViewSet):
|
|||
for i in rdata:
|
||||
rdata_l.append(i['id'])
|
||||
subproductions = SubProduction.objects.filter(product__id__in=rdata_l, is_deleted=False)
|
||||
steps = Step.objects.filter(usedsteps__is_deleted=False, usedsteps__subproduction__in=subproductions)
|
||||
steps = Step.objects.filter(usedstep__is_deleted=False, usedstep__subproduction__in=subproductions)
|
||||
equips = Equipment.objects.filter(step_equips__in=steps, is_deleted=False)
|
||||
serializer = EquipmentSerializer(instance=equips, many=True)
|
||||
return Response(serializer.data)
|
||||
|
|
|
|||
Loading…
Reference in New Issue