add pre contract
Showing
2 changed files
with
191 additions
and
7 deletions
... | @@ -51,11 +51,11 @@ def get_pos_compare_info(pos_info): | ... | @@ -51,11 +51,11 @@ def get_pos_compare_info(pos_info): |
51 | # 银行卡 | 51 | # 银行卡 |
52 | bank_info = pos_info.get('bankInfo', {}) | 52 | bank_info = pos_info.get('bankInfo', {}) |
53 | bank_status = bank_info.get('bankVerificationStatus', '') | 53 | bank_status = bank_info.get('bankVerificationStatus', '') |
54 | |||
55 | if bank_status != 'PASS': | ||
56 | account_no = bank_info.get('accountNo', '') | 54 | account_no = bank_info.get('accountNo', '') |
57 | bank_name = bank_info.get('bankName', '') | 55 | bank_name = bank_info.get('bankName', '') |
56 | account_holder_name = bank_info.get('accountHolderName', '') | ||
58 | 57 | ||
58 | if bank_status != 'PASS': | ||
59 | field_input = [ | 59 | field_input = [ |
60 | (consts.BC_FIELDS[0], account_no), | 60 | (consts.BC_FIELDS[0], account_no), |
61 | (consts.BC_FIELDS[1], bank_name), | 61 | (consts.BC_FIELDS[1], bank_name), |
... | @@ -86,12 +86,91 @@ def get_pos_compare_info(pos_info): | ... | @@ -86,12 +86,91 @@ def get_pos_compare_info(pos_info): |
86 | ] | 86 | ] |
87 | compare_info.setdefault(consts.BD_EN, []).append(field_input) | 87 | compare_info.setdefault(consts.BD_EN, []).append(field_input) |
88 | 88 | ||
89 | # 合同准备项 | ||
90 | # 还款计划表 | ||
91 | schedule_list = [] | ||
92 | for schedule_dict in quotationt_info.get('monthlyPaymentInfo', []): | ||
93 | tmp_str = "{1}{0}{2}".format(consts.SPLIT_STR, str(schedule_dict.get('term', '')), | ||
94 | str(schedule_dict.get('amount', ''))) | ||
95 | schedule_list.append(tmp_str) | ||
96 | schedule_list_str = consts.SCHEDULE_SPLIT_STR.join(schedule_list) | ||
97 | |||
98 | # asp | ||
99 | asp_list = [] | ||
100 | for asp_info in quotationt_info.get('associatedServiceInfo', []): | ||
101 | asp_list.append( | ||
102 | ( | ||
103 | asp_info.get('service', ''), | ||
104 | str(asp_info.get('amount', '0.00')), | ||
105 | str(asp_info.get('financedAmount', '0.00')), | ||
106 | ) | ||
107 | ) | ||
108 | if len(asp_list) > 0: | ||
109 | asp_list.append( | ||
110 | ( | ||
111 | consts.ASP_SUM_NAME, | ||
112 | '', | ||
113 | format(quotationt_info.get('associatedServicePrincipal', 0), '.2f'), | ||
114 | ) | ||
115 | ) | ||
116 | |||
89 | # HIL合同 | 117 | # HIL合同 |
90 | if application_entity in consts.HIL_SET: | 118 | if application_entity in consts.HIL_SET: |
91 | pass | 119 | # HIL合同 售后回租合同 -------------------------------------------------------------------------------------- |
120 | # ['合同编号-每页', '车辆识别代码', '还款计划表', '还款账号', '户名', '开户行', 'ASP项目详情'] | ||
121 | hil_contract_1_input = [ | ||
122 | (consts.HIL_CON_1_FIELDS[0], [application_id_version]), | ||
123 | (consts.HIL_CON_1_FIELDS[1], vin_no), | ||
124 | (consts.HIL_CON_1_FIELDS[2], schedule_list_str), | ||
125 | (consts.HIL_CON_1_FIELDS[3], account_no), | ||
126 | (consts.HIL_CON_1_FIELDS[4], account_holder_name), | ||
127 | (consts.HIL_CON_1_FIELDS[5], bank_name), | ||
128 | ] | ||
129 | # asp各项 | ||
130 | if len(asp_list) > 0: | ||
131 | hil_contract_1_input.append((consts.HIL_CON_1_FIELDS[6], asp_list)) | ||
132 | compare_info.setdefault(consts.HIL_CONTRACT_1_EN, []).append(hil_contract_1_input) | ||
133 | |||
134 | # HIL合同 车辆租赁抵押合同 -------------------------------------------------------------------------------------- | ||
135 | # ['合同编号', '合同编号-正文', '车辆识别代码'] | ||
136 | hil_contract_2_input = [ | ||
137 | (consts.HIL_CON_2_FIELDS[0], application_id_version), | ||
138 | (consts.HIL_CON_2_FIELDS[1], application_id_version), | ||
139 | (consts.HIL_CON_2_FIELDS[2], vin_no), | ||
140 | ] | ||
141 | compare_info.setdefault(consts.HIL_CONTRACT_2_EN, []).append(hil_contract_2_input) | ||
142 | |||
92 | # AFC合同 | 143 | # AFC合同 |
93 | else: | 144 | else: |
94 | pass | 145 | # ['合同编号-每页', '合同编号-每页(no-asp)', '车架号-重要条款', '车架号', '还款账号', '户名', '开户行', '还款计划表', |
146 | # 'ASP项目详情-重要条款', 'ASP项目详情', '见证人签字', '见证人日期'] | ||
147 | |||
148 | if len(asp_list) > 0: | ||
149 | afc_contract_input = [ | ||
150 | (consts.AFC_CON_FIELDS[0], application_id_version), | ||
151 | ] | ||
152 | else: | ||
153 | afc_contract_input = [ | ||
154 | (consts.AFC_CON_FIELDS[1], application_id_version), | ||
155 | ] | ||
156 | |||
157 | afc_contract_input.extend([ | ||
158 | (consts.AFC_CON_FIELDS[2], vin_no), | ||
159 | (consts.AFC_CON_FIELDS[3], vin_no), | ||
160 | (consts.AFC_CON_FIELDS[4], account_no), | ||
161 | (consts.AFC_CON_FIELDS[5], account_holder_name), | ||
162 | (consts.AFC_CON_FIELDS[6], bank_name), | ||
163 | (consts.AFC_CON_FIELDS[7], schedule_list_str), | ||
164 | ]) | ||
165 | |||
166 | if len(asp_list) > 0: | ||
167 | # asp各项 | ||
168 | afc_contract_input.append((consts.AFC_CON_FIELDS[8], asp_list)) | ||
169 | afc_contract_input.append((consts.AFC_CON_FIELDS[9], asp_list)) | ||
170 | |||
171 | afc_contract_input.append((consts.AFC_CON_FIELDS[10], consts.HAVE_CN)) | ||
172 | afc_contract_input.append((consts.AFC_CON_FIELDS[11], empty_str)) | ||
173 | compare_info.setdefault(consts.AFC_CONTRACT_EN, []).append(afc_contract_input) | ||
95 | 174 | ||
96 | return compare_info | 175 | return compare_info |
97 | 176 | ||
... | @@ -103,9 +182,10 @@ def pre_compare_process(compare_info, ocr_res_dict, id_res_list): | ... | @@ -103,9 +182,10 @@ def pre_compare_process(compare_info, ocr_res_dict, id_res_list): |
103 | for field_list in items_list: | 182 | for field_list in items_list: |
104 | result_list = pre_compare_license_id(license_en, id_res_list, field_list) | 183 | result_list = pre_compare_license_id(license_en, id_res_list, field_list) |
105 | compare_result.setdefault(license_en, []).append(result_list) | 184 | compare_result.setdefault(license_en, []).append(result_list) |
106 | elif license_en in [consts.HIL_CONTRACT_1_EN, consts.HIL_CONTRACT_2_EN, | 185 | elif license_en in [consts.HIL_CONTRACT_1_EN, consts.HIL_CONTRACT_2_EN, consts.AFC_CONTRACT_EN]: |
107 | consts.HIL_CONTRACT_3_EN, consts.AFC_CONTRACT_EN]: | 186 | for field_list in items_list: |
108 | pass | 187 | result_list = pre_compare_license_contract(license_en, ocr_res_dict, field_list) |
188 | compare_result.setdefault(license_en, []).append(result_list) | ||
109 | else: | 189 | else: |
110 | for field_list in items_list: | 190 | for field_list in items_list: |
111 | result_list = pre_compare_license(license_en, ocr_res_dict, field_list) | 191 | result_list = pre_compare_license(license_en, ocr_res_dict, field_list) |
... | @@ -227,6 +307,57 @@ def pre_compare_license_id(license_en, id_res_list, field_list): | ... | @@ -227,6 +307,57 @@ def pre_compare_license_id(license_en, id_res_list, field_list): |
227 | return result_field_list | 307 | return result_field_list |
228 | 308 | ||
229 | 309 | ||
310 | def pre_compare_license_contract(license_en, ocr_res_dict, field_list): | ||
311 | ocr_field, compare_logic, no_find_comment = consts.PRE_COMPARE_LOGIC_MAP[license_en] | ||
312 | |||
313 | result_field_list = [] | ||
314 | |||
315 | ocr_res_str = ocr_res_dict.get(ocr_field) | ||
316 | if ocr_res_str is not None: | ||
317 | ocr_res_list = json.loads(ocr_res_str) | ||
318 | ocr_res = ocr_res_list.pop() | ||
319 | |||
320 | for name, value in field_list: | ||
321 | ocr_str_or_list = ocr_res.get(compare_logic[name][0]) | ||
322 | |||
323 | # 见证人日期 | ||
324 | if name == consts.AFC_CON_FIELDS[11]: | ||
325 | if not isinstance(ocr_str_or_list, str) or len(ocr_str_or_list) == 0: | ||
326 | result = consts.RESULT_N | ||
327 | ocr_str = empty_str | ||
328 | else: | ||
329 | is_find_date = False | ||
330 | all_date_list = [ocr_str_or_list] | ||
331 | for date_name in consts.AFC_HT_DATE_FIELDS: | ||
332 | all_date_list.append(ocr_res.get(compare_logic[date_name][0], '')) | ||
333 | if not is_find_date and ocr_str_or_list == ocr_res.get(compare_logic[date_name][0], ''): | ||
334 | is_find_date = True | ||
335 | result = consts.RESULT_Y if is_find_date else consts.RESULT_N | ||
336 | ocr_str = json.dumps(all_date_list, ensure_ascii=False) | ||
337 | elif isinstance(ocr_str_or_list, str) or isinstance(ocr_str_or_list, list): | ||
338 | if isinstance(ocr_str_or_list, list): | ||
339 | # no-asp 合同编号-每页(no-asp) | ||
340 | if name == consts.AFC_CON_FIELDS[1]: | ||
341 | ocr_str_or_list.pop() | ||
342 | ocr_str = json.dumps(ocr_str_or_list, ensure_ascii=False) | ||
343 | else: | ||
344 | ocr_str_or_list = ocr_str_or_list.strip() | ||
345 | ocr_str = ocr_str_or_list | ||
346 | result = getattr(cp, compare_logic[name][1])(value, ocr_str_or_list, **compare_logic[name][2]) | ||
347 | else: | ||
348 | result = consts.RESULT_N | ||
349 | ocr_str = empty_str | ||
350 | |||
351 | comments = compare_logic[name][3] | ||
352 | if isinstance(value, list): | ||
353 | value = json.dumps(value, ensure_ascii=False) | ||
354 | result_field_list.append((value, ocr_str, result, comments)) | ||
355 | else: | ||
356 | result_field_list.append((empty_str, empty_str, consts.RESULT_N, no_find_comment)) | ||
357 | |||
358 | return result_field_list | ||
359 | |||
360 | |||
230 | def rebuild_result(compare_result): | 361 | def rebuild_result(compare_result): |
231 | # compare_result = { | 362 | # compare_result = { |
232 | # "is_pass": True, | 363 | # "is_pass": True, | ... | ... |
1 | SPLIT_STR = '_' | ||
2 | SCHEDULE_SPLIT_STR = '、' | ||
3 | |||
1 | HIL_SET = {'HIL', 'HIl', 'HiL', 'Hil', 'hIL', 'hIl', 'hiL', 'hil', 'CO00002', 'SF5_CL'} | 4 | HIL_SET = {'HIL', 'HIl', 'HiL', 'Hil', 'hIL', 'hIl', 'hiL', 'hil', 'CO00002', 'SF5_CL'} |
2 | 5 | ||
3 | ID_TYPE = 'ITPRC' | 6 | ID_TYPE = 'ITPRC' |
... | @@ -18,17 +21,32 @@ HAVE_CN = '有' | ... | @@ -18,17 +21,32 @@ HAVE_CN = '有' |
18 | 21 | ||
19 | BD_FIELDS = ['被保险人姓名', '被保险人证件号码', '车架号'] | 22 | BD_FIELDS = ['被保险人姓名', '被保险人证件号码', '车架号'] |
20 | 23 | ||
24 | HIL_CON_1_FIELDS = ['合同编号-每页', '车辆识别代码', '还款计划表', '还款账号', '户名', '开户行', 'ASP项目详情'] | ||
25 | ASP_SUM_NAME = '附加产品融资贷款本金总金额' | ||
26 | |||
27 | HIL_CON_2_FIELDS = ['合同编号', '合同编号-正文', '车辆识别代码'] | ||
28 | |||
29 | AFC_CON_FIELDS = ['合同编号-每页', '合同编号-每页(no-asp)', '车架号-重要条款', '车架号', '还款账号', '户名', '开户行', | ||
30 | '还款计划表', 'ASP项目详情-重要条款', 'ASP项目详情', '见证人签字', '见证人日期'] | ||
31 | AFC_HT_DATE_FIELDS = ['主借人日期', '共借人日期', '保证人日期1', '保证人日期2'] | ||
32 | |||
21 | ID_EN = 'idCard' | 33 | ID_EN = 'idCard' |
22 | MVI_EN = 'newCar Invoice' | 34 | MVI_EN = 'newCar Invoice' |
23 | BC_EN = 'Bank Card' | 35 | BC_EN = 'Bank Card' |
24 | HMH_EN = 'Mortgage Waiver Letter' | 36 | HMH_EN = 'Mortgage Waiver Letter' |
25 | BD_EN = 'Insurance' | 37 | BD_EN = 'Insurance' |
38 | HIL_CONTRACT_1_EN = '售后回租合同' | ||
39 | HIL_CONTRACT_2_EN = '车辆租赁抵押合同' | ||
40 | AFC_CONTRACT_EN = '合同' | ||
26 | 41 | ||
27 | ID_OCR_FIELD = 'ic_ocr' | 42 | ID_OCR_FIELD = 'ic_ocr' |
28 | MVI_OCR_FIELD = 'mvi_ocr' | 43 | MVI_OCR_FIELD = 'mvi_ocr' |
29 | BC_OCR_FIELD = 'bc_ocr' | 44 | BC_OCR_FIELD = 'bc_ocr' |
30 | HMH_OCR_FIELD = 'hmh_ocr' | 45 | HMH_OCR_FIELD = 'hmh_ocr' |
31 | BD_FIELD = 'bd_ocr' | 46 | BD_FIELD = 'bd_ocr' |
47 | HIL_CONTRACT_1_FIELD = 'hil_contract_1_ocr' | ||
48 | HIL_CONTRACT_2_FIELD = 'hil_contract_2_ocr' | ||
49 | HT_FIELD = 'ht_ocr' | ||
32 | 50 | ||
33 | MVI_COMPARE_LOGIC = { | 51 | MVI_COMPARE_LOGIC = { |
34 | MVI_FIELDS[0]: ('车辆识别代码', 'se_common_compare', {}, '发票车架号与系统不一致'), | 52 | MVI_FIELDS[0]: ('车辆识别代码', 'se_common_compare', {}, '发票车架号与系统不一致'), |
... | @@ -59,6 +77,41 @@ BD_COMPARE_LOGIC = { | ... | @@ -59,6 +77,41 @@ BD_COMPARE_LOGIC = { |
59 | BD_FIELDS[2]: ('车架号', 'se_common_compare', {}, '保单车架号与系统不一致'), | 77 | BD_FIELDS[2]: ('车架号', 'se_common_compare', {}, '保单车架号与系统不一致'), |
60 | } | 78 | } |
61 | 79 | ||
80 | HIL_CONTRACT_1_COMPARE_LOGIC = { | ||
81 | HIL_CON_1_FIELDS[0]: ('合同编号-每页', 'se_list_compare', {}, '售后回租合同中合同编号系统不一致'), | ||
82 | HIL_CON_1_FIELDS[1]: ('车辆识别代码', 'se_common_compare', {}, '售后回租合同车辆识别代码与系统车架号不一致'), | ||
83 | HIL_CON_1_FIELDS[2]: ('还款计划表', 'se_schedule_compare', {"value_idx": 1}, '售后回租合同还款计划表与系统不一致'), | ||
84 | HIL_CON_1_FIELDS[6]: ('ASP项目详情', 'se_asp_compare', {}, '售后回租合同ASP名称或者金额与系统不一致'), | ||
85 | HIL_CON_1_FIELDS[3]: ('还款账号', 'se_common_compare', {'remove_space': True}, '售后回租合同还款账号与系统不一致'), | ||
86 | HIL_CON_1_FIELDS[4]: ('户名', 'se_common_compare', {}, '售后回租合同户名与系统不一致'), | ||
87 | HIL_CON_1_FIELDS[5]: ('开户行', 'se_both_contain_compare', {}, '售后回租合同开户行与系统不一致'), | ||
88 | } | ||
89 | |||
90 | HIL_CONTRACT_2_COMPARE_LOGIC = { | ||
91 | HIL_CON_2_FIELDS[0]: ('合同编号', 'se_common_compare', {}, '车辆租赁抵押合同合同编号与系统合同编号不一致'), | ||
92 | HIL_CON_2_FIELDS[1]: ('合同编号-正文', 'se_common_compare', {}, '车辆租赁抵押合同正文合同编号与系统合同编号不一致'), | ||
93 | HIL_CON_2_FIELDS[2]: ('车辆识别代码', 'se_common_compare', {}, '车辆租赁抵押合同车辆识别代码与系统车架号不一致'), | ||
94 | } | ||
95 | |||
96 | HT_COMPARE_LOGIC = { | ||
97 | AFC_CON_FIELDS[0]: ('合同编号-每页', 'se_list_compare', {}, '合同编号与系统不一致'), | ||
98 | # '合同编号-每页(no-asp)': ('合同编号-每页', 'se_list_compare', {'pop_last': True}, '合同编号与系统不一致'), | ||
99 | AFC_CON_FIELDS[1]: ('合同编号-每页', 'se_list_compare', {}, '合同编号与系统不一致'), | ||
100 | AFC_CON_FIELDS[2]: ('车架号-重要条款', 'se_common_compare', {}, '合同首页中车架号与系统不一致'), | ||
101 | AFC_CON_FIELDS[3]: ('车架号', 'se_common_compare', {}, '主合同页中车架号与系统不一致'), | ||
102 | AFC_CON_FIELDS[4]: ('还款账号', 'se_common_compare', {'remove_space': True}, '主合同页中还款账号与系统不一致'), | ||
103 | AFC_CON_FIELDS[5]: ('户名', 'se_common_compare', {}, '主合同页中户名与系统不一致'), | ||
104 | AFC_CON_FIELDS[6]: ('开户行', 'se_both_contain_compare', {}, '主合同页中开户行与系统不一致'), | ||
105 | |||
106 | AFC_CON_FIELDS[10]: ('见证人签字', 'se_have_compare', {}, '合同见证人无'), | ||
107 | AFC_CON_FIELDS[11]: ('见证人日期', 'se_date_contain_compare', {}, '合同见证人签字日期不符合逻辑'), | ||
108 | |||
109 | AFC_CON_FIELDS[7]: ('还款计划表', 'se_schedule_compare', {"value_idx": 1}, '合同还款计划表与系统不一致'), | ||
110 | |||
111 | AFC_CON_FIELDS[8]: ('ASP项目详情-重要条款', 'se_asp_compare', {}, '合同(重要条款)ASP名称或者金额与系统不一致'), | ||
112 | AFC_CON_FIELDS[9]: ('ASP项目详情', 'se_asp_compare', {}, '合同ASP名称或者金额与系统不一致'), | ||
113 | } | ||
114 | |||
62 | PRE_COMPARE_LOGIC_MAP = { | 115 | PRE_COMPARE_LOGIC_MAP = { |
63 | ID_EN: (ID_OCR_FIELD, ID_COMPARE_LOGIC, '请确认是否提供身份证件'), | 116 | ID_EN: (ID_OCR_FIELD, ID_COMPARE_LOGIC, '请确认是否提供身份证件'), |
64 | MVI_EN: (MVI_OCR_FIELD, MVI_COMPARE_LOGIC, '请确认是否提供发票'), | 117 | MVI_EN: (MVI_OCR_FIELD, MVI_COMPARE_LOGIC, '请确认是否提供发票'), | ... | ... |
-
Please register or sign in to post a comment