se compare part 4
Showing
2 changed files
with
29 additions
and
6 deletions
| ... | @@ -49,6 +49,7 @@ class ProcessName(NamedEnum): | ... | @@ -49,6 +49,7 @@ class ProcessName(NamedEnum): |
| 49 | IDCARD = (2, 'F2_IDReport') | 49 | IDCARD = (2, 'F2_IDReport') |
| 50 | DDA = (3, 'CL_S1_DDAConsolidation') | 50 | DDA = (3, 'CL_S1_DDAConsolidation') |
| 51 | CACOMPARE = (4, 'S1_CA_DocumentVerify') | 51 | CACOMPARE = (4, 'S1_CA_DocumentVerify') |
| 52 | SE_CACOMPARE = (5, 'S1_SE_DocumentVerify') | ||
| 52 | 53 | ||
| 53 | 54 | ||
| 54 | class WorkflowName(NamedEnum): | 55 | class WorkflowName(NamedEnum): | ... | ... |
| ... | @@ -7,9 +7,13 @@ from collections import OrderedDict | ... | @@ -7,9 +7,13 @@ from collections import OrderedDict |
| 7 | from . import app | 7 | from . import app |
| 8 | from apps.doc.models import ( | 8 | from apps.doc.models import ( |
| 9 | AFCOCRResult, | 9 | AFCOCRResult, |
| 10 | AFCSEOCRResult, | ||
| 10 | HILOCRResult, | 11 | HILOCRResult, |
| 12 | HILSEOCRResult, | ||
| 11 | AFCComparisonInfo, | 13 | AFCComparisonInfo, |
| 14 | AFCSEComparisonInfo, | ||
| 12 | HILComparisonInfo, | 15 | HILComparisonInfo, |
| 16 | HILSEComparisonInfo, | ||
| 13 | Configs, | 17 | Configs, |
| 14 | HILCompareReport, | 18 | HILCompareReport, |
| 15 | AFCCompareReport, | 19 | AFCCompareReport, |
| ... | @@ -440,9 +444,22 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res | ... | @@ -440,9 +444,22 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res |
| 440 | else: | 444 | else: |
| 441 | # 将比对结果写入数据库 | 445 | # 将比对结果写入数据库 |
| 442 | try: | 446 | try: |
| 443 | pass | 447 | result_table = HILSECompareResult if application_entity == consts.HIL_PREFIX else AFCSECompareResult |
| 448 | res_obj = result_table.objects.filter(application_id=application_id).first() | ||
| 449 | if res_obj is None: | ||
| 450 | res_obj = result_table() | ||
| 451 | res_obj.application_id = application_id | ||
| 452 | res_obj.compare_count = total_fields | ||
| 453 | res_obj.failed_count = failed_count | ||
| 454 | # res_obj.reason1_count = reason1_count | ||
| 455 | res_obj.result = json.dumps(compare_result_str) | ||
| 456 | res_obj.save() | ||
| 457 | compare_log.info('{0} [SE] [result save success] [entity={1}] [id={2}] [ocr_res_id={3}]'.format( | ||
| 458 | log_base, application_entity, application_id, ocr_res_id)) | ||
| 444 | except Exception as e: | 459 | except Exception as e: |
| 445 | pass | 460 | compare_log.error('{0} [SE] [result save error] [entity={1}] [id={2}] [ocr_res_id={3}] ' |
| 461 | '[error={4}]'.format(log_base, application_entity, application_id, ocr_res_id, | ||
| 462 | traceback.format_exc())) | ||
| 446 | 463 | ||
| 447 | # report | 464 | # report |
| 448 | try: | 465 | try: |
| ... | @@ -456,12 +473,11 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res | ... | @@ -456,12 +473,11 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res |
| 456 | transaction_end=end_time, | 473 | transaction_end=end_time, |
| 457 | successful_at_this_level=successful_at_this_level, | 474 | successful_at_this_level=successful_at_this_level, |
| 458 | failure_reason=failure_reason, | 475 | failure_reason=failure_reason, |
| 459 | process_name=ProcessName.CACOMPARE.value, | 476 | process_name=ProcessName.SE_CACOMPARE.value, |
| 460 | total_fields=total_fields, | 477 | total_fields=total_fields, |
| 461 | workflow_name=customer_type, | 478 | workflow_name=customer_type, |
| 462 | ) | 479 | ) |
| 463 | compare_log.info( | 480 | compare_log.info('{0} [SE] [report save success] [entity={1}] [id={2}] [ocr_res_id={3}]'.format( |
| 464 | '{0} [SE] [report save success] [entity={1}] [id={2}] [ocr_res_id={3}]'.format( | ||
| 465 | log_base, application_entity, application_id, ocr_res_id)) | 481 | log_base, application_entity, application_id, ocr_res_id)) |
| 466 | except Exception as e: | 482 | except Exception as e: |
| 467 | compare_log.error('{0} [SE] [report save error] [entity={1}] [id={2}] [ocr_res_id={3}] ' | 483 | compare_log.error('{0} [SE] [report save error] [entity={1}] [id={2}] [ocr_res_id={3}] ' |
| ... | @@ -478,7 +494,10 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True | ... | @@ -478,7 +494,10 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True |
| 478 | log_base, application_entity, application_id, uniq_seq, ocr_res_id, is_ca)) | 494 | log_base, application_entity, application_id, uniq_seq, ocr_res_id, is_ca)) |
| 479 | 495 | ||
| 480 | # 根据application_id查找最新的比对信息,如果没有,结束 | 496 | # 根据application_id查找最新的比对信息,如果没有,结束 |
| 497 | if is_ca: | ||
| 481 | comparison_class = HILComparisonInfo if application_entity == consts.HIL_PREFIX else AFCComparisonInfo | 498 | comparison_class = HILComparisonInfo if application_entity == consts.HIL_PREFIX else AFCComparisonInfo |
| 499 | else: | ||
| 500 | comparison_class = HILSEComparisonInfo if application_entity == consts.HIL_PREFIX else AFCSEComparisonInfo | ||
| 482 | last_obj = comparison_class.objects.filter(application_id=application_id).last() | 501 | last_obj = comparison_class.objects.filter(application_id=application_id).last() |
| 483 | if last_obj is None: | 502 | if last_obj is None: |
| 484 | compare_log.info('{0} [comparison info empty] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}] ' | 503 | compare_log.info('{0} [comparison info empty] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}] ' |
| ... | @@ -486,7 +505,10 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True | ... | @@ -486,7 +505,10 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True |
| 486 | return | 505 | return |
| 487 | 506 | ||
| 488 | # 根据application_id查找OCR累计结果指定license字段,如果没有,结束 | 507 | # 根据application_id查找OCR累计结果指定license字段,如果没有,结束 |
| 508 | if is_ca: | ||
| 489 | result_class = HILOCRResult if application_entity == consts.HIL_PREFIX else AFCOCRResult | 509 | result_class = HILOCRResult if application_entity == consts.HIL_PREFIX else AFCOCRResult |
| 510 | else: | ||
| 511 | result_class = HILSEOCRResult if application_entity == consts.HIL_PREFIX else AFCSEOCRResult | ||
| 490 | if ocr_res_id is None: | 512 | if ocr_res_id is None: |
| 491 | ocr_res_dict = result_class.objects.filter(application_id=application_id).values(*consts.COMPARE_FIELDS).first() | 513 | ocr_res_dict = result_class.objects.filter(application_id=application_id).values(*consts.COMPARE_FIELDS).first() |
| 492 | else: | 514 | else: |
| ... | @@ -499,7 +521,7 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True | ... | @@ -499,7 +521,7 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True |
| 499 | if is_ca: | 521 | if is_ca: |
| 500 | ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict) | 522 | ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict) |
| 501 | else: | 523 | else: |
| 502 | se_compare() | 524 | se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict) |
| 503 | 525 | ||
| 504 | 526 | ||
| 505 | 527 | ... | ... |
-
Please register or sign in to post a comment