59da79a4 by 周伟奇

slice part 1

1 parent 85d82a3e
...@@ -1542,6 +1542,9 @@ BC_FIELD_ORDER_2 = (('BankName', '发卡行名称'), ...@@ -1542,6 +1542,9 @@ BC_FIELD_ORDER_2 = (('BankName', '发卡行名称'),
1542 1542
1543 IMG_PATH_KEY = 'uniq_img_path_key' 1543 IMG_PATH_KEY = 'uniq_img_path_key'
1544 IMG_PATH_KEY_2 = 'uniq_img_path_key_2' 1544 IMG_PATH_KEY_2 = 'uniq_img_path_key_2'
1545 POSITION_KEY = 'uniq_position_key'
1546 SECTION_KEY = 'uniq_section_key'
1547 ANGLE_KEY = 'uniq_angle_key'
1545 1548
1546 INFO_SOURCE = ['POS', 'CMS'] 1549 INFO_SOURCE = ['POS', 'CMS']
1547 1550
......
...@@ -373,7 +373,7 @@ class Command(BaseCommand, LoggerMixin): ...@@ -373,7 +373,7 @@ class Command(BaseCommand, LoggerMixin):
373 license_summary.setdefault(classify, []).extend(license_data) 373 license_summary.setdefault(classify, []).extend(license_data)
374 res_list.append((pno, ino, part_idx, consts.RES_SUCCESS)) 374 res_list.append((pno, ino, part_idx, consts.RES_SUCCESS))
375 375
376 def license2_process(self, ocr_res_2, license_summary, pid, classify, res_list, pno, ino, part_idx, img_path, do_dda, dda_id_bc_mapping): 376 def license2_process(self, ocr_res_2, license_summary, pid, classify, res_list, pno, ino, part_idx, img_path, do_dda, dda_id_bc_mapping, section_img_path=None):
377 if ocr_res_2.get('ErrorCode') in consts.SUCCESS_CODE_SET: 377 if ocr_res_2.get('ErrorCode') in consts.SUCCESS_CODE_SET:
378 res_list.append((pno, ino, part_idx, consts.RES_SUCCESS)) 378 res_list.append((pno, ino, part_idx, consts.RES_SUCCESS))
379 if pid == consts.BC_PID: 379 if pid == consts.BC_PID:
...@@ -390,10 +390,17 @@ class Command(BaseCommand, LoggerMixin): ...@@ -390,10 +390,17 @@ class Command(BaseCommand, LoggerMixin):
390 else: 390 else:
391 # 营业执照等 391 # 营业执照等
392 for result_dict in ocr_res_2.get('ResultList', []): 392 for result_dict in ocr_res_2.get('ResultList', []):
393 position = result_dict.get('position', {})
394 angle = result_dict.get('angle', 0)
393 res_dict = {} 395 res_dict = {}
396 position_dict = {}
394 for field_dict in result_dict.get('FieldList', []): 397 for field_dict in result_dict.get('FieldList', []):
395 res_dict[field_dict.get('chn_key', '')] = field_dict.get('value', '') 398 res_dict[field_dict.get('chn_key', '')] = field_dict.get('value', '')
396 res_dict[consts.IMG_PATH_KEY] = img_path 399 position_dict[field_dict.get('chn_key', '')] = field_dict.get('position', [])
400 position_dict[consts.SECTION_KEY] = position
401 position_dict[consts.ANGLE_KEY] = angle
402 res_dict[consts.IMG_PATH_KEY] = section_img_path if isinstance(section_img_path, str) else img_path
403 res_dict[consts.POSITION_KEY] = position_dict
397 license_summary.setdefault(classify, []).append(res_dict) 404 license_summary.setdefault(classify, []).append(res_dict)
398 else: 405 else:
399 res_list.append((pno, ino, part_idx, consts.RES_FAILED_2)) 406 res_list.append((pno, ino, part_idx, consts.RES_FAILED_2))
...@@ -972,9 +979,23 @@ class Command(BaseCommand, LoggerMixin): ...@@ -972,9 +979,23 @@ class Command(BaseCommand, LoggerMixin):
972 card_name_res.get('data', {}).get('is_exists_name') == 0: 979 card_name_res.get('data', {}).get('is_exists_name') == 0:
973 name = '无' 980 name = '无'
974 ocr_2_res['Name'] = name 981 ocr_2_res['Name'] = name
982
983 section_img_path = None
984 try:
985 if ocr_2_res.get('ErrorCode') in consts.SUCCESS_CODE_SET:
986 pre, suf = os.path.splitext(img_path)
987 section_img_path = '{0}_{1}{2}'.format(pre, part_idx, suf)
988 with open(section_img_path, "wb") as fh:
989 fh.write(base64.b64decode(file_data.encode()))
990 except Exception as e:
991 self.online_log.warn(
992 '{0} [section img save failed] [img_path={1}]'
993 ' [part_idx={2}]'.format(self.log_base, img_path, part_idx))
994
975 self.license2_process(ocr_2_res, license_summary, pid, classify, 995 self.license2_process(ocr_2_res, license_summary, pid, classify,
976 res_list, pno, ino, part_idx, img_path, 996 res_list, pno, ino, part_idx, img_path,
977 do_dda, dda_id_bc_mapping) 997 do_dda, dda_id_bc_mapping,
998 section_img_path=section_img_path)
978 break 999 break
979 else: 1000 else:
980 res_list.append((pno, ino, part_idx, consts.RES_FAILED_2)) 1001 res_list.append((pno, ino, part_idx, consts.RES_FAILED_2))
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!