fix bug
Showing
1 changed file
with
13 additions
and
11 deletions
... | @@ -259,7 +259,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -259,7 +259,7 @@ class Command(BaseCommand, LoggerMixin): |
259 | for c, res_list in all_res.items(): | 259 | for c, res_list in all_res.items(): |
260 | sheet_name, key_field, side_field_order, src_field_order = self.field_map.get(c) | 260 | sheet_name, key_field, side_field_order, src_field_order = self.field_map.get(c) |
261 | ws = wb.create_sheet(sheet_name) | 261 | ws = wb.create_sheet(sheet_name) |
262 | for res in all_res: | 262 | for res in res_list: |
263 | if key_field is not None and key_field in res: | 263 | if key_field is not None and key_field in res: |
264 | field_order = side_field_order | 264 | field_order = side_field_order |
265 | else: | 265 | else: |
... | @@ -293,8 +293,9 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -293,8 +293,9 @@ class Command(BaseCommand, LoggerMixin): |
293 | file_data = base64_data.decode() | 293 | file_data = base64_data.decode() |
294 | json_data = { | 294 | json_data = { |
295 | "file": file_data, | 295 | "file": file_data, |
296 | "channel": consts.AFC_PREFIX, | ||
296 | } | 297 | } |
297 | if len(seperate_path_map) > 0: | 298 | if len(seperate_path_map) == 0: |
298 | json_data["classify"] = classify | 299 | json_data["classify"] = classify |
299 | 300 | ||
300 | for times in range(consts.RETRY_TIMES): | 301 | for times in range(consts.RETRY_TIMES): |
... | @@ -318,19 +319,20 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -318,19 +319,20 @@ class Command(BaseCommand, LoggerMixin): |
318 | data_list = ocr_res.get('data', []) | 319 | data_list = ocr_res.get('data', []) |
319 | if isinstance(data_list, list): | 320 | if isinstance(data_list, list): |
320 | for ocr_data in data_list: | 321 | for ocr_data in data_list: |
321 | if ocr_data.get('classify') in seperate_path_map or ocr_data.get('classify') == classify: | 322 | new_classify = ocr_data.get('classify') |
322 | if ocr_data.get('classify') in seperate_path_map: | 323 | if new_classify in seperate_path_map or new_classify == classify: |
323 | seperate_dir = seperate_path_map[ocr_data.get('classify')] | 324 | if new_classify in seperate_path_map: |
325 | seperate_dir = seperate_path_map[new_classify] | ||
324 | os.makedirs(seperate_dir, exist_ok=True) | 326 | os.makedirs(seperate_dir, exist_ok=True) |
325 | real_dst = os.path.join(seperate_dir, self.basename(img_path)) | 327 | real_dst = os.path.join(seperate_dir, self.basename(img_path)) |
326 | if not os.path.exists(real_dst): | 328 | if not os.path.exists(real_dst): |
327 | shutil.move(img_path, seperate_dir) | 329 | shutil.move(img_path, seperate_dir) |
328 | if classify in consts.LICENSE_CLASSIFY_SET_1: | 330 | if new_classify in consts.LICENSE_CLASSIFY_SET_1: |
329 | self.license1_process(ocr_data, all_res, classify) | 331 | self.license1_process(ocr_data, all_res, new_classify) |
330 | elif classify in consts.LICENSE_CLASSIFY_SET_2: | 332 | elif new_classify in consts.LICENSE_CLASSIFY_SET_2: |
331 | self.license2_process(ocr_data, all_res, classify, img_path) | 333 | self.license2_process(ocr_data, all_res, new_classify, img_path) |
332 | elif classify in consts.CONTRACT_SET: | 334 | elif new_classify in consts.CONTRACT_SET: |
333 | self.contract_process(ocr_data, contract_result, classify) | 335 | self.contract_process(ocr_data, contract_result, new_classify) |
334 | break | 336 | break |
335 | else: | 337 | else: |
336 | self.folder_log.warn('{0} [ocr failed] [img_path={1}]'.format(self.log_base, img_path)) | 338 | self.folder_log.warn('{0} [ocr failed] [img_path={1}]'.format(self.log_base, img_path)) | ... | ... |
-
Please register or sign in to post a comment