Merge branch 'develop' of https://e.coding.net/ctcdevteam/hberp/hberp into develop

This commit is contained in:
shijing 2021-11-23 14:57:53 +08:00
commit 4487c34f86
3 changed files with 43 additions and 31 deletions

View File

@ -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'),
),
]

View File

@ -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)

View File

@ -364,24 +364,24 @@ 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 spp = SubProductionProgress.objects.get(subproduction_plan=i_wmat.subproduction_plan,
sp.count_real = sp.count_real + i['count'] material=i_wmat.material)
sp.save() spp.count_real = spp.count_real + i.count
spp.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 spp = i.subproduction_progress
sp.count_real = sp.count_real + i['count'] spp.count_real = spp.count_real + i.count
sp.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): for i in OperationWproduct.objects.filter(operation=op):
@ -417,21 +417,28 @@ 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)
op.is_submited = True
op.save()
return Response()
@ -544,12 +551,6 @@ class OperationMaterialInputViewSet(ListModelMixin, CreateModelMixin, DestroyMod
if self.action == 'create': if self.action == 'create':
return OperationMaterialCreate1Serailizer return OperationMaterialCreate1Serailizer
return super().get_serializer_class() return super().get_serializer_class()
def create(self, request, *args, **kwargs):
instance = self.get_object()
if instance.operation.is_submited:
raise exceptions.APIException('该操作已提交')
return super().create(request, *args, **kwargs)
@transaction.atomic() @transaction.atomic()
def destroy(self, request, *args, **kwargs): def destroy(self, request, *args, **kwargs):
@ -574,12 +575,6 @@ class OperationMaterialOutputViewSet(ListModelMixin, CreateModelMixin, DestroyMo
if self.action == 'create': if self.action == 'create':
return OperationMaterialCreate2Serailizer return OperationMaterialCreate2Serailizer
return super().get_serializer_class() return super().get_serializer_class()
def create(self, request, *args, **kwargs):
instance = self.get_object()
if instance.operation.is_submited:
raise exceptions.APIException('该操作已提交')
return super().create(request, *args, **kwargs)
@transaction.atomic() @transaction.atomic()
def destroy(self, request, *args, **kwargs): def destroy(self, request, *args, **kwargs):
@ -604,12 +599,6 @@ class OperationMaterialToolViewSet(ListModelMixin, CreateModelMixin, DestroyMode
if self.action == 'create': if self.action == 'create':
return OperationMaterialCreate3Serializer return OperationMaterialCreate3Serializer
return super().get_serializer_class() return super().get_serializer_class()
def create(self, request, *args, **kwargs):
instance = self.get_object()
if instance.operation.is_submited:
raise exceptions.APIException('该操作已提交')
return super().create(request, *args, **kwargs)
@transaction.atomic() @transaction.atomic()
def destroy(self, request, *args, **kwargs): def destroy(self, request, *args, **kwargs):