From 070d2b558aa8ec3b2f5a8af3913ac135c752b70c Mon Sep 17 00:00:00 2001 From: caoqianming Date: Mon, 14 Feb 2022 10:09:48 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=88=B0=E5=B2=97=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BA=94=E5=88=B0=E5=B7=A5=E4=BD=9C=E6=97=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb_server/apps/pm/views.py | 1 + hb_server/apps/srm/views.py | 15 +++++++++++++-- hb_server/apps/wpm/views.py | 6 +++--- hb_server/requirements.txt | 1 + 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/hb_server/apps/pm/views.py b/hb_server/apps/pm/views.py index 44eea4d..21967b1 100644 --- a/hb_server/apps/pm/views.py +++ b/hb_server/apps/pm/views.py @@ -240,6 +240,7 @@ class ResourceViewSet(GenericViewSet): 'count_safe':m['material__count_safe']}) return Response(res) + @action(methods=['post'], detail=False, perms_map={'post':'resource_cal_equip'}, serializer_class=ResourceCalListSerializer) def cal_equip(self, request, pk=None): """ diff --git a/hb_server/apps/srm/views.py b/hb_server/apps/srm/views.py index d8531c0..d92adb7 100644 --- a/hb_server/apps/srm/views.py +++ b/hb_server/apps/srm/views.py @@ -1,4 +1,5 @@ +from datetime import date, timedelta from django.shortcuts import render from numpy import number from rest_framework import serializers @@ -78,6 +79,14 @@ class AtWorkCountView(CreateAPIView): serializer = self.get_serializer(data=request.data) serializer.is_valid(raise_exception=True) vdata = serializer.validated_data + + from workalendar.asia import China + cal = China() + workday_count = cal.get_working_days_delta( + date(vdata['year'], vdata['month'], 1), + (date(vdata['year'], vdata['month'], 1).replace(day=1) + + timedelta(days=32)).replace(day=1) - timedelta(days=1) + ) ret = ClockRecord.objects.filter( update_time__year = vdata['year'], update_time__month = vdata['month'] @@ -89,5 +98,7 @@ class AtWorkCountView(CreateAPIView): dept_name = F('create_by__dept__name')).annotate( count = Count('id') ) - return Response(list(ret)) - + ret_list = list(ret) + for i in ret: + i['workday_count'] = workday_count + return Response(ret_list) diff --git a/hb_server/apps/wpm/views.py b/hb_server/apps/wpm/views.py index 81c18ed..392ceb4 100644 --- a/hb_server/apps/wpm/views.py +++ b/hb_server/apps/wpm/views.py @@ -644,8 +644,9 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd 'subproduction_plan', flat=True) if set(list(sps_omi_l)) != set(list(sps_omo_l)): raise exceptions.APIException('消耗与产出不一致') - - # 实际消耗物料校验 + else: + if not omis.exists(): + raise exceptions.APIException('请选择消耗物料') # 检查自定义表单填写 if OperationRecord.objects.filter(operation=op, is_filled=False).exists(): @@ -747,7 +748,6 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd wproduct.act_state = WProduct.WPR_ACT_STATE_DOWAIT if needTest: wproduct.act_state = WProduct.WPR_ACT_STATE_TOTEST - wproduct.material_check = wproduct.product # 更新子计划进度 WpmService.update_subproduction_progress_main( diff --git a/hb_server/requirements.txt b/hb_server/requirements.txt index 500f758..72fa958 100644 --- a/hb_server/requirements.txt +++ b/hb_server/requirements.txt @@ -12,3 +12,4 @@ pillow==8.3.1 opencv-python==4.5.3.56 django-celery-results==2.2.0 numpy==1.21.2 +workalendar==16.2.0 From 264da03d4efa1c39a09a641a7be9a83f34188f76 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Mon, 14 Feb 2022 10:12:00 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=BAcount=5Fworkday?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb_server/apps/srm/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hb_server/apps/srm/views.py b/hb_server/apps/srm/views.py index d92adb7..8e010b8 100644 --- a/hb_server/apps/srm/views.py +++ b/hb_server/apps/srm/views.py @@ -82,7 +82,7 @@ class AtWorkCountView(CreateAPIView): from workalendar.asia import China cal = China() - workday_count = cal.get_working_days_delta( + count_workday = cal.get_working_days_delta( date(vdata['year'], vdata['month'], 1), (date(vdata['year'], vdata['month'], 1).replace(day=1) + timedelta(days=32)).replace(day=1) - timedelta(days=1) @@ -100,5 +100,5 @@ class AtWorkCountView(CreateAPIView): ) ret_list = list(ret) for i in ret: - i['workday_count'] = workday_count + i['count_workday'] = count_workday return Response(ret_list) From 39704bade9a0216e018c68a22948584f9a878451 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Mon, 14 Feb 2022 10:48:28 +0800 Subject: [PATCH 3/3] =?UTF-8?q?wproduct=5Fticket=20list=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0workflow=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb_server/apps/wpm/serializers.py | 1 + hb_server/apps/wpm/views.py | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/hb_server/apps/wpm/serializers.py b/hb_server/apps/wpm/serializers.py index 3fa0a32..b5c702f 100644 --- a/hb_server/apps/wpm/serializers.py +++ b/hb_server/apps/wpm/serializers.py @@ -559,6 +559,7 @@ class WproductTicketListSerializer(serializers.ModelSerializer): resp_process_ = ProcessSimpleSerializer(source='resp_process', read_only=True) order_ = OrderSimpleSerializer(source='subproduction_plan.production_plan.order', read_only=True) product_ = MaterialSimpleSerializer(source='subproduction_plan.production_plan.product', read_only=True) + workflow = serializers.PrimaryKeyRelatedField(source='ticket.workflow', read_only=True) class Meta: model = WprouctTicket diff --git a/hb_server/apps/wpm/views.py b/hb_server/apps/wpm/views.py index 392ceb4..98d1a2d 100644 --- a/hb_server/apps/wpm/views.py +++ b/hb_server/apps/wpm/views.py @@ -499,7 +499,8 @@ class WproductTicketViewSet(ListModelMixin, GenericViewSet): perms_map = {'get': '*'} queryset = WprouctTicket.objects.select_related('step', 'material', 'subproduction_plan', 'resp_process', 'subproduction_plan__production_plan__order', - 'subproduction_plan__production_plan') + 'subproduction_plan__production_plan', + 'ticket__workflow') serializer_class = WproductTicketListSerializer filterset_fields = ['step', 'material', 'subproduction_plan', 'resp_process'] @@ -631,6 +632,7 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd """ op = self.get_object() step = op.step + processId = op.step.process.id if op.is_submited: raise exceptions.APIException('该操作已提交') omis = OperationMaterial.objects.filter(operation=op, @@ -645,7 +647,7 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd if set(list(sps_omi_l)) != set(list(sps_omo_l)): raise exceptions.APIException('消耗与产出不一致') else: - if not omis.exists(): + if not omis.exists() and processId !=1: # 不是冷加工 raise exceptions.APIException('请选择消耗物料') # 检查自定义表单填写 @@ -766,7 +768,7 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd op.save() # 如果是冷加工 - if step.process.id == 1: + if processId == 1: WpmService.update_cutting_list_with_operation(op=op) return Response()