cancel test
Showing
2 changed files
with
44 additions
and
45 deletions
... | @@ -888,54 +888,54 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -888,54 +888,54 @@ class Command(BaseCommand, LoggerMixin): |
888 | os.remove(excel_path) | 888 | os.remove(excel_path) |
889 | finally: | 889 | finally: |
890 | # TODO 识别结果存一张表,方便跑报表 | 890 | # TODO 识别结果存一张表,方便跑报表 |
891 | # if doc.document_scheme == consts.DOC_SCHEME_LIST[0]: | 891 | if doc.document_scheme == consts.DOC_SCHEME_LIST[0]: |
892 | try: | ||
893 | # 更新OCR累计识别结果表 | ||
894 | result_class = HILOCRResult if business_type == consts.HIL_PREFIX else AFCOCRResult | ||
895 | res_obj = result_class.objects.filter(application_id=doc.application_id).first() | ||
896 | if res_obj is None: | ||
897 | res_obj = result_class() | ||
898 | res_obj.application_id = doc.application_id | ||
899 | for classify, field in consts.RESULT_MAPPING.items(): | ||
900 | license_list = license_summary.get(classify) | ||
901 | if not license_list: | ||
902 | continue | ||
903 | if classify == consts.IC_CLASSIFY and ic_merge: | ||
904 | license_list[0].update(license_list[1]) | ||
905 | license_list.pop(1) | ||
906 | elif classify == consts.RP_CLASSIFY and rp_merge: | ||
907 | license_list[0].update(license_list[1]) | ||
908 | license_list.pop(1) | ||
909 | if not hasattr(res_obj, field): | ||
910 | continue | ||
911 | old_res_str = getattr(res_obj, field) | ||
912 | if old_res_str is None: | ||
913 | last_res_str = json.dumps(license_list) | ||
914 | else: | ||
915 | old_res_list = json.loads(old_res_str) | ||
916 | old_res_list.extend(license_list) | ||
917 | last_res_str = json.dumps(old_res_list) | ||
918 | setattr(res_obj, field, last_res_str) | ||
919 | res_obj.save() | ||
920 | except Exception as e: | ||
921 | self.online_log.error( | ||
922 | '{0} [process error (ocr result save)] [task={1}] [error={2}]'.format( | ||
923 | self.log_base, task_str, traceback.format_exc())) | ||
924 | else: | ||
925 | self.online_log.info('{0} [ocr result save success] [task={1}] [res_id={2}]'.format( | ||
926 | self.log_base, task_str, res_obj.id)) | ||
927 | # 触发比对 | ||
928 | try: | 892 | try: |
929 | # pass | 893 | # 更新OCR累计识别结果表 |
930 | compare.apply_async((doc.application_id, business_type, None, res_obj.id), | 894 | result_class = HILOCRResult if business_type == consts.HIL_PREFIX else AFCOCRResult |
931 | queue='queue_compare') | 895 | res_obj = result_class.objects.filter(application_id=doc.application_id).first() |
896 | if res_obj is None: | ||
897 | res_obj = result_class() | ||
898 | res_obj.application_id = doc.application_id | ||
899 | for classify, field in consts.RESULT_MAPPING.items(): | ||
900 | license_list = license_summary.get(classify) | ||
901 | if not license_list: | ||
902 | continue | ||
903 | if classify == consts.IC_CLASSIFY and ic_merge: | ||
904 | license_list[0].update(license_list[1]) | ||
905 | license_list.pop(1) | ||
906 | elif classify == consts.RP_CLASSIFY and rp_merge: | ||
907 | license_list[0].update(license_list[1]) | ||
908 | license_list.pop(1) | ||
909 | if not hasattr(res_obj, field): | ||
910 | continue | ||
911 | old_res_str = getattr(res_obj, field) | ||
912 | if old_res_str is None: | ||
913 | last_res_str = json.dumps(license_list) | ||
914 | else: | ||
915 | old_res_list = json.loads(old_res_str) | ||
916 | old_res_list.extend(license_list) | ||
917 | last_res_str = json.dumps(old_res_list) | ||
918 | setattr(res_obj, field, last_res_str) | ||
919 | res_obj.save() | ||
932 | except Exception as e: | 920 | except Exception as e: |
933 | self.online_log.error( | 921 | self.online_log.error( |
934 | '{0} [process error (comparison info send)] [task={1}] [error={2}]'.format( | 922 | '{0} [process error (ocr result save)] [task={1}] [error={2}]'.format( |
935 | self.log_base, task_str, traceback.format_exc())) | 923 | self.log_base, task_str, traceback.format_exc())) |
936 | else: | 924 | else: |
937 | self.online_log.info('{0} [comparison info send success] [task={1}] ' | 925 | self.online_log.info('{0} [ocr result save success] [task={1}] [res_id={2}]'.format( |
938 | '[res_id={2}]'.format(self.log_base, task_str, res_obj.id)) | 926 | self.log_base, task_str, res_obj.id)) |
927 | # 触发比对 | ||
928 | try: | ||
929 | # pass | ||
930 | compare.apply_async((doc.application_id, business_type, None, res_obj.id), | ||
931 | queue='queue_compare') | ||
932 | except Exception as e: | ||
933 | self.online_log.error( | ||
934 | '{0} [process error (comparison info send)] [task={1}] [error={2}]'.format( | ||
935 | self.log_base, task_str, traceback.format_exc())) | ||
936 | else: | ||
937 | self.online_log.info('{0} [comparison info send success] [task={1}] ' | ||
938 | '[res_id={2}]'.format(self.log_base, task_str, res_obj.id)) | ||
939 | finally: | 939 | finally: |
940 | try: | 940 | try: |
941 | img_save_path = os.path.join(doc_data_path, 'img') | 941 | img_save_path = os.path.join(doc_data_path, 'img') | ... | ... |
... | @@ -443,8 +443,7 @@ class DocView(GenericView, DocHandler): | ... | @@ -443,8 +443,7 @@ class DocView(GenericView, DocHandler): |
443 | 443 | ||
444 | file.close() | 444 | file.close() |
445 | # 1. 上传信息记录 | 445 | # 1. 上传信息记录 |
446 | # application_id = '{0}{1}'.format(consts.FIXED_APPLICATION_ID_PREFIX, metadata_version_id) | 446 | application_id = '{0}{1}'.format(consts.FIXED_APPLICATION_ID_PREFIX, metadata_version_id) |
447 | application_id = 'CH-S200012727' | ||
448 | upload_finish_time = timezone.now() | 447 | upload_finish_time = timezone.now() |
449 | document_scheme = random.choice(consts.DOC_SCHEME_LIST) | 448 | document_scheme = random.choice(consts.DOC_SCHEME_LIST) |
450 | data_source = random.choice(consts.DATA_SOURCE_LIST) | 449 | data_source = random.choice(consts.DATA_SOURCE_LIST) | ... | ... |
-
Please register or sign in to post a comment