Merge branch 'feature/pres-3034' into 'feature/uat-tmp'
Feature/pres 3034 See merge request !1
Showing
4 changed files
with
57 additions
and
17 deletions
... | @@ -7,6 +7,7 @@ from . import consts | ... | @@ -7,6 +7,7 @@ from . import consts |
7 | from prese.compare import pre_compare, get_empty_result | 7 | from prese.compare import pre_compare, get_empty_result |
8 | from common.mixins import LoggerMixin | 8 | from common.mixins import LoggerMixin |
9 | from settings import conf | 9 | from settings import conf |
10 | from pos.consts import DocumentType | ||
10 | 11 | ||
11 | 12 | ||
12 | class MPOSHandler: | 13 | class MPOSHandler: |
... | @@ -211,12 +212,7 @@ class PosHandler: | ... | @@ -211,12 +212,7 @@ class PosHandler: |
211 | return result_obj | 212 | return result_obj |
212 | 213 | ||
213 | @staticmethod | 214 | @staticmethod |
214 | def de_mortgage_ocr_process1(img_base64): | 215 | def greenbook_process(result_obj, img_base64): |
215 | result_obj = { | ||
216 | 'customerName': '', | ||
217 | 'application': '', | ||
218 | 'deMortgageDate': '' | ||
219 | } | ||
220 | url = conf.OCR_URL_FOLDER | 216 | url = conf.OCR_URL_FOLDER |
221 | json_data = {"file": img_base64, "classify": consts.MVC_CLASSIFY, "version": "green"} | 217 | json_data = {"file": img_base64, "classify": consts.MVC_CLASSIFY, "version": "green"} |
222 | try: | 218 | try: |
... | @@ -227,7 +223,7 @@ class PosHandler: | ... | @@ -227,7 +223,7 @@ class PosHandler: |
227 | LoggerMixin.exception_log.error( | 223 | LoggerMixin.exception_log.error( |
228 | "[PosHandler de_mortgage_ocr_process1] request error, url: %s, response: %s", | 224 | "[PosHandler de_mortgage_ocr_process1] request error, url: %s, response: %s", |
229 | url, response.text) | 225 | url, response.text) |
230 | return result_obj | 226 | return |
231 | result = response.json() | 227 | result = response.json() |
232 | data = result.get('data', []) | 228 | data = result.get('data', []) |
233 | for item in data: | 229 | for item in data: |
... | @@ -238,7 +234,7 @@ class PosHandler: | ... | @@ -238,7 +234,7 @@ class PosHandler: |
238 | for registration in registration_bar: | 234 | for registration in registration_bar: |
239 | if registration.get('register_type', '') == '抵押登记': | 235 | if registration.get('register_type', '') == '抵押登记': |
240 | register_info = registration.get('register_info', {}) | 236 | register_info = registration.get('register_info', {}) |
241 | result_obj['application'] = register_info.get('抵押权人姓名/名称', '') | 237 | result_obj['applicationName'] = register_info.get('抵押权人姓名/名称', '') |
242 | elif registration.get('register_type', '') == '解除抵押': | 238 | elif registration.get('register_type', '') == '解除抵押': |
243 | register_info = registration.get('register_info', {}) | 239 | register_info = registration.get('register_info', {}) |
244 | result_obj['deMortgageDate'] = register_info.get('解除抵押日期', '') | 240 | result_obj['deMortgageDate'] = register_info.get('解除抵押日期', '') |
... | @@ -248,5 +244,18 @@ class PosHandler: | ... | @@ -248,5 +244,18 @@ class PosHandler: |
248 | if word_result.get('chinese_key', '') == '1.机动车所有人/身份证名称/号码': | 244 | if word_result.get('chinese_key', '') == '1.机动车所有人/身份证名称/号码': |
249 | result_obj['customerName'] = word_result.get('words', '').split('/')[0] | 245 | result_obj['customerName'] = word_result.get('words', '').split('/')[0] |
250 | except Exception as e: | 246 | except Exception as e: |
251 | LoggerMixin.exception_log.error("[PosHandler de_mortgage_ocr_process1] error", exc_info=1) | 247 | LoggerMixin.exception_log.error("[PosHandler greenbook_process] error", exc_info=1) |
248 | |||
249 | @staticmethod | ||
250 | def de_mortgage_ocr_process1(file_obj): | ||
251 | result_obj = { | ||
252 | 'customerName': '', | ||
253 | 'applicationName': '', | ||
254 | 'deMortgageDate': '' | ||
255 | } | ||
256 | |||
257 | doc_type = file_obj.get('documentType', '') | ||
258 | img_base64 = file_obj.get('fileBase64') | ||
259 | if doc_type == DocumentType.GREEN_BOOK.value.en_name: | ||
260 | PosHandler.greenbook_process(result_obj, img_base64) | ||
252 | return result_obj | 261 | return result_obj | ... | ... |
... | @@ -244,6 +244,9 @@ se_compare_content = { | ... | @@ -244,6 +244,9 @@ se_compare_content = { |
244 | 'customerType': fields.Str(required=True, validate=validate.OneOf(consts.CUSTOMER_TYPE)), | 244 | 'customerType': fields.Str(required=True, validate=validate.OneOf(consts.CUSTOMER_TYPE)), |
245 | "firstSubmmisonDate": CustomDate(required=True), | 245 | "firstSubmmisonDate": CustomDate(required=True), |
246 | 'propertyDocumentPolicy': fields.Str(required=False, validate=validate.Length(max=16)), | 246 | 'propertyDocumentPolicy': fields.Str(required=False, validate=validate.Length(max=16)), |
247 | 'fsmFlag': fields.Boolean(required=False), | ||
248 | 'fsmSpecialCar': fields.Boolean(required=False), | ||
249 | 'fsmBestPrice': fields.Boolean(required=False), | ||
247 | 'isAutoSettlement': fields.Boolean(required=False), | 250 | 'isAutoSettlement': fields.Boolean(required=False), |
248 | 251 | ||
249 | 'individualCusInfo': fields.List(fields.Nested(se_individual_args), | 252 | 'individualCusInfo': fields.List(fields.Nested(se_individual_args), |
... | @@ -813,6 +816,11 @@ class SECompareView(GenericView, PreSEHandler): | ... | @@ -813,6 +816,11 @@ class SECompareView(GenericView, PreSEHandler): |
813 | uniq_seq = content.get('uniqSeq') | 816 | uniq_seq = content.get('uniqSeq') |
814 | bank_verify = content.get('bankInfo', {}).get('bankVerificationStatus', '') | 817 | bank_verify = content.get('bankInfo', {}).get('bankVerificationStatus', '') |
815 | 818 | ||
819 | # fsm | ||
820 | fsm_flag = content.get('fsmFlag', False) | ||
821 | fsm_special_car = content.get('fsmSpecialCar', False) | ||
822 | fsm_best_price = content.get('fsmBestPrice', False) | ||
823 | |||
816 | # 存库, 用于银行卡比对 | 824 | # 存库, 用于银行卡比对 |
817 | try: | 825 | try: |
818 | bank_class = HILbankVerification if business_type in consts.HIL_SET else AFCbankVerification | 826 | bank_class = HILbankVerification if business_type in consts.HIL_SET else AFCbankVerification | ... | ... |
src/pos/consts.py
0 → 100644
1 | from enum import Enum | ||
2 | |||
3 | |||
4 | class DocumentTypeModel: | ||
5 | def __init__(self, code, en_name, cn_name): | ||
6 | self.code = code; | ||
7 | self.en_name = en_name | ||
8 | self.cn_name = cn_name | ||
9 | |||
10 | |||
11 | class DocumentType(Enum): | ||
12 | GREEN_BOOK = DocumentTypeModel("DTGBK", "Green Book", "机动车登记证") | ||
13 | CONFIRMATION_LETTER = DocumentTypeModel("DTCLE", "Confirmation Letter", "解抵押确认函") | ||
14 | WEBSITE_SCREENSHOT = DocumentTypeModel("DTWES", "Website Screenshot", "网页截图") | ||
15 | |||
16 | |||
17 | if __name__ == '__main__': | ||
18 | print(DocumentType.GREEN_BOOK.value.en_name) |
... | @@ -53,17 +53,22 @@ class NSCInvoiceView(GenericView): | ... | @@ -53,17 +53,22 @@ class NSCInvoiceView(GenericView): |
53 | return response.ok() | 53 | return response.ok() |
54 | 54 | ||
55 | 55 | ||
56 | file_param = { | ||
57 | 'documentType': fields.Str(required=True, validate=validate.Length(max=20)), | ||
58 | 'fileBase64': fields.Str(required=True), | ||
59 | } | ||
60 | |||
56 | de_mortgage_args = { | 61 | de_mortgage_args = { |
57 | 'customerName': fields.Str(required=True, validate=validate.Length(max=64)), | 62 | 'customerName': fields.Str(required=True, validate=validate.Length(max=64)), |
58 | 'application': fields.Str(required=True, validate=validate.Length(max=64)), | 63 | 'applicationName': fields.Str(required=True, validate=validate.Length(max=64)), |
59 | 'deMortgageDate': fields.Date(required=True), | 64 | 'deMortgageDate': fields.Date(required=True), |
60 | 'file_base64': fields.List(fields.Str(), required=True, validate=validate.Length(min=1)), | 65 | 'files': fields.Nested(file_param, required=True), |
61 | } | 66 | } |
62 | 67 | ||
63 | 68 | ||
64 | de_mortgage_comments = { | 69 | de_mortgage_comments = { |
65 | 'customerName': ('机动车所有人识别不一致', ), | 70 | 'customerName': ('机动车所有人识别不一致', ), |
66 | 'application': ('抵押权人姓名/名称识别不一致', ), | 71 | 'applicationName': ('抵押权人姓名/名称识别不一致', ), |
67 | 'deMortgageDate': ('解除抵押日期不一致', ) | 72 | 'deMortgageDate': ('解除抵押日期不一致', ) |
68 | } | 73 | } |
69 | 74 | ||
... | @@ -75,20 +80,20 @@ class DeMortgageView(GenericView): | ... | @@ -75,20 +80,20 @@ class DeMortgageView(GenericView): |
75 | 80 | ||
76 | @use_args(de_mortgage_args, location='data') | 81 | @use_args(de_mortgage_args, location='data') |
77 | def post(self, request, args): # interface_report mpos to ocr | 82 | def post(self, request, args): # interface_report mpos to ocr |
78 | img_files = args.get('file_base64', []) | 83 | files = args.get('files', []) |
79 | customer_name = args.get('customerName', '') | 84 | customer_name = args.get('customerName', '') |
80 | application = args.get('application', '') | 85 | application_name = args.get('applicationName', '') |
81 | de_mortgage_date = args.get('deMortgageDate') | 86 | de_mortgage_date = args.get('deMortgageDate') |
82 | 87 | ||
83 | fields_input = { | 88 | fields_input = { |
84 | 'customerName': customer_name, | 89 | 'customerName': customer_name, |
85 | 'application': application, | 90 | 'applicationName': application_name, |
86 | 'deMortgageDate': de_mortgage_date | 91 | 'deMortgageDate': de_mortgage_date |
87 | } | 92 | } |
88 | de_mortgage_info = {} | 93 | de_mortgage_info = {} |
89 | # 绿本必须分开ocr | 94 | # 绿本必须分开ocr |
90 | for img_file in img_files: | 95 | for file_obj in files: |
91 | info = PosHandler.de_mortgage_ocr_process1(img_file) | 96 | info = PosHandler.de_mortgage_ocr_process1(file_obj) |
92 | de_mortgage_info.update(info) | 97 | de_mortgage_info.update(info) |
93 | 98 | ||
94 | request_pass = True | 99 | request_pass = True | ... | ... |
-
Please register or sign in to post a comment