提交操作
This commit is contained in:
parent
8666c13da8
commit
a0e56d3666
|
@ -0,0 +1,21 @@
|
||||||
|
# Generated by Django 3.2.9 on 2021-11-23 01:45
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('wpm', '0020_alter_operationwproduct_wproduct'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='operationwproduct',
|
||||||
|
name='production_plan',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='wproduct',
|
||||||
|
name='production_plan',
|
||||||
|
),
|
||||||
|
]
|
|
@ -43,7 +43,6 @@ class WProduct(CommonAModel):
|
||||||
parent = models.JSONField('父', default=list, blank=True)
|
parent = models.JSONField('父', default=list, blank=True)
|
||||||
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')
|
||||||
production_plan = models.ForeignKey(ProductionPlan, verbose_name='关联主生产计划', on_delete=models.CASCADE)
|
|
||||||
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)
|
||||||
operation = models.ForeignKey('wpm.operation', verbose_name='关联操作',
|
operation = models.ForeignKey('wpm.operation', verbose_name='关联操作',
|
||||||
on_delete=models.SET_NULL, null=True, blank=True, related_name='current_operation')
|
on_delete=models.SET_NULL, null=True, blank=True, related_name='current_operation')
|
||||||
|
@ -66,7 +65,6 @@ class OperationWproduct(BaseModel):
|
||||||
number = models.CharField('物品编号', null=True, blank=True, max_length=50)
|
number = models.CharField('物品编号', null=True, blank=True, max_length=50)
|
||||||
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)
|
subproduction_plan = models.ForeignKey(SubProductionPlan, verbose_name='当前子生产计划', on_delete=models.CASCADE)
|
||||||
production_plan = models.ForeignKey(ProductionPlan, verbose_name='当前主生产计划', on_delete=models.CASCADE)
|
|
||||||
|
|
||||||
|
|
||||||
class OperationMaterial(BaseModel):
|
class OperationMaterial(BaseModel):
|
||||||
|
|
|
@ -69,7 +69,7 @@ class WPlanViewSet(ListModelMixin, GenericViewSet):
|
||||||
wps = WProduct.objects.filter(pk__in=[x for x in i['wproducts']])
|
wps = WProduct.objects.filter(pk__in=[x for x in i['wproducts']])
|
||||||
wps.update(step=first_step, is_executed=False,
|
wps.update(step=first_step, is_executed=False,
|
||||||
act_state=WProduct.WPR_ACT_STATE_DOING, is_hidden=False, warehouse=None,
|
act_state=WProduct.WPR_ACT_STATE_DOING, is_hidden=False, warehouse=None,
|
||||||
subproduction_plan=sp, production_plan=sp.production_plan, update_by=request.user, update_time=timezone.now())
|
subproduction_plan=sp, update_by=request.user, update_time=timezone.now())
|
||||||
return Response()
|
return Response()
|
||||||
|
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ class WPlanViewSet(ListModelMixin, GenericViewSet):
|
||||||
vdata = serializer.data
|
vdata = serializer.data
|
||||||
subplan = self.get_object()
|
subplan = self.get_object()
|
||||||
material = subplan.main_product
|
material = subplan.main_product
|
||||||
batch = subplan.production_plan.number
|
batch = subplan.number
|
||||||
warehouse = WareHouse.objects.get(id=vdata['warehouse'])
|
warehouse = WareHouse.objects.get(id=vdata['warehouse'])
|
||||||
wproducts = WProduct.objects.filter(subproduction_plan=subplan,
|
wproducts = WProduct.objects.filter(subproduction_plan=subplan,
|
||||||
act_state=WProduct.WPR_ACT_STATE_OK, material=material, is_deleted=False)
|
act_state=WProduct.WPR_ACT_STATE_OK, material=material, is_deleted=False)
|
||||||
|
@ -160,7 +160,7 @@ class WProductViewSet(ListModelMixin, GenericViewSet):
|
||||||
perms_map={'*':'*'}
|
perms_map={'*':'*'}
|
||||||
queryset = WProduct.objects.select_related('step', 'material').filter(is_hidden=False).exclude(operation=None)
|
queryset = WProduct.objects.select_related('step', 'material').filter(is_hidden=False).exclude(operation=None)
|
||||||
serializer_class = WProductListSerializer
|
serializer_class = WProductListSerializer
|
||||||
filterset_fields = ['step', 'subproduction_plan', 'material', 'production_plan', 'step__process', 'act_state']
|
filterset_fields = ['step', 'subproduction_plan', 'material', 'step__process', 'act_state']
|
||||||
search_fields = ['number']
|
search_fields = ['number']
|
||||||
ordering_fields = ['id']
|
ordering_fields = ['id']
|
||||||
ordering = ['id']
|
ordering = ['id']
|
||||||
|
@ -207,7 +207,7 @@ class WProductViewSet(ListModelMixin, GenericViewSet):
|
||||||
# 更新子计划主产品数
|
# 更新子计划主产品数
|
||||||
instance = SubProductionProgress.objects.get(subproduction_plan=wproduct.subproduction_plan,
|
instance = SubProductionProgress.objects.get(subproduction_plan=wproduct.subproduction_plan,
|
||||||
is_main=True, type=SubprodctionMaterial.SUB_MA_TYPE_OUT)
|
is_main=True, type=SubprodctionMaterial.SUB_MA_TYPE_OUT)
|
||||||
instance.count_real = instance.count_real + 1 # 这个地方可能会有问题
|
instance.count_ok = instance.count_ok + 1 # 这个地方可能会有问题
|
||||||
instance.save()
|
instance.save()
|
||||||
else:# 如果不合格
|
else:# 如果不合格
|
||||||
pass
|
pass
|
||||||
|
@ -228,7 +228,7 @@ class WProductViewSet(ListModelMixin, GenericViewSet):
|
||||||
if wproduct.act_state != WProduct.WPR_ACT_STATE_OK:
|
if wproduct.act_state != WProduct.WPR_ACT_STATE_OK:
|
||||||
raise exceptions.APIException('半成品不可入库')
|
raise exceptions.APIException('半成品不可入库')
|
||||||
material = wproduct.material
|
material = wproduct.material
|
||||||
batch = wproduct.production_plan.number
|
batch = wproduct.subproduction_plan.number
|
||||||
# 创建入库记录
|
# 创建入库记录
|
||||||
remark = vdata.get('remark', '')
|
remark = vdata.get('remark', '')
|
||||||
fifo = FIFO.objects.create(type=FIFO.FIFO_TYPE_DO_IN,
|
fifo = FIFO.objects.create(type=FIFO.FIFO_TYPE_DO_IN,
|
||||||
|
@ -314,7 +314,6 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd
|
||||||
owp['number'] = wpd.number
|
owp['number'] = wpd.number
|
||||||
owp['material'] = wpd.material
|
owp['material'] = wpd.material
|
||||||
owp['subproduction_plan'] = wpd.subproduction_plan
|
owp['subproduction_plan'] = wpd.subproduction_plan
|
||||||
owp['production_plan'] = wpd.production_plan
|
|
||||||
owps.append(OperationWproduct(**owp))
|
owps.append(OperationWproduct(**owp))
|
||||||
OperationWproduct.objects.bulk_create(owps)
|
OperationWproduct.objects.bulk_create(owps)
|
||||||
else:
|
else:
|
||||||
|
@ -350,6 +349,10 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd
|
||||||
提交车间操作重要
|
提交车间操作重要
|
||||||
"""
|
"""
|
||||||
op = self.get_object()
|
op = self.get_object()
|
||||||
|
step = op.step
|
||||||
|
# 检查自定义表单填写
|
||||||
|
if OperationRecord.objects.filter(operation=op, is_filled=False).exists():
|
||||||
|
raise exceptions.APIException('存在自定义表单未填写')
|
||||||
# 更新物料消耗进度
|
# 更新物料消耗进度
|
||||||
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):
|
||||||
# 更新车间物料
|
# 更新车间物料
|
||||||
|
@ -360,9 +363,69 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd
|
||||||
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):
|
||||||
|
if not i.subproduction_progress.is_main:
|
||||||
|
# 更新车间物料产出情况
|
||||||
|
ins, _ = WMaterial.objects.get_or_create(subproduction_plan=i.subproduction_plan,
|
||||||
|
material=i.material)
|
||||||
|
ins.count = ins.count + i['count']
|
||||||
|
ins.save()
|
||||||
|
# 更新子计划物料产出情况
|
||||||
|
sp = i.subproduction_progress
|
||||||
|
sp.count_real = sp.count_real + i['count']
|
||||||
|
sp.save()
|
||||||
|
# 更新动态产品表
|
||||||
|
if step.type == Step.STEP_TYPE_NOM:
|
||||||
|
for i in OperationWproduct.objects.filter(operation=op):
|
||||||
|
wp = i.wproduct
|
||||||
|
wsp = i.subproduction_plan
|
||||||
|
# 获取下一步子工序
|
||||||
|
newstep, hasNext = WpmServies.get_next_step(wsp, step)
|
||||||
|
wp.step = newstep
|
||||||
|
wp.pre_step = step
|
||||||
|
if hasNext:
|
||||||
|
wp.is_executed= False
|
||||||
|
else:
|
||||||
|
wp.is_executed = True
|
||||||
|
wp.act_state = WProduct.WPR_ACT_STATE_TOTEST
|
||||||
|
wp.material = wsp.main_product
|
||||||
|
# 更新子计划进度
|
||||||
|
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()
|
||||||
|
wp.operation = None
|
||||||
|
wp.save()
|
||||||
|
elif step.type == Step.STEP_TYPE_DIV:
|
||||||
|
# 更新物料产出情况
|
||||||
|
for i in OperationMaterial.objects.filter(operation=op, type=SubprodctionMaterial.SUB_MA_TYPE_OUT):
|
||||||
|
if i.subproduction_progress.is_main:
|
||||||
|
newstep, _ = WpmServies.get_next_step(i.subproduction_plan, step)
|
||||||
|
wpr = dict(material=i.material, step=newstep,
|
||||||
|
act_state=WProduct.WPR_ACT_STATE_DOING, is_executed=False, remark='',
|
||||||
|
subproduction_plan=i.subproduction_plan)
|
||||||
|
for x in range(i.count):
|
||||||
|
WProduct.objects.create(**wpr)
|
||||||
|
elif step.type == Step.STEP_TYPE_COMB:
|
||||||
|
# 隐藏原半成品
|
||||||
|
ows = OperationWproduct.objects.filter(operation=op)
|
||||||
|
ows.update(is_hidden=True)
|
||||||
|
if i.subproduction_progress.is_main:
|
||||||
|
newstep, hasNext = WpmServies.get_next_step(i.subproduction_plan, step)
|
||||||
|
wproduct = WProduct()
|
||||||
|
wproduct.material = i.material
|
||||||
|
wproduct.step = newstep
|
||||||
|
wproduct.subproduction_plan = i.subproduction_plan
|
||||||
|
wproduct.parent = ows.values_list('wproduct', flat=True)
|
||||||
|
if hasNext:
|
||||||
|
wproduct.act_state = WProduct.WPR_ACT_STATE_DOING
|
||||||
|
wproduct.is_executed = False
|
||||||
|
else:
|
||||||
|
wproduct.act_state = WProduct.WPR_ACT_STATE_TOTEST
|
||||||
|
wproduct.is_executed = True
|
||||||
|
wproduct.save()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class OperationWproductViewSet(ListModelMixin, DestroyModelMixin, GenericViewSet):
|
class OperationWproductViewSet(ListModelMixin, DestroyModelMixin, GenericViewSet):
|
||||||
|
@ -598,7 +661,6 @@ class DoFormSubmit(CreateAPIView, GenericAPIView):
|
||||||
owp['number'] = wp.number
|
owp['number'] = wp.number
|
||||||
owp['material'] = wp.material
|
owp['material'] = wp.material
|
||||||
owp['subproduction_plan'] = wp.subproduction_plan
|
owp['subproduction_plan'] = wp.subproduction_plan
|
||||||
owp['production_plan'] = wp.production_plan
|
|
||||||
owps.append(OperationWproduct(**owp))
|
owps.append(OperationWproduct(**owp))
|
||||||
OperationWproduct.objects.bulk_create(owps)
|
OperationWproduct.objects.bulk_create(owps)
|
||||||
|
|
||||||
|
@ -628,8 +690,7 @@ class DoFormSubmit(CreateAPIView, GenericAPIView):
|
||||||
newstep, _ = WpmServies.get_next_step(i['subproduction_plan'], vdata['step'])
|
newstep, _ = WpmServies.get_next_step(i['subproduction_plan'], vdata['step'])
|
||||||
wpr = dict(material=ma, step=newstep,
|
wpr = dict(material=ma, step=newstep,
|
||||||
act_state=WProduct.WPR_ACT_STATE_DOING, is_executed=False, remark='',
|
act_state=WProduct.WPR_ACT_STATE_DOING, is_executed=False, remark='',
|
||||||
subproduction_plan=i['subproduction_plan'],
|
subproduction_plan=i['subproduction_plan'])
|
||||||
production_plan=i['subproduction_plan'].production_plan)
|
|
||||||
for x in range(i['count_output']):
|
for x in range(i['count_output']):
|
||||||
WProduct.objects.create(**wpr)
|
WProduct.objects.create(**wpr)
|
||||||
else:
|
else:
|
||||||
|
@ -658,7 +719,6 @@ class DoFormSubmit(CreateAPIView, GenericAPIView):
|
||||||
wproduct.material = vdata['subproduction_plan'].main_product
|
wproduct.material = vdata['subproduction_plan'].main_product
|
||||||
wproduct.step = newstep
|
wproduct.step = newstep
|
||||||
wproduct.subproduction_plan=vdata['subproduction_plan']
|
wproduct.subproduction_plan=vdata['subproduction_plan']
|
||||||
wproduct.production_plan=vdata['subproduction_plan'].production_plan
|
|
||||||
wproduct.parent = data['wproducts']
|
wproduct.parent = data['wproducts']
|
||||||
if hasNext:
|
if hasNext:
|
||||||
wproduct.act_state=WProduct.WPR_ACT_STATE_DOING
|
wproduct.act_state=WProduct.WPR_ACT_STATE_DOING
|
||||||
|
|
|
@ -62,7 +62,7 @@ class UpdateDevelop(APIView):
|
||||||
import os
|
import os
|
||||||
# 更新后端
|
# 更新后端
|
||||||
os.chdir('/home/hberp')
|
os.chdir('/home/hberp')
|
||||||
ret = os.popen('git pull https://caoqianming%40ctc.ac.cn:9093qqww@e.coding.net/ctcdevteam/hberp/hberp.git origin develop')
|
ret = os.popen('git pull https://caoqianming%40ctc.ac.cn:9093qqww@e.coding.net/ctcdevteam/hberp/hberp.git develop')
|
||||||
# 打包前端
|
# 打包前端
|
||||||
# os.chdir('/home/hberp/hb_client')
|
# os.chdir('/home/hberp/hb_client')
|
||||||
# os.system('npm run build:prod')
|
# os.system('npm run build:prod')
|
||||||
|
|
Loading…
Reference in New Issue