操作提交bug
This commit is contained in:
parent
048e25311e
commit
7dcdcfa797
|
@ -0,0 +1,23 @@
|
||||||
|
# Generated by Django 3.2.9 on 2021-11-23 06:25
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('wpm', '0021_auto_20211123_0945'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='wproduct',
|
||||||
|
name='parent',
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='wproduct',
|
||||||
|
name='child',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='wpm.wproduct'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -40,7 +40,7 @@ class WProduct(CommonAModel):
|
||||||
act_state = models.IntegerField('进行状态', default=0, choices=act_state_choices)
|
act_state = models.IntegerField('进行状态', default=0, choices=act_state_choices)
|
||||||
is_executed = models.BooleanField('子工序是否已执行', default=False)
|
is_executed = models.BooleanField('子工序是否已执行', default=False)
|
||||||
is_hidden = models.BooleanField('是否隐藏', default=False)
|
is_hidden = models.BooleanField('是否隐藏', default=False)
|
||||||
parent = models.JSONField('父', default=list, blank=True)
|
child = models.ForeignKey('self', blank=True, null=True, on_delete=models.CASCADE)
|
||||||
remark = models.CharField('备注', max_length=200, null=True, blank=True)
|
remark = models.CharField('备注', max_length=200, null=True, blank=True)
|
||||||
subproduction_plan = models.ForeignKey(SubProductionPlan, verbose_name='当前子生产计划', on_delete=models.CASCADE, related_name='wproduct_subplan')
|
subproduction_plan = models.ForeignKey(SubProductionPlan, verbose_name='当前子生产计划', on_delete=models.CASCADE, related_name='wproduct_subplan')
|
||||||
warehouse = models.ForeignKey(WareHouse, verbose_name='所在仓库', on_delete=models.SET_NULL, null=True, blank=True)
|
warehouse = models.ForeignKey(WareHouse, verbose_name='所在仓库', on_delete=models.SET_NULL, null=True, blank=True)
|
||||||
|
|
|
@ -364,23 +364,22 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd
|
||||||
for i in OperationMaterial.objects.filter(operation=op, type=SubprodctionMaterial.SUB_MA_TYPE_IN):
|
for i in OperationMaterial.objects.filter(operation=op, type=SubprodctionMaterial.SUB_MA_TYPE_IN):
|
||||||
# 更新车间物料
|
# 更新车间物料
|
||||||
i_wmat = i.wmaterial
|
i_wmat = i.wmaterial
|
||||||
i_wmat.count = i_wmat.count- i['count']
|
i_wmat.count = i_wmat.count- i.count
|
||||||
i_wmat.save()
|
i_wmat.save()
|
||||||
# 更新子计划物料消耗情况
|
# 更新子计划物料消耗情况
|
||||||
sp = i_wmat.subproduction_plan
|
sp = i_wmat.subproduction_plan
|
||||||
sp.count_real = sp.count_real + i['count']
|
sp.count_real = sp.count_real + i.count
|
||||||
sp.save()
|
sp.save()
|
||||||
# 更新产出
|
# 更新产出
|
||||||
for i in OperationMaterial.objects.filter(operation=op, type=SubprodctionMaterial.SUB_MA_TYPE_OUT):
|
for i in OperationMaterial.objects.filter(operation=op, type=SubprodctionMaterial.SUB_MA_TYPE_OUT):
|
||||||
if not i.subproduction_progress.is_main:
|
if not i.subproduction_progress.is_main:
|
||||||
# 更新车间物料产出情况
|
# 更新车间物料产出情况
|
||||||
ins, _ = WMaterial.objects.get_or_create(subproduction_plan=i.subproduction_plan,
|
ins, _ = WMaterial.objects.get_or_create(subproduction_plan=i.subproduction_plan, material=i.material)
|
||||||
material=i.material)
|
ins.count = ins.count + i.count
|
||||||
ins.count = ins.count + i['count']
|
|
||||||
ins.save()
|
ins.save()
|
||||||
# 更新子计划物料产出情况
|
# 更新子计划物料产出情况
|
||||||
sp = i.subproduction_progress
|
sp = i.subproduction_progress
|
||||||
sp.count_real = sp.count_real + i['count']
|
sp.count_real = sp.count_real + i.count
|
||||||
sp.save()
|
sp.save()
|
||||||
# 更新动态产品表
|
# 更新动态产品表
|
||||||
if step.type == Step.STEP_TYPE_NOM:
|
if step.type == Step.STEP_TYPE_NOM:
|
||||||
|
@ -417,21 +416,25 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd
|
||||||
elif step.type == Step.STEP_TYPE_COMB:
|
elif step.type == Step.STEP_TYPE_COMB:
|
||||||
# 隐藏原半成品
|
# 隐藏原半成品
|
||||||
ows = OperationWproduct.objects.filter(operation=op)
|
ows = OperationWproduct.objects.filter(operation=op)
|
||||||
ows.update(is_hidden=True)
|
|
||||||
if i.subproduction_progress.is_main:
|
if i.subproduction_progress.is_main:
|
||||||
newstep, hasNext = WpmServies.get_next_step(i.subproduction_plan, step)
|
newstep, hasNext = WpmServies.get_next_step(i.subproduction_plan, step)
|
||||||
wproduct = WProduct()
|
wproduct = WProduct()
|
||||||
wproduct.material = i.material
|
wproduct.material = i.material
|
||||||
wproduct.step = newstep
|
wproduct.step = newstep
|
||||||
wproduct.subproduction_plan = i.subproduction_plan
|
wproduct.subproduction_plan = i.subproduction_plan
|
||||||
wproduct.parent = ows.values_list('wproduct', flat=True)
|
|
||||||
if hasNext:
|
if hasNext:
|
||||||
wproduct.act_state = WProduct.WPR_ACT_STATE_DOING
|
wproduct.act_state = WProduct.WPR_ACT_STATE_DOING
|
||||||
wproduct.is_executed = False
|
wproduct.is_executed = False
|
||||||
else:
|
else:
|
||||||
wproduct.act_state = WProduct.WPR_ACT_STATE_TOTEST
|
wproduct.act_state = WProduct.WPR_ACT_STATE_TOTEST
|
||||||
wproduct.is_executed = True
|
wproduct.is_executed = True
|
||||||
|
# 更新子计划进度
|
||||||
|
instance = SubProductionProgress.objects.get(subproduction_plan=i.subproduction_plan,
|
||||||
|
is_main=True, type=SubprodctionMaterial.SUB_MA_TYPE_OUT)
|
||||||
|
instance.count_real = instance.count_real + 1 # 这个地方可能会有问题,不够严谨
|
||||||
|
instance.save()
|
||||||
wproduct.save()
|
wproduct.save()
|
||||||
|
ows.update(is_hidden=True, child=wproduct)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue