操作提交后更新进度

This commit is contained in:
caoqianming 2021-12-31 10:26:07 +08:00
parent 2ad60626e5
commit e15ad98c92
3 changed files with 42 additions and 7 deletions

View File

@ -197,6 +197,10 @@ class OperationWproduct(BaseModel):
material = models.ForeignKey(Material, verbose_name='操作时的物料状态', on_delete=models.CASCADE) material = models.ForeignKey(Material, verbose_name='操作时的物料状态', on_delete=models.CASCADE)
subproduction_plan = models.ForeignKey(SubProductionPlan, verbose_name='当前子生产计划', on_delete=models.CASCADE, related_name='ow_subplan') subproduction_plan = models.ForeignKey(SubProductionPlan, verbose_name='当前子生产计划', on_delete=models.CASCADE, related_name='ow_subplan')
class Meta:
unique_together = (
('operation','wproduct')
)
class OperationMaterial(BaseModel): class OperationMaterial(BaseModel):
""" """
@ -214,6 +218,19 @@ class OperationMaterial(BaseModel):
subproduction_plan = models.ForeignKey(SubProductionPlan, verbose_name='关联的子计划', on_delete=models.CASCADE, null=True, blank=True) subproduction_plan = models.ForeignKey(SubProductionPlan, verbose_name='关联的子计划', on_delete=models.CASCADE, null=True, blank=True)
batch = models.CharField('批次号', max_length=100, null=True, blank=True) batch = models.CharField('批次号', max_length=100, null=True, blank=True)
#以下为冷加工下料清单所用字段
count_cut = models.PositiveIntegerField('切裁片数', default=0)
count_real = models.PositiveIntegerField('生产片数', default=0)
count_ok = models.PositiveIntegerField('成品数量', default=0)
count_qipao = models.PositiveIntegerField('气泡甩片', default=0)
count_podian = models.PositiveIntegerField('破点甩片', default=0)
count_hua = models.PositiveIntegerField('划伤甩片', default=0)
count_other = models.PositiveIntegerField('其他甩片', default=0)
class Meta:
unique_together = (
('operation','material', 'batch')
)
class OperationRecord(BaseModel): class OperationRecord(BaseModel):
""" """
记录表格 记录表格

View File

@ -7,7 +7,7 @@ from apps.mtm.models import Material, Step, SubprodctionMaterial
from apps.qm.models import TestRecord from apps.qm.models import TestRecord
from apps.system.models import User from apps.system.models import User
from apps.wf.models import State, TicketFlow, Transition from apps.wf.models import State, TicketFlow, Transition
from apps.wpm.models import WProduct, WproductFlow, WprouctTicket from apps.wpm.models import Operation, OperationMaterial, WProduct, WproductFlow, WprouctTicket
from utils.tools import ranstr from utils.tools import ranstr
class WpmServies(object): class WpmServies(object):
@ -146,3 +146,11 @@ class WpmServies(object):
setattr(ins, f.name, getattr(instance, f.name, None)) setattr(ins, f.name, getattr(instance, f.name, None))
ins.change_str = change_str ins.change_str = change_str
ins.save() ins.save()
@classmethod
def update_cutting_list(cls, op:Operation):
"""
更新下料清单
"""
inputs = OperationMaterial.objects.filter(operation=op, type=SubprodctionMaterial.SUB_MA_TYPE_IN)
outputs = OperationMaterial.objects.filter(operation=op, type=SubprodctionMaterial.SUB_MA_TYPE_OUT)

View File

@ -579,9 +579,11 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd
spp.save() spp.save()
# 更新动态产品表 # 更新动态产品表
if step.type == Step.STEP_TYPE_NOM: if step.type == Step.STEP_TYPE_NOM:
for i in OperationWproduct.objects.filter(operation=op): ows = OperationWproduct.objects.filter(operation=op)
for i in ows:
wp = i.wproduct wp = i.wproduct
wsp = i.subproduction_plan wsp = i.subproduction_plan
# 获取下一步子工序 # 获取下一步子工序
newstep, hasNext = WpmServies.get_next_step(wsp, step) newstep, hasNext = WpmServies.get_next_step(wsp, step)
wp.step = newstep wp.step = newstep
@ -591,17 +593,21 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd
else: else:
wp.act_state = WProduct.WPR_ACT_STATE_TOTEST wp.act_state = WProduct.WPR_ACT_STATE_TOTEST
wp.material = wsp.product wp.material = wsp.product
# 更新子计划生产进度
# 如果产品有返工标记不做计算
if wp.ng_sign not in [WProduct.NG_BACK_FIX, WProduct.NG_BACK_WORK]:
WpmServies.update_subproduction_progress_main(sp=wsp)
wp.operation = None wp.operation = None
wp.update_by = request.user wp.update_by = request.user
wp.save() wp.save()
WpmServies.add_wproduct_flow_log(wp, 'operation_submit') WpmServies.add_wproduct_flow_log(wp, 'operation_submit')
for i in ows.values('subproduction_plan').distinct():
# 更新进度
WpmServies.update_subproduction_progress_main(sp=wsp)
elif step.type == Step.STEP_TYPE_DIV: elif step.type == Step.STEP_TYPE_DIV:
# 更新物料产出情况 # 更新物料产出情况
for i in OperationMaterial.objects.filter(operation=op, type=SubprodctionMaterial.SUB_MA_TYPE_OUT): outputs = OperationMaterial.objects.filter(operation=op, type=SubprodctionMaterial.SUB_MA_TYPE_OUT)
if not outputs.exists():
raise exceptions.APIException('请选择物料产出')
for i in outputs:
if i.subproduction_progress.is_main: if i.subproduction_progress.is_main:
newstep, _ = WpmServies.get_next_step(i.subproduction_plan, step) newstep, _ = WpmServies.get_next_step(i.subproduction_plan, step)
wpr = dict(material=i.material, step=newstep, wpr = dict(material=i.material, step=newstep,
@ -640,6 +646,10 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd
raise exceptions.APIException('产出物料未填写或填写错误') raise exceptions.APIException('产出物料未填写或填写错误')
op.is_submited = True op.is_submited = True
op.save() op.save()
# 如果是冷加工
if step.type == Step.STEP_TYPE_DIV:
WpmServies.update_cutting_list(op=op)
return Response() return Response()