f085b3b6 by 周伟奇

fix bug

1 parent a94ce721
......@@ -259,7 +259,7 @@ class Command(BaseCommand, LoggerMixin):
for c, res_list in all_res.items():
sheet_name, key_field, side_field_order, src_field_order = self.field_map.get(c)
ws = wb.create_sheet(sheet_name)
for res in all_res:
for res in res_list:
if key_field is not None and key_field in res:
field_order = side_field_order
else:
......@@ -293,8 +293,9 @@ class Command(BaseCommand, LoggerMixin):
file_data = base64_data.decode()
json_data = {
"file": file_data,
"channel": consts.AFC_PREFIX,
}
if len(seperate_path_map) > 0:
if len(seperate_path_map) == 0:
json_data["classify"] = classify
for times in range(consts.RETRY_TIMES):
......@@ -318,19 +319,20 @@ class Command(BaseCommand, LoggerMixin):
data_list = ocr_res.get('data', [])
if isinstance(data_list, list):
for ocr_data in data_list:
if ocr_data.get('classify') in seperate_path_map or ocr_data.get('classify') == classify:
if ocr_data.get('classify') in seperate_path_map:
seperate_dir = seperate_path_map[ocr_data.get('classify')]
new_classify = ocr_data.get('classify')
if new_classify in seperate_path_map or new_classify == classify:
if new_classify in seperate_path_map:
seperate_dir = seperate_path_map[new_classify]
os.makedirs(seperate_dir, exist_ok=True)
real_dst = os.path.join(seperate_dir, self.basename(img_path))
if not os.path.exists(real_dst):
shutil.move(img_path, seperate_dir)
if classify in consts.LICENSE_CLASSIFY_SET_1:
self.license1_process(ocr_data, all_res, classify)
elif classify in consts.LICENSE_CLASSIFY_SET_2:
self.license2_process(ocr_data, all_res, classify, img_path)
elif classify in consts.CONTRACT_SET:
self.contract_process(ocr_data, contract_result, classify)
if new_classify in consts.LICENSE_CLASSIFY_SET_1:
self.license1_process(ocr_data, all_res, new_classify)
elif new_classify in consts.LICENSE_CLASSIFY_SET_2:
self.license2_process(ocr_data, all_res, new_classify, img_path)
elif new_classify in consts.CONTRACT_SET:
self.contract_process(ocr_data, contract_result, new_classify)
break
else:
self.folder_log.warn('{0} [ocr failed] [img_path={1}]'.format(self.log_base, img_path))
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!