Merge branch 'develop' of https://e.coding.net/ctcdevteam/hberp/hberp into develop

This commit is contained in:
shijing 2022-02-14 10:57:49 +08:00
commit 3409d1b42e
5 changed files with 23 additions and 7 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()
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)
)
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['count_workday'] = count_workday
return Response(ret_list)

View File

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

View File

@ -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,
@ -644,8 +646,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() and processId !=1: # 不是冷加工
raise exceptions.APIException('请选择消耗物料')
# 检查自定义表单填写
if OperationRecord.objects.filter(operation=op, is_filled=False).exists():
@ -747,7 +750,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(
@ -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()

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