cms part 2
Showing
6 changed files
with
174 additions
and
22 deletions
... | @@ -1682,4 +1682,12 @@ CMS_TO_POS = [ | ... | @@ -1682,4 +1682,12 @@ CMS_TO_POS = [ |
1682 | TENANT_MAP = { | 1682 | TENANT_MAP = { |
1683 | AFC_PREFIX: 1, | 1683 | AFC_PREFIX: 1, |
1684 | HIL_PREFIX: 2, | 1684 | HIL_PREFIX: 2, |
1685 | } | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1685 | } | ||
1686 | |||
1687 | APPLICANT_TYPE_MAP = { | ||
1688 | 'Borrower': 'CUSTR', | ||
1689 | 'Co Borrower': 'COAPP', | ||
1690 | 'Guarantor': 'GAUTR1', | ||
1691 | 'Mortgager': 'GAUTR2' | ||
1692 | } | ||
1693 | ... | ... |
... | @@ -244,6 +244,33 @@ class HILSEComparisonInfo(models.Model): | ... | @@ -244,6 +244,33 @@ class HILSEComparisonInfo(models.Model): |
244 | 244 | ||
245 | 245 | ||
246 | # 比对信息表 | 246 | # 比对信息表 |
247 | class AFCSECMSInfo(models.Model): | ||
248 | id = models.BigAutoField(primary_key=True, verbose_name="id") # 主键 | ||
249 | application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引 | ||
250 | content = models.TextField(verbose_name="CMS信息") | ||
251 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') | ||
252 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') # 索引 | ||
253 | |||
254 | class Meta: | ||
255 | managed = False | ||
256 | db_table = 'afc_se_cms_info' | ||
257 | situ_db_label = 'afc' | ||
258 | |||
259 | |||
260 | # 比对信息表 | ||
261 | class HILSECMSInfo(models.Model): | ||
262 | id = models.BigAutoField(primary_key=True, verbose_name="id") # 主键 | ||
263 | application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引 | ||
264 | content = models.TextField(verbose_name="CMS信息") | ||
265 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') | ||
266 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') # 索引 | ||
267 | |||
268 | class Meta: | ||
269 | managed = False | ||
270 | db_table = 'hil_se_cms_info' | ||
271 | |||
272 | |||
273 | # 比对信息表 | ||
247 | class HILComparisonInfo(models.Model): | 274 | class HILComparisonInfo(models.Model): |
248 | id = models.BigAutoField(primary_key=True, verbose_name="id") # 主键 | 275 | id = models.BigAutoField(primary_key=True, verbose_name="id") # 主键 |
249 | uniq_seq = models.CharField(max_length=128, verbose_name="唯一序列号") # 索引? | 276 | uniq_seq = models.CharField(max_length=128, verbose_name="唯一序列号") # 索引? | ... | ... |
... | @@ -22,8 +22,10 @@ from .models import ( | ... | @@ -22,8 +22,10 @@ from .models import ( |
22 | GCAPRecords, | 22 | GCAPRecords, |
23 | AFCComparisonInfo, | 23 | AFCComparisonInfo, |
24 | AFCSEComparisonInfo, | 24 | AFCSEComparisonInfo, |
25 | AFCSECMSInfo, | ||
25 | HILComparisonInfo, | 26 | HILComparisonInfo, |
26 | HILSEComparisonInfo, | 27 | HILSEComparisonInfo, |
28 | HILSECMSInfo, | ||
27 | AFCCompareOfflineReport, | 29 | AFCCompareOfflineReport, |
28 | HILCompareOfflineReport, | 30 | HILCompareOfflineReport, |
29 | AFCCACompareResult, | 31 | AFCCACompareResult, |
... | @@ -1091,10 +1093,20 @@ class SECMSView(GenericView): | ... | @@ -1091,10 +1093,20 @@ class SECMSView(GenericView): |
1091 | # pos上传比对信息接口 SE | 1093 | # pos上传比对信息接口 SE |
1092 | @use_args(se_cms_args, location='data') | 1094 | @use_args(se_cms_args, location='data') |
1093 | def post(self, request, args): | 1095 | def post(self, request, args): |
1096 | cms_info = args.get('content', {}) | ||
1097 | business_type = consts.AFC_PREFIX if cms_info.get('financeCompany', '').startswith('宝马') else consts.HIL_PREFIX | ||
1098 | src_application_id = cms_info.get('settlemnetVerification', {}).get('applicationNo', '') | ||
1099 | application_id = src_application_id[:src_application_id.rfind('-')] | ||
1100 | content_str = json.dumps(cms_info) | ||
1094 | 1101 | ||
1102 | comparison_class = HILSECMSInfo if business_type in consts.HIL_SET else AFCSECMSInfo | ||
1103 | comparison_class.objects.create( | ||
1104 | application_id=application_id, | ||
1105 | content=content_str, | ||
1106 | ) | ||
1095 | 1107 | ||
1096 | # 触发比对 | 1108 | # 触发比对 |
1097 | compare.apply_async((application_id, business_type, uniq_seq, None, False, True), | 1109 | compare.apply_async((application_id, business_type, None, None, False, True), |
1098 | queue='queue_compare') | 1110 | queue='queue_compare') |
1099 | return response.ok() | 1111 | return response.ok() |
1100 | 1112 | ... | ... |
... | @@ -13,8 +13,10 @@ from apps.doc.models import ( | ... | @@ -13,8 +13,10 @@ from apps.doc.models import ( |
13 | HILSEOCRResult, | 13 | HILSEOCRResult, |
14 | AFCComparisonInfo, | 14 | AFCComparisonInfo, |
15 | AFCSEComparisonInfo, | 15 | AFCSEComparisonInfo, |
16 | AFCSECMSInfo, | ||
16 | HILComparisonInfo, | 17 | HILComparisonInfo, |
17 | HILSEComparisonInfo, | 18 | HILSEComparisonInfo, |
19 | HILSECMSInfo, | ||
18 | Configs, | 20 | Configs, |
19 | HILCompareReport, | 21 | HILCompareReport, |
20 | AFCCompareReport, | 22 | AFCCompareReport, |
... | @@ -29,11 +31,13 @@ from apps.doc.ocr.cms import cms | ... | @@ -29,11 +31,13 @@ from apps.doc.ocr.cms import cms |
29 | from apps.doc.exceptions import GCAPException | 31 | from apps.doc.exceptions import GCAPException |
30 | from apps.doc.named_enum import RequestTeam, RequestTrigger, ProcessName, ErrorType | 32 | from apps.doc.named_enum import RequestTeam, RequestTrigger, ProcessName, ErrorType |
31 | from common.tools.comparison import cp | 33 | from common.tools.comparison import cp |
34 | from common.tools.des import decode_des | ||
32 | 35 | ||
33 | compare_log = logging.getLogger('compare') | 36 | compare_log = logging.getLogger('compare') |
34 | log_base = '[Compare]' | 37 | log_base = '[Compare]' |
35 | empty_str = '' | 38 | empty_str = '' |
36 | empty_error_type = 1000 | 39 | empty_error_type = 1000 |
40 | des_key = conf.CMS_DES_KEY | ||
37 | 41 | ||
38 | 42 | ||
39 | class FakePOS: | 43 | class FakePOS: |
... | @@ -42,19 +46,11 @@ class FakePOS: | ... | @@ -42,19 +46,11 @@ class FakePOS: |
42 | application_id, | 46 | application_id, |
43 | first_submmison_date, | 47 | first_submmison_date, |
44 | application_version, | 48 | application_version, |
45 | customer_type, | 49 | customer_type): |
46 | individual_cus_info, | ||
47 | corporate_cus_info, | ||
48 | vehicle_info, | ||
49 | bank_info): | ||
50 | self.application_id = application_id | 50 | self.application_id = application_id |
51 | self.first_submmison_date = first_submmison_date | 51 | self.first_submmison_date = first_submmison_date |
52 | self.application_version = application_version | 52 | self.application_version = application_version |
53 | self.customer_type = customer_type | 53 | self.customer_type = customer_type |
54 | self.individual_cus_info = individual_cus_info | ||
55 | self.corporate_cus_info = corporate_cus_info | ||
56 | self.vehicle_info = vehicle_info | ||
57 | self.bank_info = bank_info | ||
58 | 54 | ||
59 | 55 | ||
60 | def name_check(ocr_res_dict, second_ocr_field, second_compare_list, second_id_num, name): | 56 | def name_check(ocr_res_dict, second_ocr_field, second_compare_list, second_id_num, name): |
... | @@ -903,7 +899,7 @@ def get_se_compare_info(last_obj, application_entity, detect_list): | ... | @@ -903,7 +899,7 @@ def get_se_compare_info(last_obj, application_entity, detect_list): |
903 | return compare_info, is_gsyh | 899 | return compare_info, is_gsyh |
904 | 900 | ||
905 | 901 | ||
906 | def rebuild_compare_info(last_obj): | 902 | def rebuild_compare_info(last_obj, application_id): |
907 | # { | 903 | # { |
908 | # "content": { | 904 | # "content": { |
909 | # "financeCompany": "宝马汽车金融有限公司", | 905 | # "financeCompany": "宝马汽车金融有限公司", |
... | @@ -1005,14 +1001,69 @@ def rebuild_compare_info(last_obj): | ... | @@ -1005,14 +1001,69 @@ def rebuild_compare_info(last_obj): |
1005 | # } | 1001 | # } |
1006 | # } | 1002 | # } |
1007 | 1003 | ||
1008 | return FakePOS(application_id, | 1004 | cms_info = json.loads(last_obj.content) |
1009 | first_submmison_date, | 1005 | |
1010 | application_version, | 1006 | fake_pos = FakePOS(application_id, |
1011 | customer_type, | 1007 | cms_info.get('submissionDate', ''), |
1012 | individual_cus_info, | 1008 | cms_info.get('applicationVersion', 1), |
1013 | corporate_cus_info, | 1009 | cms_info.get('applicantInformation', [])[0].get('customersubType', '')) |
1014 | vehicle_info, | 1010 | |
1015 | bank_info) | 1011 | fake_pos.bank_info = json.dumps( |
1012 | { | ||
1013 | 'accountNo': decode_des(cms_info.get('bankAccountDetails', {}).get('accountNo', ''), des_key), | ||
1014 | 'bankName': cms_info.get('bankAccountDetails', {}).get('bankName', ''), | ||
1015 | 'accountHolderName': cms_info.get('bankAccountDetails', {}).get('accountHolderName', ''), | ||
1016 | } | ||
1017 | ) | ||
1018 | |||
1019 | fake_pos.vehicle_info = json.dumps( | ||
1020 | { | ||
1021 | 'vehicleStatus': cms_info.get('vehicleStatus', ''), | ||
1022 | 'vinNo': cms_info.get('vehicleInformation', {}).get('vinNo', ''), | ||
1023 | 'dealer': cms_info.get('dealerName', ''), | ||
1024 | 'vehicleTransactionAmount': str(cms_info.get('totalFinanceAmount', '')), | ||
1025 | } | ||
1026 | ) | ||
1027 | |||
1028 | individual_cus_info = [] | ||
1029 | for individual_cus in cms_info.get('applicantInformation', []): | ||
1030 | id_type = id_num = id_date = second_id_type = second_id_num = None | ||
1031 | for idx, id_info in enumerate(individual_cus.get('', [])): | ||
1032 | if idx > 1: | ||
1033 | break | ||
1034 | elif idx == 0: | ||
1035 | id_type = id_info.get('idType') | ||
1036 | id_num = decode_des(id_info.get('idNum')) | ||
1037 | id_date = id_info.get('idExpiryDate') | ||
1038 | else: | ||
1039 | second_id_type = id_info.get('idType') | ||
1040 | second_id_num = decode_des(id_info.get('idNum')) | ||
1041 | individual_cus_info.append( | ||
1042 | { | ||
1043 | 'applicantType': consts.APPLICANT_TYPE_MAP.get(individual_cus.get('applicantType')), | ||
1044 | 'customerType': individual_cus.get('customersubType'), | ||
1045 | |||
1046 | 'idType': id_type, | ||
1047 | 'idNum': id_num, | ||
1048 | 'idExpiryDate': id_date, | ||
1049 | |||
1050 | 'customerName': individual_cus.get('name'), | ||
1051 | 'dateOfBirth': individual_cus.get('dateOfBirth', ''), | ||
1052 | 'hukouProvince': cms_info.get('province', ''), | ||
1053 | |||
1054 | 'secondIdType': second_id_type, | ||
1055 | 'secondIdNum': second_id_num, | ||
1056 | |||
1057 | 'companyName': individual_cus.get('name'), | ||
1058 | 'selfEmployedSubType': individual_cus.get('selfEmployedSubType', ''), | ||
1059 | } | ||
1060 | ) | ||
1061 | |||
1062 | fake_pos.individual_cus_info = json.dumps(individual_cus_info) | ||
1063 | |||
1064 | fake_pos.corporate_cus_info = None | ||
1065 | |||
1066 | return fake_pos | ||
1016 | 1067 | ||
1017 | 1068 | ||
1018 | def se_compare_license(license_en, ocr_res_dict, field_list): | 1069 | def se_compare_license(license_en, ocr_res_dict, field_list): |
... | @@ -1235,7 +1286,7 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res | ... | @@ -1235,7 +1286,7 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res |
1235 | start_time = datetime.now() | 1286 | start_time = datetime.now() |
1236 | detect_list = se_result_detect(ocr_res_dict) | 1287 | detect_list = se_result_detect(ocr_res_dict) |
1237 | if is_cms: | 1288 | if is_cms: |
1238 | last_obj = rebuild_compare_info(last_obj) | 1289 | last_obj = rebuild_compare_info(last_obj, application_id) |
1239 | compare_info, is_gsyh = get_se_compare_info(last_obj, application_entity, detect_list) | 1290 | compare_info, is_gsyh = get_se_compare_info(last_obj, application_entity, detect_list) |
1240 | compare_result, total_fields, failed_count, successful_at_this_level, failure_reason_str = se_compare_process( | 1291 | compare_result, total_fields, failed_count, successful_at_this_level, failure_reason_str = se_compare_process( |
1241 | compare_info, ocr_res_dict, is_gsyh) | 1292 | compare_info, ocr_res_dict, is_gsyh) |
... | @@ -1331,7 +1382,10 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True | ... | @@ -1331,7 +1382,10 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True |
1331 | if is_ca: | 1382 | if is_ca: |
1332 | comparison_class = HILComparisonInfo if application_entity == consts.HIL_PREFIX else AFCComparisonInfo | 1383 | comparison_class = HILComparisonInfo if application_entity == consts.HIL_PREFIX else AFCComparisonInfo |
1333 | else: | 1384 | else: |
1334 | comparison_class = HILSEComparisonInfo if application_entity == consts.HIL_PREFIX else AFCSEComparisonInfo | 1385 | if application_entity == consts.HIL_PREFIX: |
1386 | comparison_class = HILSECMSInfo if is_cms else HILSEComparisonInfo | ||
1387 | else: | ||
1388 | comparison_class = AFCSECMSInfo if is_cms else AFCSEComparisonInfo | ||
1335 | last_obj = comparison_class.objects.filter(application_id=application_id).last() | 1389 | last_obj = comparison_class.objects.filter(application_id=application_id).last() |
1336 | if last_obj is None: | 1390 | if last_obj is None: |
1337 | compare_log.info('{0} [comparison info empty] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}] ' | 1391 | compare_log.info('{0} [comparison info empty] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}] ' | ... | ... |
src/common/tools/mssql_script9.py
0 → 100644
1 | import pyodbc | ||
2 | |||
3 | hil_sql = """ | ||
4 | create table afc_se_cms_info | ||
5 | ( | ||
6 | id bigint identity primary key, | ||
7 | application_id nvarchar(64) not null, | ||
8 | content nvarchar(max) not null, | ||
9 | update_time datetime not null, | ||
10 | create_time datetime not null | ||
11 | ); | ||
12 | |||
13 | create index afc_se_cms_info_application_id_index | ||
14 | on afc_se_cms_info (application_id); | ||
15 | |||
16 | create index afc_se_cms_info_create_time_index | ||
17 | on afc_se_cms_info (create_time); | ||
18 | """ | ||
19 | |||
20 | afc_sql = """ | ||
21 | create table hil_se_cms_info | ||
22 | ( | ||
23 | id bigint identity primary key, | ||
24 | application_id nvarchar(64) not null, | ||
25 | content nvarchar(max) not null, | ||
26 | update_time datetime not null, | ||
27 | create_time datetime not null | ||
28 | ); | ||
29 | |||
30 | create index hil_se_cms_info_application_id_index | ||
31 | on hil_se_cms_info (application_id); | ||
32 | |||
33 | create index hil_se_cms_info_create_time_index | ||
34 | on hil_se_cms_info (create_time); | ||
35 | """ | ||
36 | |||
37 | hil_cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};', autocommit=True) | ||
38 | |||
39 | hil_cursor = hil_cnxn.cursor() | ||
40 | hil_cursor.execute(hil_sql) | ||
41 | |||
42 | hil_cursor.close() | ||
43 | hil_cnxn.close() | ||
44 | |||
45 | afc_cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};', autocommit=True) | ||
46 | |||
47 | afc_cursor = afc_cnxn.cursor() | ||
48 | afc_cursor.execute(afc_sql) | ||
49 | |||
50 | afc_cursor.close() | ||
51 | afc_cnxn.close() |
-
Please register or sign in to post a comment