add auto settlement
Showing
5 changed files
with
760 additions
and
66 deletions
... | @@ -1477,6 +1477,9 @@ SE_HIL_CON_1_MAP = { | ... | @@ -1477,6 +1477,9 @@ SE_HIL_CON_1_MAP = { |
1477 | '融资成本总额': (5, 4, 7, '融资成本总额', None), | 1477 | '融资成本总额': (5, 4, 7, '融资成本总额', None), |
1478 | '租期': (5, 4, 7, '租期', None), | 1478 | '租期': (5, 4, 7, '租期', None), |
1479 | '还款计划表': (5, 5, 7, '付款计划表', None), | 1479 | '还款计划表': (5, 5, 7, '付款计划表', None), |
1480 | '还款账号': (5, 5, 7, '银行账户-银行账号', None), | ||
1481 | '户名': (5, 5, 7, '银行账户-户名', None), | ||
1482 | '开户行': (5, 5, 7, '银行账户-开户行', None), | ||
1480 | 'ASP项目详情': (5, 4, 7, '车辆附加产品明细表', None), | 1483 | 'ASP项目详情': (5, 4, 7, '车辆附加产品明细表', None), |
1481 | '承租人法定代表人或授权代表': (1, 1, 7, '承租人-法定代表人或授权代表', None), | 1484 | '承租人法定代表人或授权代表': (1, 1, 7, '承租人-法定代表人或授权代表', None), |
1482 | 1485 | ||
... | @@ -1532,11 +1535,11 @@ SE_AFC_CON_FIELD = ['-瘥△', '韐剛膠颲遠-撠- | ... | @@ -1532,11 +1535,11 @@ SE_AFC_CON_FIELD = ['-瘥△', '韐剛膠颲遠-撠- |
1532 | '车辆贷款本金金额-重要条款', '附加产品融资贷款本金总额-重要条款', '所购车辆价格', '车架号', '经销商', | 1535 | '车辆贷款本金金额-重要条款', '附加产品融资贷款本金总额-重要条款', '所购车辆价格', '车架号', '经销商', |
1533 | '贷款本金金额', '车辆贷款本金金额', '附加产品融资贷款本金总额', '贷款期限', '还款账号', '户名', '开户行', | 1536 | '贷款本金金额', '车辆贷款本金金额', '附加产品融资贷款本金总额', '贷款期限', '还款账号', '户名', '开户行', |
1534 | '还款计划表', '见证人签字', '见证人日期', 'ASP项目详情-重要条款', '购置税校验', 'ASP项目详情'] | 1537 | '还款计划表', '见证人签字', '见证人日期', 'ASP项目详情-重要条款', '购置税校验', 'ASP项目详情'] |
1535 | AFC_CON_BANK_FIELD = ['还款账号', '户名', '开户行'] | 1538 | CON_BANK_FIELD = ['还款账号', '户名', '开户行'] |
1536 | 1539 | ||
1537 | # '承租人姓名', '承租人证件号码', '承租人法定代表人或授权代表' | 1540 | # '承租人姓名', '承租人证件号码', '承租人法定代表人或授权代表' |
1538 | SE_HIL_CON_1_FIELD = ['合同编号-每页', '合同编号-正文', '车辆识别代码', '车辆卖方', '车辆原始销售价格', '融资成本总额', '租期', | 1541 | SE_HIL_CON_1_FIELD = ['合同编号-每页', '合同编号-正文', '车辆识别代码', '车辆卖方', '车辆原始销售价格', '融资成本总额', '租期', |
1539 | '还款计划表', 'ASP项目详情', '购置税校验', '承租人法定代表人或授权代表'] | 1542 | '还款计划表', 'ASP项目详情', '购置税校验', '承租人法定代表人或授权代表', '还款账号', '户名', '开户行'] |
1540 | SE_HIL_CON_2_FIELD = ['合同编号', '合同编号-正文', '车辆识别代码', '租金总额', '融资租赁期限'] | 1543 | SE_HIL_CON_2_FIELD = ['合同编号', '合同编号-正文', '车辆识别代码', '租金总额', '融资租赁期限'] |
1541 | SE_HIL_CON_3_FIELD = ['合同编号-每页', '承租人姓名', '承租人证件号码', '销售经销商', '合同编号-正文', '姓名/名称', | 1544 | SE_HIL_CON_3_FIELD = ['合同编号-每页', '承租人姓名', '承租人证件号码', '销售经销商', '合同编号-正文', '姓名/名称', |
1542 | '自然人身份证件号码/法人执照号码', '承租人签字'] | 1545 | '自然人身份证件号码/法人执照号码', '承租人签字'] |
... | @@ -1820,6 +1823,9 @@ HIL_CONTRACT_1_COMPARE_LOGIC = { | ... | @@ -1820,6 +1823,9 @@ HIL_CONTRACT_1_COMPARE_LOGIC = { |
1820 | '还款计划表': ('还款计划表', 'se_schedule_compare', {"value_idx": 1}, '售后回租合同还款计划表与系统不一致'), | 1823 | '还款计划表': ('还款计划表', 'se_schedule_compare', {"value_idx": 1}, '售后回租合同还款计划表与系统不一致'), |
1821 | 'ASP项目详情': ('ASP项目详情', 'se_asp_compare', {}, '售后回租合同ASP名称或者金额与系统不一致'), | 1824 | 'ASP项目详情': ('ASP项目详情', 'se_asp_compare', {}, '售后回租合同ASP名称或者金额与系统不一致'), |
1822 | '承租人法定代表人或授权代表': ('承租人法定代表人或授权代表', 'se_name_compare', {}, '售后回租合同承租人法定代表人或授权代表与系统不一致'), | 1825 | '承租人法定代表人或授权代表': ('承租人法定代表人或授权代表', 'se_name_compare', {}, '售后回租合同承租人法定代表人或授权代表与系统不一致'), |
1826 | '还款账号': ('还款账号', 'se_common_compare', {'remove_space': True}, '售后回租合同还款账号与系统不一致'), | ||
1827 | '户名': ('户名', 'se_common_compare', {}, '售后回租合同户名与系统不一致'), | ||
1828 | '开户行': ('开户行', 'se_both_contain_compare', {}, '售后回租合同开户行与系统不一致'), | ||
1823 | 1829 | ||
1824 | '承租人姓名': ('承租人姓名', 'se_name_compare', {}, '售后回租合同承租人姓名与系统不一致'), | 1830 | '承租人姓名': ('承租人姓名', 'se_name_compare', {}, '售后回租合同承租人姓名与系统不一致'), |
1825 | '承租人证件号': ('承租人证件号', 'se_common_compare', {}, '售后回租合同承租人证件号与系统不一致'), | 1831 | '承租人证件号': ('承租人证件号', 'se_common_compare', {}, '售后回租合同承租人证件号与系统不一致'), | ... | ... |
... | @@ -806,31 +806,69 @@ class HILCACompareResultRecord(models.Model): | ... | @@ -806,31 +806,69 @@ class HILCACompareResultRecord(models.Model): |
806 | reason10_count = models.SmallIntegerField(default=0, verbose_name="原因10数目") | 806 | reason10_count = models.SmallIntegerField(default=0, verbose_name="原因10数目") |
807 | result = models.TextField(null=True, verbose_name="比对结果") | 807 | result = models.TextField(null=True, verbose_name="比对结果") |
808 | comments = models.TextField(null=True, verbose_name="备注") | 808 | comments = models.TextField(null=True, verbose_name="备注") |
809 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') # 索引 | 809 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') # 索引 |
810 | 810 | ||
811 | class Meta: | 811 | class Meta: |
812 | managed = False | 812 | managed = False |
813 | db_table = 'hil_ca_compare_result_record' | 813 | db_table = 'hil_ca_compare_result_record' |
814 | 814 | ||
815 | 815 | ||
816 | # class HILContract(models.Model): | 816 | class HILAutoSettlement(models.Model): |
817 | # id = models.AutoField(primary_key=True, verbose_name="id") # 主键 | 817 | id = models.AutoField(primary_key=True, verbose_name="id") # 主键 |
818 | # application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引 | 818 | application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引 |
819 | # create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | 819 | aa_type = models.CharField(null=True, max_length=64, verbose_name="aa_type") |
820 | |||
821 | rpa_result = models.SmallIntegerField(null=True, verbose_name="原因10数目") | ||
822 | rpa_1st_eye_tat = models.DecimalField(null=True, verbose_name='rpa_1st_eye_tat') | ||
823 | rpa_2nd_eye_tat = models.DecimalField(null=True, verbose_name='rpa_2nd_eye_tat') | ||
824 | rpa_3rd_eye_tat = models.DecimalField(null=True, verbose_name='rpa_3rd_eye_tat') | ||
825 | rpa_total_tat = models.DecimalField(null=True, verbose_name='rpa_total_tat') | ||
826 | rpa_activated_time = models.DateTimeField(null=True, verbose_name='rpa_activated_time') | ||
827 | rpa_get_case_from_ocr_time = models.DateTimeField(null=True, verbose_name='rpa_get_case_from_ocr_time') | ||
828 | rpa_get_case_from_oc_time = models.DateTimeField(null=True, verbose_name='rpa_get_case_from_oc_time') | ||
829 | rpa_payment_authorize_time = models.DateTimeField(null=True, verbose_name='rpa_payment_authorize_time') | ||
830 | rpa_second_eye_time = models.DateTimeField(null=True, verbose_name='rpa_second_eye_time') | ||
831 | |||
832 | on_off = models.BooleanField(default=True, verbose_name="是否有效") | ||
833 | ocr_auto_result_pass = models.BooleanField(default=False, verbose_name="整体结果") | ||
834 | ocr_auto_result = models.TextField(null=True, verbose_name="auto比对结果") | ||
835 | ocr_latest_comparison_time = models.DateTimeField(auto_now=True, null=True, verbose_name='最新比对时间') | ||
820 | 836 | ||
821 | # class Meta: | 837 | update_time = models.DateTimeField(auto_now=False, verbose_name='修改时间') |
822 | # managed = False | 838 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') |
823 | # db_table = 'hil_contract' | ||
824 | 839 | ||
840 | class Meta: | ||
841 | managed = False | ||
842 | db_table = 'hil_auto_settlement' | ||
825 | 843 | ||
826 | # class AFCContract(models.Model): | ||
827 | # id = models.AutoField(primary_key=True, verbose_name="id") # 主键 | ||
828 | # application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引 | ||
829 | # create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | ||
830 | 844 | ||
831 | # class Meta: | 845 | class AFCAutoSettlement(models.Model): |
832 | # managed = False | 846 | id = models.AutoField(primary_key=True, verbose_name="id") # 主键 |
833 | # db_table = 'afc_contract' | 847 | application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引 |
834 | # situ_db_label = 'afc' | 848 | aa_type = models.CharField(null=True, max_length=64, verbose_name="aa_type") |
849 | |||
850 | rpa_result = models.SmallIntegerField(null=True, verbose_name="原因10数目") | ||
851 | rpa_1st_eye_tat = models.DecimalField(null=True, verbose_name='rpa_1st_eye_tat') | ||
852 | rpa_2nd_eye_tat = models.DecimalField(null=True, verbose_name='rpa_2nd_eye_tat') | ||
853 | rpa_3rd_eye_tat = models.DecimalField(null=True, verbose_name='rpa_3rd_eye_tat') | ||
854 | rpa_total_tat = models.DecimalField(null=True, verbose_name='rpa_total_tat') | ||
855 | rpa_activated_time = models.DateTimeField(null=True, verbose_name='rpa_activated_time') | ||
856 | rpa_get_case_from_ocr_time = models.DateTimeField(null=True, verbose_name='rpa_get_case_from_ocr_time') | ||
857 | rpa_get_case_from_oc_time = models.DateTimeField(null=True, verbose_name='rpa_get_case_from_oc_time') | ||
858 | rpa_payment_authorize_time = models.DateTimeField(null=True, verbose_name='rpa_payment_authorize_time') | ||
859 | rpa_second_eye_time = models.DateTimeField(null=True, verbose_name='rpa_second_eye_time') | ||
860 | |||
861 | on_off = models.BooleanField(default=True, verbose_name="是否有效") | ||
862 | ocr_auto_result_pass = models.BooleanField(default=False, verbose_name="整体结果") | ||
863 | ocr_auto_result = models.TextField(verbose_name="auto比对结果") | ||
864 | ocr_latest_comparison_time = models.DateTimeField(auto_now=True, null=True, verbose_name='最新比对时间') | ||
865 | |||
866 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') | ||
867 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | ||
868 | |||
869 | class Meta: | ||
870 | managed = False | ||
871 | db_table = 'afc_auto_settlement' | ||
872 | situ_db_label = 'afc' | ||
835 | 873 | ||
836 | 874 | ... | ... |
... | @@ -6,7 +6,7 @@ import datetime | ... | @@ -6,7 +6,7 @@ import datetime |
6 | import fitz | 6 | import fitz |
7 | import shutil | 7 | import shutil |
8 | from django.utils import timezone | 8 | from django.utils import timezone |
9 | from django.http import HttpResponse | 9 | # from django.http import HttpResponse |
10 | from django.db.models import Q | 10 | from django.db.models import Q |
11 | from rest_framework.permissions import IsAuthenticated | 11 | from rest_framework.permissions import IsAuthenticated |
12 | from webargs import fields, validate | 12 | from webargs import fields, validate |
... | @@ -17,14 +17,15 @@ from common.mixins import GenericView | ... | @@ -17,14 +17,15 @@ from common.mixins import GenericView |
17 | from common.tools.file_tools import file_write | 17 | from common.tools.file_tools import file_write |
18 | from common.redis_cache import redis_handler as rh | 18 | from common.redis_cache import redis_handler as rh |
19 | from .models import ( | 19 | from .models import ( |
20 | # UploadDocRecords, | ||
20 | DocStatus, | 21 | DocStatus, |
21 | PriorityApplication, | 22 | PriorityApplication, |
22 | GCAPRecords, | 23 | GCAPRecords, |
23 | AFCComparisonInfo, | 24 | AFCComparisonInfo, |
24 | AFCSEComparisonInfo, | 25 | # AFCSEComparisonInfo, |
25 | AFCSECMSInfo, | 26 | AFCSECMSInfo, |
26 | HILComparisonInfo, | 27 | HILComparisonInfo, |
27 | HILSEComparisonInfo, | 28 | # HILSEComparisonInfo, |
28 | HILSECMSInfo, | 29 | HILSECMSInfo, |
29 | AFCCompareOfflineReport, | 30 | AFCCompareOfflineReport, |
30 | HILCompareOfflineReport, | 31 | HILCompareOfflineReport, |
... | @@ -36,6 +37,8 @@ from .models import ( | ... | @@ -36,6 +37,8 @@ from .models import ( |
36 | AFCSECompareResultRecord, | 37 | AFCSECompareResultRecord, |
37 | HILCACompareResultRecord, | 38 | HILCACompareResultRecord, |
38 | HILSECompareResultRecord, | 39 | HILSECompareResultRecord, |
40 | HILAutoSettlement, | ||
41 | AFCAutoSettlement, | ||
39 | ) | 42 | ) |
40 | from .named_enum import ErrorType | 43 | from .named_enum import ErrorType |
41 | from .mixins import DocHandler | 44 | from .mixins import DocHandler |
... | @@ -213,6 +216,7 @@ se_compare_content = { | ... | @@ -213,6 +216,7 @@ se_compare_content = { |
213 | 'customerType': fields.Str(required=True, validate=validate.OneOf(consts.CUSTOMER_TYPE)), | 216 | 'customerType': fields.Str(required=True, validate=validate.OneOf(consts.CUSTOMER_TYPE)), |
214 | "firstSubmmisonDate": CustomDate(required=True), | 217 | "firstSubmmisonDate": CustomDate(required=True), |
215 | 'propertyDocumentPolicy': fields.Str(required=False, validate=validate.Length(max=16)), | 218 | 'propertyDocumentPolicy': fields.Str(required=False, validate=validate.Length(max=16)), |
219 | 'isAutoSettlement': fields.Boolean(required=False), | ||
216 | 220 | ||
217 | 'individualCusInfo': fields.List(fields.Nested(se_individual_args), | 221 | 'individualCusInfo': fields.List(fields.Nested(se_individual_args), |
218 | required=True, validate=validate.Length(min=1, max=4)), | 222 | required=True, validate=validate.Length(min=1, max=4)), |
... | @@ -283,6 +287,7 @@ compare_result_args = { | ... | @@ -283,6 +287,7 @@ compare_result_args = { |
283 | 'scheme': fields.Str(required=True, validate=validate.OneOf(consts.COMPARE_DOC_SCHEME_LIST)), | 287 | 'scheme': fields.Str(required=True, validate=validate.OneOf(consts.COMPARE_DOC_SCHEME_LIST)), |
284 | 'id': fields.Int(required=False, validate=lambda val: val >= 1), | 288 | 'id': fields.Int(required=False, validate=lambda val: val >= 1), |
285 | 'case_id': fields.Str(required=True, validate=validate.Length(max=64)), | 289 | 'case_id': fields.Str(required=True, validate=validate.Length(max=64)), |
290 | 'auto': fields.Int(required=False), | ||
286 | } | 291 | } |
287 | 292 | ||
288 | upload_pdf_args = { | 293 | upload_pdf_args = { |
... | @@ -500,27 +505,29 @@ class UploadDocView(GenericView, DocHandler): | ... | @@ -500,27 +505,29 @@ class UploadDocView(GenericView, DocHandler): |
500 | # co_name = self.get_name(applicant_data, 'coApplicantName', 16) | 505 | # co_name = self.get_name(applicant_data, 'coApplicantName', 16) |
501 | # g1_name = self.get_name(applicant_data, 'guarantor1Name', 16) | 506 | # g1_name = self.get_name(applicant_data, 'guarantor1Name', 16) |
502 | # g2_name = self.get_name(applicant_data, 'guarantor2Name', 16) | 507 | # g2_name = self.get_name(applicant_data, 'guarantor2Name', 16) |
508 | |||
503 | # try: | 509 | # try: |
504 | # # 1. 上传信息记录 | 510 | # # 1. 上传信息记录 |
505 | # UploadDocRecords.objects.create( | 511 | # UploadDocRecords.objects.create( |
506 | # metadata_version_id=document.get('metadataVersionId'), | 512 | # metadata_version_id=document.get('metadataVersionId'), |
507 | # application_id=application_id, | 513 | # application_id=application_id, |
508 | # main_applicant=main_name, | 514 | # main_applicant='main_name', |
509 | # co_applicant=co_name, | 515 | # co_applicant='co_name', |
510 | # guarantor_1=g1_name, | 516 | # guarantor_1='g1_name', |
511 | # guarantor_2=g2_name, | 517 | # guarantor_2='g2_name', |
512 | # document_name=document_name, | 518 | # document_name=document_name, |
513 | # document_scheme=document_scheme, | 519 | # document_scheme=document_scheme, |
514 | # business_type=business_type, | 520 | # business_type=business_type, |
515 | # data_source=data_source, | 521 | # data_source=data_source, |
516 | # upload_finish_time=document.get('uploadFinishTime'), | 522 | # upload_finish_time=document.get('uploadFinishTime'), |
517 | # ) | 523 | # ) |
518 | # except IntegrityError as e: | 524 | # except Exception as e: |
519 | # self.running_log.info('[doc upload fail] [args={0}] [err={1}]'.format(args, e)) | 525 | # self.running_log.info('[doc upload success] [same file skip] [args={0}]'.format(args)) |
520 | # self.invalid_params(msg='metadataVersionId repeat') | 526 | # # self.invalid_params(msg='metadataVersionId repeat') |
521 | # else: | 527 | # return response.ok() |
528 | |||
522 | data_source = self.fix_data_source(data_source) | 529 | data_source = self.fix_data_source(data_source) |
523 | document_scheme=self.fix_scheme(document_scheme) | 530 | document_scheme = self.fix_scheme(document_scheme) |
524 | 531 | ||
525 | if document_name.endswith('.zip'): | 532 | if document_name.endswith('.zip'): |
526 | self.running_log.info('[doc upload success] [zip file skip] [args={0}]'.format(args)) | 533 | self.running_log.info('[doc upload success] [zip file skip] [args={0}]'.format(args)) |
... | @@ -531,6 +538,7 @@ class UploadDocView(GenericView, DocHandler): | ... | @@ -531,6 +538,7 @@ class UploadDocView(GenericView, DocHandler): |
531 | if document_name.endswith('-证书.pdf') or document_name.endswith('-证书'): | 538 | if document_name.endswith('-证书.pdf') or document_name.endswith('-证书'): |
532 | self.running_log.info('[doc upload success] [eapp license skip] [args={0}]'.format(args)) | 539 | self.running_log.info('[doc upload success] [eapp license skip] [args={0}]'.format(args)) |
533 | return response.ok() | 540 | return response.ok() |
541 | |||
534 | # 2. 根据业务类型分库存储 | 542 | # 2. 根据业务类型分库存储 |
535 | doc_class, prefix = self.get_doc_class(business_type) | 543 | doc_class, prefix = self.get_doc_class(business_type) |
536 | doc = doc_class.objects.create( | 544 | doc = doc_class.objects.create( |
... | @@ -707,37 +715,52 @@ class SECompareView(GenericView): | ... | @@ -707,37 +715,52 @@ class SECompareView(GenericView): |
707 | def post(self, request, args): | 715 | def post(self, request, args): |
708 | # 存库 | 716 | # 存库 |
709 | content = args.get('content', {}) | 717 | content = args.get('content', {}) |
710 | uniq_seq = content.get('uniqSeq') | ||
711 | business_type = content.get('applicationEntity') | 718 | business_type = content.get('applicationEntity') |
712 | application_id = content.get('applicationId') | 719 | application_id = content.get('applicationId') |
720 | is_auto = content.get('isAutoSettlement', False) | ||
721 | if is_auto: | ||
722 | # 加入优先级队列 | ||
723 | PriorityApplication.objects.update_or_create( | ||
724 | application_id=application_id, defaults={'on_off': True}) | ||
725 | # 加入auto表 | ||
726 | auto_class = HILAutoSettlement if business_type in consts.HIL_SET else AFCAutoSettlement | ||
727 | is_auto = auto_class.objects.filter(application_id=application_id, on_off=True).exists() | ||
728 | if not is_auto: | ||
729 | auto_class.objects.create( | ||
730 | application_id=application_id, | ||
731 | ) | ||
732 | return response.ok() | ||
713 | 733 | ||
714 | individual_cus_info = json.dumps(content.get('individualCusInfo')) | 734 | # uniq_seq = content.get('uniqSeq') |
715 | vehicle_info = json.dumps(content.get('vehicleInfo')) | 735 | # business_type = content.get('applicationEntity') |
716 | insurance_info = json.dumps(content.get('insuranceInfo')) | 736 | # application_id = content.get('applicationId') |
717 | bank_info = json.dumps(content.get('bankInfo')) | 737 | # |
718 | quotationt_info = json.dumps(content.get('quotationtInfo')) | 738 | # individual_cus_info = json.dumps(content.get('individualCusInfo')) |
719 | corporate_cus_info = json.dumps(content.get('corporateCusInfo')) if isinstance( | 739 | # vehicle_info = json.dumps(content.get('vehicleInfo')) |
720 | content.get('corporateCusInfo'), dict) else None | 740 | # insurance_info = json.dumps(content.get('insuranceInfo')) |
721 | 741 | # bank_info = json.dumps(content.get('bankInfo')) | |
722 | comparison_class = HILSEComparisonInfo if business_type in consts.HIL_SET else AFCSEComparisonInfo | 742 | # quotationt_info = json.dumps(content.get('quotationtInfo')) |
723 | comparison_class.objects.create( | 743 | # corporate_cus_info = json.dumps(content.get('corporateCusInfo')) if isinstance( |
724 | uniq_seq=uniq_seq, | 744 | # content.get('corporateCusInfo'), dict) else None |
725 | application_id=application_id, | 745 | |
726 | application_version=content.get('applicationVersion'), | 746 | # comparison_class = HILSEComparisonInfo if business_type in consts.HIL_SET else AFCSEComparisonInfo |
727 | customer_type=content.get('customerType'), | 747 | # comparison_class.objects.create( |
728 | first_submmison_date=content.get('firstSubmmisonDate'), | 748 | # uniq_seq=uniq_seq, |
729 | property_doc_policy=content.get('propertyDocumentPolicy', None), | 749 | # application_id=application_id, |
730 | individual_cus_info=individual_cus_info, | 750 | # application_version=content.get('applicationVersion'), |
731 | corporate_cus_info=corporate_cus_info, | 751 | # customer_type=content.get('customerType'), |
732 | vehicle_info=vehicle_info, | 752 | # first_submmison_date=content.get('firstSubmmisonDate'), |
733 | insurance_info=insurance_info, | 753 | # property_doc_policy=content.get('propertyDocumentPolicy', None), |
734 | bank_info=bank_info, | 754 | # individual_cus_info=individual_cus_info, |
735 | quotationt_info=quotationt_info | 755 | # corporate_cus_info=corporate_cus_info, |
736 | ) | 756 | # vehicle_info=vehicle_info, |
757 | # insurance_info=insurance_info, | ||
758 | # bank_info=bank_info, | ||
759 | # quotationt_info=quotationt_info | ||
760 | # ) | ||
737 | # 触发比对 | 761 | # 触发比对 |
738 | # compare.apply_async((application_id, business_type, uniq_seq, None, False, False), | 762 | # compare.apply_async((application_id, business_type, uniq_seq, None, False, False), |
739 | # queue='queue_compare') | 763 | # queue='queue_compare') |
740 | return response.ok() | ||
741 | 764 | ||
742 | post.openapi_doc = ''' | 765 | post.openapi_doc = ''' |
743 | tags: [info] | 766 | tags: [info] |
... | @@ -944,6 +967,38 @@ class CompareResultView(GenericView): | ... | @@ -944,6 +967,38 @@ class CompareResultView(GenericView): |
944 | entity = args.get('entity') | 967 | entity = args.get('entity') |
945 | scheme = args.get('scheme') | 968 | scheme = args.get('scheme') |
946 | case_id = args.get('case_id') | 969 | case_id = args.get('case_id') |
970 | is_auto = args.get('auto') | ||
971 | if is_auto == 1: | ||
972 | result_table = HILAutoSettlement if entity == consts.HIL_PREFIX else AFCAutoSettlement | ||
973 | |||
974 | if result_id is not None: | ||
975 | result_obj = result_table.objects.filter(id=result_id).first() | ||
976 | else: | ||
977 | result_obj = result_table.objects.filter(application_id=case_id).first() | ||
978 | |||
979 | if result_obj is None: | ||
980 | whole_result = '' | ||
981 | else: | ||
982 | whole_result = consts.RESULT_Y if result_obj.ocr_auto_result_pass else consts.RESULT_N | ||
983 | |||
984 | source = consts.INFO_SOURCE[1] | ||
985 | version = comments = '' | ||
986 | |||
987 | compare_result = { | ||
988 | 'id': 0 if result_obj is None else result_obj.id, | ||
989 | 'application_id': case_id, | ||
990 | 'entity': entity, | ||
991 | 'scheme': consts.DOC_SCHEME_LIST[0] if scheme == consts.COMPARE_DOC_SCHEME_LIST[0] else | ||
992 | consts.DOC_SCHEME_LIST[1], | ||
993 | 'whole_result': whole_result, | ||
994 | 'latest_compared_time': '' if result_obj is None else result_obj.ocr_latest_comparison_time.strftime('%Y-%m-%d %H:%M'), | ||
995 | 'source': source, | ||
996 | 'version': version, | ||
997 | 'comments': comments, | ||
998 | 'result': [] if result_obj is None else json.loads(result_obj.ocr_auto_result) | ||
999 | } | ||
1000 | |||
1001 | return response.ok(data=compare_result) | ||
947 | 1002 | ||
948 | if entity == consts.HIL_PREFIX: | 1003 | if entity == consts.HIL_PREFIX: |
949 | result_table = HILCACompareResult if scheme == consts.COMPARE_DOC_SCHEME_LIST[0] else HILSECompareResult | 1004 | result_table = HILCACompareResult if scheme == consts.COMPARE_DOC_SCHEME_LIST[0] else HILSECompareResult |
... | @@ -1132,7 +1187,7 @@ class SECMSView(GenericView): | ... | @@ -1132,7 +1187,7 @@ class SECMSView(GenericView): |
1132 | permission_classes = [IsAuthenticated] | 1187 | permission_classes = [IsAuthenticated] |
1133 | authentication_classes = [OAuth2AuthenticationWithUser] | 1188 | authentication_classes = [OAuth2AuthenticationWithUser] |
1134 | 1189 | ||
1135 | # pos上传比对信息接口 SE | 1190 | # CMS上传比对信息接口 SE |
1136 | # @use_args(se_cms_args, location='data') | 1191 | # @use_args(se_cms_args, location='data') |
1137 | def post(self, request): | 1192 | def post(self, request): |
1138 | args = request.data | 1193 | args = request.data | ... | ... |
... | @@ -27,6 +27,8 @@ from apps.doc.models import ( | ... | @@ -27,6 +27,8 @@ from apps.doc.models import ( |
27 | AFCCACompareResult, | 27 | AFCCACompareResult, |
28 | HILSECompareResult, | 28 | HILSECompareResult, |
29 | HILCACompareResult, | 29 | HILCACompareResult, |
30 | HILAutoSettlement, | ||
31 | AFCAutoSettlement, | ||
30 | ) | 32 | ) |
31 | from apps.doc import consts | 33 | from apps.doc import consts |
32 | from apps.doc.ocr.gcap import gcap | 34 | from apps.doc.ocr.gcap import gcap |
... | @@ -870,6 +872,481 @@ def ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res | ... | @@ -870,6 +872,481 @@ def ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res |
870 | traceback.format_exc())) | 872 | traceback.format_exc())) |
871 | 873 | ||
872 | 874 | ||
875 | def get_se_cms_compare_info_auto(last_obj, application_entity): | ||
876 | cms_info = json.loads(last_obj.content) | ||
877 | |||
878 | compare_info = {} | ||
879 | |||
880 | individual_info_dict = {} | ||
881 | main_role_info = {} | ||
882 | company_info_list = [] | ||
883 | |||
884 | # 个人信息证件--------------------------------------------------------------------------------------------------------- | ||
885 | # province = cms_info.get('province', '') | ||
886 | for individual_info in cms_info.get('applicantInformation', []): | ||
887 | all_id_num = [] | ||
888 | |||
889 | license_dict = {} | ||
890 | |||
891 | customer_name = individual_info.get('name', '') | ||
892 | legal_name = individual_info.get('legalRepName', '') | ||
893 | # establishment_date = individual_info.get('establishmentDate', '') | ||
894 | # date_of_birth = individual_info.get('dateOfBirth', '') | ||
895 | |||
896 | for id_info in individual_info.get('IDInformation', []): | ||
897 | if id_info.get('idType') in consts.SE_CMS_FIRST_ID_FIELD_MAPPING: | ||
898 | license_en, is_prc = consts.SE_CMS_FIRST_ID_FIELD_MAPPING[id_info['idType']] | ||
899 | # ['customerName', 'idNum', 'dateOfBirth', 'idExpiryDate', 'hukouProvince'] | ||
900 | id_num = decode_des(id_info.get('idNum', ''), des_key) | ||
901 | field_input = [ | ||
902 | ('customerName', customer_name), | ||
903 | ('idNum', id_num), | ||
904 | # ('dateOfBirth', date_of_birth), | ||
905 | # ('idExpiryDate', id_info.get('idExpiryDate', '')), | ||
906 | ] | ||
907 | if is_prc: | ||
908 | # field_input.append(('hukouProvince', province)) | ||
909 | field_input.append(('真伪', consts.IC_RES_MAPPING.get(1))) | ||
910 | field_input.append(('idExpiryDate', id_info.get('idExpiryDate', ''))) | ||
911 | license_dict[license_en] = field_input | ||
912 | all_id_num.append(id_num) | ||
913 | # 营业执照 -------------------------------------------------------------------------------------------------- | ||
914 | elif id_info.get('idType') in ['Unified Social Credit Code', 'Tax Number', 'Business License Number']: | ||
915 | # ['companyName', 'legalRepName', 'businessLicenseNo', 'organizationCreditCode', | ||
916 | # 'taxRegistrationCertificateNo', 'establishmentDate', 'businessLicenseDueDate'] | ||
917 | id_num = decode_des(id_info.get('idNum', ''), des_key) | ||
918 | # bl_field_input = [ | ||
919 | # ('companyName', customer_name), | ||
920 | # ('legalRepName', legal_name), | ||
921 | # ('businessLicenseNo', id_num), | ||
922 | # ('organizationCreditCode', id_num), | ||
923 | # ('taxRegistrationCertificateNo', id_num), | ||
924 | # ('establishmentDate', establishment_date), | ||
925 | # ('businessLicenseDueDate', id_info.get('idExpiryDate', '')), | ||
926 | # ] | ||
927 | # license_dict[consts.BL_EN] = bl_field_input | ||
928 | all_id_num.append(id_num) | ||
929 | if individual_info.get('customersubType', '') == 'Corporate': | ||
930 | company_info_list.append((customer_name, id_num, legal_name)) | ||
931 | |||
932 | # SME营业执照--------------------------------------------------------------------------------------------------- | ||
933 | # if individual_info.get('customersubType', '').startswith('Self Employed'): | ||
934 | # sep_field_input = [ | ||
935 | # ('legalRepName', customer_name), | ||
936 | # ('businessLicenseDueDate', ''), | ||
937 | # ] | ||
938 | # license_dict[consts.SME_BL_EN] = sep_field_input | ||
939 | |||
940 | if len(all_id_num) > 0: | ||
941 | main_role_info.setdefault(individual_info['applicantType'], []).append( | ||
942 | (customer_name, '、'.join(all_id_num), all_id_num[0]) | ||
943 | ) | ||
944 | |||
945 | if len(license_dict) > 0: | ||
946 | individual_info_dict.setdefault(individual_info['applicantType'], []).append(license_dict) | ||
947 | |||
948 | compare_info['applicantInformation'] = individual_info_dict | ||
949 | |||
950 | main_name = main_num = hmh_name = hmh_id = '' | ||
951 | for applicant_type in consts.APPLICANT_TYPE_ORDER: | ||
952 | if applicant_type in main_role_info: | ||
953 | # main_name, main_num, _ = main_role_info[applicant_type][0] | ||
954 | hmh_name, _, hmh_id = main_role_info[applicant_type][0] | ||
955 | break | ||
956 | |||
957 | # dda_name_list = [] | ||
958 | # dda_num_list = [] | ||
959 | # for applicant_type in consts.APPLICANT_TYPE_ORDER[:2]: | ||
960 | # if applicant_type in main_role_info: | ||
961 | # for dda_name_part, _, dda_num_part in main_role_info[applicant_type]: | ||
962 | # dda_name_list.append(dda_name_part) | ||
963 | # dda_num_list.append(dda_num_part) | ||
964 | # dda_name = '、'.join(dda_name_list) | ||
965 | # dda_num = '、'.join(dda_num_list) | ||
966 | # del main_role_info | ||
967 | |||
968 | if len(company_info_list) > 0: | ||
969 | company_info = company_info_list[0] | ||
970 | else: | ||
971 | company_info = None | ||
972 | |||
973 | vehicle_info = {} | ||
974 | vehicle_field_input = [] | ||
975 | vehicle_status = cms_info.get('vehicleStatus', '') | ||
976 | first_submission_date = cms_info.get('submissionDate', '') | ||
977 | vin_no = cms_info.get('vehicleInformation', {}).get('vinNo', '') | ||
978 | amount = str(cms_info.get('financialInformation', {}).get('vehiclePrice', '0.0')) | ||
979 | # 新车发票---------------------------------------------------------------------------------------------------------- | ||
980 | if vehicle_status == 'New': | ||
981 | vehicle_field_input.append(('vinNo', vin_no)) | ||
982 | vehicle_field_input.append(('dealer', '、'.join([cms_info.get('dealerName', ''), cms_info.get('fapiaoIssuerDealer', '')]))) | ||
983 | vehicle_field_input.append(('vehicleTransactionAmount', amount)) | ||
984 | |||
985 | if isinstance(company_info, tuple): | ||
986 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[0], company_info[0])) | ||
987 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[1], company_info[1])) | ||
988 | else: | ||
989 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[0], hmh_name)) | ||
990 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[1], hmh_id)) | ||
991 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[2], first_submission_date)) | ||
992 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[3], consts.SE_STAMP_VALUE)) | ||
993 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[4], consts.SE_FPL_VALUE)) | ||
994 | bhsj = float(amount) / 1.13 | ||
995 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[5], consts.SPLIT_STR.join([ | ||
996 | format(bhsj, '.2f'), | ||
997 | format(float(amount) - bhsj, '.2f'), | ||
998 | consts.RESULT_Y | ||
999 | ]))) | ||
1000 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[6], consts.SE_LAYOUT_VALUE)) | ||
1001 | vehicle_info[consts.MVI_EN] = vehicle_field_input | ||
1002 | compare_info['vehicleInfo'] = vehicle_info | ||
1003 | # 二手车发票、交易凭证、绿本------------------------------------------------------------------------------------------ | ||
1004 | # else: | ||
1005 | # gb_field_input = [ | ||
1006 | # ('vinNo', vin_no), | ||
1007 | # ] | ||
1008 | # gb34_field_input = [] | ||
1009 | # jypz_field_input = [] | ||
1010 | # vehicle_field_input.append(('vinNo', vin_no)) | ||
1011 | # vehicle_field_input.append(('vehicleTransactionAmount', amount)) | ||
1012 | # if isinstance(company_info, tuple): | ||
1013 | # vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[0], company_info[0])) | ||
1014 | # vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[1], company_info[1])) | ||
1015 | # jypz_field_input.append((consts.SE_NEW_ADD_FIELD[0], company_info[0])) | ||
1016 | # jypz_field_input.append((consts.SE_NEW_ADD_FIELD[1], company_info[1])) | ||
1017 | # gb34_field_input.append((consts.SE_GB_USED_FIELD[0], company_info[0])) | ||
1018 | # gb34_field_input.append((consts.SE_GB_USED_FIELD[1], company_info[1])) | ||
1019 | # else: | ||
1020 | # vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[0], main_name)) | ||
1021 | # vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[1], main_num)) | ||
1022 | # jypz_field_input.append((consts.SE_NEW_ADD_FIELD[0], main_name)) | ||
1023 | # jypz_field_input.append((consts.SE_NEW_ADD_FIELD[1], main_num)) | ||
1024 | # gb34_field_input.append((consts.SE_GB_USED_FIELD[0], main_name)) | ||
1025 | # gb34_field_input.append((consts.SE_GB_USED_FIELD[1], main_num)) | ||
1026 | # gb34_field_input.append((consts.SE_GB_USED_FIELD[2], first_submission_date)) | ||
1027 | # vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[2], first_submission_date)) | ||
1028 | # vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[3], consts.SE_STAMP_VALUE)) | ||
1029 | # jypz_field_input.append(('vinNo', vin_no)) | ||
1030 | # jypz_field_input.append(('vehicleTransactionAmount', amount)) | ||
1031 | # jypz_field_input.append((consts.SE_GB_USED_FIELD[-1], first_submission_date)) | ||
1032 | # | ||
1033 | # vehicle_info[consts.MVC_EN] = gb_field_input | ||
1034 | # vehicle_info[consts.MVC34_EN] = gb34_field_input | ||
1035 | # if not detect_list[0]: | ||
1036 | # vehicle_info[consts.UCI_EN] = vehicle_field_input | ||
1037 | # if not detect_list[1]: | ||
1038 | # vehicle_info[consts.JYPZ_EN] = jypz_field_input | ||
1039 | # if detect_list[0] and detect_list[1]: | ||
1040 | # vehicle_info[consts.UCI_EN] = vehicle_field_input | ||
1041 | # compare_info['vehicleInfo'] = vehicle_info | ||
1042 | |||
1043 | # 银行卡------------------------------------------------------------------------------------------------------- | ||
1044 | bank_info = {} | ||
1045 | bank_name = cms_info.get('bankAccountDetails', {}).get('bankName', '') | ||
1046 | account_no = decode_des(cms_info.get('bankAccountDetails', {}).get('accountNo', ''), des_key) | ||
1047 | is_gsyh = True if '工商' in bank_name else False | ||
1048 | bank_field_input = [ | ||
1049 | ('accountNo', account_no), | ||
1050 | ('bankName', bank_name), | ||
1051 | ('type', consts.BC_TYPE_VALUE), | ||
1052 | ] | ||
1053 | bank_info[consts.BC_EN] = bank_field_input | ||
1054 | |||
1055 | # DDA------------------------------------------------------------------------------------------------------------ | ||
1056 | # if is_gsyh or not detect_list[-1]: | ||
1057 | # dda_field_input = [ | ||
1058 | # ('applicationId(1)', last_obj.application_id), | ||
1059 | # ('applicationId(2)', last_obj.application_id), | ||
1060 | # ('bankName', bank_name), | ||
1061 | # ('companyName', consts.HIL_COMPANY_NAME if application_entity in consts.HIL_SET else consts.AFC_COMPANY_NAME), | ||
1062 | # ('customerName', dda_name), | ||
1063 | # ('idNum', dda_num), | ||
1064 | # ('accountHolderName', cms_info.get('bankAccountDetails', {}).get('accountHolderName', '')), | ||
1065 | # ('accountNo', account_no), | ||
1066 | # ] | ||
1067 | # bank_info[consts.DDA_EN] = dda_field_input | ||
1068 | compare_info['bankInfo'] = bank_info | ||
1069 | |||
1070 | # 银行流水 -------------------------------------------------------------------- | ||
1071 | if cms_info.get('autoApprovedDetails', {}).get('aaType', '') in ['CAA1', 'CAA2']: | ||
1072 | bs_role_list = [] | ||
1073 | for applicant_type in consts.APPLICANT_TYPE_ORDER[:2]: | ||
1074 | if applicant_type in main_role_info: | ||
1075 | for bs_role, _, _ in main_role_info[applicant_type]: | ||
1076 | bs_role_list.append(bs_role) | ||
1077 | |||
1078 | bs_info = dict() | ||
1079 | bs_field_input = [ | ||
1080 | (consts.SE_BS_FIELD[0], bs_role_list), | ||
1081 | (consts.SE_BS_FIELD[1], first_submission_date), | ||
1082 | (consts.SE_BS_FIELD[2], '90天'), | ||
1083 | ] | ||
1084 | |||
1085 | dbr_bs_role_list = [] | ||
1086 | for dbr_bs_role, _, _ in main_role_info.get(consts.APPLICANT_TYPE_ORDER[2], []): | ||
1087 | dbr_bs_role_list.append(dbr_bs_role) | ||
1088 | |||
1089 | if len(dbr_bs_role_list) >= 1: | ||
1090 | bs_field_input.extend([ | ||
1091 | (consts.SE_BS_FIELD[3], dbr_bs_role_list[0]), | ||
1092 | (consts.SE_BS_FIELD[4], first_submission_date), | ||
1093 | (consts.SE_BS_FIELD[5], '90天'), | ||
1094 | ]) | ||
1095 | if len(dbr_bs_role_list) >= 2: | ||
1096 | bs_field_input.extend([ | ||
1097 | (consts.SE_BS_FIELD[6], dbr_bs_role_list[1]), | ||
1098 | (consts.SE_BS_FIELD[7], first_submission_date), | ||
1099 | (consts.SE_BS_FIELD[8], '90天'), | ||
1100 | ]) | ||
1101 | bs_info[consts.BS_EN] = bs_field_input | ||
1102 | compare_info['Bank Statement'] = bs_info | ||
1103 | |||
1104 | # 抵押登记豁免函---------------------------------------------------------------------------------------------------- | ||
1105 | other_info = {} | ||
1106 | full_no = cms_info.get('settlemnetVerification', {}).get('applicationNo', '') | ||
1107 | if cms_info.get('mortgageType', '') == 'Mortgage Free' or cms_info.get('mortgageType', '') == 'MortgageFree': | ||
1108 | hmh_field_input = [ | ||
1109 | (consts.SE_HMH_FIELD[0], hmh_name), | ||
1110 | (consts.SE_HMH_FIELD[1], hmh_id), | ||
1111 | (consts.SE_HMH_FIELD[2], full_no), | ||
1112 | (consts.SE_HMH_FIELD[3], cms_info.get('financeCompany', '')), | ||
1113 | (consts.SE_HMH_FIELD[4], consts.SE_STAMP_VALUE), | ||
1114 | ] | ||
1115 | other_info[consts.HMH_EN] = hmh_field_input | ||
1116 | |||
1117 | # ASP ------------------------------------------------------------------------------------------------------- | ||
1118 | asp_list = [] | ||
1119 | gzs_status = consts.GZS_STATUS[1] | ||
1120 | gzs_list = [gzs_status] | ||
1121 | gzs_price = '0.00' | ||
1122 | is_asp = False | ||
1123 | # insurance_price = None | ||
1124 | if str(cms_info.get('financialInformation', {}).get('associatedServicePrincipal', '0.00')) != '0.00': | ||
1125 | is_asp = True | ||
1126 | # for asp_info in cms_info.get('associatedServices', []): | ||
1127 | for asp_info in cms_info.get('associatedServices', {}).get('SubassociatedServices', []): | ||
1128 | tmp_asp_name = asp_info.get('associatedServices') | ||
1129 | if isinstance(tmp_asp_name, str) and len(tmp_asp_name) > 0: | ||
1130 | if gzs_status == consts.GZS_STATUS[1] and tmp_asp_name.find(consts.GZS_NAME) != -1: | ||
1131 | gzs_status = consts.GZS_STATUS[2] | ||
1132 | gzs_price = asp_info.get('price', '0.00') | ||
1133 | asp_list.append( | ||
1134 | ( | ||
1135 | tmp_asp_name, | ||
1136 | asp_info.get('price', '0.00'), | ||
1137 | asp_info.get('financed', '0.00') | ||
1138 | ) | ||
1139 | ) | ||
1140 | # 保单费合计 | ||
1141 | # if tmp_asp_name.find('机动车辆保险') != -1: | ||
1142 | # insurance_price = asp_info.get('price', '0.00') | ||
1143 | |||
1144 | # fin_total = 0 | ||
1145 | fin_total_tmp = cms_info.get('associatedServices', {}).get('financed total', '0.00') | ||
1146 | fin_total = '0.00' if fin_total_tmp.strip() == '' else fin_total_tmp | ||
1147 | for asp_name, _, asp_fin in asp_list: | ||
1148 | if gzs_status == consts.GZS_STATUS[2] and asp_name.find(consts.GZS_NAME) == -1: | ||
1149 | gzs_status = consts.GZS_STATUS[0] | ||
1150 | # fin_total += float(asp_fin) | ||
1151 | asp_list.append( | ||
1152 | ( | ||
1153 | consts.ASP_SUM_NAME, | ||
1154 | '', | ||
1155 | fin_total, | ||
1156 | # format(fin_total, '.2f'), | ||
1157 | ) | ||
1158 | ) | ||
1159 | |||
1160 | # CMS Vehicle Price / 1.13 * 10 % | ||
1161 | if gzs_status != consts.GZS_STATUS[1]: | ||
1162 | gzs_value = float(amount) * 0.1 / 1.13 | ||
1163 | gzs_list.append(gzs_value) | ||
1164 | gzs_list.append(float(gzs_price)) | ||
1165 | |||
1166 | # 保单 ----------------------------------------------------------------------------------------------------------- | ||
1167 | # is_insurance = 0 | ||
1168 | fp_campaign = cms_info.get('fpCampaign', '') | ||
1169 | # insurance_type = cms_info.get('insuranceDetails', {}).get('insuranceType', '') | ||
1170 | # if insurance_type == 'Waive Insurance' and isinstance(insurance_price, str): | ||
1171 | # is_insurance = 1 | ||
1172 | # elif insurance_type == 'Comprehensive Insurance': | ||
1173 | # is_insurance = 2 | ||
1174 | # if is_insurance != 0: | ||
1175 | # if fp_campaign.find('OCU') == -1: | ||
1176 | # ssx_amount = amount | ||
1177 | # else: | ||
1178 | # ssx_amount = format(float(amount) * 0.8, '.2f') | ||
1179 | # if fp_campaign.find('Joy_Plus') == -1 or fp_campaign.find('JoyPlus') == -1: | ||
1180 | # dszx_amount = '200000' | ||
1181 | # else: | ||
1182 | # dszx_amount = '500000' | ||
1183 | # bd_field_input = [ | ||
1184 | # (consts.SE_BD_FIELD[0], hmh_name), | ||
1185 | # (consts.SE_BD_FIELD[1], hmh_id), | ||
1186 | # (consts.SE_BD_FIELD[2], vin_no), | ||
1187 | # (consts.SE_BD_FIELD[3], ssx_amount), | ||
1188 | # (consts.SE_BD_FIELD[4], dszx_amount), | ||
1189 | # (consts.SE_BD_FIELD[5], consts.JDMPV_VALUE), | ||
1190 | # (consts.SE_BD_FIELD[6], cms_info.get('insuranceDetails', {}).get('startDate', '')), | ||
1191 | # (consts.SE_BD_FIELD[7], cms_info.get('insuranceDetails', {}).get('endDate', '')), | ||
1192 | # (consts.SE_BD_FIELD[8], consts.SE_STAMP_VALUE), | ||
1193 | # (consts.SE_BD_FIELD[9], consts.SE_STAMP_VALUE), | ||
1194 | # ] | ||
1195 | # if is_insurance == 1: | ||
1196 | # bd_field_input.append((consts.SE_BD_FIELD[10], insurance_price)) | ||
1197 | # other_info[consts.BD_EN] = bd_field_input | ||
1198 | |||
1199 | if len(other_info) > 0: | ||
1200 | compare_info['other'] = other_info | ||
1201 | |||
1202 | schedule_list = [] | ||
1203 | total_amount = 0 | ||
1204 | for schedule_dict in cms_info.get('paymentSchedule', []): | ||
1205 | tmp_str = "{1}{0}{2}".format(consts.SPLIT_STR, str(schedule_dict.get('no', '')), | ||
1206 | str(schedule_dict.get('grossRentalAmount', ''))) | ||
1207 | schedule_list.append(tmp_str) | ||
1208 | total_amount += float(schedule_dict.get('grossRentalAmount', '0.0')) | ||
1209 | schedule_list_str = consts.SCHEDULE_SPLIT_STR.join(schedule_list) | ||
1210 | |||
1211 | online_sign = cms_info.get('contractSource', 'Online Sign') == 'Online Sign' | ||
1212 | |||
1213 | contract_info = {} | ||
1214 | if application_entity in consts.HIL_SET: | ||
1215 | # HIL合同 售后回租合同 -------------------------------------------------------------------------------------- | ||
1216 | hil_contract_1_input = [ | ||
1217 | (consts.SE_HIL_CON_1_FIELD[0], [full_no] if online_sign else full_no), | ||
1218 | (consts.SE_HIL_CON_1_FIELD[1], full_no), | ||
1219 | (consts.SE_HIL_CON_1_FIELD[2], vin_no), | ||
1220 | (consts.SE_HIL_CON_1_FIELD[3], cms_info.get('dealerName', '')), | ||
1221 | (consts.SE_HIL_CON_1_FIELD[4], amount), | ||
1222 | (consts.SE_HIL_CON_1_FIELD[5], str(cms_info.get('financialInformation', {}).get('originationPrincipal', '0.0'))), | ||
1223 | (consts.SE_HIL_CON_1_FIELD[6], str(cms_info.get('terms', '0'))), | ||
1224 | (consts.SE_HIL_CON_1_FIELD[7], schedule_list_str), | ||
1225 | (consts.SE_HIL_CON_1_FIELD[11], account_no), | ||
1226 | (consts.SE_HIL_CON_1_FIELD[12], cms_info.get('bankAccountDetails', {}).get('accountHolderName', '')), | ||
1227 | (consts.SE_HIL_CON_1_FIELD[13], bank_name), | ||
1228 | ] | ||
1229 | |||
1230 | if is_asp: | ||
1231 | hil_contract_1_input.append((consts.SE_HIL_CON_1_FIELD[8], asp_list)) | ||
1232 | hil_contract_1_input.append((consts.SE_HIL_CON_1_FIELD[9], gzs_list)) | ||
1233 | |||
1234 | if isinstance(company_info, tuple): | ||
1235 | hil_contract_1_input.append((consts.SE_HIL_CON_1_FIELD[10], company_info[2])) | ||
1236 | |||
1237 | for key, app_type, id_idx, field_idx, is_force, e_write in consts.ROLE_LIST_1: | ||
1238 | if not e_write and not online_sign: | ||
1239 | continue | ||
1240 | is_find = False | ||
1241 | if app_type in main_role_info: | ||
1242 | if len(main_role_info[app_type]) >= id_idx+1: | ||
1243 | is_find = True | ||
1244 | if isinstance(field_idx, int): | ||
1245 | hil_contract_1_input.append((key, main_role_info[app_type][id_idx][field_idx])) | ||
1246 | else: | ||
1247 | hil_contract_1_input.append((key, field_idx)) | ||
1248 | if not is_find and is_force: | ||
1249 | hil_contract_1_input.append((key, empty_str)) | ||
1250 | contract_info[consts.HIL_CONTRACT_1_EN] = hil_contract_1_input | ||
1251 | |||
1252 | # HIL合同 车辆处置协议 -------------------------------------------------------------------------------------- | ||
1253 | if fp_campaign.find('Joy_Select') != -1 or fp_campaign.find('JoySelect') != -1: | ||
1254 | hil_contract_3_input = [ | ||
1255 | (consts.SE_HIL_CON_3_FIELD[0], [full_no] if online_sign else full_no), | ||
1256 | (consts.SE_HIL_CON_3_FIELD[1], hmh_name), | ||
1257 | (consts.SE_HIL_CON_3_FIELD[2], hmh_id), | ||
1258 | (consts.SE_HIL_CON_3_FIELD[3], cms_info.get('dealerName', '')), | ||
1259 | (consts.SE_HIL_CON_3_FIELD[4], full_no), | ||
1260 | (consts.SE_HIL_CON_3_FIELD[5], hmh_name), | ||
1261 | (consts.SE_HIL_CON_3_FIELD[6], hmh_id), | ||
1262 | ] | ||
1263 | if online_sign: | ||
1264 | hil_contract_3_input.append((consts.SE_HIL_CON_3_FIELD[7], hmh_name)) | ||
1265 | contract_info[consts.HIL_CONTRACT_3_EN] = hil_contract_3_input | ||
1266 | |||
1267 | # HIL合同 车辆租赁抵押合同 -------------------------------------------------------------------------------------- | ||
1268 | hil_contract_2_input = [ | ||
1269 | (consts.SE_HIL_CON_2_FIELD[0], full_no), | ||
1270 | (consts.SE_HIL_CON_2_FIELD[1], full_no), | ||
1271 | (consts.SE_HIL_CON_2_FIELD[2], vin_no), | ||
1272 | (consts.SE_HIL_CON_2_FIELD[3], format(total_amount, '.2f')), | ||
1273 | (consts.SE_HIL_CON_2_FIELD[4], str(cms_info.get('terms', '0'))), | ||
1274 | ] | ||
1275 | |||
1276 | for key, app_type, id_idx, field_idx, is_force, e_write in consts.ROLE_LIST_2: | ||
1277 | if not e_write and not online_sign: | ||
1278 | continue | ||
1279 | is_find = False | ||
1280 | if app_type in main_role_info: | ||
1281 | if len(main_role_info[app_type]) >= id_idx+1: | ||
1282 | is_find = True | ||
1283 | if isinstance(field_idx, int): | ||
1284 | hil_contract_2_input.append((key, main_role_info[app_type][id_idx][field_idx])) | ||
1285 | else: | ||
1286 | hil_contract_2_input.append((key, field_idx)) | ||
1287 | if not is_find and is_force: | ||
1288 | hil_contract_2_input.append((key, empty_str)) | ||
1289 | contract_info[consts.HIL_CONTRACT_2_EN] = hil_contract_2_input | ||
1290 | compare_info['contract'] = contract_info | ||
1291 | return compare_info, cms_info.get('autoApprovedDetails', {}).get('aaType', ''), is_gsyh | ||
1292 | else: | ||
1293 | # AFC合同----------------------------------------------------------------------------------------------------------- | ||
1294 | vehicle_principal_str = str(cms_info.get('financialInformation', {}).get('vehiclePrincipal', '0.0')) | ||
1295 | afc_contract_input = [ | ||
1296 | (consts.SE_AFC_CON_FIELD[0], full_no), | ||
1297 | (consts.SE_AFC_CON_FIELD[1], amount), | ||
1298 | (consts.SE_AFC_CON_FIELD[2], vin_no), | ||
1299 | (consts.SE_AFC_CON_FIELD[3], str(cms_info.get('financialInformation', {}).get('originationPrincipal', '0.0'))), | ||
1300 | (consts.SE_AFC_CON_FIELD[4], str(cms_info.get('terms', '0'))), | ||
1301 | (consts.SE_AFC_CON_FIELD[5], vehicle_principal_str), | ||
1302 | (consts.SE_AFC_CON_FIELD[6], str(cms_info.get('financialInformation', {}).get('associatedServicePrincipal', '0.0'))), | ||
1303 | (consts.SE_AFC_CON_FIELD[7], amount), | ||
1304 | (consts.SE_AFC_CON_FIELD[8], vin_no), | ||
1305 | (consts.SE_AFC_CON_FIELD[9], cms_info.get('dealerName', '')), | ||
1306 | (consts.SE_AFC_CON_FIELD[10], str(cms_info.get('financialInformation', {}).get('originationPrincipal', '0.0'))), | ||
1307 | (consts.SE_AFC_CON_FIELD[11], vehicle_principal_str), | ||
1308 | (consts.SE_AFC_CON_FIELD[12], str(cms_info.get('financialInformation', {}).get('associatedServicePrincipal', '0.0'))), | ||
1309 | (consts.SE_AFC_CON_FIELD[13], str(cms_info.get('terms', '0'))), | ||
1310 | (consts.SE_AFC_CON_FIELD[14], account_no), | ||
1311 | (consts.SE_AFC_CON_FIELD[15], cms_info.get('bankAccountDetails', {}).get('accountHolderName', '')), | ||
1312 | (consts.SE_AFC_CON_FIELD[16], bank_name), | ||
1313 | (consts.SE_AFC_CON_FIELD[17], schedule_list_str), | ||
1314 | ] | ||
1315 | |||
1316 | if is_asp: | ||
1317 | afc_contract_input.append((consts.SE_AFC_CON_FIELD[20], asp_list)) | ||
1318 | afc_contract_input.append((consts.SE_AFC_CON_FIELD[22], asp_list)) | ||
1319 | afc_contract_input.append((consts.SE_AFC_CON_FIELD[21], gzs_list)) | ||
1320 | else: | ||
1321 | afc_contract_input.pop(5) | ||
1322 | afc_contract_input.pop(5) | ||
1323 | afc_contract_input.pop(9) | ||
1324 | afc_contract_input.pop(9) | ||
1325 | |||
1326 | # '借款人签字及时间', 'Borrower', 0, 0, True | ||
1327 | for key, app_type, id_idx, field_idx, is_force, e_write in consts.ROLE_LIST: | ||
1328 | if not e_write and not online_sign: | ||
1329 | continue | ||
1330 | is_find = False | ||
1331 | if app_type in main_role_info: | ||
1332 | if len(main_role_info[app_type]) >= id_idx+1: | ||
1333 | is_find = True | ||
1334 | if isinstance(field_idx, int): | ||
1335 | afc_contract_input.append((key, main_role_info[app_type][id_idx][field_idx])) | ||
1336 | else: | ||
1337 | afc_contract_input.append((key, field_idx)) | ||
1338 | if not is_find and is_force: | ||
1339 | afc_contract_input.append((key, empty_str)) | ||
1340 | |||
1341 | if online_sign: | ||
1342 | afc_contract_input.append((consts.SE_AFC_CON_FIELD[18], consts.SE_STAMP_VALUE)) | ||
1343 | afc_contract_input.append((consts.SE_AFC_CON_FIELD[19], empty_str)) | ||
1344 | |||
1345 | contract_info[consts.AFC_CONTRACT_EN] = afc_contract_input | ||
1346 | compare_info['contract'] = contract_info | ||
1347 | return compare_info, cms_info.get('autoApprovedDetails', {}).get('aaType', ''), is_gsyh | ||
1348 | |||
1349 | |||
873 | def get_se_cms_compare_info(last_obj, application_entity, detect_list): | 1350 | def get_se_cms_compare_info(last_obj, application_entity, detect_list): |
874 | cms_info = json.loads(last_obj.content) | 1351 | cms_info = json.loads(last_obj.content) |
875 | 1352 | ||
... | @@ -1173,7 +1650,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): | ... | @@ -1173,7 +1650,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): |
1173 | ssx_amount = amount | 1650 | ssx_amount = amount |
1174 | else: | 1651 | else: |
1175 | ssx_amount = format(float(amount) * 0.8, '.2f') | 1652 | ssx_amount = format(float(amount) * 0.8, '.2f') |
1176 | if fp_campaign.find('Joy_Plus') == -1: | 1653 | if fp_campaign.find('Joy_Plus') == -1 or fp_campaign.find('JoyPlus') == -1: |
1177 | dszx_amount = '200000' | 1654 | dszx_amount = '200000' |
1178 | else: | 1655 | else: |
1179 | dszx_amount = '500000' | 1656 | dszx_amount = '500000' |
... | @@ -1219,6 +1696,9 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): | ... | @@ -1219,6 +1696,9 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): |
1219 | (consts.SE_HIL_CON_1_FIELD[5], str(cms_info.get('financialInformation', {}).get('originationPrincipal', '0.0'))), | 1696 | (consts.SE_HIL_CON_1_FIELD[5], str(cms_info.get('financialInformation', {}).get('originationPrincipal', '0.0'))), |
1220 | (consts.SE_HIL_CON_1_FIELD[6], str(cms_info.get('terms', '0'))), | 1697 | (consts.SE_HIL_CON_1_FIELD[6], str(cms_info.get('terms', '0'))), |
1221 | (consts.SE_HIL_CON_1_FIELD[7], schedule_list_str), | 1698 | (consts.SE_HIL_CON_1_FIELD[7], schedule_list_str), |
1699 | (consts.SE_HIL_CON_1_FIELD[11], account_no), | ||
1700 | (consts.SE_HIL_CON_1_FIELD[12], cms_info.get('bankAccountDetails', {}).get('accountHolderName', '')), | ||
1701 | (consts.SE_HIL_CON_1_FIELD[13], bank_name), | ||
1222 | ] | 1702 | ] |
1223 | 1703 | ||
1224 | if is_asp: | 1704 | if is_asp: |
... | @@ -1244,7 +1724,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): | ... | @@ -1244,7 +1724,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): |
1244 | contract_info[consts.HIL_CONTRACT_1_EN] = hil_contract_1_input | 1724 | contract_info[consts.HIL_CONTRACT_1_EN] = hil_contract_1_input |
1245 | 1725 | ||
1246 | # HIL合同 车辆处置协议 -------------------------------------------------------------------------------------- | 1726 | # HIL合同 车辆处置协议 -------------------------------------------------------------------------------------- |
1247 | if fp_campaign.find('Joy_Select') != -1: | 1727 | if fp_campaign.find('Joy_Select') != -1 or fp_campaign.find('JoySelect') != -1: |
1248 | hil_contract_3_input = [ | 1728 | hil_contract_3_input = [ |
1249 | (consts.SE_HIL_CON_3_FIELD[0], [full_no] if online_sign else full_no), | 1729 | (consts.SE_HIL_CON_3_FIELD[0], [full_no] if online_sign else full_no), |
1250 | (consts.SE_HIL_CON_3_FIELD[1], hmh_name), | 1730 | (consts.SE_HIL_CON_3_FIELD[1], hmh_name), |
... | @@ -1917,12 +2397,12 @@ def se_contract_compare(license_en, ocr_res_dict, strip_list, is_gsyh): | ... | @@ -1917,12 +2397,12 @@ def se_contract_compare(license_en, ocr_res_dict, strip_list, is_gsyh): |
1917 | else: | 2397 | else: |
1918 | ocr_str_or_list = ocr_res.get(compare_logic[name][0]) | 2398 | ocr_str_or_list = ocr_res.get(compare_logic[name][0]) |
1919 | if ocr_str_or_list is None and license_en == consts.AFC_CONTRACT_EN \ | 2399 | if ocr_str_or_list is None and license_en == consts.AFC_CONTRACT_EN \ |
1920 | and is_gsyh is True and name in consts.AFC_CON_BANK_FIELD: | 2400 | and is_gsyh is True and name in consts.CON_BANK_FIELD: |
1921 | result = consts.RESULT_Y | 2401 | result = consts.RESULT_Y |
1922 | ocr_str = empty_str | 2402 | ocr_str = empty_str |
1923 | reason = compare_logic[name][3] | 2403 | reason = compare_logic[name][3] |
1924 | elif isinstance(ocr_str_or_list, str) or isinstance(ocr_str_or_list, list): | 2404 | elif isinstance(ocr_str_or_list, str) or isinstance(ocr_str_or_list, list): |
1925 | if license_en == consts.AFC_CONTRACT_EN and is_gsyh is True and name in consts.AFC_CON_BANK_FIELD: | 2405 | if is_gsyh is True and name in consts.CON_BANK_FIELD: |
1926 | update_args = {'is_gsyh': is_gsyh} | 2406 | update_args = {'is_gsyh': is_gsyh} |
1927 | for k, v in compare_logic[name][2].items(): | 2407 | for k, v in compare_logic[name][2].items(): |
1928 | update_args[k] = v | 2408 | update_args[k] = v |
... | @@ -2223,6 +2703,35 @@ def se_result_detect(ocr_res_dict): | ... | @@ -2223,6 +2703,35 @@ def se_result_detect(ocr_res_dict): |
2223 | return detect_list | 2703 | return detect_list |
2224 | 2704 | ||
2225 | 2705 | ||
2706 | def se_compare_auto(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict, auto_obj): | ||
2707 | try: | ||
2708 | # 比对逻辑 | ||
2709 | # detect_list = se_result_detect(ocr_res_dict) | ||
2710 | compare_info, aa_type, is_gsyh = get_se_cms_compare_info_auto( | ||
2711 | last_obj, application_entity) | ||
2712 | compare_result, total_fields, failed_count, successful_at_this_level, failure_reason_str, cn_failure_reason_str, bs_failure_reason_str = se_compare_process(compare_info, ocr_res_dict, is_gsyh) | ||
2713 | compare_log.info('{0} [Auto SE] [compare success] [entity={1}] [id={2}] [ocr_res_id={3}] [result={4}]'.format( | ||
2714 | log_base, application_entity, application_id, ocr_res_id, compare_result)) | ||
2715 | except Exception as e: | ||
2716 | compare_log.error('{0} [Auto SE] [compare error] [entity={1}] [id={2}] [ocr_res_id={3}] ' | ||
2717 | '[error={4}]'.format(log_base, application_entity, application_id, ocr_res_id, | ||
2718 | traceback.format_exc())) | ||
2719 | else: | ||
2720 | # 将比对结果写入数据库 auto settlement | ||
2721 | try: | ||
2722 | auto_obj.aa_type = aa_type | ||
2723 | auto_obj.ocr_auto_result_pass = successful_at_this_level | ||
2724 | auto_obj.ocr_auto_result = json.dumps(compare_result) | ||
2725 | auto_obj.ocr_latest_comparison_time = datetime.now() | ||
2726 | auto_obj.save() | ||
2727 | compare_log.info('{0} [Auto SE] [result save success] [entity={1}] [id={2}] [ocr_res_id={3}]'.format( | ||
2728 | log_base, application_entity, application_id, ocr_res_id)) | ||
2729 | except Exception as e: | ||
2730 | compare_log.error('{0} [Auto SE] [result save error] [entity={1}] [id={2}] [ocr_res_id={3}] ' | ||
2731 | '[error={4}]'.format(log_base, application_entity, application_id, ocr_res_id, | ||
2732 | traceback.format_exc())) | ||
2733 | |||
2734 | |||
2226 | def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict, is_cms): | 2735 | def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict, is_cms): |
2227 | try: | 2736 | try: |
2228 | # 比对逻辑 | 2737 | # 比对逻辑 |
... | @@ -2317,6 +2826,7 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res | ... | @@ -2317,6 +2826,7 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res |
2317 | compare_log.info('{0} [SE] [cms success] [entity={1}] [id={2}] [ocr_res_id={3}] [response={4}]'.format( | 2826 | compare_log.info('{0} [SE] [cms success] [entity={1}] [id={2}] [ocr_res_id={3}] [response={4}]'.format( |
2318 | log_base, application_entity, application_id, ocr_res_id, response)) | 2827 | log_base, application_entity, application_id, ocr_res_id, response)) |
2319 | 2828 | ||
2829 | |||
2320 | @app.task | 2830 | @app.task |
2321 | def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True, is_cms=False): | 2831 | def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True, is_cms=False): |
2322 | # POS: application_id, application_entity, uniq_seq, None | 2832 | # POS: application_id, application_entity, uniq_seq, None |
... | @@ -2348,12 +2858,12 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True | ... | @@ -2348,12 +2858,12 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True |
2348 | else: | 2858 | else: |
2349 | result_class = HILSEOCRResult if application_entity == consts.HIL_PREFIX else AFCSEOCRResult | 2859 | result_class = HILSEOCRResult if application_entity == consts.HIL_PREFIX else AFCSEOCRResult |
2350 | ca_result_class = HILOCRResult if application_entity == consts.HIL_PREFIX else AFCOCRResult | 2860 | ca_result_class = HILOCRResult if application_entity == consts.HIL_PREFIX else AFCOCRResult |
2351 | if ocr_res_id is None: | 2861 | # if ocr_res_id is None: |
2352 | ca_ocr_res_dict = ca_result_class.objects.filter(application_id=application_id).values( | 2862 | ca_ocr_res_dict = ca_result_class.objects.filter(application_id=application_id).values( |
2353 | *consts.CA_ADD_COMPARE_FIELDS).first() | 2863 | *consts.CA_ADD_COMPARE_FIELDS).first() |
2354 | else: | 2864 | # else: |
2355 | ca_ocr_res_dict = ca_result_class.objects.filter(id=ocr_res_id).values( | 2865 | # ca_ocr_res_dict = ca_result_class.objects.filter(id=ocr_res_id).values( |
2356 | *consts.CA_ADD_COMPARE_FIELDS).first() | 2866 | # *consts.CA_ADD_COMPARE_FIELDS).first() |
2357 | if ocr_res_id is None: | 2867 | if ocr_res_id is None: |
2358 | ocr_res_dict = result_class.objects.filter(application_id=application_id).values(*consts.COMPARE_FIELDS).first() | 2868 | ocr_res_dict = result_class.objects.filter(application_id=application_id).values(*consts.COMPARE_FIELDS).first() |
2359 | else: | 2869 | else: |
... | @@ -2374,4 +2884,10 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True | ... | @@ -2374,4 +2884,10 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True |
2374 | tmp_se_result = json.loads(ocr_res_dict.get(field_name)) | 2884 | tmp_se_result = json.loads(ocr_res_dict.get(field_name)) |
2375 | tmp_ca_result.extend(tmp_se_result) | 2885 | tmp_ca_result.extend(tmp_se_result) |
2376 | ocr_res_dict[field_name] = json.dumps(tmp_ca_result) | 2886 | ocr_res_dict[field_name] = json.dumps(tmp_ca_result) |
2887 | # auto settlement | ||
2888 | auto_class = HILAutoSettlement if application_entity == consts.HIL_PREFIX else AFCAutoSettlement | ||
2889 | auto_obj = auto_class.objects.filter(application_id=application_id, on_off=True).first() | ||
2890 | if auto_obj is not None: | ||
2891 | se_compare_auto(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict, auto_obj) | ||
2377 | se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict, is_cms) | 2892 | se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict, is_cms) |
2893 | ... | ... |
src/common/tools/mssql_script13.py
0 → 100644
1 | import pyodbc | ||
2 | |||
3 | hil_sql = """ | ||
4 | create table hil_auto_settlement | ||
5 | ( | ||
6 | id bigint identity primary key, | ||
7 | application_id nvarchar(64) not null, | ||
8 | aa_type nvarchar(64), | ||
9 | |||
10 | rpa_result smallint, | ||
11 | rpa_1st_eye_tat decimal(18,0), | ||
12 | rpa_2nd_eye_tat decimal(18,0), | ||
13 | rpa_3rd_eye_tat decimal(18,0), | ||
14 | rpa_total_tat decimal(18,0), | ||
15 | rpa_activated_time datetime, | ||
16 | rpa_get_case_from_ocr_time datetime, | ||
17 | rpa_get_case_from_oc_time datetime, | ||
18 | rpa_payment_authorize_time datetime, | ||
19 | rpa_second_eye_time datetime, | ||
20 | |||
21 | on_off bit default 1 not null, | ||
22 | ocr_auto_result_pass bit default 0 not null, | ||
23 | ocr_auto_result nvarchar(max), | ||
24 | ocr_latest_comparison_time datetime, | ||
25 | |||
26 | update_time datetime not null, | ||
27 | create_time datetime not null | ||
28 | ); | ||
29 | |||
30 | create index hil_auto_settlement_application_id_index | ||
31 | on hil_auto_settlement (application_id); | ||
32 | """ | ||
33 | |||
34 | afc_sql = """ | ||
35 | create table afc_auto_settlement | ||
36 | ( | ||
37 | id bigint identity primary key, | ||
38 | application_id nvarchar(64) not null, | ||
39 | aa_type nvarchar(64), | ||
40 | |||
41 | rpa_result smallint, | ||
42 | rpa_1st_eye_tat decimal(18,0), | ||
43 | rpa_2nd_eye_tat decimal(18,0), | ||
44 | rpa_3rd_eye_tat decimal(18,0), | ||
45 | rpa_total_tat decimal(18,0), | ||
46 | rpa_activated_time datetime, | ||
47 | rpa_get_case_from_ocr_time datetime, | ||
48 | rpa_get_case_from_oc_time datetime, | ||
49 | rpa_payment_authorize_time datetime, | ||
50 | rpa_second_eye_time datetime, | ||
51 | |||
52 | on_off bit default 1 not null, | ||
53 | ocr_auto_result_pass bit default 0 not null, | ||
54 | ocr_auto_result nvarchar(max), | ||
55 | ocr_latest_comparison_time datetime, | ||
56 | |||
57 | update_time datetime not null, | ||
58 | create_time datetime not null | ||
59 | ); | ||
60 | |||
61 | create index afc_auto_settlement_application_id_index | ||
62 | on afc_auto_settlement (application_id); | ||
63 | """ | ||
64 | |||
65 | hil_cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};', autocommit=True) | ||
66 | |||
67 | hil_cursor = hil_cnxn.cursor() | ||
68 | hil_cursor.execute(hil_sql) | ||
69 | |||
70 | hil_cursor.close() | ||
71 | hil_cnxn.close() | ||
72 | |||
73 | afc_cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};', autocommit=True) | ||
74 | |||
75 | afc_cursor = afc_cnxn.cursor() | ||
76 | afc_cursor.execute(afc_sql) | ||
77 | |||
78 | afc_cursor.close() | ||
79 | afc_cnxn.close() |
-
Please register or sign in to post a comment