下料清单接口
This commit is contained in:
parent
7861b5419e
commit
a1c86557f0
|
@ -0,0 +1,57 @@
|
|||
# Generated by Django 3.2.9 on 2021-12-31 03:30
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('mtm', '0042_alter_recordformfield_field_type'),
|
||||
('wpm', '0042_wprouctticket_resp_process'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='operationmaterial',
|
||||
name='count_cut',
|
||||
field=models.PositiveIntegerField(default=0, verbose_name='切裁片数'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='operationmaterial',
|
||||
name='count_hua',
|
||||
field=models.PositiveIntegerField(default=0, verbose_name='划伤甩片'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='operationmaterial',
|
||||
name='count_ok',
|
||||
field=models.PositiveIntegerField(default=0, verbose_name='成品数量'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='operationmaterial',
|
||||
name='count_other',
|
||||
field=models.PositiveIntegerField(default=0, verbose_name='其他甩片'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='operationmaterial',
|
||||
name='count_podian',
|
||||
field=models.PositiveIntegerField(default=0, verbose_name='破点甩片'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='operationmaterial',
|
||||
name='count_qipao',
|
||||
field=models.PositiveIntegerField(default=0, verbose_name='气泡甩片'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='operationmaterial',
|
||||
name='count_real',
|
||||
field=models.PositiveIntegerField(default=0, verbose_name='生产片数'),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='operationmaterial',
|
||||
unique_together={('operation', 'material', 'batch')},
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='operationwproduct',
|
||||
unique_together={('operation', 'wproduct')},
|
||||
),
|
||||
]
|
|
@ -13,6 +13,7 @@ from django.utils.translation import gettext_lazy as _
|
|||
from apps.pm.serializers import SubproductionPlanSimpleSerializer
|
||||
from apps.qm.models import TestRecord, TestRecordItem
|
||||
from apps.sam.serializers import OrderSimpleSerializer
|
||||
from apps.system.models import User
|
||||
from apps.system.serializers import UserSimpleSerializer
|
||||
from apps.wpm.models import Operation, OperationEquip, OperationMaterial, OperationWproduct, Pick, WMaterial, WProduct, OperationRecord, OperationRecordItem, WprouctTicket
|
||||
from django.db import transaction
|
||||
|
@ -444,4 +445,11 @@ class WproductTicketListSerializer(serializers.ModelSerializer):
|
|||
class Meta:
|
||||
model = WprouctTicket
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class CuttingListSerializer(serializers.ModelSerializer):
|
||||
subproduction_plan_ = SubproductionPlanSimpleSerializer(source='subproduction_plan', read_only=True)
|
||||
material_ = MaterialSimpleSerializer(source='material', read_only=True)
|
||||
create_by_ = UserSimpleSerializer(source='create_by', read_only=True)
|
||||
class Meta:
|
||||
model = OperationMaterial
|
||||
fields = '__all__'
|
|
@ -148,9 +148,36 @@ class WpmServies(object):
|
|||
ins.save()
|
||||
|
||||
@classmethod
|
||||
def update_cutting_list(cls, op:Operation):
|
||||
def update_cutting_list_with_operation(cls, op:Operation):
|
||||
"""
|
||||
更新下料清单
|
||||
根据车间操作更新下料清单
|
||||
"""
|
||||
inputs = OperationMaterial.objects.filter(operation=op, type=SubprodctionMaterial.SUB_MA_TYPE_IN)
|
||||
outputs = OperationMaterial.objects.filter(operation=op, type=SubprodctionMaterial.SUB_MA_TYPE_OUT)
|
||||
for i in inputs:
|
||||
sp = i.subproduction_plan
|
||||
i.count_cut = outputs.filter(subproduction_plan=sp).first().count
|
||||
i.count_real = sp.count_real
|
||||
i.count_ok = sp.count_ok
|
||||
wpfs = WproductFlow.objects.filter(subproduction_plan=sp, is_lastlog=True)
|
||||
i.count_qipao = wpfs.filter(scrap_reason=WProduct.SCRAP_REASON_QIPAO).count()
|
||||
i.count_podian = wpfs.filter(scrap_reason=WProduct.SCRAP_REASON_PODIAN).count()
|
||||
i.count_hua = wpfs.filter(scrap_reason=WProduct.SCRAP_REASON_HUA).count()
|
||||
i.count_other = wpfs.filter(scrap_reason=WProduct.SCRAP_REASON_OTHER).count()
|
||||
i.is_cutting = True
|
||||
i.save()
|
||||
|
||||
@classmethod
|
||||
def update_cutting_list_with_sp(cls, sp:SubProductionPlan):
|
||||
"""
|
||||
根据子计划更新下料清单
|
||||
"""
|
||||
wpfs = WproductFlow.objects.filter(subproduction_plan=sp, is_lastlog=True)
|
||||
for i in OperationMaterial.objects.filter(subproduction_plan=sp, is_cutting=True):
|
||||
i.count_real = sp.count_real
|
||||
i.count_ok = sp.count_ok
|
||||
i.count_qipao = wpfs.filter(scrap_reason=WProduct.SCRAP_REASON_QIPAO).count()
|
||||
i.count_podian = wpfs.filter(scrap_reason=WProduct.SCRAP_REASON_PODIAN).count()
|
||||
i.count_hua = wpfs.filter(scrap_reason=WProduct.SCRAP_REASON_HUA).count()
|
||||
i.count_other = wpfs.filter(scrap_reason=WProduct.SCRAP_REASON_OTHER).count()
|
||||
i.save()
|
|
@ -3,7 +3,7 @@ from rest_framework import urlpatterns
|
|||
from django.urls import path, include
|
||||
from rest_framework.routers import DefaultRouter
|
||||
|
||||
from apps.wpm.views import DoFormInit, DoFormSubmit, OperationEquipViewSet, OperationMaterialInputViewSet, OperationMaterialOutputViewSet, OperationMaterialToolViewSet, OperationRecordViewSet, OperationViewSet, OperationWproductViewSet, WMaterialViewSet, WPlanViewSet, WProductViewSet, WproductTicketViewSet
|
||||
from apps.wpm.views import CuttingListViewSet, DoFormInit, DoFormSubmit, OperationEquipViewSet, OperationMaterialInputViewSet, OperationMaterialOutputViewSet, OperationMaterialToolViewSet, OperationRecordViewSet, OperationViewSet, OperationWproductViewSet, WMaterialViewSet, WPlanViewSet, WProductViewSet, WproductTicketViewSet
|
||||
|
||||
router = DefaultRouter()
|
||||
router.register('wmaterial', WMaterialViewSet, basename='wmaterial')
|
||||
|
@ -17,6 +17,7 @@ router.register('operation_input', OperationMaterialInputViewSet, basename='oper
|
|||
router.register('operation_output', OperationMaterialOutputViewSet, basename='operation_output')
|
||||
router.register('operation_tool', OperationMaterialToolViewSet, basename='operation_tool')
|
||||
router.register('subplan', WPlanViewSet, basename='wplan')
|
||||
router.register('cutting_list', CuttingListViewSet, basename='cutting_list')
|
||||
urlpatterns = [
|
||||
path('do/init/', DoFormInit.as_view()),
|
||||
path('do/submit/', DoFormSubmit.as_view()),
|
||||
|
|
|
@ -22,7 +22,7 @@ from apps.wf.serializers import WorkflowSimpleSerializer
|
|||
from apps.wpm.filters import WMaterialFilterSet, WProductFilterSet
|
||||
from apps.wpm.models import OperationEquip, OperationWproduct, Pick, PickWproduct, WMaterial, WProduct, Operation, OperationMaterial, OperationRecord, OperationRecordItem, WprouctTicket
|
||||
|
||||
from apps.wpm.serializers import OperationEquipListSerializer, OperationEquipUpdateSerializer, OperationMaterialCreate1ListSerailizer, OperationMaterialCreate1Serailizer, OperationMaterialCreate2ListSerailizer, OperationMaterialCreate2Serailizer, OperationMaterialCreate3Serializer, OperationMaterialListSerializer, OperationRecordDetailSerializer, OperationRecordListSerializer, OperationRecordSubmitSerializer, OperationUpdateSerializer, OperationWproductListSerializer, OperationCreateSerializer, OperationDetailSerializer, OperationListSerializer, PickHalfSerializer, PickHalfsSerializer, PickSerializer, OperationInitSerializer, OperationSubmitSerializer, ScrapSerializer, WMaterialListSerializer, WProductListSerializer, WplanPutInSerializer, WpmTestFormInitSerializer, WpmTestRecordCreateSerializer, WproductPutInSerializer, WproductPutInsSerializer, WproductTicketListSerializer
|
||||
from apps.wpm.serializers import CuttingListSerializer, OperationEquipListSerializer, OperationEquipUpdateSerializer, OperationMaterialCreate1ListSerailizer, OperationMaterialCreate1Serailizer, OperationMaterialCreate2ListSerailizer, OperationMaterialCreate2Serailizer, OperationMaterialCreate3Serializer, OperationMaterialListSerializer, OperationRecordDetailSerializer, OperationRecordListSerializer, OperationRecordSubmitSerializer, OperationUpdateSerializer, OperationWproductListSerializer, OperationCreateSerializer, OperationDetailSerializer, OperationListSerializer, PickHalfSerializer, PickHalfsSerializer, PickSerializer, OperationInitSerializer, OperationSubmitSerializer, ScrapSerializer, WMaterialListSerializer, WProductListSerializer, WplanPutInSerializer, WpmTestFormInitSerializer, WpmTestRecordCreateSerializer, WproductPutInSerializer, WproductPutInsSerializer, WproductTicketListSerializer
|
||||
from rest_framework.response import Response
|
||||
from django.db import transaction
|
||||
from rest_framework import exceptions, serializers
|
||||
|
@ -385,6 +385,8 @@ class WProductViewSet(ListModelMixin, GenericViewSet):
|
|||
obj.update_time = timezone.now()
|
||||
obj.save()
|
||||
WpmServies.add_wproduct_flow_log(obj, 'scrap')
|
||||
if obj.step.process.id == 1: #如果是冷加工
|
||||
WpmServies.update_cutting_list_with_sp(obj.subproduction_plan)
|
||||
return Response()
|
||||
|
||||
# @action(methods=['get'], detail=False, perms_map={'get':'*'})
|
||||
|
@ -649,8 +651,8 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd
|
|||
op.save()
|
||||
|
||||
# 如果是冷加工
|
||||
if step.type == Step.STEP_TYPE_DIV:
|
||||
WpmServies.update_cutting_list(op=op)
|
||||
if step.process.id==1:
|
||||
WpmServies.update_cutting_list_with_operation(op=op)
|
||||
return Response()
|
||||
|
||||
|
||||
|
@ -785,6 +787,19 @@ class OperationMaterialInputViewSet(ListModelMixin, CreateModelMixin, DestroyMod
|
|||
instance.delete()
|
||||
return Response()
|
||||
|
||||
class CuttingListViewSet(ListModelMixin, GenericViewSet):
|
||||
"""
|
||||
下料清单
|
||||
"""
|
||||
perms_map={'*':'*'}
|
||||
queryset = OperationMaterial.objects.select_related('operation',
|
||||
'subproduction_plan', 'material', 'create_by').filter(operation__step__process__id=1)
|
||||
serializer_class = CuttingListSerializer
|
||||
filterset_fields = ['operation', 'subproduction_plan', 'material']
|
||||
ordering_fields = ['id']
|
||||
ordering = ['-id']
|
||||
|
||||
|
||||
class OperationMaterialOutputViewSet(ListModelMixin, CreateModelMixin, DestroyModelMixin, GenericViewSet):
|
||||
"""
|
||||
产出物料
|
||||
|
|
Loading…
Reference in New Issue