14cd91c6 by 周伟奇

Merge branch 'feature/license' into feature/mssql

2 parents c8a54f58 623ca8c8
......@@ -836,7 +836,8 @@ BC_PID = 4
# ('Date', '日期'))
BC_FIELD_ORDER = (('BankName', '发卡行名称'),
('CardNum', '银行卡号'),
('CardType', '银行卡类型'),)
('CardType', '银行卡类型'),
('Name', '持卡人姓名'),)
SUCCESS_CODE_SET = {'0', 0}
......
......@@ -34,6 +34,7 @@ class Command(BaseCommand, LoggerMixin):
# ocr相关
self.ocr_url_1 = conf.OCR_URL_1
self.ocr_url_2 = conf.OCR_URL_2
self.ocr_url_3 = conf.BC_URL
# EDMS web_service_api
self.edms = EDMS(conf.EDMS_USER, conf.EDMS_PWD)
# 优雅退出信号:15
......@@ -198,6 +199,13 @@ class Command(BaseCommand, LoggerMixin):
if response.status == 200:
return await response.json()
@staticmethod
async def fetch_bc_name_result(url, json_data):
async with aiohttp.ClientSession(connector=aiohttp.TCPConnector(ssl=False)) as session:
async with session.post(url, json=json_data) as response:
if response.status == 200:
return await response.json()
async def img_2_ocr_2_wb(self, wb, img_path, bs_summary, unknown_summary, license_summary, skip_img):
with open(img_path, 'rb') as f:
base64_data = base64.b64encode(f.read())
......@@ -239,6 +247,13 @@ class Command(BaseCommand, LoggerMixin):
# 识别结果
self.cronjob_log.info('{0} [ocr_2 result] [img={1}] [res={2}]'.format(
self.log_base, img_path, ocr_res_2))
if classify == consts.BC_CLASSIFY:
name = '有'
json_data_1['card_res'] = ocr_res_2
card_name_res = await self.fetch_bc_name_result(self.ocr_url_3, json_data_1)
if card_name_res.get('code') == 1 and card_name_res.get('data', {}).get('is_exists_name') == 0:
name = '无'
ocr_res_2['Name'] = name
self.license2_process(ocr_res_2, license_summary, pid, classify, skip_img, img_path)
else: # 流水处理
self.bs_process(wb, ocr_data, bs_summary, unknown_summary, img_path, classify, skip_img)
......
......@@ -281,10 +281,14 @@ class BSWorkbook(Workbook):
# 4.逗号与句号处理
if len(res_str) >= 4:
period_idx = len(res_str) - 3
if res_str[period_idx] == '.' and res_str[period_idx - 1] == ',':
if res_str[period_idx] == '.' and res_str[period_idx - 1] in {',', '.'}: # 364,.92 364..92
res_str = '{0}{1}'.format(res_str[:period_idx - 1], res_str[period_idx:])
elif res_str[period_idx] == ',':
res_str = '{0}.{1}'.format(res_str[:period_idx], res_str[period_idx + 1:])
if res_str[period_idx - 1] in {',', '.'}: # 364.,92 364,,92
pre_idx = period_idx - 1
else: # 364,92
pre_idx = period_idx
res_str = '{0}.{1}'.format(res_str[:pre_idx], res_str[period_idx + 1:])
return res_str
def build_month_sheet(self, ms, card, month_mapping, is_reverse, statistics_header_info, max_column):
......@@ -352,7 +356,9 @@ class BSWorkbook(Workbook):
tmp_ws.append((summary_cell_value, date_cell_value, amount_cell_value))
# 贷款关键词高亮
elif summary_cell_value in self.loan_keyword:
summary_cell.fill = self.loan_fill
summary_cell.fill = self.amount_fill
if amount_cell is not None:
amount_cell.fill = self.amount_fill
# 3.3.余额转数值
over_success = False
......@@ -413,6 +419,8 @@ class BSWorkbook(Workbook):
del amount_mapping
for row in amount_fill_row:
new_ws[row][amount_cell_idx].fill = self.amount_fill
if summary_cell_idx is not None:
new_ws[row][summary_cell_idx].fill = self.amount_fill
# 关键词2信息提取
ms.append(self.blank_row)
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!