This commit is contained in:
parent
24307e27f5
commit
a5a11303e0
|
@ -64,7 +64,7 @@ class TestRecord(CommonAModel):
|
|||
is_testok = models.BooleanField('是否合格', default=True)
|
||||
is_testok_robot = models.BooleanField('自动判定的是否合格', default=True)
|
||||
number = models.CharField('产品编号', null=True, blank=True, max_length=50)
|
||||
wproduct = models.ForeignKey('wpm.wproduct', verbose_name='关联的动态产品', on_delete=models.CASCADE, null=True, blank=True)
|
||||
wproduct = models.ForeignKey('wpm.wproduct', verbose_name='关联的动态产品', on_delete=models.CASCADE, null=True, blank=True, related_name='test_wproduct')
|
||||
material = models.ForeignKey('mtm.material', verbose_name='关联的物料状态', on_delete=models.CASCADE, null=True, blank=True)
|
||||
step = models.ForeignKey('mtm.step', verbose_name='关联的工序步骤', on_delete=models.CASCADE, null=True, blank=True)
|
||||
subproduction_plan = models.ForeignKey('pm.subproductionplan', verbose_name='关联的生产子计划', on_delete=models.CASCADE, null=True, blank=True)
|
||||
|
|
|
@ -13,6 +13,7 @@ class Workflow(CommonAModel):
|
|||
工作流
|
||||
"""
|
||||
name = models.CharField('名称', max_length=50)
|
||||
key = models.CharField('工作流标识', unique=True, max_length=20)
|
||||
sn_prefix = models.CharField('流水号前缀', max_length=50, default='hb')
|
||||
description = models.CharField('描述', max_length=200)
|
||||
view_permission_check = models.BooleanField('查看权限校验', default=True, help_text='开启后,只允许工单的关联人(创建人、曾经的处理人)有权限查看工单')
|
||||
|
|
|
@ -5,6 +5,7 @@ import django.utils.timezone as timezone
|
|||
from django.db.models.query import QuerySet
|
||||
from apps.inm.models import FIFO, WareHouse
|
||||
from apps.pm.models import ProductionPlan, SubProductionPlan, SubProductionProgress
|
||||
from apps.qm.models import TestRecord
|
||||
from apps.system.models import CommonADModel, CommonAModel, CommonBModel, Organization, User, Dict, File
|
||||
from utils.model import SoftModel, BaseModel
|
||||
from simple_history.models import HistoricalRecords
|
||||
|
@ -56,6 +57,12 @@ class WProduct(CommonAModel):
|
|||
operation = models.ForeignKey('wpm.operation', verbose_name='关联操作',
|
||||
on_delete=models.SET_NULL, null=True, blank=True, related_name='wp_operation')
|
||||
|
||||
@property
|
||||
def last_process_test(self):
|
||||
"""
|
||||
最后的工序自检
|
||||
"""
|
||||
return self.test_wproduct.filter(type=TestRecord.TEST_PROCESS).order_by('-id').first()
|
||||
class WprouctTicket(CommonAModel):
|
||||
"""
|
||||
玻璃审批工单
|
||||
|
|
|
@ -290,7 +290,7 @@ class WpmTestRecordCreateSerializer(serializers.ModelSerializer):
|
|||
is_testok = serializers.BooleanField(required=False)
|
||||
class Meta:
|
||||
model = TestRecord
|
||||
fields = ['form', 'record_data', 'is_testok', 'wproduct', 'origin_test']
|
||||
fields = ['form', 'record_data', 'is_testok', 'wproduct']
|
||||
|
||||
def validate(self, attrs):
|
||||
wproduct = attrs['wproduct']
|
||||
|
@ -303,8 +303,15 @@ class WpmTestRecordCreateSerializer(serializers.ModelSerializer):
|
|||
|
||||
class WpmTestFormInitSerializer(serializers.Serializer):
|
||||
wproduct = serializers.PrimaryKeyRelatedField(queryset=WProduct.objects.all(), required=True)
|
||||
form = serializers.PrimaryKeyRelatedField(queryset=RecordForm.objects.all(), required=True)
|
||||
form = serializers.PrimaryKeyRelatedField(queryset=RecordForm.objects.all(), required=False)
|
||||
|
||||
def validate(self, attrs):
|
||||
wproduct = attrs['wproduct']
|
||||
form = attrs.get('form', None)
|
||||
if wproduct.act_state != WProduct.WPR_ACT_STATE_TORETEST:
|
||||
if not form:
|
||||
raise exceptions.APIException('请指定检查表')
|
||||
return super().validate(attrs)
|
||||
|
||||
class WplanPutInSerializer(serializers.Serializer):
|
||||
warehouse = serializers.PrimaryKeyRelatedField(queryset=WareHouse.objects.all(), label="仓库ID")
|
||||
|
|
|
@ -193,16 +193,16 @@ class WProductViewSet(ListModelMixin, GenericViewSet):
|
|||
serializer.is_valid(raise_exception=True)
|
||||
vdata = serializer.validated_data
|
||||
wproduct = vdata['wproduct']
|
||||
form = vdata['form']
|
||||
form = vdata.get('form', None)
|
||||
|
||||
|
||||
# 如果是复检记录, 需要带入原数据
|
||||
if wproduct.act_state == WProduct.WPR_ACT_STATE_TORETEST:
|
||||
# 查找最近一条检验记录
|
||||
trs = TestRecord.objects.filter(wproduct=wproduct, type=TestRecord.TEST_PROCESS).order_by('-id').first()
|
||||
trs = wproduct.last_process_test
|
||||
if trs:
|
||||
origin_test = TestRecordDetailSerializer(instance=trs).data
|
||||
data = RecordFormDetailSerializer(instance=form).data
|
||||
data = RecordFormDetailSerializer(instance=trs.form).data
|
||||
data['origin_test'] = origin_test
|
||||
o_dict = {}
|
||||
for i in origin_test['record_data_']:
|
||||
|
@ -261,6 +261,8 @@ class WProductViewSet(ListModelMixin, GenericViewSet):
|
|||
|
||||
if obj.is_testok:
|
||||
if wproduct.act_state == WProduct.WPR_ACT_STATE_TORETEST: # 复检
|
||||
obj.origin_test = wproduct.last_process_test
|
||||
obj.save()
|
||||
wproduct.act_state = WProduct.WPR_ACT_STATE_DOWAIT
|
||||
elif wproduct.act_state == WProduct.WPR_ACT_STATE_TOTEST and wproduct.material.type == Material.MA_TYPE_GOOD: # 成品检验
|
||||
wproduct.act_state = WProduct.WPR_ACT_STATE_TOFINALTEST
|
||||
|
|
Loading…
Reference in New Issue