fix merge
Showing
5 changed files
with
247 additions
and
59 deletions
... | @@ -978,3 +978,22 @@ class GenericOCRReport(models.Model): | ... | @@ -978,3 +978,22 @@ class GenericOCRReport(models.Model): |
978 | class Meta: | 978 | class Meta: |
979 | managed = False | 979 | managed = False |
980 | db_table = 'generic_ocr_report' | 980 | db_table = 'generic_ocr_report' |
981 | |||
982 | |||
983 | class InterfaceReport(models.Model): | ||
984 | id = models.AutoField(primary_key=True, verbose_name="id") # 主键 | ||
985 | |||
986 | source = models.CharField(max_length=64, verbose_name="来源") | ||
987 | target = models.CharField(max_length=64, verbose_name="目标") | ||
988 | |||
989 | body = models.TextField(null=True, verbose_name="请求体") | ||
990 | response = models.TextField(null=True, verbose_name="响应") | ||
991 | |||
992 | status = models.BooleanField(default=True, verbose_name="是否成功") | ||
993 | retry_times = models.SmallIntegerField(default=0, verbose_name="重试次数") | ||
994 | duration = models.IntegerField(verbose_name='处理时长') | ||
995 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | ||
996 | |||
997 | class Meta: | ||
998 | managed = False | ||
999 | db_table = 'interface_report' | ... | ... |
... | @@ -95,3 +95,14 @@ class BSCheckResult(NamedEnum): | ... | @@ -95,3 +95,14 @@ class BSCheckResult(NamedEnum): |
95 | class OfflineFailureReason(NamedEnum): | 95 | class OfflineFailureReason(NamedEnum): |
96 | OS_ERROR = (0, 'OS_ERROR') | 96 | OS_ERROR = (0, 'OS_ERROR') |
97 | PROCESS_ERROR = (1, 'PROCESS_ERROR') | 97 | PROCESS_ERROR = (1, 'PROCESS_ERROR') |
98 | |||
99 | |||
100 | class SystemName(NamedEnum): | ||
101 | POS = (0, 'POS') | ||
102 | EAPP = (1, 'EAPP') | ||
103 | ECONTRACT = (2, 'ECONTRACT') | ||
104 | GCAP = (3, 'GCAP') | ||
105 | CMS = (4, 'CMS') | ||
106 | MPOS = (5, 'MPOS') | ||
107 | UNKNOWN = (6, 'Unknown') | ||
108 | OCR = (7, 'OCR') | ... | ... |
... | @@ -47,8 +47,9 @@ from .models import ( | ... | @@ -47,8 +47,9 @@ from .models import ( |
47 | AFCbankVerification, | 47 | AFCbankVerification, |
48 | MposReport, | 48 | MposReport, |
49 | GenericOCRReport, | 49 | GenericOCRReport, |
50 | InterfaceReport, | ||
50 | ) | 51 | ) |
51 | from .named_enum import ErrorType, AutoResult, WholeResult, RPAResult | 52 | from .named_enum import ErrorType, AutoResult, WholeResult, RPAResult, SystemName |
52 | from .mixins import DocHandler, MPOSHandler, PreSEHandler | 53 | from .mixins import DocHandler, MPOSHandler, PreSEHandler |
53 | from . import consts | 54 | from . import consts |
54 | from apps.account.authentication import OAuth2AuthenticationWithUser | 55 | from apps.account.authentication import OAuth2AuthenticationWithUser |
... | @@ -551,7 +552,9 @@ class UploadDocView(GenericView, DocHandler): | ... | @@ -551,7 +552,9 @@ class UploadDocView(GenericView, DocHandler): |
551 | 552 | ||
552 | # 上传(接收)文件接口 | 553 | # 上传(接收)文件接口 |
553 | @use_args(doc_upload_args, location='data') | 554 | @use_args(doc_upload_args, location='data') |
554 | def post(self, request, args): | 555 | def post(self, request, args): # interface_report pos/eapp/econtract to ocr |
556 | start_time = time.time() | ||
557 | |||
555 | application_data = args.get('applicationData') | 558 | application_data = args.get('applicationData') |
556 | # applicant_data = args.get('applicantData') | 559 | # applicant_data = args.get('applicantData') |
557 | document = args.get('document') | 560 | document = args.get('document') |
... | @@ -560,37 +563,9 @@ class UploadDocView(GenericView, DocHandler): | ... | @@ -560,37 +563,9 @@ class UploadDocView(GenericView, DocHandler): |
560 | document_scheme = document.get('documentScheme') | 563 | document_scheme = document.get('documentScheme') |
561 | data_source = document.get('dataSource') | 564 | data_source = document.get('dataSource') |
562 | document_name = document.get('documentName', '') | 565 | document_name = document.get('documentName', '') |
563 | # main_name = self.get_name(applicant_data, 'mainApplicantName', 16) | ||
564 | # co_name = self.get_name(applicant_data, 'coApplicantName', 16) | ||
565 | # g1_name = self.get_name(applicant_data, 'guarantor1Name', 16) | ||
566 | # g2_name = self.get_name(applicant_data, 'guarantor2Name', 16) | ||
567 | |||
568 | # try: | ||
569 | # # 1. 上传信息记录 | ||
570 | # UploadDocRecords.objects.create( | ||
571 | # metadata_version_id=document.get('metadataVersionId'), | ||
572 | # application_id=application_id, | ||
573 | # main_applicant='main_name', | ||
574 | # co_applicant='co_name', | ||
575 | # guarantor_1='g1_name', | ||
576 | # guarantor_2='g2_name', | ||
577 | # document_name=document_name, | ||
578 | # document_scheme=document_scheme, | ||
579 | # business_type=business_type, | ||
580 | # data_source=data_source, | ||
581 | # upload_finish_time=document.get('uploadFinishTime'), | ||
582 | # ) | ||
583 | # except Exception as e: | ||
584 | # self.running_log.info('[doc upload success] [same file skip] [args={0}]'.format(args)) | ||
585 | # # self.invalid_params(msg='metadataVersionId repeat') | ||
586 | # return response.ok() | ||
587 | 566 | ||
588 | data_source = self.fix_data_source(data_source) | 567 | data_source = self.fix_data_source(data_source) |
589 | document_scheme = self.fix_scheme(document_scheme) | 568 | document_scheme = self.fix_scheme(document_scheme) |
590 | |||
591 | # if document_name.endswith('.zip'): | ||
592 | # self.running_log.info('[doc upload success] [zip file skip] [args={0}]'.format(args)) | ||
593 | # return response.ok() | ||
594 | 569 | ||
595 | if data_source == consts.DATA_SOURCE_LIST[1]: | 570 | if data_source == consts.DATA_SOURCE_LIST[1]: |
596 | if document_name.endswith('-证书.pdf') or document_name.endswith('-证书'): | 571 | if document_name.endswith('-证书.pdf') or document_name.endswith('-证书'): |
... | @@ -602,10 +577,6 @@ class UploadDocView(GenericView, DocHandler): | ... | @@ -602,10 +577,6 @@ class UploadDocView(GenericView, DocHandler): |
602 | doc = doc_class.objects.create( | 577 | doc = doc_class.objects.create( |
603 | metadata_version_id=document.get('metadataVersionId'), | 578 | metadata_version_id=document.get('metadataVersionId'), |
604 | application_id=application_id, | 579 | application_id=application_id, |
605 | # main_applicant=applicant_data.get('mainApplicantName'), | ||
606 | # co_applicant=applicant_data.get('coApplicantName'), | ||
607 | # guarantor_1=applicant_data.get('guarantor1Name'), | ||
608 | # guarantor_2=applicant_data.get('guarantor2Name'), | ||
609 | document_name=document_name, | 580 | document_name=document_name, |
610 | document_scheme=document_scheme, | 581 | document_scheme=document_scheme, |
611 | data_source=data_source, | 582 | data_source=data_source, |
... | @@ -632,6 +603,22 @@ class UploadDocView(GenericView, DocHandler): | ... | @@ -632,6 +603,22 @@ class UploadDocView(GenericView, DocHandler): |
632 | self.running_log.info('[doc upload success] [args={0}] [business_type={1}] [doc_id={2}] ' | 603 | self.running_log.info('[doc upload success] [args={0}] [business_type={1}] [doc_id={2}] ' |
633 | '[is_priority={3}] [enqueue_res={4}]'.format(args, prefix, doc.id, | 604 | '[is_priority={3}] [enqueue_res={4}]'.format(args, prefix, doc.id, |
634 | is_priority, enqueue_res)) | 605 | is_priority, enqueue_res)) |
606 | |||
607 | try: | ||
608 | end_time = time.time() | ||
609 | duration_second = int(end_time - start_time) | ||
610 | InterfaceReport.objects.create( | ||
611 | source=data_source, | ||
612 | target=SystemName.OCR.name, | ||
613 | body=json.dumps(args), | ||
614 | response=None, | ||
615 | status=True, | ||
616 | # retry_times=None, | ||
617 | duration=duration_second, | ||
618 | ) | ||
619 | except Exception as e: | ||
620 | self.exception_log.exception('[upload view] [db save failed] [error={0}]'.format(traceback.format_exc())) | ||
621 | |||
635 | return response.ok() | 622 | return response.ok() |
636 | 623 | ||
637 | post.openapi_doc = ''' | 624 | post.openapi_doc = ''' |
... | @@ -660,7 +647,9 @@ class PriorityDocView(GenericView, DocHandler): | ... | @@ -660,7 +647,9 @@ class PriorityDocView(GenericView, DocHandler): |
660 | 647 | ||
661 | # 优先级订单接口 | 648 | # 优先级订单接口 |
662 | @use_args(priority_doc_args, location='data') | 649 | @use_args(priority_doc_args, location='data') |
663 | def post(self, request, args): | 650 | def post(self, request, args): # interface_report gcap to ocr |
651 | start_time = time.time() | ||
652 | |||
664 | application_info = args.get('APPLICATION_INFORMATION') | 653 | application_info = args.get('APPLICATION_INFORMATION') |
665 | application_id = application_info.get('APPLICATION_ID') | 654 | application_id = application_info.get('APPLICATION_ID') |
666 | submit_datetime = application_info.get('SUBMIT_DATETIME') | 655 | submit_datetime = application_info.get('SUBMIT_DATETIME') |
... | @@ -696,6 +685,22 @@ class PriorityDocView(GenericView, DocHandler): | ... | @@ -696,6 +685,22 @@ class PriorityDocView(GenericView, DocHandler): |
696 | enqueue_res = rh.enqueue(tasks_list, is_priority=True) # TODO 可能把压缩文件放入优先队列 | 685 | enqueue_res = rh.enqueue(tasks_list, is_priority=True) # TODO 可能把压缩文件放入优先队列 |
697 | self.running_log.info('[priority doc success] [args={0}] [tasks_list={1}] [enqueue_res={2}]'.format( | 686 | self.running_log.info('[priority doc success] [args={0}] [tasks_list={1}] [enqueue_res={2}]'.format( |
698 | args, tasks_list, enqueue_res)) | 687 | args, tasks_list, enqueue_res)) |
688 | |||
689 | try: | ||
690 | end_time = time.time() | ||
691 | duration_second = int(end_time - start_time) | ||
692 | InterfaceReport.objects.create( | ||
693 | source=SystemName.GCAP.name, | ||
694 | target=SystemName.OCR.name, | ||
695 | body=json.dumps(args), | ||
696 | response=None, | ||
697 | status=True, | ||
698 | # retry_times=None, | ||
699 | duration=duration_second, | ||
700 | ) | ||
701 | except Exception as e: | ||
702 | self.exception_log.exception('[gcap view] [db save failed] [error={0}]'.format(traceback.format_exc())) | ||
703 | |||
699 | return response.ok() | 704 | return response.ok() |
700 | 705 | ||
701 | post.openapi_doc = ''' | 706 | post.openapi_doc = ''' |
... | @@ -724,7 +729,9 @@ class CompareView(GenericView): | ... | @@ -724,7 +729,9 @@ class CompareView(GenericView): |
724 | 729 | ||
725 | # pos上传比对信息接口 CA | 730 | # pos上传比对信息接口 CA |
726 | @use_args(compare_args, location='data') | 731 | @use_args(compare_args, location='data') |
727 | def post(self, request, args): | 732 | def post(self, request, args): # interface_report pos to ocr |
733 | start_time = time.time() | ||
734 | |||
728 | # 存库 | 735 | # 存库 |
729 | content = args.get('content', {}) | 736 | content = args.get('content', {}) |
730 | uniq_seq = content.get('uniqSeq') | 737 | uniq_seq = content.get('uniqSeq') |
... | @@ -748,6 +755,22 @@ class CompareView(GenericView): | ... | @@ -748,6 +755,22 @@ class CompareView(GenericView): |
748 | # 触发比对 | 755 | # 触发比对 |
749 | compare.apply_async((application_id, business_type, uniq_seq, None, True, False), | 756 | compare.apply_async((application_id, business_type, uniq_seq, None, True, False), |
750 | queue='queue_compare') | 757 | queue='queue_compare') |
758 | |||
759 | try: | ||
760 | end_time = time.time() | ||
761 | duration_second = int(end_time - start_time) | ||
762 | InterfaceReport.objects.create( | ||
763 | source=SystemName.POS.name, | ||
764 | target=SystemName.OCR.name, | ||
765 | body=json.dumps(args), | ||
766 | response=None, | ||
767 | status=True, | ||
768 | # retry_times=None, | ||
769 | duration=duration_second, | ||
770 | ) | ||
771 | except Exception as e: | ||
772 | self.exception_log.exception('[pos ca view] [db save failed] [error={0}]'.format(traceback.format_exc())) | ||
773 | |||
751 | return response.ok() | 774 | return response.ok() |
752 | 775 | ||
753 | post.openapi_doc = ''' | 776 | post.openapi_doc = ''' |
... | @@ -776,9 +799,10 @@ class SECompareView(GenericView, PreSEHandler): | ... | @@ -776,9 +799,10 @@ class SECompareView(GenericView, PreSEHandler): |
776 | 799 | ||
777 | # SE preSettlement | 800 | # SE preSettlement |
778 | @use_args(se_compare_args, location='data') | 801 | @use_args(se_compare_args, location='data') |
779 | def post(self, request, args): | 802 | def post(self, request, args): # interface_report pos to ocr |
803 | start_time = time.time() | ||
780 | log_base = '[prese]' | 804 | log_base = '[prese]' |
781 | 805 | # 存库 | |
782 | content = args.get('content', {}) | 806 | content = args.get('content', {}) |
783 | business_type = content.get('applicationEntity') | 807 | business_type = content.get('applicationEntity') |
784 | application_id = content.get('applicationId') | 808 | application_id = content.get('applicationId') |
... | @@ -810,6 +834,21 @@ class SECompareView(GenericView, PreSEHandler): | ... | @@ -810,6 +834,21 @@ class SECompareView(GenericView, PreSEHandler): |
810 | self.running_log.info('{0} [prese completed] [applicationEntity={1}] [application_id={2}] [uniq_seq={3}] ' | 834 | self.running_log.info('{0} [prese completed] [applicationEntity={1}] [application_id={2}] [uniq_seq={3}] ' |
811 | '[result={4}]'.format(log_base, business_type, application_id, uniq_seq, compare_result)) | 835 | '[result={4}]'.format(log_base, business_type, application_id, uniq_seq, compare_result)) |
812 | 836 | ||
837 | try: | ||
838 | end_time = time.time() | ||
839 | duration_second = int(end_time - start_time) | ||
840 | InterfaceReport.objects.create( | ||
841 | source=SystemName.POS.name, | ||
842 | target=SystemName.OCR.name, | ||
843 | body=json.dumps(args), | ||
844 | response=json.dumps(compare_result), | ||
845 | status=True, | ||
846 | # retry_times=None, | ||
847 | duration=duration_second, | ||
848 | ) | ||
849 | except Exception as e: | ||
850 | self.exception_log.exception('[pos pre view] [db save failed] [error={0}]'.format(traceback.format_exc())) | ||
851 | |||
813 | return response.ok(data=compare_result) | 852 | return response.ok(data=compare_result) |
814 | 853 | ||
815 | post.openapi_doc = ''' | 854 | post.openapi_doc = ''' |
... | @@ -1263,7 +1302,9 @@ class SECMSView(GenericView): | ... | @@ -1263,7 +1302,9 @@ class SECMSView(GenericView): |
1263 | 1302 | ||
1264 | # CMS上传比对信息接口 SE | 1303 | # CMS上传比对信息接口 SE |
1265 | # @use_args(se_cms_args, location='data') | 1304 | # @use_args(se_cms_args, location='data') |
1266 | def post(self, request): | 1305 | def post(self, request): # interface_report cms to ocr |
1306 | start_time = time.time() | ||
1307 | |||
1267 | args = request.data | 1308 | args = request.data |
1268 | cms_info = args.get('content', {}) | 1309 | cms_info = args.get('content', {}) |
1269 | business_type = consts.AFC_PREFIX if cms_info.get('financeCompany', '').startswith('宝马') else consts.HIL_PREFIX | 1310 | business_type = consts.AFC_PREFIX if cms_info.get('financeCompany', '').startswith('宝马') else consts.HIL_PREFIX |
... | @@ -1305,6 +1346,21 @@ class SECMSView(GenericView): | ... | @@ -1305,6 +1346,21 @@ class SECMSView(GenericView): |
1305 | compare.apply_async((application_id, business_type, None, None, False, True), | 1346 | compare.apply_async((application_id, business_type, None, None, False, True), |
1306 | queue='queue_compare') | 1347 | queue='queue_compare') |
1307 | 1348 | ||
1349 | try: | ||
1350 | end_time = time.time() | ||
1351 | duration_second = int(end_time - start_time) | ||
1352 | InterfaceReport.objects.create( | ||
1353 | source=SystemName.CMS.name, | ||
1354 | target=SystemName.OCR.name, | ||
1355 | body=json.dumps(args), | ||
1356 | response=None, | ||
1357 | status=True, | ||
1358 | # retry_times=None, | ||
1359 | duration=duration_second, | ||
1360 | ) | ||
1361 | except Exception as e: | ||
1362 | self.exception_log.exception('[cms view] [db save failed] [error={0}]'.format(traceback.format_exc())) | ||
1363 | |||
1308 | return response.ok() | 1364 | return response.ok() |
1309 | 1365 | ||
1310 | post.openapi_doc = ''' | 1366 | post.openapi_doc = ''' |
... | @@ -1497,7 +1553,7 @@ class MPOSView(GenericView, MPOSHandler): | ... | @@ -1497,7 +1553,7 @@ class MPOSView(GenericView, MPOSHandler): |
1497 | 1553 | ||
1498 | # MPOS | 1554 | # MPOS |
1499 | @use_args(mpos_args, location='data') | 1555 | @use_args(mpos_args, location='data') |
1500 | def post(self, request, args): | 1556 | def post(self, request, args): # interface_report mpos to ocr |
1501 | start_time = time.time() | 1557 | start_time = time.time() |
1502 | 1558 | ||
1503 | classify = args.get('type') | 1559 | classify = args.get('type') |
... | @@ -1530,6 +1586,19 @@ class MPOSView(GenericView, MPOSHandler): | ... | @@ -1530,6 +1586,19 @@ class MPOSView(GenericView, MPOSHandler): |
1530 | except Exception as e: | 1586 | except Exception as e: |
1531 | self.exception_log.exception('[mpos view] [db save failed] [error={0}]'.format(traceback.format_exc())) | 1587 | self.exception_log.exception('[mpos view] [db save failed] [error={0}]'.format(traceback.format_exc())) |
1532 | 1588 | ||
1589 | try: | ||
1590 | InterfaceReport.objects.create( | ||
1591 | source=SystemName.MPOS.name, | ||
1592 | target=SystemName.OCR.name, | ||
1593 | body=None, | ||
1594 | response=json.dumps(result_list), | ||
1595 | status=True, | ||
1596 | # retry_times=None, | ||
1597 | duration=duration_second, | ||
1598 | ) | ||
1599 | except Exception as e: | ||
1600 | self.exception_log.exception('[go view] [db save failed] [error={0}]'.format(traceback.format_exc())) | ||
1601 | |||
1533 | return response.ok(data=result_list) | 1602 | return response.ok(data=result_list) |
1534 | 1603 | ||
1535 | 1604 | ||
... | @@ -1538,7 +1607,7 @@ class GoView(GenericView): | ... | @@ -1538,7 +1607,7 @@ class GoView(GenericView): |
1538 | authentication_classes = [OAuth2AuthenticationWithUser] | 1607 | authentication_classes = [OAuth2AuthenticationWithUser] |
1539 | 1608 | ||
1540 | @use_args(go_args, location='files') | 1609 | @use_args(go_args, location='files') |
1541 | def post(self, request, args): | 1610 | def post(self, request, args): # interface_report unknown to ocr |
1542 | result = None | 1611 | result = None |
1543 | is_success = False | 1612 | is_success = False |
1544 | start_time = time.time() | 1613 | start_time = time.time() |
... | @@ -1566,6 +1635,19 @@ class GoView(GenericView): | ... | @@ -1566,6 +1635,19 @@ class GoView(GenericView): |
1566 | except Exception as e: | 1635 | except Exception as e: |
1567 | self.exception_log.exception('[go view] [db save failed] [error={0}]'.format(traceback.format_exc())) | 1636 | self.exception_log.exception('[go view] [db save failed] [error={0}]'.format(traceback.format_exc())) |
1568 | 1637 | ||
1638 | try: | ||
1639 | InterfaceReport.objects.create( | ||
1640 | source=SystemName.UNKNOWN.name, | ||
1641 | target=SystemName.OCR.name, | ||
1642 | body=None, | ||
1643 | response=json.dumps(result) if is_success else None, | ||
1644 | status=is_success, | ||
1645 | # retry_times=None, | ||
1646 | duration=duration_second, | ||
1647 | ) | ||
1648 | except Exception as e: | ||
1649 | self.exception_log.exception('[go view] [db save failed] [error={0}]'.format(traceback.format_exc())) | ||
1650 | |||
1569 | if is_success: | 1651 | if is_success: |
1570 | return response.ok(data=result) | 1652 | return response.ok(data=result) |
1571 | else: | 1653 | else: | ... | ... |
... | @@ -31,12 +31,13 @@ from apps.doc.models import ( | ... | @@ -31,12 +31,13 @@ from apps.doc.models import ( |
31 | AFCAutoSettlement, | 31 | AFCAutoSettlement, |
32 | HILbankVerification, | 32 | HILbankVerification, |
33 | AFCbankVerification, | 33 | AFCbankVerification, |
34 | InterfaceReport, | ||
34 | ) | 35 | ) |
35 | from apps.doc import consts | 36 | from apps.doc import consts |
36 | from apps.doc.ocr.gcap import gcap | 37 | from apps.doc.ocr.gcap import gcap |
37 | from apps.doc.ocr.cms import cms | 38 | from apps.doc.ocr.cms import cms |
38 | from apps.doc.exceptions import GCAPException | 39 | from apps.doc.exceptions import GCAPException |
39 | from apps.doc.named_enum import RequestTeam, RequestTrigger, ProcessName, ErrorType | 40 | from apps.doc.named_enum import RequestTeam, RequestTrigger, ProcessName, ErrorType, SystemName |
40 | from common.tools.comparison import cp | 41 | from common.tools.comparison import cp |
41 | from common.tools.des import decode_des | 42 | from common.tools.des import decode_des |
42 | 43 | ||
... | @@ -748,16 +749,20 @@ def ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res | ... | @@ -748,16 +749,20 @@ def ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res |
748 | time.sleep(5) | 749 | time.sleep(5) |
749 | 750 | ||
750 | # 将比对结果发送GCAP | 751 | # 将比对结果发送GCAP |
752 | start_time = time.time() | ||
751 | try: | 753 | try: |
752 | data = gcap.dict_to_xml(comparison_res) | 754 | data = gcap.dict_to_xml(comparison_res) |
753 | except Exception as e: | 755 | except Exception as e: |
754 | compare_log.error('{0} [CA] [dict to xml failed] [entity={1}] [id={2}] [ocr_res_id={3}] [error={4}]'.format( | 756 | compare_log.error('{0} [CA] [dict to xml failed] [entity={1}] [id={2}] [ocr_res_id={3}] [error={4}]'.format( |
755 | log_base, application_entity, application_id, ocr_res_id, traceback.format_exc())) | 757 | log_base, application_entity, application_id, ocr_res_id, traceback.format_exc())) |
756 | else: | 758 | else: |
759 | final_times = 0 | ||
760 | is_success = True | ||
757 | try: | 761 | try: |
758 | for times in range(consts.RETRY_TIMES): | 762 | for times in range(consts.RETRY_TIMES): |
763 | final_times = times | ||
759 | try: | 764 | try: |
760 | res_text = gcap.send(data) | 765 | res_text = gcap.send(data) # interface_report ocr to gcap |
761 | except Exception as e: | 766 | except Exception as e: |
762 | gcap_exc = str(e) | 767 | gcap_exc = str(e) |
763 | else: | 768 | else: |
... | @@ -765,6 +770,7 @@ def ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res | ... | @@ -765,6 +770,7 @@ def ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res |
765 | else: | 770 | else: |
766 | raise GCAPException(gcap_exc) | 771 | raise GCAPException(gcap_exc) |
767 | except Exception as e: | 772 | except Exception as e: |
773 | is_success = False | ||
768 | compare_log.error('{0} [CA] [gcap failed] [entity={1}] [id={2}] [ocr_res_id={3}] [error={4}]'.format( | 774 | compare_log.error('{0} [CA] [gcap failed] [entity={1}] [id={2}] [ocr_res_id={3}] [error={4}]'.format( |
769 | log_base, application_entity, application_id, ocr_res_id, traceback.format_exc())) | 775 | log_base, application_entity, application_id, ocr_res_id, traceback.format_exc())) |
770 | else: | 776 | else: |
... | @@ -772,6 +778,21 @@ def ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res | ... | @@ -772,6 +778,21 @@ def ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res |
772 | log_base, application_entity, application_id, ocr_res_id, res_text)) | 778 | log_base, application_entity, application_id, ocr_res_id, res_text)) |
773 | compare_log.info('{0} [CA] [task success] [entity={1}] [id={2}] [ocr_res_id={3}]'.format( | 779 | compare_log.info('{0} [CA] [task success] [entity={1}] [id={2}] [ocr_res_id={3}]'.format( |
774 | log_base, application_entity, application_id, ocr_res_id)) | 780 | log_base, application_entity, application_id, ocr_res_id)) |
781 | finally: | ||
782 | end_time = time.time() | ||
783 | duration_second = int(end_time - start_time) | ||
784 | try: | ||
785 | InterfaceReport.objects.create( | ||
786 | source=SystemName.OCR.name, | ||
787 | target=SystemName.GCAP.name, | ||
788 | body=data, | ||
789 | response=res_text if is_success else None, | ||
790 | status=is_success, | ||
791 | retry_times=final_times, | ||
792 | duration=duration_second, | ||
793 | ) | ||
794 | except Exception as e: | ||
795 | compare_log.error('{0} [CA] [db save failed] [error={1}]'.format(log_base, traceback.format_exc())) | ||
775 | 796 | ||
776 | # report | 797 | # report |
777 | try: | 798 | try: |
... | @@ -3087,24 +3108,28 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res | ... | @@ -3087,24 +3108,28 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res |
3087 | compare_log.info('{0} [SE] [cms closed] [entity={1}] [id={2}] [ocr_res_id={3}]'.format( | 3108 | compare_log.info('{0} [SE] [cms closed] [entity={1}] [id={2}] [ocr_res_id={3}]'.format( |
3088 | log_base, application_entity, application_id, ocr_res_id)) | 3109 | log_base, application_entity, application_id, ocr_res_id)) |
3089 | return successful_at_this_level | 3110 | return successful_at_this_level |
3090 | try: | 3111 | |
3091 | application_link = '{0}/showList/showList?entity={1}&scheme={2}&case_id={3}'.format( | 3112 | is_success = True |
3092 | conf.BASE_URL, application_entity, consts.COMPARE_DOC_SCHEME_LIST[1], application_id) | 3113 | start_time = time.time() |
3093 | data = { | 3114 | application_link = '{0}/showList/showList?entity={1}&scheme={2}&case_id={3}'.format( |
3094 | "SubtenantId": consts.TENANT_MAP[application_entity], | 3115 | conf.BASE_URL, application_entity, consts.COMPARE_DOC_SCHEME_LIST[1], application_id) |
3095 | "Data": { | 3116 | data = { |
3096 | "Result_Message": "Pass" if successful_at_this_level else "Fail", | 3117 | "SubtenantId": consts.TENANT_MAP[application_entity], |
3097 | "AutoCheckResult": "Pass" if auto_result else "Fail", | 3118 | "Data": { |
3098 | "Failure_Reason": cn_failure_reason_str, | 3119 | "Result_Message": "Pass" if successful_at_this_level else "Fail", |
3099 | "Application_Number": application_id, | 3120 | "AutoCheckResult": "Pass" if auto_result else "Fail", |
3100 | "Bank_Statement": bs_failure_reason_str, | 3121 | "Failure_Reason": cn_failure_reason_str, |
3101 | "Link_URL": application_link, | 3122 | "Application_Number": application_id, |
3102 | "OCR_Version": 1, | 3123 | "Bank_Statement": bs_failure_reason_str, |
3103 | "Origin": consts.INFO_SOURCE[1] | 3124 | "Link_URL": application_link, |
3104 | } | 3125 | "OCR_Version": 1, |
3126 | "Origin": consts.INFO_SOURCE[1] | ||
3105 | } | 3127 | } |
3106 | response = cms.send(data) | 3128 | } |
3129 | try: | ||
3130 | response = cms.send(data) # interface_report ocr to cms | ||
3107 | except Exception as e: | 3131 | except Exception as e: |
3132 | is_success = False | ||
3108 | compare_log.error('{0} [SE] [cms error] [entity={1}] [id={2}] [ocr_res_id={3}] ' | 3133 | compare_log.error('{0} [SE] [cms error] [entity={1}] [id={2}] [ocr_res_id={3}] ' |
3109 | '[error={4}]'.format(log_base, application_entity, application_id, ocr_res_id, | 3134 | '[error={4}]'.format(log_base, application_entity, application_id, ocr_res_id, |
3110 | traceback.format_exc())) | 3135 | traceback.format_exc())) |
... | @@ -3112,6 +3137,21 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res | ... | @@ -3112,6 +3137,21 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res |
3112 | compare_log.info('{0} [SE] [cms success] [entity={1}] [id={2}] [ocr_res_id={3}] [data={4}] ' | 3137 | compare_log.info('{0} [SE] [cms success] [entity={1}] [id={2}] [ocr_res_id={3}] [data={4}] ' |
3113 | '[response={5}]'.format(log_base, application_entity, application_id, ocr_res_id, | 3138 | '[response={5}]'.format(log_base, application_entity, application_id, ocr_res_id, |
3114 | data, response)) | 3139 | data, response)) |
3140 | finally: | ||
3141 | end_time = time.time() | ||
3142 | duration_second = int(end_time - start_time) | ||
3143 | try: | ||
3144 | InterfaceReport.objects.create( | ||
3145 | source=SystemName.OCR.name, | ||
3146 | target=SystemName.CMS.name, | ||
3147 | body=json.dumps(data), | ||
3148 | response=json.dumps(response) if is_success else None, | ||
3149 | status=is_success, | ||
3150 | # retry_times=None, | ||
3151 | duration=duration_second, | ||
3152 | ) | ||
3153 | except Exception as e: | ||
3154 | compare_log.error('{0} [SE] [db save failed] [error={1}]'.format(log_base, traceback.format_exc())) | ||
3115 | 3155 | ||
3116 | return successful_at_this_level | 3156 | return successful_at_this_level |
3117 | 3157 | ... | ... |
src/common/tools/mssql_script21.py
0 → 100644
1 | import pyodbc | ||
2 | |||
3 | hil_sql = """ | ||
4 | create table interface_report | ||
5 | ( | ||
6 | id bigint identity primary key, | ||
7 | source nvarchar(64) not null, | ||
8 | target nvarchar(64) not null, | ||
9 | body nvarchar(max), | ||
10 | response nvarchar(max), | ||
11 | status bit default 1 not null, | ||
12 | retry_times tinyint default 0 not null, | ||
13 | duration smallint not null, | ||
14 | create_time datetime not null | ||
15 | ); | ||
16 | """ | ||
17 | |||
18 | afc_sql = """ | ||
19 | |||
20 | """ | ||
21 | |||
22 | hil_cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};', autocommit=True) | ||
23 | |||
24 | hil_cursor = hil_cnxn.cursor() | ||
25 | hil_cursor.execute(hil_sql) | ||
26 | |||
27 | hil_cursor.close() | ||
28 | hil_cnxn.close() | ||
29 | |||
30 | afc_cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};', autocommit=True) | ||
31 | |||
32 | afc_cursor = afc_cnxn.cursor() | ||
33 | afc_cursor.execute(afc_sql) | ||
34 | |||
35 | afc_cursor.close() | ||
36 | afc_cnxn.close() |
-
Please register or sign in to post a comment