From 59339a31fafd848ce1fe7516f7a7392837eb3c71 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Thu, 17 Feb 2022 15:24:47 +0800 Subject: [PATCH 01/11] =?UTF-8?q?=E8=AE=A1=E5=88=92=E6=9A=82=E5=81=9C?= =?UTF-8?q?=E5=92=8C=E7=BB=88=E6=AD=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb_server/apps/mtm/serializers.py | 13 ++++++ .../pm/migrations/0024_auto_20220217_1524.py | 23 +++++++++++ hb_server/apps/pm/models.py | 27 ++++++++----- hb_server/apps/pm/views.py | 40 ++++++++++++++++++- hb_server/utils/response.py | 3 +- 5 files changed, 92 insertions(+), 14 deletions(-) create mode 100644 hb_server/apps/pm/migrations/0024_auto_20220217_1524.py diff --git a/hb_server/apps/mtm/serializers.py b/hb_server/apps/mtm/serializers.py index 2746e0f..7bc9c2e 100644 --- a/hb_server/apps/mtm/serializers.py +++ b/hb_server/apps/mtm/serializers.py @@ -190,11 +190,24 @@ class RecordFormCreateSerializer(serializers.ModelSerializer): model = RecordForm fields = ['name', 'type', 'step', 'material', 'number', 'enabled'] + # def validate(self, attrs): + # if attrs['enabled']: + # if RecordForm.objects.filter(type=attrs['type'], + # enabled=True).exists(): + # raise ValidationError('已存在启用的同类检查表') + # return super().validate(attrs) class RecordFormUpdateSerializer(serializers.ModelSerializer): class Meta: model = RecordForm fields = ['name', 'type', 'number', 'enabled'] + + # def validate(self, attrs): + # if attrs['enabled']: + # if RecordForm.objects.filter(type=attrs['type'], + # enabled=True).exists(): + # raise ValidationError('已存在启用的同类检查表') + # return super().validate(attrs) class RecordFormFieldSerializer(serializers.ModelSerializer): class Meta: diff --git a/hb_server/apps/pm/migrations/0024_auto_20220217_1524.py b/hb_server/apps/pm/migrations/0024_auto_20220217_1524.py new file mode 100644 index 0000000..dd41035 --- /dev/null +++ b/hb_server/apps/pm/migrations/0024_auto_20220217_1524.py @@ -0,0 +1,23 @@ +# Generated by Django 3.2.9 on 2022-02-17 07:24 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('pm', '0023_alter_productionplan_order'), + ] + + operations = [ + migrations.AddField( + model_name='productionplan', + name='old_state', + field=models.PositiveIntegerField(blank=True, choices=[(10, '制定中'), (20, '已下达'), (30, '已接收'), (40, '生产中'), (50, '生产完成'), (60, '军检完成'), (70, '暂停'), (80, '终止')], null=True, verbose_name='原状态'), + ), + migrations.AlterField( + model_name='productionplan', + name='state', + field=models.PositiveIntegerField(choices=[(10, '制定中'), (20, '已下达'), (30, '已接收'), (40, '生产中'), (50, '生产完成'), (60, '军检完成'), (70, '暂停'), (80, '终止')], default=10, verbose_name='状态'), + ), + ] diff --git a/hb_server/apps/pm/models.py b/hb_server/apps/pm/models.py index 2a6ea86..d15141a 100644 --- a/hb_server/apps/pm/models.py +++ b/hb_server/apps/pm/models.py @@ -20,13 +20,17 @@ class ProductionPlan(CommonAModel): PLAN_STATE_WORKING = 40 PLAN_STATE_DONE = 50 PLAN_MTEST_DONE = 60 + PLAN_STATE_PAUSE = 70 + PLAN_STATE_STOP = 80 state_choices=( (PLAN_STATE_PLANING, '制定中'), (PLAN_STATE_ASSGINED, '已下达'), (PLAN_STATE_ACCEPTED, '已接收'), (PLAN_STATE_WORKING, '生产中'), (PLAN_STATE_DONE, '生产完成'), - (PLAN_MTEST_DONE, '军检完成') + (PLAN_MTEST_DONE, '军检完成'), + (PLAN_STATE_PAUSE, '暂停'), + (PLAN_STATE_STOP, '终止') ) number = models.CharField('编号', max_length=50, unique=True) order = models.ForeignKey(Order, verbose_name='关联订单', null=True, blank=True, on_delete=models.SET_NULL, related_name='plan_order') @@ -41,6 +45,7 @@ class ProductionPlan(CommonAModel): end_date = models.DateField('计划完工日期') process_json = models.JSONField('按工序的统计数', default=dict, null=True, blank=True) is_planed = models.BooleanField('是否已排产', default=False) + old_state = models.PositiveIntegerField('原状态', choices=state_choices, null=True, blank=True) class Meta: verbose_name = '生产计划' verbose_name_plural = verbose_name @@ -62,7 +67,7 @@ class SubProductionPlan(CommonAModel): (SUBPLAN_STATE_ASSGINED, '已下达'), (SUBPLAN_STATE_ACCEPTED, '已接收'), (SUBPLAN_STATE_WORKING, '生产中'), - (SUBPLAN_STATE_DONE, '已完成') + (SUBPLAN_STATE_DONE, '已完成'), ) number = models.CharField('子计划编号', max_length=50, unique=True, null=True, blank=True) production_plan = models.ForeignKey(ProductionPlan, verbose_name='关联主生产计划', on_delete=models.CASCADE, related_name='subplan_plan') @@ -91,15 +96,15 @@ class SubProductionPlan(CommonAModel): verbose_name = '子生产计划' verbose_name_plural = verbose_name -class FirstItem(BaseModel): - """ - 首件确认表记录条目 - """ - form_field = models.ForeignKey(RecordFormField, verbose_name='关联自定义表格字段', on_delete=models.CASCADE) - field_value = models.JSONField('录入值', null=True, blank=True) - is_hidden = models.BooleanField('是否隐藏', default=False) - is_testok = models.BooleanField('是否合格', null=True, blank=True) - subproduction_plan = models.ForeignKey(SubProductionPlan, verbose_name='关联的子计划', on_delete=models.CASCADE, related_name='item_test_record') +# class FirstItem(BaseModel): +# """ +# 首件确认表记录条目 +# """ +# form_field = models.ForeignKey(RecordFormField, verbose_name='关联自定义表格字段', on_delete=models.CASCADE) +# field_value = models.JSONField('录入值', null=True, blank=True) +# is_hidden = models.BooleanField('是否隐藏', default=False) +# is_testok = models.BooleanField('是否合格', null=True, blank=True) +# subproduction_plan = models.ForeignKey(SubProductionPlan, verbose_name='关联的子计划', on_delete=models.CASCADE, related_name='item_test_record') class SubProductionProgress(BaseModel): """ diff --git a/hb_server/apps/pm/views.py b/hb_server/apps/pm/views.py index 62a7bbb..5df4d6f 100644 --- a/hb_server/apps/pm/views.py +++ b/hb_server/apps/pm/views.py @@ -16,7 +16,7 @@ from apps.pm.models import ProductionPlan, SubProductionProgress, SubProductionP from rest_framework.viewsets import GenericViewSet, ModelViewSet from django.shortcuts import render from apps.sam.models import Order -from rest_framework.exceptions import APIException +from rest_framework.exceptions import APIException, ParseError from rest_framework.response import Response from rest_framework.decorators import action from django.db.models import F @@ -86,6 +86,8 @@ class ProductionPlanViewSet(CreateUpdateModelAMixin, ListModelMixin, CreateModel production_plan=self.get_object() if production_plan.is_planed: raise APIException('已生成子计划') + if production_plan.state != ProductionPlan.PLAN_STATE_PLANING: + raise APIException('不可操作') subps = SubProduction.objects.filter(product=production_plan.product).order_by('process__number') for index, i in enumerate(subps): steps = Step.objects.filter(usedstep__subproduction=i, usedstep__subproduction__is_deleted=False, @@ -101,9 +103,42 @@ class ProductionPlanViewSet(CreateUpdateModelAMixin, ListModelMixin, CreateModel is_main=m.is_main, count=m.count*production_plan.count, subproduction_plan=instance) production_plan.is_planed=True - production_plan.state = ProductionPlan.PLAN_STATE_PLANING production_plan.save() return Response() + + @action(methods=['put'], detail=True, perms_map={'post':'plan_toggle'}, serializer_class=serializers.Serializer) + @transaction.atomic + def toggle(self, request, pk=None): + """ + 计划暂停或启动 + """ + plan = self.get_object() + if plan.state == ProductionPlan.PLAN_STATE_PAUSE: + plan.state = plan.old_state + plan.old_state = None + plan.save() + return Response() + elif plan.state <= ProductionPlan.PLAN_STATE_WORKING: + plan.old_state = plan.state + plan.state = ProductionPlan.PLAN_STATE_PAUSE + plan.save() + return Response() + raise APIException('不可操作') + + @action(methods=['put'], detail=True, perms_map={'post':'plan_stop'}, serializer_class=serializers.Serializer) + @transaction.atomic + def stop(self, request, pk=None): + """ + 计划终止 + """ + plan = self.get_object() + if plan.state == ProductionPlan.PLAN_STATE_PAUSE: + plan.state = ProductionPlan.PLAN_STATE_STOP + plan.save() + return Response() + raise APIException('不可操作') + + class SubProductionPlanViewSet(CreateUpdateModelAMixin, ListModelMixin, UpdateModelMixin, GenericViewSet): """ @@ -166,6 +201,7 @@ class SubProductionPlanViewSet(CreateUpdateModelAMixin, ListModelMixin, UpdateMo plan.save() return Response() raise APIException('计划状态有误') + @action(methods=['get'], detail=True, perms_map={'get':'*'}, serializer_class=serializers.Serializer) def pick_need_(self, request, pk=None): diff --git a/hb_server/utils/response.py b/hb_server/utils/response.py index 3814076..776757f 100644 --- a/hb_server/utils/response.py +++ b/hb_server/utils/response.py @@ -59,8 +59,9 @@ class FitJSONRenderer(JSONRenderer): if isinstance(data, dict): prefix = list(data.keys())[0] data = data[prefix] - elif isinstance(data, list): + if isinstance(data, list): data = data[0] + response_body.msg = prefix + ":" + str(data) # 取一部分放入msg,方便前端alert else: response_body.data = data From c6f30f781075dc5087bcdac8cc79c613f310363c Mon Sep 17 00:00:00 2001 From: caoqianming Date: Thu, 17 Feb 2022 15:33:38 +0800 Subject: [PATCH 02/11] =?UTF-8?q?=E8=BD=A6=E9=97=B4=E7=94=9F=E4=BA=A7?= =?UTF-8?q?=E8=AE=A1=E5=88=92=E5=A2=9E=E5=8A=A0=E8=BF=87=E6=BB=A4=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb_server/apps/wpm/views.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hb_server/apps/wpm/views.py b/hb_server/apps/wpm/views.py index 98d1a2d..def12c2 100644 --- a/hb_server/apps/wpm/views.py +++ b/hb_server/apps/wpm/views.py @@ -6,7 +6,7 @@ from apps.inm.models import FIFO, FIFOItem, FIFOItemProduct from apps.inm.services import InmService from apps.mtm.models import Material, RecordForm, RecordFormField, Step, SubprodctionMaterial, TechDoc from apps.mtm.serializers import RecordFormDetailSerializer, SubprodctionMaterialListSerializer, TechDocListSerializer -from apps.pm.models import SubProductionPlan, SubProductionProgress +from apps.pm.models import ProductionPlan, SubProductionPlan, SubProductionProgress from apps.pm.serializers import SubProductionPlanListSerializer, SubProductionProgressSerializer from apps.qm.models import TestRecord, TestRecordItem from apps.qm.serializers import TestRecordDetailSerializer @@ -49,7 +49,10 @@ class WPlanViewSet(ListModelMixin, GenericViewSet): """ perms_map = {'get': '*'} queryset = SubProductionPlan.objects.select_related( - 'process', 'workshop', 'subproduction', 'product').exclude(state=0) + 'process', 'workshop', 'subproduction', 'product')\ + .exclude(state= SubProductionPlan.SUBPLAN_STATE_PLANING, + production_plan__state__in=[ProductionPlan.PLAN_STATE_PAUSE, + ProductionPlan.PLAN_STATE_STOP]) search_fields = [] serializer_class = SubProductionPlanListSerializer filterset_fields = ['production_plan', From 985935641eb0601711f3ab06dae0d830765ef535 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Thu, 17 Feb 2022 16:53:47 +0800 Subject: [PATCH 03/11] =?UTF-8?q?=E8=BD=A6=E9=97=B4=E7=94=9F=E4=BA=A7?= =?UTF-8?q?=E8=AE=A1=E5=88=92=E8=BF=87=E6=BB=A4=E6=9D=A1=E4=BB=B6bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb_server/apps/mtm/serializers.py | 5 ++++- hb_server/apps/wpm/views.py | 16 +++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/hb_server/apps/mtm/serializers.py b/hb_server/apps/mtm/serializers.py index 7bc9c2e..ae243d9 100644 --- a/hb_server/apps/mtm/serializers.py +++ b/hb_server/apps/mtm/serializers.py @@ -186,9 +186,12 @@ class RecordFormSerializer(serializers.ModelSerializer): return queryset class RecordFormCreateSerializer(serializers.ModelSerializer): + form = serializers.PrimaryKeyRelatedField( + queryset=RecordForm.objects.all(), label="复制表ID") class Meta: model = RecordForm - fields = ['name', 'type', 'step', 'material', 'number', 'enabled'] + fields = ['name', 'type', 'step', 'material', 'number', 'enabled', 'form'] + # def validate(self, attrs): # if attrs['enabled']: diff --git a/hb_server/apps/wpm/views.py b/hb_server/apps/wpm/views.py index def12c2..04c7f9f 100644 --- a/hb_server/apps/wpm/views.py +++ b/hb_server/apps/wpm/views.py @@ -35,7 +35,7 @@ from rest_framework import exceptions, serializers from apps.wpm.services import WpmService from django.utils import timezone from rest_framework import status -from django.db.models import Count +from django.db.models import Count, Q from utils.tools import ranstr @@ -49,10 +49,11 @@ class WPlanViewSet(ListModelMixin, GenericViewSet): """ perms_map = {'get': '*'} queryset = SubProductionPlan.objects.select_related( - 'process', 'workshop', 'subproduction', 'product')\ - .exclude(state= SubProductionPlan.SUBPLAN_STATE_PLANING, - production_plan__state__in=[ProductionPlan.PLAN_STATE_PAUSE, - ProductionPlan.PLAN_STATE_STOP]) + 'process', 'workshop', 'subproduction', 'product').filter( + production_plan__state__in =[ + ProductionPlan.PLAN_STATE_WORKING, ProductionPlan.PLAN_STATE_ASSGINED + ] + ) search_fields = [] serializer_class = SubProductionPlanListSerializer filterset_fields = ['production_plan', @@ -60,6 +61,7 @@ class WPlanViewSet(ListModelMixin, GenericViewSet): ordering_fields = [] ordering = ['-update_time'] + @action(methods=['post', 'get'], detail=True, perms_map={'post': 'pick_half', 'get': '*'}, serializer_class=PickHalfsSerializer) @transaction.atomic def pick_half(self, request, pk=None): @@ -119,6 +121,10 @@ class WPlanViewSet(ListModelMixin, GenericViewSet): pw.save() sp.is_picked = True sp.save() + if sp.production_plan.state in \ + [ProductionPlan.PLAN_STATE_ASSGINED, ProductionPlan.PLAN_STATE_ACCEPTED]: + sp.production_plan.state = ProductionPlan.PLAN_STATE_WORKING + sp.production_plan.save() return Response() From 7bfe483c901eebaa844b97bcf06f90260640f7ae Mon Sep 17 00:00:00 2001 From: caoqianming Date: Thu, 17 Feb 2022 21:58:23 +0800 Subject: [PATCH 04/11] =?UTF-8?q?is=5Fatwork=E8=B0=83=E6=95=B4=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hrm/migrations/0006_auto_20220217_2155.py | 23 +++++++++++++++++++ hb_server/apps/hrm/models.py | 2 ++ hb_server/apps/hrm/serializers.py | 2 -- hb_server/apps/hrm/tasks.py | 5 ++-- hb_server/apps/hrm/views.py | 8 ++----- hb_server/apps/mtm/views.py | 18 ++++++++++++++- hb_server/apps/system/filters.py | 2 +- .../system/migrations/0004_user_is_atwork.py | 18 --------------- .../migrations/0005_user_last_check_time.py | 18 --------------- hb_server/apps/system/models.py | 2 -- hb_server/apps/system/serializers.py | 2 +- 11 files changed, 48 insertions(+), 52 deletions(-) create mode 100644 hb_server/apps/hrm/migrations/0006_auto_20220217_2155.py delete mode 100644 hb_server/apps/system/migrations/0004_user_is_atwork.py delete mode 100644 hb_server/apps/system/migrations/0005_user_last_check_time.py diff --git a/hb_server/apps/hrm/migrations/0006_auto_20220217_2155.py b/hb_server/apps/hrm/migrations/0006_auto_20220217_2155.py new file mode 100644 index 0000000..15ed478 --- /dev/null +++ b/hb_server/apps/hrm/migrations/0006_auto_20220217_2155.py @@ -0,0 +1,23 @@ +# Generated by Django 3.2.9 on 2022-02-17 13:55 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('hrm', '0005_auto_20220126_1351'), + ] + + operations = [ + migrations.AddField( + model_name='employee', + name='is_atwork', + field=models.BooleanField(default=False, verbose_name='当前在岗'), + ), + migrations.AddField( + model_name='employee', + name='last_check_time', + field=models.DateTimeField(blank=True, null=True, verbose_name='打卡时间'), + ), + ] diff --git a/hb_server/apps/hrm/models.py b/hb_server/apps/hrm/models.py index 219caea..ed3a063 100644 --- a/hb_server/apps/hrm/models.py +++ b/hb_server/apps/hrm/models.py @@ -30,6 +30,8 @@ class Employee(CommonAModel): qualification = models.CharField('学历', max_length=50, null=True, blank=True) job_state = models.IntegerField('在职状态', choices=jobstate_choices, default=1) face_data = models.JSONField('人脸识别数据', null=True, blank=True) + is_atwork = models.BooleanField('当前在岗', default=False) + last_check_time = models.DateTimeField('打卡时间', null=True, blank=True) class Meta: verbose_name = '员工补充信息' verbose_name_plural = verbose_name diff --git a/hb_server/apps/hrm/serializers.py b/hb_server/apps/hrm/serializers.py index dc1eb06..9371ff4 100644 --- a/hb_server/apps/hrm/serializers.py +++ b/hb_server/apps/hrm/serializers.py @@ -10,8 +10,6 @@ from django.db.models.query import Prefetch class EmployeeSerializer(DynamicFieldsSerializerMixin, ModelSerializer): name = serializers.CharField(source='user.name', read_only=True) dept_ = OrganizationSimpleSerializer(source='user.dept', read_only=True) - is_atwork = serializers.BooleanField(source='user.is_atwork', read_only=True) - last_check_time = serializers.DateTimeField(source='user.last_check_time', read_only=True) class Meta: model = Employee exclude = ['face_data'] diff --git a/hb_server/apps/hrm/tasks.py b/hb_server/apps/hrm/tasks.py index 65ffe92..a96d2cf 100644 --- a/hb_server/apps/hrm/tasks.py +++ b/hb_server/apps/hrm/tasks.py @@ -2,16 +2,15 @@ from __future__ import absolute_import, unicode_literals from celery import shared_task from apps.hrm.models import Employee -from apps.system.models import User from django.core.cache import cache @shared_task -def update_all_user_not_atwork(): +def update_all_employee_not_atwork(): """ 将所有员工设为非在岗状态 """ - User.objects.all().update(is_atwork=False, last_check_time = None) + Employee.objects.all().update(is_atwork=False, last_check_time = None) @shared_task def update_all_user_facedata_cache(): diff --git a/hb_server/apps/hrm/views.py b/hb_server/apps/hrm/views.py index e22ec6b..c19c308 100644 --- a/hb_server/apps/hrm/views.py +++ b/hb_server/apps/hrm/views.py @@ -92,9 +92,7 @@ class ClockRecordViewSet(CreateModelMixin, ListModelMixin, GenericViewSet): ins.update_time = now ins.save() # 设为在岗 - user.is_atwork = True - user.last_check_time = now - user.save() + Employee.objects.filter(user=user).update(is_atwork=True, last_check_time=now) return Response(UserSimpleSerializer(instance=user).data) return Response(msg, status=status.HTTP_400_BAD_REQUEST) return Response('非打卡时间范围', status=status.HTTP_400_BAD_REQUEST) @@ -140,9 +138,7 @@ class FaceLogin(CreateAPIView): }) # 设为在岗 if created: - user.is_atwork = True - user.last_check_time = now - user.save() + Employee.objects.filter(user=user).update(is_atwork=True, last_check_time=now) return Response({ 'refresh': str(refresh), diff --git a/hb_server/apps/mtm/views.py b/hb_server/apps/mtm/views.py index 6fcf054..7aaf203 100644 --- a/hb_server/apps/mtm/views.py +++ b/hb_server/apps/mtm/views.py @@ -10,7 +10,7 @@ from rest_framework.decorators import action from rest_framework.response import Response from utils.pagination import PageOrNot from rest_framework.exceptions import APIException - +from django.db import transaction # Create your views here. class MaterialViewSet(PageOrNot, CreateUpdateModelAMixin, ModelViewSet): @@ -208,6 +208,22 @@ class RecordFormFieldViewSet(OptimizationMixin, CreateUpdateModelAMixin, ModelVi return RecordFormFieldUpdateSerializer return RecordFormFieldSerializer + @transaction.atomic + def create(self, request, *args, **kwargs): + serializer = self.get_serializer(data=request.data) + serializer.is_valid(raise_exception=True) + vdata = serializer.validated_data + form = vdata.pop('form', None) + instance = RecordForm(**vdata) + instance.save(create_by=request.user) + if form: + for i in RecordFormField.objects.filter(form=form, is_deleted=False): + i.pk = None + i.form = instance + i.parent = None + i.save() + return super().create(request, *args, **kwargs) + class TechDocViewSet(OptimizationMixin, CreateUpdateModelAMixin, ModelViewSet): """ 技术文件增删改查 diff --git a/hb_server/apps/system/filters.py b/hb_server/apps/system/filters.py index cd3fde7..22ef179 100644 --- a/hb_server/apps/system/filters.py +++ b/hb_server/apps/system/filters.py @@ -7,4 +7,4 @@ class UserFilter(DynamicFieldsFilterMixin, filters.FilterSet): name = filters.CharFilter(field_name='name', lookup_expr='contains') class Meta: model = User - fields = ['name', 'is_active', 'is_atwork'] \ No newline at end of file + fields = ['name', 'is_active'] \ No newline at end of file diff --git a/hb_server/apps/system/migrations/0004_user_is_atwork.py b/hb_server/apps/system/migrations/0004_user_is_atwork.py deleted file mode 100644 index b512387..0000000 --- a/hb_server/apps/system/migrations/0004_user_is_atwork.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 3.2.9 on 2022-01-21 05:41 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('system', '0003_auto_20210812_0909'), - ] - - operations = [ - migrations.AddField( - model_name='user', - name='is_atwork', - field=models.BooleanField(default=False, verbose_name='当前在岗'), - ), - ] diff --git a/hb_server/apps/system/migrations/0005_user_last_check_time.py b/hb_server/apps/system/migrations/0005_user_last_check_time.py deleted file mode 100644 index 284e91b..0000000 --- a/hb_server/apps/system/migrations/0005_user_last_check_time.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 3.2.9 on 2022-01-25 08:51 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('system', '0004_user_is_atwork'), - ] - - operations = [ - migrations.AddField( - model_name='user', - name='last_check_time', - field=models.DateTimeField(blank=True, null=True, verbose_name='打卡时间'), - ), - ] diff --git a/hb_server/apps/system/models.py b/hb_server/apps/system/models.py index d69121a..c773fcf 100644 --- a/hb_server/apps/system/models.py +++ b/hb_server/apps/system/models.py @@ -116,8 +116,6 @@ class User(AbstractUser): superior = models.ForeignKey( 'self', null=True, blank=True, on_delete=models.SET_NULL, verbose_name='上级主管') roles = models.ManyToManyField(Role, blank=True, verbose_name='角色') - is_atwork = models.BooleanField('当前在岗', default=False) - last_check_time = models.DateTimeField('打卡时间', null=True, blank=True) class Meta: verbose_name = '用户信息' diff --git a/hb_server/apps/system/serializers.py b/hb_server/apps/system/serializers.py index d59d538..45d8c29 100644 --- a/hb_server/apps/system/serializers.py +++ b/hb_server/apps/system/serializers.py @@ -144,7 +144,7 @@ class UserListSerializer(DynamicFieldsSerializerMixin, serializers.ModelSerializ fields = ['id', 'name', 'phone', 'email', 'position', 'username', 'is_active', 'date_joined', 'dept_', 'dept', 'roles', 'avatar', - 'roles_', 'is_atwork', 'last_check_time'] + 'roles_'] @staticmethod def setup_eager_loading(queryset): From 3d90952cba609fb8410dd1de0e8392e654c53bdc Mon Sep 17 00:00:00 2001 From: caoqianming Date: Fri, 18 Feb 2022 08:45:58 +0800 Subject: [PATCH 05/11] =?UTF-8?q?=E7=A6=BB=E5=B2=97=E8=AF=B4=E6=98=8E?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hrm/migrations/0007_auto_20220218_0843.py | 41 +++++++++++++++++++ hb_server/apps/hrm/models.py | 11 +++++ 2 files changed, 52 insertions(+) create mode 100644 hb_server/apps/hrm/migrations/0007_auto_20220218_0843.py diff --git a/hb_server/apps/hrm/migrations/0007_auto_20220218_0843.py b/hb_server/apps/hrm/migrations/0007_auto_20220218_0843.py new file mode 100644 index 0000000..36752f4 --- /dev/null +++ b/hb_server/apps/hrm/migrations/0007_auto_20220218_0843.py @@ -0,0 +1,41 @@ +# Generated by Django 3.2.9 on 2022-02-18 00:43 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion +import django.utils.timezone + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('hrm', '0006_auto_20220217_2155'), + ] + + operations = [ + migrations.AddField( + model_name='employee', + name='not_work_remark', + field=models.CharField(blank=True, max_length=200, null=True, verbose_name='当前未打卡说明'), + ), + migrations.CreateModel( + name='NotWorkRemark', + 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='删除标记')), + ('year', models.PositiveSmallIntegerField(default=2022, verbose_name='年')), + ('month', models.PositiveSmallIntegerField(default=2, verbose_name='月')), + ('day', models.PositiveSmallIntegerField(default=1, verbose_name='日')), + ('remark', models.CharField(blank=True, max_length=200, null=True, verbose_name='未打卡说明')), + ('create_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='notworkremark_create_by', to=settings.AUTH_USER_MODEL, verbose_name='创建人')), + ('update_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='notworkremark_update_by', to=settings.AUTH_USER_MODEL, verbose_name='最后编辑人')), + ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='用户')), + ], + options={ + 'abstract': False, + }, + ), + ] diff --git a/hb_server/apps/hrm/models.py b/hb_server/apps/hrm/models.py index ed3a063..fb202be 100644 --- a/hb_server/apps/hrm/models.py +++ b/hb_server/apps/hrm/models.py @@ -32,6 +32,7 @@ class Employee(CommonAModel): face_data = models.JSONField('人脸识别数据', null=True, blank=True) is_atwork = models.BooleanField('当前在岗', default=False) last_check_time = models.DateTimeField('打卡时间', null=True, blank=True) + not_work_remark = models.CharField('当前未打卡说明', null=True, blank=True, max_length=200) class Meta: verbose_name = '员工补充信息' verbose_name_plural = verbose_name @@ -39,6 +40,16 @@ class Employee(CommonAModel): def __str__(self): return self.name +class NotWorkRemark(CommonAModel): + """ + 离岗说明 + """ + year = models.PositiveSmallIntegerField('年', default=2022) + month = models.PositiveSmallIntegerField('月', default=2) + day = models.PositiveSmallIntegerField('日', default=1) + user = models.ForeignKey(User, verbose_name='用户', on_delete=models.CASCADE) + remark = models.CharField('未打卡说明', null=True, blank=True, max_length=200) + class ClockRecord(CommonADModel): """ 打卡记录 From ffb7b6ece2babf494d01ed6def9d319f084091bd Mon Sep 17 00:00:00 2001 From: shijing Date: Fri, 18 Feb 2022 10:51:10 +0800 Subject: [PATCH 06/11] styleAdjust --- hb_client/src/api/hrm.js | 7 + hb_client/src/views/bigScreen/index.vue | 13 + hb_client/src/views/dashboard/index.vue | 10 +- hb_client/src/views/mtm/process.vue | 433 +++--- hb_client/src/views/pm/plan.vue | 32 +- .../views/statistics/materialStatistics.vue | 10 +- .../views/statistics/progressStatistics.vue | 10 +- hb_client/src/views/wpm/worktask.vue | 1160 ++++++++--------- 8 files changed, 837 insertions(+), 838 deletions(-) diff --git a/hb_client/src/api/hrm.js b/hb_client/src/api/hrm.js index beca22f..e3378a4 100644 --- a/hb_client/src/api/hrm.js +++ b/hb_client/src/api/hrm.js @@ -13,3 +13,10 @@ export function clockRecord(data) { data }) } +export function getEmployee(data) { + return request({ + url: '/hrm/employee/', + method: 'get', + data + }) +} diff --git a/hb_client/src/views/bigScreen/index.vue b/hb_client/src/views/bigScreen/index.vue index d07274d..2a0fcf1 100644 --- a/hb_client/src/views/bigScreen/index.vue +++ b/hb_client/src/views/bigScreen/index.vue @@ -98,6 +98,7 @@ import center from './center' import bottomLeft from './bottomLeft' import bottomRight from './bottomRight' + import { getPlanGantt } from "@/api/srm"; export default { mixins: [ drawMixin ], @@ -108,6 +109,7 @@ dateDay: null, dateYear: null, dateWeek: null, + planGanttList:[], weekday: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'] } }, @@ -122,6 +124,7 @@ mounted() { this.timeFn(); this.cancelLoading(); + this.getPageData(); let bigHeight = document.getElementsByClassName('host-body')[0].clientHeight; let firstHeight = document.getElementById('firstLine').clientHeight; let secondHeight = document.getElementsByClassName('jc-between')[0].clientHeight; @@ -139,6 +142,16 @@ this.dateWeek = this.weekday[new Date().getDay()] }, 1000) }, + getPageData(){ + let that = this; + getPlanGantt({Authorization:'big_screen'}).then(res => { + if (res.code === 200) { + this.planGanttList = res.data.results; + } else { + that.$message.error(res.msg); + } + }) + }, cancelLoading() { setTimeout(() => { this.loading = false diff --git a/hb_client/src/views/dashboard/index.vue b/hb_client/src/views/dashboard/index.vue index dcac59e..74b0ecc 100644 --- a/hb_client/src/views/dashboard/index.vue +++ b/hb_client/src/views/dashboard/index.vue @@ -240,7 +240,8 @@ - + + @@ -338,7 +339,8 @@ diff --git a/hb_client/src/views/pm/plan.vue b/hb_client/src/views/pm/plan.vue index 3b75c6c..7900b38 100644 --- a/hb_client/src/views/pm/plan.vue +++ b/hb_client/src/views/pm/plan.vue @@ -114,60 +114,50 @@ stripe style="width: 100%" height="250" - - > - - + - - + - + - + - + - + - - + - - - + diff --git a/hb_client/src/views/statistics/materialStatistics.vue b/hb_client/src/views/statistics/materialStatistics.vue index d32d704..80a9fc9 100644 --- a/hb_client/src/views/statistics/materialStatistics.vue +++ b/hb_client/src/views/statistics/materialStatistics.vue @@ -9,14 +9,14 @@
废料原因统计
-
+
@@ -56,7 +56,7 @@ :id="chartId1" :options="barOptions" :className="chartsName" - height="400px" + height="45vh" width="600px" > @@ -69,7 +69,7 @@ :id="chartId2" :options="barOptions" :className="chartsName" - height="400px" + height="45vh" width="600px" > @@ -111,7 +111,7 @@ :id="chartId3" :options="barOptions" :className="chartsName" - height="400px" + height="45vh" > diff --git a/hb_client/src/views/statistics/progressStatistics.vue b/hb_client/src/views/statistics/progressStatistics.vue index 4b1942d..0e5ee33 100644 --- a/hb_client/src/views/statistics/progressStatistics.vue +++ b/hb_client/src/views/statistics/progressStatistics.vue @@ -7,7 +7,7 @@ @@ -18,7 +18,7 @@ :id="chartId1" :options="barOptions" :className="chartsName" - height="400px" + height="45vh" width="100%" > @@ -31,7 +31,7 @@ :id="chartId2" :options="barOptions1" :className="chartsName" - height="400px" + height="45vh" width="100%" > @@ -55,10 +55,10 @@ > - + - + diff --git a/hb_client/src/views/wpm/worktask.vue b/hb_client/src/views/wpm/worktask.vue index 1cdc21a..acaf939 100644 --- a/hb_client/src/views/wpm/worktask.vue +++ b/hb_client/src/views/wpm/worktask.vue @@ -17,92 +17,96 @@ highlight-current-row @current-change="handleCurrentChange" > - - - + + - - + + - + - - + + - - + + - - - + + - - + - + - + + {{ state_[scope.row.state] }} + - + - - + - - + @@ -127,79 +131,74 @@ :label="item.name" :value="item.number" @click="handlework(item)" - >{{ item.name }} - + - - 显示全部 - - - - + 报废 + + + + 显示全部 + + - - - - + + + + > + - - - + + - - - + + - - - + + - - + + - - - - - + + + + + - - - - @@ -214,21 +213,21 @@ style="width: 100%" max-height="300" > - - - + + + - - + + - + @@ -242,13 +241,13 @@ - - + - + @@ -293,8 +292,9 @@ 领半成品 + 领半成品 + @@ -303,7 +303,6 @@ 确 定 - - - - + + - - - - + + @@ -341,7 +337,6 @@ 确 定 - 确认领料 + 确认领料 + @@ -449,23 +445,20 @@ max-height="600" @selection-change="handleSelectionChanges" > - - + + - + - - + - + - - +