fix merge
Showing
13 changed files
with
351 additions
and
7 deletions
... | @@ -8,4 +8,5 @@ urlpatterns = [ | ... | @@ -8,4 +8,5 @@ urlpatterns = [ |
8 | path(r'settlement/cms/v1', views.SECMSView.as_view()), | 8 | path(r'settlement/cms/v1', views.SECMSView.as_view()), |
9 | path(r'offline/v1', views.CompareOfflineView.as_view()), | 9 | path(r'offline/v1', views.CompareOfflineView.as_view()), |
10 | path(r'result', views.CompareResultView.as_view()), | 10 | path(r'result', views.CompareResultView.as_view()), |
11 | path(r'resources', views.ResourcesView.as_view()), | ||
11 | ] | 12 | ] | ... | ... |
... | @@ -1488,3 +1488,114 @@ BC_FIELD_ORDER_2 = (('BankName', '发卡行名称'), | ... | @@ -1488,3 +1488,114 @@ BC_FIELD_ORDER_2 = (('BankName', '发卡行名称'), |
1488 | ('CardNum', '银行卡号'), | 1488 | ('CardNum', '银行卡号'), |
1489 | ('CardType', '银行卡类型'),) | 1489 | ('CardType', '银行卡类型'),) |
1490 | 1490 | ||
1491 | IMG_PATH_KEY = 'uniq_img_path_key' | ||
1492 | IMG_PATH_KEY_2 = 'uniq_img_path_key_2' | ||
1493 | |||
1494 | INFO_SOURCE = ['POS', 'CMS'] | ||
1495 | |||
1496 | # ------------------- | ||
1497 | |||
1498 | CA_FIRST_ID_FIELD = ['customerChineseName', 'idNum', 'idExpiryDate', 'dateOfBirth'] | ||
1499 | |||
1500 | CA_FIRST_ID_FIELD_MAPPING = { | ||
1501 | 'ITPRC': (ID_EN, CA_FIRST_ID_FIELD), | ||
1502 | 'ITPSP': (PP_EN, CA_FIRST_ID_FIELD), | ||
1503 | 'ITHKM': (EEP_EN, CA_FIRST_ID_FIELD), | ||
1504 | 'ITTID': (EEP_EN, CA_FIRST_ID_FIELD), | ||
1505 | 'ITRES': (RP_EN, CA_FIRST_ID_FIELD), | ||
1506 | } | ||
1507 | |||
1508 | CA_SECOND_ID_FIELD = [ | ||
1509 | ('customerChineseName', 'customerChineseName'), | ||
1510 | ('secondIdNum', 'idNum') | ||
1511 | ] | ||
1512 | |||
1513 | CA_SECOND_ID_FIELD_MAPPING = { | ||
1514 | 'ITPRC': (ID_EN, CA_SECOND_ID_FIELD), | ||
1515 | 'ITPSP': (PP_EN, CA_SECOND_ID_FIELD), | ||
1516 | 'ITHKM': (EEP_EN, CA_SECOND_ID_FIELD), | ||
1517 | 'ITTID': (EEP_EN, CA_SECOND_ID_FIELD), | ||
1518 | 'ITRES': (RP_EN, CA_SECOND_ID_FIELD), | ||
1519 | } | ||
1520 | |||
1521 | CA_SEP_FIELD = ['companyName', 'customerChineseName', 'registeredCapital', 'selfEmployedSubType'] | ||
1522 | |||
1523 | CA_CORPORATE_FIELD = [ | ||
1524 | ('customerChineseName', 'companyName'), | ||
1525 | ('legalRepName', 'customerChineseName'), | ||
1526 | ('idNum', 'idNum'), | ||
1527 | ('businessLicenseNo', 'businessLicenseNo'), | ||
1528 | ('taxRegistrationCode', 'taxRegistrationCode'), | ||
1529 | ('incorporationDate', 'incorporationDate'), | ||
1530 | ('businessLicenseDueDate', 'businessLicenseDueDate'), | ||
1531 | ('capitalRegAmount', 'registeredCapital'), | ||
1532 | ] | ||
1533 | |||
1534 | CA_MVC_FIELD = ['vinNo', 'manufactureDate', 'firstRegistrationDate'] | ||
1535 | CA_DL_FIELD = ['vinNo'] | ||
1536 | DL_EN = 'Driving Licence' | ||
1537 | |||
1538 | CA_ID_COMPARE_LOGIC = { | ||
1539 | 'customerChineseName': ('姓名', 'ca_name_compare', {}), | ||
1540 | 'idNum': ('公民身份号码', 'ca_common_compare', {}), | ||
1541 | 'dateOfBirth': ('出生年月', 'ca_date_compare', {'input_replace': ''}), | ||
1542 | 'idExpiryDate': ('有效期限', 'ca_date_compare', {'long': True, 'ocr_split': True, 'input_replace': ''}), | ||
1543 | } | ||
1544 | |||
1545 | |||
1546 | CA_PP_COMPARE_LOGIC = { | ||
1547 | 'customerChineseName': ('英文姓名', 'ca_name_compare', {'is_passport': True}), | ||
1548 | 'idNum': ('护照号码', 'ca_common_compare', {}), | ||
1549 | 'dateOfBirth': ('出生日期', 'ca_date_compare', {'input_replace': ''}), | ||
1550 | 'idExpiryDate': ('有效期至', 'ca_date_compare', {'input_replace': ''}), | ||
1551 | } | ||
1552 | |||
1553 | CA_EEP_COMPARE_LOGIC = { | ||
1554 | 'customerChineseName': ('中文名', 'ca_common_compare', {}), | ||
1555 | 'idNum': ('证件号码', 'ca_common_compare', {}), | ||
1556 | 'dateOfBirth': ('出生日期', 'ca_date_compare', {'input_replace': '.'}), | ||
1557 | 'idExpiryDate': ('有效期限', 'ca_date_compare', {'ocr_split': True, 'input_replace': '.'}), | ||
1558 | } | ||
1559 | |||
1560 | CA_RP_COMPARE_LOGIC = { | ||
1561 | 'customerChineseName': ('姓名', 'ca_common_compare', {}), | ||
1562 | 'idNum': ('公民身份号码', 'ca_common_compare', {}), | ||
1563 | 'dateOfBirth': ('出生年月', 'ca_date_compare', {'input_replace': ''}), | ||
1564 | 'idExpiryDate': ('有效期限', 'ca_date_compare', {'ocr_split': True, 'input_replace': ''}), | ||
1565 | } | ||
1566 | |||
1567 | CA_BL_COMPARE_LOGIC = { | ||
1568 | 'companyName': ('企业名称', 'ca_company_compare', {}), | ||
1569 | 'customerChineseName': ('经营者姓名', 'ca_name_compare', {}), | ||
1570 | 'idNum': ('注册号', 'ca_common_compare', {}), | ||
1571 | 'businessLicenseNo': ('注册号', 'ca_common_compare', {}), | ||
1572 | 'taxRegistrationCode': ('注册号', 'ca_common_compare', {}), | ||
1573 | 'incorporationDate': ('成立日期', 'ca_date_compare', {'ocr_replace': True}), | ||
1574 | 'businessLicenseDueDate': ('营业期限', 'ca_date_compare', {'ocr_split': True, 'long': True, 'ocr_replace': True}), | ||
1575 | 'registeredCapital': ('注册资本', 'ca_rmb_compare', {}), | ||
1576 | 'selfEmployedSubType': ('企业类型', 'ca_type_compare', {}), | ||
1577 | } | ||
1578 | |||
1579 | CA_MVC_COMPARE_LOGIC = { | ||
1580 | 'vinNo': ('9.车辆识别代号/车架号', 'ca_common_compare', {}), | ||
1581 | 'manufactureDate': ('32.车辆出厂日期', 'ca_date_compare', {}), | ||
1582 | 'firstRegistrationDate': ('3.登记日期', 'ca_date_compare', {}), | ||
1583 | } | ||
1584 | |||
1585 | CA_DL_COMPARE_LOGIC = { | ||
1586 | 'vinNo': ('车辆识别代码', 'ca_common_compare', {}), | ||
1587 | } | ||
1588 | |||
1589 | CA_COMPARE_FIELD = { | ||
1590 | ID_EN: (IC_OCR_FIELD, CA_ID_COMPARE_LOGIC, True), | ||
1591 | PP_EN: (PP_OCR_FIELD, CA_PP_COMPARE_LOGIC, False), | ||
1592 | EEP_EN: (EEP_OCR_FIELD, CA_EEP_COMPARE_LOGIC, False), | ||
1593 | RP_EN: (RP_OCR_FIELD, CA_RP_COMPARE_LOGIC, True), | ||
1594 | |||
1595 | BL_EN: (BL_OCR_FIELD, CA_BL_COMPARE_LOGIC, False), | ||
1596 | |||
1597 | MVC_EN: (MVC_OCR_FIELD, CA_MVC_COMPARE_LOGIC, False), | ||
1598 | DL_EN: (DL_OCR_FIELD, CA_DL_COMPARE_LOGIC, False), | ||
1599 | } | ||
1600 | |||
1601 | ... | ... |
... | @@ -221,6 +221,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -221,6 +221,7 @@ class Command(BaseCommand, LoggerMixin): |
221 | dda_ocr_result = {key: value.get('words', '') for key, value in license_data.get('result', {}).items()} | 221 | dda_ocr_result = {key: value.get('words', '') for key, value in license_data.get('result', {}).items()} |
222 | dda_ocr_result[consts.DDA_IMG_PATH] = img_path | 222 | dda_ocr_result[consts.DDA_IMG_PATH] = img_path |
223 | dda_ocr_result[consts.DDA_PRO] = pro | 223 | dda_ocr_result[consts.DDA_PRO] = pro |
224 | dda_ocr_result[consts.IMG_PATH_KEY] = img_path | ||
224 | license_summary.setdefault(classify, []).append(dda_ocr_result) | 225 | license_summary.setdefault(classify, []).append(dda_ocr_result) |
225 | elif classify == consts.HMH_CLASSIFY: # 抵押登记豁免函 | 226 | elif classify == consts.HMH_CLASSIFY: # 抵押登记豁免函 |
226 | hmh_ocr_result = {key: value.get('words', '') for key, value in license_data.items()} | 227 | hmh_ocr_result = {key: value.get('words', '') for key, value in license_data.items()} |
... | @@ -230,6 +231,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -230,6 +231,7 @@ class Command(BaseCommand, LoggerMixin): |
230 | license_summary.setdefault(classify, []).append(jypz_ocr_result) | 231 | license_summary.setdefault(classify, []).append(jypz_ocr_result) |
231 | elif classify == consts.MVC_CLASSIFY: # 车辆登记证 3/4页结果整合 | 232 | elif classify == consts.MVC_CLASSIFY: # 车辆登记证 3/4页结果整合 |
232 | for mvc_dict in license_data: | 233 | for mvc_dict in license_data: |
234 | mvc_dict[consts.IMG_PATH_KEY] = img_path | ||
233 | try: | 235 | try: |
234 | mvc_page = mvc_dict.pop('page') | 236 | mvc_page = mvc_dict.pop('page') |
235 | except Exception as e: | 237 | except Exception as e: |
... | @@ -247,6 +249,10 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -247,6 +249,10 @@ class Command(BaseCommand, LoggerMixin): |
247 | 249 | ||
248 | elif classify == consts.IC_CLASSIFY: # 身份证真伪 | 250 | elif classify == consts.IC_CLASSIFY: # 身份证真伪 |
249 | for id_card_dict in license_data: | 251 | for id_card_dict in license_data: |
252 | if '有效期限' in id_card_dict: | ||
253 | id_card_dict[consts.IMG_PATH_KEY_2] = img_path | ||
254 | else: | ||
255 | id_card_dict[consts.IMG_PATH_KEY] = img_path | ||
250 | try: | 256 | try: |
251 | base64_img = id_card_dict.pop('base64_img') | 257 | base64_img = id_card_dict.pop('base64_img') |
252 | except Exception as e: | 258 | except Exception as e: |
... | @@ -299,6 +305,8 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -299,6 +305,8 @@ class Command(BaseCommand, LoggerMixin): |
299 | dda_id_bc_mapping.setdefault(consts.IC_FIELD, []).append((ic_name, ic_id, img_path)) | 305 | dda_id_bc_mapping.setdefault(consts.IC_FIELD, []).append((ic_name, ic_id, img_path)) |
300 | license_summary.setdefault(classify, []).extend(license_data) | 306 | license_summary.setdefault(classify, []).extend(license_data) |
301 | else: | 307 | else: |
308 | for res_dict in license_data: | ||
309 | res_dict[consts.IMG_PATH_KEY] = img_path | ||
302 | license_summary.setdefault(classify, []).extend(license_data) | 310 | license_summary.setdefault(classify, []).extend(license_data) |
303 | res_list.append((pno, ino, part_idx, consts.RES_SUCCESS)) | 311 | res_list.append((pno, ino, part_idx, consts.RES_SUCCESS)) |
304 | 312 | ||
... | @@ -310,6 +318,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -310,6 +318,7 @@ class Command(BaseCommand, LoggerMixin): |
310 | # res_dict = {} | 318 | # res_dict = {} |
311 | # for en_key, chn_key in consts.BC_FIELD: | 319 | # for en_key, chn_key in consts.BC_FIELD: |
312 | # res_dict[chn_key] = ocr_res_2.get(en_key, '') | 320 | # res_dict[chn_key] = ocr_res_2.get(en_key, '') |
321 | ocr_res_2[consts.IMG_PATH_KEY] = img_path | ||
313 | license_summary.setdefault(classify, []).append(ocr_res_2) | 322 | license_summary.setdefault(classify, []).append(ocr_res_2) |
314 | if do_dda and isinstance(ocr_res_2.get(consts.BC_KEY_FIELD), str): | 323 | if do_dda and isinstance(ocr_res_2.get(consts.BC_KEY_FIELD), str): |
315 | bc_no = ocr_res_2[consts.BC_KEY_FIELD].strip() | 324 | bc_no = ocr_res_2[consts.BC_KEY_FIELD].strip() |
... | @@ -321,6 +330,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -321,6 +330,7 @@ class Command(BaseCommand, LoggerMixin): |
321 | res_dict = {} | 330 | res_dict = {} |
322 | for field_dict in result_dict.get('FieldList', []): | 331 | for field_dict in result_dict.get('FieldList', []): |
323 | res_dict[field_dict.get('chn_key', '')] = field_dict.get('value', '') | 332 | res_dict[field_dict.get('chn_key', '')] = field_dict.get('value', '') |
333 | res_dict[consts.IMG_PATH_KEY] = img_path | ||
324 | license_summary.setdefault(classify, []).append(res_dict) | 334 | license_summary.setdefault(classify, []).append(res_dict) |
325 | else: | 335 | else: |
326 | res_list.append((pno, ino, part_idx, consts.RES_FAILED_2)) | 336 | res_list.append((pno, ino, part_idx, consts.RES_FAILED_2)) |
... | @@ -927,8 +937,8 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -927,8 +937,8 @@ class Command(BaseCommand, LoggerMixin): |
927 | # self.bs_log.info('[task={0}] [bs_summary={1}]'.format(task_str, merged_bs_summary)) | 937 | # self.bs_log.info('[task={0}] [bs_summary={1}]'.format(task_str, merged_bs_summary)) |
928 | 938 | ||
929 | self.online_log.info('{0} [task={1}] [merged_bs_summary={2}] [license_summary={3}] ' | 939 | self.online_log.info('{0} [task={1}] [merged_bs_summary={2}] [license_summary={3}] ' |
930 | '[res_list={4}]'.format(self.log_base, task_str, merged_bs_summary, | 940 | '[res_list={4}]'.format(self.log_base, task_str, merged_bs_summary, |
931 | license_summary, res_list)) | 941 | license_summary, res_list)) |
932 | 942 | ||
933 | except Exception as e: | 943 | except Exception as e: |
934 | 944 | ||
... | @@ -1355,9 +1365,9 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -1355,9 +1365,9 @@ class Command(BaseCommand, LoggerMixin): |
1355 | 1365 | ||
1356 | finally: | 1366 | finally: |
1357 | try: | 1367 | try: |
1358 | img_save_path = os.path.join(doc_data_path, 'img') | 1368 | # img_save_path = os.path.join(doc_data_path, 'img') |
1359 | write_zip_file(img_save_path, os.path.join(doc_data_path, '{0}_img.zip'.format(doc_id_str))) | 1369 | # write_zip_file(img_save_path, os.path.join(doc_data_path, '{0}_img.zip'.format(doc_id_str))) |
1360 | shutil.rmtree(img_save_path, ignore_errors=True) | 1370 | # shutil.rmtree(img_save_path, ignore_errors=True) |
1361 | pdf_path = os.path.join(doc_data_path, '{0}.pdf'.format(doc_id_str)) | 1371 | pdf_path = os.path.join(doc_data_path, '{0}.pdf'.format(doc_id_str)) |
1362 | os.remove(pdf_path) | 1372 | os.remove(pdf_path) |
1363 | self.online_log.info('{0} [pdf & img removed] [task={1}]'.format(self.log_base, task_str)) | 1373 | self.online_log.info('{0} [pdf & img removed] [task={1}]'.format(self.log_base, task_str)) | ... | ... |
This diff is collapsed.
Click to expand it.
... | @@ -58,3 +58,11 @@ class WorkflowName(NamedEnum): | ... | @@ -58,3 +58,11 @@ class WorkflowName(NamedEnum): |
58 | NORMAL = (0, 'Normal BS') | 58 | NORMAL = (0, 'Normal BS') |
59 | MOBILE = (1, 'Mobile BS') | 59 | MOBILE = (1, 'Mobile BS') |
60 | 60 | ||
61 | |||
62 | class ErrorType(NamedEnum): | ||
63 | OCR = (0, 'OCR识别错误') | ||
64 | INPUT = (1, '输入比对信息错误') | ||
65 | NF = (2, '相关文件未找到') | ||
66 | IMAGE = (3, '图片问题') | ||
67 | OTHER = (4, '其他') | ||
68 | ... | ... |
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
... | @@ -20,6 +20,7 @@ class MetaStatus(NamedEnum): | ... | @@ -20,6 +20,7 @@ class MetaStatus(NamedEnum): |
20 | ASYNC_WAIT = (5, 'async wait') | 20 | ASYNC_WAIT = (5, 'async wait') |
21 | NO_PERMISSION = (6, 'no permission') | 21 | NO_PERMISSION = (6, 'no permission') |
22 | ILLEGAL_OPERATION = (7, 'illegal operation') | 22 | ILLEGAL_OPERATION = (7, 'illegal operation') |
23 | NEED_UPDATE = (8, 'need update') | ||
23 | 24 | ||
24 | 25 | ||
25 | class APIResponse(JsonResponse): | 26 | class APIResponse(JsonResponse): |
... | @@ -32,3 +33,7 @@ class APIResponse(JsonResponse): | ... | @@ -32,3 +33,7 @@ class APIResponse(JsonResponse): |
32 | 33 | ||
33 | def ok(**kwargs): | 34 | def ok(**kwargs): |
34 | return APIResponse(MetaStatus.SUCCESS.value, msg=MetaStatus.SUCCESS.verbose_name, **kwargs) | 35 | return APIResponse(MetaStatus.SUCCESS.value, msg=MetaStatus.SUCCESS.verbose_name, **kwargs) |
36 | |||
37 | |||
38 | def need_update(**kwargs): | ||
39 | return APIResponse(MetaStatus.NEED_UPDATE.value, msg=MetaStatus.NEED_UPDATE.verbose_name, **kwargs) | ... | ... |
... | @@ -155,9 +155,30 @@ class Comparison: | ... | @@ -155,9 +155,30 @@ class Comparison: |
155 | ocr_s = ocr_str.translate(self.TRANS) | 155 | ocr_s = ocr_str.translate(self.TRANS) |
156 | return self.build_res(input_s == ocr_s) | 156 | return self.build_res(input_s == ocr_s) |
157 | 157 | ||
158 | def ca_name_compare(self, input_str, ocr_str, **kwargs): | ||
159 | if kwargs.get('is_passport'): | ||
160 | input_tmp = input_str.upper().replace(' ', '') | ||
161 | ocr_tmp = ocr_str.upper().replace(' ', '') | ||
162 | if input_tmp.find(ocr_tmp) == -1: | ||
163 | return self.RESULT_N | ||
164 | else: | ||
165 | if ocr_str.strip() == '': | ||
166 | return self.RESULT_N | ||
167 | else: | ||
168 | return self.RESULT_Y | ||
169 | else: | ||
170 | # if re.search(r'[a-zA-Z]]', input_str): | ||
171 | # return self.RESULT_NA, ocr_str | ||
172 | input_s = input_str.translate(self.TRANS) | ||
173 | ocr_s = ocr_str.translate(self.TRANS) | ||
174 | return self.build_res(input_s == ocr_s) | ||
175 | |||
158 | def se_common_compare(self, input_str, ocr_str, **kwargs): | 176 | def se_common_compare(self, input_str, ocr_str, **kwargs): |
159 | return self.build_res(input_str == ocr_str) | 177 | return self.build_res(input_str == ocr_str) |
160 | 178 | ||
179 | def ca_common_compare(self, input_str, ocr_str, **kwargs): | ||
180 | return self.build_res(input_str == ocr_str) | ||
181 | |||
161 | def se_date_compare(self, input_str, ocr_str, **kwargs): | 182 | def se_date_compare(self, input_str, ocr_str, **kwargs): |
162 | if kwargs.get('long', False): | 183 | if kwargs.get('long', False): |
163 | if '长期' in ocr_str or '永久' in ocr_str or '***' in ocr_str or '至今' in ocr_str: | 184 | if '长期' in ocr_str or '永久' in ocr_str or '***' in ocr_str or '至今' in ocr_str: |
... | @@ -176,6 +197,24 @@ class Comparison: | ... | @@ -176,6 +197,24 @@ class Comparison: |
176 | input_str = input_str.replace('-', kwargs.get('input_replace')) | 197 | input_str = input_str.replace('-', kwargs.get('input_replace')) |
177 | return self.build_res(input_str == ocr_str) | 198 | return self.build_res(input_str == ocr_str) |
178 | 199 | ||
200 | def ca_date_compare(self, input_str, ocr_str, **kwargs): | ||
201 | if kwargs.get('long', False): | ||
202 | if '长期' in ocr_str or '永久' in ocr_str: | ||
203 | if input_str in ['2099-12-31', '2099-01-01']: | ||
204 | return self.RESULT_Y | ||
205 | else: | ||
206 | return self.RESULT_N | ||
207 | if kwargs.get('ocr_split', False): | ||
208 | if '至' in ocr_str: | ||
209 | ocr_str = ocr_str.split('至')[-1] | ||
210 | elif '-' in ocr_str: | ||
211 | ocr_str = ocr_str.split('-')[-1] | ||
212 | if kwargs.get('ocr_replace', False): | ||
213 | ocr_str = ocr_str.replace('年', '-').replace('月', '-').replace('日', '') | ||
214 | if kwargs.get('input_replace') is not None: | ||
215 | input_str = input_str.replace('-', kwargs.get('input_replace')) | ||
216 | return self.build_res(input_str == ocr_str) | ||
217 | |||
179 | def se_contain_compare(self, input_str, ocr_str, **kwargs): | 218 | def se_contain_compare(self, input_str, ocr_str, **kwargs): |
180 | if ocr_str.find(input_str) == -1: | 219 | if ocr_str.find(input_str) == -1: |
181 | return self.RESULT_N | 220 | return self.RESULT_N |
... | @@ -220,6 +259,11 @@ class Comparison: | ... | @@ -220,6 +259,11 @@ class Comparison: |
220 | ocr_tmp = re.sub(self.re_obj, '', ocr_str).strip() | 259 | ocr_tmp = re.sub(self.re_obj, '', ocr_str).strip() |
221 | return self.build_res(input_tmp == ocr_tmp) | 260 | return self.build_res(input_tmp == ocr_tmp) |
222 | 261 | ||
262 | def ca_company_compare(self, input_str, ocr_str, **kwargs): | ||
263 | input_tmp = re.sub(self.re_obj, '', input_str).strip() | ||
264 | ocr_tmp = re.sub(self.re_obj, '', ocr_str).strip() | ||
265 | return self.build_res(input_tmp == ocr_tmp) | ||
266 | |||
223 | def se_rmb_compare(self, input_str, ocr_str, **kwargs): | 267 | def se_rmb_compare(self, input_str, ocr_str, **kwargs): |
224 | try: | 268 | try: |
225 | ocr_lower = rmb_handler.to_rmb_lower(ocr_str) | 269 | ocr_lower = rmb_handler.to_rmb_lower(ocr_str) |
... | @@ -231,6 +275,17 @@ class Comparison: | ... | @@ -231,6 +275,17 @@ class Comparison: |
231 | else: | 275 | else: |
232 | return res | 276 | return res |
233 | 277 | ||
278 | def ca_rmb_compare(self, input_str, ocr_str, **kwargs): | ||
279 | try: | ||
280 | ocr_lower = rmb_handler.to_rmb_lower(ocr_str) | ||
281 | res = self.build_res(float(input_str) == ocr_lower) | ||
282 | # input_rmb_upper = to_rmb_upper(float(input_str)) | ||
283 | # res = self.build_res(input_rmb_upper == ocr_str) | ||
284 | except Exception as e: | ||
285 | return self.RESULT_N | ||
286 | else: | ||
287 | return res | ||
288 | |||
234 | def se_type_compare(self, input_str, ocr_str, **kwargs): | 289 | def se_type_compare(self, input_str, ocr_str, **kwargs): |
235 | for map_tuple in self.TYPE_MAPPING: | 290 | for map_tuple in self.TYPE_MAPPING: |
236 | if re.search(map_tuple[0], ocr_str) is not None: | 291 | if re.search(map_tuple[0], ocr_str) is not None: |
... | @@ -240,6 +295,15 @@ class Comparison: | ... | @@ -240,6 +295,15 @@ class Comparison: |
240 | compare_str = self.CSOTH | 295 | compare_str = self.CSOTH |
241 | return self.build_res(input_str == compare_str) | 296 | return self.build_res(input_str == compare_str) |
242 | 297 | ||
298 | def ca_type_compare(self, input_str, ocr_str, **kwargs): | ||
299 | for map_tuple in self.TYPE_MAPPING: | ||
300 | if re.search(map_tuple[0], ocr_str) is not None: | ||
301 | compare_str = map_tuple[1] | ||
302 | break | ||
303 | else: | ||
304 | compare_str = self.CSOTH | ||
305 | return self.build_res(input_str == compare_str) | ||
306 | |||
243 | def se_date_compare_2(self, input_str, ocr_str, **kwargs): | 307 | def se_date_compare_2(self, input_str, ocr_str, **kwargs): |
244 | try: | 308 | try: |
245 | input_date = time.strptime(input_str, "%Y-%m-%d") | 309 | input_date = time.strptime(input_str, "%Y-%m-%d") | ... | ... |
src/common/tools/mssql_script7.py
0 → 100644
1 | import pyodbc | ||
2 | |||
3 | hil_sql = """ | ||
4 | ALTER TABLE hil_ca_compare_result ADD version nvarchar(8), comments nvarchar(max); | ||
5 | ALTER TABLE hil_se_compare_result ADD version nvarchar(8), comments nvarchar(max); | ||
6 | |||
7 | create table hil_se_compare_result_record | ||
8 | ( | ||
9 | id int identity primary key, | ||
10 | application_id nvarchar(64) not null, | ||
11 | is_finish bit default 0 not null, | ||
12 | compare_count smallint default 0 not null, | ||
13 | failed_count smallint default 0 not null, | ||
14 | reason1_count smallint default 0 not null, | ||
15 | reason2_count smallint default 0 not null, | ||
16 | reason3_count smallint default 0 not null, | ||
17 | reason4_count smallint default 0 not null, | ||
18 | reason5_count smallint default 0 not null, | ||
19 | reason6_count smallint default 0 not null, | ||
20 | reason7_count smallint default 0 not null, | ||
21 | reason8_count smallint default 0 not null, | ||
22 | reason9_count smallint default 0 not null, | ||
23 | reason10_count smallint default 0 not null, | ||
24 | result nvarchar(max), | ||
25 | comments nvarchar(max), | ||
26 | create_time datetime not null | ||
27 | ); | ||
28 | |||
29 | create index hil_se_compare_result_record_application_id_index | ||
30 | on hil_se_compare_result_record (application_id); | ||
31 | |||
32 | create index hil_se_compare_result_record_create_time_index | ||
33 | on hil_se_compare_result_record (create_time); | ||
34 | |||
35 | create table hil_ca_compare_result_record | ||
36 | ( | ||
37 | id int identity primary key, | ||
38 | application_id nvarchar(64) not null, | ||
39 | is_finish bit default 0 not null, | ||
40 | compare_count smallint default 0 not null, | ||
41 | failed_count smallint default 0 not null, | ||
42 | reason1_count smallint default 0 not null, | ||
43 | reason2_count smallint default 0 not null, | ||
44 | reason3_count smallint default 0 not null, | ||
45 | reason4_count smallint default 0 not null, | ||
46 | reason5_count smallint default 0 not null, | ||
47 | reason6_count smallint default 0 not null, | ||
48 | reason7_count smallint default 0 not null, | ||
49 | reason8_count smallint default 0 not null, | ||
50 | reason9_count smallint default 0 not null, | ||
51 | reason10_count smallint default 0 not null, | ||
52 | result nvarchar(max), | ||
53 | comments nvarchar(max), | ||
54 | create_time datetime not null | ||
55 | ); | ||
56 | |||
57 | create index hil_ca_compare_result_record_application_id_index | ||
58 | on hil_ca_compare_result_record (application_id); | ||
59 | |||
60 | create index hil_ca_compare_result_record_create_time_index | ||
61 | on hil_ca_compare_result_record (create_time); | ||
62 | """ | ||
63 | |||
64 | afc_sql = """ | ||
65 | ALTER TABLE afc_ca_compare_result ADD version nvarchar(8), comments nvarchar(max); | ||
66 | ALTER TABLE afc_se_compare_result ADD version nvarchar(8), comments nvarchar(max); | ||
67 | |||
68 | create table afc_se_compare_result_record | ||
69 | ( | ||
70 | id int identity primary key, | ||
71 | application_id nvarchar(64) not null, | ||
72 | is_finish bit default 0 not null, | ||
73 | compare_count smallint default 0 not null, | ||
74 | failed_count smallint default 0 not null, | ||
75 | reason1_count smallint default 0 not null, | ||
76 | reason2_count smallint default 0 not null, | ||
77 | reason3_count smallint default 0 not null, | ||
78 | reason4_count smallint default 0 not null, | ||
79 | reason5_count smallint default 0 not null, | ||
80 | reason6_count smallint default 0 not null, | ||
81 | reason7_count smallint default 0 not null, | ||
82 | reason8_count smallint default 0 not null, | ||
83 | reason9_count smallint default 0 not null, | ||
84 | reason10_count smallint default 0 not null, | ||
85 | result nvarchar(max), | ||
86 | comments nvarchar(max), | ||
87 | create_time datetime not null | ||
88 | ); | ||
89 | |||
90 | create index afc_se_compare_result_record_application_id_index | ||
91 | on afc_se_compare_result_record (application_id); | ||
92 | |||
93 | create index afc_se_compare_result_record_create_time_index | ||
94 | on afc_se_compare_result_record (create_time); | ||
95 | |||
96 | create table afc_ca_compare_result_record | ||
97 | ( | ||
98 | id int identity primary key, | ||
99 | application_id nvarchar(64) not null, | ||
100 | is_finish bit default 0 not null, | ||
101 | compare_count smallint default 0 not null, | ||
102 | failed_count smallint default 0 not null, | ||
103 | reason1_count smallint default 0 not null, | ||
104 | reason2_count smallint default 0 not null, | ||
105 | reason3_count smallint default 0 not null, | ||
106 | reason4_count smallint default 0 not null, | ||
107 | reason5_count smallint default 0 not null, | ||
108 | reason6_count smallint default 0 not null, | ||
109 | reason7_count smallint default 0 not null, | ||
110 | reason8_count smallint default 0 not null, | ||
111 | reason9_count smallint default 0 not null, | ||
112 | reason10_count smallint default 0 not null, | ||
113 | result nvarchar(max), | ||
114 | comments nvarchar(max), | ||
115 | create_time datetime not null | ||
116 | ); | ||
117 | |||
118 | create index afc_ca_compare_result_record_application_id_index | ||
119 | on afc_ca_compare_result_record (application_id); | ||
120 | |||
121 | create index afc_ca_compare_result_record_create_time_index | ||
122 | on afc_ca_compare_result_record (create_time); | ||
123 | """ | ||
124 | |||
125 | hil_cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};', autocommit=True) | ||
126 | |||
127 | hil_cursor = hil_cnxn.cursor() | ||
128 | hil_cursor.execute(hil_sql) | ||
129 | |||
130 | hil_cursor.close() | ||
131 | hil_cnxn.close() | ||
132 | |||
133 | afc_cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};', autocommit=True) | ||
134 | |||
135 | afc_cursor = afc_cnxn.cursor() | ||
136 | afc_cursor.execute(afc_sql) | ||
137 | |||
138 | afc_cursor.close() | ||
139 | afc_cnxn.close() |
... | @@ -12,3 +12,5 @@ EDMS_DOWNLOAD_URL = http://sccn0639.bmwgroup.net/FH/FileHold/DocumentRepository/ | ... | @@ -12,3 +12,5 @@ EDMS_DOWNLOAD_URL = http://sccn0639.bmwgroup.net/FH/FileHold/DocumentRepository/ |
12 | EDMS_UPLOAD_URL = http://sccn0639.bmwgroup.net/FH/FileHold/DocumentRepository/UploadHandler.ashx | 12 | EDMS_UPLOAD_URL = http://sccn0639.bmwgroup.net/FH/FileHold/DocumentRepository/UploadHandler.ashx |
13 | DEALER_CODE = ocr_group | 13 | DEALER_CODE = ocr_group |
14 | 14 | ||
15 | BASE_URL = https://li19dkocruat02vm.bmwgroup.net | ||
16 | ... | ... |
... | @@ -10,4 +10,6 @@ IMG_QUEUE_SIZE = 500 | ... | @@ -10,4 +10,6 @@ IMG_QUEUE_SIZE = 500 |
10 | 10 | ||
11 | EDMS_DOWNLOAD_URL = https://edms-test.bmw.com/FH/FileHold/DocumentRepository/DownloadHandler.ashx | 11 | EDMS_DOWNLOAD_URL = https://edms-test.bmw.com/FH/FileHold/DocumentRepository/DownloadHandler.ashx |
12 | EDMS_UPLOAD_URL = https://edms-test.bmw.com/FH/FileHold/DocumentRepository/UploadHandler.ashx | 12 | EDMS_UPLOAD_URL = https://edms-test.bmw.com/FH/FileHold/DocumentRepository/UploadHandler.ashx |
13 | DEALER_CODE = ocr_situ_group | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
13 | DEALER_CODE = ocr_situ_group | ||
14 | |||
15 | BASE_URL = https://staging-bmw-ocr.situdata.com | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -10,4 +10,6 @@ IMG_QUEUE_SIZE = 500 | ... | @@ -10,4 +10,6 @@ IMG_QUEUE_SIZE = 500 |
10 | 10 | ||
11 | EDMS_DOWNLOAD_URL = http://sccn0637.bmwgroup.net/FH/FileHold/DocumentRepository/DownloadHandler.ashx | 11 | EDMS_DOWNLOAD_URL = http://sccn0637.bmwgroup.net/FH/FileHold/DocumentRepository/DownloadHandler.ashx |
12 | EDMS_UPLOAD_URL = http://sccn0637.bmwgroup.net/FH/FileHold/DocumentRepository/UploadHandler.ashx | 12 | EDMS_UPLOAD_URL = http://sccn0637.bmwgroup.net/FH/FileHold/DocumentRepository/UploadHandler.ashx |
13 | DEALER_CODE = ocr_situ_group | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
13 | DEALER_CODE = ocr_situ_group | ||
14 | |||
15 | BASE_URL = https://li19dkocruat01vm.bmwgroup.net | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or sign in to post a comment