fix merge
Showing
13 changed files
with
928 additions
and
88 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)) | ... | ... |
| ... | @@ -545,7 +545,8 @@ class IDBCRecords(models.Model): | ... | @@ -545,7 +545,8 @@ class IDBCRecords(models.Model): |
| 545 | class AFCSECompareResult(models.Model): | 545 | class AFCSECompareResult(models.Model): |
| 546 | id = models.AutoField(primary_key=True, verbose_name="id") # 主键 | 546 | id = models.AutoField(primary_key=True, verbose_name="id") # 主键 |
| 547 | application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引 | 547 | application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引 |
| 548 | is_finish = models.BooleanField(default=False, verbose_name="是否完成") | 548 | version = models.CharField(max_length=8, verbose_name="POS/CMS version") |
| 549 | is_finish = models.BooleanField(default=False, verbose_name="整体结果") | ||
| 549 | compare_count = models.SmallIntegerField(default=0, verbose_name="比对字段总数") | 550 | compare_count = models.SmallIntegerField(default=0, verbose_name="比对字段总数") |
| 550 | failed_count = models.SmallIntegerField(default=0, verbose_name="比对失败数目") | 551 | failed_count = models.SmallIntegerField(default=0, verbose_name="比对失败数目") |
| 551 | reason1_count = models.SmallIntegerField(default=0, verbose_name="原因1数目") | 552 | reason1_count = models.SmallIntegerField(default=0, verbose_name="原因1数目") |
| ... | @@ -559,6 +560,7 @@ class AFCSECompareResult(models.Model): | ... | @@ -559,6 +560,7 @@ class AFCSECompareResult(models.Model): |
| 559 | reason9_count = models.SmallIntegerField(default=0, verbose_name="原因9数目") | 560 | reason9_count = models.SmallIntegerField(default=0, verbose_name="原因9数目") |
| 560 | reason10_count = models.SmallIntegerField(default=0, verbose_name="原因10数目") | 561 | reason10_count = models.SmallIntegerField(default=0, verbose_name="原因10数目") |
| 561 | result = models.TextField(null=True, verbose_name="比对结果") | 562 | result = models.TextField(null=True, verbose_name="比对结果") |
| 563 | comments = models.TextField(null=True, verbose_name="备注") | ||
| 562 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') # 索引 | 564 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') # 索引 |
| 563 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | 565 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') |
| 564 | 566 | ||
| ... | @@ -571,7 +573,8 @@ class AFCSECompareResult(models.Model): | ... | @@ -571,7 +573,8 @@ class AFCSECompareResult(models.Model): |
| 571 | class AFCCACompareResult(models.Model): | 573 | class AFCCACompareResult(models.Model): |
| 572 | id = models.AutoField(primary_key=True, verbose_name="id") # 主键 | 574 | id = models.AutoField(primary_key=True, verbose_name="id") # 主键 |
| 573 | application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引 | 575 | application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引 |
| 574 | is_finish = models.BooleanField(default=False, verbose_name="是否完成") | 576 | version = models.CharField(max_length=8, verbose_name="POS/CMS version") |
| 577 | is_finish = models.BooleanField(default=False, verbose_name="整体结果") | ||
| 575 | compare_count = models.SmallIntegerField(default=0, verbose_name="比对字段总数") | 578 | compare_count = models.SmallIntegerField(default=0, verbose_name="比对字段总数") |
| 576 | failed_count = models.SmallIntegerField(default=0, verbose_name="比对失败数目") | 579 | failed_count = models.SmallIntegerField(default=0, verbose_name="比对失败数目") |
| 577 | reason1_count = models.SmallIntegerField(default=0, verbose_name="原因1数目") | 580 | reason1_count = models.SmallIntegerField(default=0, verbose_name="原因1数目") |
| ... | @@ -585,6 +588,7 @@ class AFCCACompareResult(models.Model): | ... | @@ -585,6 +588,7 @@ class AFCCACompareResult(models.Model): |
| 585 | reason9_count = models.SmallIntegerField(default=0, verbose_name="原因9数目") | 588 | reason9_count = models.SmallIntegerField(default=0, verbose_name="原因9数目") |
| 586 | reason10_count = models.SmallIntegerField(default=0, verbose_name="原因10数目") | 589 | reason10_count = models.SmallIntegerField(default=0, verbose_name="原因10数目") |
| 587 | result = models.TextField(null=True, verbose_name="比对结果") | 590 | result = models.TextField(null=True, verbose_name="比对结果") |
| 591 | comments = models.TextField(null=True, verbose_name="备注") | ||
| 588 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') # 索引 | 592 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') # 索引 |
| 589 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | 593 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') |
| 590 | 594 | ||
| ... | @@ -597,7 +601,8 @@ class AFCCACompareResult(models.Model): | ... | @@ -597,7 +601,8 @@ class AFCCACompareResult(models.Model): |
| 597 | class HILSECompareResult(models.Model): | 601 | class HILSECompareResult(models.Model): |
| 598 | id = models.AutoField(primary_key=True, verbose_name="id") # 主键 | 602 | id = models.AutoField(primary_key=True, verbose_name="id") # 主键 |
| 599 | application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引 | 603 | application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引 |
| 600 | is_finish = models.BooleanField(default=False, verbose_name="是否完成") | 604 | version = models.CharField(max_length=8, verbose_name="POS/CMS version") |
| 605 | is_finish = models.BooleanField(default=False, verbose_name="整体结果") | ||
| 601 | compare_count = models.SmallIntegerField(default=0, verbose_name="比对字段总数") | 606 | compare_count = models.SmallIntegerField(default=0, verbose_name="比对字段总数") |
| 602 | failed_count = models.SmallIntegerField(default=0, verbose_name="比对失败数目") | 607 | failed_count = models.SmallIntegerField(default=0, verbose_name="比对失败数目") |
| 603 | reason1_count = models.SmallIntegerField(default=0, verbose_name="原因1数目") | 608 | reason1_count = models.SmallIntegerField(default=0, verbose_name="原因1数目") |
| ... | @@ -611,6 +616,7 @@ class HILSECompareResult(models.Model): | ... | @@ -611,6 +616,7 @@ class HILSECompareResult(models.Model): |
| 611 | reason9_count = models.SmallIntegerField(default=0, verbose_name="原因9数目") | 616 | reason9_count = models.SmallIntegerField(default=0, verbose_name="原因9数目") |
| 612 | reason10_count = models.SmallIntegerField(default=0, verbose_name="原因10数目") | 617 | reason10_count = models.SmallIntegerField(default=0, verbose_name="原因10数目") |
| 613 | result = models.TextField(null=True, verbose_name="比对结果") | 618 | result = models.TextField(null=True, verbose_name="比对结果") |
| 619 | comments = models.TextField(null=True, verbose_name="备注") | ||
| 614 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') # 索引 | 620 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') # 索引 |
| 615 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | 621 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') |
| 616 | 622 | ||
| ... | @@ -622,7 +628,8 @@ class HILSECompareResult(models.Model): | ... | @@ -622,7 +628,8 @@ class HILSECompareResult(models.Model): |
| 622 | class HILCACompareResult(models.Model): | 628 | class HILCACompareResult(models.Model): |
| 623 | id = models.AutoField(primary_key=True, verbose_name="id") # 主键 | 629 | id = models.AutoField(primary_key=True, verbose_name="id") # 主键 |
| 624 | application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引 | 630 | application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引 |
| 625 | is_finish = models.BooleanField(default=False, verbose_name="是否完成") | 631 | version = models.CharField(max_length=8, verbose_name="POS/CMS version") |
| 632 | is_finish = models.BooleanField(default=False, verbose_name="整体结果") | ||
| 626 | compare_count = models.SmallIntegerField(default=0, verbose_name="比对字段总数") | 633 | compare_count = models.SmallIntegerField(default=0, verbose_name="比对字段总数") |
| 627 | failed_count = models.SmallIntegerField(default=0, verbose_name="比对失败数目") | 634 | failed_count = models.SmallIntegerField(default=0, verbose_name="比对失败数目") |
| 628 | reason1_count = models.SmallIntegerField(default=0, verbose_name="原因1数目") | 635 | reason1_count = models.SmallIntegerField(default=0, verbose_name="原因1数目") |
| ... | @@ -636,6 +643,7 @@ class HILCACompareResult(models.Model): | ... | @@ -636,6 +643,7 @@ class HILCACompareResult(models.Model): |
| 636 | reason9_count = models.SmallIntegerField(default=0, verbose_name="原因9数目") | 643 | reason9_count = models.SmallIntegerField(default=0, verbose_name="原因9数目") |
| 637 | reason10_count = models.SmallIntegerField(default=0, verbose_name="原因10数目") | 644 | reason10_count = models.SmallIntegerField(default=0, verbose_name="原因10数目") |
| 638 | result = models.TextField(null=True, verbose_name="比对结果") | 645 | result = models.TextField(null=True, verbose_name="比对结果") |
| 646 | comments = models.TextField(null=True, verbose_name="备注") | ||
| 639 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') # 索引 | 647 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') # 索引 |
| 640 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | 648 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') |
| 641 | 649 | ||
| ... | @@ -644,3 +652,103 @@ class HILCACompareResult(models.Model): | ... | @@ -644,3 +652,103 @@ class HILCACompareResult(models.Model): |
| 644 | db_table = 'hil_ca_compare_result' | 652 | db_table = 'hil_ca_compare_result' |
| 645 | 653 | ||
| 646 | 654 | ||
| 655 | class AFCSECompareResultRecord(models.Model): | ||
| 656 | id = models.AutoField(primary_key=True, verbose_name="id") # 主键 | ||
| 657 | application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引 | ||
| 658 | is_finish = models.BooleanField(default=False, verbose_name="整体结果") | ||
| 659 | compare_count = models.SmallIntegerField(default=0, verbose_name="比对字段总数") | ||
| 660 | failed_count = models.SmallIntegerField(default=0, verbose_name="比对失败数目") | ||
| 661 | reason1_count = models.SmallIntegerField(default=0, verbose_name="原因1数目") | ||
| 662 | reason2_count = models.SmallIntegerField(default=0, verbose_name="原因2数目") | ||
| 663 | reason3_count = models.SmallIntegerField(default=0, verbose_name="原因3数目") | ||
| 664 | reason4_count = models.SmallIntegerField(default=0, verbose_name="原因4数目") | ||
| 665 | reason5_count = models.SmallIntegerField(default=0, verbose_name="原因5数目") | ||
| 666 | reason6_count = models.SmallIntegerField(default=0, verbose_name="原因6数目") | ||
| 667 | reason7_count = models.SmallIntegerField(default=0, verbose_name="原因7数目") | ||
| 668 | reason8_count = models.SmallIntegerField(default=0, verbose_name="原因8数目") | ||
| 669 | reason9_count = models.SmallIntegerField(default=0, verbose_name="原因9数目") | ||
| 670 | reason10_count = models.SmallIntegerField(default=0, verbose_name="原因10数目") | ||
| 671 | result = models.TextField(null=True, verbose_name="比对结果") | ||
| 672 | comments = models.TextField(null=True, verbose_name="备注") | ||
| 673 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | ||
| 674 | |||
| 675 | class Meta: | ||
| 676 | managed = False | ||
| 677 | db_table = 'afc_se_compare_result_record' | ||
| 678 | |||
| 679 | |||
| 680 | class AFCCACompareResultRecord(models.Model): | ||
| 681 | id = models.AutoField(primary_key=True, verbose_name="id") # 主键 | ||
| 682 | application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引 | ||
| 683 | is_finish = models.BooleanField(default=False, verbose_name="整体结果") | ||
| 684 | compare_count = models.SmallIntegerField(default=0, verbose_name="比对字段总数") | ||
| 685 | failed_count = models.SmallIntegerField(default=0, verbose_name="比对失败数目") | ||
| 686 | reason1_count = models.SmallIntegerField(default=0, verbose_name="原因1数目") | ||
| 687 | reason2_count = models.SmallIntegerField(default=0, verbose_name="原因2数目") | ||
| 688 | reason3_count = models.SmallIntegerField(default=0, verbose_name="原因3数目") | ||
| 689 | reason4_count = models.SmallIntegerField(default=0, verbose_name="原因4数目") | ||
| 690 | reason5_count = models.SmallIntegerField(default=0, verbose_name="原因5数目") | ||
| 691 | reason6_count = models.SmallIntegerField(default=0, verbose_name="原因6数目") | ||
| 692 | reason7_count = models.SmallIntegerField(default=0, verbose_name="原因7数目") | ||
| 693 | reason8_count = models.SmallIntegerField(default=0, verbose_name="原因8数目") | ||
| 694 | reason9_count = models.SmallIntegerField(default=0, verbose_name="原因9数目") | ||
| 695 | reason10_count = models.SmallIntegerField(default=0, verbose_name="原因10数目") | ||
| 696 | result = models.TextField(null=True, verbose_name="比对结果") | ||
| 697 | comments = models.TextField(null=True, verbose_name="备注") | ||
| 698 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | ||
| 699 | |||
| 700 | class Meta: | ||
| 701 | managed = False | ||
| 702 | db_table = 'afc_ca_compare_result_record' | ||
| 703 | |||
| 704 | |||
| 705 | class HILSECompareResultRecord(models.Model): | ||
| 706 | id = models.AutoField(primary_key=True, verbose_name="id") # 主键 | ||
| 707 | application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引 | ||
| 708 | is_finish = models.BooleanField(default=False, verbose_name="整体结果") | ||
| 709 | compare_count = models.SmallIntegerField(default=0, verbose_name="比对字段总数") | ||
| 710 | failed_count = models.SmallIntegerField(default=0, verbose_name="比对失败数目") | ||
| 711 | reason1_count = models.SmallIntegerField(default=0, verbose_name="原因1数目") | ||
| 712 | reason2_count = models.SmallIntegerField(default=0, verbose_name="原因2数目") | ||
| 713 | reason3_count = models.SmallIntegerField(default=0, verbose_name="原因3数目") | ||
| 714 | reason4_count = models.SmallIntegerField(default=0, verbose_name="原因4数目") | ||
| 715 | reason5_count = models.SmallIntegerField(default=0, verbose_name="原因5数目") | ||
| 716 | reason6_count = models.SmallIntegerField(default=0, verbose_name="原因6数目") | ||
| 717 | reason7_count = models.SmallIntegerField(default=0, verbose_name="原因7数目") | ||
| 718 | reason8_count = models.SmallIntegerField(default=0, verbose_name="原因8数目") | ||
| 719 | reason9_count = models.SmallIntegerField(default=0, verbose_name="原因9数目") | ||
| 720 | reason10_count = models.SmallIntegerField(default=0, verbose_name="原因10数目") | ||
| 721 | result = models.TextField(null=True, verbose_name="比对结果") | ||
| 722 | comments = models.TextField(null=True, verbose_name="备注") | ||
| 723 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | ||
| 724 | |||
| 725 | class Meta: | ||
| 726 | managed = False | ||
| 727 | db_table = 'hil_se_compare_result_record' | ||
| 728 | |||
| 729 | |||
| 730 | class HILCACompareResultRecord(models.Model): | ||
| 731 | id = models.AutoField(primary_key=True, verbose_name="id") # 主键 | ||
| 732 | application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引 | ||
| 733 | is_finish = models.BooleanField(default=False, verbose_name="整体结果") | ||
| 734 | compare_count = models.SmallIntegerField(default=0, verbose_name="比对字段总数") | ||
| 735 | failed_count = models.SmallIntegerField(default=0, verbose_name="比对失败数目") | ||
| 736 | reason1_count = models.SmallIntegerField(default=0, verbose_name="原因1数目") | ||
| 737 | reason2_count = models.SmallIntegerField(default=0, verbose_name="原因2数目") | ||
| 738 | reason3_count = models.SmallIntegerField(default=0, verbose_name="原因3数目") | ||
| 739 | reason4_count = models.SmallIntegerField(default=0, verbose_name="原因4数目") | ||
| 740 | reason5_count = models.SmallIntegerField(default=0, verbose_name="原因5数目") | ||
| 741 | reason6_count = models.SmallIntegerField(default=0, verbose_name="原因6数目") | ||
| 742 | reason7_count = models.SmallIntegerField(default=0, verbose_name="原因7数目") | ||
| 743 | reason8_count = models.SmallIntegerField(default=0, verbose_name="原因8数目") | ||
| 744 | reason9_count = models.SmallIntegerField(default=0, verbose_name="原因9数目") | ||
| 745 | reason10_count = models.SmallIntegerField(default=0, verbose_name="原因10数目") | ||
| 746 | result = models.TextField(null=True, verbose_name="比对结果") | ||
| 747 | comments = models.TextField(null=True, verbose_name="备注") | ||
| 748 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') # 索引 | ||
| 749 | |||
| 750 | class Meta: | ||
| 751 | managed = False | ||
| 752 | db_table = 'hil_ca_compare_result_record' | ||
| 753 | |||
| 754 | ... | ... |
| ... | @@ -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 | ... | ... |
| ... | @@ -30,7 +30,12 @@ from .models import ( | ... | @@ -30,7 +30,12 @@ from .models import ( |
| 30 | AFCSECompareResult, | 30 | AFCSECompareResult, |
| 31 | HILCACompareResult, | 31 | HILCACompareResult, |
| 32 | HILSECompareResult, | 32 | HILSECompareResult, |
| 33 | AFCCACompareResultRecord, | ||
| 34 | AFCSECompareResultRecord, | ||
| 35 | HILCACompareResultRecord, | ||
| 36 | HILSECompareResultRecord, | ||
| 33 | ) | 37 | ) |
| 38 | from .named_enum import ErrorType | ||
| 34 | from .mixins import DocHandler | 39 | from .mixins import DocHandler |
| 35 | from . import consts | 40 | from . import consts |
| 36 | from apps.account.authentication import OAuth2AuthenticationWithUser | 41 | from apps.account.authentication import OAuth2AuthenticationWithUser |
| ... | @@ -294,7 +299,6 @@ application_information = { | ... | @@ -294,7 +299,6 @@ application_information = { |
| 294 | 299 | ||
| 295 | priority_doc_args = { | 300 | priority_doc_args = { |
| 296 | 'APPLICATION_INFORMATION': fields.Nested(application_information, required=True) | 301 | 'APPLICATION_INFORMATION': fields.Nested(application_information, required=True) |
| 297 | |||
| 298 | } | 302 | } |
| 299 | 303 | ||
| 300 | compare_offline_args = { | 304 | compare_offline_args = { |
| ... | @@ -434,6 +438,32 @@ se_cms_args = { | ... | @@ -434,6 +438,32 @@ se_cms_args = { |
| 434 | 'content': fields.Nested(se_cms_content, required=True) | 438 | 'content': fields.Nested(se_cms_content, required=True) |
| 435 | } | 439 | } |
| 436 | 440 | ||
| 441 | result_item_args = { | ||
| 442 | consts.HEAD_LIST[0]: fields.Str(required=True), | ||
| 443 | consts.HEAD_LIST[1]: fields.Str(required=True), | ||
| 444 | consts.HEAD_LIST[2]: fields.Str(required=True), | ||
| 445 | consts.HEAD_LIST[3]: fields.Str(required=True), | ||
| 446 | consts.HEAD_LIST[4]: fields.Str(required=True), | ||
| 447 | consts.HEAD_LIST[5]: fields.Str(required=True), | ||
| 448 | consts.HEAD_LIST[6]: fields.Str(required=True), | ||
| 449 | consts.HEAD_LIST[7]: fields.Str(required=True), | ||
| 450 | consts.HEAD_LIST[8]: fields.List(fields.Str(), required=True), | ||
| 451 | consts.HEAD_LIST[9]: fields.Int(required=True), | ||
| 452 | } | ||
| 453 | |||
| 454 | result_update_args = { | ||
| 455 | 'id': fields.Int(required=True), | ||
| 456 | 'application_id': fields.Str(required=True, validate=validate.Length(max=64)), | ||
| 457 | 'entity': fields.Str(required=True, validate=validate.OneOf(consts.BUSINESS_TYPE_LIST)), | ||
| 458 | 'scheme': fields.Str(required=True, validate=validate.OneOf(consts.DOC_SCHEME_LIST)), | ||
| 459 | 'whole_result': fields.Str(required=True), | ||
| 460 | 'version': fields.Str(required=True), | ||
| 461 | 'source': fields.Str(required=True), | ||
| 462 | 'latest_compared_time': fields.Str(required=True), | ||
| 463 | 'comments': fields.Str(required=True), | ||
| 464 | 'result': fields.List(fields.Nested(result_item_args), required=True, validate=validate.Length(min=1)), | ||
| 465 | } | ||
| 466 | |||
| 437 | 467 | ||
| 438 | class UploadDocView(GenericView, DocHandler): | 468 | class UploadDocView(GenericView, DocHandler): |
| 439 | # permission_classes = [] | 469 | # permission_classes = [] |
| ... | @@ -890,44 +920,166 @@ class CompareResultView(GenericView): | ... | @@ -890,44 +920,166 @@ class CompareResultView(GenericView): |
| 890 | result_table = AFCCACompareResult if scheme == consts.COMPARE_DOC_SCHEME_LIST[0] else AFCSECompareResult | 920 | result_table = AFCCACompareResult if scheme == consts.COMPARE_DOC_SCHEME_LIST[0] else AFCSECompareResult |
| 891 | 921 | ||
| 892 | if result_id is not None: | 922 | if result_id is not None: |
| 893 | result_str_list = result_table.objects.filter(id=result_id).values_list('result', flat=True) | 923 | result_obj = result_table.objects.filter(id=result_id).first() |
| 894 | else: | 924 | else: |
| 895 | result_str_list = result_table.objects.filter(application_id=case_id).values_list('result', flat=True) | 925 | result_obj = result_table.objects.filter(application_id=case_id).first() |
| 896 | 926 | ||
| 897 | if len(result_str_list) == 0: | 927 | if result_obj is None: |
| 898 | compare_result_list = [] | 928 | whole_result = '' |
| 899 | else: | 929 | else: |
| 900 | compare_result_list = json.loads(result_str_list[0]) | 930 | whole_result = consts.RESULT_Y if result_obj.is_finish else consts.RESULT_N |
| 901 | 931 | ||
| 902 | if len(compare_result_list) == 0: | 932 | if result_obj is None or result_obj.comments is None: |
| 903 | body_html = "<h1>没有比对结果</h1>" | 933 | comments = '' |
| 904 | else: | 934 | else: |
| 905 | head_content = ''.join(['<th>{0}</th>'.format(head_name) for head_name in consts.HEAD_LIST]) | 935 | comments = result_obj.comments |
| 906 | head_html = '<tr>{0}</tr>'.format(head_content) | 936 | |
| 907 | row_html_list = [] | 937 | compare_result = { |
| 908 | for row_dict in compare_result_list: | 938 | 'id': 0 if result_obj is None else result_obj.id, |
| 909 | row_list = [row_dict.get(head, '') for head in consts.HEAD_LIST] | 939 | 'application_id': case_id, |
| 910 | row_content = ''.join(['<td>{0}</td>'.format(row_str) for row_str in row_list]) | 940 | 'entity': entity, |
| 911 | row_html = '<tr>{0}</tr>'.format(row_content) | 941 | 'scheme': consts.DOC_SCHEME_LIST[0] if scheme == consts.COMPARE_DOC_SCHEME_LIST[0] else consts.DOC_SCHEME_LIST[1], |
| 912 | row_html_list.append(row_html) | 942 | 'whole_result': whole_result, |
| 913 | content_html = ''.join(row_html_list) | 943 | 'latest_compared_time': '' if result_obj is None else result_obj.update_time.strftime('%Y-%m-%d %H:%M'), |
| 914 | body_html = '<table border="1">{0}{1}</table>'.format(head_html, content_html) | 944 | 'source': '' if result_obj is None else result_obj.version.split(consts.SPLIT_STR)[0], |
| 915 | 945 | 'version': '' if result_obj is None else result_obj.version.split(consts.SPLIT_STR)[1], | |
| 916 | html = """ | 946 | 'comments': comments, |
| 917 | <!DOCTYPE html> | 947 | 'result': [] if result_obj is None else json.loads(result_obj.result) |
| 918 | <html> | 948 | } |
| 919 | <head> | 949 | |
| 920 | <meta charset="utf-8"> | 950 | return response.ok(data=compare_result) |
| 921 | <title>比对结果</title> | 951 | |
| 922 | </head> | 952 | # if len(result_str_list) == 0: |
| 923 | <body> | 953 | # compare_result_list = [] |
| 924 | {0} | 954 | # else: |
| 925 | </body> | 955 | # compare_result_list = json.loads(result_str_list[0]) |
| 926 | </html> | 956 | # |
| 927 | """.format(body_html) | 957 | # if len(compare_result_list) == 0: |
| 928 | return HttpResponse(html) | 958 | # body_html = "<h1>没有比对结果</h1>" |
| 929 | 959 | # else: | |
| 930 | # return response.ok(data=compare_result) | 960 | # head_content = ''.join(['<th>{0}</th>'.format(head_name) for head_name in consts.HEAD_LIST]) |
| 961 | # head_html = '<tr>{0}</tr>'.format(head_content) | ||
| 962 | # row_html_list = [] | ||
| 963 | # for row_dict in compare_result_list: | ||
| 964 | # row_list = [row_dict.get(head, '') for head in consts.HEAD_LIST] | ||
| 965 | # row_content = ''.join(['<td>{0}</td>'.format(row_str) for row_str in row_list]) | ||
| 966 | # row_html = '<tr>{0}</tr>'.format(row_content) | ||
| 967 | # row_html_list.append(row_html) | ||
| 968 | # content_html = ''.join(row_html_list) | ||
| 969 | # body_html = '<table border="1">{0}{1}</table>'.format(head_html, content_html) | ||
| 970 | # | ||
| 971 | # html = """ | ||
| 972 | # <!DOCTYPE html> | ||
| 973 | # <html> | ||
| 974 | # <head> | ||
| 975 | # <meta charset="utf-8"> | ||
| 976 | # <title>比对结果</title> | ||
| 977 | # </head> | ||
| 978 | # <body> | ||
| 979 | # {0} | ||
| 980 | # </body> | ||
| 981 | # </html> | ||
| 982 | # """.format(body_html) | ||
| 983 | # return HttpResponse(html) | ||
| 984 | |||
| 985 | # 比对结果更新 | ||
| 986 | @use_args(result_update_args, location='data') | ||
| 987 | def post(self, request, args): | ||
| 988 | result_id = args.get('id') | ||
| 989 | case_id = args.get('application_id') | ||
| 990 | update_time = args.get('latest_compared_time') | ||
| 991 | scheme = args.get('scheme') | ||
| 992 | entity = args.get('entity') | ||
| 993 | whole_result = args.get('whole_result') | ||
| 994 | |||
| 995 | if entity == consts.HIL_PREFIX: | ||
| 996 | result_table = HILCACompareResult if scheme == consts.DOC_SCHEME_LIST[0] else HILSECompareResult | ||
| 997 | record_table = HILCACompareResultRecord if scheme == consts.DOC_SCHEME_LIST[0] else HILSECompareResultRecord | ||
| 998 | else: | ||
| 999 | result_table = AFCCACompareResult if scheme == consts.DOC_SCHEME_LIST[0] else AFCSECompareResult | ||
| 1000 | record_table = AFCCACompareResultRecord if scheme == consts.DOC_SCHEME_LIST[0] else AFCSECompareResultRecord | ||
| 1001 | |||
| 1002 | if result_id is not None: | ||
| 1003 | result_obj = result_table.objects.filter(id=result_id).first() | ||
| 1004 | else: | ||
| 1005 | result_obj = result_table.objects.filter(application_id=case_id).first() | ||
| 1006 | |||
| 1007 | if result_obj is None: | ||
| 1008 | return response.ok() | ||
| 1009 | |||
| 1010 | result_str = json.dumps(args.get('result', [])) | ||
| 1011 | is_finish = whole_result == consts.RESULT_Y | ||
| 1012 | compare_count = 0 | ||
| 1013 | failed_count = 0 | ||
| 1014 | reason_dict = {} | ||
| 1015 | for result in args.get('result', []): | ||
| 1016 | compare_count += 1 | ||
| 1017 | if result.get(consts.HEAD_LIST[6]) == consts.RESULT_N: | ||
| 1018 | failed_count += 1 | ||
| 1019 | error_type = result.get(consts.HEAD_LIST[-1], '') | ||
| 1020 | if error_type in reason_dict: | ||
| 1021 | reason_dict[error_type] = reason_dict[error_type] + 1 | ||
| 1022 | else: | ||
| 1023 | reason_dict[error_type] = 1 | ||
| 1024 | |||
| 1025 | record_table.objects.create( | ||
| 1026 | application_id=case_id, | ||
| 1027 | is_finish=is_finish, | ||
| 1028 | compare_count=compare_count, | ||
| 1029 | failed_count=failed_count, | ||
| 1030 | reason1_count=reason_dict.get(0, 0), | ||
| 1031 | reason2_count=reason_dict.get(1, 0), | ||
| 1032 | reason3_count=reason_dict.get(2, 0), | ||
| 1033 | reason4_count=reason_dict.get(3, 0), | ||
| 1034 | reason5_count=reason_dict.get(4, 0), | ||
| 1035 | reason6_count=reason_dict.get(5, 0), | ||
| 1036 | reason7_count=reason_dict.get(6, 0), | ||
| 1037 | reason8_count=reason_dict.get(7, 0), | ||
| 1038 | reason9_count=reason_dict.get(8, 0), | ||
| 1039 | reason10_count=reason_dict.get(9, 0), | ||
| 1040 | result=result_str, | ||
| 1041 | comments=args.get('comments', ''), | ||
| 1042 | ) | ||
| 1043 | |||
| 1044 | if update_time == result_obj.update_time.strftime('%Y-%m-%d %H:%M'): | ||
| 1045 | result_obj.result = result_str | ||
| 1046 | result_obj.comments = args.get('comments', '') | ||
| 1047 | result_obj.update_time = result_obj.update_time | ||
| 1048 | result_obj.save() | ||
| 1049 | return response.ok() | ||
| 1050 | else: | ||
| 1051 | whole_result = consts.RESULT_Y if result_obj.is_finish else consts.RESULT_N | ||
| 1052 | |||
| 1053 | comments = '' if result_obj.comments is None else comments = result_obj.comments | ||
| 1054 | |||
| 1055 | compare_result = { | ||
| 1056 | 'id': 0 if result_obj is None else result_obj.id, | ||
| 1057 | 'application_id': case_id, | ||
| 1058 | 'entity': entity, | ||
| 1059 | 'scheme': consts.DOC_SCHEME_LIST[0] if scheme == consts.COMPARE_DOC_SCHEME_LIST[0] else | ||
| 1060 | consts.DOC_SCHEME_LIST[1], | ||
| 1061 | 'whole_result': whole_result, | ||
| 1062 | 'latest_compared_time': '' if result_obj is None else result_obj.update_time.strftime('%Y-%m-%d %H:%M'), | ||
| 1063 | 'source': '' if result_obj is None else result_obj.version.split(consts.SPLIT_STR)[0], | ||
| 1064 | 'version': '' if result_obj is None else result_obj.version.split(consts.SPLIT_STR)[1], | ||
| 1065 | 'comments': comments, | ||
| 1066 | 'result': [] if result_obj is None else json.loads(result_obj.result) | ||
| 1067 | } | ||
| 1068 | |||
| 1069 | return response.need_update(data=compare_result) | ||
| 1070 | |||
| 1071 | |||
| 1072 | class ResourcesView(GenericView): | ||
| 1073 | permission_classes = [] | ||
| 1074 | authentication_classes = [] | ||
| 1075 | |||
| 1076 | def get(self, request): | ||
| 1077 | error_type_map = ErrorType.get_mappings() | ||
| 1078 | error_type = [{'label': v, 'value': k} for k, v in error_type_map.items()] | ||
| 1079 | resources = { | ||
| 1080 | 'error_type': error_type | ||
| 1081 | } | ||
| 1082 | return response.ok(data=resources) | ||
| 931 | 1083 | ||
| 932 | 1084 | ||
| 933 | class SECMSView(GenericView): | 1085 | class SECMSView(GenericView): |
| ... | @@ -957,4 +1109,4 @@ class SECMSView(GenericView): | ... | @@ -957,4 +1109,4 @@ class SECMSView(GenericView): |
| 957 | description: ok | 1109 | description: ok |
| 958 | schema: | 1110 | schema: |
| 959 | $ref: '#/definitions/ApiResponse' | 1111 | $ref: '#/definitions/ApiResponse' |
| 960 | ''' | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1112 | ''' | ... | ... |
| ... | @@ -5,6 +5,7 @@ import traceback | ... | @@ -5,6 +5,7 @@ import traceback |
| 5 | from datetime import datetime, timedelta | 5 | from datetime import datetime, timedelta |
| 6 | from collections import OrderedDict | 6 | from collections import OrderedDict |
| 7 | from . import app | 7 | from . import app |
| 8 | from settings import conf | ||
| 8 | from apps.doc.models import ( | 9 | from apps.doc.models import ( |
| 9 | AFCOCRResult, | 10 | AFCOCRResult, |
| 10 | AFCSEOCRResult, | 11 | AFCSEOCRResult, |
| ... | @@ -18,16 +19,20 @@ from apps.doc.models import ( | ... | @@ -18,16 +19,20 @@ from apps.doc.models import ( |
| 18 | HILCompareReport, | 19 | HILCompareReport, |
| 19 | AFCCompareReport, | 20 | AFCCompareReport, |
| 20 | AFCSECompareResult, | 21 | AFCSECompareResult, |
| 22 | AFCCACompareResult, | ||
| 21 | HILSECompareResult, | 23 | HILSECompareResult, |
| 24 | HILCACompareResult, | ||
| 22 | ) | 25 | ) |
| 23 | from apps.doc import consts | 26 | from apps.doc import consts |
| 24 | from apps.doc.ocr.gcap import gcap | 27 | from apps.doc.ocr.gcap import gcap |
| 25 | from apps.doc.exceptions import GCAPException | 28 | from apps.doc.exceptions import GCAPException |
| 26 | from apps.doc.named_enum import RequestTeam, RequestTrigger, ProcessName | 29 | from apps.doc.named_enum import RequestTeam, RequestTrigger, ProcessName, ErrorType |
| 27 | from common.tools.comparison import cp | 30 | from common.tools.comparison import cp |
| 28 | 31 | ||
| 29 | compare_log = logging.getLogger('compare') | 32 | compare_log = logging.getLogger('compare') |
| 30 | log_base = '[Compare]' | 33 | log_base = '[Compare]' |
| 34 | empty_str = '' | ||
| 35 | empty_error_type = 1000 | ||
| 31 | 36 | ||
| 32 | 37 | ||
| 33 | def name_check(ocr_res_dict, second_ocr_field, second_compare_list, second_id_num, name): | 38 | def name_check(ocr_res_dict, second_ocr_field, second_compare_list, second_id_num, name): |
| ... | @@ -96,10 +101,11 @@ def field_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_set, | ... | @@ -96,10 +101,11 @@ def field_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_set, |
| 96 | else: | 101 | else: |
| 97 | expiry_dates = [] | 102 | expiry_dates = [] |
| 98 | 103 | ||
| 99 | for ocr_res in tmp_list: | 104 | for res_idx in range(length-1, -1, -1): |
| 100 | # for ocr_res in ocr_res_list: | 105 | # for ocr_res in ocr_res_list: |
| 101 | if is_find: | 106 | if is_find: |
| 102 | break | 107 | break |
| 108 | ocr_res = tmp_list[res_idx] | ||
| 103 | for idx, compare_tuple in enumerate(compare_list): | 109 | for idx, compare_tuple in enumerate(compare_list): |
| 104 | input_str = info_dict.get(compare_tuple[0]) | 110 | input_str = info_dict.get(compare_tuple[0]) |
| 105 | ocr_str = ocr_res.get(compare_tuple[1]) | 111 | ocr_str = ocr_res.get(compare_tuple[1]) |
| ... | @@ -159,9 +165,10 @@ def usedcar_info_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_s | ... | @@ -159,9 +165,10 @@ def usedcar_info_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_s |
| 159 | 165 | ||
| 160 | length = len(tmp_list) | 166 | length = len(tmp_list) |
| 161 | 167 | ||
| 162 | for ocr_res in tmp_list: | 168 | for res_idx in range(length-1, -1, -1): |
| 163 | if is_find: | 169 | if is_find: |
| 164 | break | 170 | break |
| 171 | ocr_res = tmp_list[res_idx] | ||
| 165 | for idx, compare_tuple in enumerate(compare_list): | 172 | for idx, compare_tuple in enumerate(compare_list): |
| 166 | input_str = info_dict.get(compare_tuple[0]) | 173 | input_str = info_dict.get(compare_tuple[0]) |
| 167 | ocr_str = ocr_res.get(compare_tuple[1]) | 174 | ocr_str = ocr_res.get(compare_tuple[1]) |
| ... | @@ -195,9 +202,230 @@ def usedcar_info_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_s | ... | @@ -195,9 +202,230 @@ def usedcar_info_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_s |
| 195 | return is_find and key_right, no_match_vino | 202 | return is_find and key_right, no_match_vino |
| 196 | 203 | ||
| 197 | 204 | ||
| 205 | def get_ca_compare_info(last_obj): | ||
| 206 | compare_info = {} | ||
| 207 | individual_info_dict = {} | ||
| 208 | for individual_info in json.loads(last_obj.individual_cus_info): | ||
| 209 | license_dict = {} | ||
| 210 | |||
| 211 | if individual_info['idType'] in consts.CA_FIRST_ID_FIELD_MAPPING: | ||
| 212 | license_en, field_list = consts.CA_FIRST_ID_FIELD_MAPPING[individual_info['idType']] | ||
| 213 | field_input = [] | ||
| 214 | for field in field_list: | ||
| 215 | if field in individual_info: | ||
| 216 | field_input.append((field, individual_info.get(field, ''))) | ||
| 217 | license_dict[license_en] = field_input | ||
| 218 | |||
| 219 | if individual_info.get('secondIdType') in consts.CA_SECOND_ID_FIELD_MAPPING: | ||
| 220 | second_license_en, second_field_list = consts.CA_SECOND_ID_FIELD_MAPPING[individual_info['secondIdType']] | ||
| 221 | if second_license_en not in license_dict: | ||
| 222 | second_field_input = [] | ||
| 223 | for second_field, write_field in second_field_list: | ||
| 224 | if second_field in individual_info: | ||
| 225 | second_field_input.append((write_field, individual_info.get(second_field, ''))) | ||
| 226 | license_dict[second_license_en] = second_field_input | ||
| 227 | |||
| 228 | if individual_info['customerType'] == consts.CUSTOMER_TYPE[5]: | ||
| 229 | sep_field_input = [] | ||
| 230 | for sep_field in consts.CA_SEP_FIELD: | ||
| 231 | if sep_field in individual_info: | ||
| 232 | sep_field_input.append((sep_field, individual_info.get(sep_field, ''))) | ||
| 233 | license_dict[consts.BL_EN] = sep_field_input | ||
| 234 | |||
| 235 | if len(license_dict) > 0: | ||
| 236 | individual_info_dict.setdefault(individual_info['applicantType'], []).append(license_dict) | ||
| 237 | |||
| 238 | compare_info['individualCusInfo'] = individual_info_dict | ||
| 239 | |||
| 240 | if isinstance(last_obj.corporate_cus_info, str): | ||
| 241 | corporate_info_dict = json.loads(last_obj.corporate_cus_info) | ||
| 242 | corporate_info = {} | ||
| 243 | bl_field_input = [] | ||
| 244 | for bl_field, write_field in consts.CA_CORPORATE_FIELD: | ||
| 245 | bl_field_input.append((write_field, corporate_info_dict.get(bl_field, ''))) | ||
| 246 | corporate_info[consts.BL_EN] = bl_field_input | ||
| 247 | |||
| 248 | compare_info['corporateCusInfo'] = corporate_info | ||
| 249 | |||
| 250 | if last_obj.vehicle_status == consts.VEHICLE_STATUS[0] and isinstance(last_obj.usedcar_info, str): | ||
| 251 | usedcar_info_dict = json.loads(last_obj.usedcar_info) | ||
| 252 | usedcar_info = {} | ||
| 253 | |||
| 254 | mvc_field_input = [] | ||
| 255 | for mvc_field in consts.CA_MVC_FIELD: | ||
| 256 | mvc_field_input.append((mvc_field, usedcar_info_dict.get(mvc_field, ''))) | ||
| 257 | usedcar_info[consts.MVC_EN] = mvc_field_input | ||
| 258 | |||
| 259 | dl_field_input = [] | ||
| 260 | for dl_field in consts.CA_DL_FIELD: | ||
| 261 | dl_field_input.append((dl_field, usedcar_info_dict.get(dl_field, ''))) | ||
| 262 | usedcar_info[consts.DL_EN] = dl_field_input | ||
| 263 | |||
| 264 | compare_info['usedCarInfo'] = usedcar_info | ||
| 265 | |||
| 266 | return compare_info | ||
| 267 | |||
| 268 | |||
| 269 | def ca_compare_license(license_en, ocr_res_dict, field_list): | ||
| 270 | ocr_field, compare_logic, special_expiry_date = consts.CA_COMPARE_FIELD[license_en] | ||
| 271 | |||
| 272 | is_find = False | ||
| 273 | result_field_list = [] | ||
| 274 | ocr_res_str = ocr_res_dict.get(ocr_field) | ||
| 275 | if ocr_res_str is not None: | ||
| 276 | ocr_res_list = json.loads(ocr_res_str) | ||
| 277 | length = len(ocr_res_list) | ||
| 278 | |||
| 279 | # 身份证、居住证 过期期限特殊处理 | ||
| 280 | if special_expiry_date: | ||
| 281 | expiry_dates = set() | ||
| 282 | expiry_dates_img_path = set() | ||
| 283 | key = compare_logic.get('idExpiryDate')[0] | ||
| 284 | for ocr_res in ocr_res_list: | ||
| 285 | if key in ocr_res: | ||
| 286 | expiry_dates.add(ocr_res[key]) | ||
| 287 | expiry_dates_img_path.add(ocr_res.get(consts.IMG_PATH_KEY_2, '')) | ||
| 288 | else: | ||
| 289 | expiry_dates = set() | ||
| 290 | expiry_dates_img_path = set() | ||
| 291 | |||
| 292 | for res_idx in range(length-1, -1, -1): | ||
| 293 | if is_find: | ||
| 294 | break | ||
| 295 | |||
| 296 | for idx, (name, value) in enumerate(field_list): | ||
| 297 | ocr_str = ocr_res_list[res_idx].get(compare_logic[name][0]) | ||
| 298 | if not isinstance(ocr_str, str): | ||
| 299 | result = consts.RESULT_N | ||
| 300 | ocr_str = empty_str | ||
| 301 | else: | ||
| 302 | result = getattr(cp, compare_logic[name][1])(value, ocr_str, **compare_logic[name][2]) | ||
| 303 | |||
| 304 | if idx == 0 and result == consts.RESULT_N and length > 1: | ||
| 305 | break | ||
| 306 | |||
| 307 | is_find = True | ||
| 308 | |||
| 309 | # 过期期限特殊处理 | ||
| 310 | if special_expiry_date and name == 'idExpiryDate' and result == consts.RESULT_N: | ||
| 311 | for expiry_date in expiry_dates: | ||
| 312 | expiry_date_res = getattr(cp, compare_logic[name][1])(value, expiry_date, **compare_logic[name][2]) | ||
| 313 | if expiry_date_res == consts.RESULT_Y: | ||
| 314 | ocr_str = expiry_date | ||
| 315 | result = expiry_date_res | ||
| 316 | break | ||
| 317 | |||
| 318 | if result == consts.RESULT_N: | ||
| 319 | next_img_path = expiry_dates_img_path.pop() if len(expiry_dates_img_path) > 0 else empty_str | ||
| 320 | img_path = ocr_res_list[res_idx].get(consts.IMG_PATH_KEY_2, next_img_path) | ||
| 321 | else: | ||
| 322 | img_path = empty_str | ||
| 323 | else: | ||
| 324 | img_path = ocr_res_list[res_idx].get(consts.IMG_PATH_KEY, '') if result == consts.RESULT_N else empty_str | ||
| 325 | error_type = empty_error_type if result == consts.RESULT_Y else ErrorType.OCR.value | ||
| 326 | result_field_list.append((name, value, result, ocr_str, img_path, error_type)) | ||
| 327 | |||
| 328 | if not is_find: | ||
| 329 | for name, value in field_list: | ||
| 330 | result_field_list.append((name, value, consts.RESULT_N, empty_str, empty_str, ErrorType.NF.value)) | ||
| 331 | |||
| 332 | return result_field_list | ||
| 333 | |||
| 334 | |||
| 335 | def ca_compare_process(compare_info, ocr_res_dict): | ||
| 336 | # individualCusInfo | ||
| 337 | # corporateCusInfo | ||
| 338 | # usedCarInfo | ||
| 339 | compare_result = [] | ||
| 340 | total_fields = 0 | ||
| 341 | failed_count = 0 | ||
| 342 | |||
| 343 | for info_key, info_value in compare_info.items(): | ||
| 344 | if info_key == 'individualCusInfo': | ||
| 345 | for idx, license_list in info_value.items(): | ||
| 346 | for license_dict in license_list: | ||
| 347 | for license_en, field_list in license_dict.items(): | ||
| 348 | result_field_list = ca_compare_license(license_en, ocr_res_dict, field_list) | ||
| 349 | for name, value, result, ocr_str, img_path, error_type in result_field_list: | ||
| 350 | total_fields += 1 | ||
| 351 | if result == consts.RESULT_N: | ||
| 352 | failed_count += 1 | ||
| 353 | compare_result.append( | ||
| 354 | { | ||
| 355 | consts.HEAD_LIST[0]: info_key, | ||
| 356 | consts.HEAD_LIST[1]: idx, | ||
| 357 | consts.HEAD_LIST[2]: license_en, | ||
| 358 | consts.HEAD_LIST[3]: name, | ||
| 359 | consts.HEAD_LIST[4]: value, | ||
| 360 | consts.HEAD_LIST[5]: ocr_str, | ||
| 361 | consts.HEAD_LIST[6]: result, | ||
| 362 | consts.HEAD_LIST[7]: empty_str, | ||
| 363 | consts.HEAD_LIST[8]: img_path, | ||
| 364 | consts.HEAD_LIST[9]: error_type, | ||
| 365 | } | ||
| 366 | ) | ||
| 367 | else: | ||
| 368 | for license_en, field_list in info_value.items(): | ||
| 369 | result_field_list = ca_compare_license(license_en, ocr_res_dict, field_list) | ||
| 370 | for name, value, result, ocr_str, img_path, error_type in result_field_list: | ||
| 371 | total_fields += 1 | ||
| 372 | if result == consts.RESULT_N: | ||
| 373 | failed_count += 1 | ||
| 374 | compare_result.append( | ||
| 375 | { | ||
| 376 | consts.HEAD_LIST[0]: info_key, | ||
| 377 | consts.HEAD_LIST[1]: "0", | ||
| 378 | consts.HEAD_LIST[2]: license_en, | ||
| 379 | consts.HEAD_LIST[3]: name, | ||
| 380 | consts.HEAD_LIST[4]: value, | ||
| 381 | consts.HEAD_LIST[5]: ocr_str, | ||
| 382 | consts.HEAD_LIST[6]: result, | ||
| 383 | consts.HEAD_LIST[7]: empty_str, | ||
| 384 | consts.HEAD_LIST[8]: img_path, | ||
| 385 | consts.HEAD_LIST[9]: error_type, | ||
| 386 | } | ||
| 387 | ) | ||
| 388 | return compare_result, total_fields, failed_count | ||
| 389 | |||
| 390 | |||
| 198 | def ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict): | 391 | def ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict): |
| 199 | start_time = datetime.now() | 392 | start_time = datetime.now() |
| 393 | |||
| 394 | try: | ||
| 395 | # 比对逻辑 | ||
| 396 | compare_info = get_ca_compare_info(last_obj) | ||
| 397 | compare_result, total_fields, failed_count = ca_compare_process(compare_info, ocr_res_dict) | ||
| 398 | compare_log.info('{0} [CA] [compare success] [entity={1}] [id={2}] [ocr_res_id={3}] [result={4}]'.format( | ||
| 399 | log_base, application_entity, application_id, ocr_res_id, compare_result)) | ||
| 400 | except Exception as e: | ||
| 401 | compare_log.error('{0} [CA] [compare error] [entity={1}] [id={2}] [ocr_res_id={3}] ' | ||
| 402 | '[error={4}]'.format(log_base, application_entity, application_id, ocr_res_id, | ||
| 403 | traceback.format_exc())) | ||
| 404 | else: | ||
| 405 | # 将比对结果写入数据库 | ||
| 406 | try: | ||
| 407 | result_table = HILCACompareResult if application_entity == consts.HIL_PREFIX else AFCCACompareResult | ||
| 408 | res_obj = result_table.objects.filter(application_id=application_id).first() | ||
| 409 | if res_obj is None: | ||
| 410 | res_obj = result_table() | ||
| 411 | res_obj.application_id = application_id | ||
| 412 | res_obj.compare_count = total_fields | ||
| 413 | res_obj.failed_count = failed_count | ||
| 414 | res_obj.is_finish = failed_count == 0 | ||
| 415 | res_obj.version = '{0}{1}{2}'.format(consts.INFO_SOURCE[0], consts.SPLIT_STR, last_obj.application_version) | ||
| 416 | # res_obj.reason1_count = reason1_count | ||
| 417 | res_obj.result = json.dumps(compare_result) | ||
| 418 | res_obj.save() | ||
| 419 | compare_log.info('{0} [CA] [result save success] [entity={1}] [id={2}] [ocr_res_id={3}]'.format( | ||
| 420 | log_base, application_entity, application_id, ocr_res_id)) | ||
| 421 | except Exception as e: | ||
| 422 | compare_log.error('{0} [CA] [result save error] [entity={1}] [id={2}] [ocr_res_id={3}] ' | ||
| 423 | '[error={4}]'.format(log_base, application_entity, application_id, ocr_res_id, | ||
| 424 | traceback.format_exc())) | ||
| 425 | |||
| 200 | compare_failed = False | 426 | compare_failed = False |
| 427 | application_link = '{0}/showList/showList?entity={1}&scheme={2}&case_id={3}'.format( | ||
| 428 | conf.BASE_URL, application_entity, consts.COMPARE_DOC_SCHEME_LIST[0], application_id) | ||
| 201 | 429 | ||
| 202 | # 比对信息 | 430 | # 比对信息 |
| 203 | try: | 431 | try: |
| ... | @@ -209,8 +437,8 @@ def ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res | ... | @@ -209,8 +437,8 @@ def ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res |
| 209 | 'applicationVersion': last_obj.application_version, | 437 | 'applicationVersion': last_obj.application_version, |
| 210 | 'vehicleStatus': last_obj.vehicle_status, | 438 | 'vehicleStatus': last_obj.vehicle_status, |
| 211 | 'wholeResult': 'N', | 439 | 'wholeResult': 'N', |
| 212 | 'wholeResultMessage': '', | 440 | 'wholeResultMessage': empty_str, |
| 213 | 'applicationLink': r'//china.bmw.corp/WINFS/SF-CN-data/SF3-CN-S/SF3-CN-S-1-New Business/CA/OCR II test', | 441 | 'applicationLink': application_link, |
| 214 | } | 442 | } |
| 215 | }) | 443 | }) |
| 216 | 444 | ||
| ... | @@ -230,7 +458,7 @@ def ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res | ... | @@ -230,7 +458,7 @@ def ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res |
| 230 | sep_name = order_individual_cus_info.get('customerChineseName') | 458 | sep_name = order_individual_cus_info.get('customerChineseName') |
| 231 | if isinstance(sep_name, str): | 459 | if isinstance(sep_name, str): |
| 232 | sep_name = sep_name.strip() | 460 | sep_name = sep_name.strip() |
| 233 | if sep_name == '': | 461 | if sep_name == empty_str: |
| 234 | sep_name = None | 462 | sep_name = None |
| 235 | else: | 463 | else: |
| 236 | sep_name = None | 464 | sep_name = None |
| ... | @@ -296,12 +524,12 @@ def ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res | ... | @@ -296,12 +524,12 @@ def ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res |
| 296 | consts.PCUSD_DL, res_set) | 524 | consts.PCUSD_DL, res_set) |
| 297 | 525 | ||
| 298 | if mvc_find is True and dl_find is False: | 526 | if mvc_find is True and dl_find is False: |
| 299 | vino = dl_vinos[-1] if len(dl_vinos) > 0 else '' | 527 | vino = dl_vinos[-1] if len(dl_vinos) > 0 else empty_str |
| 300 | order_usedcar_info[consts.PCUSD_MVC[0][0]] = '{0}-{1} {2} {3}-{4}'.format( | 528 | order_usedcar_info[consts.PCUSD_MVC[0][0]] = '{0}-{1} {2} {3}-{4}'.format( |
| 301 | consts.PREFIX_MVC, consts.RESULT_Y, consts.SPLIT, consts.PREFIX_DL, vino) | 529 | consts.PREFIX_MVC, consts.RESULT_Y, consts.SPLIT, consts.PREFIX_DL, vino) |
| 302 | order_usedcar_info[consts.PCUSD_MVC[0][4]] = consts.RESULT_N | 530 | order_usedcar_info[consts.PCUSD_MVC[0][4]] = consts.RESULT_N |
| 303 | elif mvc_find is False and dl_find is True: | 531 | elif mvc_find is False and dl_find is True: |
| 304 | vino = mvc_vinos[-1] if len(mvc_vinos) > 0 else '' | 532 | vino = mvc_vinos[-1] if len(mvc_vinos) > 0 else empty_str |
| 305 | order_usedcar_info[consts.PCUSD_MVC[0][0]] = '{0}-{1} {2} {3}-{4}'.format( | 533 | order_usedcar_info[consts.PCUSD_MVC[0][0]] = '{0}-{1} {2} {3}-{4}'.format( |
| 306 | consts.PREFIX_MVC, vino, consts.SPLIT, consts.PREFIX_DL, consts.RESULT_Y) | 534 | consts.PREFIX_MVC, vino, consts.SPLIT, consts.PREFIX_DL, consts.RESULT_Y) |
| 307 | order_usedcar_info[consts.PCUSD_MVC[0][4]] = consts.RESULT_N | 535 | order_usedcar_info[consts.PCUSD_MVC[0][4]] = consts.RESULT_N |
| ... | @@ -310,8 +538,8 @@ def ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res | ... | @@ -310,8 +538,8 @@ def ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res |
| 310 | order_usedcar_info[consts.PCUSD_MVC[0][0]] = None | 538 | order_usedcar_info[consts.PCUSD_MVC[0][0]] = None |
| 311 | order_usedcar_info[consts.PCUSD_MVC[0][4]] = consts.RESULT_NA | 539 | order_usedcar_info[consts.PCUSD_MVC[0][4]] = consts.RESULT_NA |
| 312 | else: | 540 | else: |
| 313 | mvc_vino = mvc_vinos[-1] if len(mvc_vinos) > 0 else '' | 541 | mvc_vino = mvc_vinos[-1] if len(mvc_vinos) > 0 else empty_str |
| 314 | dl_vino = dl_vinos[-1] if len(dl_vinos) > 0 else '' | 542 | dl_vino = dl_vinos[-1] if len(dl_vinos) > 0 else empty_str |
| 315 | vino = '{0}-{1} {2} {3}-{4}'.format( | 543 | vino = '{0}-{1} {2} {3}-{4}'.format( |
| 316 | consts.PREFIX_MVC, mvc_vino, consts.SPLIT, consts.PREFIX_DL, dl_vino) | 544 | consts.PREFIX_MVC, mvc_vino, consts.SPLIT, consts.PREFIX_DL, dl_vino) |
| 317 | order_usedcar_info[consts.PCUSD_MVC[0][0]] = vino | 545 | order_usedcar_info[consts.PCUSD_MVC[0][0]] = vino |
| ... | @@ -452,7 +680,7 @@ def ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res | ... | @@ -452,7 +680,7 @@ def ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res |
| 452 | failure_reason = '、'.join(reason_list) | 680 | failure_reason = '、'.join(reason_list) |
| 453 | 681 | ||
| 454 | else: | 682 | else: |
| 455 | failure_reason = '' | 683 | failure_reason = empty_str |
| 456 | 684 | ||
| 457 | request_trigger = RequestTrigger.SUBMITING.value if ocr_res_id is None else RequestTrigger.UPLOADING.value | 685 | request_trigger = RequestTrigger.SUBMITING.value if ocr_res_id is None else RequestTrigger.UPLOADING.value |
| 458 | report_class = HILCompareReport if application_entity == consts.HIL_PREFIX else AFCCompareReport | 686 | report_class = HILCompareReport if application_entity == consts.HIL_PREFIX else AFCCompareReport |
| ... | @@ -652,7 +880,7 @@ def se_compare_license(license_en, ocr_res_dict, field_list): | ... | @@ -652,7 +880,7 @@ def se_compare_license(license_en, ocr_res_dict, field_list): |
| 652 | ocr_str = ocr_res_list[res_idx].get(compare_logic[name][0]) | 880 | ocr_str = ocr_res_list[res_idx].get(compare_logic[name][0]) |
| 653 | if not isinstance(ocr_str, str): | 881 | if not isinstance(ocr_str, str): |
| 654 | result = consts.RESULT_N | 882 | result = consts.RESULT_N |
| 655 | ocr_str = '' | 883 | ocr_str = empty_str |
| 656 | else: | 884 | else: |
| 657 | result = getattr(cp, compare_logic[name][1])(value, ocr_str, **compare_logic[name][2]) | 885 | result = getattr(cp, compare_logic[name][1])(value, ocr_str, **compare_logic[name][2]) |
| 658 | 886 | ||
| ... | @@ -670,11 +898,13 @@ def se_compare_license(license_en, ocr_res_dict, field_list): | ... | @@ -670,11 +898,13 @@ def se_compare_license(license_en, ocr_res_dict, field_list): |
| 670 | result = expiry_date_res | 898 | result = expiry_date_res |
| 671 | break | 899 | break |
| 672 | 900 | ||
| 673 | result_field_list.append((name, value, result, ocr_str)) | 901 | img_path = ocr_res_list[res_idx].get(consts.IMG_PATH_KEY, '') if result == consts.RESULT_N else empty_str |
| 902 | error_type = empty_error_type if result == consts.RESULT_Y else ErrorType.OCR.value | ||
| 903 | result_field_list.append((name, value, result, ocr_str, img_path, error_type)) | ||
| 674 | 904 | ||
| 675 | if not is_find: | 905 | if not is_find: |
| 676 | for name, value in field_list: | 906 | for name, value in field_list: |
| 677 | result_field_list.append((name, value, consts.RESULT_N, '')) | 907 | result_field_list.append((name, value, consts.RESULT_N, empty_str, empty_str, ErrorType.NF.value)) |
| 678 | 908 | ||
| 679 | return result_field_list | 909 | return result_field_list |
| 680 | 910 | ||
| ... | @@ -694,19 +924,21 @@ def se_mvc34_compare(license_en, ocr_res_dict, field_list): | ... | @@ -694,19 +924,21 @@ def se_mvc34_compare(license_en, ocr_res_dict, field_list): |
| 694 | first_res = None | 924 | first_res = None |
| 695 | for res_idx in range(length-1, -1, -1): | 925 | for res_idx in range(length-1, -1, -1): |
| 696 | if consts.TRANSFER_DATE in ocr_res_list[res_idx]: | 926 | if consts.TRANSFER_DATE in ocr_res_list[res_idx]: |
| 927 | img_path = ocr_res_list[res_idx].get(consts.IMG_PATH_KEY, '') | ||
| 697 | for idx, transfer_date in enumerate(ocr_res_list[res_idx].get(consts.TRANSFER_DATE, [])): | 928 | for idx, transfer_date in enumerate(ocr_res_list[res_idx].get(consts.TRANSFER_DATE, [])): |
| 698 | try: | 929 | try: |
| 699 | transfer_name = ocr_res_list[res_idx].get(consts.TRANSFER_NAME, [])[idx] | 930 | transfer_name = ocr_res_list[res_idx].get(consts.TRANSFER_NAME, [])[idx] |
| 700 | except Exception as e: | 931 | except Exception as e: |
| 701 | transfer_name = '' | 932 | transfer_name = empty_str |
| 702 | try: | 933 | try: |
| 703 | transfer_num = ocr_res_list[res_idx].get(consts.TRANSFER_NUM, [])[idx] | 934 | transfer_num = ocr_res_list[res_idx].get(consts.TRANSFER_NUM, [])[idx] |
| 704 | except Exception as e: | 935 | except Exception as e: |
| 705 | transfer_num = '' | 936 | transfer_num = empty_str |
| 706 | core_info = { | 937 | core_info = { |
| 707 | consts.TRANSFER_NAME: transfer_name, | 938 | consts.TRANSFER_NAME: transfer_name, |
| 708 | consts.TRANSFER_NUM: transfer_num, | 939 | consts.TRANSFER_NUM: transfer_num, |
| 709 | consts.TRANSFER_DATE: transfer_date | 940 | consts.TRANSFER_DATE: transfer_date, |
| 941 | consts.IMG_PATH_KEY: img_path, | ||
| 710 | } | 942 | } |
| 711 | page34_date_dict.setdefault(transfer_date, []).append(core_info) | 943 | page34_date_dict.setdefault(transfer_date, []).append(core_info) |
| 712 | if first_res is None: | 944 | if first_res is None: |
| ... | @@ -729,14 +961,16 @@ def se_mvc34_compare(license_en, ocr_res_dict, field_list): | ... | @@ -729,14 +961,16 @@ def se_mvc34_compare(license_en, ocr_res_dict, field_list): |
| 729 | ocr_str = ocr_res.get(compare_logic[name][0]) | 961 | ocr_str = ocr_res.get(compare_logic[name][0]) |
| 730 | if not isinstance(ocr_str, str): | 962 | if not isinstance(ocr_str, str): |
| 731 | result = consts.RESULT_N | 963 | result = consts.RESULT_N |
| 732 | ocr_str = '' | 964 | ocr_str = empty_str |
| 733 | else: | 965 | else: |
| 734 | result = getattr(cp, compare_logic[name][1])(value, ocr_str, **compare_logic[name][2]) | 966 | result = getattr(cp, compare_logic[name][1])(value, ocr_str, **compare_logic[name][2]) |
| 735 | result_field_list.append((name, value, result, ocr_str)) | 967 | img_path = ocr_res.get(consts.IMG_PATH_KEY, '') if result == consts.RESULT_N else empty_str |
| 968 | error_type = empty_error_type if result == consts.RESULT_Y else ErrorType.OCR.value | ||
| 969 | result_field_list.append((name, value, result, ocr_str, img_path, error_type)) | ||
| 736 | 970 | ||
| 737 | if not is_find: | 971 | if not is_find: |
| 738 | for name, value in field_list: | 972 | for name, value in field_list: |
| 739 | result_field_list.append((name, value, consts.RESULT_N, '')) | 973 | result_field_list.append((name, value, consts.RESULT_N, empty_str, empty_str, ErrorType.NF.value)) |
| 740 | 974 | ||
| 741 | return result_field_list | 975 | return result_field_list |
| 742 | 976 | ||
| ... | @@ -759,7 +993,7 @@ def se_compare_process(compare_info, ocr_res_dict): | ... | @@ -759,7 +993,7 @@ def se_compare_process(compare_info, ocr_res_dict): |
| 759 | for license_en, field_list in license_dict.items(): | 993 | for license_en, field_list in license_dict.items(): |
| 760 | failure_field = [] | 994 | failure_field = [] |
| 761 | result_field_list = se_compare_license(license_en, ocr_res_dict, field_list) | 995 | result_field_list = se_compare_license(license_en, ocr_res_dict, field_list) |
| 762 | for name, value, result, ocr_str in result_field_list: | 996 | for name, value, result, ocr_str, img_path, error_type in result_field_list: |
| 763 | total_fields += 1 | 997 | total_fields += 1 |
| 764 | if result == consts.RESULT_N: | 998 | if result == consts.RESULT_N: |
| 765 | failed_count += 1 | 999 | failed_count += 1 |
| ... | @@ -767,16 +1001,16 @@ def se_compare_process(compare_info, ocr_res_dict): | ... | @@ -767,16 +1001,16 @@ def se_compare_process(compare_info, ocr_res_dict): |
| 767 | failure_field.append(name) | 1001 | failure_field.append(name) |
| 768 | compare_result.append( | 1002 | compare_result.append( |
| 769 | { | 1003 | { |
| 770 | 'Info': info_key, | 1004 | consts.HEAD_LIST[0]: info_key, |
| 771 | 'Index': idx, | 1005 | consts.HEAD_LIST[1]: idx, |
| 772 | 'License': license_en, | 1006 | consts.HEAD_LIST[2]: license_en, |
| 773 | 'Field': name, | 1007 | consts.HEAD_LIST[3]: name, |
| 774 | 'Input': value, | 1008 | consts.HEAD_LIST[4]: value, |
| 775 | 'OCR': ocr_str, | 1009 | consts.HEAD_LIST[5]: ocr_str, |
| 776 | 'Result': result, | 1010 | consts.HEAD_LIST[6]: result, |
| 777 | 'Position': '', | 1011 | consts.HEAD_LIST[7]: empty_str, |
| 778 | 'Image': '', | 1012 | consts.HEAD_LIST[8]: img_path, |
| 779 | 'errorType': '', | 1013 | consts.HEAD_LIST[9]: error_type, |
| 780 | } | 1014 | } |
| 781 | ) | 1015 | ) |
| 782 | if len(failure_field) > 0: | 1016 | if len(failure_field) > 0: |
| ... | @@ -788,7 +1022,7 @@ def se_compare_process(compare_info, ocr_res_dict): | ... | @@ -788,7 +1022,7 @@ def se_compare_process(compare_info, ocr_res_dict): |
| 788 | result_field_list = se_mvc34_compare(license_en, ocr_res_dict, field_list) | 1022 | result_field_list = se_mvc34_compare(license_en, ocr_res_dict, field_list) |
| 789 | else: | 1023 | else: |
| 790 | result_field_list = se_compare_license(license_en, ocr_res_dict, field_list) | 1024 | result_field_list = se_compare_license(license_en, ocr_res_dict, field_list) |
| 791 | for name, value, result, ocr_str in result_field_list: | 1025 | for name, value, result, ocr_str, img_path, error_type in result_field_list: |
| 792 | total_fields += 1 | 1026 | total_fields += 1 |
| 793 | if result == consts.RESULT_N: | 1027 | if result == consts.RESULT_N: |
| 794 | failed_count += 1 | 1028 | failed_count += 1 |
| ... | @@ -796,16 +1030,16 @@ def se_compare_process(compare_info, ocr_res_dict): | ... | @@ -796,16 +1030,16 @@ def se_compare_process(compare_info, ocr_res_dict): |
| 796 | failure_field.append(name) | 1030 | failure_field.append(name) |
| 797 | compare_result.append( | 1031 | compare_result.append( |
| 798 | { | 1032 | { |
| 799 | 'Info': info_key, | 1033 | consts.HEAD_LIST[0]: info_key, |
| 800 | 'Index': 0, | 1034 | consts.HEAD_LIST[1]: "0", |
| 801 | 'License': license_en, | 1035 | consts.HEAD_LIST[2]: license_en, |
| 802 | 'Field': name, | 1036 | consts.HEAD_LIST[3]: name, |
| 803 | 'Input': value, | 1037 | consts.HEAD_LIST[4]: value, |
| 804 | 'OCR': ocr_str, | 1038 | consts.HEAD_LIST[5]: ocr_str, |
| 805 | 'Result': result, | 1039 | consts.HEAD_LIST[6]: result, |
| 806 | 'Position': '', | 1040 | consts.HEAD_LIST[7]: empty_str, |
| 807 | 'Image': '', | 1041 | consts.HEAD_LIST[8]: img_path, |
| 808 | 'errorType': '', | 1042 | consts.HEAD_LIST[9]: error_type, |
| 809 | } | 1043 | } |
| 810 | ) | 1044 | ) |
| 811 | if len(failure_field) > 0: | 1045 | if len(failure_field) > 0: |
| ... | @@ -840,6 +1074,8 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res | ... | @@ -840,6 +1074,8 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res |
| 840 | res_obj.application_id = application_id | 1074 | res_obj.application_id = application_id |
| 841 | res_obj.compare_count = total_fields | 1075 | res_obj.compare_count = total_fields |
| 842 | res_obj.failed_count = failed_count | 1076 | res_obj.failed_count = failed_count |
| 1077 | res_obj.is_finish = failed_count == 0 | ||
| 1078 | res_obj.version = '{0}{1}{2}'.format(consts.INFO_SOURCE[0], consts.SPLIT_STR, last_obj.application_version) | ||
| 843 | # res_obj.reason1_count = reason1_count | 1079 | # res_obj.reason1_count = reason1_count |
| 844 | res_obj.result = json.dumps(compare_result) | 1080 | res_obj.result = json.dumps(compare_result) |
| 845 | res_obj.save() | 1081 | res_obj.save() | ... | ... |
| ... | @@ -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