增加待复检
This commit is contained in:
parent
4dfdd09a3c
commit
bb324727e0
|
@ -1,6 +1,5 @@
|
|||
<template>
|
||||
<div class="app-container">
|
||||
<el-card>
|
||||
<el-card>
|
||||
<div slot="header" class="clearfix">
|
||||
<span>基本信息</span>
|
||||
|
@ -465,7 +464,7 @@
|
|||
>提交本次操作</el-button
|
||||
>
|
||||
</el-card>
|
||||
</el-card>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
<style scoped>
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
# Generated by Django 3.2.9 on 2021-11-29 06:56
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('mtm', '0036_auto_20211123_1052'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='recordform',
|
||||
name='type',
|
||||
field=models.IntegerField(choices=[(1, '生产记录模板'), (2, '检验记录模板')], default=1, verbose_name='表格类型'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='step',
|
||||
name='need_test',
|
||||
field=models.BooleanField(default=False, verbose_name='是否需要检验'),
|
||||
),
|
||||
]
|
|
@ -81,7 +81,7 @@ class Step(CommonAModel):
|
|||
name = models.CharField('工序步骤名称', max_length=100)
|
||||
number = models.CharField('步骤编号', max_length=100, null=True, blank=True)
|
||||
instruction_content = models.TextField('相应操作指导', null=True, blank=True)
|
||||
need_test = models.BooleanField('是否需要过程检验', default=False)
|
||||
need_test = models.BooleanField('是否需要检验', default=False)
|
||||
sort = models.IntegerField('排序号', default=1)
|
||||
equipments = models.ManyToManyField(Equipment, verbose_name='使用设备', related_name='step_equips')
|
||||
|
||||
|
@ -99,8 +99,8 @@ class RecordForm(CommonAModel):
|
|||
RF_TYPE_DO = 1
|
||||
RF_TYPE_TEST = 2
|
||||
type_choices=(
|
||||
(RF_TYPE_DO, '生产记录'),
|
||||
(RF_TYPE_TEST, '检验记录')
|
||||
(RF_TYPE_DO, '生产记录模板'),
|
||||
(RF_TYPE_TEST, '检验记录模板')
|
||||
)
|
||||
name = models.CharField('表格名称', max_length=100)
|
||||
type = models.IntegerField('表格类型', choices=type_choices, default=1)
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 3.2.9 on 2021-11-29 06:56
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('qm', '0011_auto_20211119_0848'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='testrecorditem',
|
||||
name='field_type',
|
||||
field=models.CharField(choices=[(1, '生产记录模板'), (2, '检验记录模板')], max_length=50, verbose_name='字段类型'),
|
||||
),
|
||||
]
|
|
@ -8,5 +8,4 @@ from .permission import get_permission_list
|
|||
@receiver(m2m_changed, sender=User.roles.through)
|
||||
def update_perms_cache_user(sender, instance, action, **kwargs):
|
||||
if action in ['post_remove', 'post_add']:
|
||||
if cache.get(instance.username+'__perms', None):
|
||||
get_permission_list(instance)
|
|
@ -0,0 +1,23 @@
|
|||
# Generated by Django 3.2.9 on 2021-11-29 06:56
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('wpm', '0023_alter_operationmaterial_count'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='operationrecorditem',
|
||||
name='field_type',
|
||||
field=models.CharField(choices=[(1, '生产记录模板'), (2, '检验记录模板')], max_length=50, verbose_name='字段类型'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='wproduct',
|
||||
name='act_state',
|
||||
field=models.IntegerField(choices=[(6, '待复检'), (10, '生产中'), (20, '待检验'), (30, '已合格'), (40, '库存中'), (50, '不合格'), (60, '待成品检验')], default=0, verbose_name='进行状态'),
|
||||
),
|
||||
]
|
|
@ -23,15 +23,21 @@ class WProduct(CommonAModel):
|
|||
"""
|
||||
动态半成品/成品表
|
||||
"""
|
||||
WPR_ACT_STATE_DOING = 1
|
||||
WPR_ACT_STATE_TOTEST = 2
|
||||
WPR_ACT_STATE_OK = 3
|
||||
WPR_ACT_STATE_INM = 4
|
||||
WPR_ACT_STATE_TORETEST = 6
|
||||
WPR_ACT_STATE_DOING = 10
|
||||
WPR_ACT_STATE_TOTEST = 20
|
||||
WPR_ACT_STATE_OK = 30
|
||||
WPR_ACT_STATE_INM = 40
|
||||
WPR_ACT_STATE_NOTOK = 50
|
||||
WPR_ACT_STATE_TOFINALTEST = 60
|
||||
act_state_choices=(
|
||||
(WPR_ACT_STATE_TORETEST, '待复检'),
|
||||
(WPR_ACT_STATE_DOING, '生产中'),
|
||||
(WPR_ACT_STATE_TOTEST, '待检测'),
|
||||
(WPR_ACT_STATE_TOTEST, '待检验'),
|
||||
(WPR_ACT_STATE_OK, '已合格'),
|
||||
(WPR_ACT_STATE_INM, '库存中'),
|
||||
(WPR_ACT_STATE_NOTOK, '不合格'),
|
||||
(WPR_ACT_STATE_TOFINALTEST, '待成品检验')
|
||||
)
|
||||
number = models.CharField('物品编号', unique=True, null=True, blank=True, max_length=50)
|
||||
material = models.ForeignKey(Material, verbose_name='所属物料状态', on_delete=models.CASCADE)
|
||||
|
|
|
@ -37,16 +37,16 @@ class PickSerializer(serializers.Serializer):
|
|||
sp = validated_data.pop('subproduction_plan')
|
||||
if sp.state not in [SubProductionPlan.SUBPLAN_STATE_ASSGINED, SubProductionPlan.SUBPLAN_STATE_ACCEPTED,
|
||||
SubProductionPlan.SUBPLAN_STATE_WORKING]:
|
||||
raise exceptions.ValidationError('该子计划状态错误')
|
||||
raise exceptions.APIException('该子计划状态错误')
|
||||
# if sp.is_picked:
|
||||
# raise exceptions.ValidationError('该子计划已领料')
|
||||
# raise exceptions.APIException('该子计划已领料')
|
||||
# for i in picks:
|
||||
# try:
|
||||
# instance = MaterialBatch.objects.get(material=i['material'], batch=i['batch'])
|
||||
# if instance.count < i['pick_count']:
|
||||
# raise exceptions.ValidationError('物料不足')
|
||||
# raise exceptions.APIException('物料不足')
|
||||
# except:
|
||||
# raise exceptions.ValidationError('物料不存在')
|
||||
# raise exceptions.APIException('物料不存在')
|
||||
# 创建出库记录
|
||||
|
||||
with transaction.atomic():
|
||||
|
@ -100,7 +100,7 @@ class PickSerializer(serializers.Serializer):
|
|||
wproducts = WProduct.objects.filter(pk__in=wids)
|
||||
first_step = Step.objects.get(pk=sp.steps[0]['id'])
|
||||
wproducts.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_TORETEST, is_hidden=False, warehouse=None,
|
||||
subproduction_plan=sp)
|
||||
sp.is_picked=True
|
||||
sp.state = SubProductionPlan.SUBPLAN_STATE_WORKING #生产中
|
||||
|
@ -173,21 +173,23 @@ class OperationCreateSerializer(serializers.Serializer):
|
|||
|
||||
# stepIds=[i['id'] for i in subproduction_plan.steps]
|
||||
# if step.id not in stepIds:
|
||||
# raise exceptions.ValidationError('请选择正确的子工序操作')
|
||||
# raise exceptions.APIException('请选择正确的子工序操作')
|
||||
|
||||
if 'wproducts' in data and data['wproducts']:
|
||||
if step.type == Step.STEP_TYPE_DIV:
|
||||
raise exceptions.ValidationError(_('不可进行此操作'))
|
||||
raise exceptions.APIException(_('不可进行此操作'))
|
||||
for i in data['wproducts']:
|
||||
if i.act_state != WProduct.WPR_ACT_STATE_DOING:
|
||||
raise exceptions.APIException('半成品不在生产状态')
|
||||
if i.is_executed:
|
||||
raise exceptions.ValidationError('不可进行操作')
|
||||
raise exceptions.APIException('不可进行操作')
|
||||
# if i.subproduction_plan != subproduction_plan:
|
||||
# raise exceptions.ValidationError('半成品所属子计划不一致')
|
||||
# raise exceptions.APIException('半成品所属子计划不一致')
|
||||
if i.step != step:
|
||||
raise exceptions.ValidationError('半成品所属子工序不一致')
|
||||
raise exceptions.APIException('半成品所属子工序不一致')
|
||||
else:
|
||||
if step.type != Step.STEP_TYPE_DIV:
|
||||
raise exceptions.ValidationError(_('请选择半成品进行操作'))
|
||||
raise exceptions.APIException(_('请选择半成品进行操作'))
|
||||
return data
|
||||
|
||||
|
||||
|
@ -208,21 +210,21 @@ class OperationInitSerializer(serializers.Serializer):
|
|||
|
||||
# stepIds=[i['id'] for i in subproduction_plan.steps]
|
||||
# if step.id not in stepIds:
|
||||
# raise exceptions.ValidationError('请选择正确的子工序操作')
|
||||
# raise exceptions.APIException('请选择正确的子工序操作')
|
||||
|
||||
if 'wproducts' in data and data['wproducts']:
|
||||
if step.type == Step.STEP_TYPE_DIV:
|
||||
raise exceptions.ValidationError(_('不可进行此操作'))
|
||||
raise exceptions.APIException(_('不可进行此操作'))
|
||||
for i in data['wproducts']:
|
||||
if i.is_executed:
|
||||
raise exceptions.ValidationError('不可进行操作')
|
||||
raise exceptions.APIException('不可进行操作')
|
||||
# if i.subproduction_plan != subproduction_plan:
|
||||
# raise exceptions.ValidationError('半成品所属子计划不一致')
|
||||
# raise exceptions.APIException('半成品所属子计划不一致')
|
||||
if i.step != step:
|
||||
raise exceptions.ValidationError('半成品所属子工序不一致')
|
||||
raise exceptions.APIException('半成品所属子工序不一致')
|
||||
else:
|
||||
if step.type != Step.STEP_TYPE_DIV:
|
||||
raise exceptions.ValidationError(_('请选择半成品进行操作'))
|
||||
raise exceptions.APIException(_('请选择半成品进行操作'))
|
||||
return data
|
||||
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ class WPlanViewSet(ListModelMixin, GenericViewSet):
|
|||
spp.save()
|
||||
wps = WProduct.objects.filter(pk__in=[x for x in i['wproducts']])
|
||||
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_TORETEST, is_hidden=False, warehouse=None,
|
||||
subproduction_plan=sp, update_by=request.user, update_time=timezone.now())
|
||||
sp.is_picked = True
|
||||
sp.save()
|
||||
|
@ -179,11 +179,12 @@ class WProductViewSet(ListModelMixin, GenericViewSet):
|
|||
record_data = vdata.pop('record_data')
|
||||
wproduct = vdata['wproduct']
|
||||
if wproduct.act_state != WProduct.WPR_ACT_STATE_TOTEST:
|
||||
raise exceptions.APIException('该半成品不可检测')
|
||||
raise exceptions.APIException('该产品当前状态不可检验')
|
||||
if 'is_testok' not in vdata:
|
||||
raise exceptions.APIException('未填写检测结论')
|
||||
|
||||
obj = serializer.save(create_by = self.request.user, material=wproduct.material)
|
||||
obj = serializer.save(create_by = self.request.user,
|
||||
material=wproduct.material, number=wproduct.number, subproduction_plan=wproduct.subproduction_plan)
|
||||
tris = []
|
||||
for m in record_data: # 保存记录详情
|
||||
form_field = m['form_field']
|
||||
|
@ -212,10 +213,53 @@ class WProductViewSet(ListModelMixin, GenericViewSet):
|
|||
instance.count_ok = instance.count_ok + 1 # 这个地方可能会有问题
|
||||
instance.save()
|
||||
else:# 如果不合格
|
||||
pass
|
||||
wproduct.act_state = WProduct.WPR_ACT_STATE_NOTOK
|
||||
wproduct.save()
|
||||
|
||||
return Response()
|
||||
|
||||
@action(methods=['post'], detail=False, perms_map={'post':'*'}, serializer_class=WpmTestRecordCreateSerializer)
|
||||
@transaction.atomic
|
||||
def retest(self, request, pk=None):
|
||||
"""
|
||||
复检
|
||||
"""
|
||||
serializer = WpmTestRecordCreateSerializer(data=request.data)
|
||||
serializer.is_valid(raise_exception=True)
|
||||
vdata = serializer.validated_data
|
||||
record_data = vdata.pop('record_data')
|
||||
wproduct = vdata['wproduct']
|
||||
if wproduct.act_state != WProduct.WPR_ACT_STATE_TORETEST:
|
||||
raise exceptions.APIException('该产品当前状态不可检验')
|
||||
if 'is_testok' not in vdata:
|
||||
raise exceptions.APIException('未填写检测结论')
|
||||
|
||||
obj = serializer.save(create_by = self.request.user,
|
||||
material=wproduct.material, number=wproduct.number, subproduction_plan=wproduct.subproduction_plan)
|
||||
tris = []
|
||||
for m in record_data: # 保存记录详情
|
||||
form_field = m['form_field']
|
||||
m['field_name'] = form_field.field_name
|
||||
m['field_key'] = form_field.field_key
|
||||
m['field_type'] = form_field.field_type
|
||||
m['field_value'] = m['field_value']
|
||||
m['sort'] = form_field.sort
|
||||
m['need_judge'] = form_field.need_judge
|
||||
m['is_testok'] = m['is_testok'] if 'is_testok' in m else None
|
||||
m['test_record'] = obj
|
||||
tris.append(TestRecordItem(**m))
|
||||
TestRecordItem.objects.bulk_create(tris)
|
||||
|
||||
# 如果检测合格, 变更动态产品进行状态
|
||||
|
||||
if obj.is_testok:
|
||||
wproduct.act_state = WProduct.WPR_ACT_STATE_DOING
|
||||
wproduct.save()
|
||||
else:# 如果不合格
|
||||
wproduct.act_state = WProduct.WPR_ACT_STATE_NOTOK
|
||||
wproduct.save()
|
||||
return Response()
|
||||
|
||||
@action(methods=['post'], detail=True, perms_map={'post':'*'}, serializer_class=WproductPutInSerializer)
|
||||
@transaction.atomic
|
||||
def putin(self, request, pk=None):
|
||||
|
|
Loading…
Reference in New Issue