Merge branch 'feature/SE3'
Showing
9 changed files
with
593 additions
and
198 deletions
... | @@ -1031,9 +1031,9 @@ JYPZ_FIELD_ORDER = (("type", "标题"), | ... | @@ -1031,9 +1031,9 @@ JYPZ_FIELD_ORDER = (("type", "标题"), |
1031 | ("buyer_id", "购买方身份证号码/营业执照号码"), | 1031 | ("buyer_id", "购买方身份证号码/营业执照号码"), |
1032 | ("vin", "车辆识别代号/车架号码"), | 1032 | ("vin", "车辆识别代号/车架号码"), |
1033 | ("price", "车辆价格"), | 1033 | ("price", "车辆价格"), |
1034 | ("date", "购买方交易日期"), | 1034 | ("buyer_date", "购买方交易日期"), |
1035 | ("date", "出卖方交易日期"), | 1035 | ("seller_date", "出卖方交易日期"), |
1036 | ("date", "经销商交易日期"), | 1036 | ("agent_date", "经销商交易日期"), |
1037 | ("stamp_signature_buyer", "购买方签字/盖章"), | 1037 | ("stamp_signature_buyer", "购买方签字/盖章"), |
1038 | ("stamp_signature_seller", "出卖方签字/盖章"), | 1038 | ("stamp_signature_seller", "出卖方签字/盖章"), |
1039 | ("stamp_signature_agent", "经销商签字/盖章"),) | 1039 | ("stamp_signature_agent", "经销商签字/盖章"),) |
... | @@ -1439,6 +1439,8 @@ SE_BS_FIELD = ['户名', '打印日期', '流水日期', '(担保人1)户名', ' | ... | @@ -1439,6 +1439,8 @@ SE_BS_FIELD = ['户名', '打印日期', '流水日期', '(担保人1)户名', ' |
1439 | SE_HMH_FIELD = ['借款人/承租人姓名', '借款人/承租人证件号', '申请号', '渠道', '签字'] | 1439 | SE_HMH_FIELD = ['借款人/承租人姓名', '借款人/承租人证件号', '申请号', '渠道', '签字'] |
1440 | SE_BD_FIELD = ['被保险人姓名', '被保险人证件号码', '车架号', '机动车损失保险金额', '第三者责任保险金额', '绝对免赔率', '保险起始日期', '保险截止日期', '保单章', '第一受益人', '保险费合计'] | 1440 | SE_BD_FIELD = ['被保险人姓名', '被保险人证件号码', '车架号', '机动车损失保险金额', '第三者责任保险金额', '绝对免赔率', '保险起始日期', '保险截止日期', '保单章', '第一受益人', '保险费合计'] |
1441 | JDMPV_VALUE = ['-', '--', '0%', '0.00', '/', '0', ''] | 1441 | JDMPV_VALUE = ['-', '--', '0%', '0.00', '/', '0', ''] |
1442 | JYPZ_TYPE_1 = ['二手车交易凭证'] | ||
1443 | JYPZ_TYPE_2 = ['BMW官方认证二手车交易凭证', '二手车交易凭证'] | ||
1442 | 1444 | ||
1443 | SE_BANK_FIELD = ['accountNo', 'bankName'] | 1445 | SE_BANK_FIELD = ['accountNo', 'bankName'] |
1444 | SE_DDA_FIELD = ['applicationId(1)', 'applicationId(2)', 'bankName', 'companyName', 'customerName', 'idNum', 'accountHolderName', 'accountNo'] | 1446 | SE_DDA_FIELD = ['applicationId(1)', 'applicationId(2)', 'bankName', 'companyName', 'customerName', 'idNum', 'accountHolderName', 'accountNo'] |
... | @@ -1582,19 +1584,21 @@ SE_HIL_CON_MAP = { | ... | @@ -1582,19 +1584,21 @@ SE_HIL_CON_MAP = { |
1582 | SE_AFC_CON_FIELD = ['合同编号-每页', '所购车辆价格-小写-重要条款', '车架号-重要条款', '贷款本金金额-重要条款', '贷款期限-重要条款', | 1584 | SE_AFC_CON_FIELD = ['合同编号-每页', '所购车辆价格-小写-重要条款', '车架号-重要条款', '贷款本金金额-重要条款', '贷款期限-重要条款', |
1583 | '车辆贷款本金金额-重要条款', '附加产品融资贷款本金总额-重要条款', '所购车辆价格', '车架号', '经销商', | 1585 | '车辆贷款本金金额-重要条款', '附加产品融资贷款本金总额-重要条款', '所购车辆价格', '车架号', '经销商', |
1584 | '贷款本金金额', '车辆贷款本金金额', '附加产品融资贷款本金总额', '贷款期限', '还款账号', '户名', '开户行', | 1586 | '贷款本金金额', '车辆贷款本金金额', '附加产品融资贷款本金总额', '贷款期限', '还款账号', '户名', '开户行', |
1585 | '还款计划表', '见证人签字', '见证人日期', 'ASP项目详情-重要条款', '购置税校验', 'ASP项目详情'] | 1587 | '还款计划表', '见证人签字', '见证人日期', 'ASP项目详情-重要条款', '购置税校验', 'ASP项目详情', |
1588 | '合同编号-每页(no-asp)', '无ASP产品'] | ||
1586 | CON_BANK_FIELD = ['还款账号', '户名', '开户行'] | 1589 | CON_BANK_FIELD = ['还款账号', '户名', '开户行'] |
1587 | 1590 | ||
1588 | # '承租人姓名', '承租人证件号码', '承租人法定代表人或授权代表' | 1591 | # '承租人姓名', '承租人证件号码', '承租人法定代表人或授权代表' |
1589 | SE_HIL_CON_1_FIELD = ['合同编号-每页', '合同编号-正文', '车辆识别代码', '车辆卖方', '车辆原始销售价格', '融资成本总额', '租期', | 1592 | SE_HIL_CON_1_FIELD = ['合同编号-每页', '合同编号-正文', '车辆识别代码', '车辆卖方', '车辆原始销售价格', '融资成本总额', '租期', |
1590 | '还款计划表', 'ASP项目详情', '购置税校验', '承租人法定代表人或授权代表', '还款账号', '户名', '开户行', | 1593 | '还款计划表', 'ASP项目详情', '购置税校验', '承租人法定代表人或授权代表', '还款账号', '户名', '开户行', |
1591 | '共同承租人法定代表人或授权代表'] | 1594 | '共同承租人法定代表人或授权代表', '无ASP产品'] |
1592 | SE_HIL_CON_2_FIELD = ['合同编号', '合同编号-正文', '车辆识别代码', '租金总额', '融资租赁期限'] | 1595 | SE_HIL_CON_2_FIELD = ['合同编号', '合同编号-正文', '车辆识别代码', '租金总额', '融资租赁期限'] |
1593 | SE_HIL_CON_3_FIELD = ['合同编号-每页', '承租人姓名', '承租人证件号码', '销售经销商', '合同编号-正文', '姓名/名称', | 1596 | SE_HIL_CON_3_FIELD = ['合同编号-每页', '承租人姓名', '承租人证件号码', '销售经销商', '合同编号-正文', '姓名/名称', |
1594 | '自然人身份证件号码/法人执照号码', '承租人签字'] | 1597 | '自然人身份证件号码/法人执照号码', '承租人签字'] |
1595 | 1598 | ||
1596 | 1599 | ||
1597 | ROLE_LIST = [ | 1600 | ROLE_LIST = [ |
1601 | # key_afc1, cdfl_key, app_type, id_idx, field_idx, is_force, e_write | ||
1598 | ('借款人签字及时间', '借款人签字及时间', 'Borrower', 0, 0, True, False), | 1602 | ('借款人签字及时间', '借款人签字及时间', 'Borrower', 0, 0, True, False), |
1599 | ('借款人姓名', '借款人姓名', 'Borrower', 0, 0, True, True), | 1603 | ('借款人姓名', '借款人姓名', 'Borrower', 0, 0, True, True), |
1600 | ('借款人证件号', '借款人证件号', 'Borrower', 0, 2, True, True), | 1604 | ('借款人证件号', '借款人证件号', 'Borrower', 0, 2, True, True), |
... | @@ -1810,14 +1814,21 @@ DDA_COMPARE_LOGIC = { | ... | @@ -1810,14 +1814,21 @@ DDA_COMPARE_LOGIC = { |
1810 | } | 1814 | } |
1811 | 1815 | ||
1812 | JYPZ_COMPARE_LOGIC = { | 1816 | JYPZ_COMPARE_LOGIC = { |
1817 | 'type': ('type', 'super_list_compare', {}, '二手车凭证类型与产品不符'), | ||
1813 | 'vinNo': ('vin', 'se_common_compare', {}, '二手车凭证车辆识别代号与系统车架号不一致'), | 1818 | 'vinNo': ('vin', 'se_common_compare', {}, '二手车凭证车辆识别代号与系统车架号不一致'), |
1814 | 'dealerName': ('authorized_dealer', 'se_common_compare', {}, '二手车凭证经销商与系统经销商不一致'), | 1819 | 'dealerName': ('authorized_dealer', 'se_common_compare', {}, '二手车凭证经销商与系统经销商不一致'), |
1815 | 'vehicleTransactionAmount': ('price', 'se_amount_compare', {}, '二手车凭证购买方交易价格与系统车辆价格不一致'), | 1820 | 'vehicleTransactionAmount': ('price', 'se_amount_compare', {}, '二手车凭证购买方交易价格与系统车辆价格不一致'), |
1816 | 'customerName': ('buyer_name', 'se_name_compare', {'is_passport': True}, '二手车凭证购买方姓名与系统主借人姓名不一致'), | 1821 | 'customerName': ('buyer_name', 'se_name_compare', {'is_passport': True}, '二手车凭证购买方姓名与系统主借人姓名不一致'), |
1817 | 'idNum': ('buyer_id', 'se_contain_compare_2', {}, '二手车凭证购买方证件号与系统主借人证件号不一致'), | 1822 | 'idNum': ('buyer_id', 'se_contain_compare_2', {}, '二手车凭证购买方证件号与系统主借人证件号不一致'), |
1818 | 'date': ('date', 'se_date_compare_2', {'three_month': True}, '二手车凭证交易日期早于submissionDate'), | 1823 | # 'date': ('date', 'se_date_compare_2', {'three_month': True}, '二手车凭证交易日期早于submissionDate'), |
1824 | 'date': ('buyer_date', 'se_jypz_date_compare', {}, '二手车交易凭证交易日期不一致或二手车凭证交易日期早于submissionDate'), | ||
1819 | } | 1825 | } |
1820 | 1826 | ||
1827 | JYPZ_DATE_FIELD_1 = 'date' | ||
1828 | JYPZ_DATE_FIELD_2 = 'buyer_date' | ||
1829 | JYPZ_DATE_FIELD_3 = 'seller_date' | ||
1830 | JYPZ_DATE_FIELD_4 = 'agent_date' | ||
1831 | |||
1821 | HMH_COMPARE_LOGIC = { | 1832 | HMH_COMPARE_LOGIC = { |
1822 | '借款人/承租人姓名': ('借款/承租人姓名', 'se_name_compare', {}, '抵押登记豁免函借款人/承租人姓名与系统不符'), | 1833 | '借款人/承租人姓名': ('借款/承租人姓名', 'se_name_compare', {}, '抵押登记豁免函借款人/承租人姓名与系统不符'), |
1823 | '借款人/承租人证件号': ('证件号码', 'se_common_compare', {}, '抵押登记豁免函借款人/承租人证件号码与系统不符'), | 1834 | '借款人/承租人证件号': ('证件号码', 'se_common_compare', {}, '抵押登记豁免函借款人/承租人证件号码与系统不符'), |
... | @@ -1911,6 +1922,9 @@ HIL_CONTRACT_1_COMPARE_LOGIC = { | ... | @@ -1911,6 +1922,9 @@ HIL_CONTRACT_1_COMPARE_LOGIC = { |
1911 | '保证人姓名2': ('保证人姓名2', 'se_name_compare', {}, '售后回租合同保证人姓名2与系统不一致'), | 1922 | '保证人姓名2': ('保证人姓名2', 'se_name_compare', {}, '售后回租合同保证人姓名2与系统不一致'), |
1912 | '保证人证件号2': ('保证人证件号2', 'se_common_compare', {}, '售后回租合同保证人证件号2与系统不一致'), | 1923 | '保证人证件号2': ('保证人证件号2', 'se_common_compare', {}, '售后回租合同保证人证件号2与系统不一致'), |
1913 | '保证人签字2': ('保证人签字2', 'se_contain_compare', {}, '售后回租合同保证人签字2与系统不一致'), | 1924 | '保证人签字2': ('保证人签字2', 'se_contain_compare', {}, '售后回租合同保证人签字2与系统不一致'), |
1925 | |||
1926 | '购置税校验': ('购置税校验', 'se_self_compare_gzs', {}, GZS_REASON_2), | ||
1927 | '无ASP产品': ('无ASP产品', 'se_self_compare_other_asp', {}, GZS_REASON_1), | ||
1914 | } | 1928 | } |
1915 | 1929 | ||
1916 | # ['合同编号', '合同编号-正文', '车辆识别代码', '租金总额', '融资租赁期限'] | 1930 | # ['合同编号', '合同编号-正文', '车辆识别代码', '租金总额', '融资租赁期限'] |
... | @@ -1943,6 +1957,8 @@ HIL_CONTRACT_3_COMPARE_LOGIC = { | ... | @@ -1943,6 +1957,8 @@ HIL_CONTRACT_3_COMPARE_LOGIC = { |
1943 | 1957 | ||
1944 | HT_COMPARE_LOGIC = { | 1958 | HT_COMPARE_LOGIC = { |
1945 | '合同编号-每页': ('合同编号-每页', 'se_list_compare', {}, '合同编号与系统不一致'), | 1959 | '合同编号-每页': ('合同编号-每页', 'se_list_compare', {}, '合同编号与系统不一致'), |
1960 | # '合同编号-每页(no-asp)': ('合同编号-每页', 'se_list_compare', {'pop_last': True}, '合同编号与系统不一致'), | ||
1961 | '合同编号-每页(no-asp)': ('合同编号-每页', 'se_list_compare', {}, '合同编号与系统不一致'), | ||
1946 | '所购车辆价格-小写-重要条款': ('所购车辆价格-小写-重要条款', 'se_amount_str_compare', {}, '合同首页中车辆价格与系统不一致'), | 1962 | '所购车辆价格-小写-重要条款': ('所购车辆价格-小写-重要条款', 'se_amount_str_compare', {}, '合同首页中车辆价格与系统不一致'), |
1947 | '车架号-重要条款': ('车架号-重要条款', 'se_common_compare', {}, '合同首页中车架号与系统不一致'), | 1963 | '车架号-重要条款': ('车架号-重要条款', 'se_common_compare', {}, '合同首页中车架号与系统不一致'), |
1948 | '贷款本金金额-重要条款': ('贷款本金金额-重要条款', 'se_amount_str_compare', {}, '合同首页中贷款本金与系统不一致'), | 1964 | '贷款本金金额-重要条款': ('贷款本金金额-重要条款', 'se_amount_str_compare', {}, '合同首页中贷款本金与系统不一致'), |
... | @@ -1988,8 +2004,12 @@ HT_COMPARE_LOGIC = { | ... | @@ -1988,8 +2004,12 @@ HT_COMPARE_LOGIC = { |
1988 | 2004 | ||
1989 | 'ASP项目详情-重要条款': ('ASP项目详情-重要条款', 'se_asp_compare', {}, '合同(重要条款)ASP名称或者金额与系统不一致'), | 2005 | 'ASP项目详情-重要条款': ('ASP项目详情-重要条款', 'se_asp_compare', {}, '合同(重要条款)ASP名称或者金额与系统不一致'), |
1990 | 'ASP项目详情': ('ASP项目详情', 'se_asp_compare', {}, '合同ASP名称或者金额与系统不一致'), | 2006 | 'ASP项目详情': ('ASP项目详情', 'se_asp_compare', {}, '合同ASP名称或者金额与系统不一致'), |
2007 | |||
2008 | '购置税校验': ('购置税校验', 'se_self_compare_gzs', {}, GZS_REASON_2), | ||
2009 | '无ASP产品': ('无ASP产品', 'se_self_compare_other_asp', {}, GZS_REASON_1), | ||
1991 | } | 2010 | } |
1992 | 2011 | ||
2012 | AFC_HT_DATE_FIELDS = ['主借人日期', '共借人日期', '保证人日期1', '保证人日期2'] | ||
1993 | 2013 | ||
1994 | # MVC_OCR_FIELD = 'mvc_ocr' | 2014 | # MVC_OCR_FIELD = 'mvc_ocr' |
1995 | 2015 | ... | ... |
... | @@ -919,6 +919,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -919,6 +919,7 @@ class Command(BaseCommand, LoggerMixin): |
919 | 'role': bs_info.get('role', ''), | 919 | 'role': bs_info.get('role', ''), |
920 | 'print_time': print_date, | 920 | 'print_time': print_date, |
921 | 'timedelta': bs_info.get('timedelta', ''), | 921 | 'timedelta': bs_info.get('timedelta', ''), |
922 | 'verify': bs_info.get('verify', True) | ||
922 | } | 923 | } |
923 | ) | 924 | ) |
924 | return res | 925 | return res |
... | @@ -928,12 +929,14 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -928,12 +929,14 @@ class Command(BaseCommand, LoggerMixin): |
928 | if classify == consts.CONTRACT_CLASSIFY: | 929 | if classify == consts.CONTRACT_CLASSIFY: |
929 | res = {} | 930 | res = {} |
930 | is_asp = page_info_dict.get(consts.ASP_KEY, False) | 931 | is_asp = page_info_dict.get(consts.ASP_KEY, False) |
932 | # is_asp = True | ||
931 | for key, (pno_not_asp, pno_asp, key1, key2) in consts.SE_AFC_CON_MAP.items(): | 933 | for key, (pno_not_asp, pno_asp, key1, key2) in consts.SE_AFC_CON_MAP.items(): |
932 | pno = pno_asp if is_asp else pno_not_asp | 934 | pno = pno_asp if is_asp else pno_not_asp |
933 | if pno is None: | 935 | if pno is None: |
934 | if isinstance(pno_asp, int): | 936 | if isinstance(pno_asp, int): |
935 | continue | 937 | continue |
936 | end_idx = 9 if is_asp else 8 | 938 | end_idx = 9 |
939 | # end_idx = 9 if is_asp else 8 | ||
937 | for i in range(1, end_idx): | 940 | for i in range(1, end_idx): |
938 | res.setdefault(key, list()).append(page_info_dict.get(str(i), {}).get(key1, '')) | 941 | res.setdefault(key, list()).append(page_info_dict.get(str(i), {}).get(key1, '')) |
939 | elif key2 is None: | 942 | elif key2 is None: | ... | ... |
... | @@ -882,3 +882,26 @@ class AFCAutoSettlement(models.Model): | ... | @@ -882,3 +882,26 @@ class AFCAutoSettlement(models.Model): |
882 | situ_db_label = 'afc' | 882 | situ_db_label = 'afc' |
883 | 883 | ||
884 | 884 | ||
885 | class HILbankVerification(models.Model): | ||
886 | id = models.AutoField(primary_key=True, verbose_name="id") # 主键 | ||
887 | application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引 | ||
888 | on_off = models.BooleanField(default=True, verbose_name="是否有效") | ||
889 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') | ||
890 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | ||
891 | |||
892 | class Meta: | ||
893 | managed = False | ||
894 | db_table = 'hil_bank_verification' | ||
895 | |||
896 | |||
897 | class AFCbankVerification(models.Model): | ||
898 | id = models.AutoField(primary_key=True, verbose_name="id") # 主键 | ||
899 | application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引 | ||
900 | on_off = models.BooleanField(default=True, verbose_name="是否有效") | ||
901 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') | ||
902 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | ||
903 | |||
904 | class Meta: | ||
905 | managed = False | ||
906 | db_table = 'afc_bank_verification' | ||
907 | situ_db_label = 'afc' | ... | ... |
... | @@ -392,7 +392,9 @@ class BSWorkbook(Workbook): | ... | @@ -392,7 +392,9 @@ class BSWorkbook(Workbook): |
392 | cell.fill = self.amount_fill | 392 | cell.fill = self.amount_fill |
393 | for cell in ms[4]: | 393 | for cell in ms[4]: |
394 | cell.fill = self.amount_fill | 394 | cell.fill = self.amount_fill |
395 | return ms, timedelta | 395 | |
396 | verify_res = False if len(metadata_highlight_row) > 0 or len(verify_highlight_row) > 0 else True | ||
397 | return ms, timedelta, verify_res | ||
396 | 398 | ||
397 | @staticmethod | 399 | @staticmethod |
398 | def amount_format(amount_str): | 400 | def amount_format(amount_str): |
... | @@ -723,20 +725,21 @@ class BSWorkbook(Workbook): | ... | @@ -723,20 +725,21 @@ class BSWorkbook(Workbook): |
723 | # 2.元信息提取表 | 725 | # 2.元信息提取表 |
724 | confidence = self.get_confidence(max_find_count, classify) | 726 | confidence = self.get_confidence(max_find_count, classify) |
725 | is_verify_classify = classify in consts.BS_VERIFY_CLASSIFY | 727 | is_verify_classify = classify in consts.BS_VERIFY_CLASSIFY |
726 | ms, timedelta = self.build_meta_sheet(role_name, | 728 | ms, timedelta, verify_res = self.build_meta_sheet(role_name, |
727 | new_card, | 729 | new_card, |
728 | confidence, | 730 | confidence, |
729 | summary.get('code'), | 731 | summary.get('code'), |
730 | summary.get('verify'), | 732 | summary.get('verify'), |
731 | summary.get('print_time'), | 733 | summary.get('print_time'), |
732 | start_date, | 734 | start_date, |
733 | end_date, | 735 | end_date, |
734 | res_count_tuple, | 736 | res_count_tuple, |
735 | is_verify_classify, | 737 | is_verify_classify, |
736 | metadata) | 738 | metadata) |
737 | 739 | ||
738 | summary['timedelta'] = timedelta | 740 | summary['timedelta'] = timedelta |
739 | summary['end_date'] = end_date | 741 | summary['end_date'] = end_date |
742 | summary['verify'] = verify_res | ||
740 | 743 | ||
741 | # 3.创建月份表、提取/高亮关键行 | 744 | # 3.创建月份表、提取/高亮关键行 |
742 | # 倒序处理 | 745 | # 倒序处理 | ... | ... |
... | @@ -42,6 +42,8 @@ from .models import ( | ... | @@ -42,6 +42,8 @@ from .models import ( |
42 | HILSECompareResultRecord, | 42 | HILSECompareResultRecord, |
43 | HILAutoSettlement, | 43 | HILAutoSettlement, |
44 | AFCAutoSettlement, | 44 | AFCAutoSettlement, |
45 | HILbankVerification, | ||
46 | AFCbankVerification, | ||
45 | ) | 47 | ) |
46 | from .named_enum import ErrorType, AutoResult, WholeResult, RPAResult | 48 | from .named_enum import ErrorType, AutoResult, WholeResult, RPAResult |
47 | from .mixins import DocHandler, MPOSHandler | 49 | from .mixins import DocHandler, MPOSHandler |
... | @@ -112,7 +114,7 @@ se_bank_args = { | ... | @@ -112,7 +114,7 @@ se_bank_args = { |
112 | 'applicantType': fields.Str(required=True, validate=validate.Length(max=16)), | 114 | 'applicantType': fields.Str(required=True, validate=validate.Length(max=16)), |
113 | 'accountHolderName': fields.Str(required=True, validate=validate.Length(max=256)), | 115 | 'accountHolderName': fields.Str(required=True, validate=validate.Length(max=256)), |
114 | 'accountNo': fields.Str(required=True, validate=validate.Length(max=256)), | 116 | 'accountNo': fields.Str(required=True, validate=validate.Length(max=256)), |
115 | 'bankVerificationStatus': fields.Str(required=False, validate=validate.Length(max=16)), | 117 | 'bankVerificationStatus': fields.Str(required=False, validate=validate.Length(max=128)), |
116 | 'isAllDocUploaded': fields.Boolean(required=False) | 118 | 'isAllDocUploaded': fields.Boolean(required=False) |
117 | } | 119 | } |
118 | 120 | ||
... | @@ -249,10 +251,10 @@ applicant_data_args = { | ... | @@ -249,10 +251,10 @@ applicant_data_args = { |
249 | # 'coApplicantName': fields.Str(required=True, validate=validate.Length(max=16)), | 251 | # 'coApplicantName': fields.Str(required=True, validate=validate.Length(max=16)), |
250 | # 'guarantor1Name': fields.Str(required=True, validate=validate.Length(max=16)), | 252 | # 'guarantor1Name': fields.Str(required=True, validate=validate.Length(max=16)), |
251 | # 'guarantor2Name': fields.Str(required=True, validate=validate.Length(max=16)), | 253 | # 'guarantor2Name': fields.Str(required=True, validate=validate.Length(max=16)), |
252 | 'mainApplicantName': fields.Str(required=True), | 254 | 'mainApplicantName': fields.Str(required=False), |
253 | 'coApplicantName': fields.Str(required=True), | 255 | 'coApplicantName': fields.Str(required=False), |
254 | 'guarantor1Name': fields.Str(required=True), | 256 | 'guarantor1Name': fields.Str(required=False), |
255 | 'guarantor2Name': fields.Str(required=True), | 257 | 'guarantor2Name': fields.Str(required=False), |
256 | } | 258 | } |
257 | 259 | ||
258 | document_args = { | 260 | document_args = { |
... | @@ -267,7 +269,7 @@ document_args = { | ... | @@ -267,7 +269,7 @@ document_args = { |
267 | 269 | ||
268 | doc_upload_args = { | 270 | doc_upload_args = { |
269 | 'applicationData': fields.Nested(application_data_args, required=True), | 271 | 'applicationData': fields.Nested(application_data_args, required=True), |
270 | 'applicantData': fields.Nested(applicant_data_args, required=True), | 272 | 'applicantData': fields.Nested(applicant_data_args, required=False), |
271 | 'document': fields.Nested(document_args, required=True), | 273 | 'document': fields.Nested(document_args, required=True), |
272 | } | 274 | } |
273 | 275 | ||
... | @@ -748,61 +750,26 @@ class SECompareView(GenericView): | ... | @@ -748,61 +750,26 @@ class SECompareView(GenericView): |
748 | @use_args(se_compare_args, location='data') | 750 | @use_args(se_compare_args, location='data') |
749 | def post(self, request, args): | 751 | def post(self, request, args): |
750 | # 存库 | 752 | # 存库 |
751 | # content = args.get('content', {}) | 753 | content = args.get('content', {}) |
752 | # business_type = content.get('applicationEntity') | 754 | business_type = content.get('applicationEntity') |
753 | # application_id = content.get('applicationId') | 755 | application_id = content.get('applicationId') |
754 | # is_auto = content.get('isAutoSettlement', False) | 756 | bank_verify = content.get('bankInfo', {}).get('bankVerificationStatus', '') |
755 | # | 757 | |
756 | # auto_class = HILAutoSettlement if business_type in consts.HIL_SET else AFCAutoSettlement | 758 | bank_class = HILbankVerification if business_type in consts.HIL_SET else AFCbankVerification |
757 | # auto_obj = auto_class.objects.filter(application_id=application_id).first() | 759 | bank_obj = bank_class.objects.filter(application_id=application_id).first() |
758 | # if is_auto: | 760 | |
759 | # # 加入优先级队列 | 761 | if bank_obj is None and bank_verify == 'PASS': |
760 | # PriorityApplication.objects.update_or_create( | 762 | bank_class.objects.create( |
761 | # application_id=application_id, defaults={'on_off': True}) | 763 | application_id=application_id, |
762 | # # 加入auto表 | 764 | ) |
763 | # if auto_obj is None: | 765 | elif bank_obj is not None and bank_verify == 'PASS' and bank_obj.on_off is False: |
764 | # auto_class.objects.create( | 766 | bank_obj.on_off = True |
765 | # application_id=application_id, | 767 | bank_obj.save() |
766 | # ) | 768 | elif bank_obj is not None and bank_verify != 'PASS' and bank_obj.on_off is True: |
767 | # elif auto_obj.on_off is False: | 769 | bank_obj.on_off = False |
768 | # auto_obj.on_off = True | 770 | bank_obj.save() |
769 | # auto_obj.save() | ||
770 | # else: | ||
771 | # if auto_obj is not None and auto_obj.on_off is True: | ||
772 | # auto_obj.on_off = False | ||
773 | # auto_obj.save() | ||
774 | return response.ok() | ||
775 | 771 | ||
776 | # uniq_seq = content.get('uniqSeq') | 772 | return response.ok() |
777 | # business_type = content.get('applicationEntity') | ||
778 | # application_id = content.get('applicationId') | ||
779 | # | ||
780 | # individual_cus_info = json.dumps(content.get('individualCusInfo')) | ||
781 | # vehicle_info = json.dumps(content.get('vehicleInfo')) | ||
782 | # insurance_info = json.dumps(content.get('insuranceInfo')) | ||
783 | # bank_info = json.dumps(content.get('bankInfo')) | ||
784 | # quotationt_info = json.dumps(content.get('quotationtInfo')) | ||
785 | # corporate_cus_info = json.dumps(content.get('corporateCusInfo')) if isinstance( | ||
786 | # content.get('corporateCusInfo'), dict) else None | ||
787 | |||
788 | # comparison_class = HILSEComparisonInfo if business_type in consts.HIL_SET else AFCSEComparisonInfo | ||
789 | # comparison_class.objects.create( | ||
790 | # uniq_seq=uniq_seq, | ||
791 | # application_id=application_id, | ||
792 | # application_version=content.get('applicationVersion'), | ||
793 | # customer_type=content.get('customerType'), | ||
794 | # first_submmison_date=content.get('firstSubmmisonDate'), | ||
795 | # property_doc_policy=content.get('propertyDocumentPolicy', None), | ||
796 | # individual_cus_info=individual_cus_info, | ||
797 | # corporate_cus_info=corporate_cus_info, | ||
798 | # vehicle_info=vehicle_info, | ||
799 | # insurance_info=insurance_info, | ||
800 | # bank_info=bank_info, | ||
801 | # quotationt_info=quotationt_info | ||
802 | # ) | ||
803 | # 触发比对 | ||
804 | # compare.apply_async((application_id, business_type, uniq_seq, None, False, False), | ||
805 | # queue='queue_compare') | ||
806 | 773 | ||
807 | post.openapi_doc = ''' | 774 | post.openapi_doc = ''' |
808 | tags: [info] | 775 | tags: [info] | ... | ... |
... | @@ -29,6 +29,8 @@ from apps.doc.models import ( | ... | @@ -29,6 +29,8 @@ from apps.doc.models import ( |
29 | HILCACompareResult, | 29 | HILCACompareResult, |
30 | HILAutoSettlement, | 30 | HILAutoSettlement, |
31 | AFCAutoSettlement, | 31 | AFCAutoSettlement, |
32 | HILbankVerification, | ||
33 | AFCbankVerification, | ||
32 | ) | 34 | ) |
33 | from apps.doc import consts | 35 | from apps.doc import consts |
34 | from apps.doc.ocr.gcap import gcap | 36 | from apps.doc.ocr.gcap import gcap |
... | @@ -872,7 +874,7 @@ def ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res | ... | @@ -872,7 +874,7 @@ def ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res |
872 | traceback.format_exc())) | 874 | traceback.format_exc())) |
873 | 875 | ||
874 | 876 | ||
875 | def get_se_cms_compare_info_auto(last_obj, application_entity, auto=True): | 877 | def get_se_cms_compare_info_auto(last_obj, application_entity, auto=True, ignore_bank=False): |
876 | cms_info = json.loads(last_obj.content) | 878 | cms_info = json.loads(last_obj.content) |
877 | 879 | ||
878 | compare_info = {} | 880 | compare_info = {} |
... | @@ -1062,7 +1064,7 @@ def get_se_cms_compare_info_auto(last_obj, application_entity, auto=True): | ... | @@ -1062,7 +1064,7 @@ def get_se_cms_compare_info_auto(last_obj, application_entity, auto=True): |
1062 | # jypz_field_input.append(('dealerName', dealer_name)) | 1064 | # jypz_field_input.append(('dealerName', dealer_name)) |
1063 | # jypz_field_input.append(('vinNo', vin_no)) | 1065 | # jypz_field_input.append(('vinNo', vin_no)) |
1064 | # jypz_field_input.append(('vehicleTransactionAmount', amount)) | 1066 | # jypz_field_input.append(('vehicleTransactionAmount', amount)) |
1065 | # jypz_field_input.append((consts.SE_GB_USED_FIELD[-1], first_submission_date)) | 1067 | # jypz_field_input.append((consts.SE_GB_USED_FIELD[2], first_submission_date)) |
1066 | # | 1068 | # |
1067 | # vehicle_info[consts.MVC_EN] = gb_field_input | 1069 | # vehicle_info[consts.MVC_EN] = gb_field_input |
1068 | # vehicle_info[consts.MVC34_EN] = gb34_field_input | 1070 | # vehicle_info[consts.MVC34_EN] = gb34_field_input |
... | @@ -1083,7 +1085,7 @@ def get_se_cms_compare_info_auto(last_obj, application_entity, auto=True): | ... | @@ -1083,7 +1085,7 @@ def get_se_cms_compare_info_auto(last_obj, application_entity, auto=True): |
1083 | 1085 | ||
1084 | if isinstance(company_info, tuple) and company_info[0] == account_holder_name: | 1086 | if isinstance(company_info, tuple) and company_info[0] == account_holder_name: |
1085 | pass | 1087 | pass |
1086 | else: | 1088 | elif not ignore_bank: |
1087 | bank_field_input = [ | 1089 | bank_field_input = [ |
1088 | ('accountNo', account_no), | 1090 | ('accountNo', account_no), |
1089 | ('bankName', bank_name), | 1091 | ('bankName', bank_name), |
... | @@ -1158,20 +1160,17 @@ def get_se_cms_compare_info_auto(last_obj, application_entity, auto=True): | ... | @@ -1158,20 +1160,17 @@ def get_se_cms_compare_info_auto(last_obj, application_entity, auto=True): |
1158 | 1160 | ||
1159 | # ASP ------------------------------------------------------------------------------------------------------- | 1161 | # ASP ------------------------------------------------------------------------------------------------------- |
1160 | asp_list = [] | 1162 | asp_list = [] |
1161 | gzs_status = consts.GZS_STATUS[1] | ||
1162 | gzs_list = [gzs_status] | ||
1163 | gzs_price = '0.00' | ||
1164 | is_asp = False | 1163 | is_asp = False |
1165 | # insurance_price = None | 1164 | insurance_price = None |
1165 | gzs_price = None | ||
1166 | have_other_asp = False | ||
1167 | fin_total = 0 | ||
1166 | if str(cms_info.get('financialInformation', {}).get('associatedServicePrincipal', '0.00')) != '0.00': | 1168 | if str(cms_info.get('financialInformation', {}).get('associatedServicePrincipal', '0.00')) != '0.00': |
1167 | is_asp = True | 1169 | is_asp = True |
1168 | # for asp_info in cms_info.get('associatedServices', []): | 1170 | # for asp_info in cms_info.get('associatedServices', []): |
1169 | for asp_info in cms_info.get('associatedServices', {}).get('SubassociatedServices', []): | 1171 | for asp_info in cms_info.get('associatedServices', {}).get('SubassociatedServices', []): |
1170 | tmp_asp_name = asp_info.get('associatedServices') | 1172 | tmp_asp_name = asp_info.get('associatedServices') |
1171 | if isinstance(tmp_asp_name, str) and len(tmp_asp_name) > 0: | 1173 | if isinstance(tmp_asp_name, str) and len(tmp_asp_name) > 0: |
1172 | if gzs_status == consts.GZS_STATUS[1] and tmp_asp_name.find(consts.GZS_NAME) != -1: | ||
1173 | gzs_status = consts.GZS_STATUS[2] | ||
1174 | gzs_price = asp_info.get('price', '0.00') | ||
1175 | asp_list.append( | 1174 | asp_list.append( |
1176 | ( | 1175 | ( |
1177 | tmp_asp_name, | 1176 | tmp_asp_name, |
... | @@ -1179,17 +1178,16 @@ def get_se_cms_compare_info_auto(last_obj, application_entity, auto=True): | ... | @@ -1179,17 +1178,16 @@ def get_se_cms_compare_info_auto(last_obj, application_entity, auto=True): |
1179 | asp_info.get('financed', '0.00') | 1178 | asp_info.get('financed', '0.00') |
1180 | ) | 1179 | ) |
1181 | ) | 1180 | ) |
1181 | fin_total += float(asp_info.get('financed', '0.00')) | ||
1182 | # 购置税 | ||
1183 | if tmp_asp_name.find(consts.GZS_NAME) != -1: | ||
1184 | gzs_price = asp_info.get('price', '0.00') | ||
1182 | # 保单费合计 | 1185 | # 保单费合计 |
1183 | # if tmp_asp_name.find('机动车辆保险') != -1: | 1186 | elif tmp_asp_name.find('机动车辆保险') != -1: |
1184 | # insurance_price = asp_info.get('price', '0.00') | 1187 | insurance_price = asp_info.get('price', '0.00') |
1185 | 1188 | else: | |
1186 | fin_total = 0 | 1189 | have_other_asp = True |
1187 | # fin_total_tmp = cms_info.get('associatedServices', {}).get('financed total', '0.00') | 1190 | |
1188 | # fin_total = '0.00' if fin_total_tmp.strip() == '' else fin_total_tmp | ||
1189 | for asp_name, _, asp_fin in asp_list: | ||
1190 | if gzs_status == consts.GZS_STATUS[2] and asp_name.find(consts.GZS_NAME) == -1: | ||
1191 | gzs_status = consts.GZS_STATUS[0] | ||
1192 | fin_total += float(asp_fin) | ||
1193 | asp_list.append( | 1191 | asp_list.append( |
1194 | ( | 1192 | ( |
1195 | consts.ASP_SUM_NAME, | 1193 | consts.ASP_SUM_NAME, |
... | @@ -1199,12 +1197,14 @@ def get_se_cms_compare_info_auto(last_obj, application_entity, auto=True): | ... | @@ -1199,12 +1197,14 @@ def get_se_cms_compare_info_auto(last_obj, application_entity, auto=True): |
1199 | ) | 1197 | ) |
1200 | ) | 1198 | ) |
1201 | 1199 | ||
1202 | # CMS Vehicle Price / 1.13 * 10 % | 1200 | # CMS Vehicle Price / 1.13 * 10 % |
1203 | gzs_list = [gzs_status] | 1201 | if isinstance(gzs_price, str): |
1204 | if gzs_status != consts.GZS_STATUS[1]: | 1202 | try: |
1205 | gzs_value = float(amount) * 0.1 / 1.13 | 1203 | tmp_gzs_list = [float(amount) * 0.1 / 1.13, float(gzs_price)] |
1206 | gzs_list.append(gzs_value) | 1204 | except Exception as e: |
1207 | gzs_list.append(float(gzs_price)) | 1205 | tmp_gzs_list = [amount, gzs_price] |
1206 | else: | ||
1207 | tmp_gzs_list = [amount, ] | ||
1208 | 1208 | ||
1209 | # 保单 ----------------------------------------------------------------------------------------------------------- | 1209 | # 保单 ----------------------------------------------------------------------------------------------------------- |
1210 | # is_insurance = 0 | 1210 | # is_insurance = 0 |
... | @@ -1272,8 +1272,15 @@ def get_se_cms_compare_info_auto(last_obj, application_entity, auto=True): | ... | @@ -1272,8 +1272,15 @@ def get_se_cms_compare_info_auto(last_obj, application_entity, auto=True): |
1272 | ] | 1272 | ] |
1273 | 1273 | ||
1274 | if is_asp: | 1274 | if is_asp: |
1275 | # asp各项 | ||
1275 | hil_contract_1_input.append((consts.SE_HIL_CON_1_FIELD[8], asp_list)) | 1276 | hil_contract_1_input.append((consts.SE_HIL_CON_1_FIELD[8], asp_list)) |
1276 | hil_contract_1_input.append((consts.SE_HIL_CON_1_FIELD[9], gzs_list)) | 1277 | # 购置税校验 |
1278 | if isinstance(gzs_price, str): | ||
1279 | hil_contract_1_input.append( | ||
1280 | (consts.SE_HIL_CON_1_FIELD[9], tmp_gzs_list)) | ||
1281 | # 非购置税非车辆保险的其他asp | ||
1282 | if have_other_asp: | ||
1283 | hil_contract_1_input.append((consts.SE_HIL_CON_1_FIELD[15], 'N')) | ||
1277 | 1284 | ||
1278 | if isinstance(company_info, tuple): | 1285 | if isinstance(company_info, tuple): |
1279 | if is_cdfl: | 1286 | if is_cdfl: |
... | @@ -1343,8 +1350,17 @@ def get_se_cms_compare_info_auto(last_obj, application_entity, auto=True): | ... | @@ -1343,8 +1350,17 @@ def get_se_cms_compare_info_auto(last_obj, application_entity, auto=True): |
1343 | else: | 1350 | else: |
1344 | # AFC合同------------------------------------------------------------------------------------------------------ | 1351 | # AFC合同------------------------------------------------------------------------------------------------------ |
1345 | vehicle_principal_str = str(cms_info.get('financialInformation', {}).get('vehiclePrincipal', '0.0')) | 1352 | vehicle_principal_str = str(cms_info.get('financialInformation', {}).get('vehiclePrincipal', '0.0')) |
1346 | afc_contract_input = [ | 1353 | |
1347 | (consts.SE_AFC_CON_FIELD[0], full_no), | 1354 | if is_asp: |
1355 | afc_contract_input = [ | ||
1356 | (consts.SE_AFC_CON_FIELD[0], full_no), | ||
1357 | ] | ||
1358 | else: | ||
1359 | afc_contract_input = [ | ||
1360 | (consts.SE_AFC_CON_FIELD[23], full_no), | ||
1361 | ] | ||
1362 | |||
1363 | afc_contract_input.extend([ | ||
1348 | (consts.SE_AFC_CON_FIELD[1], amount), | 1364 | (consts.SE_AFC_CON_FIELD[1], amount), |
1349 | (consts.SE_AFC_CON_FIELD[2], vin_no), | 1365 | (consts.SE_AFC_CON_FIELD[2], vin_no), |
1350 | (consts.SE_AFC_CON_FIELD[3], str(cms_info.get('financialInformation', {}).get('originationPrincipal', '0.0'))), | 1366 | (consts.SE_AFC_CON_FIELD[3], str(cms_info.get('financialInformation', {}).get('originationPrincipal', '0.0'))), |
... | @@ -1362,12 +1378,18 @@ def get_se_cms_compare_info_auto(last_obj, application_entity, auto=True): | ... | @@ -1362,12 +1378,18 @@ def get_se_cms_compare_info_auto(last_obj, application_entity, auto=True): |
1362 | (consts.SE_AFC_CON_FIELD[15], account_holder_name), | 1378 | (consts.SE_AFC_CON_FIELD[15], account_holder_name), |
1363 | (consts.SE_AFC_CON_FIELD[16], bank_name), | 1379 | (consts.SE_AFC_CON_FIELD[16], bank_name), |
1364 | (consts.SE_AFC_CON_FIELD[17], schedule_list_str), | 1380 | (consts.SE_AFC_CON_FIELD[17], schedule_list_str), |
1365 | ] | 1381 | ]) |
1366 | 1382 | ||
1367 | if is_asp: | 1383 | if is_asp: |
1368 | afc_contract_input.append((consts.SE_AFC_CON_FIELD[20], asp_list)) | 1384 | afc_contract_input.append((consts.SE_AFC_CON_FIELD[20], asp_list)) |
1369 | afc_contract_input.append((consts.SE_AFC_CON_FIELD[22], asp_list)) | 1385 | afc_contract_input.append((consts.SE_AFC_CON_FIELD[22], asp_list)) |
1370 | afc_contract_input.append((consts.SE_AFC_CON_FIELD[21], gzs_list)) | 1386 | # 购置税校验 |
1387 | if isinstance(gzs_price, str): | ||
1388 | afc_contract_input.append( | ||
1389 | (consts.SE_AFC_CON_FIELD[21], tmp_gzs_list)) | ||
1390 | # 非购置税非车辆保险的其他asp | ||
1391 | if have_other_asp: | ||
1392 | afc_contract_input.append((consts.SE_AFC_CON_FIELD[24], 'N')) | ||
1371 | else: | 1393 | else: |
1372 | afc_contract_input.pop(5) | 1394 | afc_contract_input.pop(5) |
1373 | afc_contract_input.pop(5) | 1395 | afc_contract_input.pop(5) |
... | @@ -1399,7 +1421,7 @@ def get_se_cms_compare_info_auto(last_obj, application_entity, auto=True): | ... | @@ -1399,7 +1421,7 @@ def get_se_cms_compare_info_auto(last_obj, application_entity, auto=True): |
1399 | return compare_info, cms_info.get('autoApprovedDetails', {}).get('aaType', ''), is_gsyh | 1421 | return compare_info, cms_info.get('autoApprovedDetails', {}).get('aaType', ''), is_gsyh |
1400 | 1422 | ||
1401 | 1423 | ||
1402 | def get_se_cms_compare_info(last_obj, application_entity, detect_list, auto=False): | 1424 | def get_se_cms_compare_info(last_obj, application_entity, detect_list, auto=False, ignore_bank=False): |
1403 | cms_info = json.loads(last_obj.content) | 1425 | cms_info = json.loads(last_obj.content) |
1404 | 1426 | ||
1405 | compare_info = {} | 1427 | compare_info = {} |
... | @@ -1522,6 +1544,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list, auto=Fals | ... | @@ -1522,6 +1544,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list, auto=Fals |
1522 | # dda_num = '、'.join(dda_num_list) | 1544 | # dda_num = '、'.join(dda_num_list) |
1523 | # del main_role_info | 1545 | # del main_role_info |
1524 | 1546 | ||
1547 | fp_group = cms_info.get('fpGroup', '') | ||
1525 | vehicle_info = {} | 1548 | vehicle_info = {} |
1526 | vehicle_field_input = [] | 1549 | vehicle_field_input = [] |
1527 | vehicle_status = cms_info.get('vehicleStatus', '') | 1550 | vehicle_status = cms_info.get('vehicleStatus', '') |
... | @@ -1583,7 +1606,11 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list, auto=Fals | ... | @@ -1583,7 +1606,11 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list, auto=Fals |
1583 | jypz_field_input.append(('dealerName', dealer_name)) | 1606 | jypz_field_input.append(('dealerName', dealer_name)) |
1584 | jypz_field_input.append(('vinNo', vin_no)) | 1607 | jypz_field_input.append(('vinNo', vin_no)) |
1585 | jypz_field_input.append(('vehicleTransactionAmount', amount)) | 1608 | jypz_field_input.append(('vehicleTransactionAmount', amount)) |
1586 | jypz_field_input.append((consts.SE_GB_USED_FIELD[-1], first_submission_date)) | 1609 | jypz_field_input.append((consts.SE_GB_USED_FIELD[2], first_submission_date)) |
1610 | if fp_group.find('Non OCU Product Group') != -1: | ||
1611 | jypz_field_input.append(('type', consts.JYPZ_TYPE_1)) | ||
1612 | elif fp_group.find('OCU Product Group') != -1: | ||
1613 | jypz_field_input.append(('type', consts.JYPZ_TYPE_2)) | ||
1587 | 1614 | ||
1588 | vehicle_info[consts.MVC_EN] = gb_field_input | 1615 | vehicle_info[consts.MVC_EN] = gb_field_input |
1589 | vehicle_info[consts.MVC34_EN] = gb34_field_input | 1616 | vehicle_info[consts.MVC34_EN] = gb34_field_input |
... | @@ -1604,7 +1631,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list, auto=Fals | ... | @@ -1604,7 +1631,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list, auto=Fals |
1604 | 1631 | ||
1605 | if isinstance(company_info, tuple) and company_info[0] == account_holder_name: | 1632 | if isinstance(company_info, tuple) and company_info[0] == account_holder_name: |
1606 | pass | 1633 | pass |
1607 | else: | 1634 | elif not ignore_bank: |
1608 | bank_field_input = [ | 1635 | bank_field_input = [ |
1609 | ('accountNo', account_no), | 1636 | ('accountNo', account_no), |
1610 | ('bankName', bank_name), | 1637 | ('bankName', bank_name), |
... | @@ -1679,20 +1706,16 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list, auto=Fals | ... | @@ -1679,20 +1706,16 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list, auto=Fals |
1679 | 1706 | ||
1680 | # ASP ------------------------------------------------------------------------------------------------------- | 1707 | # ASP ------------------------------------------------------------------------------------------------------- |
1681 | asp_list = [] | 1708 | asp_list = [] |
1682 | gzs_status = consts.GZS_STATUS[1] | ||
1683 | gzs_list = [gzs_status] | ||
1684 | gzs_price = '0.00' | ||
1685 | is_asp = False | 1709 | is_asp = False |
1686 | insurance_price = None | 1710 | insurance_price = None |
1711 | gzs_price = None | ||
1712 | have_other_asp = False | ||
1713 | fin_total = 0 | ||
1687 | if str(cms_info.get('financialInformation', {}).get('associatedServicePrincipal', '0.00')) != '0.00': | 1714 | if str(cms_info.get('financialInformation', {}).get('associatedServicePrincipal', '0.00')) != '0.00': |
1688 | is_asp = True | 1715 | is_asp = True |
1689 | # for asp_info in cms_info.get('associatedServices', []): | ||
1690 | for asp_info in cms_info.get('associatedServices', {}).get('SubassociatedServices', []): | 1716 | for asp_info in cms_info.get('associatedServices', {}).get('SubassociatedServices', []): |
1691 | tmp_asp_name = asp_info.get('associatedServices') | 1717 | tmp_asp_name = asp_info.get('associatedServices') |
1692 | if isinstance(tmp_asp_name, str) and len(tmp_asp_name) > 0: | 1718 | if isinstance(tmp_asp_name, str) and len(tmp_asp_name) > 0: |
1693 | if gzs_status == consts.GZS_STATUS[1] and tmp_asp_name.find(consts.GZS_NAME) != -1: | ||
1694 | gzs_status = consts.GZS_STATUS[2] | ||
1695 | gzs_price = asp_info.get('price', '0.00') | ||
1696 | asp_list.append( | 1719 | asp_list.append( |
1697 | ( | 1720 | ( |
1698 | tmp_asp_name, | 1721 | tmp_asp_name, |
... | @@ -1700,17 +1723,16 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list, auto=Fals | ... | @@ -1700,17 +1723,16 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list, auto=Fals |
1700 | asp_info.get('financed', '0.00') | 1723 | asp_info.get('financed', '0.00') |
1701 | ) | 1724 | ) |
1702 | ) | 1725 | ) |
1726 | fin_total += float(asp_info.get('financed', '0.00')) | ||
1727 | # 购置税 | ||
1728 | if tmp_asp_name.find(consts.GZS_NAME) != -1: | ||
1729 | gzs_price = asp_info.get('price', '0.00') | ||
1703 | # 保单费合计 | 1730 | # 保单费合计 |
1704 | if tmp_asp_name.find('机动车辆保险') != -1: | 1731 | elif tmp_asp_name.find('机动车辆保险') != -1: |
1705 | insurance_price = asp_info.get('price', '0.00') | 1732 | insurance_price = asp_info.get('price', '0.00') |
1733 | else: | ||
1734 | have_other_asp = True | ||
1706 | 1735 | ||
1707 | fin_total = 0 | ||
1708 | # fin_total_tmp = cms_info.get('associatedServices', {}).get('financed total', '0.00') | ||
1709 | # fin_total = '0.00' if fin_total_tmp.strip() == '' else fin_total_tmp | ||
1710 | for asp_name, _, asp_fin in asp_list: | ||
1711 | if gzs_status == consts.GZS_STATUS[2] and asp_name.find(consts.GZS_NAME) == -1: | ||
1712 | gzs_status = consts.GZS_STATUS[0] | ||
1713 | fin_total += float(asp_fin) | ||
1714 | asp_list.append( | 1736 | asp_list.append( |
1715 | ( | 1737 | ( |
1716 | consts.ASP_SUM_NAME, | 1738 | consts.ASP_SUM_NAME, |
... | @@ -1720,19 +1742,20 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list, auto=Fals | ... | @@ -1720,19 +1742,20 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list, auto=Fals |
1720 | ) | 1742 | ) |
1721 | ) | 1743 | ) |
1722 | 1744 | ||
1723 | # CMS Vehicle Price / 1.13 * 10 % | 1745 | # CMS Vehicle Price / 1.13 * 10 % |
1724 | gzs_list = [gzs_status] | 1746 | if isinstance(gzs_price, str): |
1725 | if gzs_status != consts.GZS_STATUS[1]: | 1747 | try: |
1726 | gzs_value = float(amount) * 0.1 / 1.13 | 1748 | tmp_gzs_list = [float(amount) * 0.1 / 1.13, float(gzs_price)] |
1727 | gzs_list.append(gzs_value) | 1749 | except Exception as e: |
1728 | gzs_list.append(float(gzs_price)) | 1750 | tmp_gzs_list = [amount, gzs_price] |
1751 | else: | ||
1752 | tmp_gzs_list = [amount, ] | ||
1729 | 1753 | ||
1730 | # 保单 ----------------------------------------------------------------------------------------------------------- | 1754 | # 保单 ----------------------------------------------------------------------------------------------------------- |
1731 | is_insurance = 0 | 1755 | is_insurance = 0 |
1732 | fp_campaign = cms_info.get('fpCampaign', '') | 1756 | fp_campaign = cms_info.get('fpCampaign', '') |
1733 | fp_group = cms_info.get('fpGroup', '') | ||
1734 | insurance_type = cms_info.get('insuranceDetails', {}).get('insuranceType', '') | 1757 | insurance_type = cms_info.get('insuranceDetails', {}).get('insuranceType', '') |
1735 | if insurance_type == 'Waive Insurance' and isinstance(insurance_price, str): | 1758 | if isinstance(insurance_price, str): |
1736 | is_insurance = 1 | 1759 | is_insurance = 1 |
1737 | elif insurance_type == 'Comprehensive Insurance': | 1760 | elif insurance_type == 'Comprehensive Insurance': |
1738 | is_insurance = 2 | 1761 | is_insurance = 2 |
... | @@ -1793,8 +1816,14 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list, auto=Fals | ... | @@ -1793,8 +1816,14 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list, auto=Fals |
1793 | ] | 1816 | ] |
1794 | 1817 | ||
1795 | if is_asp: | 1818 | if is_asp: |
1819 | # asp各项 | ||
1796 | hil_contract_1_input.append((consts.SE_HIL_CON_1_FIELD[8], asp_list)) | 1820 | hil_contract_1_input.append((consts.SE_HIL_CON_1_FIELD[8], asp_list)) |
1797 | hil_contract_1_input.append((consts.SE_HIL_CON_1_FIELD[9], gzs_list)) | 1821 | # 购置税校验 |
1822 | if isinstance(gzs_price, str): | ||
1823 | hil_contract_1_input.append((consts.SE_HIL_CON_1_FIELD[9], tmp_gzs_list)) | ||
1824 | # 非购置税非车辆保险的其他asp | ||
1825 | if have_other_asp: | ||
1826 | hil_contract_1_input.append((consts.SE_HIL_CON_1_FIELD[15], 'N')) | ||
1798 | 1827 | ||
1799 | if isinstance(company_info, tuple): | 1828 | if isinstance(company_info, tuple): |
1800 | if is_cdfl: | 1829 | if is_cdfl: |
... | @@ -1864,8 +1893,16 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list, auto=Fals | ... | @@ -1864,8 +1893,16 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list, auto=Fals |
1864 | else: | 1893 | else: |
1865 | # AFC合同------------------------------------------------------------------------------------------------------ | 1894 | # AFC合同------------------------------------------------------------------------------------------------------ |
1866 | vehicle_principal_str = str(cms_info.get('financialInformation', {}).get('vehiclePrincipal', '0.0')) | 1895 | vehicle_principal_str = str(cms_info.get('financialInformation', {}).get('vehiclePrincipal', '0.0')) |
1867 | afc_contract_input = [ | 1896 | if is_asp: |
1868 | (consts.SE_AFC_CON_FIELD[0], full_no), | 1897 | afc_contract_input = [ |
1898 | (consts.SE_AFC_CON_FIELD[0], full_no), | ||
1899 | ] | ||
1900 | else: | ||
1901 | afc_contract_input = [ | ||
1902 | (consts.SE_AFC_CON_FIELD[23], full_no), | ||
1903 | ] | ||
1904 | |||
1905 | afc_contract_input.extend([ | ||
1869 | (consts.SE_AFC_CON_FIELD[1], amount), | 1906 | (consts.SE_AFC_CON_FIELD[1], amount), |
1870 | (consts.SE_AFC_CON_FIELD[2], vin_no), | 1907 | (consts.SE_AFC_CON_FIELD[2], vin_no), |
1871 | (consts.SE_AFC_CON_FIELD[3], str(cms_info.get('financialInformation', {}).get('originationPrincipal', '0.0'))), | 1908 | (consts.SE_AFC_CON_FIELD[3], str(cms_info.get('financialInformation', {}).get('originationPrincipal', '0.0'))), |
... | @@ -1883,12 +1920,19 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list, auto=Fals | ... | @@ -1883,12 +1920,19 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list, auto=Fals |
1883 | (consts.SE_AFC_CON_FIELD[15], account_holder_name), | 1920 | (consts.SE_AFC_CON_FIELD[15], account_holder_name), |
1884 | (consts.SE_AFC_CON_FIELD[16], bank_name), | 1921 | (consts.SE_AFC_CON_FIELD[16], bank_name), |
1885 | (consts.SE_AFC_CON_FIELD[17], schedule_list_str), | 1922 | (consts.SE_AFC_CON_FIELD[17], schedule_list_str), |
1886 | ] | 1923 | ]) |
1887 | 1924 | ||
1888 | if is_asp: | 1925 | if is_asp: |
1926 | # asp各项 | ||
1889 | afc_contract_input.append((consts.SE_AFC_CON_FIELD[20], asp_list)) | 1927 | afc_contract_input.append((consts.SE_AFC_CON_FIELD[20], asp_list)) |
1890 | afc_contract_input.append((consts.SE_AFC_CON_FIELD[22], asp_list)) | 1928 | afc_contract_input.append((consts.SE_AFC_CON_FIELD[22], asp_list)) |
1891 | afc_contract_input.append((consts.SE_AFC_CON_FIELD[21], gzs_list)) | 1929 | # 购置税校验 |
1930 | if isinstance(gzs_price, str): | ||
1931 | afc_contract_input.append( | ||
1932 | (consts.SE_AFC_CON_FIELD[21], tmp_gzs_list)) | ||
1933 | # 非购置税非车辆保险的其他asp | ||
1934 | if have_other_asp: | ||
1935 | afc_contract_input.append((consts.SE_AFC_CON_FIELD[24], 'N')) | ||
1892 | else: | 1936 | else: |
1893 | afc_contract_input.pop(5) | 1937 | afc_contract_input.pop(5) |
1894 | afc_contract_input.pop(5) | 1938 | afc_contract_input.pop(5) |
... | @@ -1944,9 +1988,16 @@ def se_bs_compare(license_en, ocr_res_dict, strip_list, is_auto): | ... | @@ -1944,9 +1988,16 @@ def se_bs_compare(license_en, ocr_res_dict, strip_list, is_auto): |
1944 | # 主共借人 | 1988 | # 主共借人 |
1945 | pre_best_res = {} | 1989 | pre_best_res = {} |
1946 | max_correct_count = 0 | 1990 | max_correct_count = 0 |
1947 | for ocr_res in ocr_res_list: | 1991 | verify_list = [] |
1992 | verify_false_idx_list = [] | ||
1993 | |||
1994 | for tmp_idx, ocr_res in enumerate(ocr_res_list): | ||
1948 | correct_count = 0 | 1995 | correct_count = 0 |
1949 | pre_tmp_res_part = {} | 1996 | pre_tmp_res_part = {} |
1997 | verify_bool = ocr_res.get('verify', True) | ||
1998 | verify_list.append(verify_bool) | ||
1999 | if not verify_bool: | ||
2000 | verify_false_idx_list.append(str(tmp_idx+1)) | ||
1950 | for idx, (name, value) in enumerate(pre_field_list): | 2001 | for idx, (name, value) in enumerate(pre_field_list): |
1951 | ocr_str_or_list = ocr_res.get(compare_logic[name][0]) | 2002 | ocr_str_or_list = ocr_res.get(compare_logic[name][0]) |
1952 | if isinstance(ocr_str_or_list, str) or isinstance(ocr_str_or_list, list) \ | 2003 | if isinstance(ocr_str_or_list, str) or isinstance(ocr_str_or_list, list) \ |
... | @@ -1973,6 +2024,13 @@ def se_bs_compare(license_en, ocr_res_dict, strip_list, is_auto): | ... | @@ -1973,6 +2024,13 @@ def se_bs_compare(license_en, ocr_res_dict, strip_list, is_auto): |
1973 | max_correct_count = correct_count | 2024 | max_correct_count = correct_count |
1974 | pre_best_res = pre_tmp_res_part | 2025 | pre_best_res = pre_tmp_res_part |
1975 | 2026 | ||
2027 | # 真伪 | ||
2028 | if not is_auto: | ||
2029 | name = '真伪' | ||
2030 | result = consts.RESULT_Y if all(verify_list) else consts.RESULT_N | ||
2031 | reason = '第{0}份银行流水疑似造假,需人工核查'.format('、'.join(verify_false_idx_list)) | ||
2032 | result_field_list.append((name, empty_str, result, json.dumps(verify_list, ensure_ascii=False), empty_str, empty_error_type, reason)) | ||
2033 | |||
1976 | # 担保人1 | 2034 | # 担保人1 |
1977 | dbr1_best_res = {} | 2035 | dbr1_best_res = {} |
1978 | if len(dbr1_field_list) > 0: | 2036 | if len(dbr1_field_list) > 0: |
... | @@ -2160,20 +2218,36 @@ def se_compare_license(license_en, ocr_res_dict, field_list): | ... | @@ -2160,20 +2218,36 @@ def se_compare_license(license_en, ocr_res_dict, field_list): |
2160 | break | 2218 | break |
2161 | 2219 | ||
2162 | for idx, (name, value) in enumerate(field_list): | 2220 | for idx, (name, value) in enumerate(field_list): |
2163 | if ocr_field == consts.MVI_OCR_FIELD and name == consts.SE_NEW_ADD_FIELD[9]: | 2221 | # 二手车交易凭证 日期 |
2222 | if ocr_field == consts.JYPZ_OCR_FIELD and name == consts.SE_GB_USED_FIELD[2]: | ||
2223 | date_1 = ocr_res_list[res_idx].get(consts.JYPZ_DATE_FIELD_1, '') | ||
2224 | if len(date_1) > 0: | ||
2225 | date_2 = date_3 = '' | ||
2226 | else: | ||
2227 | date_1 = ocr_res_list[res_idx].get(consts.JYPZ_DATE_FIELD_2, '') | ||
2228 | date_2 = ocr_res_list[res_idx].get(consts.JYPZ_DATE_FIELD_3, '') | ||
2229 | date_3 = ocr_res_list[res_idx].get(consts.JYPZ_DATE_FIELD_4, '') | ||
2230 | ocr_str = [date_1, date_2, date_3] | ||
2231 | # 购车发票 价税合计大小写检验 | ||
2232 | elif ocr_field == consts.MVI_OCR_FIELD and name == consts.SE_NEW_ADD_FIELD[9]: | ||
2164 | ocr_str = getattr(cp, consts.ZW_METHOD)( | 2233 | ocr_str = getattr(cp, consts.ZW_METHOD)( |
2165 | ocr_res_list[res_idx].get(consts.LOWER_AMOUNT_FIELD, ''), | 2234 | ocr_res_list[res_idx].get(consts.LOWER_AMOUNT_FIELD, ''), |
2166 | ocr_res_list[res_idx].get(consts.UPPER_AMOUNT_FIELD, ''), | 2235 | ocr_res_list[res_idx].get(consts.UPPER_AMOUNT_FIELD, ''), |
2167 | ) | 2236 | ) |
2168 | else: | 2237 | else: |
2169 | ocr_str = ocr_res_list[res_idx].get(compare_logic[name][0]) | 2238 | ocr_str = ocr_res_list[res_idx].get(compare_logic[name][0]) |
2170 | if not isinstance(ocr_str, str): | 2239 | |
2240 | if isinstance(ocr_str, str): | ||
2241 | result = getattr(cp, compare_logic[name][1])(value, ocr_str, **compare_logic[name][2]) | ||
2242 | no_key = False | ||
2243 | # 二手车交易凭证 日期 | ||
2244 | elif ocr_field == consts.JYPZ_OCR_FIELD and name == consts.SE_GB_USED_FIELD[2]: | ||
2245 | result = getattr(cp, compare_logic[name][1])(value, ocr_str, **compare_logic[name][2]) | ||
2246 | no_key = False | ||
2247 | else: | ||
2171 | result = consts.RESULT_N | 2248 | result = consts.RESULT_N |
2172 | ocr_str = empty_str | 2249 | ocr_str = empty_str |
2173 | no_key = True | 2250 | no_key = True |
2174 | else: | ||
2175 | result = getattr(cp, compare_logic[name][1])(value, ocr_str, **compare_logic[name][2]) | ||
2176 | no_key = False | ||
2177 | 2251 | ||
2178 | if idx == 0 and result == consts.RESULT_N and length > 1: | 2252 | if idx == 0 and result == consts.RESULT_N and length > 1: |
2179 | break | 2253 | break |
... | @@ -2294,6 +2368,183 @@ def se_compare_license(license_en, ocr_res_dict, field_list): | ... | @@ -2294,6 +2368,183 @@ def se_compare_license(license_en, ocr_res_dict, field_list): |
2294 | return result_field_list, no_ocr_result, field_img_path_dict | 2368 | return result_field_list, no_ocr_result, field_img_path_dict |
2295 | 2369 | ||
2296 | 2370 | ||
2371 | def se_compare_license_id(license_en, id_res_list, field_list): | ||
2372 | ocr_field, compare_logic, special_expiry_date = consts.SE_COMPARE_FIELD[license_en] | ||
2373 | |||
2374 | is_find = False | ||
2375 | no_ocr_result = True | ||
2376 | special_expiry_date_slice = False | ||
2377 | result_field_list = [] | ||
2378 | section_img_info = dict() | ||
2379 | field_img_path_dict = dict() | ||
2380 | |||
2381 | # ocr_res_str = ocr_res_dict.get(ocr_field) | ||
2382 | for ocr_res_str in id_res_list: | ||
2383 | if is_find: | ||
2384 | break | ||
2385 | |||
2386 | if ocr_res_str is not None: | ||
2387 | no_ocr_result = False | ||
2388 | |||
2389 | ocr_res_list = json.loads(ocr_res_str) | ||
2390 | |||
2391 | # 3/4页去除 | ||
2392 | # if ocr_field == consts.MVC_OCR_FIELD: | ||
2393 | # tmp_list = [] | ||
2394 | # for res in ocr_res_list: | ||
2395 | # if compare_logic['vinNo'][0] in res: | ||
2396 | # tmp_list.append(res) | ||
2397 | # ocr_res_list = tmp_list | ||
2398 | |||
2399 | length = len(ocr_res_list) | ||
2400 | |||
2401 | # 身份证、居住证 过期期限特殊处理 | ||
2402 | if special_expiry_date: | ||
2403 | expiry_dates = dict() | ||
2404 | key = compare_logic.get('idExpiryDate')[0] | ||
2405 | for date_tmp_idx, ocr_res in enumerate(ocr_res_list): | ||
2406 | if key in ocr_res: | ||
2407 | expiry_dates[ocr_res[key]] = (ocr_res.get(consts.IMG_PATH_KEY_2, ''), date_tmp_idx) | ||
2408 | else: | ||
2409 | expiry_dates = dict() | ||
2410 | |||
2411 | for res_idx in range(length-1, -1, -1): | ||
2412 | if is_find: | ||
2413 | break | ||
2414 | |||
2415 | for idx, (name, value) in enumerate(field_list): | ||
2416 | # if ocr_field == consts.MVI_OCR_FIELD and name == consts.SE_NEW_ADD_FIELD[9]: | ||
2417 | # ocr_str = getattr(cp, consts.ZW_METHOD)( | ||
2418 | # ocr_res_list[res_idx].get(consts.LOWER_AMOUNT_FIELD, ''), | ||
2419 | # ocr_res_list[res_idx].get(consts.UPPER_AMOUNT_FIELD, ''), | ||
2420 | # ) | ||
2421 | # else: | ||
2422 | ocr_str = ocr_res_list[res_idx].get(compare_logic[name][0]) | ||
2423 | if not isinstance(ocr_str, str): | ||
2424 | result = consts.RESULT_N | ||
2425 | ocr_str = empty_str | ||
2426 | no_key = True | ||
2427 | else: | ||
2428 | result = getattr(cp, compare_logic[name][1])(value, ocr_str, **compare_logic[name][2]) | ||
2429 | no_key = False | ||
2430 | |||
2431 | if idx == 0 and result == consts.RESULT_N and length > 1: | ||
2432 | break | ||
2433 | |||
2434 | is_find = True | ||
2435 | section_img_info[consts.SECTION_IMG_PATH_KEY] = ocr_res_list[res_idx].get(consts.SECTION_IMG_PATH_KEY, '') | ||
2436 | section_img_info[consts.ALL_POSITION_KEY] = ocr_res_list[res_idx].get(consts.ALL_POSITION_KEY, {}) | ||
2437 | if special_expiry_date: | ||
2438 | section_img_info[consts.SECTION_IMG_PATH_KEY_2] = ocr_res_list[res_idx].get( | ||
2439 | consts.SECTION_IMG_PATH_KEY_2, '') | ||
2440 | section_img_info[consts.ALL_POSITION_KEY_2] = ocr_res_list[res_idx].get(consts.ALL_POSITION_KEY_2, {}) | ||
2441 | |||
2442 | # 过期期限特殊处理 | ||
2443 | if special_expiry_date and name == 'idExpiryDate' and result == consts.RESULT_N: | ||
2444 | if no_key: | ||
2445 | if len(expiry_dates) == 0: | ||
2446 | ocr_str = empty_str | ||
2447 | result = consts.RESULT_N | ||
2448 | img_path = empty_str | ||
2449 | else: | ||
2450 | for expiry_date, (date_img_path, date_res_idx) in expiry_dates.items(): | ||
2451 | expiry_date_res = getattr(cp, compare_logic[name][1])(value, expiry_date, **compare_logic[name][2]) | ||
2452 | if expiry_date_res == consts.RESULT_N: | ||
2453 | ocr_str = expiry_date | ||
2454 | img_path = date_img_path | ||
2455 | special_expiry_date_slice = True | ||
2456 | section_img_info[consts.SECTION_IMG_PATH_KEY_2] = ocr_res_list[date_res_idx].get( | ||
2457 | consts.SECTION_IMG_PATH_KEY_2, '') | ||
2458 | section_img_info[consts.ALL_POSITION_KEY_2] = ocr_res_list[date_res_idx].get( | ||
2459 | consts.ALL_POSITION_KEY_2, {}) | ||
2460 | break | ||
2461 | else: | ||
2462 | ocr_str = empty_str | ||
2463 | result = consts.RESULT_Y | ||
2464 | img_path = empty_str | ||
2465 | else: | ||
2466 | img_path = ocr_res_list[res_idx].get(consts.IMG_PATH_KEY_2, '') | ||
2467 | special_expiry_date_slice = True | ||
2468 | else: | ||
2469 | img_path = ocr_res_list[res_idx].get(consts.IMG_PATH_KEY, '') if result == consts.RESULT_N else empty_str | ||
2470 | if isinstance(value, list): | ||
2471 | value = json.dumps(value, ensure_ascii=False) | ||
2472 | error_type = empty_error_type if result == consts.RESULT_Y else ErrorType.OCR.value | ||
2473 | result_field_list.append((name, value, result, ocr_str, img_path, error_type, compare_logic[name][3])) | ||
2474 | |||
2475 | if not is_find: | ||
2476 | for name, value in field_list: | ||
2477 | if isinstance(value, list): | ||
2478 | value = json.dumps(value, ensure_ascii=False) | ||
2479 | no_find_str = consts.DDA_NO_FIND if license_en == consts.DDA_EN else '{0}未找到'.format(license_en) | ||
2480 | result_field_list.append((name, value, consts.RESULT_N, empty_str, empty_str, ErrorType.NF.value, no_find_str)) | ||
2481 | |||
2482 | if is_find: | ||
2483 | if special_expiry_date_slice: | ||
2484 | special_section_img_path = section_img_info.get(consts.SECTION_IMG_PATH_KEY_2, '') | ||
2485 | if os.path.exists(special_section_img_path): | ||
2486 | field = 'idExpiryDate' | ||
2487 | special_info = section_img_info.get(consts.ALL_POSITION_KEY_2, {}) | ||
2488 | special_section_position = special_info.get(consts.POSITION_KEY, {}) | ||
2489 | special_section_angle = special_info.get(consts.ANGLE_KEY, 0) | ||
2490 | try: | ||
2491 | last_img = img_process(special_section_img_path, special_section_position, special_section_angle) | ||
2492 | except Exception as e: | ||
2493 | field_img_path_dict[field] = special_section_img_path | ||
2494 | else: | ||
2495 | pre, suf = os.path.splitext(special_section_img_path) | ||
2496 | try: | ||
2497 | res_field = compare_logic[field][0] | ||
2498 | is_valid, coord_tuple = field_build_coordinates(special_info.get(res_field, {})) | ||
2499 | if is_valid: | ||
2500 | save_path = '{0}_{1}{2}'.format(pre, field, suf) | ||
2501 | field_img = last_img[coord_tuple[0]:coord_tuple[1], coord_tuple[2]:coord_tuple[3], :] | ||
2502 | cv2.imwrite(save_path, field_img) | ||
2503 | field_img_path_dict[field] = save_path | ||
2504 | else: | ||
2505 | field_img_path_dict[field] = special_section_img_path | ||
2506 | except Exception as e: | ||
2507 | field_img_path_dict[field] = special_section_img_path | ||
2508 | |||
2509 | section_img_path = section_img_info.get(consts.SECTION_IMG_PATH_KEY, '') | ||
2510 | if os.path.exists(section_img_path): | ||
2511 | failed_field = [] | ||
2512 | base_img_path = empty_str | ||
2513 | for name, _, result, _, img_path, _, _ in result_field_list: | ||
2514 | if result == consts.RESULT_N: | ||
2515 | if special_expiry_date_slice and name == 'idExpiryDate': | ||
2516 | continue | ||
2517 | failed_field.append(name) | ||
2518 | if base_img_path == empty_str: | ||
2519 | base_img_path = img_path | ||
2520 | if len(failed_field) > 0: | ||
2521 | info = section_img_info.get(consts.ALL_POSITION_KEY, {}) | ||
2522 | section_position = info.get(consts.POSITION_KEY, {}) | ||
2523 | section_angle = info.get(consts.ANGLE_KEY, 0) | ||
2524 | try: | ||
2525 | last_img = img_process(section_img_path, section_position, section_angle) | ||
2526 | except Exception as e: | ||
2527 | for field in failed_field: | ||
2528 | field_img_path_dict[field] = base_img_path | ||
2529 | else: | ||
2530 | pre, suf = os.path.splitext(section_img_path) | ||
2531 | for field in failed_field: | ||
2532 | try: | ||
2533 | res_field = compare_logic[field][0] | ||
2534 | is_valid, coord_tuple = field_build_coordinates(info.get(res_field, {})) | ||
2535 | if is_valid: | ||
2536 | save_path = '{0}_{1}{2}'.format(pre, field, suf) | ||
2537 | field_img = last_img[coord_tuple[0]:coord_tuple[1], coord_tuple[2]:coord_tuple[3], :] | ||
2538 | cv2.imwrite(save_path, field_img) | ||
2539 | field_img_path_dict[field] = save_path | ||
2540 | else: | ||
2541 | field_img_path_dict[field] = base_img_path | ||
2542 | except Exception as e: | ||
2543 | field_img_path_dict[field] = base_img_path | ||
2544 | |||
2545 | return result_field_list, no_ocr_result, field_img_path_dict | ||
2546 | |||
2547 | |||
2297 | def se_contract_compare(license_en, ocr_res_dict, strip_list, is_gsyh): | 2548 | def se_contract_compare(license_en, ocr_res_dict, strip_list, is_gsyh): |
2298 | ocr_field, compare_logic, _ = consts.SE_COMPARE_FIELD[license_en] | 2549 | ocr_field, compare_logic, _ = consts.SE_COMPARE_FIELD[license_en] |
2299 | ocr_res_str = ocr_res_dict.get(ocr_field) | 2550 | ocr_res_str = ocr_res_dict.get(ocr_field) |
... | @@ -2308,50 +2559,75 @@ def se_contract_compare(license_en, ocr_res_dict, strip_list, is_gsyh): | ... | @@ -2308,50 +2559,75 @@ def se_contract_compare(license_en, ocr_res_dict, strip_list, is_gsyh): |
2308 | 2559 | ||
2309 | for name, value in strip_list: | 2560 | for name, value in strip_list: |
2310 | # 购置税校验 | 2561 | # 购置税校验 |
2311 | if name == consts.SE_AFC_CON_FIELD[21]: | 2562 | # if name == consts.SE_AFC_CON_FIELD[21]: |
2312 | if len(value) == 3: | 2563 | # if len(value) == 3: |
2313 | reason = [] | 2564 | # reason = [] |
2314 | gzs_verify = value[1] >= value[2] | 2565 | # gzs_verify = value[1] >= value[2] |
2315 | if gzs_verify: | 2566 | # if gzs_verify: |
2316 | if value[0] == consts.GZS_STATUS[0]: | 2567 | # if value[0] == consts.GZS_STATUS[0]: |
2317 | reason.append(consts.GZS_REASON_1) | 2568 | # reason.append(consts.GZS_REASON_1) |
2318 | result = consts.RESULT_N | 2569 | # result = consts.RESULT_N |
2319 | else: | 2570 | # else: |
2320 | result = consts.RESULT_Y | 2571 | # result = consts.RESULT_Y |
2321 | else: | 2572 | # else: |
2322 | if value[0] == consts.GZS_STATUS[0]: | 2573 | # if value[0] == consts.GZS_STATUS[0]: |
2323 | reason.append(consts.GZS_REASON_1) | 2574 | # reason.append(consts.GZS_REASON_1) |
2324 | result = consts.RESULT_N | 2575 | # result = consts.RESULT_N |
2325 | reason.append(consts.GZS_REASON_2) | 2576 | # reason.append(consts.GZS_REASON_2) |
2326 | else: | 2577 | # else: |
2327 | result = consts.RESULT_N | 2578 | # result = consts.RESULT_N |
2328 | reason = consts.GZS_REASON_1 | 2579 | # reason = consts.GZS_REASON_1 |
2329 | ocr_str = empty_str | 2580 | # ocr_str = empty_str |
2581 | # else: | ||
2582 | |||
2583 | if name == consts.SE_HIL_CON_1_FIELD[9] or name == consts.SE_HIL_CON_1_FIELD[15] or \ | ||
2584 | name == consts.SE_AFC_CON_FIELD[21] or name == consts.SE_AFC_CON_FIELD[24]: | ||
2585 | ocr_str_or_list = '' | ||
2330 | else: | 2586 | else: |
2331 | ocr_str_or_list = ocr_res.get(compare_logic[name][0]) | 2587 | ocr_str_or_list = ocr_res.get(compare_logic[name][0]) |
2332 | if ocr_str_or_list is None and license_en == consts.AFC_CONTRACT_EN \ | 2588 | |
2333 | and is_gsyh is True and name in consts.CON_BANK_FIELD: | 2589 | # 招商银行特殊 |
2334 | result = consts.RESULT_Y | 2590 | # if ocr_str_or_list is None and license_en == consts.AFC_CONTRACT_EN \ |
2335 | ocr_str = empty_str | 2591 | # and is_gsyh is True and name in consts.CON_BANK_FIELD: |
2336 | reason = compare_logic[name][3] | 2592 | # result = consts.RESULT_Y |
2337 | elif isinstance(ocr_str_or_list, str) or isinstance(ocr_str_or_list, list): | 2593 | # ocr_str = empty_str |
2338 | if is_gsyh is True and name in consts.CON_BANK_FIELD: | 2594 | # reason = compare_logic[name][3] |
2339 | update_args = {'is_gsyh': is_gsyh} | 2595 | # 见证人日期 |
2340 | for k, v in compare_logic[name][2].items(): | 2596 | if name == consts.SE_AFC_CON_FIELD[19]: |
2341 | update_args[k] = v | 2597 | if not isinstance(ocr_str_or_list, str) or len(ocr_str_or_list) == 0: |
2342 | else: | ||
2343 | update_args = compare_logic[name][2] | ||
2344 | if isinstance(ocr_str_or_list, list): | ||
2345 | ocr_str = json.dumps(ocr_str_or_list, ensure_ascii=False) | ||
2346 | else: | ||
2347 | ocr_str_or_list = ocr_str_or_list.strip() | ||
2348 | ocr_str = ocr_str_or_list | ||
2349 | result = getattr(cp, compare_logic[name][1])(value, ocr_str_or_list, **update_args) | ||
2350 | reason = compare_logic[name][3] | ||
2351 | else: | ||
2352 | result = consts.RESULT_N | 2598 | result = consts.RESULT_N |
2353 | ocr_str = empty_str | 2599 | ocr_str = empty_str |
2354 | reason = compare_logic[name][3] | 2600 | else: |
2601 | is_find_date = False | ||
2602 | all_date_list = [ocr_str_or_list] | ||
2603 | for date_name in consts.AFC_HT_DATE_FIELDS: | ||
2604 | all_date_list.append(ocr_res.get(compare_logic[date_name][0], '')) | ||
2605 | if not is_find_date and ocr_str_or_list == ocr_res.get(compare_logic[date_name][0], ''): | ||
2606 | is_find_date = True | ||
2607 | result = consts.RESULT_Y if is_find_date else consts.RESULT_N | ||
2608 | ocr_str = json.dumps(all_date_list, ensure_ascii=False) | ||
2609 | reason = compare_logic[name][3] | ||
2610 | elif isinstance(ocr_str_or_list, str) or isinstance(ocr_str_or_list, list): | ||
2611 | # if is_gsyh is True and name in consts.CON_BANK_FIELD: | ||
2612 | # update_args = {'is_gsyh': is_gsyh} | ||
2613 | # for k, v in compare_logic[name][2].items(): | ||
2614 | # update_args[k] = v | ||
2615 | # else: | ||
2616 | # update_args = compare_logic[name][2] | ||
2617 | if isinstance(ocr_str_or_list, list): | ||
2618 | # no-asp 合同编号-每页(no-asp) | ||
2619 | if name == consts.SE_AFC_CON_FIELD[23]: | ||
2620 | ocr_str_or_list.pop() | ||
2621 | ocr_str = json.dumps(ocr_str_or_list, ensure_ascii=False) | ||
2622 | else: | ||
2623 | ocr_str_or_list = ocr_str_or_list.strip() | ||
2624 | ocr_str = ocr_str_or_list | ||
2625 | result = getattr(cp, compare_logic[name][1])(value, ocr_str_or_list, **compare_logic[name][2]) | ||
2626 | reason = compare_logic[name][3] | ||
2627 | else: | ||
2628 | result = consts.RESULT_N | ||
2629 | ocr_str = empty_str | ||
2630 | reason = compare_logic[name][3] | ||
2355 | 2631 | ||
2356 | # img_path = empty_str | 2632 | # img_path = empty_str |
2357 | if name not in compare_logic: | 2633 | if name not in compare_logic: |
... | @@ -2513,7 +2789,7 @@ def se_mvc34_compare(license_en, ocr_res_dict, field_list): | ... | @@ -2513,7 +2789,7 @@ def se_mvc34_compare(license_en, ocr_res_dict, field_list): |
2513 | return result_field_list, field_img_path_dict | 2789 | return result_field_list, field_img_path_dict |
2514 | 2790 | ||
2515 | 2791 | ||
2516 | def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto): | 2792 | def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list): |
2517 | # individualCusInfo | 2793 | # individualCusInfo |
2518 | # corporateCusInfo | 2794 | # corporateCusInfo |
2519 | # vehicleInfo | 2795 | # vehicleInfo |
... | @@ -2546,7 +2822,13 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto): | ... | @@ -2546,7 +2822,13 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto): |
2546 | else: | 2822 | else: |
2547 | strip_list.append((a, b)) | 2823 | strip_list.append((a, b)) |
2548 | failure_field = [] | 2824 | failure_field = [] |
2549 | result_field_list, no_ocr_result, field_img_path_dict = se_compare_license(license_en, ocr_res_dict, strip_list) | 2825 | # 身份证先SE正反面,后CA正反面 |
2826 | if license_en == consts.ID_EN: | ||
2827 | result_field_list, no_ocr_result, field_img_path_dict = se_compare_license_id( | ||
2828 | license_en, id_res_list, strip_list) | ||
2829 | else: | ||
2830 | result_field_list, no_ocr_result, field_img_path_dict = se_compare_license( | ||
2831 | license_en, ocr_res_dict, strip_list) | ||
2550 | for name, value, result, ocr_str, img_path, error_type, cn_reason in result_field_list: | 2832 | for name, value, result, ocr_str, img_path, error_type, cn_reason in result_field_list: |
2551 | if license_en not in consts.SKIP_CARD or not no_ocr_result: | 2833 | if license_en not in consts.SKIP_CARD or not no_ocr_result: |
2552 | total_fields += 1 | 2834 | total_fields += 1 |
... | @@ -2665,13 +2947,15 @@ def se_result_detect(ocr_res_dict): | ... | @@ -2665,13 +2947,15 @@ def se_result_detect(ocr_res_dict): |
2665 | return detect_list | 2947 | return detect_list |
2666 | 2948 | ||
2667 | 2949 | ||
2668 | def se_compare_auto(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict, auto_obj): | 2950 | def se_compare_auto(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict, auto_obj, ignore_bank, id_res_list): |
2669 | try: | 2951 | try: |
2670 | # 比对逻辑 | 2952 | # 比对逻辑 |
2671 | # detect_list = se_result_detect(ocr_res_dict) | 2953 | # detect_list = se_result_detect(ocr_res_dict) |
2672 | compare_info, aa_type, is_gsyh = get_se_cms_compare_info_auto( | 2954 | compare_info, aa_type, is_gsyh = get_se_cms_compare_info_auto( |
2673 | last_obj, application_entity) | 2955 | last_obj, application_entity, ignore_bank=ignore_bank) |
2674 | 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, True) | 2956 | compare_result, total_fields, failed_count, successful_at_this_level, failure_reason_str, \ |
2957 | cn_failure_reason_str, bs_failure_reason_str, _ = se_compare_process( | ||
2958 | compare_info, ocr_res_dict, is_gsyh, True, id_res_list) | ||
2675 | compare_log.info('{0} [Auto SE] [compare success] [entity={1}] [id={2}] [ocr_res_id={3}] [result={4}]'.format( | 2959 | compare_log.info('{0} [Auto SE] [compare success] [entity={1}] [id={2}] [ocr_res_id={3}] [result={4}]'.format( |
2676 | log_base, application_entity, application_id, ocr_res_id, compare_result)) | 2960 | log_base, application_entity, application_id, ocr_res_id, compare_result)) |
2677 | except Exception as e: | 2961 | except Exception as e: |
... | @@ -2709,14 +2993,17 @@ def se_compare_auto(application_id, application_entity, ocr_res_id, last_obj, oc | ... | @@ -2709,14 +2993,17 @@ def se_compare_auto(application_id, application_entity, ocr_res_id, last_obj, oc |
2709 | return successful_at_this_level | 2993 | return successful_at_this_level |
2710 | 2994 | ||
2711 | 2995 | ||
2712 | def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict, is_cms, auto_result): | 2996 | def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict, is_cms, |
2997 | auto_result, ignore_bank, id_res_list): | ||
2713 | try: | 2998 | try: |
2714 | # 比对逻辑 | 2999 | # 比对逻辑 |
2715 | start_time = datetime.now() | 3000 | start_time = datetime.now() |
2716 | detect_list = se_result_detect(ocr_res_dict) | 3001 | detect_list = se_result_detect(ocr_res_dict) |
2717 | compare_info, application_version, is_gsyh = get_se_cms_compare_info( | 3002 | compare_info, application_version, is_gsyh = get_se_cms_compare_info( |
2718 | last_obj, application_entity, detect_list) | 3003 | last_obj, application_entity, detect_list, ignore_bank=ignore_bank) |
2719 | compare_result, total_fields, failed_count, successful_at_this_level, failure_reason_str, cn_failure_reason_str, bs_failure_reason_str, rpa_failure_reason = se_compare_process(compare_info, ocr_res_dict, is_gsyh, False) | 3004 | compare_result, total_fields, failed_count, successful_at_this_level, failure_reason_str, \ |
3005 | cn_failure_reason_str, bs_failure_reason_str, rpa_failure_reason = se_compare_process( | ||
3006 | compare_info, ocr_res_dict, is_gsyh, False, id_res_list) | ||
2720 | compare_log.info('{0} [SE] [compare success] [entity={1}] [id={2}] [ocr_res_id={3}] [result={4}]'.format( | 3007 | compare_log.info('{0} [SE] [compare success] [entity={1}] [id={2}] [ocr_res_id={3}] [result={4}]'.format( |
2721 | log_base, application_entity, application_id, ocr_res_id, compare_result)) | 3008 | log_base, application_entity, application_id, ocr_res_id, compare_result)) |
2722 | except Exception as e: | 3009 | except Exception as e: |
... | @@ -2858,7 +3145,12 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True | ... | @@ -2858,7 +3145,12 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True |
2858 | if is_ca: | 3145 | if is_ca: |
2859 | ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict) | 3146 | ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict) |
2860 | else: | 3147 | else: |
3148 | id_res_list = [] | ||
2861 | for field_name in consts.CA_ADD_COMPARE_FIELDS: | 3149 | for field_name in consts.CA_ADD_COMPARE_FIELDS: |
3150 | if field_name == consts.IC_OCR_FIELD: | ||
3151 | id_res_list.append(ocr_res_dict.get(field_name)) | ||
3152 | id_res_list.append(ca_ocr_res_dict.get(field_name) if isinstance(ca_ocr_res_dict, dict) else None) | ||
3153 | |||
2862 | if isinstance(ca_ocr_res_dict, dict) and isinstance(ca_ocr_res_dict.get(field_name), str): | 3154 | if isinstance(ca_ocr_res_dict, dict) and isinstance(ca_ocr_res_dict.get(field_name), str): |
2863 | tmp_ca_result = json.loads(ca_ocr_res_dict.get(field_name)) | 3155 | tmp_ca_result = json.loads(ca_ocr_res_dict.get(field_name)) |
2864 | if isinstance(ocr_res_dict.get(field_name), str): | 3156 | if isinstance(ocr_res_dict.get(field_name), str): |
... | @@ -2868,12 +3160,14 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True | ... | @@ -2868,12 +3160,14 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True |
2868 | # auto settlement | 3160 | # auto settlement |
2869 | auto_class = HILAutoSettlement if application_entity == consts.HIL_PREFIX else AFCAutoSettlement | 3161 | auto_class = HILAutoSettlement if application_entity == consts.HIL_PREFIX else AFCAutoSettlement |
2870 | auto_obj = auto_class.objects.filter(application_id=application_id, on_off=True).first() | 3162 | auto_obj = auto_class.objects.filter(application_id=application_id, on_off=True).first() |
3163 | bank_class = HILbankVerification if application_entity == consts.HIL_PREFIX else AFCbankVerification | ||
3164 | ignore_bank = bank_class.objects.filter(application_id=application_id, on_off=True).exists() | ||
2871 | if auto_obj is not None: | 3165 | if auto_obj is not None: |
2872 | auto_result = se_compare_auto(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict, auto_obj) | 3166 | auto_result = se_compare_auto(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict, auto_obj, ignore_bank, id_res_list) |
2873 | else: | 3167 | else: |
2874 | auto_result = None | 3168 | auto_result = None |
2875 | 3169 | ||
2876 | full_result = se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict, is_cms, auto_result) | 3170 | full_result = se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict, is_cms, auto_result, ignore_bank, id_res_list) |
2877 | 3171 | ||
2878 | if auto_obj is not None: | 3172 | if auto_obj is not None: |
2879 | try: | 3173 | try: | ... | ... |
... | @@ -173,6 +173,11 @@ class Comparison: | ... | @@ -173,6 +173,11 @@ class Comparison: |
173 | return self.RESULT_Y | 173 | return self.RESULT_Y |
174 | return self.RESULT_N | 174 | return self.RESULT_N |
175 | else: | 175 | else: |
176 | # if kwargs.get('pop_last', False): | ||
177 | # for item in ocr_str_or_list[:-1]: | ||
178 | # if item != input_str_or_list: | ||
179 | # return self.RESULT_N | ||
180 | # else: | ||
176 | for item in ocr_str_or_list: | 181 | for item in ocr_str_or_list: |
177 | if item != input_str_or_list: | 182 | if item != input_str_or_list: |
178 | return self.RESULT_N | 183 | return self.RESULT_N |
... | @@ -582,6 +587,27 @@ class Comparison: | ... | @@ -582,6 +587,27 @@ class Comparison: |
582 | else: | 587 | else: |
583 | return self.RESULT_N | 588 | return self.RESULT_N |
584 | 589 | ||
590 | def se_self_compare_gzs(self, input_list, ocr_str, **kwargs): | ||
591 | if isinstance(input_list, list) and len(input_list) == 2: | ||
592 | try: | ||
593 | if isinstance(input_list[0], float) and isinstance(input_list[1], float) \ | ||
594 | and input_list[0] >= input_list[1]: | ||
595 | return self.RESULT_Y | ||
596 | except Exception as e: | ||
597 | return self.RESULT_N | ||
598 | return self.RESULT_N | ||
599 | |||
600 | def se_self_compare_other_asp(self, input_str, ocr_str, **kwargs): | ||
601 | return self.RESULT_N | ||
602 | |||
603 | def se_jypz_date_compare(self, input_str, ocr_date_list, **kwargs): | ||
604 | ocr_date_set = set(ocr_date_list) | ||
605 | if len(ocr_date_set) > 1: | ||
606 | return self.RESULT_N | ||
607 | if not any(ocr_date_set): | ||
608 | return self.RESULT_N | ||
609 | return self.se_date_compare_2(input_str, ocr_date_set.pop(), three_month=True) | ||
610 | |||
585 | 611 | ||
586 | cp = Comparison() | 612 | cp = Comparison() |
587 | 613 | ... | ... |
src/common/tools/mssql_script18.py
0 → 100644
1 | import pyodbc | ||
2 | |||
3 | hil_sql = """ | ||
4 | create table hil_bank_verification | ||
5 | ( | ||
6 | id bigint identity primary key, | ||
7 | application_id nvarchar(64) not null, | ||
8 | on_off bit default 1 not null, | ||
9 | update_time datetime not null, | ||
10 | create_time datetime not null | ||
11 | ); | ||
12 | |||
13 | create index hil_bank_verification_application_id_index | ||
14 | on hil_bank_verification (application_id); | ||
15 | """ | ||
16 | |||
17 | afc_sql = """ | ||
18 | create table afc_bank_verification | ||
19 | ( | ||
20 | id bigint identity primary key, | ||
21 | application_id nvarchar(64) not null, | ||
22 | on_off bit default 1 not null, | ||
23 | update_time datetime not null, | ||
24 | create_time datetime not null | ||
25 | ); | ||
26 | |||
27 | create index afc_bank_verification_application_id_index | ||
28 | on afc_bank_verification (application_id); | ||
29 | """ | ||
30 | |||
31 | hil_cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};', autocommit=True) | ||
32 | |||
33 | hil_cursor = hil_cnxn.cursor() | ||
34 | hil_cursor.execute(hil_sql) | ||
35 | |||
36 | hil_cursor.close() | ||
37 | hil_cnxn.close() | ||
38 | |||
39 | afc_cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};', autocommit=True) | ||
40 | |||
41 | afc_cursor = afc_cnxn.cursor() | ||
42 | afc_cursor.execute(afc_sql) | ||
43 | |||
44 | afc_cursor.close() | ||
45 | afc_cnxn.close() |
1 | import os | 1 | import os |
2 | import re | ||
2 | import json | 3 | import json |
3 | import cv2 | 4 | import cv2 |
4 | import shutil | 5 | import shutil |
... | @@ -48,8 +49,9 @@ class PDFBuild: | ... | @@ -48,8 +49,9 @@ class PDFBuild: |
48 | 49 | ||
49 | class PDFHandler: | 50 | class PDFHandler: |
50 | 51 | ||
51 | def __init__(self, path, img_dir_path, document_name=None): | 52 | def __init__(self, path, img_dir_path, document_name=None, pwd_list=[]): |
52 | self.path = path | 53 | self.path = path |
54 | self.pwd_list = self.get_pwd_list(document_name, pwd_list) | ||
53 | self.img_dir_path = img_dir_path | 55 | self.img_dir_path = img_dir_path |
54 | self.img_path_list = [] | 56 | self.img_path_list = [] |
55 | self.img_count = 0 | 57 | self.img_count = 0 |
... | @@ -75,6 +77,12 @@ class PDFHandler: | ... | @@ -75,6 +77,12 @@ class PDFHandler: |
75 | self.page_count = None | 77 | self.page_count = None |
76 | self.metadata = None | 78 | self.metadata = None |
77 | 79 | ||
80 | @staticmethod | ||
81 | def get_pwd_list(doc_name, pwd_list): | ||
82 | pwd_list_from_doc_name = re.findall(r'\d{6}', doc_name) | ||
83 | pwd_list_from_doc_name.extend(pwd_list) | ||
84 | return pwd_list_from_doc_name | ||
85 | |||
78 | def get_suffix(self, file_name): | 86 | def get_suffix(self, file_name): |
79 | if file_name is None: | 87 | if file_name is None: |
80 | return None | 88 | return None |
... | @@ -370,6 +378,12 @@ class PDFHandler: | ... | @@ -370,6 +378,12 @@ class PDFHandler: |
370 | self.img_path_list.append(img_save_path) | 378 | self.img_path_list.append(img_save_path) |
371 | else: | 379 | else: |
372 | with fitz.Document(self.path) as pdf: | 380 | with fitz.Document(self.path) as pdf: |
381 | # 解密 | ||
382 | for pwd in self.pwd_list: | ||
383 | if not pdf.isEncrypted: | ||
384 | break | ||
385 | pdf.authenticate(pwd) | ||
386 | |||
373 | self.metadata = pdf.metadata | 387 | self.metadata = pdf.metadata |
374 | self.page_count = pdf.pageCount | 388 | self.page_count = pdf.pageCount |
375 | if isinstance(max_img_count, int) and pdf.pageCount >= max_img_count: | 389 | if isinstance(max_img_count, int) and pdf.pageCount >= max_img_count: | ... | ... |
-
Please register or sign in to post a comment