add auto excel
Showing
2 changed files
with
55 additions
and
1 deletions
... | @@ -2217,3 +2217,12 @@ RPA_RESULT_MAP = { | ... | @@ -2217,3 +2217,12 @@ RPA_RESULT_MAP = { |
2217 | 2217 | ||
2218 | RE_RPA_RESULT_MAP = {v: k for k, v in RPA_RESULT_MAP.items()} | 2218 | RE_RPA_RESULT_MAP = {v: k for k, v in RPA_RESULT_MAP.items()} |
2219 | 2219 | ||
2220 | AUTO_WB_FIELD = ( | ||
2221 | ('application_id', 'aa_type', 'ocr_latest_comparison_time', 'ocr_auto_result_pass', 'ocr_whole_result_pass', | ||
2222 | 'rpa_result', 'rpa_1st_eye_tat', 'rpa_2nd_eye_tat', 'rpa_3rd_eye_tat', 'rpa_total_tat', 'rpa_activated_time', | ||
2223 | 'rpa_get_case_from_ocr_time', 'rpa_get_case_from_oc_time', 'rpa_payment_authorize_time', 'rpa_second_eye_time'), | ||
2224 | ('application_id', 'aa_type', 'latest_comparison_time', 'auto_result', 'whole_result', 'rpa_result', | ||
2225 | 'rpa_1st_eye_tat', 'rpa_2nd_eye_tat', 'rpa_3rd_eye_tat', 'rpa_total_tat', 'rpa_activated_time', | ||
2226 | 'rpa_get_case_from_ocr_time', 'rpa_get_case_from_oc_time', 'rpa_payment_authorize_time', 'rpa_second_eye_time') | ||
2227 | ) | ||
2228 | ... | ... |
... | @@ -1369,9 +1369,54 @@ class AutoSettlementExcelView(GenericView): | ... | @@ -1369,9 +1369,54 @@ class AutoSettlementExcelView(GenericView): |
1369 | # 获取auto settlement excel | 1369 | # 获取auto settlement excel |
1370 | @use_args(auto_list_args, location='querystring') | 1370 | @use_args(auto_list_args, location='querystring') |
1371 | def get(self, request, args): | 1371 | def get(self, request, args): |
1372 | business_type = args.get('business_type') | ||
1373 | application_id = args.get('application_id') | ||
1374 | |||
1375 | get_case_from_ocr_time_start = args.get('get_case_from_ocr_time_start') | ||
1376 | get_case_from_ocr_time_end = args.get('get_case_from_ocr_time_end') | ||
1377 | activated_time_start = args.get('activated_time_start') | ||
1378 | activated_time_end = args.get('activated_time_end') | ||
1379 | comparison_time_start = args.get('comparison_time_start') | ||
1380 | comparison_time_end = args.get('comparison_time_end') | ||
1381 | |||
1382 | auto_result = args.get('auto_result', '') | ||
1383 | whole_result = args.get('whole_result', '') | ||
1384 | rpa_result = args.get('rpa_result', '') | ||
1385 | |||
1386 | if isinstance(auto_result, int): | ||
1387 | auto_result = consts.RESULT_MAP.get(auto_result) | ||
1388 | if isinstance(whole_result, int): | ||
1389 | whole_result = consts.RESULT_MAP.get(whole_result) | ||
1390 | if isinstance(rpa_result, int): | ||
1391 | rpa_result = consts.RPA_RESULT_MAP.get(rpa_result) | ||
1392 | |||
1393 | application_id_query = Q(application_id__contains=application_id) if application_id is not None else Q() | ||
1394 | auto_result_query = Q(ocr_auto_result_pass=auto_result) if not isinstance(auto_result, str) else Q() | ||
1395 | whole_result_query = Q(ocr_whole_result_pass=whole_result) if not isinstance(whole_result, str) else Q() | ||
1396 | rpa_result_query = Q(rpa_result=rpa_result) if not isinstance(rpa_result, str) else Q() | ||
1397 | time1_query = Q(rpa_get_case_from_ocr_time__gte=get_case_from_ocr_time_start, | ||
1398 | rpa_get_case_from_ocr_time__lt=get_case_from_ocr_time_end + datetime.timedelta(days=1)) \ | ||
1399 | if get_case_from_ocr_time_start is not None and get_case_from_ocr_time_end is not None else Q() | ||
1400 | time2_query = Q(rpa_activated_time__gte=activated_time_start, | ||
1401 | rpa_activated_time__lt=activated_time_end + datetime.timedelta(days=1)) \ | ||
1402 | if activated_time_start is not None and activated_time_end is not None else Q() | ||
1403 | time3_query = Q(ocr_latest_comparison_time__gte=comparison_time_start, | ||
1404 | ocr_latest_comparison_time__lt=comparison_time_end + datetime.timedelta(days=1)) \ | ||
1405 | if comparison_time_start is not None and comparison_time_end is not None else Q() | ||
1406 | |||
1407 | query = application_id_query & auto_result_query & whole_result_query & rpa_result_query \ | ||
1408 | & time1_query & time2_query & time3_query | ||
1409 | |||
1410 | auto_class = HILAutoSettlement if business_type in consts.HIL_SET else AFCAutoSettlement | ||
1411 | |||
1412 | auto_queryset = auto_class.objects.filter(query).values_list(*consts.AUTO_WB_FIELD[0]).order_by( | ||
1413 | '-ocr_latest_comparison_time') | ||
1414 | |||
1372 | wb = Workbook() | 1415 | wb = Workbook() |
1373 | ws = wb.active | 1416 | ws = wb.active |
1374 | ws.append(['序号', '告警id', '设备编号']) | 1417 | ws.append(consts.AUTO_WB_FIELD[1]) |
1418 | for row in auto_queryset: | ||
1419 | ws.append(row) | ||
1375 | io_content = io.BytesIO() # 创建在内存中处理对象 | 1420 | io_content = io.BytesIO() # 创建在内存中处理对象 |
1376 | wb.save(io_content) | 1421 | wb.save(io_content) |
1377 | wb.close() | 1422 | wb.close() | ... | ... |
-
Please register or sign in to post a comment