d4126306 by 王聪

Merge branch 'feature/pres-3034' into 'feature/uat-tmp'

Feature/pres 3034

See merge request !1
2 parents 41e2b260 7edab924
......@@ -7,6 +7,7 @@ from . import consts
from prese.compare import pre_compare, get_empty_result
from common.mixins import LoggerMixin
from settings import conf
from pos.consts import DocumentType
class MPOSHandler:
......@@ -211,12 +212,7 @@ class PosHandler:
return result_obj
@staticmethod
def de_mortgage_ocr_process1(img_base64):
result_obj = {
'customerName': '',
'application': '',
'deMortgageDate': ''
}
def greenbook_process(result_obj, img_base64):
url = conf.OCR_URL_FOLDER
json_data = {"file": img_base64, "classify": consts.MVC_CLASSIFY, "version": "green"}
try:
......@@ -227,7 +223,7 @@ class PosHandler:
LoggerMixin.exception_log.error(
"[PosHandler de_mortgage_ocr_process1] request error, url: %s, response: %s",
url, response.text)
return result_obj
return
result = response.json()
data = result.get('data', [])
for item in data:
......@@ -238,7 +234,7 @@ class PosHandler:
for registration in registration_bar:
if registration.get('register_type', '') == '抵押登记':
register_info = registration.get('register_info', {})
result_obj['application'] = register_info.get('抵押权人姓名/名称', '')
result_obj['applicationName'] = register_info.get('抵押权人姓名/名称', '')
elif registration.get('register_type', '') == '解除抵押':
register_info = registration.get('register_info', {})
result_obj['deMortgageDate'] = register_info.get('解除抵押日期', '')
......@@ -248,5 +244,18 @@ class PosHandler:
if word_result.get('chinese_key', '') == '1.机动车所有人/身份证名称/号码':
result_obj['customerName'] = word_result.get('words', '').split('/')[0]
except Exception as e:
LoggerMixin.exception_log.error("[PosHandler de_mortgage_ocr_process1] error", exc_info=1)
LoggerMixin.exception_log.error("[PosHandler greenbook_process] error", exc_info=1)
@staticmethod
def de_mortgage_ocr_process1(file_obj):
result_obj = {
'customerName': '',
'applicationName': '',
'deMortgageDate': ''
}
doc_type = file_obj.get('documentType', '')
img_base64 = file_obj.get('fileBase64')
if doc_type == DocumentType.GREEN_BOOK.value.en_name:
PosHandler.greenbook_process(result_obj, img_base64)
return result_obj
......
......@@ -244,6 +244,9 @@ se_compare_content = {
'customerType': fields.Str(required=True, validate=validate.OneOf(consts.CUSTOMER_TYPE)),
"firstSubmmisonDate": CustomDate(required=True),
'propertyDocumentPolicy': fields.Str(required=False, validate=validate.Length(max=16)),
'fsmFlag': fields.Boolean(required=False),
'fsmSpecialCar': fields.Boolean(required=False),
'fsmBestPrice': fields.Boolean(required=False),
'isAutoSettlement': fields.Boolean(required=False),
'individualCusInfo': fields.List(fields.Nested(se_individual_args),
......@@ -813,6 +816,11 @@ class SECompareView(GenericView, PreSEHandler):
uniq_seq = content.get('uniqSeq')
bank_verify = content.get('bankInfo', {}).get('bankVerificationStatus', '')
# fsm
fsm_flag = content.get('fsmFlag', False)
fsm_special_car = content.get('fsmSpecialCar', False)
fsm_best_price = content.get('fsmBestPrice', False)
# 存库, 用于银行卡比对
try:
bank_class = HILbankVerification if business_type in consts.HIL_SET else AFCbankVerification
......
from enum import Enum
class DocumentTypeModel:
def __init__(self, code, en_name, cn_name):
self.code = code;
self.en_name = en_name
self.cn_name = cn_name
class DocumentType(Enum):
GREEN_BOOK = DocumentTypeModel("DTGBK", "Green Book", "机动车登记证")
CONFIRMATION_LETTER = DocumentTypeModel("DTCLE", "Confirmation Letter", "解抵押确认函")
WEBSITE_SCREENSHOT = DocumentTypeModel("DTWES", "Website Screenshot", "网页截图")
if __name__ == '__main__':
print(DocumentType.GREEN_BOOK.value.en_name)
......@@ -53,17 +53,22 @@ class NSCInvoiceView(GenericView):
return response.ok()
file_param = {
'documentType': fields.Str(required=True, validate=validate.Length(max=20)),
'fileBase64': fields.Str(required=True),
}
de_mortgage_args = {
'customerName': fields.Str(required=True, validate=validate.Length(max=64)),
'application': fields.Str(required=True, validate=validate.Length(max=64)),
'applicationName': fields.Str(required=True, validate=validate.Length(max=64)),
'deMortgageDate': fields.Date(required=True),
'file_base64': fields.List(fields.Str(), required=True, validate=validate.Length(min=1)),
'files': fields.Nested(file_param, required=True),
}
de_mortgage_comments = {
'customerName': ('机动车所有人识别不一致', ),
'application': ('抵押权人姓名/名称识别不一致', ),
'applicationName': ('抵押权人姓名/名称识别不一致', ),
'deMortgageDate': ('解除抵押日期不一致', )
}
......@@ -75,20 +80,20 @@ class DeMortgageView(GenericView):
@use_args(de_mortgage_args, location='data')
def post(self, request, args): # interface_report mpos to ocr
img_files = args.get('file_base64', [])
files = args.get('files', [])
customer_name = args.get('customerName', '')
application = args.get('application', '')
application_name = args.get('applicationName', '')
de_mortgage_date = args.get('deMortgageDate')
fields_input = {
'customerName': customer_name,
'application': application,
'applicationName': application_name,
'deMortgageDate': de_mortgage_date
}
de_mortgage_info = {}
# 绿本必须分开ocr
for img_file in img_files:
info = PosHandler.de_mortgage_ocr_process1(img_file)
for file_obj in files:
info = PosHandler.de_mortgage_ocr_process1(file_obj)
de_mortgage_info.update(info)
request_pass = True
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!