pre settlement pos 接口更新
Showing
8 changed files
with
86 additions
and
124 deletions
src/apps/doc/comments.py
deleted
100644 → 0
1 | ID_EN = 'PRC ID' | ||
2 | PP_EN = 'Passport' | ||
3 | EEP_EN = 'Resident Permit to Mainland' | ||
4 | RP_EN = 'Resident ID' | ||
5 | BL_EN = 'Business permit' | ||
6 | SME_BL_EN = 'SME Business permit' | ||
7 | MVI_EN = 'newCar Invoice' | ||
8 | UCI_EN = 'usedCar Invoice' | ||
9 | MVC_EN = 'Green Book(1/2)' | ||
10 | MVC34_EN = 'Green Book(3/4)' | ||
11 | BC_EN = 'Bank Card' | ||
12 | DDA_EN = 'DDA' | ||
13 | HMH_EN = 'Mortgage Waiver Letter' | ||
14 | JYPZ_EN = 'Used Car Document' | ||
15 | AFC_CONTRACT_EN = 'AFC Contract' | ||
16 | BD_EN = 'Insurance' | ||
17 | BS_EN = 'Bank Statement' | ||
18 | HIL_CONTRACT_1_EN = '售后回租合同' | ||
19 | HIL_CONTRACT_2_EN = '车辆租赁抵押合同' | ||
20 | HIL_CONTRACT_3_EN = '车辆处置协议' | ||
21 | |||
22 | OCR_COMPARE_COMMENT = { | ||
23 | ID_EN: { | ||
24 | 'idExpiryDate': '身份证疑似过期', | ||
25 | 'customerName': '身份证姓名与系统不一致', | ||
26 | 'idNum': '身份证号码与系统不一致', | ||
27 | 'other': '请确认是否提供身份证件' | ||
28 | }, | ||
29 | MVI_EN: { | ||
30 | 'firstSubmmisonDate': '请确认发票开票日期,若发票开票日期早于首次提交审批日期则无法受理放款申请', | ||
31 | 'customerName': '发票购买方姓名与系统不一致', | ||
32 | 'idNum': '发票购买方证件号码与系统不一致', | ||
33 | 'vinNo': '发票车架号与系统不一致', | ||
34 | 'vehicleTransactionAmount': '发票车辆价格与系统不一致', | ||
35 | 'productGroupName': '请确认是否提供发票' | ||
36 | }, | ||
37 | BC_EN: { | ||
38 | 'bankName': '银行卡开户行与系统不一致', | ||
39 | 'accountNo': '银行卡卡号与系统不一致', | ||
40 | 'bankVerificationStatus': '请确认是否提供银行卡' | ||
41 | }, | ||
42 | AFC_CONTRACT_EN: { | ||
43 | 'applicationId & applicationVersion': '', | ||
44 | 'service': '', | ||
45 | 'amount': '', | ||
46 | 'financedAmount': '', | ||
47 | 'associatedServicePrincipal': '', | ||
48 | 'vinNo': '', | ||
49 | 'accountNo': '', | ||
50 | 'accountHolderName': '', | ||
51 | 'bankName': '', | ||
52 | 'term': '', | ||
53 | 'applicationEntity': '' | ||
54 | }, | ||
55 | HIL_CONTRACT_1_EN: { | ||
56 | |||
57 | }, | ||
58 | HIL_CONTRACT_2_EN: { | ||
59 | |||
60 | }, | ||
61 | BD_EN: { | ||
62 | '': '' | ||
63 | } | ||
64 | } |
... | @@ -781,19 +781,20 @@ class SECompareView(GenericView): | ... | @@ -781,19 +781,20 @@ class SECompareView(GenericView): |
781 | bank_obj.on_off = False | 781 | bank_obj.on_off = False |
782 | bank_obj.save() | 782 | bank_obj.save() |
783 | 783 | ||
784 | # compare_result = pos_compare() | 784 | compare_result = pos_compare(content) |
785 | compare_result = { | 785 | |
786 | "is_pass": True, | 786 | # compare_result = { |
787 | "particulars": [{ | 787 | # "is_pass": True, |
788 | "object_name": "PRC ID", | 788 | # "particulars": [{ |
789 | "fields": [{ | 789 | # "object_name": "PRC ID", |
790 | "input": "张三", | 790 | # "fields": [{ |
791 | "ocr": "张三", | 791 | # "input": "张三", |
792 | "field_is_pass": True, | 792 | # "ocr": "张三", |
793 | "comments": "身份证姓名与系统不一致" | 793 | # "field_is_pass": True, |
794 | }] | 794 | # "comments": "身份证姓名与系统不一致" |
795 | }] | 795 | # }] |
796 | } | 796 | # }] |
797 | # } | ||
797 | 798 | ||
798 | return response.ok(data=compare_result) | 799 | return response.ok(data=compare_result) |
799 | 800 | ... | ... |
... | @@ -9,6 +9,7 @@ from datetime import datetime, timedelta | ... | @@ -9,6 +9,7 @@ from datetime import datetime, timedelta |
9 | from collections import OrderedDict | 9 | from collections import OrderedDict |
10 | from . import app | 10 | from . import app |
11 | from settings import conf | 11 | from settings import conf |
12 | from pos import pos | ||
12 | from apps.doc.models import ( | 13 | from apps.doc.models import ( |
13 | AFCOCRResult, | 14 | AFCOCRResult, |
14 | AFCSEOCRResult, | 15 | AFCSEOCRResult, |
... | @@ -39,7 +40,7 @@ from apps.doc.exceptions import GCAPException | ... | @@ -39,7 +40,7 @@ from apps.doc.exceptions import GCAPException |
39 | from apps.doc.named_enum import RequestTeam, RequestTrigger, ProcessName, ErrorType | 40 | from apps.doc.named_enum import RequestTeam, RequestTrigger, ProcessName, ErrorType |
40 | from common.tools.comparison import cp | 41 | from common.tools.comparison import cp |
41 | from common.tools.des import decode_des | 42 | from common.tools.des import decode_des |
42 | from apps.doc.comments import OCR_COMPARE_COMMENT | 43 | from pos.pos_consts import OCR_COMPARE_COMMENT |
43 | 44 | ||
44 | compare_log = logging.getLogger('compare') | 45 | compare_log = logging.getLogger('compare') |
45 | log_base = '[Compare]' | 46 | log_base = '[Compare]' |
... | @@ -3182,28 +3183,28 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True | ... | @@ -3182,28 +3183,28 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True |
3182 | traceback.format_exc())) | 3183 | traceback.format_exc())) |
3183 | 3184 | ||
3184 | 3185 | ||
3185 | def pos_compare(application_id, application_entity, uniq_seq, ocr_res_id=None, is_ca=True, is_cms=False): | 3186 | # pos接口 |
3187 | def pos_compare(pos_content, application_id, application_entity, uniq_seq, ocr_res_id=None, is_ca=True, is_cms=False): | ||
3186 | # POS: application_id, application_entity, uniq_seq, None | 3188 | # POS: application_id, application_entity, uniq_seq, None |
3187 | # OCR: application_id, business_type(application_entity), None, ocr_res_id | 3189 | # OCR: application_id, business_type(application_entity), None, ocr_res_id |
3188 | |||
3189 | compare_log.info('{0} [pos_compare] [entity={1}] [id={2}] [uniq_seq={3}] [is_ca={4}] ' | 3190 | compare_log.info('{0} [pos_compare] [entity={1}] [id={2}] [uniq_seq={3}] [is_ca={4}] ' |
3190 | '[is_cms={5}]'.format(log_base, application_entity, application_id, uniq_seq, | 3191 | '[is_cms={5}]'.format(log_base, application_entity, application_id, uniq_seq, |
3191 | is_ca, is_cms)) | 3192 | is_ca, is_cms)) |
3192 | 3193 | ||
3193 | # 根据application_id查找最新的比对信息,如果没有,结束 | 3194 | # 根据application_id查找最新的比对信息,如果没有,结束 |
3194 | if is_ca: | 3195 | # if is_ca: |
3195 | comparison_class = HILComparisonInfo if application_entity == consts.HIL_PREFIX else AFCComparisonInfo | 3196 | # comparison_class = HILComparisonInfo if application_entity == consts.HIL_PREFIX else AFCComparisonInfo |
3196 | else: | 3197 | # else: |
3197 | if application_entity == consts.HIL_PREFIX: | 3198 | # if application_entity == consts.HIL_PREFIX: |
3198 | comparison_class = HILSECMSInfo if is_cms else HILSEComparisonInfo | 3199 | # comparison_class = HILSECMSInfo if is_cms else HILSEComparisonInfo |
3199 | else: | 3200 | # else: |
3200 | comparison_class = AFCSECMSInfo if is_cms else AFCSEComparisonInfo | 3201 | # comparison_class = AFCSECMSInfo if is_cms else AFCSEComparisonInfo |
3201 | last_obj = comparison_class.objects.filter(application_id=application_id).last() | 3202 | # last_obj = comparison_class.objects.filter(application_id=application_id).last() |
3202 | if last_obj is None: | 3203 | # if last_obj is None: |
3203 | compare_log.info('{0} [comparison info empty] [entity={1}] [id={2}] [uniq_seq={3}] ' | 3204 | # compare_log.info('{0} [comparison info empty] [entity={1}] [id={2}] [uniq_seq={3}] ' |
3204 | '[is_ca={4}] [is_cms]={5}'.format(log_base, application_entity, application_id, uniq_seq, | 3205 | # '[is_ca={4}] [is_cms]={5}'.format(log_base, application_entity, application_id, uniq_seq, |
3205 | is_ca, is_cms)) | 3206 | # is_ca, is_cms)) |
3206 | return | 3207 | # return |
3207 | 3208 | ||
3208 | # 根据application_id查找OCR累计结果指定license字段,如果没有,结束 | 3209 | # 根据application_id查找OCR累计结果指定license字段,如果没有,结束 |
3209 | if is_ca: | 3210 | if is_ca: |
... | @@ -3225,8 +3226,15 @@ def pos_compare(application_id, application_entity, uniq_seq, ocr_res_id=None, i | ... | @@ -3225,8 +3226,15 @@ def pos_compare(application_id, application_entity, uniq_seq, ocr_res_id=None, i |
3225 | uniq_seq, ocr_res_id, is_ca, is_cms)) | 3226 | uniq_seq, ocr_res_id, is_ca, is_cms)) |
3226 | return | 3227 | return |
3227 | 3228 | ||
3229 | pos_content_obj = json.loads(pos_content) | ||
3228 | if is_ca: | 3230 | if is_ca: |
3229 | ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict) | 3231 | # 比对逻辑 |
3232 | # compare_info = get_ca_compare_info(pos_content_obj) | ||
3233 | # compare_result, total_fields, failed_count = ca_compare_process(compare_info, ocr_res_dict) | ||
3234 | # compare_log.info('{0} [CA] [compare success] [entity={1}] [id={2}] [ocr_res_id={3}] [result={4}]'.format( | ||
3235 | # log_base, application_entity, application_id, ocr_res_id, compare_result)) | ||
3236 | # ca_compare(application_id, application_entity, ocr_res_id, pos_content_obj, ocr_res_dict) | ||
3237 | compare_result = pos.PosCompare.ca_compare(pos_content_obj, ocr_res_dict) | ||
3230 | else: | 3238 | else: |
3231 | id_res_list = [] | 3239 | id_res_list = [] |
3232 | for field_name in consts.CA_ADD_COMPARE_FIELDS: | 3240 | for field_name in consts.CA_ADD_COMPARE_FIELDS: |
... | @@ -3241,31 +3249,32 @@ def pos_compare(application_id, application_entity, uniq_seq, ocr_res_id=None, i | ... | @@ -3241,31 +3249,32 @@ def pos_compare(application_id, application_entity, uniq_seq, ocr_res_id=None, i |
3241 | tmp_ca_result.extend(tmp_se_result) | 3249 | tmp_ca_result.extend(tmp_se_result) |
3242 | ocr_res_dict[field_name] = json.dumps(tmp_ca_result) | 3250 | ocr_res_dict[field_name] = json.dumps(tmp_ca_result) |
3243 | # auto settlement | 3251 | # auto settlement |
3244 | auto_class = HILAutoSettlement if application_entity == consts.HIL_PREFIX else AFCAutoSettlement | 3252 | # auto_class = HILAutoSettlement if application_entity == consts.HIL_PREFIX else AFCAutoSettlement |
3245 | auto_obj = auto_class.objects.filter(application_id=application_id, on_off=True).first() | 3253 | # auto_obj = auto_class.objects.filter(application_id=application_id, on_off=True).first() |
3246 | bank_class = HILbankVerification if application_entity == consts.HIL_PREFIX else AFCbankVerification | 3254 | # bank_class = HILbankVerification if application_entity == consts.HIL_PREFIX else AFCbankVerification |
3247 | ignore_bank = bank_class.objects.filter(application_id=application_id, on_off=True).exists() | 3255 | # ignore_bank = bank_class.objects.filter(application_id=application_id, on_off=True).exists() |
3248 | if auto_obj is not None: | 3256 | # if auto_obj is not None: |
3249 | auto_result = se_compare_auto(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict, auto_obj, ignore_bank, id_res_list) | 3257 | # auto_result = se_compare_auto(application_id, application_entity, ocr_res_id, pos_content_obj, ocr_res_dict, auto_obj, ignore_bank, id_res_list) |
3250 | else: | 3258 | # else: |
3251 | auto_result = None | 3259 | # auto_result = None |
3252 | 3260 | # | |
3253 | full_result = se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict, is_cms, auto_result, ignore_bank, id_res_list) | 3261 | # full_result = se_compare(application_id, application_entity, ocr_res_id, pos_content_obj, ocr_res_dict, is_cms, auto_result, ignore_bank, id_res_list) |
3254 | 3262 | # | |
3255 | if auto_obj is not None: | 3263 | # if auto_obj is not None: |
3256 | try: | 3264 | # try: |
3257 | auto_obj.ocr_whole_result_pass = full_result | 3265 | # auto_obj.ocr_whole_result_pass = full_result |
3258 | auto_obj.save() | 3266 | # auto_obj.save() |
3259 | compare_log.info('{0} [Auto SE] [result save success] [entity={1}] [id={2}] [ocr_res_id={3}]'.format( | 3267 | # compare_log.info('{0} [Auto SE] [result save success] [entity={1}] [id={2}] [ocr_res_id={3}]'.format( |
3260 | log_base, application_entity, application_id, ocr_res_id)) | 3268 | # log_base, application_entity, application_id, ocr_res_id)) |
3261 | except Exception as e: | 3269 | # except Exception as e: |
3262 | compare_log.error('{0} [Auto SE] [result save error] [entity={1}] [id={2}] [ocr_res_id={3}] ' | 3270 | # compare_log.error('{0} [Auto SE] [result save error] [entity={1}] [id={2}] [ocr_res_id={3}] ' |
3263 | '[error={4}]'.format(log_base, application_entity, application_id, ocr_res_id, | 3271 | # '[error={4}]'.format(log_base, application_entity, application_id, ocr_res_id, |
3264 | traceback.format_exc())) | 3272 | # traceback.format_exc())) |
3265 | 3273 | ||
3266 | result_table = HILCACompareResult if application_entity == consts.HIL_PREFIX else AFCCACompareResult | 3274 | # result_table = HILCACompareResult if application_entity == consts.HIL_PREFIX else AFCCACompareResult |
3267 | res_obj = result_table.objects.filter(application_id=application_id).first() | 3275 | # res_obj = result_table.objects.filter(application_id=application_id).first() |
3268 | return pos_result_output(res_obj.result) | 3276 | compare_result = pos.PosCompare.se_compare(pos_content_obj, ocr_res_dict, id_res_list=id_res_list) |
3277 | return pos_result_output(compare_result) | ||
3269 | 3278 | ||
3270 | 3279 | ||
3271 | # pos输出解析 | 3280 | # pos输出解析 |
... | @@ -3284,9 +3293,9 @@ def pos_result_output(compare_result): | ... | @@ -3284,9 +3293,9 @@ def pos_result_output(compare_result): |
3284 | particulars = [] | 3293 | particulars = [] |
3285 | for license, license_items in license_map.items(): | 3294 | for license, license_items in license_map.items(): |
3286 | particular = {"object_name": license} | 3295 | particular = {"object_name": license} |
3287 | license_comments = OCR_COMPARE_COMMENT.get(license) | 3296 | # license_comments = OCR_COMPARE_COMMENT.get(license) |
3288 | if not license_comments: | 3297 | # if not license_comments: |
3289 | continue | 3298 | # continue |
3290 | fields = [] | 3299 | fields = [] |
3291 | particular["fields"] = fields | 3300 | particular["fields"] = fields |
3292 | for license_item in license_items: | 3301 | for license_item in license_items: |
... | @@ -3296,7 +3305,7 @@ def pos_result_output(compare_result): | ... | @@ -3296,7 +3305,7 @@ def pos_result_output(compare_result): |
3296 | field["field_is_pass"] = license_item.get("Result") == 'Y' | 3305 | field["field_is_pass"] = license_item.get("Result") == 'Y' |
3297 | if not field["field_is_pass"]: | 3306 | if not field["field_is_pass"]: |
3298 | is_pass = False | 3307 | is_pass = False |
3299 | field["comments"] = license_comments.get(license_item.get("Field"), '') | 3308 | field["comments"] = license_item.get('comments', '') |
3300 | fields.append(field) | 3309 | fields.append(field) |
3301 | particular["fields"] = fields | 3310 | particular["fields"] = fields |
3302 | particulars.append(particular) | 3311 | particulars.append(particular) | ... | ... |
1 | import re | 1 | import re |
2 | import time | 2 | import time |
3 | import numpy as np | 3 | import numpy as np |
4 | from datetime import datetime | 4 | from datetime import datetime, timedelta |
5 | from dateutil.relativedelta import relativedelta | 5 | from dateutil.relativedelta import relativedelta |
6 | from .rmb_lower import rmb_handler | 6 | from .rmb_lower import rmb_handler |
7 | # from .rmb_upper import to_rmb_upper | 7 | # from .rmb_upper import to_rmb_upper |
... | @@ -29,6 +29,8 @@ class Comparison: | ... | @@ -29,6 +29,8 @@ class Comparison: |
29 | 29 | ||
30 | self.RESULT_Y = 'Y' | 30 | self.RESULT_Y = 'Y' |
31 | self.RESULT_N = 'N' | 31 | self.RESULT_N = 'N' |
32 | self.RESULT_N1 = 'N1' | ||
33 | self.RESULT_N2 = 'N2' | ||
32 | self.RESULT_NA = 'NA' | 34 | self.RESULT_NA = 'NA' |
33 | 35 | ||
34 | self.TRANS_MAP = { | 36 | self.TRANS_MAP = { |
... | @@ -380,6 +382,20 @@ class Comparison: | ... | @@ -380,6 +382,20 @@ class Comparison: |
380 | except Exception as e: | 382 | except Exception as e: |
381 | return self.RESULT_N | 383 | return self.RESULT_N |
382 | 384 | ||
385 | def se_date_compare_pos(self, input_str, ocr_str, **kwargs): | ||
386 | try: | ||
387 | ocr_date = datetime.strptime(ocr_str, "%Y-%m-%d").date() | ||
388 | today = datetime.now().date() | ||
389 | if ocr_date < today: | ||
390 | return self.RESULT_N1 | ||
391 | elif today <= ocr_date <= (today + timedelta(days=8)): | ||
392 | return self.RESULT_N2 | ||
393 | elif ocr_date > (today + timedelta(days=8)): | ||
394 | return self.RESULT_Y | ||
395 | except Exception as e: | ||
396 | return self.RESULT_N | ||
397 | return self.RESULT_N | ||
398 | |||
383 | def ca_date_compare(self, input_str, ocr_str, **kwargs): | 399 | def ca_date_compare(self, input_str, ocr_str, **kwargs): |
384 | if kwargs.get('long', False): | 400 | if kwargs.get('long', False): |
385 | if '长期' in ocr_str or '永久' in ocr_str: | 401 | if '长期' in ocr_str or '永久' in ocr_str: | ... | ... |
src/pos/__init__.py
0 → 100644
File mode changed
src/pos/pos.py
0 → 100644
This diff is collapsed.
Click to expand it.
src/pos/pos_compare.py
0 → 100644
This diff is collapsed.
Click to expand it.
src/pos/pos_consts.py
0 → 100644
This diff is collapsed.
Click to expand it.
-
Please register or sign in to post a comment