add hil contract
Showing
3 changed files
with
34 additions
and
13 deletions
| ... | @@ -1008,6 +1008,24 @@ JYPZ_FIELD_ORDER = (("type", "标题"), | ... | @@ -1008,6 +1008,24 @@ JYPZ_FIELD_ORDER = (("type", "标题"), |
| 1008 | CONTRACT_CN_NAME = '合同' | 1008 | CONTRACT_CN_NAME = '合同' |
| 1009 | CONTRACT_CLASSIFY = 41 | 1009 | CONTRACT_CLASSIFY = 41 |
| 1010 | 1010 | ||
| 1011 | HIL_CONTRACT_1_CN_NAME = '售后回租合同' | ||
| 1012 | HIL_CONTRACT_1_CLASSIFY = 43 | ||
| 1013 | |||
| 1014 | HIL_CONTRACT_2_CN_NAME = '车辆租赁抵押合同' | ||
| 1015 | HIL_CONTRACT_2_CLASSIFY = 44 | ||
| 1016 | |||
| 1017 | HIL_CONTRACT_3_CN_NAME = '车辆处置协议' | ||
| 1018 | HIL_CONTRACT_3_CLASSIFY = 45 | ||
| 1019 | |||
| 1020 | CONTRACT_SET = {CONTRACT_CLASSIFY, HIL_CONTRACT_1_CLASSIFY, HIL_CONTRACT_2_CLASSIFY, HIL_CONTRACT_3_CLASSIFY} | ||
| 1021 | |||
| 1022 | CONTRACT_MAP = { | ||
| 1023 | HIL_CONTRACT_1_CLASSIFY: HIL_CONTRACT_1_CN_NAME, | ||
| 1024 | HIL_CONTRACT_2_CLASSIFY: HIL_CONTRACT_2_CN_NAME, | ||
| 1025 | HIL_CONTRACT_3_CLASSIFY: HIL_CONTRACT_3_CN_NAME, | ||
| 1026 | CONTRACT_CLASSIFY: CONTRACT_CN_NAME, | ||
| 1027 | } | ||
| 1028 | |||
| 1011 | # 保单 | 1029 | # 保单 |
| 1012 | INSURANCE_CN_NAME = '保单' | 1030 | INSURANCE_CN_NAME = '保单' |
| 1013 | INSURANCE_CLASSIFY = 42 | 1031 | INSURANCE_CLASSIFY = 42 | ... | ... |
| ... | @@ -207,7 +207,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -207,7 +207,7 @@ class Command(BaseCommand, LoggerMixin): |
| 207 | else: | 207 | else: |
| 208 | res_list.append((pno, ino, part_idx, consts.RES_SUCCESS_EMPTY)) | 208 | res_list.append((pno, ino, part_idx, consts.RES_SUCCESS_EMPTY)) |
| 209 | 209 | ||
| 210 | def contract_process(self, ocr_data, contract_result, res_list, pno, ino, part_idx, img_path): | 210 | def contract_process(self, classify, ocr_data, contract_result, res_list, pno, ino, part_idx, img_path): |
| 211 | contract_dict = ocr_data.get('data') | 211 | contract_dict = ocr_data.get('data') |
| 212 | if not contract_dict or contract_dict.get('page_num') is None or contract_dict.get('page_info') is None: | 212 | if not contract_dict or contract_dict.get('page_num') is None or contract_dict.get('page_info') is None: |
| 213 | res_list.append((pno, ino, part_idx, consts.RES_SUCCESS_EMPTY)) | 213 | res_list.append((pno, ino, part_idx, consts.RES_SUCCESS_EMPTY)) |
| ... | @@ -243,7 +243,8 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -243,7 +243,8 @@ class Command(BaseCommand, LoggerMixin): |
| 243 | for row_list in sub_value[text_key]: | 243 | for row_list in sub_value[text_key]: |
| 244 | rebuild_page_info.append(row_list) | 244 | rebuild_page_info.append(row_list) |
| 245 | 245 | ||
| 246 | contract_result.setdefault(page_num, []).append(rebuild_page_info) | 246 | # contract_result.setdefault(page_num, []).append(rebuild_page_info) |
| 247 | contract_result.setdefault(classify, dict()).setdefault(page_num, []).append(rebuild_page_info) | ||
| 247 | 248 | ||
| 248 | 249 | ||
| 249 | def license1_process(self, ocr_data, license_summary, classify, res_list, pno, ino, part_idx, img_path, do_dda, dda_id_bc_mapping): | 250 | def license1_process(self, ocr_data, license_summary, classify, res_list, pno, ino, part_idx, img_path, do_dda, dda_id_bc_mapping): |
| ... | @@ -745,7 +746,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -745,7 +746,7 @@ class Command(BaseCommand, LoggerMixin): |
| 745 | text_list = [] | 746 | text_list = [] |
| 746 | else: | 747 | else: |
| 747 | text_list = [] | 748 | text_list = [] |
| 748 | img_queue.put((img_path, text_list)) | 749 | img_queue.put((business_type, img_path, text_list)) |
| 749 | # except EDMSException as e: | 750 | # except EDMSException as e: |
| 750 | # try: | 751 | # try: |
| 751 | # doc.status = DocStatus.PROCESS_FAILED.value | 752 | # doc.status = DocStatus.PROCESS_FAILED.value |
| ... | @@ -790,7 +791,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -790,7 +791,7 @@ class Command(BaseCommand, LoggerMixin): |
| 790 | def img_2_ocr_1(self, img_queue, todo_count_dict, res_dict, finish_queue, lock, url, error_list): | 791 | def img_2_ocr_1(self, img_queue, todo_count_dict, res_dict, finish_queue, lock, url, error_list): |
| 791 | while len(error_list) == 0 or not img_queue.empty(): | 792 | while len(error_list) == 0 or not img_queue.empty(): |
| 792 | try: | 793 | try: |
| 793 | img_path, text_list = img_queue.get(block=False) | 794 | channel, img_path, text_list = img_queue.get(block=False) |
| 794 | except Exception as e: | 795 | except Exception as e: |
| 795 | # self.online_log.info('{0} [img_2_ocr_1] [queue empty]'.format(self.log_base)) | 796 | # self.online_log.info('{0} [img_2_ocr_1] [queue empty]'.format(self.log_base)) |
| 796 | time.sleep(self.sleep_time_img_get) | 797 | time.sleep(self.sleep_time_img_get) |
| ... | @@ -806,7 +807,8 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -806,7 +807,8 @@ class Command(BaseCommand, LoggerMixin): |
| 806 | # 获取解码后的base64值 | 807 | # 获取解码后的base64值 |
| 807 | file_data = base64_data.decode() | 808 | file_data = base64_data.decode() |
| 808 | json_data_1 = { | 809 | json_data_1 = { |
| 809 | "file": file_data | 810 | "file": file_data, |
| 811 | "channel": channel, | ||
| 810 | } | 812 | } |
| 811 | if len(text_list) > 0: | 813 | if len(text_list) > 0: |
| 812 | json_data_1['text_list'] = text_list | 814 | json_data_1['text_list'] = text_list |
| ... | @@ -984,9 +986,9 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -984,9 +986,9 @@ class Command(BaseCommand, LoggerMixin): |
| 984 | res_list.append((pno, ino, part_idx, consts.RES_FAILED_2)) | 986 | res_list.append((pno, ino, part_idx, consts.RES_FAILED_2)) |
| 985 | self.online_log.warn( | 987 | self.online_log.warn( |
| 986 | '{0} [ocr_2 failed] [img_path={1}]'.format(self.log_base, img_path)) | 988 | '{0} [ocr_2 failed] [img_path={1}]'.format(self.log_base, img_path)) |
| 987 | elif classify == consts.CONTRACT_CLASSIFY: | 989 | elif classify in consts.CONTRACT_SET: |
| 988 | self.contract_process(ocr_data, contract_result, res_list, pno, ino, | 990 | self.contract_process(classify, ocr_data, contract_result, res_list, pno, |
| 989 | part_idx, img_path) | 991 | ino, part_idx, img_path) |
| 990 | else: # 流水处理 | 992 | else: # 流水处理 |
| 991 | bs_classify_set.add(classify) | 993 | bs_classify_set.add(classify) |
| 992 | self.bs_process(wb, ocr_data, bs_summary, unknown_summary, classify, res_list, pno, ino, part_idx) | 994 | self.bs_process(wb, ocr_data, bs_summary, unknown_summary, classify, res_list, pno, ino, part_idx) |
| ... | @@ -1018,7 +1020,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -1018,7 +1020,7 @@ class Command(BaseCommand, LoggerMixin): |
| 1018 | 1020 | ||
| 1019 | self.online_log.info('{0} [task={1}] [merged_bs_summary={2}] [license_summary={3}] [contract={4}] ' | 1021 | self.online_log.info('{0} [task={1}] [merged_bs_summary={2}] [license_summary={3}] [contract={4}] ' |
| 1020 | '[res_list={5}]'.format(self.log_base, task_str, merged_bs_summary, | 1022 | '[res_list={5}]'.format(self.log_base, task_str, merged_bs_summary, |
| 1021 | contract_result, license_summary, res_list)) | 1023 | license_summary, contract_result, res_list)) |
| 1022 | 1024 | ||
| 1023 | except Exception as e: | 1025 | except Exception as e: |
| 1024 | 1026 | ... | ... |
| ... | @@ -702,11 +702,12 @@ class BSWorkbook(Workbook): | ... | @@ -702,11 +702,12 @@ class BSWorkbook(Workbook): |
| 702 | if field_str is not None: | 702 | if field_str is not None: |
| 703 | count_list.append((field_str, count)) | 703 | count_list.append((field_str, count)) |
| 704 | 704 | ||
| 705 | def contract_rebuild(self, contract_result): | 705 | def contract_rebuild(self, contract_result_dict): |
| 706 | for classify, contract_result in contract_result_dict.items(): | ||
| 706 | if len(contract_result) == 0: | 707 | if len(contract_result) == 0: |
| 707 | return | 708 | continue |
| 708 | ws = self.create_sheet(consts.CONTRACT_SHEET_NAME) | 709 | ws = self.create_sheet(consts.CONTRACT_MAP.get(classify)) |
| 709 | for i in range(15): | 710 | for i in range(30): |
| 710 | if str(i) in contract_result: | 711 | if str(i) in contract_result: |
| 711 | page_num = str(i) | 712 | page_num = str(i) |
| 712 | info_list = contract_result.get(page_num) | 713 | info_list = contract_result.get(page_num) | ... | ... |
-
Please register or sign in to post a comment