增加子生产进度表
This commit is contained in:
parent
7b6f5008ce
commit
1d056a775f
|
|
@ -2,6 +2,6 @@
|
|||
ENV = 'production'
|
||||
|
||||
# base api
|
||||
#VUE_APP_BASE_API = 'http://47.95.0.242:2222/api'
|
||||
VUE_APP_BASE_API = 'http://127.0.0.1:8000/api'
|
||||
VUE_APP_BASE_API = 'http://47.95.0.242:2222/api'
|
||||
#VUE_APP_BASE_API = 'http://127.0.0.1:8000/api'
|
||||
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ class FaceLogin(CreateAPIView):
|
|||
unknown_face_encoding = face_recognition.face_encodings(unknown_picture)[0]
|
||||
os.remove(filepath)
|
||||
except:
|
||||
logger.error('解码失败')
|
||||
return Response('头像解码失败', status=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
# 匹配人脸库
|
||||
user_faces = Employee.objects.filter(face_data__isnull=False, user__is_active=True).values('user', 'face_data')
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 3.2.6 on 2021-10-19 01:44
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('mtm', '0023_auto_20211018_1057'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='recordformfield',
|
||||
name='rule_expression',
|
||||
field=models.JSONField(default=list, help_text='判定表达式, 格式为[{"expression":"{value} > 3 and {value}<10"}] 其中{}用于填充的字段key,运算时会换算成实际的值,符合条件返回true,表达式只支持简单的运算或datetime/time运算.以首次匹配成功的条件为准,所以多个条件不要有冲突', verbose_name='判定表达式'),
|
||||
),
|
||||
]
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
# Generated by Django 3.2.6 on 2021-10-19 01:44
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import django.utils.timezone
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('mtm', '0024_alter_recordformfield_rule_expression'),
|
||||
('pm', '0004_subproductionplan_steps'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='subproductionplan',
|
||||
name='state',
|
||||
field=models.IntegerField(default=0, verbose_name='状态'),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='SubProductionProgress',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('create_time', models.DateTimeField(default=django.utils.timezone.now, help_text='创建时间', verbose_name='创建时间')),
|
||||
('update_time', models.DateTimeField(auto_now=True, help_text='修改时间', verbose_name='修改时间')),
|
||||
('is_deleted', models.BooleanField(default=False, help_text='删除标记', verbose_name='删除标记')),
|
||||
('type', models.IntegerField(default=1, verbose_name='物料应用类型')),
|
||||
('count', models.IntegerField(verbose_name='应出入数')),
|
||||
('count_real', models.IntegerField(verbose_name='实际出入数')),
|
||||
('material', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='mtm.material', verbose_name='关联物料')),
|
||||
('subproduction_plan', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='progress_subplan', to='pm.subproductionplan', verbose_name='关联子生产计划')),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
},
|
||||
),
|
||||
]
|
||||
|
|
@ -31,6 +31,13 @@ class SubProductionPlan(CommonAModel):
|
|||
"""
|
||||
子生产计划
|
||||
"""
|
||||
state_choices=(
|
||||
(0, '制定中'),
|
||||
(1, '已下达'),
|
||||
(2, '已接收'),
|
||||
(3, '生产中'),
|
||||
(4, '已完成')
|
||||
)
|
||||
production_plan = models.ForeignKey(ProductionPlan, verbose_name='关联主生产计划', on_delete=models.CASCADE)
|
||||
subproduction = models.ForeignKey(SubProduction, verbose_name='关联生产分解', on_delete=models.CASCADE)
|
||||
start_date = models.DateField('计划开工日期')
|
||||
|
|
@ -38,13 +45,21 @@ class SubProductionPlan(CommonAModel):
|
|||
workshop = models.ForeignKey(Organization, verbose_name='生产车间', on_delete=models.CASCADE)
|
||||
process = models.ForeignKey(Process, verbose_name='关联大工序', on_delete=models.CASCADE)
|
||||
steps = models.JSONField('工艺步骤', default=list)
|
||||
state = models.IntegerField('状态', default=0)
|
||||
class Meta:
|
||||
verbose_name = '子生产计划'
|
||||
verbose_name_plural = verbose_name
|
||||
|
||||
# class ProductionProgress(BaseModel):
|
||||
# """
|
||||
# 子计划生产进度
|
||||
# """
|
||||
# subproduction_plan = models.ForeignKey(SubProductionPlan, verbose_name='关联子生产计划', on_delete=models.CASCADE)
|
||||
# material = models.
|
||||
class SubProductionProgress(BaseModel):
|
||||
"""
|
||||
子计划生产进度统计表
|
||||
"""
|
||||
type_choices=(
|
||||
(1, '输入物料'),
|
||||
(2, '输出物料')
|
||||
)
|
||||
subproduction_plan = models.ForeignKey(SubProductionPlan, verbose_name='关联子生产计划', on_delete=models.CASCADE, related_name='progress_subplan')
|
||||
material = models.ForeignKey(Material, verbose_name='关联物料', on_delete=models.CASCADE)
|
||||
type = models.IntegerField('物料应用类型', default=1)
|
||||
count = models.IntegerField('应出入数')
|
||||
count_real = models.IntegerField('实际出入数')
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
from apps.pm.models import ProductionPlan, SubProductionPlan
|
||||
from apps.pm.models import ProductionPlan, SubProductionPlan, SubProductionProgress
|
||||
from rest_framework import serializers
|
||||
from apps.sam.serializers import OrderSerializer
|
||||
from apps.mtm.serializers import MaterialSimpleSerializer, ProcessSimpleSerializer
|
||||
|
|
@ -38,3 +38,8 @@ class SubProductionPlanUpdateSerializer(serializers.ModelSerializer):
|
|||
|
||||
class GenSubPlanSerializer(serializers.Serializer):
|
||||
pass
|
||||
|
||||
class SubProductionProgressSerializer(serializers.ModelSerializer):
|
||||
material_ = MaterialSimpleSerializer(source='material', read_only=True)
|
||||
class Meta:
|
||||
model = SubProductionProgress
|
||||
|
|
@ -2,11 +2,11 @@ from rest_framework import serializers
|
|||
from rest_framework.views import APIView
|
||||
from apps.em.models import Equipment
|
||||
from apps.em.serializers import EquipmentSerializer
|
||||
from apps.mtm.models import InputMaterial, Step, SubProduction, UsedStep
|
||||
from apps.mtm.models import InputMaterial, OutputMaterial, Step, SubProduction, UsedStep
|
||||
from apps.system.mixins import CreateUpdateModelAMixin
|
||||
from apps.pm.serializers import GenSubPlanSerializer, ProductionPlanCreateFromOrderSerializer, ProductionPlanSerializer, ResourceCalListSerializer, ResourceCalSerializer, SubProductionPlanListSerializer, SubProductionPlanUpdateSerializer
|
||||
from apps.pm.serializers import GenSubPlanSerializer, ProductionPlanCreateFromOrderSerializer, ProductionPlanSerializer, ResourceCalListSerializer, ResourceCalSerializer, SubProductionPlanListSerializer, SubProductionPlanUpdateSerializer, SubProductionProgressSerializer
|
||||
from rest_framework.mixins import CreateModelMixin, ListModelMixin, UpdateModelMixin
|
||||
from apps.pm.models import ProductionPlan, SubProductionPlan
|
||||
from apps.pm.models import ProductionPlan, SubProductionProgress, SubProductionPlan
|
||||
from rest_framework.viewsets import GenericViewSet, ModelViewSet
|
||||
from django.shortcuts import render
|
||||
from apps.sam.models import Order
|
||||
|
|
@ -72,10 +72,14 @@ class ProductionPlanViewSet(CreateUpdateModelAMixin, ListModelMixin, CreateModel
|
|||
for i in subps:
|
||||
steps = Step.objects.filter(usedstep__subproduction=i, usedstep__subproduction__is_deleted=False,
|
||||
usedstep__is_deleted=False, is_deleted=False).values('id', 'number', 'name', 'usedstep__remark')
|
||||
SubProductionPlan.objects.create(production_plan=production_plan, subproduction=i,
|
||||
instance = SubProductionPlan.objects.create(production_plan=production_plan, subproduction=i,
|
||||
start_date=production_plan.start_date, end_date=production_plan.end_date,
|
||||
workshop=i.process.workshop, process=i.process, create_by=request.user,
|
||||
steps = list(steps))
|
||||
for m in InputMaterial.objects.filter(subproduction=i, is_delete=False).order_by('sort'):
|
||||
SubProductionProgress.objects.create(material=m.material, type=1, count=m.count, subproduction_plan=instance)
|
||||
for m in OutputMaterial.objects.filter(subproduction=i, is_delete=False).order_by('sort'):
|
||||
SubProductionProgress.objects.create(material=m.material, type=2, count=m.count, subproduction_plan=instance)
|
||||
production_plan.is_planed=True
|
||||
production_plan.save()
|
||||
return Response()
|
||||
|
|
@ -98,6 +102,11 @@ class SubProductionPlanViewSet(CreateUpdateModelAMixin, ListModelMixin, UpdateMo
|
|||
return SubProductionPlanUpdateSerializer
|
||||
return SubProductionPlanListSerializer
|
||||
|
||||
@action(methods=['get'], detail=True, perms_map={'get':'*'}, serializer_class=SubProductionProgressSerializer)
|
||||
def progress(self, request, pk=None):
|
||||
obj = self.get_object()
|
||||
serializer = SubProductionProgressSerializer(instance=obj.progress_subplan, many=True)
|
||||
return Response(serializer.data)
|
||||
|
||||
class ResourceViewSet(GenericViewSet):
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue