add bank card name
Showing
3 changed files
with
23 additions
and
3 deletions
| ... | @@ -836,7 +836,8 @@ BC_PID = 4 | ... | @@ -836,7 +836,8 @@ BC_PID = 4 |
| 836 | # ('Date', '日期')) | 836 | # ('Date', '日期')) |
| 837 | BC_FIELD_ORDER = (('BankName', '发卡行名称'), | 837 | BC_FIELD_ORDER = (('BankName', '发卡行名称'), |
| 838 | ('CardNum', '银行卡号'), | 838 | ('CardNum', '银行卡号'), |
| 839 | ('CardType', '银行卡类型'),) | 839 | ('CardType', '银行卡类型'), |
| 840 | ('Name', '持卡人姓名'),) | ||
| 840 | 841 | ||
| 841 | SUCCESS_CODE_SET = {'0', 0} | 842 | SUCCESS_CODE_SET = {'0', 0} |
| 842 | 843 | ... | ... |
| ... | @@ -34,6 +34,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -34,6 +34,7 @@ class Command(BaseCommand, LoggerMixin): |
| 34 | # ocr相关 | 34 | # ocr相关 |
| 35 | self.ocr_url_1 = conf.OCR_URL_1 | 35 | self.ocr_url_1 = conf.OCR_URL_1 |
| 36 | self.ocr_url_2 = conf.OCR_URL_2 | 36 | self.ocr_url_2 = conf.OCR_URL_2 |
| 37 | self.ocr_url_3 = conf.BC_URL | ||
| 37 | # EDMS web_service_api | 38 | # EDMS web_service_api |
| 38 | self.edms = EDMS(conf.EDMS_USER, conf.EDMS_PWD) | 39 | self.edms = EDMS(conf.EDMS_USER, conf.EDMS_PWD) |
| 39 | # 优雅退出信号:15 | 40 | # 优雅退出信号:15 |
| ... | @@ -198,6 +199,13 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -198,6 +199,13 @@ class Command(BaseCommand, LoggerMixin): |
| 198 | if response.status == 200: | 199 | if response.status == 200: |
| 199 | return await response.json() | 200 | return await response.json() |
| 200 | 201 | ||
| 202 | @staticmethod | ||
| 203 | async def fetch_bc_name_result(url, json_data): | ||
| 204 | async with aiohttp.ClientSession(connector=aiohttp.TCPConnector(ssl=False)) as session: | ||
| 205 | async with session.post(url, data=json_data) as response: | ||
| 206 | if response.status == 200: | ||
| 207 | return await response.json() | ||
| 208 | |||
| 201 | async def img_2_ocr_2_wb(self, wb, img_path, bs_summary, unknown_summary, license_summary, skip_img): | 209 | async def img_2_ocr_2_wb(self, wb, img_path, bs_summary, unknown_summary, license_summary, skip_img): |
| 202 | with open(img_path, 'rb') as f: | 210 | with open(img_path, 'rb') as f: |
| 203 | base64_data = base64.b64encode(f.read()) | 211 | base64_data = base64.b64encode(f.read()) |
| ... | @@ -239,6 +247,13 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -239,6 +247,13 @@ class Command(BaseCommand, LoggerMixin): |
| 239 | # 识别结果 | 247 | # 识别结果 |
| 240 | self.cronjob_log.info('{0} [ocr_2 result] [img={1}] [res={2}]'.format( | 248 | self.cronjob_log.info('{0} [ocr_2 result] [img={1}] [res={2}]'.format( |
| 241 | self.log_base, img_path, ocr_res_2)) | 249 | self.log_base, img_path, ocr_res_2)) |
| 250 | if classify == consts.BC_CLASSIFY: | ||
| 251 | name = '有' | ||
| 252 | json_data_1['card_res'] = ocr_res_2 | ||
| 253 | card_name_res = await self.fetch_bc_name_result(self.ocr_url_3, json_data_1) | ||
| 254 | if card_name_res.get('code') == 1 and card_name_res.get('data', {}).get('is_exists_name') == 0: | ||
| 255 | name = '无' | ||
| 256 | ocr_res_2['Name'] = name | ||
| 242 | self.license2_process(ocr_res_2, license_summary, pid, classify, skip_img, img_path) | 257 | self.license2_process(ocr_res_2, license_summary, pid, classify, skip_img, img_path) |
| 243 | else: # 流水处理 | 258 | else: # 流水处理 |
| 244 | self.bs_process(wb, ocr_data, bs_summary, unknown_summary, img_path, classify, skip_img) | 259 | self.bs_process(wb, ocr_data, bs_summary, unknown_summary, img_path, classify, skip_img) | ... | ... |
| ... | @@ -281,10 +281,14 @@ class BSWorkbook(Workbook): | ... | @@ -281,10 +281,14 @@ class BSWorkbook(Workbook): |
| 281 | # 4.逗号与句号处理 | 281 | # 4.逗号与句号处理 |
| 282 | if len(res_str) >= 4: | 282 | if len(res_str) >= 4: |
| 283 | period_idx = len(res_str) - 3 | 283 | period_idx = len(res_str) - 3 |
| 284 | if res_str[period_idx] == '.' and res_str[period_idx - 1] == ',': | 284 | if res_str[period_idx] == '.' and res_str[period_idx - 1] in {',', '.'}: # 364,.92 364..92 |
| 285 | res_str = '{0}{1}'.format(res_str[:period_idx - 1], res_str[period_idx:]) | 285 | res_str = '{0}{1}'.format(res_str[:period_idx - 1], res_str[period_idx:]) |
| 286 | elif res_str[period_idx] == ',': | 286 | elif res_str[period_idx] == ',': |
| 287 | res_str = '{0}.{1}'.format(res_str[:period_idx], res_str[period_idx + 1:]) | 287 | if res_str[period_idx - 1] in {',', '.'}: # 364.,92 364,,92 |
| 288 | pre_idx = period_idx - 1 | ||
| 289 | else: # 364,92 | ||
| 290 | pre_idx = period_idx | ||
| 291 | res_str = '{0}.{1}'.format(res_str[:pre_idx], res_str[period_idx + 1:]) | ||
| 288 | return res_str | 292 | return res_str |
| 289 | 293 | ||
| 290 | def build_month_sheet(self, ms, card, month_mapping, is_reverse, statistics_header_info, max_column): | 294 | def build_month_sheet(self, ms, card, month_mapping, is_reverse, statistics_header_info, max_column): | ... | ... |
-
Please register or sign in to post a comment