Merge branch 'develop' of https://e.coding.net/ctcdevteam/hberp/hberp into develop
This commit is contained in:
commit
2b4bc1025b
|
@ -5,11 +5,11 @@ from apps.mtm.models import TechDoc
|
|||
|
||||
|
||||
class TechDocFilterset(filters.FilterSet):
|
||||
# operation = filters.NumberFilter(method='filter_operation')
|
||||
operation = filters.CharFilter(field_name="subproduction__subplan_subprod__ow_subplan__operation")
|
||||
operation = filters.NumberFilter(method='filter_operation')
|
||||
# operation = filters.CharFilter(field_name="subproduction__subplan_subprod__ow_subplan__operation")
|
||||
class Meta:
|
||||
model = TechDoc
|
||||
fields = ['subproduction', 'operation']
|
||||
|
||||
# def filter_operation(self, queryset, name, value):
|
||||
# return queryset.filter(subproduction__subplan_subprod__ow_subplan__operation=value)
|
||||
def filter_operation(self, queryset, name, value):
|
||||
return queryset.filter(subproduction__subplan_subprod__ow_subplan__operation=value).distinct()
|
||||
|
|
|
@ -208,7 +208,7 @@ class RecordFormDetailSerializer(serializers.ModelSerializer):
|
|||
return queryset
|
||||
|
||||
def get_form_fields(self, obj):
|
||||
serializer = RecordFormFieldSerializer(instance=RecordFormField.objects.filter(form=obj, is_deleted=False), many=True)
|
||||
serializer = RecordFormFieldSerializer(instance=RecordFormField.objects.filter(form=obj, is_deleted=False).order_by('sort'), many=True)
|
||||
data = serializer.data
|
||||
if obj.type == RecordForm.RF_TYPE_TEST:
|
||||
for i in data:
|
||||
|
|
|
@ -238,5 +238,3 @@ class ResourceViewSet(GenericViewSet):
|
|||
equips = Equipment.objects.filter(step_equips__in=steps, is_deleted=False).distinct()
|
||||
serializer = EquipmentSerializer(instance=equips, many=True)
|
||||
return Response(serializer.data)
|
||||
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -50,7 +50,7 @@ class TestRecordViewSet(ListModelMixin, RetrieveModelMixin, GenericViewSet):
|
|||
perms_map = {'*': '*'}
|
||||
queryset = TestRecord.objects.select_related('fifo_item', 'form').all()
|
||||
serializer_class = TestRecordListSerializer
|
||||
filterset_fields = ['wproduct', 'material', 'step', 'subproduction_plan', 'fifo_item', 'origin_test']
|
||||
filterset_fields = ['wproduct', 'material', 'step', 'subproduction_plan', 'fifo_item', 'origin_test', 'type']
|
||||
ordering = ['-id']
|
||||
|
||||
def get_serializer_class(self):
|
||||
|
|
|
@ -7,6 +7,7 @@ from apps.inm.serializers import IProductListSerializer
|
|||
from .models import Contract, Customer, Order, Sale, SaleProduct
|
||||
|
||||
from apps.mtm.serializers import MaterialSimpleSerializer
|
||||
from utils.tools import ranstr
|
||||
|
||||
class CustomerSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
|
@ -45,6 +46,10 @@ class OrderCreateUpdateSerializer(serializers.ModelSerializer):
|
|||
model = Order
|
||||
fields = ['number', 'customer', 'contract', 'product', 'count', 'delivery_date']
|
||||
|
||||
def create(self, validated_data):
|
||||
validated_data['number'] = 'DD' + ranstr(7)
|
||||
return super().create(validated_data)
|
||||
|
||||
class OrderSerializer(serializers.ModelSerializer):
|
||||
contract_ = ContractSimpleSerializer(source='contract', read_only=True)
|
||||
customer_ = CustomerSimpleSerializer(source='customer', read_only=True)
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
|
@ -0,0 +1,6 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class SrmConfig(AppConfig):
|
||||
name = 'apps.srm'
|
||||
verbose_name = '统计报表'
|
|
@ -0,0 +1,3 @@
|
|||
from django.db import models
|
||||
|
||||
# Create your models here.
|
|
@ -0,0 +1,3 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
|
@ -0,0 +1,8 @@
|
|||
from django.shortcuts import render
|
||||
from rest_framework.generics import ListAPIView
|
||||
# Create your views here.
|
||||
|
||||
class GanttOrder(ListAPIView):
|
||||
"""
|
||||
订单-计划-子计划甘特图
|
||||
"""
|
|
@ -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):
|
||||
"""
|
||||
玻璃审批工单
|
||||
|
|
|
@ -288,15 +288,21 @@ class WpmTestRecordCreateSerializer(serializers.ModelSerializer):
|
|||
record_data = WpmTestRecordItemCreateSerializer(many=True)
|
||||
wproduct = serializers.PrimaryKeyRelatedField(queryset=WProduct.objects.all(), required=True)
|
||||
is_testok = serializers.BooleanField(required=False)
|
||||
|
||||
class Meta:
|
||||
model = TestRecord
|
||||
fields = ['form', 'record_data', 'is_testok', 'wproduct']
|
||||
|
||||
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,22 +193,22 @@ 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_']:
|
||||
o_dict[i['field_key']] = i['field_value']
|
||||
for i in data['form_fields']:
|
||||
i['origin_value'] = o_dict[i['field_key']]
|
||||
i['origin_value'] = o_dict[i['field_key']] if i['field_key'] in o_dict else None
|
||||
else:
|
||||
raise exceptions.APIException('原工序检验记录不存在')
|
||||
else:
|
||||
|
@ -249,7 +249,6 @@ class WProductViewSet(ListModelMixin, GenericViewSet):
|
|||
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
|
||||
|
@ -261,6 +260,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
|
||||
|
@ -660,7 +661,6 @@ class OperationRecordViewSet(ListModelMixin, DestroyModelMixin, GenericViewSet):
|
|||
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['operation_record'] = opr
|
||||
wrds.append(OperationRecordItem(**m))
|
||||
|
|
|
@ -57,7 +57,8 @@ INSTALLED_APPS = [
|
|||
'apps.sam',
|
||||
'apps.qm',
|
||||
'apps.pm',
|
||||
'apps.wpm'
|
||||
'apps.wpm',
|
||||
'apps.srm'
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
|
|
Loading…
Reference in New Issue