From 070d2b558aa8ec3b2f5a8af3913ac135c752b70c Mon Sep 17 00:00:00 2001 From: caoqianming Date: Mon, 14 Feb 2022 10:09:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=B0=E5=B2=97=E7=BB=9F=E8=AE=A1=E5=A2=9E?= =?UTF-8?q?=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