fix auto
Showing
2 changed files
with
12 additions
and
6 deletions
... | @@ -508,7 +508,7 @@ result_update_args = { | ... | @@ -508,7 +508,7 @@ result_update_args = { |
508 | } | 508 | } |
509 | 509 | ||
510 | mpos_args = { | 510 | mpos_args = { |
511 | 'type': fields.Int(required=True, validate=validate.OneOf(consts.MPOS_MAP.keys())), | 511 | 'type': fields.Int(required=True, validate=validate.OneOf(consts.MPOS_MAP)), |
512 | 'file_base64_content': fields.List(fields.Str(), required=True, validate=validate.Length(min=1)), | 512 | 'file_base64_content': fields.List(fields.Str(), required=True, validate=validate.Length(min=1)), |
513 | } | 513 | } |
514 | 514 | ||
... | @@ -1012,8 +1012,10 @@ class CompareResultView(GenericView): | ... | @@ -1012,8 +1012,10 @@ class CompareResultView(GenericView): |
1012 | 1012 | ||
1013 | if result_obj is None: | 1013 | if result_obj is None: |
1014 | whole_result = '' | 1014 | whole_result = '' |
1015 | latest_compared_time = '' | ||
1015 | else: | 1016 | else: |
1016 | whole_result = consts.RESULT_Y if result_obj.ocr_auto_result_pass else consts.RESULT_N | 1017 | whole_result = consts.RESULT_Y if result_obj.ocr_auto_result_pass else consts.RESULT_N |
1018 | latest_compared_time = '' if result_obj.ocr_latest_comparison_time is None else result_obj.ocr_latest_comparison_time.strftime('%Y-%m-%d %H:%M') | ||
1017 | 1019 | ||
1018 | source = consts.INFO_SOURCE[1] | 1020 | source = consts.INFO_SOURCE[1] |
1019 | version = comments = '' | 1021 | version = comments = '' |
... | @@ -1025,11 +1027,11 @@ class CompareResultView(GenericView): | ... | @@ -1025,11 +1027,11 @@ class CompareResultView(GenericView): |
1025 | 'scheme': consts.DOC_SCHEME_LIST[0] if scheme == consts.COMPARE_DOC_SCHEME_LIST[0] else | 1027 | 'scheme': consts.DOC_SCHEME_LIST[0] if scheme == consts.COMPARE_DOC_SCHEME_LIST[0] else |
1026 | consts.DOC_SCHEME_LIST[1], | 1028 | consts.DOC_SCHEME_LIST[1], |
1027 | 'whole_result': whole_result, | 1029 | 'whole_result': whole_result, |
1028 | 'latest_compared_time': '' if result_obj is None else result_obj.ocr_latest_comparison_time.strftime('%Y-%m-%d %H:%M'), | 1030 | 'latest_compared_time': latest_compared_time, |
1029 | 'source': source, | 1031 | 'source': source, |
1030 | 'version': version, | 1032 | 'version': version, |
1031 | 'comments': comments, | 1033 | 'comments': comments, |
1032 | 'result': [] if result_obj is None else json.loads(result_obj.ocr_auto_result) | 1034 | 'result': [] if result_obj is None or not result_obj.ocr_auto_result else json.loads(result_obj.ocr_auto_result) |
1033 | } | 1035 | } |
1034 | 1036 | ||
1035 | return response.ok(data=compare_result) | 1037 | return response.ok(data=compare_result) | ... | ... |
... | @@ -2720,7 +2720,7 @@ def se_result_detect(ocr_res_dict): | ... | @@ -2720,7 +2720,7 @@ def se_result_detect(ocr_res_dict): |
2720 | return detect_list | 2720 | return detect_list |
2721 | 2721 | ||
2722 | 2722 | ||
2723 | def se_compare_auto(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict, auto_obj): | 2723 | def se_compare_auto(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict, auto_obj, full_result): |
2724 | try: | 2724 | try: |
2725 | # 比对逻辑 | 2725 | # 比对逻辑 |
2726 | # detect_list = se_result_detect(ocr_res_dict) | 2726 | # detect_list = se_result_detect(ocr_res_dict) |
... | @@ -2738,6 +2738,7 @@ def se_compare_auto(application_id, application_entity, ocr_res_id, last_obj, oc | ... | @@ -2738,6 +2738,7 @@ def se_compare_auto(application_id, application_entity, ocr_res_id, last_obj, oc |
2738 | try: | 2738 | try: |
2739 | auto_obj.aa_type = aa_type | 2739 | auto_obj.aa_type = aa_type |
2740 | auto_obj.ocr_auto_result_pass = successful_at_this_level | 2740 | auto_obj.ocr_auto_result_pass = successful_at_this_level |
2741 | auto_obj.ocr_whole_result_pass = full_result | ||
2741 | auto_obj.ocr_auto_result = json.dumps(compare_result) | 2742 | auto_obj.ocr_auto_result = json.dumps(compare_result) |
2742 | auto_obj.ocr_latest_comparison_time = datetime.now() | 2743 | auto_obj.ocr_latest_comparison_time = datetime.now() |
2743 | auto_obj.save() | 2744 | auto_obj.save() |
... | @@ -2769,6 +2770,7 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res | ... | @@ -2769,6 +2770,7 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res |
2769 | compare_log.error('{0} [SE] [compare error] [entity={1}] [id={2}] [ocr_res_id={3}] ' | 2770 | compare_log.error('{0} [SE] [compare error] [entity={1}] [id={2}] [ocr_res_id={3}] ' |
2770 | '[error={4}]'.format(log_base, application_entity, application_id, ocr_res_id, | 2771 | '[error={4}]'.format(log_base, application_entity, application_id, ocr_res_id, |
2771 | traceback.format_exc())) | 2772 | traceback.format_exc())) |
2773 | return False | ||
2772 | else: | 2774 | else: |
2773 | # 将比对结果写入数据库 | 2775 | # 将比对结果写入数据库 |
2774 | try: | 2776 | try: |
... | @@ -2844,6 +2846,8 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res | ... | @@ -2844,6 +2846,8 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res |
2844 | '[response={5}]'.format(log_base, application_entity, application_id, ocr_res_id, | 2846 | '[response={5}]'.format(log_base, application_entity, application_id, ocr_res_id, |
2845 | data, response)) | 2847 | data, response)) |
2846 | 2848 | ||
2849 | return successful_at_this_level | ||
2850 | |||
2847 | 2851 | ||
2848 | @app.task | 2852 | @app.task |
2849 | def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True, is_cms=False): | 2853 | def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True, is_cms=False): |
... | @@ -2902,10 +2906,10 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True | ... | @@ -2902,10 +2906,10 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True |
2902 | tmp_se_result = json.loads(ocr_res_dict.get(field_name)) | 2906 | tmp_se_result = json.loads(ocr_res_dict.get(field_name)) |
2903 | tmp_ca_result.extend(tmp_se_result) | 2907 | tmp_ca_result.extend(tmp_se_result) |
2904 | ocr_res_dict[field_name] = json.dumps(tmp_ca_result) | 2908 | ocr_res_dict[field_name] = json.dumps(tmp_ca_result) |
2909 | full_result = se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict, is_cms) | ||
2905 | # auto settlement | 2910 | # auto settlement |
2906 | auto_class = HILAutoSettlement if application_entity == consts.HIL_PREFIX else AFCAutoSettlement | 2911 | auto_class = HILAutoSettlement if application_entity == consts.HIL_PREFIX else AFCAutoSettlement |
2907 | auto_obj = auto_class.objects.filter(application_id=application_id, on_off=True).first() | 2912 | auto_obj = auto_class.objects.filter(application_id=application_id, on_off=True).first() |
2908 | if auto_obj is not None: | 2913 | if auto_obj is not None: |
2909 | se_compare_auto(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict, auto_obj) | 2914 | se_compare_auto(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict, auto_obj, full_result) |
2910 | se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict, is_cms) | ||
2911 | 2915 | ... | ... |
-
Please register or sign in to post a comment