From c9ad35b4b5e16cc08af2b51a3e32bb89ec639c69 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Tue, 15 Feb 2022 10:52:10 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=8D=8A=E6=88=90=E5=93=81=E6=8A=98?= =?UTF-8?q?=E5=90=88=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb_server/apps/pm/serializers.py | 7 +++ hb_server/apps/pm/views.py | 80 ++++++++++++++++++++++++++++---- 2 files changed, 77 insertions(+), 10 deletions(-) diff --git a/hb_server/apps/pm/serializers.py b/hb_server/apps/pm/serializers.py index a77694f..a537ae9 100644 --- a/hb_server/apps/pm/serializers.py +++ b/hb_server/apps/pm/serializers.py @@ -22,6 +22,13 @@ class ResourceCalSerializer(serializers.Serializer): id = serializers.IntegerField(label='产品ID') count = serializers.IntegerField(label='生产数量') +class ResourceConvertSerializer(serializers.Serializer): + id = serializers.IntegerField(label='半成品ID') + count = serializers.IntegerField(label='折合数量') + +class ResourceConvertListSerializer(serializers.ListSerializer): + child = ResourceConvertSerializer() + class ResourceCalListSerializer(serializers.ListSerializer): child = ResourceCalSerializer() diff --git a/hb_server/apps/pm/views.py b/hb_server/apps/pm/views.py index 21967b1..28e9c3d 100644 --- a/hb_server/apps/pm/views.py +++ b/hb_server/apps/pm/views.py @@ -10,7 +10,7 @@ from apps.inm.serializers import MaterialBatchSerializer from apps.mtm.models import Material, Step, SubProduction, SubprodctionMaterial from apps.pm.filters import PlanFilterSet, SubproductionProgressFilterSet from apps.system.mixins import CreateUpdateModelAMixin -from apps.pm.serializers import GenSubPlanSerializer, PickNeedSerializer, PlanDestorySerializer, ProductionPlanCreateFromOrderSerializer, ProductionPlanSerializer, ResourceCalListSerializer, ResourceCalSerializer, SubProductionPlanListSerializer, SubProductionPlanUpdateSerializer, SubProductionProgressSerializer +from apps.pm.serializers import GenSubPlanSerializer, PickNeedSerializer, PlanDestorySerializer, ProductionPlanCreateFromOrderSerializer, ProductionPlanSerializer, ResourceCalListSerializer, ResourceCalSerializer, ResourceConvertListSerializer, ResourceConvertSerializer, SubProductionPlanListSerializer, SubProductionPlanUpdateSerializer, SubProductionProgressSerializer from rest_framework.mixins import CreateModelMixin, ListModelMixin, RetrieveModelMixin, UpdateModelMixin from apps.pm.models import ProductionPlan, SubProductionProgress, SubProductionPlan from rest_framework.viewsets import GenericViewSet, ModelViewSet @@ -216,30 +216,90 @@ class ResourceViewSet(GenericViewSet): rdata = request.data serializer = self.get_serializer(data=rdata) serializer.is_valid(raise_exception=True) + productIdList = [] + productList = [] + for i in rdata: + if i['id'] not in productIdList: + productIdList.append(i['id']) + productList.append(i) + else: + index = productIdList.index(i['id']) + productList[index]['count'] = productList[index]['count'] + i['count'] + res_d_list = [] res = [] - for i in rdata: + for i in productList: # 计算输入物料 materials = SubprodctionMaterial.objects.filter(subproduction__product__id=i['id'], subproduction__is_deleted=False, is_deleted=False, - material__type__in=[Material.MA_TYPE_MAINSO, - Material.MA_TYPE_HELPSO], type= SubprodctionMaterial.SUB_MA_TYPE_IN).order_by('material__number')\ + type= SubprodctionMaterial.SUB_MA_TYPE_IN).order_by('material__number')\ .values('material__id', 'material__name', 'material__number', 'material__type', 'count', 'material__count', 'material__count_safe') l_m = list(materials) for m in l_m: if m['material__id'] in res_d_list: - index = res_d_list.index(m['material__id']) - res[index]['count'] = res[index]['count'] + m['count']*i['count'] + if m['material__type'] in [Material.MA_TYPE_MAINSO, Material.MA_TYPE_HELPSO]: + index = res_d_list.index(m['material__id']) + res[index]['count'] = res[index]['count'] + m['count']*i['count'] else: res_d_list.append(m['material__id']) - res.append({'id':m['material__id'], 'name':m['material__name'], + item = {'id':m['material__id'], 'name':m['material__name'], 'type':m['material__type'], 'number':m['material__number'], - 'count':m['count']*i['count'], 'inv_count':m['material__count'], - 'count_safe':m['material__count_safe']}) + 'count': None,'inv_count':m['material__count'], + 'count_safe':m['material__count_safe']} + if item['type'] in [Material.MA_TYPE_MAINSO, Material.MA_TYPE_HELPSO]: + item['count'] = m['count']*i['count'] + res.append(item) return Response(res) + @action(methods=['post'], detail=False, perms_map={'post':'resource_cal'}, serializer_class=ResourceConvertListSerializer) + def convert(self, request, pk=None): + rdata = request.data + serializer = self.get_serializer(data=rdata) + serializer.is_valid(raise_exception=True) + res_d_list = [] + res = [] + half_list = rdata + while half_list: + fitem = half_list[0] + sm = SubprodctionMaterial.objects.filter( + type= SubprodctionMaterial.SUB_MA_TYPE_OUT, + is_deleted = False, + material__id = fitem['id'] + ).first() + if sm: + spn = sm.subproduction + sm_left_l = list(SubprodctionMaterial.objects.filter( + subproduction = spn, + type= SubprodctionMaterial.SUB_MA_TYPE_IN, + is_deleted = False, + ).order_by('material__number')\ + .values('material__id', 'material__name', + 'material__number', 'material__type', + 'count', 'material__count', 'material__count_safe')) + + for i in sm_left_l: + if i['material__type'] == Material.MA_TYPE_HALFGOOD: + item = { + 'id':i['material__id'], + 'count':(i['count']*fitem['count'])/(sm.count) + } + half_list.append(item) + else: + if i['material__id'] in res_d_list: + index = res_d_list.index(i['material__id']) + res[index]['count'] = res[index]['count'] + \ + (i['count']*fitem['count'])/(sm.count) + else: + res_d_list.append(i['material__id']) + item = { + 'id': i['material__id'], + 'count':(i['count']*fitem['count'])/(sm.count) + } + res.append(item) + del(half_list[0]) + return Response(res) @action(methods=['post'], detail=False, perms_map={'post':'resource_cal_equip'}, serializer_class=ResourceCalListSerializer) def cal_equip(self, request, pk=None): @@ -256,4 +316,4 @@ class ResourceViewSet(GenericViewSet): steps = Step.objects.filter(usedstep__is_deleted=False, usedstep__subproduction__in=subproductions) equips = Equipment.objects.filter(step_equips__in=steps, is_deleted=False).distinct() serializer = EquipmentSimpleSerializer(instance=equips, many=True) - return Response(serializer.data) + return Response(serializer.data) \ No newline at end of file From f67989c14215a9df34a013acd6b045abf29bb42c Mon Sep 17 00:00:00 2001 From: shijing Date: Tue, 15 Feb 2022 10:58:03 +0800 Subject: [PATCH 2/3] bigScreenTextChange&icons --- hb_client/src/icons/svg/password.svg | 1 + hb_client/src/icons/svg/search.svg | 1 + hb_client/src/icons/svg/size.svg | 1 + hb_client/src/icons/svg/userName.svg | 1 + hb_client/src/views/bigScreen/index.vue | 2 +- hb_client/src/views/dashboard/index.vue | 20 +++++++++++--------- hb_client/src/views/login/index.vue | 2 +- 7 files changed, 17 insertions(+), 11 deletions(-) create mode 100644 hb_client/src/icons/svg/password.svg create mode 100644 hb_client/src/icons/svg/search.svg create mode 100644 hb_client/src/icons/svg/size.svg create mode 100644 hb_client/src/icons/svg/userName.svg diff --git a/hb_client/src/icons/svg/password.svg b/hb_client/src/icons/svg/password.svg new file mode 100644 index 0000000..e291d85 --- /dev/null +++ b/hb_client/src/icons/svg/password.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/hb_client/src/icons/svg/search.svg b/hb_client/src/icons/svg/search.svg new file mode 100644 index 0000000..84233dd --- /dev/null +++ b/hb_client/src/icons/svg/search.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/hb_client/src/icons/svg/size.svg b/hb_client/src/icons/svg/size.svg new file mode 100644 index 0000000..ddb25b8 --- /dev/null +++ b/hb_client/src/icons/svg/size.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/hb_client/src/icons/svg/userName.svg b/hb_client/src/icons/svg/userName.svg new file mode 100644 index 0000000..0ba0716 --- /dev/null +++ b/hb_client/src/icons/svg/userName.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/hb_client/src/views/bigScreen/index.vue b/hb_client/src/views/bigScreen/index.vue index ed67ed2..d07274d 100644 --- a/hb_client/src/views/bigScreen/index.vue +++ b/hb_client/src/views/bigScreen/index.vue @@ -9,7 +9,7 @@
- *航玻车间可视化平台 + 航玻生产管理系统
@@ -18,16 +19,14 @@ {{contractTotalCurrent}}
-
@@ -41,8 +40,9 @@
@@ -56,8 +56,9 @@
@@ -71,8 +72,9 @@
@@ -1064,9 +1066,9 @@ .cardsWrap:nth-child(1) { .svgIconWrap { background: #e9f3ff; - .svgIcon { color: #409EFF; + fill: #409EFF; } } } diff --git a/hb_client/src/views/login/index.vue b/hb_client/src/views/login/index.vue index e86cde5..5b48238 100644 --- a/hb_client/src/views/login/index.vue +++ b/hb_client/src/views/login/index.vue @@ -24,7 +24,7 @@ auto-complete="on" > From 42cbd43117d3d298b434e0fda04b3a3131c5e81f Mon Sep 17 00:00:00 2001 From: caoqianming Date: Tue, 15 Feb 2022 11:12:40 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E7=89=A9=E6=96=99=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E6=8C=89=E7=89=A9=E6=96=99=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E5=92=8C=E7=BC=96=E5=8F=B7=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb_server/apps/hrm/views.py | 18 ++++++++++++++++++ hb_server/apps/pm/views.py | 3 ++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/hb_server/apps/hrm/views.py b/hb_server/apps/hrm/views.py index ed733da..e22ec6b 100644 --- a/hb_server/apps/hrm/views.py +++ b/hb_server/apps/hrm/views.py @@ -126,6 +126,24 @@ class FaceLogin(CreateAPIView): if user: refresh = RefreshToken.for_user(user) # 可设为在岗 + now = timezone.now() + now_local = timezone.localtime() + if 8<=now_local.hour<=17: + ins, created = ClockRecord.objects.get_or_create( + create_by = user, create_time__hour__range = [8,18], + create_time__year=now_local.year, create_time__month=now_local.month, + create_time__day=now_local.day, + defaults={ + 'type':ClockRecord.ClOCK_WORK1, + 'create_by':user, + 'create_time':now + }) + # 设为在岗 + if created: + user.is_atwork = True + user.last_check_time = now + user.save() + return Response({ 'refresh': str(refresh), 'access': str(refresh.access_token), diff --git a/hb_server/apps/pm/views.py b/hb_server/apps/pm/views.py index 28e9c3d..62a7bbb 100644 --- a/hb_server/apps/pm/views.py +++ b/hb_server/apps/pm/views.py @@ -232,7 +232,8 @@ class ResourceViewSet(GenericViewSet): # 计算输入物料 materials = SubprodctionMaterial.objects.filter(subproduction__product__id=i['id'], subproduction__is_deleted=False, is_deleted=False, - type= SubprodctionMaterial.SUB_MA_TYPE_IN).order_by('material__number')\ + type= SubprodctionMaterial.SUB_MA_TYPE_IN).order_by( + 'material__type', 'material__number')\ .values('material__id', 'material__name', 'material__number', 'material__type', 'count', 'material__count', 'material__count_safe')