Merge branch 'feature/license' into feature/mssql
Showing
3 changed files
with
14 additions
and
9 deletions
This diff is collapsed.
Click to expand it.
| ... | @@ -159,6 +159,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -159,6 +159,7 @@ class Command(BaseCommand, LoggerMixin): |
| 159 | ed_list.append(summary[6]) | 159 | ed_list.append(summary[6]) |
| 160 | 160 | ||
| 161 | def license1_process(self, ocr_data, license_summary, classify, skip_img, img_path): | 161 | def license1_process(self, ocr_data, license_summary, classify, skip_img, img_path): |
| 162 | # 类别:'0'身份证, '1'居住证 | ||
| 162 | license_data = ocr_data.get('data', []) | 163 | license_data = ocr_data.get('data', []) |
| 163 | if not license_data: | 164 | if not license_data: |
| 164 | skip_img.append(self.parse_img_path(img_path)) | 165 | skip_img.append(self.parse_img_path(img_path)) |
| ... | @@ -174,7 +175,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -174,7 +175,7 @@ class Command(BaseCommand, LoggerMixin): |
| 174 | # res_dict[chn_key] = ocr_res_2.get(en_key, '') | 175 | # res_dict[chn_key] = ocr_res_2.get(en_key, '') |
| 175 | license_summary.setdefault(classify, []).append(ocr_res_2) | 176 | license_summary.setdefault(classify, []).append(ocr_res_2) |
| 176 | else: | 177 | else: |
| 177 | # 营业执照、行驶证等 | 178 | # 营业执照等 |
| 178 | for result_dict in ocr_res_2.get('ResultList', []): | 179 | for result_dict in ocr_res_2.get('ResultList', []): |
| 179 | res_dict = {} | 180 | res_dict = {} |
| 180 | for field_dict in result_dict.get('FieldList', []): | 181 | for field_dict in result_dict.get('FieldList', []): |
| ... | @@ -224,7 +225,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -224,7 +225,7 @@ class Command(BaseCommand, LoggerMixin): |
| 224 | elif classify in consts.LICENSE_CLASSIFY_SET_1: # 证件1 | 225 | elif classify in consts.LICENSE_CLASSIFY_SET_1: # 证件1 |
| 225 | self.license1_process(ocr_data, license_summary, classify, skip_img, img_path) | 226 | self.license1_process(ocr_data, license_summary, classify, skip_img, img_path) |
| 226 | elif classify in consts.LICENSE_CLASSIFY_SET_2: # 证件2 | 227 | elif classify in consts.LICENSE_CLASSIFY_SET_2: # 证件2 |
| 227 | pid, _, _ = consts.LICENSE_CLASSIFY_MAPPING.get(classify) | 228 | pid, _, _, _, _ = consts.LICENSE_CLASSIFY_MAPPING.get(classify) |
| 228 | json_data_2 = { | 229 | json_data_2 = { |
| 229 | "pid": str(pid), | 230 | "pid": str(pid), |
| 230 | "key": conf.OCR_KEY, | 231 | "key": conf.OCR_KEY, |
| ... | @@ -490,8 +491,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -490,8 +491,7 @@ class Command(BaseCommand, LoggerMixin): |
| 490 | # 识别失败:普通异常,如PDF异常、构建过程异常 | 491 | # 识别失败:普通异常,如PDF异常、构建过程异常 |
| 491 | # EDMS异常:下载异常-->回队列-->邮件;上传异常-->重新上传队列-->邮件 | 492 | # EDMS异常:下载异常-->回队列-->邮件;上传异常-->重新上传队列-->邮件 |
| 492 | # 算法异常:第一道异常-->识别失败-->邮件;第二道异常-->识别失败-->邮件 | 493 | # 算法异常:第一道异常-->识别失败-->邮件;第二道异常-->识别失败-->邮件 |
| 493 | # TODO 协程异步发送OCR请求 | 494 | # TODO OCR接口调用重试 |
| 494 | # TODO 调用接口重试 | ||
| 495 | # TODO 数据库断联问题 | 495 | # TODO 数据库断联问题 |
| 496 | def handle(self, *args, **kwargs): | 496 | def handle(self, *args, **kwargs): |
| 497 | sleep_second = int(conf.SLEEP_SECOND) | 497 | sleep_second = int(conf.SLEEP_SECOND) | ... | ... |
| ... | @@ -360,15 +360,20 @@ class BSWorkbook(Workbook): | ... | @@ -360,15 +360,20 @@ class BSWorkbook(Workbook): |
| 360 | self.remove(self.get_sheet_by_name(sheet)) | 360 | self.remove(self.get_sheet_by_name(sheet)) |
| 361 | 361 | ||
| 362 | def license_rebuild(self, license_summary, document_scheme): | 362 | def license_rebuild(self, license_summary, document_scheme): |
| 363 | for classify, (_, name, field_order) in consts.LICENSE_ORDER: | 363 | for classify, (_, name, field_order, side_diff, scheme_diff) in consts.LICENSE_ORDER: |
| 364 | # 机动车登记证:CA和SE不同顺序 | ||
| 365 | if classify == consts.MVC_CLASSIFY and document_scheme == consts.DOC_SCHEME_LIST[1]: | ||
| 366 | field_order = consts.MVC_SE_FIELD_ORDER | ||
| 367 | license_list = license_summary.get(classify) | 364 | license_list = license_summary.get(classify) |
| 368 | if license_list is None: | 365 | if not license_list: |
| 369 | continue | 366 | continue |
| 370 | ws = self.create_sheet(name) | 367 | ws = self.create_sheet(name) |
| 368 | if scheme_diff and document_scheme == consts.DOC_SCHEME_LIST[1]: | ||
| 369 | classify = consts.MVC_CLASSIFY_SE | ||
| 371 | for license_dict in license_list: | 370 | for license_dict in license_list: |
| 371 | if classify == consts.IC_CLASSIFY and license_dict.get('类别') == '1': | ||
| 372 | license_summary.setdefault(consts.RP_CLASSIFY, []).append(license_dict) | ||
| 373 | continue | ||
| 374 | if side_diff: | ||
| 375 | key, field_order_yes, field_order_no = consts.FIELD_ORDER_MAP.get(classify) | ||
| 376 | field_order = field_order_yes if key in license_dict else field_order_no | ||
| 372 | for search_field, write_field in field_order: | 377 | for search_field, write_field in field_order: |
| 373 | ws.append((write_field, license_dict.get(search_field, ''))) | 378 | ws.append((write_field, license_dict.get(search_field, ''))) |
| 374 | ws.append((None, )) | 379 | ws.append((None, )) | ... | ... |
-
Please register or sign in to post a comment