加签接口

This commit is contained in:
caoqianming 2021-10-15 10:17:18 +08:00
parent 71fd3e3892
commit c6481027bf
5 changed files with 26 additions and 4 deletions

View File

@ -0,0 +1,18 @@
# Generated by Django 3.2.6 on 2021-10-15 02:14
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('pm', '0003_auto_20211014_1503'),
]
operations = [
migrations.AddField(
model_name='subproductionplan',
name='steps',
field=models.JSONField(default=list, verbose_name='工艺步骤'),
),
]

View File

@ -37,7 +37,7 @@ class SubProductionPlan(CommonAModel):
end_date = models.DateField('计划完工日期') end_date = models.DateField('计划完工日期')
workshop = models.ForeignKey(Organization, verbose_name='生产车间', on_delete=models.CASCADE) workshop = models.ForeignKey(Organization, verbose_name='生产车间', on_delete=models.CASCADE)
process = models.ForeignKey(Process, verbose_name='关联大工序', on_delete=models.CASCADE) process = models.ForeignKey(Process, verbose_name='关联大工序', on_delete=models.CASCADE)
# steps = models.JSONField('工艺步骤', default=list) steps = models.JSONField('工艺步骤', default=list)
class Meta: class Meta:
verbose_name = '子生产计划' verbose_name = '子生产计划'
verbose_name_plural = verbose_name verbose_name_plural = verbose_name

View File

@ -13,6 +13,7 @@ from apps.sam.models import Order
from rest_framework.exceptions import APIException from rest_framework.exceptions import APIException
from rest_framework.response import Response from rest_framework.response import Response
from rest_framework.decorators import action from rest_framework.decorators import action
from django.db.models import F
# Create your views here. # Create your views here.
def updateOrderPlanedCount(order): def updateOrderPlanedCount(order):
@ -69,9 +70,12 @@ class ProductionPlanViewSet(CreateUpdateModelAMixin, ListModelMixin, CreateModel
raise APIException('已生成子计划') raise APIException('已生成子计划')
subps = SubProduction.objects.filter(product=production_plan.product).order_by('process__number') subps = SubProduction.objects.filter(product=production_plan.product).order_by('process__number')
for i in subps: 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')
SubProductionPlan.objects.create(production_plan=production_plan, subproduction=i, SubProductionPlan.objects.create(production_plan=production_plan, subproduction=i,
start_date=production_plan.start_date, end_date=production_plan.end_date, start_date=production_plan.start_date, end_date=production_plan.end_date,
workshop=i.process.workshop, process=i.process, create_by=request.user) workshop=i.process.workshop, process=i.process, create_by=request.user,
steps = list(steps))
production_plan.is_planed=True production_plan.is_planed=True
production_plan.save() production_plan.save()
return Response() return Response()

View File

@ -136,7 +136,7 @@ class TicketCloseSerializer(serializers.Serializer):
class TicketAddNodeSerializer(serializers.Serializer): class TicketAddNodeSerializer(serializers.Serializer):
suggestion = serializers.CharField(label="加签说明", required = False) suggestion = serializers.CharField(label="加签说明", required = False)
add_node_man = serializers.IntegerField(label='加签') toadd_user = serializers.IntegerField(label='发送给谁去加签')
class TicketAddNodeEndSerializer(serializers.Serializer): class TicketAddNodeEndSerializer(serializers.Serializer):
suggestion = serializers.CharField(label="加签意见", required = False) suggestion = serializers.CharField(label="加签意见", required = False)

View File

@ -321,7 +321,7 @@ class TicketViewSet(OptimizationMixin, CreateUpdateCustomMixin, CreateModelMixin
""" """
ticket = self.get_object() ticket = self.get_object()
data = request.data data = request.data
add_user = User.objects.get(pk=data['add_node_man']) add_user = User.objects.get(pk=data['toadd_user'])
ticket.participant_type = State.PARTICIPANT_TYPE_PERSONAL ticket.participant_type = State.PARTICIPANT_TYPE_PERSONAL
ticket.participant = add_user.id ticket.participant = add_user.id
ticket.in_add_node = True ticket.in_add_node = True