35db299e by 周伟奇

slice1 part2

1 parent 254938ba
...@@ -1449,7 +1449,112 @@ SE_SECOND_ID_FIELD_MAPPING = { ...@@ -1449,7 +1449,112 @@ SE_SECOND_ID_FIELD_MAPPING = {
1449 HEAD_LIST = ['Info', 'Index', 'License', 'Field', 'Input', 'OCR', 'Result', 'Position', 'Image', 'errorType'] 1449 HEAD_LIST = ['Info', 'Index', 'License', 'Field', 'Input', 'OCR', 'Result', 'Position', 'Image', 'errorType']
1450 1450
1451 IMG_PATH_KEY = 'uniq_img_path_key' 1451 IMG_PATH_KEY = 'uniq_img_path_key'
1452 IMG_PATH_KEY_2 = 'uniq_img_path_key_2'
1452 1453
1453 INFO_SOURCE = ['POS', 'CMS'] 1454 INFO_SOURCE = ['POS', 'CMS']
1454 1455
1456 # -------------------
1457
1458 CA_FIRST_ID_FIELD = ['customerChineseName', 'idNum', 'idExpiryDate', 'dateOfBirth']
1459
1460 CA_FIRST_ID_FIELD_MAPPING = {
1461 'ITPRC': (ID_EN, CA_FIRST_ID_FIELD),
1462 'ITPSP': (PP_EN, CA_FIRST_ID_FIELD),
1463 'ITHKM': (EEP_EN, CA_FIRST_ID_FIELD),
1464 'ITTID': (EEP_EN, CA_FIRST_ID_FIELD),
1465 'ITRES': (RP_EN, CA_FIRST_ID_FIELD),
1466 }
1467
1468 CA_SECOND_ID_FIELD = [
1469 ('customerChineseName', 'customerChineseName'),
1470 ('secondIdNum', 'idNum')
1471 ]
1472
1473 CA_SECOND_ID_FIELD_MAPPING = {
1474 'ITPRC': (ID_EN, CA_SECOND_ID_FIELD),
1475 'ITPSP': (PP_EN, CA_SECOND_ID_FIELD),
1476 'ITHKM': (EEP_EN, CA_SECOND_ID_FIELD),
1477 'ITTID': (EEP_EN, CA_SECOND_ID_FIELD),
1478 'ITRES': (RP_EN, CA_SECOND_ID_FIELD),
1479 }
1480
1481 CA_SEP_FIELD = ['companyName', 'customerChineseName', 'registeredCapital', 'selfEmployedSubType']
1482
1483 CA_CORPORATE_FIELD = [
1484 ('customerChineseName', 'companyName'),
1485 ('legalRepName', 'customerChineseName'),
1486 ('idNum', 'idNum'),
1487 ('businessLicenseNo', 'businessLicenseNo'),
1488 ('taxRegistrationCode', 'taxRegistrationCode'),
1489 ('incorporationDate', 'incorporationDate'),
1490 ('businessLicenseDueDate', 'businessLicenseDueDate'),
1491 ('capitalRegAmount', 'registeredCapital'),
1492 ]
1493
1494 CA_MVC_FIELD = ['vinNo', 'manufactureDate', 'firstRegistrationDate']
1495 CA_DL_FIELD = ['vinNo']
1496 DL_EN = 'Driving Licence'
1497
1498 CA_ID_COMPARE_LOGIC = {
1499 'customerChineseName': ('姓名', 'ca_name_compare', {}),
1500 'idNum': ('公民身份号码', 'ca_common_compare', {}),
1501 'dateOfBirth': ('出生年月', 'ca_date_compare', {'input_replace': ''}),
1502 'idExpiryDate': ('有效期限', 'ca_date_compare', {'long': True, 'ocr_split': True, 'input_replace': ''}),
1503 }
1504
1505
1506 CA_PP_COMPARE_LOGIC = {
1507 'customerChineseName': ('英文姓名', 'ca_name_compare', {'is_passport': True}),
1508 'idNum': ('护照号码', 'ca_common_compare', {}),
1509 'dateOfBirth': ('出生日期', 'ca_date_compare', {'input_replace': ''}),
1510 'idExpiryDate': ('有效期至', 'ca_date_compare', {'input_replace': ''}),
1511 }
1512
1513 CA_EEP_COMPARE_LOGIC = {
1514 'customerChineseName': ('中文名', 'ca_common_compare', {}),
1515 'idNum': ('证件号码', 'ca_common_compare', {}),
1516 'dateOfBirth': ('出生日期', 'ca_date_compare', {'input_replace': '.'}),
1517 'idExpiryDate': ('有效期限', 'ca_date_compare', {'ocr_split': True, 'input_replace': '.'}),
1518 }
1519
1520 CA_RP_COMPARE_LOGIC = {
1521 'customerChineseName': ('姓名', 'ca_common_compare', {}),
1522 'idNum': ('公民身份号码', 'ca_common_compare', {}),
1523 'dateOfBirth': ('出生年月', 'ca_date_compare', {'input_replace': ''}),
1524 'idExpiryDate': ('有效期限', 'ca_date_compare', {'ocr_split': True, 'input_replace': ''}),
1525 }
1526
1527 CA_BL_COMPARE_LOGIC = {
1528 'companyName': ('企业名称', 'ca_company_compare', {}),
1529 'customerChineseName': ('经营者姓名', 'ca_name_compare', {}),
1530 'idNum': ('注册号', 'ca_common_compare', {}),
1531 'businessLicenseNo': ('注册号', 'ca_common_compare', {}),
1532 'taxRegistrationCode': ('注册号', 'ca_common_compare', {}),
1533 'incorporationDate': ('成立日期', 'ca_date_compare', {'ocr_replace': True}),
1534 'businessLicenseDueDate': ('营业期限', 'ca_date_compare', {'ocr_split': True, 'long': True, 'ocr_replace': True}),
1535 'registeredCapital': ('注册资本', 'ca_rmb_compare', {}),
1536 'selfEmployedSubType': ('企业类型', 'ca_type_compare', {}),
1537 }
1538
1539 CA_MVC_COMPARE_LOGIC = {
1540 'vinNo': ('9.车辆识别代号/车架号', 'ca_common_compare', {}),
1541 'manufactureDate': ('32.车辆出厂日期', 'ca_date_compare', {}),
1542 'firstRegistrationDate': ('3.登记日期', 'ca_date_compare', {}),
1543 }
1544
1545 CA_DL_COMPARE_LOGIC = {
1546 'vinNo': ('车辆识别代码', 'ca_common_compare', {}),
1547 }
1548
1549 CA_COMPARE_FIELD = {
1550 ID_EN: (IC_OCR_FIELD, CA_ID_COMPARE_LOGIC, True),
1551 PP_EN: (PP_OCR_FIELD, CA_PP_COMPARE_LOGIC, False),
1552 EEP_EN: (EEP_OCR_FIELD, CA_EEP_COMPARE_LOGIC, False),
1553 RP_EN: (RP_OCR_FIELD, CA_RP_COMPARE_LOGIC, True),
1554
1555 BL_EN: (BL_OCR_FIELD, CA_BL_COMPARE_LOGIC, False),
1556
1557 MVC_EN: (MVC_OCR_FIELD, CA_MVC_COMPARE_LOGIC, False),
1558 DL_EN: (DL_OCR_FIELD, CA_DL_COMPARE_LOGIC, False),
1559 }
1455 1560
......
...@@ -244,6 +244,9 @@ class Command(BaseCommand, LoggerMixin): ...@@ -244,6 +244,9 @@ class Command(BaseCommand, LoggerMixin):
244 244
245 elif classify == consts.IC_CLASSIFY: # 身份证真伪 245 elif classify == consts.IC_CLASSIFY: # 身份证真伪
246 for id_card_dict in license_data: 246 for id_card_dict in license_data:
247 if '有效期限' in id_card_dict:
248 id_card_dict[consts.IMG_PATH_KEY_2] = img_path
249 else:
247 id_card_dict[consts.IMG_PATH_KEY] = img_path 250 id_card_dict[consts.IMG_PATH_KEY] = img_path
248 try: 251 try:
249 base64_img = id_card_dict.pop('base64_img') 252 base64_img = id_card_dict.pop('base64_img')
...@@ -1030,7 +1033,7 @@ class Command(BaseCommand, LoggerMixin): ...@@ -1030,7 +1033,7 @@ class Command(BaseCommand, LoggerMixin):
1030 license_list = license_summary.get(classify) 1033 license_list = license_summary.get(classify)
1031 if not license_list: 1034 if not license_list:
1032 continue 1035 continue
1033 if classify == consts.IC_CLASSIFY and ic_merge: # TODO 正反面合并时的img_path处理 1036 if classify == consts.IC_CLASSIFY and ic_merge:
1034 license_list[0].update(license_list[1]) 1037 license_list[0].update(license_list[1])
1035 license_list.pop(1) 1038 license_list.pop(1)
1036 elif classify == consts.RP_CLASSIFY and rp_merge: 1039 elif classify == consts.RP_CLASSIFY and rp_merge:
...@@ -1357,9 +1360,9 @@ class Command(BaseCommand, LoggerMixin): ...@@ -1357,9 +1360,9 @@ class Command(BaseCommand, LoggerMixin):
1357 1360
1358 finally: 1361 finally:
1359 try: 1362 try:
1360 img_save_path = os.path.join(doc_data_path, 'img') 1363 # img_save_path = os.path.join(doc_data_path, 'img')
1361 write_zip_file(img_save_path, os.path.join(doc_data_path, '{0}_img.zip'.format(doc_id_str))) 1364 # write_zip_file(img_save_path, os.path.join(doc_data_path, '{0}_img.zip'.format(doc_id_str)))
1362 shutil.rmtree(img_save_path, ignore_errors=True) 1365 # shutil.rmtree(img_save_path, ignore_errors=True)
1363 pdf_path = os.path.join(doc_data_path, '{0}.pdf'.format(doc_id_str)) 1366 pdf_path = os.path.join(doc_data_path, '{0}.pdf'.format(doc_id_str))
1364 os.remove(pdf_path) 1367 os.remove(pdf_path)
1365 self.online_log.info('{0} [pdf & img removed] [task={1}]'.format(self.log_base, task_str)) 1368 self.online_log.info('{0} [pdf & img removed] [task={1}]'.format(self.log_base, task_str))
......
...@@ -546,7 +546,7 @@ class AFCSECompareResult(models.Model): ...@@ -546,7 +546,7 @@ 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 version = models.CharField(max_length=8, verbose_name="POS/CMS version") 548 version = models.CharField(max_length=8, verbose_name="POS/CMS version")
549 is_finish = models.BooleanField(default=False, verbose_name="是否完成") 549 is_finish = models.BooleanField(default=False, verbose_name="整体结果")
550 compare_count = models.SmallIntegerField(default=0, verbose_name="比对字段总数") 550 compare_count = models.SmallIntegerField(default=0, verbose_name="比对字段总数")
551 failed_count = models.SmallIntegerField(default=0, verbose_name="比对失败数目") 551 failed_count = models.SmallIntegerField(default=0, verbose_name="比对失败数目")
552 reason1_count = models.SmallIntegerField(default=0, verbose_name="原因1数目") 552 reason1_count = models.SmallIntegerField(default=0, verbose_name="原因1数目")
...@@ -574,7 +574,7 @@ class AFCCACompareResult(models.Model): ...@@ -574,7 +574,7 @@ class AFCCACompareResult(models.Model):
574 id = models.AutoField(primary_key=True, verbose_name="id") # 主键 574 id = models.AutoField(primary_key=True, verbose_name="id") # 主键
575 application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引 575 application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引
576 version = models.CharField(max_length=8, verbose_name="POS/CMS version") 576 version = models.CharField(max_length=8, verbose_name="POS/CMS version")
577 is_finish = models.BooleanField(default=False, verbose_name="是否完成") 577 is_finish = models.BooleanField(default=False, verbose_name="整体结果")
578 compare_count = models.SmallIntegerField(default=0, verbose_name="比对字段总数") 578 compare_count = models.SmallIntegerField(default=0, verbose_name="比对字段总数")
579 failed_count = models.SmallIntegerField(default=0, verbose_name="比对失败数目") 579 failed_count = models.SmallIntegerField(default=0, verbose_name="比对失败数目")
580 reason1_count = models.SmallIntegerField(default=0, verbose_name="原因1数目") 580 reason1_count = models.SmallIntegerField(default=0, verbose_name="原因1数目")
...@@ -602,7 +602,7 @@ class HILSECompareResult(models.Model): ...@@ -602,7 +602,7 @@ class HILSECompareResult(models.Model):
602 id = models.AutoField(primary_key=True, verbose_name="id") # 主键 602 id = models.AutoField(primary_key=True, verbose_name="id") # 主键
603 application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引 603 application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引
604 version = models.CharField(max_length=8, verbose_name="POS/CMS version") 604 version = models.CharField(max_length=8, verbose_name="POS/CMS version")
605 is_finish = models.BooleanField(default=False, verbose_name="是否完成") 605 is_finish = models.BooleanField(default=False, verbose_name="整体结果")
606 compare_count = models.SmallIntegerField(default=0, verbose_name="比对字段总数") 606 compare_count = models.SmallIntegerField(default=0, verbose_name="比对字段总数")
607 failed_count = models.SmallIntegerField(default=0, verbose_name="比对失败数目") 607 failed_count = models.SmallIntegerField(default=0, verbose_name="比对失败数目")
608 reason1_count = models.SmallIntegerField(default=0, verbose_name="原因1数目") 608 reason1_count = models.SmallIntegerField(default=0, verbose_name="原因1数目")
...@@ -629,7 +629,7 @@ class HILCACompareResult(models.Model): ...@@ -629,7 +629,7 @@ class HILCACompareResult(models.Model):
629 id = models.AutoField(primary_key=True, verbose_name="id") # 主键 629 id = models.AutoField(primary_key=True, verbose_name="id") # 主键
630 application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引 630 application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引
631 version = models.CharField(max_length=8, verbose_name="POS/CMS version") 631 version = models.CharField(max_length=8, verbose_name="POS/CMS version")
632 is_finish = models.BooleanField(default=False, verbose_name="是否完成") 632 is_finish = models.BooleanField(default=False, verbose_name="整体结果")
633 compare_count = models.SmallIntegerField(default=0, verbose_name="比对字段总数") 633 compare_count = models.SmallIntegerField(default=0, verbose_name="比对字段总数")
634 failed_count = models.SmallIntegerField(default=0, verbose_name="比对失败数目") 634 failed_count = models.SmallIntegerField(default=0, verbose_name="比对失败数目")
635 reason1_count = models.SmallIntegerField(default=0, verbose_name="原因1数目") 635 reason1_count = models.SmallIntegerField(default=0, verbose_name="原因1数目")
...@@ -652,3 +652,103 @@ class HILCACompareResult(models.Model): ...@@ -652,3 +652,103 @@ class HILCACompareResult(models.Model):
652 db_table = 'hil_ca_compare_result' 652 db_table = 'hil_ca_compare_result'
653 653
654 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
......
...@@ -30,6 +30,10 @@ from .models import ( ...@@ -30,6 +30,10 @@ 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 )
34 from .named_enum import ErrorType 38 from .named_enum import ErrorType
35 from .mixins import DocHandler 39 from .mixins import DocHandler
...@@ -295,7 +299,6 @@ application_information = { ...@@ -295,7 +299,6 @@ application_information = {
295 299
296 priority_doc_args = { 300 priority_doc_args = {
297 'APPLICATION_INFORMATION': fields.Nested(application_information, required=True) 301 'APPLICATION_INFORMATION': fields.Nested(application_information, required=True)
298
299 } 302 }
300 303
301 compare_offline_args = { 304 compare_offline_args = {
...@@ -313,6 +316,32 @@ compare_offline_args = { ...@@ -313,6 +316,32 @@ compare_offline_args = {
313 'workflow_name': fields.Str(required=True, validate=validate.Length(max=1024)), 316 'workflow_name': fields.Str(required=True, validate=validate.Length(max=1024)),
314 } 317 }
315 318
319 result_item_args = {
320 consts.HEAD_LIST[0]: fields.Str(required=True),
321 consts.HEAD_LIST[1]: fields.Str(required=True),
322 consts.HEAD_LIST[2]: fields.Str(required=True),
323 consts.HEAD_LIST[3]: fields.Str(required=True),
324 consts.HEAD_LIST[4]: fields.Str(required=True),
325 consts.HEAD_LIST[5]: fields.Str(required=True),
326 consts.HEAD_LIST[6]: fields.Str(required=True),
327 consts.HEAD_LIST[7]: fields.Str(required=True),
328 consts.HEAD_LIST[8]: fields.List(fields.Str(), required=True),
329 consts.HEAD_LIST[9]: fields.Int(required=True),
330 }
331
332 result_update_args = {
333 'id': fields.Int(required=True),
334 'application_id': fields.Str(required=True, validate=validate.Length(max=64)),
335 'entity': fields.Str(required=True, validate=validate.OneOf(consts.BUSINESS_TYPE_LIST)),
336 'scheme': fields.Str(required=True, validate=validate.OneOf(consts.DOC_SCHEME_LIST)),
337 'whole_result': fields.Str(required=True),
338 'version': fields.Str(required=True),
339 'source': fields.Str(required=True),
340 'latest_compared_time': fields.Str(required=True),
341 'comments': fields.Str(required=True),
342 'result': fields.List(fields.Nested(result_item_args), required=True, validate=validate.Length(min=1)),
343 }
344
316 345
317 class UploadDocView(GenericView, DocHandler): 346 class UploadDocView(GenericView, DocHandler):
318 # permission_classes = [] 347 # permission_classes = []
...@@ -776,7 +805,7 @@ class CompareResultView(GenericView): ...@@ -776,7 +805,7 @@ class CompareResultView(GenericView):
776 if result_obj is None: 805 if result_obj is None:
777 whole_result = '' 806 whole_result = ''
778 else: 807 else:
779 whole_result = 'Y' if result_obj.is_finish else 'N' 808 whole_result = consts.RESULT_Y if result_obj.is_finish else consts.RESULT_N
780 809
781 if result_obj is None or result_obj.comments is None: 810 if result_obj is None or result_obj.comments is None:
782 comments = '' 811 comments = ''
...@@ -786,6 +815,7 @@ class CompareResultView(GenericView): ...@@ -786,6 +815,7 @@ class CompareResultView(GenericView):
786 compare_result = { 815 compare_result = {
787 'id': 0 if result_obj is None else result_obj.id, 816 'id': 0 if result_obj is None else result_obj.id,
788 'application_id': case_id, 817 'application_id': case_id,
818 'entity': entity,
789 'scheme': consts.DOC_SCHEME_LIST[0] if scheme == consts.COMPARE_DOC_SCHEME_LIST[0] else consts.DOC_SCHEME_LIST[1], 819 'scheme': consts.DOC_SCHEME_LIST[0] if scheme == consts.COMPARE_DOC_SCHEME_LIST[0] else consts.DOC_SCHEME_LIST[1],
790 'whole_result': whole_result, 820 'whole_result': whole_result,
791 'latest_compared_time': '' if result_obj is None else result_obj.update_time.strftime('%Y-%m-%d %H:%M'), 821 'latest_compared_time': '' if result_obj is None else result_obj.update_time.strftime('%Y-%m-%d %H:%M'),
...@@ -831,21 +861,21 @@ class CompareResultView(GenericView): ...@@ -831,21 +861,21 @@ class CompareResultView(GenericView):
831 # return HttpResponse(html) 861 # return HttpResponse(html)
832 862
833 # 比对结果更新 863 # 比对结果更新
834 # @use_args(result_update_args, location='data') 864 @use_args(result_update_args, location='data')
835 def post(self, request): 865 def post(self, request, args):
836 tmp_flag = random.choice([0, 1]) 866 result_id = args.get('id')
837 if tmp_flag == 0: 867 case_id = args.get('application_id')
838 return response.ok() 868 update_time = args.get('latest_compared_time')
839 else: 869 scheme = args.get('scheme')
840 result_id = None 870 entity = args.get('entity')
841 entity = "AFC" 871 whole_result = args.get('whole_result')
842 scheme = 'SE'
843 case_id = 'CH-S1120929121'
844 872
845 if entity == consts.HIL_PREFIX: 873 if entity == consts.HIL_PREFIX:
846 result_table = HILCACompareResult if scheme == consts.COMPARE_DOC_SCHEME_LIST[0] else HILSECompareResult 874 result_table = HILCACompareResult if scheme == consts.DOC_SCHEME_LIST[0] else HILSECompareResult
875 record_table = HILCACompareResultRecord if scheme == consts.DOC_SCHEME_LIST[0] else HILSECompareResultRecord
847 else: 876 else:
848 result_table = AFCCACompareResult if scheme == consts.COMPARE_DOC_SCHEME_LIST[0] else AFCSECompareResult 877 result_table = AFCCACompareResult if scheme == consts.DOC_SCHEME_LIST[0] else AFCSECompareResult
878 record_table = AFCCACompareResultRecord if scheme == consts.DOC_SCHEME_LIST[0] else AFCSECompareResultRecord
849 879
850 if result_id is not None: 880 if result_id is not None:
851 result_obj = result_table.objects.filter(id=result_id).first() 881 result_obj = result_table.objects.filter(id=result_id).first()
...@@ -853,18 +883,57 @@ class CompareResultView(GenericView): ...@@ -853,18 +883,57 @@ class CompareResultView(GenericView):
853 result_obj = result_table.objects.filter(application_id=case_id).first() 883 result_obj = result_table.objects.filter(application_id=case_id).first()
854 884
855 if result_obj is None: 885 if result_obj is None:
856 whole_result = '' 886 return response.ok()
887
888 result_str = json.dumps(args.get('result', []))
889 is_finish = whole_result == consts.RESULT_Y
890 compare_count = 0
891 failed_count = 0
892 reason_dict = {}
893 for result in args.get('result', []):
894 compare_count += 1
895 if result.get(consts.HEAD_LIST[6]) == consts.RESULT_N:
896 failed_count += 1
897 error_type = result.get(consts.HEAD_LIST[-1], '')
898 if error_type in reason_dict:
899 reason_dict[error_type] = reason_dict[error_type] + 1
857 else: 900 else:
858 whole_result = 'Y' if result_obj.is_finish else 'N' 901 reason_dict[error_type] = 1
902
903 record_table.objects.create(
904 application_id=case_id,
905 is_finish=is_finish,
906 compare_count=compare_count,
907 failed_count=failed_count,
908 reason1_count=reason_dict.get(0, 0),
909 reason2_count=reason_dict.get(1, 0),
910 reason3_count=reason_dict.get(2, 0),
911 reason4_count=reason_dict.get(3, 0),
912 reason5_count=reason_dict.get(4, 0),
913 reason6_count=reason_dict.get(5, 0),
914 reason7_count=reason_dict.get(6, 0),
915 reason8_count=reason_dict.get(7, 0),
916 reason9_count=reason_dict.get(8, 0),
917 reason10_count=reason_dict.get(9, 0),
918 result=result_str,
919 comments=args.get('comments', ''),
920 )
859 921
860 if result_obj is None or result_obj.comments is None: 922 if update_time == result_obj.update_time.strftime('%Y-%m-%d %H:%M'):
861 comments = '' 923 result_obj.result = result_str
924 result_obj.comments = args.get('comments', '')
925 result_obj.update_time = result_obj.update_time
926 result_obj.save()
927 return response.ok()
862 else: 928 else:
863 comments = result_obj.comments 929 whole_result = consts.RESULT_Y if result_obj.is_finish else consts.RESULT_N
930
931 comments = '' if result_obj.comments is None else comments = result_obj.comments
864 932
865 compare_result = { 933 compare_result = {
866 'id': 0 if result_obj is None else result_obj.id, 934 'id': 0 if result_obj is None else result_obj.id,
867 'application_id': case_id, 935 'application_id': case_id,
936 'entity': entity,
868 'scheme': consts.DOC_SCHEME_LIST[0] if scheme == consts.COMPARE_DOC_SCHEME_LIST[0] else 937 'scheme': consts.DOC_SCHEME_LIST[0] if scheme == consts.COMPARE_DOC_SCHEME_LIST[0] else
869 consts.DOC_SCHEME_LIST[1], 938 consts.DOC_SCHEME_LIST[1],
870 'whole_result': whole_result, 939 'whole_result': whole_result,
......
...@@ -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")
......
...@@ -3,11 +3,123 @@ import pyodbc ...@@ -3,11 +3,123 @@ import pyodbc
3 hil_sql = """ 3 hil_sql = """
4 ALTER TABLE hil_ca_compare_result ADD version nvarchar(8), comments nvarchar(max); 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); 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);
6 """ 62 """
7 63
8 afc_sql = """ 64 afc_sql = """
9 ALTER TABLE afc_ca_compare_result ADD version nvarchar(8), comments nvarchar(max); 65 ALTER TABLE afc_ca_compare_result ADD version nvarchar(8), comments nvarchar(max);
10 ALTER TABLE afc_se_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);
11 """ 123 """
12 124
13 hil_cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};', autocommit=True) 125 hil_cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};', autocommit=True)
......
...@@ -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
......
...@@ -11,3 +11,5 @@ IMG_QUEUE_SIZE = 500 ...@@ -11,3 +11,5 @@ IMG_QUEUE_SIZE = 500
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 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
......
...@@ -11,3 +11,5 @@ IMG_QUEUE_SIZE = 500 ...@@ -11,3 +11,5 @@ IMG_QUEUE_SIZE = 500
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 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
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!