到岗统计增加应到工作日

This commit is contained in:
caoqianming 2022-02-14 10:09:48 +08:00
parent da9bb2b79d
commit 070d2b558a
4 changed files with 18 additions and 5 deletions

View File

@ -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):
"""

View File

@ -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)

View File

@ -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(

View File

@ -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