pm相关表增加count_notok字段, update_wproduct_log
This commit is contained in:
parent
0b989f79b1
commit
8563a0c7f9
|
@ -1,7 +1,5 @@
|
||||||
from django.apps import AppConfig
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
class DevelopConfig(AppConfig):
|
class DevelopConfig(AppConfig):
|
||||||
name = 'apps.develop'
|
name = 'apps.develop'
|
||||||
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,10 @@
|
||||||
|
from django.db.models import base
|
||||||
|
from rest_framework import urlpatterns
|
||||||
|
from django.urls import path, include
|
||||||
|
from rest_framework.routers import DefaultRouter
|
||||||
|
from apps.develop.views import CleanDataView
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
path('cleandata/', CleanDataView.as_view()),
|
||||||
|
]
|
||||||
|
|
|
@ -1,12 +1,20 @@
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from rest_framework.exceptions import APIException
|
|
||||||
from rest_framework.views import APIView
|
from rest_framework.views import APIView
|
||||||
from rest_framework.viewsets import ModelViewSet
|
from rest_framework.permissions import IsAdminUser
|
||||||
|
|
||||||
from rest_framework import serializers, status
|
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
|
from apps.inm.models import FIFO
|
||||||
|
from apps.mtm.models import Material
|
||||||
|
from apps.sam.models import Order
|
||||||
|
# Create your views here.
|
||||||
|
|
||||||
|
class CleanDataView(APIView):
|
||||||
|
permission_classes = [IsAdminUser]
|
||||||
|
|
||||||
|
def post(self, request, format=None):
|
||||||
class CleanData(APIView):
|
"""
|
||||||
pass
|
清空数据库
|
||||||
|
"""
|
||||||
|
Order.objects.delete()
|
||||||
|
FIFO.objects.delete()
|
||||||
|
Material.objects.filter(type__in=[Material.MA_TYPE_GOOD, Material.MA_TYPE_HALFGOOD]).delete()
|
||||||
|
return Response()
|
|
@ -0,0 +1,48 @@
|
||||||
|
# Generated by Django 3.2.9 on 2021-12-29 01:12
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('pm', '0019_alter_productionplan_process_json'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='productionplan',
|
||||||
|
name='count_notok',
|
||||||
|
field=models.PositiveIntegerField(default=0, verbose_name='不合格数量'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='subproductionplan',
|
||||||
|
name='main_count_notok',
|
||||||
|
field=models.PositiveIntegerField(default=0, verbose_name='不合格数量'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='subproductionprogress',
|
||||||
|
name='count_notok',
|
||||||
|
field=models.PositiveIntegerField(default=0, verbose_name='不合格数量'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='subproductionprogress',
|
||||||
|
name='count',
|
||||||
|
field=models.PositiveIntegerField(verbose_name='应出入数'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='subproductionprogress',
|
||||||
|
name='count_ok',
|
||||||
|
field=models.PositiveIntegerField(default=0, verbose_name='合格数量'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='subproductionprogress',
|
||||||
|
name='count_pick',
|
||||||
|
field=models.PositiveIntegerField(default=0, verbose_name='实际领用数'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='subproductionprogress',
|
||||||
|
name='count_real',
|
||||||
|
field=models.PositiveIntegerField(default=0, verbose_name='实际消耗/产出数'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -27,6 +27,7 @@ class ProductionPlan(CommonAModel):
|
||||||
count = models.PositiveIntegerField('生产数量', default=1)
|
count = models.PositiveIntegerField('生产数量', default=1)
|
||||||
count_real = models.PositiveIntegerField('实际产出数', default=0)
|
count_real = models.PositiveIntegerField('实际产出数', default=0)
|
||||||
count_ok = models.PositiveIntegerField('合格数', default=0)
|
count_ok = models.PositiveIntegerField('合格数', default=0)
|
||||||
|
count_notok = models.PositiveIntegerField('不合格数量', default=0)
|
||||||
start_date = models.DateField('计划开工日期')
|
start_date = models.DateField('计划开工日期')
|
||||||
end_date = models.DateField('计划完工日期')
|
end_date = models.DateField('计划完工日期')
|
||||||
process_json = models.JSONField('按工序的统计数', default=dict, null=True, blank=True)
|
process_json = models.JSONField('按工序的统计数', default=dict, null=True, blank=True)
|
||||||
|
@ -67,6 +68,7 @@ class SubProductionPlan(CommonAModel):
|
||||||
main_count = models.PositiveIntegerField('应产出数', default=0)
|
main_count = models.PositiveIntegerField('应产出数', default=0)
|
||||||
main_count_real = models.PositiveIntegerField('实际产出数', default=0)
|
main_count_real = models.PositiveIntegerField('实际产出数', default=0)
|
||||||
main_count_ok = models.PositiveIntegerField('合格数', default=0)
|
main_count_ok = models.PositiveIntegerField('合格数', default=0)
|
||||||
|
main_count_notok = models.PositiveIntegerField('不合格数量', default=0)
|
||||||
|
|
||||||
steps = models.JSONField('工艺步骤', default=list)
|
steps = models.JSONField('工艺步骤', default=list)
|
||||||
|
|
||||||
|
@ -88,7 +90,8 @@ class SubProductionProgress(BaseModel):
|
||||||
material = models.ForeignKey(Material, verbose_name='关联物料', on_delete=models.CASCADE)
|
material = models.ForeignKey(Material, verbose_name='关联物料', on_delete=models.CASCADE)
|
||||||
is_main = models.BooleanField('是否主产出', default=False)
|
is_main = models.BooleanField('是否主产出', default=False)
|
||||||
type = models.IntegerField('物料应用类型', default=SubprodctionMaterial.type_choices)
|
type = models.IntegerField('物料应用类型', default=SubprodctionMaterial.type_choices)
|
||||||
count = models.IntegerField('应出入数')
|
count = models.PositiveIntegerField('应出入数')
|
||||||
count_pick = models.IntegerField('实际领用数', default=0)
|
count_pick = models.PositiveIntegerField('实际领用数', default=0)
|
||||||
count_real = models.IntegerField('实际消耗/产出数', default=0)
|
count_real = models.PositiveIntegerField('实际消耗/产出数', default=0)
|
||||||
count_ok = models.IntegerField('合格数量', default=0)
|
count_ok = models.PositiveIntegerField('合格数量', default=0)
|
||||||
|
count_notok = models.PositiveIntegerField('不合格数量', default=0)
|
||||||
|
|
|
@ -17,6 +17,7 @@ def update_subplan_main(sender, instance, created, **kwargs):
|
||||||
|
|
||||||
subplan.main_count_real = instance.count_real
|
subplan.main_count_real = instance.count_real
|
||||||
subplan.main_count_ok = instance.count_ok
|
subplan.main_count_ok = instance.count_ok
|
||||||
|
subplan.main_count_notok = instance.count_notok
|
||||||
if instance.count_ok >= instance.count and instance.count_ok > 0:
|
if instance.count_ok >= instance.count and instance.count_ok > 0:
|
||||||
subplan.state = SubProductionPlan.SUBPLAN_STATE_DONE
|
subplan.state = SubProductionPlan.SUBPLAN_STATE_DONE
|
||||||
elif instance.count_ok < instance.count and instance.count_ok > 0:
|
elif instance.count_ok < instance.count and instance.count_ok > 0:
|
||||||
|
@ -27,6 +28,7 @@ def update_subplan_main(sender, instance, created, **kwargs):
|
||||||
plan = subplan.production_plan
|
plan = subplan.production_plan
|
||||||
plan.count_real = subplan.main_count_real
|
plan.count_real = subplan.main_count_real
|
||||||
plan.count_ok = subplan.main_count_ok
|
plan.count_ok = subplan.main_count_ok
|
||||||
|
plan.count_notok = subplan.main_count_notok
|
||||||
plan.save()
|
plan.save()
|
||||||
# 更新计划工序统计字段
|
# 更新计划工序统计字段
|
||||||
PmService.update_plan_process_json(subplan.production_plan)
|
PmService.update_plan_process_json(subplan.production_plan)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from django.utils import timezone
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from django.db.models.expressions import F
|
from django.db.models.expressions import F
|
||||||
|
@ -67,6 +68,7 @@ class WpmServies(object):
|
||||||
wproduct.act_state = WProduct.WPR_ACT_STATE_NOTOK
|
wproduct.act_state = WProduct.WPR_ACT_STATE_NOTOK
|
||||||
# 需要走不合格品审理的工单
|
# 需要走不合格品审理的工单
|
||||||
wproduct.update_by = user
|
wproduct.update_by = user
|
||||||
|
wproduct.update_time = timezone.now()
|
||||||
wproduct.test = None
|
wproduct.test = None
|
||||||
wproduct.save()
|
wproduct.save()
|
||||||
|
|
||||||
|
@ -78,10 +80,13 @@ class WpmServies(object):
|
||||||
objs = WproductFlow.objects.filter(subproduction_plan=sp, is_lastlog=True)
|
objs = WproductFlow.objects.filter(subproduction_plan=sp, is_lastlog=True)
|
||||||
count_ok = objs.filter(act_state__in=[WProduct.WPR_ACT_STATE_INM,
|
count_ok = objs.filter(act_state__in=[WProduct.WPR_ACT_STATE_INM,
|
||||||
WProduct.WPR_ACT_STATE_OK, WProduct.WPR_ACT_STATE_SELLED]).count()
|
WProduct.WPR_ACT_STATE_OK, WProduct.WPR_ACT_STATE_SELLED]).count()
|
||||||
|
count_notok = objs.filter(act_state__in=[WProduct.WPR_ACT_STATE_NOTOK, WProduct.WPR_ACT_STATE_SCRAP]).count()
|
||||||
count_real = objs.exclude(act_state__in=[WProduct.WPR_ACT_STATE_TORETEST,
|
count_real = objs.exclude(act_state__in=[WProduct.WPR_ACT_STATE_TORETEST,
|
||||||
WProduct.WPR_ACT_STATE_DOWAIT, WProduct.WPR_ACT_STATE_DOING])
|
WProduct.WPR_ACT_STATE_DOWAIT, WProduct.WPR_ACT_STATE_DOING]).count()
|
||||||
ins = SubProductionProgress.objects.get(subproduction_plan=sp,
|
ins = SubProductionProgress.objects.filter(subproduction_plan=sp,
|
||||||
is_main=True, type=SubprodctionMaterial.SUB_MA_TYPE_OUT)
|
is_main=True, type=SubprodctionMaterial.SUB_MA_TYPE_OUT).first()
|
||||||
|
if ins:
|
||||||
ins.count_ok = count_ok
|
ins.count_ok = count_ok
|
||||||
|
ins.count_notok = count_notok
|
||||||
ins.count_real = count_real
|
ins.count_real = count_real
|
||||||
ins.save()
|
ins.save()
|
|
@ -88,6 +88,7 @@ def update_wproduct_log(sender, instance, created, **kwargs):
|
||||||
"""
|
"""
|
||||||
更新产品变动日志
|
更新产品变动日志
|
||||||
"""
|
"""
|
||||||
|
# update_fields = kwargs['update_fields']
|
||||||
WproductFlow.objects.filter(wproduct=instance, subproduction_plan=instance.subproduction_plan).update(is_lastlog=False)
|
WproductFlow.objects.filter(wproduct=instance, subproduction_plan=instance.subproduction_plan).update(is_lastlog=False)
|
||||||
ins = WproductFlow()
|
ins = WproductFlow()
|
||||||
ins.wproduct = instance
|
ins.wproduct = instance
|
||||||
|
|
|
@ -233,6 +233,8 @@ class WProductViewSet(ListModelMixin, GenericViewSet):
|
||||||
savedict['type'] = TestRecord.TEST_COMB
|
savedict['type'] = TestRecord.TEST_COMB
|
||||||
tr = TestRecord.objects.create(**savedict)
|
tr = TestRecord.objects.create(**savedict)
|
||||||
wproduct.test = tr
|
wproduct.test = tr
|
||||||
|
wproduct.update_by = request.user
|
||||||
|
wproduct.update_time = timezone.now()
|
||||||
wproduct.save()
|
wproduct.save()
|
||||||
# 创建检验条目
|
# 创建检验条目
|
||||||
for i in RecordFormField.objects.filter(form=form, is_deleted=False):
|
for i in RecordFormField.objects.filter(form=form, is_deleted=False):
|
||||||
|
@ -366,6 +368,7 @@ class WProductViewSet(ListModelMixin, GenericViewSet):
|
||||||
raise exceptions.APIException('该产品不可报废')
|
raise exceptions.APIException('该产品不可报废')
|
||||||
obj.act_state = WProduct.WPR_ACT_STATE_SCRAP
|
obj.act_state = WProduct.WPR_ACT_STATE_SCRAP
|
||||||
obj.update_by = request.user
|
obj.update_by = request.user
|
||||||
|
obj.update_time = timezone.now()
|
||||||
obj.save()
|
obj.save()
|
||||||
return Response()
|
return Response()
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,8 @@ INSTALLED_APPS = [
|
||||||
'apps.qm',
|
'apps.qm',
|
||||||
'apps.pm',
|
'apps.pm',
|
||||||
'apps.wpm',
|
'apps.wpm',
|
||||||
'apps.srm'
|
'apps.srm',
|
||||||
|
'apps.develop'
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
|
|
|
@ -70,6 +70,7 @@ urlpatterns = [
|
||||||
path('api/pm/', include('apps.pm.urls')),
|
path('api/pm/', include('apps.pm.urls')),
|
||||||
path('api/wpm/', include('apps.wpm.urls')),
|
path('api/wpm/', include('apps.wpm.urls')),
|
||||||
path('api/srm/', include('apps.srm.urls')),
|
path('api/srm/', include('apps.srm.urls')),
|
||||||
|
path('api/develop/', include('apps.develop.urls')),
|
||||||
# 工具
|
# 工具
|
||||||
path('api/utils/signature/', GenSignature.as_view()),
|
path('api/utils/signature/', GenSignature.as_view()),
|
||||||
path('api/utils/develop/', UpdateDevelop.as_view()),
|
path('api/utils/develop/', UpdateDevelop.as_view()),
|
||||||
|
|
Loading…
Reference in New Issue