操作时掉出工具工装
This commit is contained in:
parent
de94a56416
commit
4e5eead1a8
|
@ -0,0 +1,34 @@
|
||||||
|
# Generated by Django 3.2.6 on 2021-11-17 08:37
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('mtm', '0034_auto_20211116_1603'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='techdoc',
|
||||||
|
name='enabled',
|
||||||
|
field=models.BooleanField(default=True, verbose_name='是否启用'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='step',
|
||||||
|
name='type',
|
||||||
|
field=models.IntegerField(choices=[(1, '常规'), (2, '分割'), (3, '结合')], default=1, verbose_name='操作类型'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='subprodctionmaterial',
|
||||||
|
name='subproduction',
|
||||||
|
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='subm_subprod', to='mtm.subproduction', verbose_name='关联生产分解'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='techdoc',
|
||||||
|
name='subproduction',
|
||||||
|
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='tech_subprod', to='mtm.subproduction', verbose_name='关联生产分解'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -72,7 +72,7 @@ class Step(CommonAModel):
|
||||||
STEP_TYPE_DIV = 2
|
STEP_TYPE_DIV = 2
|
||||||
STEP_TYPE_COMB = 3
|
STEP_TYPE_COMB = 3
|
||||||
step_type_choices=(
|
step_type_choices=(
|
||||||
(STEP_TYPE_NOM, '普通'),
|
(STEP_TYPE_NOM, '常规'),
|
||||||
(STEP_TYPE_DIV, '分割'),
|
(STEP_TYPE_DIV, '分割'),
|
||||||
(STEP_TYPE_COMB, '结合')
|
(STEP_TYPE_COMB, '结合')
|
||||||
)
|
)
|
||||||
|
@ -199,7 +199,7 @@ class SubprodctionMaterial(CommonADModel):
|
||||||
material = models.ForeignKey(Material, verbose_name='物料', on_delete=models.CASCADE, related_name='subplan_material')
|
material = models.ForeignKey(Material, verbose_name='物料', on_delete=models.CASCADE, related_name='subplan_material')
|
||||||
is_main = models.BooleanField('是否主产出', default=False) # 以该产品完成度计算进度
|
is_main = models.BooleanField('是否主产出', default=False) # 以该产品完成度计算进度
|
||||||
count = models.FloatField('消耗量/产出量', default=0)
|
count = models.FloatField('消耗量/产出量', default=0)
|
||||||
subproduction = models.ForeignKey(SubProduction, verbose_name='关联生产分解', on_delete=models.CASCADE)
|
subproduction = models.ForeignKey(SubProduction, verbose_name='关联生产分解', on_delete=models.CASCADE, related_name='subm_subprod')
|
||||||
type = models.IntegerField('物料应用类型', default=1)
|
type = models.IntegerField('物料应用类型', default=1)
|
||||||
sort = models.IntegerField('排序号', default=1)
|
sort = models.IntegerField('排序号', default=1)
|
||||||
|
|
||||||
|
@ -223,8 +223,9 @@ class TechDoc(CommonADModel):
|
||||||
"""
|
"""
|
||||||
name = models.CharField('名称', max_length=50)
|
name = models.CharField('名称', max_length=50)
|
||||||
file = models.ForeignKey(File, verbose_name='技术文件', on_delete=models.CASCADE)
|
file = models.ForeignKey(File, verbose_name='技术文件', on_delete=models.CASCADE)
|
||||||
subproduction = models.ForeignKey(SubProduction, verbose_name='关联生产分解', on_delete=models.CASCADE)
|
subproduction = models.ForeignKey(SubProduction, verbose_name='关联生产分解', on_delete=models.CASCADE, related_name='tech_subprod')
|
||||||
content = models.TextField('内容', null=True, blank=True)
|
content = models.TextField('内容', null=True, blank=True)
|
||||||
|
enabled = models.BooleanField('是否启用', default=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = '技术文件'
|
verbose_name = '技术文件'
|
||||||
|
|
|
@ -241,9 +241,9 @@ class TechDocListSerializer(serializers.ModelSerializer):
|
||||||
class TechDocCreateSerializer(serializers.ModelSerializer):
|
class TechDocCreateSerializer(serializers.ModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = TechDoc
|
model = TechDoc
|
||||||
fields = ['file', 'subproduction', 'name', 'content']
|
fields = ['file', 'subproduction', 'name', 'content', 'enabled']
|
||||||
|
|
||||||
class TechDocUpdateSerializer(serializers.ModelSerializer):
|
class TechDocUpdateSerializer(serializers.ModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = TechDoc
|
model = TechDoc
|
||||||
fields = ['file', 'name', 'content']
|
fields = ['file', 'name', 'content', 'enabled']
|
||||||
|
|
|
@ -153,7 +153,8 @@ class RecordFormViewSet(OptimizationMixin, CreateUpdateModelAMixin, ModelViewSet
|
||||||
queryset = RecordForm.objects.all()
|
queryset = RecordForm.objects.all()
|
||||||
filterset_fields = ['step', 'type', 'material']
|
filterset_fields = ['step', 'type', 'material']
|
||||||
search_fields = ['name']
|
search_fields = ['name']
|
||||||
ordering='id'
|
ordering='sort'
|
||||||
|
ordering_fields = ['sort', 'id']
|
||||||
|
|
||||||
def get_serializer_class(self):
|
def get_serializer_class(self):
|
||||||
if self.action =='create':
|
if self.action =='create':
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
# Generated by Django 3.2.6 on 2021-11-17 08:37
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('mtm', '0035_auto_20211117_1637'),
|
||||||
|
('pm', '0012_alter_subproductionprogress_type'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='subproductionplan',
|
||||||
|
name='subproduction',
|
||||||
|
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='subplan_subprod', to='mtm.subproduction', verbose_name='关联生产分解'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -40,7 +40,7 @@ class SubProductionPlan(CommonAModel):
|
||||||
(4, '已完成')
|
(4, '已完成')
|
||||||
)
|
)
|
||||||
production_plan = models.ForeignKey(ProductionPlan, verbose_name='关联主生产计划', on_delete=models.CASCADE)
|
production_plan = models.ForeignKey(ProductionPlan, verbose_name='关联主生产计划', on_delete=models.CASCADE)
|
||||||
subproduction = models.ForeignKey(SubProduction, verbose_name='关联生产分解', on_delete=models.CASCADE)
|
subproduction = models.ForeignKey(SubProduction, verbose_name='关联生产分解', on_delete=models.CASCADE, related_name='subplan_subprod')
|
||||||
start_date = models.DateField('计划开工日期')
|
start_date = models.DateField('计划开工日期')
|
||||||
end_date = models.DateField('计划完工日期')
|
end_date = models.DateField('计划完工日期')
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from datetime import timezone
|
from datetime import timezone
|
||||||
|
from django.db import transaction
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
from rest_framework.views import APIView
|
from rest_framework.views import APIView
|
||||||
from apps.em.models import Equipment
|
from apps.em.models import Equipment
|
||||||
|
@ -49,7 +50,8 @@ class ProductionPlanViewSet(CreateUpdateModelAMixin, ListModelMixin, CreateModel
|
||||||
elif self.action == 'list':
|
elif self.action == 'list':
|
||||||
return ProductionPlanSerializer
|
return ProductionPlanSerializer
|
||||||
return super().get_serializer_class()
|
return super().get_serializer_class()
|
||||||
|
|
||||||
|
@transaction.atomic()
|
||||||
def create(self, request, *args, **kwargs):
|
def create(self, request, *args, **kwargs):
|
||||||
data = request.data
|
data = request.data
|
||||||
serializer = self.get_serializer(data=data)
|
serializer = self.get_serializer(data=data)
|
||||||
|
|
|
@ -7,8 +7,8 @@ from rest_framework.views import APIView
|
||||||
from rest_framework.viewsets import GenericViewSet, ModelViewSet
|
from rest_framework.viewsets import GenericViewSet, ModelViewSet
|
||||||
from apps.inm.models import FIFO, FIFOItem, FIFOItemProduct, IProduct, WareHouse
|
from apps.inm.models import FIFO, FIFOItem, FIFOItemProduct, IProduct, WareHouse
|
||||||
from apps.inm.signals import update_inm
|
from apps.inm.signals import update_inm
|
||||||
from apps.mtm.models import Material, RecordForm, Step, SubprodctionMaterial
|
from apps.mtm.models import Material, RecordForm, Step, SubprodctionMaterial, TechDoc
|
||||||
from apps.mtm.serializers import RecordFormDetailSerializer
|
from apps.mtm.serializers import RecordFormDetailSerializer, SubprodctionMaterialListSerializer, TechDocListSerializer
|
||||||
from apps.pm.models import SubProductionPlan, SubProductionProgress
|
from apps.pm.models import SubProductionPlan, SubProductionProgress
|
||||||
from apps.pm.serializers import SubProductionPlanListSerializer, SubProductionPlanUpdateSerializer
|
from apps.pm.serializers import SubProductionPlanListSerializer, SubProductionPlanUpdateSerializer
|
||||||
from apps.qm.models import TestRecordItem
|
from apps.qm.models import TestRecordItem
|
||||||
|
@ -319,6 +319,15 @@ class DoFormInit(CreateAPIView, GenericAPIView):
|
||||||
ret['forms'] = []
|
ret['forms'] = []
|
||||||
ret_0['id'] = 0
|
ret_0['id'] = 0
|
||||||
ret_0['name'] = '基本信息'
|
ret_0['name'] = '基本信息'
|
||||||
|
# 查询工具工装
|
||||||
|
ret_0['tools'] = SubprodctionMaterialListSerializer(instance=
|
||||||
|
SubprodctionMaterial.objects.filter(type=SubprodctionMaterial.SUB_MA_TYPE_TOOL,
|
||||||
|
subproduction__subplan_subprod__in = splans), many=True).data
|
||||||
|
# 查询技术文档
|
||||||
|
ret_0['techdocs'] = TechDocListSerializer(instance =
|
||||||
|
TechDoc.objects.filter(subproduction__subplan_subprod__in = splans, enabled=True)\
|
||||||
|
.distinct(), many=True).data
|
||||||
|
|
||||||
ret['forms'].append(ret_0)
|
ret['forms'].append(ret_0)
|
||||||
forms = RecordForm.objects.filter(step=vdata['step'], type=RecordForm.RF_TYPE_DO)
|
forms = RecordForm.objects.filter(step=vdata['step'], type=RecordForm.RF_TYPE_DO)
|
||||||
if forms.exists():
|
if forms.exists():
|
||||||
|
|
Loading…
Reference in New Issue