到岗统计增加应到工作日
This commit is contained in:
parent
da9bb2b79d
commit
070d2b558a
|
@ -240,6 +240,7 @@ class ResourceViewSet(GenericViewSet):
|
||||||
'count_safe':m['material__count_safe']})
|
'count_safe':m['material__count_safe']})
|
||||||
return Response(res)
|
return Response(res)
|
||||||
|
|
||||||
|
|
||||||
@action(methods=['post'], detail=False, perms_map={'post':'resource_cal_equip'}, serializer_class=ResourceCalListSerializer)
|
@action(methods=['post'], detail=False, perms_map={'post':'resource_cal_equip'}, serializer_class=ResourceCalListSerializer)
|
||||||
def cal_equip(self, request, pk=None):
|
def cal_equip(self, request, pk=None):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
|
|
||||||
|
from datetime import date, timedelta
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from numpy import number
|
from numpy import number
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
@ -78,6 +79,14 @@ class AtWorkCountView(CreateAPIView):
|
||||||
serializer = self.get_serializer(data=request.data)
|
serializer = self.get_serializer(data=request.data)
|
||||||
serializer.is_valid(raise_exception=True)
|
serializer.is_valid(raise_exception=True)
|
||||||
vdata = serializer.validated_data
|
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(
|
ret = ClockRecord.objects.filter(
|
||||||
update_time__year = vdata['year'],
|
update_time__year = vdata['year'],
|
||||||
update_time__month = vdata['month']
|
update_time__month = vdata['month']
|
||||||
|
@ -89,5 +98,7 @@ class AtWorkCountView(CreateAPIView):
|
||||||
dept_name = F('create_by__dept__name')).annotate(
|
dept_name = F('create_by__dept__name')).annotate(
|
||||||
count = Count('id')
|
count = Count('id')
|
||||||
)
|
)
|
||||||
return Response(list(ret))
|
ret_list = list(ret)
|
||||||
|
for i in ret:
|
||||||
|
i['workday_count'] = workday_count
|
||||||
|
return Response(ret_list)
|
||||||
|
|
|
@ -644,8 +644,9 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd
|
||||||
'subproduction_plan', flat=True)
|
'subproduction_plan', flat=True)
|
||||||
if set(list(sps_omi_l)) != set(list(sps_omo_l)):
|
if set(list(sps_omi_l)) != set(list(sps_omo_l)):
|
||||||
raise exceptions.APIException('消耗与产出不一致')
|
raise exceptions.APIException('消耗与产出不一致')
|
||||||
|
else:
|
||||||
# 实际消耗物料校验
|
if not omis.exists():
|
||||||
|
raise exceptions.APIException('请选择消耗物料')
|
||||||
|
|
||||||
# 检查自定义表单填写
|
# 检查自定义表单填写
|
||||||
if OperationRecord.objects.filter(operation=op, is_filled=False).exists():
|
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
|
wproduct.act_state = WProduct.WPR_ACT_STATE_DOWAIT
|
||||||
if needTest:
|
if needTest:
|
||||||
wproduct.act_state = WProduct.WPR_ACT_STATE_TOTEST
|
wproduct.act_state = WProduct.WPR_ACT_STATE_TOTEST
|
||||||
wproduct.material_check = wproduct.product
|
|
||||||
|
|
||||||
# 更新子计划进度
|
# 更新子计划进度
|
||||||
WpmService.update_subproduction_progress_main(
|
WpmService.update_subproduction_progress_main(
|
||||||
|
|
|
@ -12,3 +12,4 @@ pillow==8.3.1
|
||||||
opencv-python==4.5.3.56
|
opencv-python==4.5.3.56
|
||||||
django-celery-results==2.2.0
|
django-celery-results==2.2.0
|
||||||
numpy==1.21.2
|
numpy==1.21.2
|
||||||
|
workalendar==16.2.0
|
||||||
|
|
Loading…
Reference in New Issue