Merge branch 'feature/cms4' into feature/0918
Showing
3 changed files
with
32 additions
and
13 deletions
| ... | @@ -22,7 +22,7 @@ class CMS: | ... | @@ -22,7 +22,7 @@ class CMS: |
| 22 | self.token_type_key = 'token_type' | 22 | self.token_type_key = 'token_type' |
| 23 | 23 | ||
| 24 | def update_token(self): | 24 | def update_token(self): |
| 25 | response = requests.post(self.oauth_url, data=self.oauth_payload, files=[]) | 25 | response = requests.post(self.oauth_url, data=self.oauth_payload, files=[], verify=False) |
| 26 | if response.status_code != 200: | 26 | if response.status_code != 200: |
| 27 | raise CMSException('CMS Oauth response with code: {0}'.format(response.status_code)) | 27 | raise CMSException('CMS Oauth response with code: {0}'.format(response.status_code)) |
| 28 | token = response.json().get(self.token_key) | 28 | token = response.json().get(self.token_key) |
| ... | @@ -46,7 +46,7 @@ class CMS: | ... | @@ -46,7 +46,7 @@ class CMS: |
| 46 | 'Authorization': '{0} {1}'.format(self.token_type.capitalize(), token), | 46 | 'Authorization': '{0} {1}'.format(self.token_type.capitalize(), token), |
| 47 | 'Content-Type': 'application/json', | 47 | 'Content-Type': 'application/json', |
| 48 | } | 48 | } |
| 49 | response = requests.post(self.url, headers=headers, json=payload) | 49 | response = requests.post(self.url, headers=headers, json=payload, verify=False) |
| 50 | if response.status_code != 200: | 50 | if response.status_code != 200: |
| 51 | raise CMSException('CMS Oauth response with code: {0}'.format(response.status_code)) | 51 | raise CMSException('CMS Oauth response with code: {0}'.format(response.status_code)) |
| 52 | return response.json() | 52 | return response.json() | ... | ... |
| ... | @@ -823,7 +823,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): | ... | @@ -823,7 +823,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): |
| 823 | vehicle_status = cms_info.get('vehicleStatus', '') | 823 | vehicle_status = cms_info.get('vehicleStatus', '') |
| 824 | first_submmison_date = cms_info.get('submissionDate', '') | 824 | first_submmison_date = cms_info.get('submissionDate', '') |
| 825 | vin_no = cms_info.get('vehicleInformation', {}).get('vinNo', '') | 825 | vin_no = cms_info.get('vehicleInformation', {}).get('vinNo', '') |
| 826 | amount = str(cms_info.get('totalFinanceAmount', '')) | 826 | amount = str(cms_info.get('financialInformation', {}).get('vehiclePrice', '')) |
| 827 | if vehicle_status == 'New': | 827 | if vehicle_status == 'New': |
| 828 | vehicle_field_input.append(('vinNo', vin_no)) | 828 | vehicle_field_input.append(('vinNo', vin_no)) |
| 829 | vehicle_field_input.append(('dealer', cms_info.get('dealerName', ''))) | 829 | vehicle_field_input.append(('dealer', cms_info.get('dealerName', ''))) |
| ... | @@ -901,7 +901,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): | ... | @@ -901,7 +901,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): |
| 901 | bank_info[consts.DDA_EN] = dda_field_input | 901 | bank_info[consts.DDA_EN] = dda_field_input |
| 902 | compare_info['bankInfo'] = bank_info | 902 | compare_info['bankInfo'] = bank_info |
| 903 | 903 | ||
| 904 | if not detect_list[2]: | 904 | if cms_info.get('mortgageType', '') == 'Mortgage Free': |
| 905 | other_info = {} | 905 | other_info = {} |
| 906 | hmh_field_input = [ | 906 | hmh_field_input = [ |
| 907 | (consts.SE_HMH_FIELD[0], hmh_name), | 907 | (consts.SE_HMH_FIELD[0], hmh_name), |
| ... | @@ -1399,8 +1399,14 @@ def se_compare_process(compare_info, ocr_res_dict): | ... | @@ -1399,8 +1399,14 @@ def se_compare_process(compare_info, ocr_res_dict): |
| 1399 | for idx, license_list in info_value.items(): | 1399 | for idx, license_list in info_value.items(): |
| 1400 | for license_dict in license_list: | 1400 | for license_dict in license_list: |
| 1401 | for license_en, field_list in license_dict.items(): | 1401 | for license_en, field_list in license_dict.items(): |
| 1402 | strip_list = [] | ||
| 1403 | for a, b in field_list: | ||
| 1404 | if isinstance(b, str): | ||
| 1405 | strip_list.append((a, b.strip())) | ||
| 1406 | else: | ||
| 1407 | strip_list.append((a, b)) | ||
| 1402 | failure_field = [] | 1408 | failure_field = [] |
| 1403 | result_field_list, no_ocr_result = se_compare_license(license_en, ocr_res_dict, field_list) | 1409 | result_field_list, no_ocr_result = se_compare_license(license_en, ocr_res_dict, strip_list) |
| 1404 | for name, value, result, ocr_str, img_path, error_type in result_field_list: | 1410 | for name, value, result, ocr_str, img_path, error_type in result_field_list: |
| 1405 | if license_en not in consts.SKIP_CARD or not no_ocr_result: | 1411 | if license_en not in consts.SKIP_CARD or not no_ocr_result: |
| 1406 | total_fields += 1 | 1412 | total_fields += 1 |
| ... | @@ -1426,11 +1432,17 @@ def se_compare_process(compare_info, ocr_res_dict): | ... | @@ -1426,11 +1432,17 @@ def se_compare_process(compare_info, ocr_res_dict): |
| 1426 | failure_reason.setdefault(info_key, []).append(';'.join(failure_field)) | 1432 | failure_reason.setdefault(info_key, []).append(';'.join(failure_field)) |
| 1427 | else: | 1433 | else: |
| 1428 | for license_en, field_list in info_value.items(): | 1434 | for license_en, field_list in info_value.items(): |
| 1435 | strip_list = [] | ||
| 1436 | for a, b in field_list: | ||
| 1437 | if isinstance(b, str): | ||
| 1438 | strip_list.append((a, b.strip())) | ||
| 1439 | else: | ||
| 1440 | strip_list.append((a, b)) | ||
| 1429 | failure_field = [] | 1441 | failure_field = [] |
| 1430 | if license_en == consts.MVC34_EN: | 1442 | if license_en == consts.MVC34_EN: |
| 1431 | result_field_list = se_mvc34_compare(license_en, ocr_res_dict, field_list) | 1443 | result_field_list = se_mvc34_compare(license_en, ocr_res_dict, strip_list) |
| 1432 | else: | 1444 | else: |
| 1433 | result_field_list, _ = se_compare_license(license_en, ocr_res_dict, field_list) | 1445 | result_field_list, _ = se_compare_license(license_en, ocr_res_dict, strip_list) |
| 1434 | for name, value, result, ocr_str, img_path, error_type in result_field_list: | 1446 | for name, value, result, ocr_str, img_path, error_type in result_field_list: |
| 1435 | total_fields += 1 | 1447 | total_fields += 1 |
| 1436 | if result == consts.RESULT_N: | 1448 | if result == consts.RESULT_N: |
| ... | @@ -1505,7 +1517,8 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res | ... | @@ -1505,7 +1517,8 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res |
| 1505 | res_obj.compare_count = total_fields | 1517 | res_obj.compare_count = total_fields |
| 1506 | res_obj.failed_count = failed_count | 1518 | res_obj.failed_count = failed_count |
| 1507 | res_obj.is_finish = successful_at_this_level | 1519 | res_obj.is_finish = successful_at_this_level |
| 1508 | res_obj.version = '{0}{1}{2}'.format(consts.INFO_SOURCE[0], consts.SPLIT_STR, application_version) | 1520 | source = consts.INFO_SOURCE[1] if is_cms else consts.INFO_SOURCE[0] |
| 1521 | res_obj.version = '{0}{1}{2}'.format(source, consts.SPLIT_STR, application_version) | ||
| 1509 | # res_obj.reason1_count = reason1_count | 1522 | # res_obj.reason1_count = reason1_count |
| 1510 | res_obj.result = json.dumps(compare_result) | 1523 | res_obj.result = json.dumps(compare_result) |
| 1511 | res_obj.update_time = datetime.now() | 1524 | res_obj.update_time = datetime.now() | ... | ... |
| ... | @@ -44,11 +44,17 @@ def encode_des(to_encode_str, des_key): | ... | @@ -44,11 +44,17 @@ def encode_des(to_encode_str, des_key): |
| 44 | 44 | ||
| 45 | 45 | ||
| 46 | def un_des_pad(data): | 46 | def un_des_pad(data): |
| 47 | result_byte = data[0:4] | 47 | # print(data) |
| 48 | e = struct.unpack('>I', result_byte)[0] | 48 | # result_byte = data[0:4] |
| 49 | x = (e + 4) % 8 | 49 | # print(result_byte) |
| 50 | y = 0 if x == 0 else 8 - x | 50 | # e = struct.unpack('>I', result_byte)[0] |
| 51 | return data[4:] if y == 0 else data[4:-y] | 51 | # x = (e + 4) % 8 |
| 52 | # y = 0 if x == 0 else 8 - x | ||
| 53 | # print(y) | ||
| 54 | # return data[:-4] if y == 0 else data[:-y] | ||
| 55 | |||
| 56 | offset = data[-1] | ||
| 57 | return data[:-offset] | ||
| 52 | 58 | ||
| 53 | 59 | ||
| 54 | def decode_des(to_decode_str, des_key): | 60 | def decode_des(to_decode_str, des_key): | ... | ... |
-
Please register or sign in to post a comment