12a2684f by 周伟奇

se compare part 8

1 parent d777eccb
...@@ -1253,10 +1253,9 @@ SE_SEP_FIELD = [ ...@@ -1253,10 +1253,9 @@ SE_SEP_FIELD = [
1253 ('selfEmployedSubType', 'organizationType') 1253 ('selfEmployedSubType', 'organizationType')
1254 ] 1254 ]
1255 SE_CORPORATE_FIELD = ['companyName', 'legalRepName', 'businessLicenseNo', 'organizationCreditCode', 1255 SE_CORPORATE_FIELD = ['companyName', 'legalRepName', 'businessLicenseNo', 'organizationCreditCode',
1256 'taxRegistrationCertificateNo', 'establishmentDate', 'businessLicenseDueDate', 'organizationType'] 1256 'taxRegistrationCertificateNo', 'establishmentDate', 'businessLicenseDueDate']
1257 SE_CORPORATE_ALL_FIELD = ['companyName', 'legalRepName', 'firstIdNo', 'businessLicenseNo', 'organizationCreditCode', 1257 SE_CORPORATE_ALL_FIELD = ['companyName', 'legalRepName', 'firstIdNo', 'businessLicenseNo', 'organizationCreditCode',
1258 'taxRegistrationCertificateNo', 'establishmentDate', 'businessLicenseDueDate', 1258 'taxRegistrationCertificateNo', 'establishmentDate', 'businessLicenseDueDate']
1259 'organizationType']
1260 SE_NEW_FIELD = ['vinNo', 'dealer', 'vehicleTransactionAmount'] 1259 SE_NEW_FIELD = ['vinNo', 'dealer', 'vehicleTransactionAmount']
1261 SE_USED_FIELD = ['vinNo', 'vehicleTransactionAmount'] 1260 SE_USED_FIELD = ['vinNo', 'vehicleTransactionAmount']
1262 SE_NEW_ADD_FIELD = ['customerName', 'idNum', 'dateOfInvoice'] 1261 SE_NEW_ADD_FIELD = ['customerName', 'idNum', 'dateOfInvoice']
...@@ -1281,76 +1280,76 @@ BC_EN = 'Bank Card' ...@@ -1281,76 +1280,76 @@ BC_EN = 'Bank Card'
1281 DDA_EN = 'DDA' 1280 DDA_EN = 'DDA'
1282 1281
1283 ID_COMPARE_LOGIC = { 1282 ID_COMPARE_LOGIC = {
1284 'customerName': ('姓名', ), 1283 'customerName': ('姓名', 'se_name_compare', {}),
1285 'idNum': ('公民身份号码', ), 1284 'idNum': ('公民身份号码', 'se_common_compare', {}),
1286 'dateOfBirth': ('出生年月', ), 1285 'dateOfBirth': ('出生年月', 'se_date_compare', {'input_replace': ''}),
1287 'idExpiryDate': ('有效期限', ), 1286 'idExpiryDate': ('有效期限', 'se_date_compare', {'long': True, 'ocr_split': True, 'input_replace': ''}),
1288 'hukouProvince': ('住址', ), 1287 'hukouProvince': ('住址', 'se_contain_compare', {}),
1289 'hukouCity': ('住址', ), 1288 'hukouCity': ('住址', 'se_contain_compare', {}),
1290 } 1289 }
1291 1290
1292 PP_COMPARE_LOGIC = { 1291 PP_COMPARE_LOGIC = {
1293 'customerName': ('英文姓名', ), 1292 'customerName': ('英文姓名', 'se_name_compare', {'is_passport': True}),
1294 'idNum': ('护照号码', ), 1293 'idNum': ('护照号码', 'se_common_compare', {}),
1295 'dateOfBirth': ('出生日期', ), 1294 'dateOfBirth': ('出生日期', 'se_date_compare', {'input_replace': ''}),
1296 'idExpiryDate': ('有效期至', ), 1295 'idExpiryDate': ('有效期至', 'se_date_compare', {'input_replace': ''}),
1297 } 1296 }
1298 1297
1299 EEP_COMPARE_LOGIC = { 1298 EEP_COMPARE_LOGIC = {
1300 'customerName': ('中文名', ), 1299 'customerName': ('中文名', 'se_common_compare', {}),
1301 'idNum': ('证件号码', ), 1300 'idNum': ('证件号码', 'se_common_compare', {}),
1302 'dateOfBirth': ('出生日期', ), 1301 'dateOfBirth': ('出生日期', 'se_date_compare', {'input_replace': '.'}),
1303 'idExpiryDate': ('有效期限', ), 1302 'idExpiryDate': ('有效期限', 'se_date_compare', {'ocr_split': True, 'input_replace': '.'}),
1304 } 1303 }
1305 1304
1306 RP_COMPARE_LOGIC = { 1305 RP_COMPARE_LOGIC = {
1307 'customerName': ('姓名', ), 1306 'customerName': ('姓名', 'se_name_compare', {}),
1308 'idNum': ('公民身份号码', ), 1307 'idNum': ('公民身份号码', 'se_common_compare', {}),
1309 'dateOfBirth': ('出生年月', ), 1308 'dateOfBirth': ('出生年月', 'se_date_compare', {'input_replace': ''}),
1310 'idExpiryDate': ('有效期限', ), 1309 'idExpiryDate': ('有效期限', 'se_date_compare', {'ocr_split': True, 'input_replace': ''}),
1311 'hukouProvince': ('住址', ), 1310 'hukouProvince': ('住址', 'se_contain_compare', {}),
1312 'hukouCity': ('住址', ), 1311 'hukouCity': ('住址', 'se_contain_compare', {}),
1313 } 1312 }
1314 1313
1315 BL_COMPARE_LOGIC = { 1314 BL_COMPARE_LOGIC = {
1316 'companyName': ('企业名称', ), 1315 'companyName': ('企业名称', 'se_company_compare', {}),
1317 'legalRepName': ('经营者姓名', ), 1316 'legalRepName': ('经营者姓名', 'se_name_compare', {}),
1318 'firstIdNo': ('注册号', ), 1317 'firstIdNo': ('注册号', 'se_common_compare', {}),
1319 'businessLicenseNo': ('注册号', ), 1318 'businessLicenseNo': ('注册号', 'se_common_compare', {}),
1320 'organizationCreditCode': ('注册号', ), 1319 'organizationCreditCode': ('注册号', 'se_common_compare', {}),
1321 'taxRegistrationCertificateNo': ('注册号', ), 1320 'taxRegistrationCertificateNo': ('注册号', 'se_common_compare', {}),
1322 'establishmentDate': ('成立日期', ), 1321 'establishmentDate': ('成立日期', 'se_date_compare', {'ocr_replace': True}),
1323 'businessLicenseDueDate': ('营业期限', ), 1322 'businessLicenseDueDate': ('营业期限', 'se_date_compare', {'ocr_split': True, 'long': True, 'ocr_replace': True}),
1324 'organizationType': ('企业类型', ), 1323 'organizationType': ('企业类型', 'se_type_compare', {}),
1325 'registeredCapital': ('注册资本', ), 1324 'registeredCapital': ('注册资本', 'se_rmb_compare', {}),
1326 } 1325 }
1327 1326
1328 MVI_COMPARE_LOGIC = { 1327 MVI_COMPARE_LOGIC = {
1329 'vinNo': ('车辆识别代码', ), 1328 'vinNo': ('车辆识别代码', 'se_common_compare', {}),
1330 'dealer': ('销方名称', ), 1329 'dealer': ('销方名称', 'se_common_compare', {}),
1331 'vehicleTransactionAmount': ('价税合计小写', ), 1330 'vehicleTransactionAmount': ('价税合计小写', 'se_amount_compare', {}),
1332 'customerName': ('购方名称', ), 1331 'customerName': ('购方名称', 'se_name_compare', {}),
1333 'idNum': ('购买方身份证号或组织机构代码', ), 1332 'idNum': ('购买方身份证号或组织机构代码', 'se_common_compare', {}),
1334 'dateOfInvoice': ('开票日期', ), 1333 'dateOfInvoice': ('开票日期', 'se_date_compare', {}),
1335 } 1334 }
1336 1335
1337 UCI_COMPARE_LOGIC = { 1336 UCI_COMPARE_LOGIC = {
1338 'vinNo': ('车架号', ), 1337 'vinNo': ('车架号', 'se_common_compare', {}),
1339 'vehicleTransactionAmount': ('价税合计小写', ), 1338 'vehicleTransactionAmount': ('价税合计小写', 'se_amount_compare', {}),
1340 'customerName': ('购方名称', ), 1339 'customerName': ('购方名称', 'se_name_compare', {}),
1341 'idNum': ('购方纳税人识别号', ), 1340 'idNum': ('购方纳税人识别号', 'se_common_compare', {}),
1342 } 1341 }
1343 1342
1344 MVC_COMPARE_LOGIC = { 1343 MVC_COMPARE_LOGIC = {
1345 'vinNo': ('9.车辆识别代号/车架号', ), 1344 'vinNo': ('9.车辆识别代号/车架号', 'se_common_compare', {}),
1346 # 'customerName': ('姓名/名称', ), 1345 # 'customerName': ('姓名/名称', ),
1347 # 'idNum': ('身份证明名称/号码', ), 1346 # 'idNum': ('身份证明名称/号码', ),
1348 # 'date': ('转移登记日期', ), 1347 # 'date': ('转移登记日期', ),
1349 } 1348 }
1350 1349
1351 BC_COMPARE_LOGIC = { 1350 BC_COMPARE_LOGIC = {
1352 'accountNo': ('CardNum', ), 1351 'accountNo': ('CardNum', 'se_common_compare', {}),
1353 'bankName': ('BankName', ), 1352 'bankName': ('BankName', 'se_common_compare', {}),
1354 } 1353 }
1355 1354
1356 DDA_COMPARE_LOGIC = { 1355 DDA_COMPARE_LOGIC = {
......
1 import re 1 import re
2 from datetime import datetime 2 from datetime import datetime
3 # from .rmb_lower import rmb_handler 3 from .rmb_lower import rmb_handler
4 from .rmb_upper import to_rmb_upper 4 # from .rmb_upper import to_rmb_upper
5 5
6 6
7 class Comparison: 7 class Comparison:
...@@ -136,6 +136,85 @@ class Comparison: ...@@ -136,6 +136,85 @@ class Comparison:
136 136
137 return self.build_res(input_str == compare_str), compare_str 137 return self.build_res(input_str == compare_str), compare_str
138 138
139 def se_name_compare(self, input_str, ocr_str, **kwargs):
140 if kwargs.get('is_passport'):
141 input_tmp = input_str.upper().replace(' ', '')
142 ocr_tmp = ocr_str.upper().replace(' ', '')
143 if input_tmp.find(ocr_tmp) == -1:
144 return self.RESULT_N
145 else:
146 return self.RESULT_Y
147 else:
148 # if re.search(r'[a-zA-Z]]', input_str):
149 # return self.RESULT_NA, ocr_str
150 input_s = input_str.translate(self.TRANS)
151 ocr_s = ocr_str.translate(self.TRANS)
152 return self.build_res(input_s == ocr_s)
153
154 def se_common_compare(self, input_str, ocr_str, **kwargs):
155 return self.build_res(input_str == ocr_str)
156
157 def se_date_compare(self, input_str, ocr_str, **kwargs):
158 if kwargs.get('long', False):
159 if '长期' in ocr_str or '永久' in ocr_str:
160 if input_str in ['2099-12-31', '2099-01-01', '2999-12-31', '2999-01-01']:
161 return self.RESULT_Y
162 else:
163 return self.RESULT_N
164 if kwargs.get('ocr_split', False):
165 if '至' in ocr_str:
166 ocr_str = ocr_str.split('至')[-1]
167 elif '-' in ocr_str:
168 ocr_str = ocr_str.split('-')[-1]
169 if kwargs.get('ocr_replace', False):
170 ocr_str = ocr_str.replace('年', '-').replace('月', '-').replace('日', '')
171 if kwargs.get('input_replace') is not None:
172 input_str = input_str.replace('-', kwargs.get('input_replace'))
173 return self.build_res(input_str == ocr_str)
174
175 def se_contain_compare(self, input_str, ocr_str, **kwargs):
176 if ocr_str.find(input_str) == -1:
177 return self.RESULT_N
178 else:
179 return self.RESULT_Y
180
181 def se_amount_compare(self, input_str, ocr_str, **kwargs):
182 if input_str == ocr_str:
183 return self.RESULT_Y
184 else:
185 try:
186 float_input = float(input_str)
187 float_ocr = float(ocr_str)
188 except Exception as e:
189 return self.RESULT_N
190 else:
191 return self.build_res(float_ocr == float_input)
192
193 def se_company_compare(self, input_str, ocr_str, **kwargs):
194 input_tmp = re.sub(self.re_obj, '', input_str).strip()
195 ocr_tmp = re.sub(self.re_obj, '', ocr_str).strip()
196 return self.build_res(input_tmp == ocr_tmp)
197
198 def se_rmb_compare(self, input_str, ocr_str, **kwargs):
199 try:
200 ocr_lower = rmb_handler.to_rmb_lower(ocr_str)
201 res = self.build_res(float(input_str) == ocr_lower)
202 # input_rmb_upper = to_rmb_upper(float(input_str))
203 # res = self.build_res(input_rmb_upper == ocr_str)
204 except Exception as e:
205 return self.RESULT_N
206 else:
207 return res
208
209 def se_type_compare(self, input_str, ocr_str, **kwargs):
210 for map_tuple in self.TYPE_MAPPING:
211 if re.search(map_tuple[0], ocr_str) is not None:
212 compare_str = map_tuple[1]
213 break
214 else:
215 compare_str = self.CSOTH
216 return self.build_res(input_str == compare_str)
217
139 218
140 cp = Comparison() 219 cp = Comparison()
141 220
......
...@@ -2,6 +2,36 @@ import pyodbc ...@@ -2,6 +2,36 @@ import pyodbc
2 2
3 3
4 hil_sql = """ 4 hil_sql = """
5 create table hil_se_comparison_info
6 (
7 id bigint identity primary key,
8 uniq_seq nvarchar(128) not null,
9 application_id nvarchar(64) not null,
10 application_version tinyint default 0 not null,
11 customer_type nvarchar(16) not null,
12 first_submmison_date nvarchar(16) not null,
13 property_doc_policy nvarchar(16),
14
15 individual_cus_info nvarchar(max) not null,
16 corporate_cus_info nvarchar(max),
17 vehicle_info nvarchar(max) not null,
18 insurance_info nvarchar(max) not null,
19 bank_info nvarchar(max) not null,
20 quotationt_info nvarchar(max) not null,
21
22 update_time datetime not null,
23 create_time datetime not null
24 );
25
26 create index hil_se_comparison_info_application_id_index
27 on hil_se_comparison_info (application_id);
28
29 create index hil_se_comparison_info_create_time_index
30 on hil_se_comparison_info (create_time);
31
32 create index hil_se_comparison_info_uniq_seq_index
33 on hil_se_comparison_info (uniq_seq);
34
5 create table hil_se_ocr_result 35 create table hil_se_ocr_result
6 ( 36 (
7 id int identity primary key, 37 id int identity primary key,
...@@ -83,6 +113,36 @@ hil_sql = """ ...@@ -83,6 +113,36 @@ hil_sql = """
83 """ 113 """
84 114
85 afc_sql = """ 115 afc_sql = """
116 create table afc_se_comparison_info
117 (
118 id bigint identity primary key,
119 uniq_seq nvarchar(128) not null,
120 application_id nvarchar(64) not null,
121 application_version tinyint default 0 not null,
122 customer_type nvarchar(16) not null,
123 first_submmison_date nvarchar(16) not null,
124 property_doc_policy nvarchar(16),
125
126 individual_cus_info nvarchar(max) not null,
127 corporate_cus_info nvarchar(max),
128 vehicle_info nvarchar(max) not null,
129 insurance_info nvarchar(max) not null,
130 bank_info nvarchar(max) not null,
131 quotationt_info nvarchar(max) not null,
132
133 update_time datetime not null,
134 create_time datetime not null
135 );
136
137 create index afc_se_comparison_info_application_id_index
138 on afc_se_comparison_info (application_id);
139
140 create index afc_se_comparison_info_create_time_index
141 on afc_se_comparison_info (create_time);
142
143 create index afc_se_comparison_info_uniq_seq_index
144 on afc_se_comparison_info (uniq_seq);
145
86 create table afc_se_ocr_result 146 create table afc_se_ocr_result
87 ( 147 (
88 id int identity primary key, 148 id int identity primary key,
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!