prese part 1
Showing
11 changed files
with
189 additions
and
187 deletions
| ... | @@ -1234,26 +1234,39 @@ RESULT_MAPPING = { | ... | @@ -1234,26 +1234,39 @@ RESULT_MAPPING = { |
| 1234 | } | 1234 | } |
| 1235 | 1235 | ||
| 1236 | CA_ADD_COMPARE_FIELDS = (IC_OCR_FIELD, BL_OCR_FIELD, BS_FIELD) | 1236 | CA_ADD_COMPARE_FIELDS = (IC_OCR_FIELD, BL_OCR_FIELD, BS_FIELD) |
| 1237 | CA_ADD_COMPARE_FIELDS_PRE = (IC_OCR_FIELD,) | ||
| 1238 | |||
| 1239 | COMPARE_FIELDS = ( | ||
| 1240 | MVI_OCR_FIELD, | ||
| 1241 | IC_OCR_FIELD, | ||
| 1242 | RP_OCR_FIELD, | ||
| 1243 | BC_OCR_FIELD, | ||
| 1244 | BL_OCR_FIELD, | ||
| 1245 | UCI_OCR_FIELD, | ||
| 1246 | EEP_OCR_FIELD, | ||
| 1247 | DL_OCR_FIELD, | ||
| 1248 | PP_OCR_FIELD, | ||
| 1249 | MVC_OCR_FIELD, | ||
| 1250 | DDA_OCR_FIELD, | ||
| 1251 | HMH_OCR_FIELD, | ||
| 1252 | JYPZ_OCR_FIELD, | ||
| 1253 | HT_FIELD, | ||
| 1254 | BD_FIELD, | ||
| 1255 | BS_FIELD, | ||
| 1256 | HIL_CONTRACT_1_FIELD, | ||
| 1257 | HIL_CONTRACT_2_FIELD, | ||
| 1258 | HIL_CONTRACT_3_FIELD, | ||
| 1259 | ) | ||
| 1237 | 1260 | ||
| 1238 | COMPARE_FIELDS = (MVI_OCR_FIELD, | 1261 | PRE_COMPARE_FIELDS = ( |
| 1239 | IC_OCR_FIELD, | 1262 | MVI_OCR_FIELD, |
| 1240 | RP_OCR_FIELD, | 1263 | IC_OCR_FIELD, |
| 1241 | BC_OCR_FIELD, | 1264 | BC_OCR_FIELD, |
| 1242 | BL_OCR_FIELD, | 1265 | HMH_OCR_FIELD, |
| 1243 | UCI_OCR_FIELD, | 1266 | HT_FIELD, |
| 1244 | EEP_OCR_FIELD, | 1267 | BD_FIELD, |
| 1245 | DL_OCR_FIELD, | 1268 | HIL_CONTRACT_1_FIELD, |
| 1246 | PP_OCR_FIELD, | 1269 | HIL_CONTRACT_2_FIELD, |
| 1247 | MVC_OCR_FIELD, | ||
| 1248 | DDA_OCR_FIELD, | ||
| 1249 | HMH_OCR_FIELD, | ||
| 1250 | JYPZ_OCR_FIELD, | ||
| 1251 | HT_FIELD, | ||
| 1252 | BD_FIELD, | ||
| 1253 | BS_FIELD, | ||
| 1254 | HIL_CONTRACT_1_FIELD, | ||
| 1255 | HIL_CONTRACT_2_FIELD, | ||
| 1256 | HIL_CONTRACT_3_FIELD, | ||
| 1257 | ) | 1270 | ) |
| 1258 | 1271 | ||
| 1259 | # 身份证 | 1272 | # 身份证 | ... | ... |
| ... | @@ -2,8 +2,9 @@ import re | ... | @@ -2,8 +2,9 @@ import re |
| 2 | import json | 2 | import json |
| 3 | import requests | 3 | import requests |
| 4 | from .named_enum import DocStatus | 4 | from .named_enum import DocStatus |
| 5 | from .models import HILDoc, AFCDoc | 5 | from .models import HILDoc, AFCDoc, AFCSEOCRResult, AFCOCRResult, HILSEOCRResult, HILOCRResult |
| 6 | from . import consts | 6 | from . import consts |
| 7 | from prese.compare import pre_compare | ||
| 7 | 8 | ||
| 8 | 9 | ||
| 9 | class MPOSHandler: | 10 | class MPOSHandler: |
| ... | @@ -141,3 +142,31 @@ class DocHandler: | ... | @@ -141,3 +142,31 @@ class DocHandler: |
| 141 | else: | 142 | else: |
| 142 | return consts.DATA_SOURCE_LIST[0] | 143 | return consts.DATA_SOURCE_LIST[0] |
| 143 | 144 | ||
| 145 | |||
| 146 | class PreSEHandler: | ||
| 147 | |||
| 148 | # preSettlement | ||
| 149 | @staticmethod | ||
| 150 | def pre_compare_entrance(pos_content): | ||
| 151 | application_entity = pos_content.get('applicationEntity') | ||
| 152 | application_id = pos_content.get('applicationId') | ||
| 153 | |||
| 154 | # 根据application_id查找OCR累计结果指定license字段,如果没有,结束 | ||
| 155 | result_class = HILSEOCRResult if application_entity in consts.HIL_SET else AFCSEOCRResult | ||
| 156 | ca_result_class = HILOCRResult if application_entity in consts.HIL_SET else AFCOCRResult | ||
| 157 | |||
| 158 | ca_ocr_res_dict = ca_result_class.objects.filter(application_id=application_id).values( | ||
| 159 | *consts.CA_ADD_COMPARE_FIELDS_PRE).first() | ||
| 160 | ocr_res_dict = result_class.objects.filter(application_id=application_id).values( | ||
| 161 | *consts.PRE_COMPARE_FIELDS).first() | ||
| 162 | if ocr_res_dict is None: | ||
| 163 | return | ||
| 164 | |||
| 165 | id_res_list = [] | ||
| 166 | for field_name in consts.CA_ADD_COMPARE_FIELDS_PRE: | ||
| 167 | if field_name == consts.IC_OCR_FIELD: | ||
| 168 | id_res_list.append(ca_ocr_res_dict.get(field_name) if isinstance(ca_ocr_res_dict, dict) else None) | ||
| 169 | id_res_list.append(ocr_res_dict.get(field_name)) | ||
| 170 | |||
| 171 | rebuild_compare_result = pre_compare(pos_content, ocr_res_dict, id_res_list) | ||
| 172 | return rebuild_compare_result | ... | ... |
| ... | @@ -48,10 +48,10 @@ from .models import ( | ... | @@ -48,10 +48,10 @@ from .models import ( |
| 48 | MposReport, | 48 | MposReport, |
| 49 | ) | 49 | ) |
| 50 | from .named_enum import ErrorType, AutoResult, WholeResult, RPAResult | 50 | from .named_enum import ErrorType, AutoResult, WholeResult, RPAResult |
| 51 | from .mixins import DocHandler, MPOSHandler | 51 | from .mixins import DocHandler, MPOSHandler, PreSEHandler |
| 52 | from . import consts | 52 | from . import consts |
| 53 | from apps.account.authentication import OAuth2AuthenticationWithUser | 53 | from apps.account.authentication import OAuth2AuthenticationWithUser |
| 54 | from celery_compare.tasks import compare, pos_compare | 54 | from celery_compare.tasks import compare |
| 55 | 55 | ||
| 56 | 56 | ||
| 57 | class CustomDate(fields.Date): | 57 | class CustomDate(fields.Date): |
| ... | @@ -87,6 +87,8 @@ se_vehicle_args = { | ... | @@ -87,6 +87,8 @@ se_vehicle_args = { |
| 87 | 'vehicleTransactionAmount': CustomDecimal(required=True), | 87 | 'vehicleTransactionAmount': CustomDecimal(required=True), |
| 88 | 'vinNo': fields.Str(required=True, validate=validate.Length(max=256)), | 88 | 'vinNo': fields.Str(required=True, validate=validate.Length(max=256)), |
| 89 | 'dealer': fields.Str(required=True, validate=validate.Length(max=256)), | 89 | 'dealer': fields.Str(required=True, validate=validate.Length(max=256)), |
| 90 | 'showRoom': fields.Str(required=False), | ||
| 91 | 'agencyDealer': fields.Str(required=False), | ||
| 90 | 'option': CustomDecimal(required=False), | 92 | 'option': CustomDecimal(required=False), |
| 91 | 'msrp': CustomDecimal(required=False), | 93 | 'msrp': CustomDecimal(required=False), |
| 92 | 'totalAmount': CustomDecimal(required=False), | 94 | 'totalAmount': CustomDecimal(required=False), |
| ... | @@ -125,6 +127,7 @@ se_quotationt_args = { | ... | @@ -125,6 +127,7 @@ se_quotationt_args = { |
| 125 | 'loanTerm': fields.Int(required=True), | 127 | 'loanTerm': fields.Int(required=True), |
| 126 | 'vehiclePrincipal': CustomDecimal(required=True), | 128 | 'vehiclePrincipal': CustomDecimal(required=True), |
| 127 | 'associatedServicePrincipal': CustomDecimal(required=False), | 129 | 'associatedServicePrincipal': CustomDecimal(required=False), |
| 130 | 'mortgageType': fields.Str(required=True, validate=validate.Length(max=16)), | ||
| 128 | 'associatedServiceInfo': fields.List(fields.Nested(se_associated_args), required=False), | 131 | 'associatedServiceInfo': fields.List(fields.Nested(se_associated_args), required=False), |
| 129 | 'monthlyPaymentInfo': fields.List(fields.Nested(se_payment_args), required=True, validate=validate.Length(min=1)), | 132 | 'monthlyPaymentInfo': fields.List(fields.Nested(se_payment_args), required=True, validate=validate.Length(min=1)), |
| 130 | } | 133 | } |
| ... | @@ -224,6 +227,10 @@ se_compare_content = { | ... | @@ -224,6 +227,10 @@ se_compare_content = { |
| 224 | 'applicationId': fields.Str(required=True, validate=validate.Length(max=64)), | 227 | 'applicationId': fields.Str(required=True, validate=validate.Length(max=64)), |
| 225 | "applicationVersion": fields.Int(required=True), | 228 | "applicationVersion": fields.Int(required=True), |
| 226 | 'applicationEntity': fields.Str(required=True, validate=validate.OneOf(consts.ENTITY)), | 229 | 'applicationEntity': fields.Str(required=True, validate=validate.OneOf(consts.ENTITY)), |
| 230 | |||
| 231 | 'productGroup': fields.Str(required=False), | ||
| 232 | 'productGroupID': fields.Str(required=False), | ||
| 233 | |||
| 227 | 'customerType': fields.Str(required=True, validate=validate.OneOf(consts.CUSTOMER_TYPE)), | 234 | 'customerType': fields.Str(required=True, validate=validate.OneOf(consts.CUSTOMER_TYPE)), |
| 228 | "firstSubmmisonDate": CustomDate(required=True), | 235 | "firstSubmmisonDate": CustomDate(required=True), |
| 229 | 'propertyDocumentPolicy': fields.Str(required=False, validate=validate.Length(max=16)), | 236 | 'propertyDocumentPolicy': fields.Str(required=False, validate=validate.Length(max=16)), |
| ... | @@ -754,34 +761,45 @@ class CompareView(GenericView): | ... | @@ -754,34 +761,45 @@ class CompareView(GenericView): |
| 754 | ''' | 761 | ''' |
| 755 | 762 | ||
| 756 | 763 | ||
| 757 | class SECompareView(GenericView): | 764 | class SECompareView(GenericView, PreSEHandler): |
| 758 | permission_classes = [IsAuthenticated] | 765 | permission_classes = [IsAuthenticated] |
| 759 | authentication_classes = [OAuth2AuthenticationWithUser] | 766 | authentication_classes = [OAuth2AuthenticationWithUser] |
| 760 | 767 | ||
| 761 | # pos上传比对信息接口 SE | 768 | # SE preSettlement |
| 762 | @use_args(se_compare_args, location='data') | 769 | @use_args(se_compare_args, location='data') |
| 763 | def post(self, request, args): | 770 | def post(self, request, args): |
| 764 | # 存库 | 771 | log_base = '[prese]' |
| 772 | |||
| 765 | content = args.get('content', {}) | 773 | content = args.get('content', {}) |
| 766 | business_type = content.get('applicationEntity') | 774 | business_type = content.get('applicationEntity') |
| 767 | application_id = content.get('applicationId') | 775 | application_id = content.get('applicationId') |
| 776 | uniq_seq = content.get('uniqSeq') | ||
| 768 | bank_verify = content.get('bankInfo', {}).get('bankVerificationStatus', '') | 777 | bank_verify = content.get('bankInfo', {}).get('bankVerificationStatus', '') |
| 769 | 778 | ||
| 770 | bank_class = HILbankVerification if business_type in consts.HIL_SET else AFCbankVerification | 779 | # 存库, 用于银行卡比对 |
| 771 | bank_obj = bank_class.objects.filter(application_id=application_id).first() | 780 | try: |
| 781 | bank_class = HILbankVerification if business_type in consts.HIL_SET else AFCbankVerification | ||
| 782 | bank_obj = bank_class.objects.filter(application_id=application_id).first() | ||
| 772 | 783 | ||
| 773 | if bank_obj is None and bank_verify == 'PASS': | 784 | if bank_obj is None and bank_verify == 'PASS': |
| 774 | bank_class.objects.create( | 785 | bank_class.objects.create( |
| 775 | application_id=application_id, | 786 | application_id=application_id, |
| 776 | ) | 787 | ) |
| 777 | elif bank_obj is not None and bank_verify == 'PASS' and bank_obj.on_off is False: | 788 | elif bank_obj is not None and bank_verify == 'PASS' and bank_obj.on_off is False: |
| 778 | bank_obj.on_off = True | 789 | bank_obj.on_off = True |
| 779 | bank_obj.save() | 790 | bank_obj.save() |
| 780 | elif bank_obj is not None and bank_verify != 'PASS' and bank_obj.on_off is True: | 791 | elif bank_obj is not None and bank_verify != 'PASS' and bank_obj.on_off is True: |
| 781 | bank_obj.on_off = False | 792 | bank_obj.on_off = False |
| 782 | bank_obj.save() | 793 | bank_obj.save() |
| 783 | 794 | except Exception as e: | |
| 784 | compare_result = pos_compare(content) | 795 | self.running_log.info('{0} [bankCard verify save db error] [applicationEntity={1}] ' |
| 796 | '[application_id={2}] [bank_status={3}] [error={4}]'.format( | ||
| 797 | log_base, business_type, application_id, bank_verify, traceback.format_exc())) | ||
| 798 | |||
| 799 | # preSettlement比对 | ||
| 800 | compare_result = self.pre_compare_entrance(content) | ||
| 801 | self.running_log.info('{0} [prese completed] [applicationEntity={1}] [application_id={2}] [uniq_seq={3}] ' | ||
| 802 | '[result={4}]'.format(log_base, business_type, application_id, uniq_seq, compare_result)) | ||
| 785 | 803 | ||
| 786 | return response.ok(data=compare_result) | 804 | return response.ok(data=compare_result) |
| 787 | 805 | ... | ... |
| ... | @@ -39,7 +39,6 @@ from apps.doc.exceptions import GCAPException | ... | @@ -39,7 +39,6 @@ from apps.doc.exceptions import GCAPException |
| 39 | from apps.doc.named_enum import RequestTeam, RequestTrigger, ProcessName, ErrorType | 39 | from apps.doc.named_enum import RequestTeam, RequestTrigger, ProcessName, ErrorType |
| 40 | from common.tools.comparison import cp | 40 | from common.tools.comparison import cp |
| 41 | from common.tools.des import decode_des | 41 | from common.tools.des import decode_des |
| 42 | from pos import pos | ||
| 43 | 42 | ||
| 44 | compare_log = logging.getLogger('compare') | 43 | compare_log = logging.getLogger('compare') |
| 45 | log_base = '[Compare]' | 44 | log_base = '[Compare]' |
| ... | @@ -2414,6 +2413,7 @@ def se_compare_license_id(license_en, id_res_list, field_list): | ... | @@ -2414,6 +2413,7 @@ def se_compare_license_id(license_en, id_res_list, field_list): |
| 2414 | if is_find: | 2413 | if is_find: |
| 2415 | break | 2414 | break |
| 2416 | 2415 | ||
| 2416 | result_field_list.clear() | ||
| 2417 | for idx, (name, value) in enumerate(field_list): | 2417 | for idx, (name, value) in enumerate(field_list): |
| 2418 | # if ocr_field == consts.MVI_OCR_FIELD and name == consts.SE_NEW_ADD_FIELD[9]: | 2418 | # if ocr_field == consts.MVI_OCR_FIELD and name == consts.SE_NEW_ADD_FIELD[9]: |
| 2419 | # ocr_str = getattr(cp, consts.ZW_METHOD)( | 2419 | # ocr_str = getattr(cp, consts.ZW_METHOD)( |
| ... | @@ -2493,6 +2493,7 @@ def se_compare_license_id(license_en, id_res_list, field_list): | ... | @@ -2493,6 +2493,7 @@ def se_compare_license_id(license_en, id_res_list, field_list): |
| 2493 | result_field_list.append((name, value, result, ocr_str, img_path, error_type, compare_logic[name][3])) | 2493 | result_field_list.append((name, value, result, ocr_str, img_path, error_type, compare_logic[name][3])) |
| 2494 | 2494 | ||
| 2495 | if not is_find: | 2495 | if not is_find: |
| 2496 | result_field_list.clear() | ||
| 2496 | for name, value in field_list: | 2497 | for name, value in field_list: |
| 2497 | if isinstance(value, list): | 2498 | if isinstance(value, list): |
| 2498 | value = json.dumps(value, ensure_ascii=False) | 2499 | value = json.dumps(value, ensure_ascii=False) |
| ... | @@ -3200,135 +3201,3 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True | ... | @@ -3200,135 +3201,3 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True |
| 3200 | '[error={4}]'.format(log_base, application_entity, application_id, ocr_res_id, | 3201 | '[error={4}]'.format(log_base, application_entity, application_id, ocr_res_id, |
| 3201 | traceback.format_exc())) | 3202 | traceback.format_exc())) |
| 3202 | 3203 | ||
| 3203 | |||
| 3204 | # pos接口 | ||
| 3205 | def pos_compare(pos_content, application_id, application_entity, uniq_seq, ocr_res_id=None, is_ca=True, is_cms=False): | ||
| 3206 | # POS: application_id, application_entity, uniq_seq, None | ||
| 3207 | # OCR: application_id, business_type(application_entity), None, ocr_res_id | ||
| 3208 | compare_log.info('{0} [pos_compare] [entity={1}] [id={2}] [uniq_seq={3}] [is_ca={4}] ' | ||
| 3209 | '[is_cms={5}]'.format(log_base, application_entity, application_id, uniq_seq, | ||
| 3210 | is_ca, is_cms)) | ||
| 3211 | |||
| 3212 | # 根据application_id查找最新的比对信息,如果没有,结束 | ||
| 3213 | # if is_ca: | ||
| 3214 | # comparison_class = HILComparisonInfo if application_entity == consts.HIL_PREFIX else AFCComparisonInfo | ||
| 3215 | # else: | ||
| 3216 | # if application_entity == consts.HIL_PREFIX: | ||
| 3217 | # comparison_class = HILSECMSInfo if is_cms else HILSEComparisonInfo | ||
| 3218 | # else: | ||
| 3219 | # comparison_class = AFCSECMSInfo if is_cms else AFCSEComparisonInfo | ||
| 3220 | # last_obj = comparison_class.objects.filter(application_id=application_id).last() | ||
| 3221 | # if last_obj is None: | ||
| 3222 | # compare_log.info('{0} [comparison info empty] [entity={1}] [id={2}] [uniq_seq={3}] ' | ||
| 3223 | # '[is_ca={4}] [is_cms]={5}'.format(log_base, application_entity, application_id, uniq_seq, | ||
| 3224 | # is_ca, is_cms)) | ||
| 3225 | # return | ||
| 3226 | |||
| 3227 | # 根据application_id查找OCR累计结果指定license字段,如果没有,结束 | ||
| 3228 | if is_ca: | ||
| 3229 | result_class = HILOCRResult if application_entity == consts.HIL_PREFIX else AFCOCRResult | ||
| 3230 | ca_ocr_res_dict = dict() | ||
| 3231 | else: | ||
| 3232 | result_class = HILSEOCRResult if application_entity == consts.HIL_PREFIX else AFCSEOCRResult | ||
| 3233 | ca_result_class = HILOCRResult if application_entity == consts.HIL_PREFIX else AFCOCRResult | ||
| 3234 | # if ocr_res_id is None: | ||
| 3235 | ca_ocr_res_dict = ca_result_class.objects.filter(application_id=application_id).values( | ||
| 3236 | *consts.CA_ADD_COMPARE_FIELDS).first() | ||
| 3237 | # else: | ||
| 3238 | # ca_ocr_res_dict = ca_result_class.objects.filter(id=ocr_res_id).values( | ||
| 3239 | # *consts.CA_ADD_COMPARE_FIELDS).first() | ||
| 3240 | ocr_res_dict = result_class.objects.filter(application_id=application_id).values(*consts.COMPARE_FIELDS).first() | ||
| 3241 | if ocr_res_dict is None: | ||
| 3242 | compare_log.info('{0} [ocr info empty] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}] ' | ||
| 3243 | '[is_ca={5}] [is_cms]={6}'.format(log_base, application_entity, application_id, | ||
| 3244 | uniq_seq, ocr_res_id, is_ca, is_cms)) | ||
| 3245 | return | ||
| 3246 | |||
| 3247 | pos_content_obj = json.loads(pos_content) | ||
| 3248 | if is_ca: | ||
| 3249 | # 比对逻辑 | ||
| 3250 | # compare_info = get_ca_compare_info(pos_content_obj) | ||
| 3251 | # compare_result, total_fields, failed_count = ca_compare_process(compare_info, ocr_res_dict) | ||
| 3252 | # compare_log.info('{0} [CA] [compare success] [entity={1}] [id={2}] [ocr_res_id={3}] [result={4}]'.format( | ||
| 3253 | # log_base, application_entity, application_id, ocr_res_id, compare_result)) | ||
| 3254 | # ca_compare(application_id, application_entity, ocr_res_id, pos_content_obj, ocr_res_dict) | ||
| 3255 | compare_result = pos.PosCompare.ca_compare(pos_content_obj, ocr_res_dict) | ||
| 3256 | else: | ||
| 3257 | id_res_list = [] | ||
| 3258 | for field_name in consts.CA_ADD_COMPARE_FIELDS: | ||
| 3259 | if field_name == consts.IC_OCR_FIELD: | ||
| 3260 | id_res_list.append(ocr_res_dict.get(field_name)) | ||
| 3261 | id_res_list.append(ca_ocr_res_dict.get(field_name) if isinstance(ca_ocr_res_dict, dict) else None) | ||
| 3262 | |||
| 3263 | if isinstance(ca_ocr_res_dict, dict) and isinstance(ca_ocr_res_dict.get(field_name), str): | ||
| 3264 | tmp_ca_result = json.loads(ca_ocr_res_dict.get(field_name)) | ||
| 3265 | if isinstance(ocr_res_dict.get(field_name), str): | ||
| 3266 | tmp_se_result = json.loads(ocr_res_dict.get(field_name)) | ||
| 3267 | tmp_ca_result.extend(tmp_se_result) | ||
| 3268 | ocr_res_dict[field_name] = json.dumps(tmp_ca_result) | ||
| 3269 | # auto settlement | ||
| 3270 | # auto_class = HILAutoSettlement if application_entity == consts.HIL_PREFIX else AFCAutoSettlement | ||
| 3271 | # auto_obj = auto_class.objects.filter(application_id=application_id, on_off=True).first() | ||
| 3272 | # bank_class = HILbankVerification if application_entity == consts.HIL_PREFIX else AFCbankVerification | ||
| 3273 | # ignore_bank = bank_class.objects.filter(application_id=application_id, on_off=True).exists() | ||
| 3274 | # if auto_obj is not None: | ||
| 3275 | # 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) | ||
| 3276 | # else: | ||
| 3277 | # auto_result = None | ||
| 3278 | # | ||
| 3279 | # 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) | ||
| 3280 | # | ||
| 3281 | # if auto_obj is not None: | ||
| 3282 | # try: | ||
| 3283 | # auto_obj.ocr_whole_result_pass = full_result | ||
| 3284 | # auto_obj.save() | ||
| 3285 | # compare_log.info('{0} [Auto SE] [result save success] [entity={1}] [id={2}] [ocr_res_id={3}]'.format( | ||
| 3286 | # log_base, application_entity, application_id, ocr_res_id)) | ||
| 3287 | # except Exception as e: | ||
| 3288 | # compare_log.error('{0} [Auto SE] [result save error] [entity={1}] [id={2}] [ocr_res_id={3}] ' | ||
| 3289 | # '[error={4}]'.format(log_base, application_entity, application_id, ocr_res_id, | ||
| 3290 | # traceback.format_exc())) | ||
| 3291 | |||
| 3292 | # result_table = HILCACompareResult if application_entity == consts.HIL_PREFIX else AFCCACompareResult | ||
| 3293 | # res_obj = result_table.objects.filter(application_id=application_id).first() | ||
| 3294 | compare_result = pos.PosCompare.se_compare(pos_content_obj, ocr_res_dict, id_res_list=id_res_list) | ||
| 3295 | return pos_result_output(compare_result) | ||
| 3296 | |||
| 3297 | |||
| 3298 | # pos输出解析 | ||
| 3299 | def pos_result_output(compare_result): | ||
| 3300 | result_obj = json.loads(compare_result) | ||
| 3301 | license_map = dict() | ||
| 3302 | for item in result_obj: | ||
| 3303 | license_en = item.get("License") | ||
| 3304 | if license_map.get(license_en): | ||
| 3305 | license_map.get(license_en).append(item) | ||
| 3306 | else: | ||
| 3307 | info_items = [item] | ||
| 3308 | license_map[license_en] = info_items | ||
| 3309 | |||
| 3310 | is_pass = True | ||
| 3311 | particulars = [] | ||
| 3312 | for license, license_items in license_map.items(): | ||
| 3313 | particular = {"object_name": license} | ||
| 3314 | # license_comments = OCR_COMPARE_COMMENT.get(license) | ||
| 3315 | # if not license_comments: | ||
| 3316 | # continue | ||
| 3317 | fields = [] | ||
| 3318 | particular["fields"] = fields | ||
| 3319 | for license_item in license_items: | ||
| 3320 | field = dict() | ||
| 3321 | field["input"] = license_item.get("Input") | ||
| 3322 | field["ocr"] = license_item.get("OCR") | ||
| 3323 | field["field_is_pass"] = license_item.get("Result") == 'Y' | ||
| 3324 | if not field["field_is_pass"]: | ||
| 3325 | is_pass = False | ||
| 3326 | field["comments"] = license_item.get('comments', '') | ||
| 3327 | fields.append(field) | ||
| 3328 | particular["fields"] = fields | ||
| 3329 | particulars.append(particular) | ||
| 3330 | |||
| 3331 | return { | ||
| 3332 | "is_pass": is_pass, | ||
| 3333 | "particulars": particulars | ||
| 3334 | } | ... | ... |
| ... | @@ -29,8 +29,6 @@ class Comparison: | ... | @@ -29,8 +29,6 @@ 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' | ||
| 34 | self.RESULT_NA = 'NA' | 32 | self.RESULT_NA = 'NA' |
| 35 | 33 | ||
| 36 | self.TRANS_MAP = { | 34 | self.TRANS_MAP = { |
| ... | @@ -610,19 +608,19 @@ class Comparison: | ... | @@ -610,19 +608,19 @@ class Comparison: |
| 610 | return self.RESULT_N | 608 | return self.RESULT_N |
| 611 | return self.se_date_compare_2(input_str, ocr_date_set.pop(), three_month=True) | 609 | return self.se_date_compare_2(input_str, ocr_date_set.pop(), three_month=True) |
| 612 | 610 | ||
| 613 | def se_date_compare_pos(self, input_str, ocr_str, **kwargs): | 611 | # def se_date_compare_pos(self, input_str, ocr_str, **kwargs): |
| 614 | try: | 612 | # try: |
| 615 | ocr_date = datetime.strptime(ocr_str, "%Y-%m-%d").date() | 613 | # ocr_date = datetime.strptime(ocr_str, "%Y-%m-%d").date() |
| 616 | today = datetime.now().date() | 614 | # today = datetime.now().date() |
| 617 | if ocr_date < today: | 615 | # if ocr_date < today: |
| 618 | return self.RESULT_N1 | 616 | # return self.RESULT_N1 |
| 619 | elif today <= ocr_date <= (today + timedelta(days=8)): | 617 | # elif today <= ocr_date <= (today + timedelta(days=8)): |
| 620 | return self.RESULT_N2 | 618 | # return self.RESULT_N2 |
| 621 | elif ocr_date > (today + timedelta(days=8)): | 619 | # elif ocr_date > (today + timedelta(days=8)): |
| 622 | return self.RESULT_Y | 620 | # return self.RESULT_Y |
| 623 | except Exception as e: | 621 | # except Exception as e: |
| 624 | return self.RESULT_N | 622 | # return self.RESULT_N |
| 625 | return self.RESULT_N | 623 | # return self.RESULT_N |
| 626 | 624 | ||
| 627 | 625 | ||
| 628 | cp = Comparison() | 626 | cp = Comparison() | ... | ... |
src/pos/pos.py
deleted
100644 → 0
This diff is collapsed.
Click to expand it.
src/pos/pos_compare.py
deleted
100644 → 0
This diff is collapsed.
Click to expand it.
src/pos/pos_consts.py
deleted
100644 → 0
This diff is collapsed.
Click to expand it.
File moved
src/prese/compare.py
0 → 100644
This diff is collapsed.
Click to expand it.
src/prese/consts.py
0 → 100644
| 1 | HIL_SET = {'HIL', 'HIl', 'HiL', 'Hil', 'hIL', 'hIl', 'hiL', 'hil', 'CO00002', 'SF5_CL'} | ||
| 2 | |||
| 3 | ID_TYPE = 'ITPRC' | ||
| 4 | ID_FIELDS = ['姓名', '身份证号码', '有效期限'] | ||
| 5 | |||
| 6 | MVI_FIELDS = ['车架号', '价税合计(小写)', '购买方姓名', '购买方证件号码', '开票日期', '发票联'] | ||
| 7 | MVI_FPL_VALUE = '发票联' | ||
| 8 | |||
| 9 | BC_FIELDS = ['卡号', '开户行名称', '卡片类型'] | ||
| 10 | BC_TYPE_VALUE = '借记卡' | ||
| 11 | |||
| 12 | HMH_FIELDS = ['借款人/承租人姓名', '借款人/承租人证件号', '申请号', '渠道', '签字'] | ||
| 13 | HMH_CHANNEL_MAP = { | ||
| 14 | 'AFC': '宝马金融(中国)有限公司', | ||
| 15 | 'HIL': '先锋国际融资租赁有限公司' | ||
| 16 | } | ||
| 17 | HAVE_CN = '有' | ||
| 18 | |||
| 19 | BD_FIELDS = ['被保险人姓名', '被保险人证件号码', '车架号'] | ||
| 20 | |||
| 21 | ID_EN = 'idCard' | ||
| 22 | MVI_EN = 'newCar Invoice' | ||
| 23 | BC_EN = 'Bank Card' | ||
| 24 | HMH_EN = 'Mortgage Waiver Letter' | ||
| 25 | BD_EN = 'Insurance' | ||
| 26 | |||
| 27 | ID_OCR_FIELD = 'ic_ocr' | ||
| 28 | MVI_OCR_FIELD = 'mvi_ocr' | ||
| 29 | BC_OCR_FIELD = 'bc_ocr' | ||
| 30 | HMH_OCR_FIELD = 'hmh_ocr' | ||
| 31 | BD_FIELD = 'bd_ocr' | ||
| 32 | |||
| 33 | MVI_COMPARE_LOGIC = { | ||
| 34 | MVI_FIELDS[0]: ('车辆识别代码', 'se_common_compare', {}, '发票车架号与系统不一致'), | ||
| 35 | MVI_FIELDS[1]: ('价税合计小写', 'se_amount_compare', {}, '发票车辆价格与系统不一致'), | ||
| 36 | MVI_FIELDS[2]: ('购方名称', 'se_name_compare', {'is_passport': True, 'replace_kuohao': True}, '发票购买方姓名与系统不一致'), | ||
| 37 | MVI_FIELDS[3]: ('购买方身份证号或组织机构代码', 'se_common_compare', {}, '发票购买方证件号码与系统不一致'), | ||
| 38 | MVI_FIELDS[4]: ('开票日期', 'se_date_compare_2', {'three_month': True}, '请确认发票开票日期,若发票开票日期早于首次提交审批日期则无法受理放款申请'), | ||
| 39 | MVI_FIELDS[5]: ('发票类型', 'se_common_compare', {}, '发票疑似非发票联'), | ||
| 40 | } | ||
| 41 | |||
| 42 | BC_COMPARE_LOGIC = { | ||
| 43 | BC_FIELDS[0]: ('CardNum', 'se_common_compare', {'remove_space': True}, '银行卡卡号与系统不一致'), | ||
| 44 | BC_FIELDS[1]: ('BankName', 'se_both_contain_compare', {}, '银行卡开户行与系统不一致'), | ||
| 45 | BC_FIELDS[2]: ('CardType', 'se_common_compare', {}, '银行卡疑似非借记卡'), | ||
| 46 | } | ||
| 47 | |||
| 48 | HMH_COMPARE_LOGIC = { | ||
| 49 | HMH_FIELDS[0]: ('借款/承租人姓名', 'se_name_compare', {}, '抵押登记豁免函借款人/承租人姓名与系统不符'), | ||
| 50 | HMH_FIELDS[1]: ('证件号码', 'se_common_compare', {}, '抵押登记豁免函借款人/承租人证件号码与系统不符'), | ||
| 51 | HMH_FIELDS[2]: ('合同编号', 'se_common_compare', {}, '抵押登记豁免函申请号与系统不符'), | ||
| 52 | HMH_FIELDS[3]: ('渠道', 'se_channel_compare', {}, '抵押登记豁免函渠道与系统不符'), | ||
| 53 | HMH_FIELDS[4]: ('借款人签字/盖章', 'se_common_compare', {}, '抵押登记豁免函无签字'), | ||
| 54 | } | ||
| 55 | |||
| 56 | BD_COMPARE_LOGIC = { | ||
| 57 | BD_FIELDS[0]: ('被保险人姓名', 'super_list_compare', {'method': 'name'}, '保单被保险人姓名与系统不一致'), | ||
| 58 | BD_FIELDS[1]: ('被保险人证件号码', 'super_list_compare', {'method': 'common', 'is_bd_id': True}, '保单身份证号需人工核查'), | ||
| 59 | BD_FIELDS[2]: ('车架号', 'se_common_compare', {}, '保单车架号与系统不一致'), | ||
| 60 | } | ||
| 61 | |||
| 62 | PRE_COMPARE_LOGIC_MAP = { | ||
| 63 | ID_EN: (ID_OCR_FIELD, ID_COMPARE_LOGIC, '请确认是否提供身份证件'), | ||
| 64 | MVI_EN: (MVI_OCR_FIELD, MVI_COMPARE_LOGIC, '请确认是否提供发票'), | ||
| 65 | BC_EN: (BC_OCR_FIELD, BC_COMPARE_LOGIC, '请确认是否提供银行卡'), | ||
| 66 | HMH_EN: (HMH_OCR_FIELD, HMH_COMPARE_LOGIC, '请确认是否已完成抵押登记豁免函签署'), | ||
| 67 | BD_EN: (BD_FIELD, BD_COMPARE_LOGIC, '请确认是否提供保单'), | ||
| 68 | AFC_CONTRACT_EN: (HT_FIELD, HT_COMPARE_LOGIC, '请确认是否已完成车辆抵押贷款合同签署'), | ||
| 69 | HIL_CONTRACT_1_EN: (HIL_CONTRACT_1_FIELD, HIL_CONTRACT_1_COMPARE_LOGIC, '请确认是否已完成售后回租合同签署'), | ||
| 70 | HIL_CONTRACT_2_EN: (HIL_CONTRACT_2_FIELD, HIL_CONTRACT_2_COMPARE_LOGIC, '请确认是否已完成车辆租赁抵押合同签署'), | ||
| 71 | } | ||
| 72 | |||
| 73 | RESULT_Y = 'Y' | ||
| 74 | RESULT_N = 'N' | ||
| 75 |
-
Please register or sign in to post a comment