发起不合格审理单
This commit is contained in:
parent
7713cc045d
commit
c8c9cd4554
|
@ -1,4 +1,6 @@
|
|||
from typing import List
|
||||
|
||||
from django.db.models.expressions import F
|
||||
from apps.pm.models import SubProductionPlan, SubProductionProgress
|
||||
from apps.mtm.models import Material, Step, SubprodctionMaterial
|
||||
from apps.qm.models import TestRecord
|
||||
|
@ -55,10 +57,9 @@ class WpmServies(object):
|
|||
wproduct.number = 'WP'+ranstr(7)
|
||||
|
||||
# 更新子计划合格进度
|
||||
instance = SubProductionProgress.objects.get(subproduction_plan=wproduct.subproduction_plan,
|
||||
is_main=True, type=SubprodctionMaterial.SUB_MA_TYPE_OUT)
|
||||
instance.count_ok = instance.count_ok + 1
|
||||
instance.save()
|
||||
SubProductionProgress.objects.filter(subproduction_plan=wproduct.subproduction_plan,
|
||||
is_main=True, type=SubprodctionMaterial.SUB_MA_TYPE_OUT).update(count_ok=F('count_ok')+1)
|
||||
|
||||
else:# 如果不合格
|
||||
wproduct.act_state = WProduct.WPR_ACT_STATE_NOTOK
|
||||
# 需要走不合格品审理的工单
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from django.db.models.expressions import F
|
||||
from django.db.models.signals import post_save
|
||||
from apps.mtm.models import SubprodctionMaterial
|
||||
from apps.pm.models import SubProductionProgress
|
||||
from apps.mtm.models import Step, SubprodctionMaterial
|
||||
from apps.pm.models import SubProductionPlan, SubProductionProgress
|
||||
from apps.qm.models import TestRecord
|
||||
from apps.wf.models import Ticket
|
||||
from django.dispatch import receiver
|
||||
|
@ -56,10 +57,11 @@ def handleTicket(sender, instance, created, **kwargs):
|
|||
|
||||
wp.ng_sign = decision
|
||||
if decision in [WProduct.NG_BACK_WORK, WProduct.NG_BACK_FIX]:
|
||||
step = ticket_data['back_step']
|
||||
step = Step.objects.get(id=ticket_data['back_step'])
|
||||
wp.step = step
|
||||
# 找到当时所属的计划
|
||||
sp = OperationWproduct.objects.filter(operation__is_submited=True, operation__step=step).first()
|
||||
sp = SubProductionPlan.objects.filter(ow_subplan__wproduct=wp,
|
||||
ow_subplan__operation__is_submited=True, ow_subplan__step=step).first()
|
||||
if sp:
|
||||
wp.subproduction_plan = sp
|
||||
wt.save()
|
||||
|
@ -67,10 +69,9 @@ def handleTicket(sender, instance, created, **kwargs):
|
|||
wp.act_state = WProduct.WPR_ACT_STATE_DOWAIT
|
||||
wp.save()
|
||||
# 更新子计划合格进度
|
||||
instance = SubProductionProgress.objects.get(subproduction_plan=sp,
|
||||
is_main=True, type=SubprodctionMaterial.SUB_MA_TYPE_OUT)
|
||||
instance.count_ok = instance.count_ok - 1 #进度计算这里该怎么处理呢
|
||||
instance.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)
|
||||
|
||||
else:
|
||||
raise exceptions.APIException('返回步骤点错误')
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
from django.db.models.expressions import F
|
||||
from django.shortcuts import render
|
||||
from rest_framework.generics import CreateAPIView, GenericAPIView
|
||||
from rest_framework.mixins import CreateModelMixin, DestroyModelMixin, ListModelMixin, RetrieveModelMixin, UpdateModelMixin
|
||||
|
@ -370,7 +371,8 @@ class WProductViewSet(ListModelMixin, GenericViewSet):
|
|||
发起不合格审理单
|
||||
"""
|
||||
obj = self.get_object()
|
||||
if obj.act_state != WProduct.WPR_ACT_STATE_NOTOK or obj.ng_sign is not None:
|
||||
if obj.act_state != WProduct.WPR_ACT_STATE_NOTOK or obj.ng_sign is not None\
|
||||
or obj.ticket is not None:
|
||||
raise exceptions.APIException('该产品不可发起不合格审理')
|
||||
workflow = Workflow.objects.filter(name='不合格品审理单', is_deleted=False).first()
|
||||
if workflow:
|
||||
|
@ -542,10 +544,8 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd
|
|||
# 更新子计划生产进度
|
||||
# 如果产品有返工标记不做计算
|
||||
if wp.ng_sign not in [WProduct.NG_BACK_FIX, WProduct.NG_BACK_WORK]:
|
||||
instance = SubProductionProgress.objects.get(subproduction_plan=wsp,
|
||||
is_main=True, type=SubprodctionMaterial.SUB_MA_TYPE_OUT)
|
||||
instance.count_real = instance.count_real + 1 # 这个地方可能会有问题,不够严谨
|
||||
instance.save()
|
||||
SubProductionProgress.objects.filter(subproduction_plan=wsp,
|
||||
is_main=True, type=SubprodctionMaterial.SUB_MA_TYPE_OUT).update(count_real=F('count_real')+1)
|
||||
wp.operation = None
|
||||
wp.update_by = request.user
|
||||
wp.save()
|
||||
|
|
Loading…
Reference in New Issue