refector: 打卡记录导出

This commit is contained in:
caoqianming 2023-03-23 11:15:12 +08:00
parent e4aad35f06
commit 1606213cbc
1 changed files with 7 additions and 7 deletions

View File

@ -30,7 +30,8 @@ from rest_framework.permissions import IsAuthenticated
epTypeOptions = {'employee': '正式员工', 'remployee': '相关方',
'visitor': '访客', 'driver': '货车司机'}
crOptions = {10: '上班打卡', 20: '下班打卡'}
crOptions = {10: '上班打卡', 20: '下班打卡', 30: ''}
crEoptions = {10: '在岗时间短', 20: '在岗时间长', 30: '缺卡', 40: '加班'}
# Create your views here.
@ -235,9 +236,8 @@ class ClockRecordViewSet(ListModelMixin, CustomGenericViewSet):
"""导出excel
导出excel
"""
field_data = ['人员类型', '人员', '编号', '身份证号',
'所属部门', '打卡类型', '触发形式', '体温', '打卡时间']
queryset = self.filter_queryset(self.get_queryset()).filter(type__in=[10, 20])
field_data = ['人员类型', '人员', '编号', '身份证号', '所属部门', '触发形式', '打卡时间', '打卡推测', '异常推测']
queryset = self.filter_queryset(self.get_queryset())
odata = ClockRecordListSerializer(queryset, many=True).data
# 处理数据
data = []
@ -248,10 +248,10 @@ class ClockRecordViewSet(ListModelMixin, CustomGenericViewSet):
i['employee_']['number'],
i['employee_']['id_number'],
i['employee_'].get('belong_dept_name', ''),
crOptions[i['type']],
i['detail'].get('deviceName', None),
i['detail'].get('curTemp', None),
i['create_time']]
i['create_time']],
crOptions[i['type']],
crEoptions[i['exception_type']]
)
return Response({'path': export_excel(field_data, data, '打卡记录')})