将uat-tmp所有内容合并到uat-tmp-cy分支上
Showing
26 changed files
with
1818 additions
and
277 deletions
... | @@ -55,6 +55,7 @@ class LoginView(ObtainJSONWebToken, GenericView): | ... | @@ -55,6 +55,7 @@ class LoginView(ObtainJSONWebToken, GenericView): |
55 | 'role': user_role.role if user_role else -1 | 55 | 'role': user_role.role if user_role else -1 |
56 | } | 56 | } |
57 | rh.set_token(res.data.get('token')[-10:], user.username) | 57 | rh.set_token(res.data.get('token')[-10:], user.username) |
58 | rh.set_token(res.data.get('token')[-11:], user_role.role if user_role else -1) | ||
58 | return response.ok(data=data) | 59 | return response.ok(data=data) |
59 | 60 | ||
60 | 61 | ||
... | @@ -85,9 +86,10 @@ class IWALoginView(IWABaseView, GenericView): | ... | @@ -85,9 +86,10 @@ class IWALoginView(IWABaseView, GenericView): |
85 | is_valid, data = self.validate(q_number) | 86 | is_valid, data = self.validate(q_number) |
86 | 87 | ||
87 | if is_valid: | 88 | if is_valid: |
88 | rh.set_token(data.get('token')[-10:], data.get('user_name')) | ||
89 | user_role = UserRole.objects.filter(auth_user_id=data.get('user_id')).first() | 89 | user_role = UserRole.objects.filter(auth_user_id=data.get('user_id')).first() |
90 | data['role'] = user_role.role if user_role else -1 | 90 | data['role'] = user_role.role if user_role else -1 |
91 | rh.set_token(data.get('token')[-10:], data.get('user_name')) | ||
92 | rh.set_token(data.get('token')[-11:], user_role.role if user_role else -1) | ||
91 | return response.ok(data=data) | 93 | return response.ok(data=data) |
92 | else: | 94 | else: |
93 | self.no_permission(data) | 95 | self.no_permission(data) | ... | ... |
... | @@ -98,6 +98,8 @@ RES_SHEET_HEADER = ('页码', '图片序号', '检测图片序号', '结果') | ... | @@ -98,6 +98,8 @@ RES_SHEET_HEADER = ('页码', '图片序号', '检测图片序号', '结果') |
98 | RES_SUCCESS = '识别成功' | 98 | RES_SUCCESS = '识别成功' |
99 | RES_SUCCESS_OTHER = '识别成功(其他类)' | 99 | RES_SUCCESS_OTHER = '识别成功(其他类)' |
100 | RES_SUCCESS_EMPTY = '识别成功(空数据)' | 100 | RES_SUCCESS_EMPTY = '识别成功(空数据)' |
101 | RES_SUCCESS_FINANCIAL_STATEMENT = '识别成功(财务报表类)' | ||
102 | RES_SUCCESS_DOWN_PAYMENT = '识别成功(首付款支付承诺书类)' | ||
101 | RES_FAILED = '识别失败' | 103 | RES_FAILED = '识别失败' |
102 | RES_FAILED_1 = '识别失败(阶段1)' | 104 | RES_FAILED_1 = '识别失败(阶段1)' |
103 | RES_FAILED_2 = '识别失败(阶段2)' | 105 | RES_FAILED_2 = '识别失败(阶段2)' |
... | @@ -1247,6 +1249,9 @@ FSM_CONTRACT_WEP_FIELD = 'fsm_wep_ocr' | ... | @@ -1247,6 +1249,9 @@ FSM_CONTRACT_WEP_FIELD = 'fsm_wep_ocr' |
1247 | FSM_CONTRACT_MSI_FIELD = 'fsm_msi_ocr' | 1249 | FSM_CONTRACT_MSI_FIELD = 'fsm_msi_ocr' |
1248 | FSM_CONTRACT_SC_FIELD = 'fsm_sc_ocr' | 1250 | FSM_CONTRACT_SC_FIELD = 'fsm_sc_ocr' |
1249 | FSM_CONTRACT_SC2_FIELD = 'fsm_sc2_ocr' | 1251 | FSM_CONTRACT_SC2_FIELD = 'fsm_sc2_ocr' |
1252 | FS_FIELD = 'fs_ocr' | ||
1253 | FSS_FIELD = 'fss_ocr' | ||
1254 | DP_FIELD = 'dp_ocr' | ||
1250 | 1255 | ||
1251 | 1256 | ||
1252 | BS_CLASSIFY = 10089 | 1257 | BS_CLASSIFY = 10089 |
... | @@ -1303,6 +1308,9 @@ COMPARE_FIELDS = ( | ... | @@ -1303,6 +1308,9 @@ COMPARE_FIELDS = ( |
1303 | HIL_CONTRACT_1_FIELD, | 1308 | HIL_CONTRACT_1_FIELD, |
1304 | HIL_CONTRACT_2_FIELD, | 1309 | HIL_CONTRACT_2_FIELD, |
1305 | HIL_CONTRACT_3_FIELD, | 1310 | HIL_CONTRACT_3_FIELD, |
1311 | FS_FIELD, | ||
1312 | FSS_FIELD, | ||
1313 | DP_FIELD, | ||
1306 | ) | 1314 | ) |
1307 | 1315 | ||
1308 | PRE_COMPARE_FIELDS = ( | 1316 | PRE_COMPARE_FIELDS = ( |
... | @@ -1498,12 +1506,15 @@ SE_DYSYR_VALUE = '无' | ... | @@ -1498,12 +1506,15 @@ SE_DYSYR_VALUE = '无' |
1498 | SE_LAYOUT_VALUE = '旧版-旧打印、新版-新打印' | 1506 | SE_LAYOUT_VALUE = '旧版-旧打印、新版-新打印' |
1499 | SE_GB_NEW_FIELD = ['vinNo'] | 1507 | SE_GB_NEW_FIELD = ['vinNo'] |
1500 | SE_GB_USED_FIELD = ['customerName', 'idNum', 'date'] | 1508 | SE_GB_USED_FIELD = ['customerName', 'idNum', 'date'] |
1501 | SE_BS_FIELD = ['户名', '打印日期', '流水日期', '(担保人1)户名', '(担保人1)打印日期', '(担保人1)流水日期', '(担保人2)户名', '(担保人2)打印日期', '(担保人2)流水日期'] | 1509 | SE_BS_FIELD = ['户名', '打印日期', '流水日期', '(担保人1)户名', '(担保人1)打印日期', '(担保人1)流水日期', '(担保人2)户名', '(担保人2)打印日期', '(担保人2)流水日期', '类型'] |
1502 | SE_HMH_FIELD = ['借款人/承租人姓名', '借款人/承租人证件号', '申请号', '渠道', '签字'] | 1510 | SE_HMH_FIELD = ['借款人/承租人姓名', '借款人/承租人证件号', '申请号', '渠道', '签字'] |
1503 | SE_BD_FIELD = ['被保险人姓名', '被保险人证件号码', '车架号', '机动车损失保险金额', '第三者责任保险金额', '绝对免赔率', '保险起始日期', '保险截止日期', '保单章', '第一受益人', '保险费合计'] | 1511 | SE_BD_FIELD = ['被保险人姓名', '被保险人证件号码', '车架号', '机动车损失保险金额', '第三者责任保险金额', '绝对免赔率', '保险起始日期', '保险截止日期', '保单章', '第一受益人', '保险费合计'] |
1504 | JDMPV_VALUE = ['-', '--', '0%', '0.00', '/', '0', ''] | 1512 | JDMPV_VALUE = ['-', '--', '0%', '0.00', '/', '0', ''] |
1505 | JYPZ_TYPE_1 = ['二手车交易凭证'] | 1513 | JYPZ_TYPE_1 = ['二手车交易凭证'] |
1506 | JYPZ_TYPE_2 = ['BMW官方认证二手车交易凭证', '二手车交易凭证'] | 1514 | JYPZ_TYPE_2 = ['BMW官方认证二手车交易凭证', '二手车交易凭证'] |
1515 | SE_FS_FIELD = ['Hash值', '公章', '财年', '资产负债表内容', '利润表内容'] | ||
1516 | SE_FSS_FIELD = ['公司名称', '公章'] | ||
1517 | SE_DP_FIELD = ['渠道', '姓名', '证件号码', '合同编号(含版本号)', '承诺人签字-电子', '承诺人签字日期-电子'] | ||
1507 | 1518 | ||
1508 | SE_BANK_FIELD = ['accountNo', 'bankName'] | 1519 | SE_BANK_FIELD = ['accountNo', 'bankName'] |
1509 | SE_DDA_FIELD = ['applicationId(1)', 'applicationId(2)', 'bankName', 'companyName', 'customerName', 'idNum', 'accountHolderName', 'accountNo'] | 1520 | SE_DDA_FIELD = ['applicationId(1)', 'applicationId(2)', 'bankName', 'companyName', 'customerName', 'idNum', 'accountHolderName', 'accountNo'] |
... | @@ -1606,7 +1617,7 @@ SE_HIL_CON_1_MAP = { | ... | @@ -1606,7 +1617,7 @@ SE_HIL_CON_1_MAP = { |
1606 | 1617 | ||
1607 | '承租人姓名': (1, 1, 7, '承租人-姓名', None), | 1618 | '承租人姓名': (1, 1, 7, '承租人-姓名', None), |
1608 | '承租人证件号': (1, 1, 7, '承租人-证件号码', None), | 1619 | '承租人证件号': (1, 1, 7, '承租人-证件号码', None), |
1609 | '承租人签字': (6, 6, 7, '签字页-承租人姓名', None), | 1620 | '承租人签字': (6, 6, 7, '签字页-承租人签章', None), |
1610 | 1621 | ||
1611 | '共同承租人姓名': (1, 1, 7, '保证人1-姓名', None), | 1622 | '共同承租人姓名': (1, 1, 7, '保证人1-姓名', None), |
1612 | '共同承租人证件号': (1, 1, 7, '保证人1-证件号码', None), | 1623 | '共同承租人证件号': (1, 1, 7, '保证人1-证件号码', None), |
... | @@ -1634,7 +1645,7 @@ SE_HIL_CON_2_MAP = { | ... | @@ -1634,7 +1645,7 @@ SE_HIL_CON_2_MAP = { |
1634 | '融资租赁期限': (1, None, 3, '融资租赁期限', None), | 1645 | '融资租赁期限': (1, None, 3, '融资租赁期限', None), |
1635 | '抵押人': (1, None, 3, '抵押人姓名/名称', None), | 1646 | '抵押人': (1, None, 3, '抵押人姓名/名称', None), |
1636 | '抵押人证件号码': (1, None, 3, '抵押人证件号码', None), | 1647 | '抵押人证件号码': (1, None, 3, '抵押人证件号码', None), |
1637 | '抵押人签字': (2, None, 3, '签字页-抵押人姓名', None), | 1648 | '抵押人签字': (2, None, 3, '签字页-抵押人签章', None), |
1638 | '抵押人配偶': (1, None, 3, '抵押人配偶姓名/名称', None), | 1649 | '抵押人配偶': (1, None, 3, '抵押人配偶姓名/名称', None), |
1639 | '抵押人配偶证件号码': (1, None, 3, '抵押人配偶证件号码', None), | 1650 | '抵押人配偶证件号码': (1, None, 3, '抵押人配偶证件号码', None), |
1640 | '抵押人配偶签字': (2, None, 3, '签字页-抵押人配偶姓名', None), | 1651 | '抵押人配偶签字': (2, None, 3, '签字页-抵押人配偶姓名', None), |
... | @@ -1817,8 +1828,12 @@ BS_EN = 'Bank Statement' | ... | @@ -1817,8 +1828,12 @@ BS_EN = 'Bank Statement' |
1817 | HIL_CONTRACT_1_EN = '售后回租合同' | 1828 | HIL_CONTRACT_1_EN = '售后回租合同' |
1818 | HIL_CONTRACT_2_EN = '车辆租赁抵押合同' | 1829 | HIL_CONTRACT_2_EN = '车辆租赁抵押合同' |
1819 | HIL_CONTRACT_3_EN = '车辆处置协议' | 1830 | HIL_CONTRACT_3_EN = '车辆处置协议' |
1831 | FS_EN = 'Financial Statement' | ||
1832 | FSS_EN = 'Financial Statement Supplementary' | ||
1833 | DP_EN = 'Down Payment' | ||
1820 | 1834 | ||
1821 | DDA_NO_FIND = '需人工查看DDA或截图' | 1835 | DDA_NO_FIND = '需人工查看DDA或截图' |
1836 | FS_NO_FIND = '未提供财报或财报不完整' | ||
1822 | 1837 | ||
1823 | SKIP_CARD = {SME_BL_EN} | 1838 | SKIP_CARD = {SME_BL_EN} |
1824 | 1839 | ||
... | @@ -1990,8 +2005,8 @@ BD_COMPARE_LOGIC = { | ... | @@ -1990,8 +2005,8 @@ BD_COMPARE_LOGIC = { |
1990 | '机动车损失保险金额': ('机动车损失保险金额', 'se_amount_lte_compare', {}, '保单车损险异常'), | 2005 | '机动车损失保险金额': ('机动车损失保险金额', 'se_amount_lte_compare', {}, '保单车损险异常'), |
1991 | '第三者责任保险金额': ('机动车第三者责任保险金额', 'se_amount_lte_compare', {}, '保单三者险异常'), | 2006 | '第三者责任保险金额': ('机动车第三者责任保险金额', 'se_amount_lte_compare', {}, '保单三者险异常'), |
1992 | '绝对免赔率': ('机动车损失保险绝对免赔率/绝对免赔额', 'se_one_compare', {}, '保单无绝对免赔项'), | 2007 | '绝对免赔率': ('机动车损失保险绝对免赔率/绝对免赔额', 'se_one_compare', {}, '保单无绝对免赔项'), |
1993 | '保险起始日期': ('保险起始日期', 'se_bd_date_compare', {'start': True}, '保单起始时间有误'), | 2008 | '保险起始日期': ('保险起始日期', 'se_bd_date_2_compare', {'start': True}, '保单保险期间错误'), |
1994 | '保险截止日期': ('保险截止日期', 'se_bd_date_compare', {}, '保单截止时间有误'), | 2009 | '保险截止日期': ('保险截止日期', 'se_bd_date_2_compare', {}, '保单保险期间错误'), |
1995 | '保单章': ('保单章', 'se_common_compare', {}, '保单无保单章'), | 2010 | '保单章': ('保单章', 'se_common_compare', {}, '保单无保单章'), |
1996 | '第一受益人': ('特别约定第一受益人', 'se_common_compare', {}, '保单第一受益人需人工核查'), | 2011 | '第一受益人': ('特别约定第一受益人', 'se_common_compare', {}, '保单第一受益人需人工核查'), |
1997 | '保险费合计': ('保险费合计', 'se_amount_lte_compare', {}, '保单保费疑似无法覆盖ASP保险融资'), | 2012 | '保险费合计': ('保险费合计', 'se_amount_lte_compare', {}, '保单保费疑似无法覆盖ASP保险融资'), |
... | @@ -2001,12 +2016,13 @@ BS_COMPARE_LOGIC = { | ... | @@ -2001,12 +2016,13 @@ BS_COMPARE_LOGIC = { |
2001 | '户名': ('role', 'se_bs_one_compare', {}, '主共借人未提供银行流水'), | 2016 | '户名': ('role', 'se_bs_one_compare', {}, '主共借人未提供银行流水'), |
2002 | '(担保人1)户名': ('role', 'se_bs_name_compare', {}, '担保人1未提供银行流水'), | 2017 | '(担保人1)户名': ('role', 'se_bs_name_compare', {}, '担保人1未提供银行流水'), |
2003 | '(担保人2)户名': ('role', 'se_bs_name_compare', {}, '担保人2未提供银行流水'), | 2018 | '(担保人2)户名': ('role', 'se_bs_name_compare', {}, '担保人2未提供银行流水'), |
2004 | '打印日期': ('print_time', 'se_bs_print_date_compare', {'days': 15}, '主共借人银行流水打印日期超过15天'), | 2019 | '打印日期': ('print_time', 'se_bs_print_date_compare', {'days': 30}, '主共借人银行流水打印日期超过30天'), |
2005 | '(担保人1)打印日期': ('print_time', 'se_bs_print_date_compare', {'days': 15}, '担保人1银行流水打印日期超过15天'), | 2020 | '(担保人1)打印日期': ('print_time', 'se_bs_print_date_compare', {'days': 30}, '担保人1银行流水打印日期超过30天'), |
2006 | '(担保人2)打印日期': ('print_time', 'se_bs_print_date_compare', {'days': 15}, '担保人2银行流水打印日期超过15天'), | 2021 | '(担保人2)打印日期': ('print_time', 'se_bs_print_date_compare', {'days': 30}, '担保人2银行流水打印日期超过30天'), |
2007 | '流水日期': ('timedelta', 'se_bs_date_compare', {}, '主共借人银行流水日期不满足3个月'), | 2022 | '流水日期': ('timedelta', 'se_bs_date_compare', {}, '主共借人银行流水区间异常,请核查'), |
2008 | '(担保人1)流水日期': ('timedelta', 'se_bs_date_compare', {}, '担保人1银行流水日期不满足3个月'), | 2023 | '(担保人1)流水日期': ('timedelta', 'se_bs_date_compare', {}, '担保人1银行流水区间异常,请核查'), |
2009 | '(担保人2)流水日期': ('timedelta', 'se_bs_date_compare', {}, '担保人2银行流水日期不满足3个月'), | 2024 | '(担保人2)流水日期': ('timedelta', 'se_bs_date_compare', {}, '担保人2银行流水区间异常,请核查'), |
2025 | '类型': ('bankStatement_type', 'se_bs_type_compare', {}, '高风险经销商流水类型异常'), | ||
2010 | } | 2026 | } |
2011 | 2027 | ||
2012 | BS_COMPARE_LOGIC_AUTO = { | 2028 | BS_COMPARE_LOGIC_AUTO = { |
... | @@ -2016,9 +2032,10 @@ BS_COMPARE_LOGIC_AUTO = { | ... | @@ -2016,9 +2032,10 @@ BS_COMPARE_LOGIC_AUTO = { |
2016 | '打印日期': ('print_time', 'se_bs_print_date_compare', {'days': 30}, '主共借人银行流水打印日期超过30天'), | 2032 | '打印日期': ('print_time', 'se_bs_print_date_compare', {'days': 30}, '主共借人银行流水打印日期超过30天'), |
2017 | '(担保人1)打印日期': ('print_time', 'se_bs_print_date_compare', {'days': 30}, '担保人1银行流水打印日期超过30天'), | 2033 | '(担保人1)打印日期': ('print_time', 'se_bs_print_date_compare', {'days': 30}, '担保人1银行流水打印日期超过30天'), |
2018 | '(担保人2)打印日期': ('print_time', 'se_bs_print_date_compare', {'days': 30}, '担保人2银行流水打印日期超过30天'), | 2034 | '(担保人2)打印日期': ('print_time', 'se_bs_print_date_compare', {'days': 30}, '担保人2银行流水打印日期超过30天'), |
2019 | '流水日期': ('timedelta', 'se_bs_date_compare', {}, '主共借人银行流水日期不满足2个月'), | 2035 | '流水日期': ('timedelta', 'se_bs_date_compare', {}, '主共借人银行流水区间异常,请核查'), |
2020 | '(担保人1)流水日期': ('timedelta', 'se_bs_date_compare', {}, '担保人1银行流水日期不满足2个月'), | 2036 | '(担保人1)流水日期': ('timedelta', 'se_bs_date_compare', {}, '担保人1银行流水区间异常,请核查'), |
2021 | '(担保人2)流水日期': ('timedelta', 'se_bs_date_compare', {}, '担保人2银行流水日期不满足2个月'), | 2037 | '(担保人2)流水日期': ('timedelta', 'se_bs_date_compare', {}, '担保人2银行流水区间异常,请核查'), |
2038 | '类型': ('bankStatement_type', 'se_bs_type_compare', {}, '高风险经销商流水类型异常'), | ||
2022 | } | 2039 | } |
2023 | 2040 | ||
2024 | SPECIAL_REASON = '主共借人未提供银行流水,含担保人需人工查看直系亲属关系' | 2041 | SPECIAL_REASON = '主共借人未提供银行流水,含担保人需人工查看直系亲属关系' |
... | @@ -2053,7 +2070,7 @@ HIL_CONTRACT_1_COMPARE_LOGIC = { | ... | @@ -2053,7 +2070,7 @@ HIL_CONTRACT_1_COMPARE_LOGIC = { |
2053 | 2070 | ||
2054 | '承租人姓名': ('承租人姓名', 'se_name_compare', {}, '售后回租合同承租人姓名与系统不一致'), | 2071 | '承租人姓名': ('承租人姓名', 'se_name_compare', {}, '售后回租合同承租人姓名与系统不一致'), |
2055 | '承租人证件号': ('承租人证件号', 'se_common_compare', {}, '售后回租合同承租人证件号与系统不一致'), | 2072 | '承租人证件号': ('承租人证件号', 'se_common_compare', {}, '售后回租合同承租人证件号与系统不一致'), |
2056 | '承租人签字': ('承租人签字', 'se_contain_compare', {}, '售后回租合同承租人签字与系统不一致'), | 2073 | '承租人签字': ('承租人签字', 'se_common_compare', {}, '售后回租合同承租人签字与系统不一致'), |
2057 | 2074 | ||
2058 | '共同承租人姓名': ('共同承租人姓名', 'se_name_compare', {}, '售后回租合同共同承租人姓名与系统不一致'), | 2075 | '共同承租人姓名': ('共同承租人姓名', 'se_name_compare', {}, '售后回租合同共同承租人姓名与系统不一致'), |
2059 | '共同承租人&抵押人姓名': ('共同承租人&抵押人姓名', 'se_name_compare', {}, '售后回租合同共同承租人&抵押人姓名与系统不一致'), | 2076 | '共同承租人&抵押人姓名': ('共同承租人&抵押人姓名', 'se_name_compare', {}, '售后回租合同共同承租人&抵押人姓名与系统不一致'), |
... | @@ -2083,7 +2100,7 @@ HIL_CONTRACT_2_COMPARE_LOGIC = { | ... | @@ -2083,7 +2100,7 @@ HIL_CONTRACT_2_COMPARE_LOGIC = { |
2083 | '融资租赁期限': ('融资租赁期限', 'se_common_compare', {}, '车辆租赁抵押合同融资租赁期限与系统不一致'), | 2100 | '融资租赁期限': ('融资租赁期限', 'se_common_compare', {}, '车辆租赁抵押合同融资租赁期限与系统不一致'), |
2084 | '抵押人': ('抵押人', 'se_name_compare', {}, '车辆租赁抵押合同抵押人姓名与系统不一致'), | 2101 | '抵押人': ('抵押人', 'se_name_compare', {}, '车辆租赁抵押合同抵押人姓名与系统不一致'), |
2085 | '抵押人证件号码': ('抵押人证件号码', 'se_common_compare', {}, '车辆租赁抵押合同抵押人证件号码与系统不一致'), | 2102 | '抵押人证件号码': ('抵押人证件号码', 'se_common_compare', {}, '车辆租赁抵押合同抵押人证件号码与系统不一致'), |
2086 | '抵押人签字': ('抵押人签字', 'se_contain_compare', {}, '车辆租赁抵押合同抵押人签字与系统承租人姓名不一致'), | 2103 | '抵押人签字': ('抵押人签字', 'se_common_compare', {}, '车辆租赁抵押合同抵押人签字与系统承租人姓名不一致'), |
2087 | '抵押人配偶': ('抵押人配偶', 'se_name_compare', {}, '车辆租赁抵押合同抵押人配偶姓名与系统不一致'), | 2104 | '抵押人配偶': ('抵押人配偶', 'se_name_compare', {}, '车辆租赁抵押合同抵押人配偶姓名与系统不一致'), |
2088 | '抵押人配偶证件号码': ('抵押人配偶证件号码', 'se_common_compare', {}, '车辆租赁抵押合同抵押人配偶证件号码与系统不一致'), | 2105 | '抵押人配偶证件号码': ('抵押人配偶证件号码', 'se_common_compare', {}, '车辆租赁抵押合同抵押人配偶证件号码与系统不一致'), |
2089 | '抵押人配偶签字': ('抵押人配偶签字', 'se_contain_compare', {}, '车辆租赁抵押合同抵押人签字与系统承租人配偶姓名不一致'), | 2106 | '抵押人配偶签字': ('抵押人配偶签字', 'se_contain_compare', {}, '车辆租赁抵押合同抵押人签字与系统承租人配偶姓名不一致'), |
... | @@ -2098,7 +2115,7 @@ HIL_CONTRACT_3_COMPARE_LOGIC = { | ... | @@ -2098,7 +2115,7 @@ HIL_CONTRACT_3_COMPARE_LOGIC = { |
2098 | '合同编号-正文': ('合同编号-正文', 'se_common_compare', {}, '车辆处置协议正文合同编号与系统不一致'), | 2115 | '合同编号-正文': ('合同编号-正文', 'se_common_compare', {}, '车辆处置协议正文合同编号与系统不一致'), |
2099 | '姓名/名称': ('姓名/名称', 'se_name_compare', {}, '车辆处置协议签字页客户姓名与系统不一致'), | 2116 | '姓名/名称': ('姓名/名称', 'se_name_compare', {}, '车辆处置协议签字页客户姓名与系统不一致'), |
2100 | '自然人身份证件号码/法人执照号码': ('自然人身份证件号码/法人执照号码', 'se_common_compare', {}, '车辆处置协议签字页客户证件号码与系统不一致'), | 2117 | '自然人身份证件号码/法人执照号码': ('自然人身份证件号码/法人执照号码', 'se_common_compare', {}, '车辆处置协议签字页客户证件号码与系统不一致'), |
2101 | '承租人签字': ('承租人签字', 'se_contain_compare', {}, '车辆处置协议承租人签字与系统承租人姓名不一致'), | 2118 | '承租人签字': ('承租人签字', 'se_common_compare', {}, '车辆处置协议承租人签字与系统承租人姓名不一致'), |
2102 | } | 2119 | } |
2103 | 2120 | ||
2104 | HT_QRS_COMPARE_LOGIC = { | 2121 | HT_QRS_COMPARE_LOGIC = { |
... | @@ -2159,6 +2176,29 @@ HT_COMPARE_LOGIC = { | ... | @@ -2159,6 +2176,29 @@ HT_COMPARE_LOGIC = { |
2159 | '无ASP产品': ('无ASP产品', 'se_self_compare_other_asp', {}, GZS_REASON_1), | 2176 | '无ASP产品': ('无ASP产品', 'se_self_compare_other_asp', {}, GZS_REASON_1), |
2160 | } | 2177 | } |
2161 | 2178 | ||
2179 | # 格式:'xueao给的excel字段名':('数据库字段名','比对逻辑','特殊处理可以忽略','比对不合格时的返回内容') | ||
2180 | FS_COMPARE_LOGIC = { | ||
2181 | 'Hash值': ('code', 'hash_code_compare', {}, '财报Hash值与系统不一致'), | ||
2182 | '公章': ('stamp', 'stamp_dict_compare', {}, '财报无公章'), | ||
2183 | '财年': ('财年', 'fiscal_year_compare', {}, '财报所属财年错误'), | ||
2184 | '资产负债表内容': ('资产负债表内容', 'input_list_not_zero_compare', {}, '财报资产负债表为空'), | ||
2185 | '利润表内容': ('利润表内容', 'input_list_not_zero_compare', {}, '财报利润表为空'), | ||
2186 | } | ||
2187 | |||
2188 | FSS_COMPARE_LOGIC = { | ||
2189 | '公司名称': ('title', 'se_company_compare', {}, '财报情况说明公司名称错误'), | ||
2190 | '公章': ('stamp', 'stamp_str_compare', {}, '财报情况说明无公章'), | ||
2191 | } | ||
2192 | |||
2193 | DP_COMPARE_LOGIC = { | ||
2194 | '渠道': ('financial_org_name', 'se_common_compare', {'remove_space': True}, '首付款支付承诺书渠道错误'), | ||
2195 | '姓名': ('main_borrower_name', 'se_common_compare', {'remove_all_space': True}, '首付款支付承诺书姓名与系统不一致'), | ||
2196 | '证件号码': ('main_borrower_id_no', 'se_common_compare', {'remove_space': True}, '首付款支付承诺书证件号码与系统不一致'), | ||
2197 | '合同编号(含版本号)': ('apply_no', 'se_common_compare', {'remove_space': True}, '首付款支付承诺书合同编号与系统不一致'), | ||
2198 | '承诺人签字-电子': ('promisor_signature', 'se_common_compare', {'remove_all_space': True}, '首付款支付承诺书承诺人签字与系统不一致'), | ||
2199 | '承诺人签字日期-电子': ('promisor_signature_date', 'se_have_compare', {}, 'N-首付款支付承诺书缺少签字日期'), | ||
2200 | } | ||
2201 | |||
2162 | AFC_HT_DATE_FIELDS = ['主借人日期', '共借人日期', '保证人日期1', '保证人日期2'] | 2202 | AFC_HT_DATE_FIELDS = ['主借人日期', '共借人日期', '保证人日期1', '保证人日期2'] |
2163 | 2203 | ||
2164 | # MVC_OCR_FIELD = 'mvc_ocr' | 2204 | # MVC_OCR_FIELD = 'mvc_ocr' |
... | @@ -2187,6 +2227,9 @@ SE_COMPARE_FIELD = { | ... | @@ -2187,6 +2227,9 @@ SE_COMPARE_FIELD = { |
2187 | HIL_CONTRACT_1_EN: (HIL_CONTRACT_1_FIELD, HIL_CONTRACT_1_COMPARE_LOGIC, False), | 2227 | HIL_CONTRACT_1_EN: (HIL_CONTRACT_1_FIELD, HIL_CONTRACT_1_COMPARE_LOGIC, False), |
2188 | HIL_CONTRACT_2_EN: (HIL_CONTRACT_2_FIELD, HIL_CONTRACT_2_COMPARE_LOGIC, False), | 2228 | HIL_CONTRACT_2_EN: (HIL_CONTRACT_2_FIELD, HIL_CONTRACT_2_COMPARE_LOGIC, False), |
2189 | HIL_CONTRACT_3_EN: (HIL_CONTRACT_3_FIELD, HIL_CONTRACT_3_COMPARE_LOGIC, False), | 2229 | HIL_CONTRACT_3_EN: (HIL_CONTRACT_3_FIELD, HIL_CONTRACT_3_COMPARE_LOGIC, False), |
2230 | FS_EN: (FS_FIELD, FS_COMPARE_LOGIC, False), | ||
2231 | FSS_EN: (FSS_FIELD, FSS_COMPARE_LOGIC, False), | ||
2232 | DP_EN: (DP_FIELD, DP_COMPARE_LOGIC, False), | ||
2190 | } | 2233 | } |
2191 | 2234 | ||
2192 | SE_COMPARE_FIELD_AUTO = { | 2235 | SE_COMPARE_FIELD_AUTO = { |
... | @@ -2534,6 +2577,23 @@ FSM_ACTIVITED_STATUS = { | ... | @@ -2534,6 +2577,23 @@ FSM_ACTIVITED_STATUS = { |
2534 | "APARD": "Activated-Review done", | 2577 | "APARD": "Activated-Review done", |
2535 | } | 2578 | } |
2536 | 2579 | ||
2580 | # 财务报表分类标签 | ||
2581 | FINANCIAL_STATEMENT_CLASSIFY_LIST = [97, 98, 99] | ||
2582 | # 财务报表sheet名称 | ||
2583 | FINANCIAL_SHEET_NAME = "财务报表" | ||
2584 | |||
2585 | # 财报情况说明分类标签 | ||
2586 | FINANCIAL_EXPLANATION_CLASSIFY_LIST = [100] | ||
2587 | # 财报情况说明sheet名称 | ||
2588 | FINANCIAL_EXPLANATION_SHEET_NAME = "财报情况说明" | ||
2589 | |||
2590 | # 首付款支付承诺书分类标签 | ||
2591 | DOWN_PAYMENT_CLASSIFY_LIST = [96] | ||
2592 | # 首付款支付承诺书sheet名称 | ||
2593 | DOWN_PAYMENT_SHEET_NAME = "首付款支付承诺书" | ||
2594 | |||
2595 | NEW_FILE_COMPARE_SET = [96] | ||
2596 | |||
2537 | # Jira-4562 - 银行流水首页提取关键词 | 2597 | # Jira-4562 - 银行流水首页提取关键词 |
2538 | INCOME_KEYWORDS_LIST = ["养老金", "社保", "代发工资", "工资入账", "奖金", "养老保险", "代发", "工资"] | 2598 | INCOME_KEYWORDS_LIST = ["养老金", "社保", "代发工资", "工资入账", "奖金", "养老保险", "代发", "工资"] |
2539 | INCOME_KEYWORDS_DICT = { | 2599 | INCOME_KEYWORDS_DICT = { | ... | ... |
... | @@ -4,5 +4,10 @@ from . import views | ... | @@ -4,5 +4,10 @@ from . import views |
4 | 4 | ||
5 | urlpatterns = [ | 5 | urlpatterns = [ |
6 | path(r'', views.DocView.as_view()), | 6 | path(r'', views.DocView.as_view()), |
7 | path(r'query/employee', views.EmployeeView.as_view()), | ||
8 | path(r'query/greenBookHistoryFile', views.SearchGBHistoryFileView.as_view()), | ||
9 | path(r'download/greenBookHistoryFile', views.DownloadGBHistoryFileView.as_view()), | ||
10 | path(r'invoice/downloadExcel', views.InvoiceExcelView.as_view()), | ||
11 | path(r'invoice/queryInfo', views.InvoiceQueryInfoView.as_view()), | ||
7 | path(r'contract/v1', views.SEContractView.as_view()), | 12 | path(r'contract/v1', views.SEContractView.as_view()), |
8 | ] | 13 | ] | ... | ... |
... | @@ -162,7 +162,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -162,7 +162,7 @@ class Command(BaseCommand, LoggerMixin): |
162 | 162 | ||
163 | @staticmethod | 163 | @staticmethod |
164 | def get_path(name, img_output_dir, wb_output_dir, pdf_output_dir): | 164 | def get_path(name, img_output_dir, wb_output_dir, pdf_output_dir): |
165 | time_stamp = datetime.now().strftime('%Y-%m-%d_%H:%M:%S') | 165 | time_stamp = datetime.now().strftime('%Y-%m-%d_%H_%M_%S') |
166 | new_name = '{0}_{1}'.format(time_stamp, name) | 166 | new_name = '{0}_{1}'.format(time_stamp, name) |
167 | img_save_path = os.path.join(img_output_dir, new_name) | 167 | img_save_path = os.path.join(img_output_dir, new_name) |
168 | pdf_save_path = os.path.join(pdf_output_dir, new_name) | 168 | pdf_save_path = os.path.join(pdf_output_dir, new_name) | ... | ... |
... | @@ -320,7 +320,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -320,7 +320,7 @@ class Command(BaseCommand, LoggerMixin): |
320 | true_file_set.add(os_error_filename_set.pop()) | 320 | true_file_set.add(os_error_filename_set.pop()) |
321 | for name in true_file_set: | 321 | for name in true_file_set: |
322 | time.sleep(10) | 322 | time.sleep(10) |
323 | unique_folder_name = '{0}_{1}'.format(datetime.now().strftime('%Y-%m-%d_%H:%M:%S'), name) | 323 | unique_folder_name = '{0}_{1}'.format(datetime.now().strftime('%Y-%m-%d_%H_%M_%S'), name) |
324 | path = os.path.join(input_dir, name) | 324 | path = os.path.join(input_dir, name) |
325 | 325 | ||
326 | try: | 326 | try: | ... | ... |
... | @@ -272,7 +272,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -272,7 +272,7 @@ class Command(BaseCommand, LoggerMixin): |
272 | 272 | ||
273 | @staticmethod | 273 | @staticmethod |
274 | def get_path(name, img_output_dir, wb_output_dir, pdf_output_dir, seperate_dir_map): | 274 | def get_path(name, img_output_dir, wb_output_dir, pdf_output_dir, seperate_dir_map): |
275 | time_stamp = datetime.now().strftime('%Y-%m-%d_%H:%M:%S') | 275 | time_stamp = datetime.now().strftime('%Y-%m-%d_%H_%M_%S') |
276 | new_name = '{0}_{1}'.format(time_stamp, name) | 276 | new_name = '{0}_{1}'.format(time_stamp, name) |
277 | img_save_path = os.path.join(img_output_dir, new_name) | 277 | img_save_path = os.path.join(img_output_dir, new_name) |
278 | pdf_save_path = os.path.join(pdf_output_dir, new_name) | 278 | pdf_save_path = os.path.join(pdf_output_dir, new_name) | ... | ... |
... | @@ -186,7 +186,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -186,7 +186,7 @@ class Command(BaseCommand, LoggerMixin): |
186 | 186 | ||
187 | @staticmethod | 187 | @staticmethod |
188 | def get_path(name, img_output_dir, wb_output_dir, pdf_output_dir): | 188 | def get_path(name, img_output_dir, wb_output_dir, pdf_output_dir): |
189 | time_stamp = datetime.now().strftime('%Y-%m-%d_%H:%M:%S') | 189 | time_stamp = datetime.now().strftime('%Y-%m-%d_%H_%M_%S') |
190 | new_name = '{0}_{1}'.format(time_stamp, name) | 190 | new_name = '{0}_{1}'.format(time_stamp, name) |
191 | img_save_path = os.path.join(img_output_dir, new_name) | 191 | img_save_path = os.path.join(img_output_dir, new_name) |
192 | pdf_save_path = os.path.join(pdf_output_dir, new_name) | 192 | pdf_save_path = os.path.join(pdf_output_dir, new_name) | ... | ... |
... | @@ -409,7 +409,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -409,7 +409,7 @@ class Command(BaseCommand, LoggerMixin): |
409 | 409 | ||
410 | @staticmethod | 410 | @staticmethod |
411 | def get_path(name, img_output_dir, wb_output_dir, pdf_output_dir): | 411 | def get_path(name, img_output_dir, wb_output_dir, pdf_output_dir): |
412 | time_stamp = datetime.now().strftime('%Y-%m-%d_%H:%M:%S') | 412 | time_stamp = datetime.now().strftime('%Y-%m-%d_%H_%M_%S') |
413 | new_name = '{0}_{1}'.format(time_stamp, name) | 413 | new_name = '{0}_{1}'.format(time_stamp, name) |
414 | img_save_path = os.path.join(img_output_dir, new_name) | 414 | img_save_path = os.path.join(img_output_dir, new_name) |
415 | pdf_save_path = os.path.join(pdf_output_dir, new_name) | 415 | pdf_save_path = os.path.join(pdf_output_dir, new_name) | ... | ... |
... | @@ -965,13 +965,21 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -965,13 +965,21 @@ class Command(BaseCommand, LoggerMixin): |
965 | print_date = bs_info.get('end_date', '').strftime("%Y-%m-%d") | 965 | print_date = bs_info.get('end_date', '').strftime("%Y-%m-%d") |
966 | except Exception as e: | 966 | except Exception as e: |
967 | print_date = '' | 967 | print_date = '' |
968 | is_eBank = bs_info.get('e_bank', False) | ||
969 | if is_eBank: | ||
970 | bs_verify = bs_info.get('verify_res_ebank', True) | ||
971 | else: | ||
972 | bs_verify = bs_info.get('verify_res_paper_bank', True) | ||
968 | res.append( | 973 | res.append( |
969 | { | 974 | { |
975 | 'bankStatement_type': str(bs_info.get('classify', '')), | ||
970 | 'role': bs_info.get('role', ''), | 976 | 'role': bs_info.get('role', ''), |
971 | 'print_time': print_date, | 977 | 'print_time': print_date, |
972 | 'timedelta': bs_info.get('timedelta', ''), | 978 | 'timedelta': bs_info.get('timedelta', ''), |
973 | 'verify': bs_info.get('verify_res_ebank', True), | 979 | # 'verify': bs_info.get('verify_res_ebank', True), |
974 | 'e_bank': bs_info.get('e_bank', False), | 980 | 'verify': bs_verify, |
981 | # 'e_bank': bs_info.get('e_bank', False), | ||
982 | 'e_bank': is_eBank, | ||
975 | 'income_keywords': income_keywords_str | 983 | 'income_keywords': income_keywords_str |
976 | } | 984 | } |
977 | ) | 985 | ) |
... | @@ -1037,6 +1045,13 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -1037,6 +1045,13 @@ class Command(BaseCommand, LoggerMixin): |
1037 | tmp_res = page_info_dict.get(str(pno2), {}).get(key1, '') | 1045 | tmp_res = page_info_dict.get(str(pno2), {}).get(key1, '') |
1038 | img_pno = pno1 | 1046 | img_pno = pno1 |
1039 | res[key] = tmp_res | 1047 | res[key] = tmp_res |
1048 | # 添加处理, | ||
1049 | # [售后回租合同] - 如果 key 是 "承租人签字", 且内容中包含 签署日期:XXXX, 则将签署日期去除 | ||
1050 | # [车辆租赁抵押合同] - 如果 key 是 "" | ||
1051 | if key == '承租人签字' and tmp_res is not None and '签署日期' in tmp_res: | ||
1052 | res[key] = tmp_res.split('签署日期')[0] | ||
1053 | if key == "抵押人签字" and tmp_res is not None and "签署日期" in tmp_res: | ||
1054 | res[key] = tmp_res.split("签署日期")[0] | ||
1040 | res.setdefault(consts.IMG_PATH_KEY, dict())[key] = page_info_dict.get(str(img_pno), {}).get( | 1055 | res.setdefault(consts.IMG_PATH_KEY, dict())[key] = page_info_dict.get(str(img_pno), {}).get( |
1041 | consts.IMG_PATH_KEY, '') | 1056 | consts.IMG_PATH_KEY, '') |
1042 | else: | 1057 | else: |
... | @@ -1639,7 +1654,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -1639,7 +1654,7 @@ class Command(BaseCommand, LoggerMixin): |
1639 | try: | 1654 | try: |
1640 | channel, img_path, text_list = img_queue.get(block=False) | 1655 | channel, img_path, text_list = img_queue.get(block=False) |
1641 | except Exception as e: | 1656 | except Exception as e: |
1642 | # self.online_log.info('{0} [img_2_ocr_1] [queue empty]'.format(self.log_base)) | 1657 | # # self.online_log.info('{0} [img_2_ocr_1] [queue empty]'.format(self.log_base)) |
1643 | time.sleep(self.sleep_time_img_get) | 1658 | time.sleep(self.sleep_time_img_get) |
1644 | continue | 1659 | continue |
1645 | else: | 1660 | else: |
... | @@ -1668,6 +1683,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -1668,6 +1683,7 @@ class Command(BaseCommand, LoggerMixin): |
1668 | '[error={4}]'.format(self.log_base, times, url, img_path, | 1683 | '[error={4}]'.format(self.log_base, times, url, img_path, |
1669 | traceback.format_exc())) | 1684 | traceback.format_exc())) |
1670 | else: | 1685 | else: |
1686 | self.online_log.info('{0} [ocr_1 start] [img={1}] [url={2}]'.format(self.log_base, img_path, url)) | ||
1671 | ocr_1_res = ocr_1_response.json() | 1687 | ocr_1_res = ocr_1_response.json() |
1672 | end_time = time.time() | 1688 | end_time = time.time() |
1673 | speed_time = int(end_time - start_time) | 1689 | speed_time = int(end_time - start_time) |
... | @@ -1684,32 +1700,41 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -1684,32 +1700,41 @@ class Command(BaseCommand, LoggerMixin): |
1684 | self.log_base, img_path, traceback.format_exc())) | 1700 | self.log_base, img_path, traceback.format_exc())) |
1685 | else: | 1701 | else: |
1686 | try: | 1702 | try: |
1703 | self.online_log.info('{0} [del json_data_1] [img={1}] '.format(self.log_base, img_path)) | ||
1687 | del json_data_1 | 1704 | del json_data_1 |
1688 | # /data/bmw-ocr-data/AFC/tmp/6/img/page_0_img_0.jpeg | 1705 | # /data/bmw-ocr-data/AFC/tmp/6/img/page_0_img_0.jpeg |
1689 | # AFC_2 | 1706 | # AFC_2 |
1690 | path_split = img_path.split('/') | 1707 | path_split = img_path.split('/') |
1691 | task_str = consts.SPLIT_STR.join((path_split[-5], path_split[-3])) | 1708 | task_str = consts.SPLIT_STR.join((path_split[-5], path_split[-3])) |
1692 | 1709 | ||
1710 | self.online_log.info('{0} [before lock] [img={1}] '.format(self.log_base, img_path)) | ||
1693 | with lock: | 1711 | with lock: |
1712 | self.online_log.info('{0} [get lock] [img={1}] '.format(self.log_base, img_path)) | ||
1694 | doc_res_dict = res_dict.setdefault(task_str, {}) | 1713 | doc_res_dict = res_dict.setdefault(task_str, {}) |
1695 | doc_res_dict[img_path] = ocr_1_res | 1714 | doc_res_dict[img_path] = ocr_1_res |
1696 | res_dict[task_str] = doc_res_dict | 1715 | res_dict[task_str] = doc_res_dict |
1697 | todo_count = todo_count_dict.get(task_str) | 1716 | todo_count = todo_count_dict.get(task_str) |
1698 | if todo_count == 1: | 1717 | if todo_count == 1: |
1699 | finish_queue.put(task_str) | 1718 | finish_queue.put(task_str) |
1719 | self.online_log.info('{0} [ocr_1 to finish_queue] [img={1}] '.format(self.log_base, img_path)) | ||
1700 | del todo_count_dict[task_str] | 1720 | del todo_count_dict[task_str] |
1721 | self.online_log.info('{0} [del todo_count_dict] [img={1}] '.format(self.log_base, img_path)) | ||
1701 | else: | 1722 | else: |
1702 | todo_count_dict[task_str] = todo_count - 1 | 1723 | todo_count_dict[task_str] = todo_count - 1 |
1724 | self.online_log.info('{0} [after lock] [img={1}] '.format(self.log_base, img_path)) | ||
1703 | except Exception as e: | 1725 | except Exception as e: |
1704 | self.online_log.error('{0} [process error (store ocr res)] [img_path={1}] [error={2}]'.format( | 1726 | self.online_log.error('{0} [process error (store ocr res)] [img_path={1}] [error={2}]'.format( |
1705 | self.log_base, img_path, traceback.format_exc())) | 1727 | self.log_base, img_path, traceback.format_exc())) |
1706 | 1728 | ||
1707 | def res_2_wb(self, res_dict, img_queue, finish_queue, error_list): | 1729 | def res_2_wb(self, res_dict, img_queue, finish_queue, error_list): |
1730 | self.online_log.info('{0} [res_2_wb] [get task] [queue running] [finish_queue_size={1}]'.format(self.log_base, finish_queue.qsize())) | ||
1708 | while len(error_list) == 0 or not img_queue.empty() or not finish_queue.empty(): | 1731 | while len(error_list) == 0 or not img_queue.empty() or not finish_queue.empty(): |
1709 | try: | 1732 | try: |
1733 | self.online_log.info('{0} [res_2_wb] [finish_queue.get1] [finish_queue_size={1}] [img_queue_size={2}]'.format(self.log_base, finish_queue.qsize(), img_queue.qsize())) | ||
1710 | task_str = finish_queue.get(block=False) | 1734 | task_str = finish_queue.get(block=False) |
1735 | self.online_log.info('{0} [res_2_wb] [finish_queue.get2]'.format(self.log_base)) | ||
1711 | except Exception as e: | 1736 | except Exception as e: |
1712 | # self.online_log.info('{0} [res_2_wb] [queue empty]'.format(self.log_base)) | 1737 | self.online_log.info('{0} [res_2_wb] [queue empty]'.format(self.log_base)) |
1713 | time.sleep(self.sleep_time_task_get) | 1738 | time.sleep(self.sleep_time_task_get) |
1714 | continue | 1739 | continue |
1715 | else: | 1740 | else: |
... | @@ -1747,6 +1772,12 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -1747,6 +1772,12 @@ class Command(BaseCommand, LoggerMixin): |
1747 | contract_result = {} | 1772 | contract_result = {} |
1748 | contract_result_compare = {} | 1773 | contract_result_compare = {} |
1749 | income_keywords_dictionary = {"income_keywords": []} | 1774 | income_keywords_dictionary = {"income_keywords": []} |
1775 | # 添加财报三个报表的处理 | ||
1776 | financial_statement_dict = {} | ||
1777 | # 添加财报情况说明的处理 | ||
1778 | financial_explanation_dict = {} | ||
1779 | # 添加首付款支付承诺书的处理 | ||
1780 | down_payment_dict = {} | ||
1750 | res_list = [] | 1781 | res_list = [] |
1751 | interest_keyword = Keywords.objects.filter( | 1782 | interest_keyword = Keywords.objects.filter( |
1752 | type=KeywordsType.INTEREST.value, on_off=True).values_list('keyword', flat=True) | 1783 | type=KeywordsType.INTEREST.value, on_off=True).values_list('keyword', flat=True) |
... | @@ -1771,11 +1802,75 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -1771,11 +1802,75 @@ class Command(BaseCommand, LoggerMixin): |
1771 | for part_idx, ocr_data in enumerate(ocr_data_list): | 1802 | for part_idx, ocr_data in enumerate(ocr_data_list): |
1772 | part_idx = part_idx + 1 | 1803 | part_idx = part_idx + 1 |
1773 | classify = ocr_data.get('classify') | 1804 | classify = ocr_data.get('classify') |
1805 | self.online_log.info('{0} [task={1}] [classify={2}]'.format(self.log_base, task_str, classify)) | ||
1774 | if classify is None: | 1806 | if classify is None: |
1775 | res_list.append((pno, ino, part_idx, consts.RES_FAILED_3)) | 1807 | res_list.append((pno, ino, part_idx, consts.RES_FAILED_3)) |
1776 | self.online_log.warn('{0} [ocr_1 res error] [img={1}]'.format( | 1808 | self.online_log.warn('{0} [ocr_1 res error] [img={1}]'.format( |
1777 | self.log_base, img_path)) | 1809 | self.log_base, img_path)) |
1778 | continue | 1810 | continue |
1811 | elif classify in consts.FINANCIAL_STATEMENT_CLASSIFY_LIST: | ||
1812 | # 添加到 res_list 中 | ||
1813 | res_list.append((pno, ino, part_idx, consts.RES_SUCCESS_FINANCIAL_STATEMENT)) | ||
1814 | # 只要分类为财报三个报表的,就在 financial_statement_dict 中添加对应的 code 和 stamp 两个dict | ||
1815 | if "code" not in financial_statement_dict: | ||
1816 | financial_statement_dict["code"] = {} | ||
1817 | if "stamp" not in financial_statement_dict: | ||
1818 | financial_statement_dict["stamp"] = {} | ||
1819 | |||
1820 | financial_statement_table_name = None | ||
1821 | if classify == 97: | ||
1822 | financial_statement_table_name = "balance_sheet" | ||
1823 | elif classify == 98: | ||
1824 | financial_statement_table_name = "income_statement" | ||
1825 | elif classify == 99: | ||
1826 | financial_statement_table_name = "cash_flow_statement" | ||
1827 | if financial_statement_table_name is not None: | ||
1828 | if "id_code" in ocr_data: | ||
1829 | id_code = ocr_data.get("id_code", "") | ||
1830 | financial_statement_dict["code"][financial_statement_table_name] = id_code | ||
1831 | if "stamp" in ocr_data: | ||
1832 | stamp = ocr_data.get("stamp", "") | ||
1833 | financial_statement_dict["stamp"][financial_statement_table_name] = stamp | ||
1834 | elif classify in consts.FINANCIAL_EXPLANATION_CLASSIFY_LIST: | ||
1835 | # 添加到 res_list 中 | ||
1836 | res_list.append((pno, ino, part_idx, consts.RES_SUCCESS_FINANCIAL_STATEMENT)) | ||
1837 | # 只要分类为财报情况说明的,就在 financial_explanation_dict 中添加对应的 title 和 stamp 两个dict | ||
1838 | if "title" not in financial_explanation_dict: | ||
1839 | financial_explanation_dict["title"] = {} | ||
1840 | if "stamp" not in financial_explanation_dict: | ||
1841 | financial_explanation_dict["stamp"] = {} | ||
1842 | |||
1843 | if "title" in ocr_data: | ||
1844 | title = ocr_data.get("title", "") | ||
1845 | financial_explanation_dict["title"] = title | ||
1846 | if "stamp" in ocr_data: | ||
1847 | stamp = ocr_data.get("stamp", "") | ||
1848 | financial_explanation_dict["stamp"] = stamp | ||
1849 | elif classify in consts.DOWN_PAYMENT_CLASSIFY_LIST: | ||
1850 | # 添加到 res_list 中 | ||
1851 | res_list.append((pno, ino, part_idx, consts.RES_SUCCESS_DOWN_PAYMENT)) | ||
1852 | # 1-金融机构名称 | ||
1853 | financial_org_name = ocr_data.get("financial_org_name", "") | ||
1854 | down_payment_dict["financial_org_name"] = financial_org_name | ||
1855 | # 2-主借人姓名 | ||
1856 | main_borrower_name = ocr_data.get("main_borrower_name", "") | ||
1857 | down_payment_dict["main_borrower_name"] = main_borrower_name | ||
1858 | # 3-主借人证件号码 | ||
1859 | main_borrower_id_no = ocr_data.get("main_borrower_id_no", "") | ||
1860 | down_payment_dict["main_borrower_id_no"] = main_borrower_id_no | ||
1861 | # 4-申请编号 | ||
1862 | apply_no = ocr_data.get("apply_no", "") | ||
1863 | down_payment_dict["apply_no"] = apply_no | ||
1864 | # 5-抵押/租赁合同名称 | ||
1865 | contract_name = ocr_data.get("contract_name", "") | ||
1866 | down_payment_dict["contract_name"] = contract_name | ||
1867 | # 6-承诺人签字 | ||
1868 | promisor_signature = ocr_data.get("promisor_signature", "") | ||
1869 | down_payment_dict["promisor_signature"] = promisor_signature | ||
1870 | # 7-承诺人签字日期 | ||
1871 | promisor_signature_date = ocr_data.get("promisor_signature_date", "") | ||
1872 | down_payment_dict["promisor_signature_date"] = promisor_signature_date | ||
1873 | |||
1779 | elif classify in consts.OTHER_CLASSIFY_SET: # 其他类 | 1874 | elif classify in consts.OTHER_CLASSIFY_SET: # 其他类 |
1780 | res_list.append((pno, ino, part_idx, consts.RES_SUCCESS_OTHER)) | 1875 | res_list.append((pno, ino, part_idx, consts.RES_SUCCESS_OTHER)) |
1781 | continue | 1876 | continue |
... | @@ -1962,7 +2057,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -1962,7 +2057,7 @@ class Command(BaseCommand, LoggerMixin): |
1962 | # src_excel_path = os.path.join(doc_data_path, 'src.xlsx') | 2057 | # src_excel_path = os.path.join(doc_data_path, 'src.xlsx') |
1963 | # wb.save(src_excel_path) | 2058 | # wb.save(src_excel_path) |
1964 | #need_follow表示在上传edms时文件名是否要添加"关注"两字 | 2059 | #need_follow表示在上传edms时文件名是否要添加"关注"两字 |
1965 | count_list, need_follow = wb.rebuild(merged_bs_summary, license_summary, res_list, doc.document_scheme, contract_result, doc.metadata) | 2060 | count_list, need_follow = wb.rebuild(merged_bs_summary, license_summary, res_list, doc.document_scheme, contract_result, doc.metadata, financial_statement_dict, financial_explanation_dict, down_payment_dict) |
1966 | wb.save(excel_path) | 2061 | wb.save(excel_path) |
1967 | 2062 | ||
1968 | except Exception as e: | 2063 | except Exception as e: |
... | @@ -2063,46 +2158,84 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -2063,46 +2158,84 @@ class Command(BaseCommand, LoggerMixin): |
2063 | license_summary[consts.BS_CLASSIFY] = bs_rebuild | 2158 | license_summary[consts.BS_CLASSIFY] = bs_rebuild |
2064 | 2159 | ||
2065 | # 比对 | 2160 | # 比对 |
2066 | if len(license_summary) > 0 and doc.document_scheme != consts.DOC_SCHEME_LIST[2]: | 2161 | if len(license_summary) > 0 or classify in consts.NEW_FILE_COMPARE_SET: |
2162 | if doc.document_scheme != consts.DOC_SCHEME_LIST[2]: | ||
2163 | # if len(license_summary) > 0 and doc.document_scheme != consts.DOC_SCHEME_LIST[2]: | ||
2164 | try: | ||
2165 | is_ca = True if doc.document_scheme == consts.DOC_SCHEME_LIST[0] else False | ||
2166 | # 更新OCR累计识别结果表 | ||
2167 | if business_type == consts.HIL_PREFIX: | ||
2168 | result_class = HILOCRResult if is_ca else HILSEOCRResult | ||
2169 | try: | ||
2170 | res_obj = atomicSaveDBHIL(self,result_class,doc,license_summary,ic_merge,rp_merge, task_str, financial_statement_dict, financial_explanation_dict, down_payment_dict) | ||
2171 | except Exception as e: | ||
2172 | # 遇到报错重试一次,希望解决两个文件首次入库都插入的问题 | ||
2173 | self.online_log.error('{0} [process error (ocr result save) retry] [task={1}] [error={2}]'.format(self.log_base, task_str, traceback.format_exc())) | ||
2174 | res_obj = atomicSaveDBHIL(self,result_class,doc,license_summary,ic_merge,rp_merge, task_str, financial_statement_dict, financial_explanation_dict, down_payment_dict) | ||
2175 | else: | ||
2176 | result_class = AFCOCRResult if is_ca else AFCSEOCRResult | ||
2177 | try: | ||
2178 | res_obj = atomicSaveDBAFC(self,result_class,doc,license_summary,ic_merge,rp_merge, task_str, financial_statement_dict, financial_explanation_dict, down_payment_dict) | ||
2179 | except Exception as e: | ||
2180 | # 遇到报错重试一次,希望解决两个文件首次入库都插入的问题 | ||
2181 | self.online_log.error('{0} [process error (ocr result save) retry] [task={1}] [error={2}]'.format(self.log_base, task_str, traceback.format_exc())) | ||
2182 | res_obj = atomicSaveDBAFC(self,result_class,doc,license_summary,ic_merge,rp_merge, task_str, financial_statement_dict, financial_explanation_dict, down_payment_dict) | ||
2183 | |||
2184 | except Exception as e: | ||
2185 | self.online_log.error( | ||
2186 | '{0} [process error (ocr result save)] [task={1}] [error={2}]'.format( | ||
2187 | self.log_base, task_str, traceback.format_exc())) | ||
2188 | else: | ||
2189 | self.online_log.info('{0} [ocr result save success] [task={1}] [res_id={2}]'.format( | ||
2190 | self.log_base, task_str, res_obj.id)) | ||
2191 | # 触发比对 | ||
2192 | try: | ||
2193 | # 是否fsm | ||
2194 | cms_status_class = HILCmsStatusInfo if business_type in consts.HIL_SET else AFCCmsStatusInfo | ||
2195 | cms_status_info = cms_status_class.objects.filter(application_id=doc.application_id).first() | ||
2196 | is_fsm = cms_status_info is not None and cms_status_info.is_fsm == 1 | ||
2197 | self.online_log.info('{0} [isfsm] [task={1}] [true or false={2}]'.format( | ||
2198 | self.log_base, task_str, is_fsm)) | ||
2199 | if is_fsm: | ||
2200 | fsm_compare.apply_async((doc.application_id, business_type, None, res_obj.id, is_ca, True), | ||
2201 | queue='queue_compare') | ||
2202 | else: | ||
2203 | # pass | ||
2204 | compare.apply_async((doc.application_id, business_type, None, res_obj.id, | ||
2205 | is_ca, True), queue='queue_compare') | ||
2206 | except Exception as e: | ||
2207 | self.online_log.error( | ||
2208 | '{0} [process error (comparison info send)] [task={1}] [error={2}]'.format( | ||
2209 | self.log_base, task_str, traceback.format_exc())) | ||
2210 | else: | ||
2211 | self.online_log.info('{0} [comparison info send success] [task={1}] ' | ||
2212 | '[res_id={2}]'.format(self.log_base, task_str, res_obj.id)) | ||
2213 | else: | ||
2214 | # license_summary 为空 | ||
2215 | self.online_log.info('{0} [task={1}] [no license_summary]'.format(self.log_base, task_str)) | ||
2067 | try: | 2216 | try: |
2068 | is_ca = True if doc.document_scheme == consts.DOC_SCHEME_LIST[0] else False | 2217 | is_ca = True if doc.document_scheme == consts.DOC_SCHEME_LIST[0] else False |
2069 | # 更新OCR累计识别结果表 | 2218 | # 更新OCR累计识别结果表 |
2070 | if business_type == consts.HIL_PREFIX: | 2219 | if business_type == consts.HIL_PREFIX: |
2071 | result_class = HILOCRResult if is_ca else HILSEOCRResult | 2220 | result_class = HILOCRResult if is_ca else HILSEOCRResult |
2072 | res_obj = atomicSaveDBHIL(self,result_class,doc,license_summary,ic_merge,rp_merge, task_str) | 2221 | try: |
2222 | res_obj = atomicSaveDBHIL(self,result_class,doc,license_summary,ic_merge,rp_merge, task_str, financial_statement_dict, financial_explanation_dict, down_payment_dict) | ||
2223 | except Exception as e: | ||
2224 | # 遇到报错重试一次,希望解决两个文件首次入库都插入的问题 | ||
2225 | self.online_log.error('{0} [process error (ocr result save) retry] [task={1}] [error={2}]'.format(self.log_base, task_str, traceback.format_exc())) | ||
2226 | res_obj = atomicSaveDBHIL(self,result_class,doc,license_summary,ic_merge,rp_merge, task_str, financial_statement_dict, financial_explanation_dict, down_payment_dict) | ||
2073 | else: | 2227 | else: |
2074 | result_class = AFCOCRResult if is_ca else AFCSEOCRResult | 2228 | result_class = AFCOCRResult if is_ca else AFCSEOCRResult |
2075 | res_obj = atomicSaveDBAFC(self,result_class,doc,license_summary,ic_merge,rp_merge, task_str) | 2229 | try: |
2076 | 2230 | res_obj = atomicSaveDBAFC(self,result_class,doc,license_summary,ic_merge,rp_merge, task_str, financial_statement_dict, financial_explanation_dict, down_payment_dict) | |
2231 | except Exception as e: | ||
2232 | # 遇到报错重试一次,希望解决两个文件首次入库都插入的问题 | ||
2233 | self.online_log.error('{0} [process error (ocr result save) retry] [task={1}] [error={2}]'.format(self.log_base, task_str, traceback.format_exc())) | ||
2234 | res_obj = atomicSaveDBAFC(self,result_class,doc,license_summary,ic_merge,rp_merge, task_str, financial_statement_dict, financial_explanation_dict, down_payment_dict) | ||
2077 | except Exception as e: | 2235 | except Exception as e: |
2078 | self.online_log.error( | 2236 | self.online_log.error( |
2079 | '{0} [process error (ocr result save)] [task={1}] [error={2}]'.format( | 2237 | '{0} [process error (ocr result save)] [task={1}] [error={2}]'.format( |
2080 | self.log_base, task_str, traceback.format_exc())) | 2238 | self.log_base, task_str, traceback.format_exc())) |
2081 | else: | ||
2082 | self.online_log.info('{0} [ocr result save success] [task={1}] [res_id={2}]'.format( | ||
2083 | self.log_base, task_str, res_obj.id)) | ||
2084 | # 触发比对 | ||
2085 | try: | ||
2086 | # 是否fsm | ||
2087 | cms_status_class = HILCmsStatusInfo if business_type in consts.HIL_SET else AFCCmsStatusInfo | ||
2088 | cms_status_info = cms_status_class.objects.filter(application_id=doc.application_id).first() | ||
2089 | is_fsm = cms_status_info is not None and cms_status_info.is_fsm == 1 | ||
2090 | self.online_log.info('{0} [isfsm] [task={1}] [true or false={2}]'.format( | ||
2091 | self.log_base, task_str, is_fsm)) | ||
2092 | if is_fsm: | ||
2093 | fsm_compare.apply_async((doc.application_id, business_type, None, res_obj.id, is_ca, True), | ||
2094 | queue='queue_compare') | ||
2095 | else: | ||
2096 | # pass | ||
2097 | compare.apply_async((doc.application_id, business_type, None, res_obj.id, | ||
2098 | is_ca, True), queue='queue_compare') | ||
2099 | except Exception as e: | ||
2100 | self.online_log.error( | ||
2101 | '{0} [process error (comparison info send)] [task={1}] [error={2}]'.format( | ||
2102 | self.log_base, task_str, traceback.format_exc())) | ||
2103 | else: | ||
2104 | self.online_log.info('{0} [comparison info send success] [task={1}] ' | ||
2105 | '[res_id={2}]'.format(self.log_base, task_str, res_obj.id)) | ||
2106 | 2239 | ||
2107 | # DDA处理 | 2240 | # DDA处理 |
2108 | if do_dda: | 2241 | if do_dda: |
... | @@ -2411,6 +2544,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -2411,6 +2544,7 @@ class Command(BaseCommand, LoggerMixin): |
2411 | except Exception as e: | 2544 | except Exception as e: |
2412 | self.online_log.error('{0} [process error (pdf & img remove)] [task={1}] [error={2}]'.format( | 2545 | self.online_log.error('{0} [process error (pdf & img remove)] [task={1}] [error={2}]'.format( |
2413 | self.log_base, task_str, traceback.format_exc())) | 2546 | self.log_base, task_str, traceback.format_exc())) |
2547 | self.online_log.info('{0} [res_2_wb after while] [len(error_list)={1}] [img_queue={2}] [finish_queue={3}]'.format(self.log_base, len(error_list), img_queue.empty(), finish_queue.empty())) | ||
2414 | 2548 | ||
2415 | def handle(self, *args, **kwargs): | 2549 | def handle(self, *args, **kwargs): |
2416 | db.close_old_connections() | 2550 | db.close_old_connections() |
... | @@ -2449,7 +2583,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -2449,7 +2583,7 @@ class Command(BaseCommand, LoggerMixin): |
2449 | self.online_log.info('{0} [stop safely]'.format(self.log_base)) | 2583 | self.online_log.info('{0} [stop safely]'.format(self.log_base)) |
2450 | 2584 | ||
2451 | @transaction.atomic | 2585 | @transaction.atomic |
2452 | def atomicSaveDBAFC(self,result_class,doc,license_summary,ic_merge,rp_merge,task_str): | 2586 | def atomicSaveDBAFC(self,result_class,doc,license_summary,ic_merge,rp_merge,task_str, financial_statement_dict, financial_explanation_dict, down_payment_dict): |
2453 | with transaction.atomic('afc'): | 2587 | with transaction.atomic('afc'): |
2454 | res_obj = result_class.objects.using('afc').select_for_update().filter(application_id=doc.application_id).first() | 2588 | res_obj = result_class.objects.using('afc').select_for_update().filter(application_id=doc.application_id).first() |
2455 | self.online_log.info('{0} [sql lock AFC application_id={1} doc_id={2}]'.format(self.log_base, doc.application_id,doc.id)) | 2589 | self.online_log.info('{0} [sql lock AFC application_id={1} doc_id={2}]'.format(self.log_base, doc.application_id,doc.id)) |
... | @@ -2457,6 +2591,18 @@ def atomicSaveDBAFC(self,result_class,doc,license_summary,ic_merge,rp_merge,task | ... | @@ -2457,6 +2591,18 @@ def atomicSaveDBAFC(self,result_class,doc,license_summary,ic_merge,rp_merge,task |
2457 | res_obj = result_class() | 2591 | res_obj = result_class() |
2458 | res_obj.application_id = doc.application_id | 2592 | res_obj.application_id = doc.application_id |
2459 | self.online_log.info('{0} [res_obj is None application_id={1} doc_id={2}]'.format(self.log_base, doc.application_id,doc.id)) | 2593 | self.online_log.info('{0} [res_obj is None application_id={1} doc_id={2}]'.format(self.log_base, doc.application_id,doc.id)) |
2594 | # 财务报表存入数据库 | ||
2595 | if res_obj is not None: | ||
2596 | if financial_statement_dict: | ||
2597 | res_obj.fs_ocr = json.dumps([financial_statement_dict]) | ||
2598 | # 财报情况说明存入数据库 | ||
2599 | if res_obj is not None: | ||
2600 | if financial_explanation_dict: | ||
2601 | res_obj.fss_ocr = json.dumps([financial_explanation_dict]) | ||
2602 | # 首付款支付承诺书存入数据库 | ||
2603 | if res_obj is not None: | ||
2604 | if down_payment_dict: | ||
2605 | res_obj.dp_ocr = json.dumps([down_payment_dict]) | ||
2460 | for classify, field in consts.RESULT_MAPPING.items(): | 2606 | for classify, field in consts.RESULT_MAPPING.items(): |
2461 | if not hasattr(res_obj, field): | 2607 | if not hasattr(res_obj, field): |
2462 | continue | 2608 | continue |
... | @@ -2482,7 +2628,7 @@ def atomicSaveDBAFC(self,result_class,doc,license_summary,ic_merge,rp_merge,task | ... | @@ -2482,7 +2628,7 @@ def atomicSaveDBAFC(self,result_class,doc,license_summary,ic_merge,rp_merge,task |
2482 | return res_obj | 2628 | return res_obj |
2483 | 2629 | ||
2484 | @transaction.atomic | 2630 | @transaction.atomic |
2485 | def atomicSaveDBHIL(self,result_class,doc,license_summary,ic_merge,rp_merge, task_str): | 2631 | def atomicSaveDBHIL(self,result_class,doc,license_summary,ic_merge,rp_merge, task_str, financial_statement_dict, financial_explanation_dict, down_payment_dict): |
2486 | with transaction.atomic('default'): | 2632 | with transaction.atomic('default'): |
2487 | res_obj = result_class.objects.using('default').select_for_update().filter(application_id=doc.application_id).first() | 2633 | res_obj = result_class.objects.using('default').select_for_update().filter(application_id=doc.application_id).first() |
2488 | self.online_log.info('{0} [sql lock HIL application_id={1} doc_id={2}]'.format(self.log_base, doc.application_id,doc.id)) | 2634 | self.online_log.info('{0} [sql lock HIL application_id={1} doc_id={2}]'.format(self.log_base, doc.application_id,doc.id)) |
... | @@ -2490,6 +2636,18 @@ def atomicSaveDBHIL(self,result_class,doc,license_summary,ic_merge,rp_merge, tas | ... | @@ -2490,6 +2636,18 @@ def atomicSaveDBHIL(self,result_class,doc,license_summary,ic_merge,rp_merge, tas |
2490 | res_obj = result_class() | 2636 | res_obj = result_class() |
2491 | res_obj.application_id = doc.application_id | 2637 | res_obj.application_id = doc.application_id |
2492 | self.online_log.info('{0} [res_obj is None application_id={1} doc_id={2}]'.format(self.log_base, doc.application_id,doc.id)) | 2638 | self.online_log.info('{0} [res_obj is None application_id={1} doc_id={2}]'.format(self.log_base, doc.application_id,doc.id)) |
2639 | # 财务报表三个表存入数据库 | ||
2640 | if res_obj is not None: | ||
2641 | if financial_statement_dict: | ||
2642 | res_obj.fs_ocr = json.dumps([financial_statement_dict]) | ||
2643 | # 财报情况说明存入数据库 | ||
2644 | if res_obj is not None: | ||
2645 | if financial_explanation_dict: | ||
2646 | res_obj.fss_ocr = json.dumps([financial_explanation_dict]) | ||
2647 | # 首付款支付承诺书存入数据库 | ||
2648 | if res_obj is not None: | ||
2649 | if down_payment_dict: | ||
2650 | res_obj.dp_ocr = json.dumps([down_payment_dict]) | ||
2493 | for classify, field in consts.RESULT_MAPPING.items(): | 2651 | for classify, field in consts.RESULT_MAPPING.items(): |
2494 | if not hasattr(res_obj, field): | 2652 | if not hasattr(res_obj, field): |
2495 | continue | 2653 | continue | ... | ... |
... | @@ -336,6 +336,9 @@ class AFCOCRResult(models.Model): | ... | @@ -336,6 +336,9 @@ class AFCOCRResult(models.Model): |
336 | fsm_sc_ocr = models.TextField(null=True, verbose_name="汽车销售合同") | 336 | fsm_sc_ocr = models.TextField(null=True, verbose_name="汽车销售合同") |
337 | fsm_sc2_ocr = models.TextField(null=True, verbose_name="汽车销售合同补充合同") | 337 | fsm_sc2_ocr = models.TextField(null=True, verbose_name="汽车销售合同补充合同") |
338 | fsm_activited = models.IntegerField(null=False, default=0, verbose_name="fsm激活状态 1:激活") | 338 | fsm_activited = models.IntegerField(null=False, default=0, verbose_name="fsm激活状态 1:激活") |
339 | fs_ocr = models.TextField(null=True, verbose_name="财务报表") | ||
340 | fss_ocr = models.TextField(null=True, verbose_name="财务情况说明书") | ||
341 | dp_ocr = models.TextField(null=True, verbose_name="首付款支付承诺书") | ||
339 | 342 | ||
340 | 343 | ||
341 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') | 344 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') |
... | @@ -379,6 +382,9 @@ class HILOCRResult(models.Model): | ... | @@ -379,6 +382,9 @@ class HILOCRResult(models.Model): |
379 | fsm_sc_ocr = models.TextField(null=True, verbose_name="汽车销售合同") | 382 | fsm_sc_ocr = models.TextField(null=True, verbose_name="汽车销售合同") |
380 | fsm_sc2_ocr = models.TextField(null=True, verbose_name="汽车销售合同补充合同") | 383 | fsm_sc2_ocr = models.TextField(null=True, verbose_name="汽车销售合同补充合同") |
381 | fsm_activited = models.IntegerField(null=False, default=0, verbose_name="fsm激活状态 1:激活") | 384 | fsm_activited = models.IntegerField(null=False, default=0, verbose_name="fsm激活状态 1:激活") |
385 | fs_ocr = models.TextField(null=True, verbose_name="财务报表") | ||
386 | fss_ocr = models.TextField(null=True, verbose_name="财务情况说明书") | ||
387 | dp_ocr = models.TextField(null=True, verbose_name="首付款支付承诺书") | ||
382 | 388 | ||
383 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') | 389 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') |
384 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | 390 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') |
... | @@ -420,6 +426,9 @@ class AFCSEOCRResult(models.Model): | ... | @@ -420,6 +426,9 @@ class AFCSEOCRResult(models.Model): |
420 | fsm_sc_ocr = models.TextField(null=True, verbose_name="汽车销售合同") | 426 | fsm_sc_ocr = models.TextField(null=True, verbose_name="汽车销售合同") |
421 | fsm_sc2_ocr = models.TextField(null=True, verbose_name="汽车销售合同补充合同") | 427 | fsm_sc2_ocr = models.TextField(null=True, verbose_name="汽车销售合同补充合同") |
422 | fsm_activited = models.IntegerField(null=False, default=0, verbose_name="fsm激活状态 1:激活") | 428 | fsm_activited = models.IntegerField(null=False, default=0, verbose_name="fsm激活状态 1:激活") |
429 | fs_ocr = models.TextField(null=True, verbose_name="财务报表") | ||
430 | fss_ocr = models.TextField(null=True, verbose_name="财务情况说明书") | ||
431 | dp_ocr = models.TextField(null=True, verbose_name="首付款支付承诺书") | ||
423 | 432 | ||
424 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') | 433 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') |
425 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | 434 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') |
... | @@ -461,6 +470,9 @@ class HILSEOCRResult(models.Model): | ... | @@ -461,6 +470,9 @@ class HILSEOCRResult(models.Model): |
461 | fsm_sc_ocr = models.TextField(null=True, verbose_name="汽车销售合同") | 470 | fsm_sc_ocr = models.TextField(null=True, verbose_name="汽车销售合同") |
462 | fsm_sc2_ocr = models.TextField(null=True, verbose_name="汽车销售合同补充合同") | 471 | fsm_sc2_ocr = models.TextField(null=True, verbose_name="汽车销售合同补充合同") |
463 | fsm_activited = models.IntegerField(null=False, default=0, verbose_name="fsm激活状态 1:激活") | 472 | fsm_activited = models.IntegerField(null=False, default=0, verbose_name="fsm激活状态 1:激活") |
473 | fs_ocr = models.TextField(null=True, verbose_name="财务报表") | ||
474 | fss_ocr = models.TextField(null=True, verbose_name="财务情况说明书") | ||
475 | dp_ocr = models.TextField(null=True, verbose_name="首付款支付承诺书") | ||
464 | 476 | ||
465 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') | 477 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') |
466 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | 478 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') |
... | @@ -1118,4 +1130,46 @@ class DealerMapping(models.Model): | ... | @@ -1118,4 +1130,46 @@ class DealerMapping(models.Model): |
1118 | 1130 | ||
1119 | class Meta: | 1131 | class Meta: |
1120 | managed = False | 1132 | managed = False |
1121 | db_table = 'dealer_mapping' | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1133 | db_table = 'dealer_mapping' | ||
1134 | |||
1135 | class HILGreenBookHistoryFile(models.Model): | ||
1136 | id = models.AutoField(primary_key=True, verbose_name="id") # 主键 | ||
1137 | object_id = models.CharField(max_length=64, verbose_name="文件唯一ID") | ||
1138 | object_name = models.CharField(max_length=255, verbose_name="文件名称") | ||
1139 | application_no = models.CharField(max_length=64, verbose_name="申请号") | ||
1140 | object_type = models.CharField(max_length=64, verbose_name="文件类型") | ||
1141 | customer_name = models.CharField(max_length=64, verbose_name="customer_name") | ||
1142 | content_size = models.CharField(max_length=64, verbose_name="文件大小") | ||
1143 | owner_name = models.CharField(max_length=64, verbose_name="owner_name") | ||
1144 | input_date = models.DateTimeField(verbose_name="上传时间") | ||
1145 | modify_date = models.DateTimeField(verbose_name="修改时间") | ||
1146 | location = models.CharField(max_length=255, verbose_name="文件位置") | ||
1147 | download_finish = models.SmallIntegerField(null=False, default=0, verbose_name="是否下载完成") | ||
1148 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') | ||
1149 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | ||
1150 | |||
1151 | class Meta: | ||
1152 | managed = False | ||
1153 | db_table = 'hil_gb_history_file' | ||
1154 | |||
1155 | |||
1156 | class AFCGreenBookHistoryFile(models.Model): | ||
1157 | id = models.AutoField(primary_key=True, verbose_name="id") # 主键 | ||
1158 | object_id = models.CharField(max_length=64, verbose_name="文件唯一ID") | ||
1159 | object_name = models.CharField(max_length=255, verbose_name="文件名称") | ||
1160 | application_no = models.CharField(max_length=64, verbose_name="申请号") | ||
1161 | object_type = models.CharField(max_length=64, verbose_name="文件类型") | ||
1162 | customer_name = models.CharField(max_length=64, verbose_name="customer_name") | ||
1163 | content_size = models.CharField(max_length=64, verbose_name="文件大小") | ||
1164 | owner_name = models.CharField(max_length=64, verbose_name="owner_name") | ||
1165 | input_date = models.DateTimeField(verbose_name="上传时间") | ||
1166 | modify_date = models.DateTimeField(verbose_name="修改时间") | ||
1167 | location = models.CharField(max_length=255, verbose_name="文件位置") | ||
1168 | download_finish = models.BooleanField(default=True, verbose_name="是否下载完成") | ||
1169 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') | ||
1170 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | ||
1171 | |||
1172 | class Meta: | ||
1173 | managed = False | ||
1174 | db_table = 'afc_gb_history_file' | ||
1175 | situ_db_label = 'afc' | ... | ... |
... | @@ -102,9 +102,14 @@ class ECM(GenericView): | ... | @@ -102,9 +102,14 @@ class ECM(GenericView): |
102 | "docbase": self.doc_base_map.get(business_type), | 102 | "docbase": self.doc_base_map.get(business_type), |
103 | "documentType": doc_type, | 103 | "documentType": doc_type, |
104 | "objectId": object_id, | 104 | "objectId": object_id, |
105 | "b_input_date": time.strftime("%m/%d/%Y %X"), | ||
106 | "b_credit_signing_date": time.strftime("%m/%d/%Y %X"), | ||
107 | "b_credit_check": True, | ||
108 | "b_id_number": '', | ||
105 | } | 109 | } |
106 | header_info = self.get_headers() | 110 | header_info = self.get_headers() |
107 | self.running_log.info("{0} download header_info:{1}".format(self.log_base, header_info)) | 111 | self.running_log.info("{0} download header_info:{1}".format(self.log_base, header_info)) |
112 | self.running_log.info("{0} download args_info:{1}".format(self.log_base, download_json)) | ||
108 | response = requests.post(self.download_url, headers=header_info, json=download_json, verify=False) | 113 | response = requests.post(self.download_url, headers=header_info, json=download_json, verify=False) |
109 | if response.status_code != 200: | 114 | if response.status_code != 200: |
110 | raise ECMException('ECM download failed with code: {0}'.format(response.status_code)) | 115 | raise ECMException('ECM download failed with code: {0}'.format(response.status_code)) |
... | @@ -142,6 +147,9 @@ class ECM(GenericView): | ... | @@ -142,6 +147,9 @@ class ECM(GenericView): |
142 | "b_region": "0", | 147 | "b_region": "0", |
143 | "b_region_name": self.b_region_name_map.get(business_type), | 148 | "b_region_name": self.b_region_name_map.get(business_type), |
144 | "b_input_date": time.strftime("%m/%d/%Y %X"), | 149 | "b_input_date": time.strftime("%m/%d/%Y %X"), |
150 | "b_credit_signing_date": time.strftime("%m/%d/%Y %X"), | ||
151 | "b_credit_check": True, | ||
152 | "b_id_number": '', | ||
145 | # "file_base64_content": "", | 153 | # "file_base64_content": "", |
146 | } | 154 | } |
147 | for key in self.upload_fields: | 155 | for key in self.upload_fields: |
... | @@ -153,9 +161,28 @@ class ECM(GenericView): | ... | @@ -153,9 +161,28 @@ class ECM(GenericView): |
153 | args['file_base64_content'] = file_data | 161 | args['file_base64_content'] = file_data |
154 | header_info = self.get_headers() | 162 | header_info = self.get_headers() |
155 | self.running_log.info("{0} upload header_info:{1}".format(self.log_base, header_info)) | 163 | self.running_log.info("{0} upload header_info:{1}".format(self.log_base, header_info)) |
164 | self.running_log.info("{0} upload args_info:{1}".format(self.log_base, args)) | ||
156 | response = requests.post(self.upload_url, headers=header_info, json=args, verify=False) | 165 | response = requests.post(self.upload_url, headers=header_info, json=args, verify=False) |
157 | if response.status_code != 200: | 166 | if response.status_code != 200: |
158 | raise ECMException('ECM upload failed with code: {0} , with headers: {1} , with content: {2}'.format( | 167 | raise ECMException('ECM upload failed with code: {0} , with headers: {1} , with content: {2}'.format( |
159 | response.status_code, response.headers, response.text)) | 168 | response.status_code, response.headers, response.text)) |
160 | if 'ns6:createResponse' not in response.json().get('S:Envelope', {}).get('S:Body', {}): | 169 | if 'ns12:createResponse' not in response.json().get('S:Envelope', {}).get('S:Body', {}): |
161 | raise ECMException('ECM upload failed: {0} , with headers: {1}'.format(response.json(), response.headers)) | 170 | raise ECMException('ECM upload failed: {0} , with headers: {1}'.format(response.json(), response.headers)) |
171 | |||
172 | def search_doc_info_list(self, filePath, business_type): | ||
173 | args = { | ||
174 | #userName n大写,和其他接口不一样,是因为apigateway没有做统一 | ||
175 | "userName": self.username, | ||
176 | "password": self.pwd, | ||
177 | "docbase": self.doc_base_map.get(business_type), | ||
178 | "documentType": "green_book", | ||
179 | "dql":"select r_object_id, object_name,b_application_no, r_object_type,b_customer_name,r_content_size, owner_name, b_input_date, r_modify_date, b_location from green_book where b_location = '{}'" .format(filePath), | ||
180 | } | ||
181 | header_info = self.get_headers() | ||
182 | self.running_log.info("{0} search header_info:{1}".format(self.log_base, header_info)) | ||
183 | self.running_log.info("{0} search args_info:{1}".format(self.log_base, args)) | ||
184 | response = requests.post(self.search_url, headers=header_info, json=args, verify=False) | ||
185 | if response.status_code != 200: | ||
186 | raise ECMException('ECM search failed with code: {0}'.format(response.status_code)) | ||
187 | #self.running_log.info("{0} search response.json():{1}".format(self.log_base, response.json())) | ||
188 | return response.json() | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -827,6 +827,80 @@ class BSWorkbook(Workbook): | ... | @@ -827,6 +827,80 @@ class BSWorkbook(Workbook): |
827 | ws.append(row) | 827 | ws.append(row) |
828 | ws.append((None, )) | 828 | ws.append((None, )) |
829 | 829 | ||
830 | |||
831 | def financial_rebuild(self, financial_statement_dict): | ||
832 | # 如果 financial_statement_dict 为空,则不创建表 | ||
833 | if not financial_statement_dict: | ||
834 | return | ||
835 | # 如果 financial_statement_dict 不为空,则创建表 | ||
836 | ws = self.create_sheet(consts.FINANCIAL_SHEET_NAME) | ||
837 | for fin_key, fin_value in financial_statement_dict.items(): | ||
838 | table_str = "识别码" | ||
839 | if fin_key == "code": | ||
840 | table_str = "识别码" | ||
841 | elif fin_key == "stamp": | ||
842 | table_str = "印章" | ||
843 | |||
844 | for table_key, table_value in fin_value.items(): | ||
845 | if table_key == "balance_sheet": | ||
846 | row = ["资产负债表" + table_str, str(table_value)] | ||
847 | ws.append(row) | ||
848 | elif table_key == "income_statement": | ||
849 | row = ["利润表" + table_str, str(table_value)] | ||
850 | ws.append(row) | ||
851 | elif table_key == "cash_flow_statement": | ||
852 | row = ["现金流量表" + table_str, str(table_value)] | ||
853 | ws.append(row) | ||
854 | |||
855 | |||
856 | def financial_explanation_rebuild(self, financial_explanation_dict): | ||
857 | """ | ||
858 | Desc: | ||
859 | 重构财报情况说明sheet | ||
860 | """ | ||
861 | # 如果 financial_explanation_dict 为空,则不创建sheet | ||
862 | if not financial_explanation_dict: | ||
863 | return | ||
864 | # 如果 financial_explanation_dict 不为空, 则创建sheet | ||
865 | ws = self.create_sheet(consts.FINANCIAL_EXPLANATION_SHEET_NAME) | ||
866 | for fin_key, fin_value in financial_explanation_dict.items(): | ||
867 | table_str = "公司名称" | ||
868 | if fin_key == "title": | ||
869 | table_str = "公司名称" | ||
870 | elif fin_key == "stamp": | ||
871 | table_str = "印章" | ||
872 | |||
873 | row = ["财报情况说明" + table_str, str(fin_value)] | ||
874 | ws.append(row) | ||
875 | |||
876 | |||
877 | def down_payment_rebuild(self, down_payment_dict): | ||
878 | """ | ||
879 | Desc: | ||
880 | 重构首付款支付承诺书sheet | ||
881 | """ | ||
882 | # 如果 down_payment_dict 为空, 则不创建sheet | ||
883 | if not down_payment_dict: | ||
884 | return | ||
885 | # 如果 down_payment_dict 不为空, 则创建sheet | ||
886 | ws = self.create_sheet(consts.DOWN_PAYMENT_SHEET_NAME) | ||
887 | english_chinese_dict = { | ||
888 | "financial_org_name": "渠道", | ||
889 | "main_borrower_name": "姓名", | ||
890 | "main_borrower_id_no": "证件号码", | ||
891 | "apply_no": "合同编号", | ||
892 | "contract_name": "合同名称", | ||
893 | "promisor_signature": "承诺人签字-电子", | ||
894 | "promisor_signature_date": "承诺人签字日期-电子" | ||
895 | } | ||
896 | for dp_key, dp_value in down_payment_dict.items(): | ||
897 | if dp_key in english_chinese_dict.keys(): | ||
898 | row = [english_chinese_dict[dp_key], str(dp_value)] | ||
899 | ws.append(row) | ||
900 | else: | ||
901 | row = [english_chinese_dict[dp_key], ""] | ||
902 | ws.append(row) | ||
903 | |||
830 | @staticmethod | 904 | @staticmethod |
831 | def remove_yuan(amount_key_set, key, src_str): | 905 | def remove_yuan(amount_key_set, key, src_str): |
832 | if key in amount_key_set and isinstance(src_str, str): | 906 | if key in amount_key_set and isinstance(src_str, str): |
... | @@ -926,7 +1000,7 @@ class BSWorkbook(Workbook): | ... | @@ -926,7 +1000,7 @@ class BSWorkbook(Workbook): |
926 | if len(self.sheetnames) > 1: | 1000 | if len(self.sheetnames) > 1: |
927 | self.remove(self.get_sheet_by_name('Sheet')) | 1001 | self.remove(self.get_sheet_by_name('Sheet')) |
928 | 1002 | ||
929 | def rebuild(self, bs_summary, license_summary, res_list, document_scheme, contract_result, metadata): | 1003 | def rebuild(self, bs_summary, license_summary, res_list, document_scheme, contract_result, metadata, financial_statement_dict, financial_explanation_dict, down_payment_dict): |
930 | res_count_tuple = self.res_sheet(res_list) | 1004 | res_count_tuple = self.res_sheet(res_list) |
931 | 1005 | ||
932 | count_list = [(consts.MODEL_FIELD_BS, len(bs_summary))] | 1006 | count_list = [(consts.MODEL_FIELD_BS, len(bs_summary))] |
... | @@ -934,10 +1008,16 @@ class BSWorkbook(Workbook): | ... | @@ -934,10 +1008,16 @@ class BSWorkbook(Workbook): |
934 | self.license_rebuild(license_summary, document_scheme, count_list) | 1008 | self.license_rebuild(license_summary, document_scheme, count_list) |
935 | self.contract_rebuild(contract_result) | 1009 | self.contract_rebuild(contract_result) |
936 | self.bs_rebuild(bs_summary, res_count_tuple, metadata) | 1010 | self.bs_rebuild(bs_summary, res_count_tuple, metadata) |
1011 | self.financial_rebuild(financial_statement_dict) | ||
1012 | self.financial_explanation_rebuild(financial_explanation_dict) | ||
1013 | self.down_payment_rebuild(down_payment_dict) | ||
937 | else: | 1014 | else: |
938 | self.bs_rebuild(bs_summary, res_count_tuple, metadata) | 1015 | self.bs_rebuild(bs_summary, res_count_tuple, metadata) |
939 | self.license_rebuild(license_summary, document_scheme, count_list) | 1016 | self.license_rebuild(license_summary, document_scheme, count_list) |
940 | self.contract_rebuild(contract_result, True) | 1017 | self.contract_rebuild(contract_result, True) |
1018 | self.financial_rebuild(financial_statement_dict) | ||
1019 | self.financial_explanation_rebuild(financial_explanation_dict) | ||
1020 | self.down_payment_rebuild(down_payment_dict) | ||
941 | self.move_res_sheet() | 1021 | self.move_res_sheet() |
942 | self.remove_base_sheet() | 1022 | self.remove_base_sheet() |
943 | return count_list, self.need_follow | 1023 | return count_list, self.need_follow | ... | ... |
... | @@ -20,6 +20,7 @@ from common import response | ... | @@ -20,6 +20,7 @@ from common import response |
20 | from common.mixins import GenericView,DocGenericView | 20 | from common.mixins import GenericView,DocGenericView |
21 | from common.tools.file_tools import file_write | 21 | from common.tools.file_tools import file_write |
22 | from common.redis_cache import redis_handler as rh | 22 | from common.redis_cache import redis_handler as rh |
23 | from apps.doc.ocr.cms import cms | ||
23 | from .models import ( | 24 | from .models import ( |
24 | # UploadDocRecords, | 25 | # UploadDocRecords, |
25 | DocStatus, | 26 | DocStatus, |
... | @@ -53,16 +54,22 @@ from .models import ( | ... | @@ -53,16 +54,22 @@ from .models import ( |
53 | AFCOCRResult, | 54 | AFCOCRResult, |
54 | AFCSEOCRResult, | 55 | AFCSEOCRResult, |
55 | HILCmsStatusInfo, | 56 | HILCmsStatusInfo, |
56 | AFCCmsStatusInfo | 57 | AFCCmsStatusInfo, |
58 | HILGreenBookHistoryFile, | ||
59 | AFCGreenBookHistoryFile, | ||
60 | Configs | ||
57 | ) | 61 | ) |
62 | from common.exceptions import (NoPermissionException) | ||
58 | from .named_enum import ErrorType, AutoResult, WholeResult, RPAResult, SystemName, RequestTeam | 63 | from .named_enum import ErrorType, AutoResult, WholeResult, RPAResult, SystemName, RequestTeam |
59 | from .mixins import DocHandler, MPOSHandler, PreSEHandler | 64 | from .mixins import DocHandler, MPOSHandler, PreSEHandler |
60 | from . import consts | 65 | from . import consts |
61 | from apps.account.authentication import OAuth2AuthenticationWithUser | 66 | from apps.account.authentication import OAuth2AuthenticationWithUser |
62 | from celery_compare.tasks import compare, fsm_compare | 67 | from celery_compare.tasks import compare, fsm_compare |
63 | from prese.compare import get_empty_result | 68 | from prese.compare import get_empty_result |
64 | 69 | from apps.doc.ocr.ecm import ECM | |
65 | import time | 70 | import time |
71 | from django.http import HttpResponse | ||
72 | from django.utils.encoding import escape_uri_path | ||
66 | 73 | ||
67 | 74 | ||
68 | class CustomDate(fields.Date): | 75 | class CustomDate(fields.Date): |
... | @@ -90,6 +97,22 @@ class CustomDecimal(fields.Decimal): | ... | @@ -90,6 +97,22 @@ class CustomDecimal(fields.Decimal): |
90 | def load_data(request, schema): | 97 | def load_data(request, schema): |
91 | return request.data | 98 | return request.data |
92 | 99 | ||
100 | employee_args = { | ||
101 | 'application_id': fields.Str(required=True, validate=validate.Length(max=64)), | ||
102 | 'business_type': fields.Str(required=True, validate=validate.Length(max=64)), | ||
103 | } | ||
104 | |||
105 | q_gb_file_args = { | ||
106 | 'file_path': fields.Str(required=True, validate=validate.Length(max=255)), | ||
107 | 'business_type': fields.Str(required=True, validate=validate.Length(max=64)), | ||
108 | } | ||
109 | |||
110 | d_gb_file_args = { | ||
111 | 'object_id': fields.Str(required=True, validate=validate.Length(max=64)), | ||
112 | 'save_path': fields.Str(required=True, validate=validate.Length(max=255)), | ||
113 | 'business_type': fields.Str(required=True, validate=validate.Length(max=64)), | ||
114 | } | ||
115 | |||
93 | 116 | ||
94 | go_args = { | 117 | go_args = { |
95 | 'image': fields.Raw(required=True), | 118 | 'image': fields.Raw(required=True), |
... | @@ -561,6 +584,10 @@ mpos_args = { | ... | @@ -561,6 +584,10 @@ mpos_args = { |
561 | 'file_base64_content': fields.List(fields.Str(), required=True, validate=validate.Length(min=1)), | 584 | 'file_base64_content': fields.List(fields.Str(), required=True, validate=validate.Length(min=1)), |
562 | } | 585 | } |
563 | 586 | ||
587 | invoice_download_args = { | ||
588 | 'application_entity': fields.Int(required=True), | ||
589 | 'application_ids': fields.Str(required=True), | ||
590 | } | ||
564 | 591 | ||
565 | class UploadDocView(GenericView, DocHandler): | 592 | class UploadDocView(GenericView, DocHandler): |
566 | # permission_classes = [] | 593 | # permission_classes = [] |
... | @@ -620,7 +647,7 @@ class UploadDocView(GenericView, DocHandler): | ... | @@ -620,7 +647,7 @@ class UploadDocView(GenericView, DocHandler): |
620 | 647 | ||
621 | self.running_log.info('[doc upload applicationId-{0}] [ocr result saved]'.format(application_id)) | 648 | self.running_log.info('[doc upload applicationId-{0}] [ocr result saved]'.format(application_id)) |
622 | if data_source == consts.DATA_SOURCE_LIST[1]: | 649 | if data_source == consts.DATA_SOURCE_LIST[1]: |
623 | if document_name.endswith('-证书.pdf') or document_name.endswith('-证书'): | 650 | if document_name.endswith('-证书.pdf') or document_name.endswith('-证书') or '-证书-bk-' in document_name: |
624 | self.running_log.info('[doc upload success] [eapp license skip] [args={0}]'.format(args)) | 651 | self.running_log.info('[doc upload success] [eapp license skip] [args={0}]'.format(args)) |
625 | return response.ok() | 652 | return response.ok() |
626 | 653 | ||
... | @@ -1059,6 +1086,27 @@ class DocView(DocGenericView, DocHandler): | ... | @@ -1059,6 +1086,27 @@ class DocView(DocGenericView, DocHandler): |
1059 | create_time_start = args.get('create_time_start') | 1086 | create_time_start = args.get('create_time_start') |
1060 | create_time_end = args.get('create_time_end') | 1087 | create_time_end = args.get('create_time_end') |
1061 | 1088 | ||
1089 | # 角色权限不符,返回空列表 | ||
1090 | token = request.META.get("HTTP_AUTHORIZATION") | ||
1091 | user_role = rh.get_token(token[-11:]) | ||
1092 | self.running_log.info('[api doc] [user_role={0} business_type={1}] '.format(user_role, business_type)) | ||
1093 | if user_role is None or user_role == '-1' or (user_role == '1' and business_type == 'HIL') or (user_role == '2' and business_type == 'AFC'): | ||
1094 | # pagination = {'current': page, 'total': 0, 'page_size': page_size} | ||
1095 | # res = { | ||
1096 | # 'pagination': pagination, | ||
1097 | # 'doc_list': [] | ||
1098 | # } | ||
1099 | # return response.ok(data=res) | ||
1100 | raise NoPermissionException('no permission') | ||
1101 | if user_role is None or user_role == '-1' or (user_role == '1' and business_type == 'HIL') or (user_role == '2' and business_type == 'AFC'): | ||
1102 | # pagination = {'current': page, 'total': 0, 'page_size': page_size} | ||
1103 | # res = { | ||
1104 | # 'pagination': pagination, | ||
1105 | # 'doc_list': [] | ||
1106 | # } | ||
1107 | # return response.ok(data=res) | ||
1108 | raise NoPermissionException('no permission') | ||
1109 | |||
1062 | status_query = Q(status=status) if status is not None else Q() | 1110 | status_query = Q(status=status) if status is not None else Q() |
1063 | application_id_query = Q(application_id__contains=application_id) if application_id is not None else Q() | 1111 | application_id_query = Q(application_id__contains=application_id) if application_id is not None else Q() |
1064 | data_source_query = Q(data_source=data_source) if data_source is not None else Q() | 1112 | data_source_query = Q(data_source=data_source) if data_source is not None else Q() |
... | @@ -1224,6 +1272,14 @@ class CompareResultView(GenericView): | ... | @@ -1224,6 +1272,14 @@ class CompareResultView(GenericView): |
1224 | scheme = args.get('scheme') | 1272 | scheme = args.get('scheme') |
1225 | case_id = args.get('case_id') | 1273 | case_id = args.get('case_id') |
1226 | is_auto = args.get('auto') | 1274 | is_auto = args.get('auto') |
1275 | |||
1276 | # 角色权限不符,返回异常 | ||
1277 | token = request.META.get("HTTP_AUTHORIZATION") | ||
1278 | user_role = rh.get_token(token[-11:]) | ||
1279 | self.running_log.info('[CompareResultView] [user_role={0}] '.format(user_role)) | ||
1280 | if user_role is None or user_role == '-1' or (user_role == '1' and entity == 'HIL') or (user_role == '2' and entity == 'AFC'): | ||
1281 | raise NoPermissionException('no permission') | ||
1282 | |||
1227 | if is_auto == 1: | 1283 | if is_auto == 1: |
1228 | result_table = HILAutoSettlement if entity == consts.HIL_PREFIX else AFCAutoSettlement | 1284 | result_table = HILAutoSettlement if entity == consts.HIL_PREFIX else AFCAutoSettlement |
1229 | 1285 | ||
... | @@ -1460,10 +1516,18 @@ class SECMSView(GenericView): | ... | @@ -1460,10 +1516,18 @@ class SECMSView(GenericView): |
1460 | # CMS上传比对信息接口 SE | 1516 | # CMS上传比对信息接口 SE |
1461 | # @use_args(se_cms_args, location='data') | 1517 | # @use_args(se_cms_args, location='data') |
1462 | def post(self, request): # interface_report cms to ocr | 1518 | def post(self, request): # interface_report cms to ocr |
1519 | # 如果是压测 直接返回通过结果 | ||
1520 | is_pressure = notifyCmsPass(self, request) | ||
1521 | if is_pressure: | ||
1522 | return response.ok() | ||
1523 | |||
1524 | # 以下时非压测时的正常逻辑 | ||
1463 | start_time = time.time() | 1525 | start_time = time.time() |
1464 | 1526 | ||
1465 | args = request.data | 1527 | args = request.data |
1466 | cms_info = args.get('content', {}) | 1528 | cms_info = args.get('content', {}) |
1529 | # uat 强制"仅接受银行流水" | ||
1530 | # cms_info['autoApprovedDetails']['PolicyComments'] = '仅接受银行流水' | ||
1467 | business_type = consts.AFC_PREFIX if cms_info.get('financeCompany', '').startswith( | 1531 | business_type = consts.AFC_PREFIX if cms_info.get('financeCompany', '').startswith( |
1468 | '宝马') else consts.HIL_PREFIX | 1532 | '宝马') else consts.HIL_PREFIX |
1469 | src_application_id = cms_info.get('settlemnetVerification', {}).get('applicationNo', '') | 1533 | src_application_id = cms_info.get('settlemnetVerification', {}).get('applicationNo', '') |
... | @@ -1477,6 +1541,11 @@ class SECMSView(GenericView): | ... | @@ -1477,6 +1541,11 @@ class SECMSView(GenericView): |
1477 | fsm_contract = cms_info.get('FSMContract', False) | 1541 | fsm_contract = cms_info.get('FSMContract', False) |
1478 | is_fsm=1 if fsm_contract else 0 | 1542 | is_fsm=1 if fsm_contract else 0 |
1479 | 1543 | ||
1544 | # 测试是否单线程 | ||
1545 | #self.running_log.info('接到请求,准备sleep') | ||
1546 | #time.sleep(10) | ||
1547 | #self.running_log.info('sleep结束') | ||
1548 | |||
1480 | auto_class = HILAutoSettlement if business_type in consts.HIL_SET else AFCAutoSettlement | 1549 | auto_class = HILAutoSettlement if business_type in consts.HIL_SET else AFCAutoSettlement |
1481 | auto_obj = auto_class.objects.filter(application_id=application_id).first() | 1550 | auto_obj = auto_class.objects.filter(application_id=application_id).first() |
1482 | if is_auto: | 1551 | if is_auto: |
... | @@ -1616,6 +1685,19 @@ class AutoSettlementView(GenericView): | ... | @@ -1616,6 +1685,19 @@ class AutoSettlementView(GenericView): |
1616 | 1685 | ||
1617 | is_fsm = args.get('is_fsm') | 1686 | is_fsm = args.get('is_fsm') |
1618 | 1687 | ||
1688 | # 角色权限不符,返回空列表 | ||
1689 | token = request.META.get("HTTP_AUTHORIZATION") | ||
1690 | user_role = rh.get_token(token[-11:]) | ||
1691 | self.running_log.info('[AutoSettlementView] [user_role={0}] '.format(user_role)) | ||
1692 | if user_role is None or user_role == '-1' or (user_role == '1' and business_type == 'HIL') or (user_role == '2' and business_type == 'AFC'): | ||
1693 | # pagination = {'current': page, 'total': 0, 'page_size': page_size} | ||
1694 | # res = { | ||
1695 | # 'pagination': pagination, | ||
1696 | # 'doc_list': [] | ||
1697 | # } | ||
1698 | # return response.ok(data=res) | ||
1699 | raise NoPermissionException('no permission') | ||
1700 | |||
1619 | if isinstance(auto_result, int): | 1701 | if isinstance(auto_result, int): |
1620 | auto_result = consts.RESULT_MAP.get(auto_result) | 1702 | auto_result = consts.RESULT_MAP.get(auto_result) |
1621 | if isinstance(whole_result, int): | 1703 | if isinstance(whole_result, int): |
... | @@ -1700,6 +1782,13 @@ class AutoSettlementExcelView(GenericView): | ... | @@ -1700,6 +1782,13 @@ class AutoSettlementExcelView(GenericView): |
1700 | 1782 | ||
1701 | is_fsm = args.get('is_fsm') | 1783 | is_fsm = args.get('is_fsm') |
1702 | 1784 | ||
1785 | # 角色权限不符,返回异常 | ||
1786 | token = request.META.get("HTTP_AUTHORIZATION") | ||
1787 | user_role = rh.get_token(token[-11:]) | ||
1788 | self.running_log.info('[AutoSettlementExcelView] [user_role={0}] '.format(user_role)) | ||
1789 | if user_role is None or user_role == '-1' or (user_role == '1' and business_type == 'HIL') or (user_role == '2' and business_type == 'AFC'): | ||
1790 | raise NoPermissionException('no permission') | ||
1791 | |||
1703 | if isinstance(auto_result, int): | 1792 | if isinstance(auto_result, int): |
1704 | auto_result = consts.RESULT_MAP.get(auto_result) | 1793 | auto_result = consts.RESULT_MAP.get(auto_result) |
1705 | if isinstance(whole_result, int): | 1794 | if isinstance(whole_result, int): |
... | @@ -1847,3 +1936,206 @@ class GoView(GenericView): | ... | @@ -1847,3 +1936,206 @@ class GoView(GenericView): |
1847 | return response.ok(data=result) | 1936 | return response.ok(data=result) |
1848 | else: | 1937 | else: |
1849 | return response.error_msg(msg='识别错误') | 1938 | return response.error_msg(msg='识别错误') |
1939 | |||
1940 | class InvoiceExcelView(GenericView): | ||
1941 | #permission_classes = [IsAuthenticated] | ||
1942 | #authentication_classes = [OAuth2AuthenticationWithUser] | ||
1943 | |||
1944 | # 下载发票excel | ||
1945 | @use_args(invoice_download_args, location='querystring') | ||
1946 | def get(self, request, args): | ||
1947 | application_ids = args.get('application_ids') | ||
1948 | application_entity = args.get('application_entity') | ||
1949 | self.running_log.info('[InvoiceExcelView] [user_role={0}] '.format('111222333')) | ||
1950 | # 角色权限不符,返回异常 | ||
1951 | token = request.META.get("HTTP_AUTHORIZATION") | ||
1952 | user_role = rh.get_token(token[-11:]) | ||
1953 | self.running_log.info('[InvoiceExcelView] [user_role={0}] '.format(user_role)) | ||
1954 | if user_role is None or user_role == '-1' or (user_role == '1' and application_entity == '2') or (user_role == '2' and application_entity == '1'): | ||
1955 | self.running_log.info('[InvoiceExcelView no permission] [user_role={0}] [application_entity={1}]'.format(user_role, application_entity)) | ||
1956 | raise NoPermissionException('no permission') | ||
1957 | |||
1958 | url = 'http://127.0.0.1:8088/napi/invoice/downloadExcelOri' | ||
1959 | body = { | ||
1960 | 'applicationIds': application_ids, | ||
1961 | 'applicationEntity': application_entity | ||
1962 | } | ||
1963 | try: | ||
1964 | self.running_log.info("request java invoice excel api, url:{0}, body:{1}".format(url, json.dumps(body))) | ||
1965 | headers = { | ||
1966 | 'Content-Type': 'application/json' | ||
1967 | } | ||
1968 | resp = requests.post(url, headers=headers, json=body) | ||
1969 | self.running_log.info("java invoice excel api finish, applicationIds:{0},{1}".format(application_ids, resp.text)) | ||
1970 | res_json = json.loads(resp.text) | ||
1971 | file_path = res_json.get('result') | ||
1972 | self.running_log.info("java invoice excel after process, filePath:{0}".format(file_path)) | ||
1973 | current_time = time.strftime('%Y-%m-%d_%H_%M_%S', time.localtime()) | ||
1974 | download_file_name = "发票信息提取-" + current_time + ".xlsx" | ||
1975 | f = open(file_path,"rb") | ||
1976 | response = HttpResponse(content_type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') | ||
1977 | response['Content-Disposition'] = 'attachment; filename="{0}"'.format(escape_uri_path(download_file_name)) | ||
1978 | response['Access-Control-Expose-Headers'] = 'content-disposition' | ||
1979 | response.write(f.read()) | ||
1980 | f.close() | ||
1981 | return response | ||
1982 | except Exception as e: | ||
1983 | self.running_log.error("invoice excel request to java error, url:{0}, param:{1}, errorMsg:{2}".format( | ||
1984 | url, json.dumps(body), traceback.format_exc())) | ||
1985 | |||
1986 | class InvoiceQueryInfoView(GenericView): | ||
1987 | #permission_classes = [IsAuthenticated] | ||
1988 | #authentication_classes = [OAuth2AuthenticationWithUser] | ||
1989 | |||
1990 | @use_args(invoice_download_args, location='querystring') | ||
1991 | def get(self, request, args): | ||
1992 | application_ids = args.get('application_ids') | ||
1993 | application_entity = args.get('application_entity') | ||
1994 | self.running_log.info('[InvoiceExcelView] [user_role={0}] '.format('111222333')) | ||
1995 | |||
1996 | # 角色权限不符,返回异常 | ||
1997 | token = request.META.get("HTTP_AUTHORIZATION") | ||
1998 | user_role = rh.get_token(token[-11:]) | ||
1999 | self.running_log.info('[InvoiceQueryInfoView] [user_role={0}] '.format(user_role)) | ||
2000 | if user_role is None or user_role == '-1' or (user_role == '1' and application_entity == '2') or (user_role == '2' and application_entity == '1'): | ||
2001 | self.running_log.info('[InvoiceExcelView no permission] [user_role={0}] [application_entity={1}]'.format(user_role, application_entity)) | ||
2002 | raise NoPermissionException('no permission') | ||
2003 | |||
2004 | url = 'http://127.0.0.1:8088/napi/invoice/queryInfoOri' | ||
2005 | body = { | ||
2006 | 'applicationIds': application_ids, | ||
2007 | 'applicationEntity': application_entity | ||
2008 | } | ||
2009 | try: | ||
2010 | self.running_log.info("request java invoice info api, url:{0}, body:{1}".format(url, json.dumps(body))) | ||
2011 | headers = { | ||
2012 | 'Content-Type': 'application/json' | ||
2013 | } | ||
2014 | resp = requests.post(url, headers=headers, json=body) | ||
2015 | self.running_log.info("java invoice info api finish, applicationIds:{0},{1}".format(application_ids, resp.text)) | ||
2016 | res_json = json.loads(resp.text) | ||
2017 | java_result = res_json.get('result') | ||
2018 | return response.ok(data=java_result) | ||
2019 | except Exception as e: | ||
2020 | self.running_log.error("invoice info request to java error, url:{0}, param:{1}, errorMsg:{2}".format( | ||
2021 | url, json.dumps(body), traceback.format_exc())) | ||
2022 | |||
2023 | def notifyCmsPass(self, request): | ||
2024 | args = request.data | ||
2025 | cms_info = args.get('content', {}) | ||
2026 | business_type = consts.AFC_PREFIX if cms_info.get('financeCompany', '').startswith('宝马') else consts.HIL_PREFIX | ||
2027 | src_application_id = cms_info.get('settlemnetVerification', {}).get('applicationNo', '') | ||
2028 | application_id = src_application_id[:src_application_id.rfind('-')] | ||
2029 | |||
2030 | pressure_switch = Configs.objects.filter(id=3).first() | ||
2031 | if pressure_switch is None or (pressure_switch is not None and pressure_switch.value == 'N'): | ||
2032 | self.running_log.info('[pressure_switch] [entity={0}]]'.format(pressure_switch)) | ||
2033 | return False | ||
2034 | |||
2035 | application_link = '{0}/showList/showList?entity={1}&scheme={2}&case_id={3}'.format( | ||
2036 | conf.BASE_URL, business_type, consts.COMPARE_DOC_SCHEME_LIST[1], application_id) | ||
2037 | data = { | ||
2038 | "SubtenantId": consts.TENANT_MAP[business_type], | ||
2039 | "Data": { | ||
2040 | "Result_Message": "Pass", | ||
2041 | "AutoCheckResult": "Pass", | ||
2042 | "Failure_Reason": "", | ||
2043 | "Application_Number": application_id, | ||
2044 | "Bank_Statement": "", | ||
2045 | "Link_URL": application_link, | ||
2046 | "OCR_Version": 1, | ||
2047 | "Origin": consts.INFO_SOURCE[1] | ||
2048 | } | ||
2049 | } | ||
2050 | try: | ||
2051 | response = cms.send(data) # interface_report ocr to cms | ||
2052 | except Exception as e: | ||
2053 | self.running_log.error('[pressure cms error] [error={0}]'.format(traceback.format_exc())) | ||
2054 | else: | ||
2055 | self.running_log.info('[pressure cms success] [response={0}]'.format(response)) | ||
2056 | return True | ||
2057 | class EmployeeView(GenericView): | ||
2058 | permission_classes = [IsAuthenticated] | ||
2059 | authentication_classes = [OAuth2AuthenticationWithUser] | ||
2060 | |||
2061 | @use_args(employee_args, location='data') | ||
2062 | def post(self, request, args): | ||
2063 | |||
2064 | application_id = args.get('application_id') | ||
2065 | business_type = args.get('business_type') | ||
2066 | |||
2067 | ocr_result_class = HILOCRResult if business_type in consts.HIL_SET else AFCOCRResult | ||
2068 | ocr_result_info = ocr_result_class.objects.filter(application_id=application_id).first() | ||
2069 | self.running_log.info('[query Employee] [application_id={0}] [business_type={1}] [ocr_result_info exist={2}]'.format(application_id, business_type, ocr_result_info is not None)) | ||
2070 | if not ocr_result_info: | ||
2071 | self.running_log.info('[query Employee] [application_id={0}] ocr_result none'.format(application_id)) | ||
2072 | return response.ok(data=False) | ||
2073 | bss_ocr_str = ocr_result_info.bss_ocr | ||
2074 | if bss_ocr_str is None: | ||
2075 | return response.ok(data=False) | ||
2076 | bss_ocr = json.loads(bss_ocr_str) | ||
2077 | self.running_log.info('[query Employee] [application_id={0}] [bss_ocr={1}]'.format(application_id, bss_ocr)) | ||
2078 | for one_bss in bss_ocr: | ||
2079 | income_keywords = one_bss.get('income_keywords') | ||
2080 | self.running_log.info('[query Employee] [application_id={0}] [income_keywords={1}]'.format(application_id, income_keywords)) | ||
2081 | if income_keywords is not None and len(income_keywords) > 0: | ||
2082 | return response.ok(data=True) | ||
2083 | return response.ok(data=False) | ||
2084 | |||
2085 | class SearchGBHistoryFileView(GenericView): | ||
2086 | permission_classes = [IsAuthenticated] | ||
2087 | authentication_classes = [OAuth2AuthenticationWithUser] | ||
2088 | |||
2089 | @use_args(q_gb_file_args, location='data') | ||
2090 | def post(self, request, args): | ||
2091 | |||
2092 | file_path = args.get('file_path') | ||
2093 | business_type = args.get('business_type') | ||
2094 | |||
2095 | gb_history_file_class = HILGreenBookHistoryFile if business_type in consts.HIL_SET else AFCGreenBookHistoryFile | ||
2096 | ecm = ECM() | ||
2097 | response_json = ecm.search_doc_info_list(file_path, business_type) | ||
2098 | data_objects = response_json['Envelope']['Body']['executeResponse']['return']['dataPackage']['DataObjects'] | ||
2099 | self.running_log.info('[SearchGBHistoryFileView] [data_objects size={0}] '.format(len(data_objects))) | ||
2100 | for data_object in data_objects: | ||
2101 | object_id = data_object['Identity']['ObjectId']['@id'] | ||
2102 | properties_dict = {} | ||
2103 | properties = data_object['Properties']['Properties'] | ||
2104 | for prop in properties: | ||
2105 | name = prop['@name'] | ||
2106 | value = prop.get('Value', 'null') # 如果Value为空,则输出null | ||
2107 | properties_dict[name] = value | ||
2108 | self.running_log.info('[SearchGBHistoryFileView] [properties_dict={0}] '.format(properties_dict)) | ||
2109 | |||
2110 | try: | ||
2111 | gb_history_file_class.objects.create( | ||
2112 | object_id=object_id, | ||
2113 | object_name=properties_dict.get('object_name', ''), | ||
2114 | application_no=properties_dict.get('b_application_no', ''), | ||
2115 | object_type='green_book', | ||
2116 | customer_name=properties_dict.get('b_customer_name', ''), | ||
2117 | content_size=properties_dict.get('r_content_size', ''), | ||
2118 | owner_name=properties_dict.get('owner_name', ''), | ||
2119 | #input_date=properties_dict.get('b_input_date', ''), | ||
2120 | #modify_date=properties_dict.get('r_modify_date', ''), | ||
2121 | location=properties_dict.get('b_location', ''), | ||
2122 | download_finish=False | ||
2123 | ) | ||
2124 | except Exception as e: | ||
2125 | self.exception_log.exception('[SearchGBHistoryFileView] [db save failed] [error={0}]'.format(traceback.format_exc())) | ||
2126 | return response.ok(data=True) | ||
2127 | |||
2128 | class DownloadGBHistoryFileView(GenericView): | ||
2129 | permission_classes = [IsAuthenticated] | ||
2130 | authentication_classes = [OAuth2AuthenticationWithUser] | ||
2131 | |||
2132 | @use_args(d_gb_file_args, location='data') | ||
2133 | def post(self, request, args): | ||
2134 | |||
2135 | business_type = args.get('business_type') | ||
2136 | object_id = args.get('object_id') | ||
2137 | save_path = args.get('save_path') | ||
2138 | ecm = ECM() | ||
2139 | ecm.download(save_path, object_id, 'green_book', business_type) | ||
2140 | self.running_log.info('[DownloadGBHistoryFileView] [args={0}] '.format(args)) | ||
2141 | return response.ok(data=False) | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -8,4 +8,6 @@ broker = conf.CELERY_BROKER_URL | ... | @@ -8,4 +8,6 @@ broker = conf.CELERY_BROKER_URL |
8 | 8 | ||
9 | app = Celery('celery_compare', broker=broker, include=['celery_compare.tasks']) | 9 | app = Celery('celery_compare', broker=broker, include=['celery_compare.tasks']) |
10 | 10 | ||
11 | app.conf.update(worker_max_tasks_per_child=5, timezone='Asia/Shanghai') | 11 | # worker_max_tasks_per_child ,worker执行了几次任务就会死 |
12 | #app.conf.update(worker_max_tasks_per_child=10, timezone='Asia/Shanghai') | ||
13 | app.conf.update(timezone='Asia/Shanghai') | ... | ... |
1 | import json | 1 | import json |
2 | from multiprocessing.sharedctypes import Value | ||
2 | import os | 3 | import os |
3 | import cv2 | 4 | import cv2 |
4 | import time | 5 | import time |
... | @@ -38,6 +39,7 @@ from apps.doc.models import ( | ... | @@ -38,6 +39,7 @@ from apps.doc.models import ( |
38 | HILCompareReportNew, | 39 | HILCompareReportNew, |
39 | AFCCompareReportNew, | 40 | AFCCompareReportNew, |
40 | AFCDoc, | 41 | AFCDoc, |
42 | HILDoc, | ||
41 | DealerMapping, | 43 | DealerMapping, |
42 | ) | 44 | ) |
43 | from apps.doc import consts | 45 | from apps.doc import consts |
... | @@ -46,7 +48,14 @@ from apps.doc.ocr.cms import cms | ... | @@ -46,7 +48,14 @@ from apps.doc.ocr.cms import cms |
46 | from apps.doc.exceptions import GCAPException | 48 | from apps.doc.exceptions import GCAPException |
47 | from apps.doc.named_enum import RequestTeam, RequestTrigger, ProcessName, ErrorType, SystemName | 49 | from apps.doc.named_enum import RequestTeam, RequestTrigger, ProcessName, ErrorType, SystemName |
48 | from common.tools.comparison import cp | 50 | from common.tools.comparison import cp |
49 | from common.tools.des import decode_des | 51 | # from common.tools.des import decode_des |
52 | from common.tools.aes_util import aes_decrypt_cbc | ||
53 | |||
54 | import threading | ||
55 | import concurrent.futures | ||
56 | from concurrent.futures import ThreadPoolExecutor | ||
57 | |||
58 | pool = ThreadPoolExecutor(max_workers=50, thread_name_prefix="compare_thread_") | ||
50 | 59 | ||
51 | compare_log = logging.getLogger('compare') | 60 | compare_log = logging.getLogger('compare') |
52 | log_base = '[Compare]' | 61 | log_base = '[Compare]' |
... | @@ -54,6 +63,7 @@ log_base = '[Compare]' | ... | @@ -54,6 +63,7 @@ log_base = '[Compare]' |
54 | empty_str = '' | 63 | empty_str = '' |
55 | empty_error_type = 1000 | 64 | empty_error_type = 1000 |
56 | des_key = conf.CMS_DES_KEY | 65 | des_key = conf.CMS_DES_KEY |
66 | des_iv = conf.CMS_DES_IV | ||
57 | 67 | ||
58 | 68 | ||
59 | def rotate_bound(image, angle): | 69 | def rotate_bound(image, angle): |
... | @@ -933,7 +943,11 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d | ... | @@ -933,7 +943,11 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d |
933 | # is_cdfl = True # 车贷分离 | 943 | # is_cdfl = True # 车贷分离 |
934 | is_cdfl_bo = False # 车贷分离,主借 | 944 | is_cdfl_bo = False # 车贷分离,主借 |
935 | is_cdfl_co = False # 车贷分离,共借 | 945 | is_cdfl_co = False # 车贷分离,共借 |
946 | is_bo_corporate = False | ||
936 | role_count = 0 | 947 | role_count = 0 |
948 | borrower_name = '' | ||
949 | borrower_idnum = '' | ||
950 | legal_name = '' | ||
937 | # province = cms_info.get('province', '') | 951 | # province = cms_info.get('province', '') |
938 | for individual_info in cms_info.get('applicantInformation', []): | 952 | for individual_info in cms_info.get('applicantInformation', []): |
939 | role_count += 1 | 953 | role_count += 1 |
... | @@ -942,7 +956,8 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d | ... | @@ -942,7 +956,8 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d |
942 | license_dict = {} | 956 | license_dict = {} |
943 | 957 | ||
944 | customer_name = individual_info.get('name', '').strip() | 958 | customer_name = individual_info.get('name', '').strip() |
945 | legal_name = individual_info.get('legalRepName', '') | 959 | if legal_name == '': |
960 | legal_name = individual_info.get('legalRepName', '') | ||
946 | establishment_date = individual_info.get('establishmentDate', '') | 961 | establishment_date = individual_info.get('establishmentDate', '') |
947 | # date_of_birth = individual_info.get('dateOfBirth', '') | 962 | # date_of_birth = individual_info.get('dateOfBirth', '') |
948 | 963 | ||
... | @@ -953,11 +968,26 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d | ... | @@ -953,11 +968,26 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d |
953 | if individual_info['applicantType'] == consts.APPLICANT_TYPE_ORDER[0] and not is_corporate: | 968 | if individual_info['applicantType'] == consts.APPLICANT_TYPE_ORDER[0] and not is_corporate: |
954 | is_cdfl_bo = True | 969 | is_cdfl_bo = True |
955 | 970 | ||
971 | # CHINARPA-4660 是否公户判断 | ||
972 | customersubType = individual_info.get('customersubType', '') | ||
973 | if individual_info['applicantType'] == consts.APPLICANT_TYPE_ORDER[0] and is_corporate: | ||
974 | is_bo_corporate = True | ||
975 | |||
976 | # CHINARPA-4660 财报主借人姓名赋值 | ||
977 | # CHINARPA-5075 首付款承诺书主借人证件号赋值 | ||
978 | if individual_info['applicantType'] == consts.APPLICANT_TYPE_ORDER[0]: | ||
979 | borrower_name = customer_name | ||
980 | for id_info in individual_info.get('IDInformation', []): | ||
981 | if id_info.get('idType') in consts.SE_CMS_FIRST_ID_FIELD_MAPPING: | ||
982 | borrower_idnum = aes_decrypt_cbc(id_info.get('idNum', ''), des_key, des_iv) | ||
983 | elif is_corporate and id_info.get('idType') in ['Unified Social Credit Code', 'Tax Number', 'Business License Number']: | ||
984 | borrower_idnum = aes_decrypt_cbc(id_info.get('idNum', ''), des_key, des_iv) | ||
985 | |||
956 | for id_info in individual_info.get('IDInformation', []): | 986 | for id_info in individual_info.get('IDInformation', []): |
957 | if id_info.get('idType') in consts.SE_CMS_FIRST_ID_FIELD_MAPPING: | 987 | if id_info.get('idType') in consts.SE_CMS_FIRST_ID_FIELD_MAPPING: |
958 | license_en, is_prc = consts.SE_CMS_FIRST_ID_FIELD_MAPPING[id_info['idType']] | 988 | license_en, is_prc = consts.SE_CMS_FIRST_ID_FIELD_MAPPING[id_info['idType']] |
959 | # ['customerName', 'idNum', 'dateOfBirth', 'idExpiryDate', 'hukouProvince'] | 989 | # ['customerName', 'idNum', 'dateOfBirth', 'idExpiryDate', 'hukouProvince'] |
960 | id_num = decode_des(id_info.get('idNum', ''), des_key) | 990 | id_num = aes_decrypt_cbc(id_info.get('idNum', ''), des_key, des_iv) |
961 | field_input = [('customerName', customer_name), ('idNum', id_num), | 991 | field_input = [('customerName', customer_name), ('idNum', id_num), |
962 | ('idExpiryDate', id_info.get('idExpiryDate', ''))] | 992 | ('idExpiryDate', id_info.get('idExpiryDate', ''))] |
963 | # if is_prc: | 993 | # if is_prc: |
... | @@ -969,22 +999,23 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d | ... | @@ -969,22 +999,23 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d |
969 | elif id_info.get('idType') in ['Unified Social Credit Code', 'Tax Number', 'Business License Number']: | 999 | elif id_info.get('idType') in ['Unified Social Credit Code', 'Tax Number', 'Business License Number']: |
970 | # ['companyName', 'legalRepName', 'businessLicenseNo', 'organizationCreditCode', | 1000 | # ['companyName', 'legalRepName', 'businessLicenseNo', 'organizationCreditCode', |
971 | # 'taxRegistrationCertificateNo', 'establishmentDate', 'businessLicenseDueDate'] | 1001 | # 'taxRegistrationCertificateNo', 'establishmentDate', 'businessLicenseDueDate'] |
972 | id_num = decode_des(id_info.get('idNum', ''), des_key) | 1002 | id_num = aes_decrypt_cbc(id_info.get('idNum', ''), des_key, des_iv) |
973 | # bl_field_input = [ | 1003 | bl_field_input = [ |
974 | # ('companyName', customer_name), | 1004 | ('companyName', customer_name), |
975 | # ('legalRepName', legal_name), | 1005 | ('legalRepName', legal_name), |
976 | # ('businessLicenseNo', id_num), | 1006 | ('businessLicenseNo', id_num), |
977 | # ('organizationCreditCode', id_num), | 1007 | ('organizationCreditCode', id_num), |
978 | # ('taxRegistrationCertificateNo', id_num), | 1008 | ('taxRegistrationCertificateNo', id_num), |
979 | # ('businessLicenseDueDate', id_info.get('idExpiryDate', '')), | 1009 | # ('businessLicenseDueDate', id_info.get('idExpiryDate', '')), |
980 | # ] | 1010 | ] |
981 | 1011 | ||
982 | if is_corporate: | 1012 | if is_corporate: |
983 | company_info_list.append((customer_name, id_num, legal_name)) | 1013 | company_info_list.append((customer_name, id_num, legal_name)) |
984 | # else: | 1014 | else: |
985 | # bl_field_input.append(('establishmentDate', establishment_date)) | 1015 | bl_field_input.append(('establishmentDate', establishment_date)) |
986 | 1016 | ||
987 | # license_dict[consts.BL_EN] = bl_field_input | 1017 | compare_log.info('{0} [bl_field_input] [{1}]'.format(log_base, bl_field_input)) |
1018 | license_dict[consts.BL_EN] = bl_field_input | ||
988 | all_id_num.append(id_num) | 1019 | all_id_num.append(id_num) |
989 | 1020 | ||
990 | # SME营业执照--------------------------------------------------------------------------------------------------- | 1021 | # SME营业执照--------------------------------------------------------------------------------------------------- |
... | @@ -1000,6 +1031,7 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d | ... | @@ -1000,6 +1031,7 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d |
1000 | (customer_name, '、'.join(all_id_num), all_id_num[0]) | 1031 | (customer_name, '、'.join(all_id_num), all_id_num[0]) |
1001 | ) | 1032 | ) |
1002 | 1033 | ||
1034 | compare_log.info('{0} [license_dict] [{1}]'.format(log_base, license_dict)) | ||
1003 | if len(license_dict) > 0: | 1035 | if len(license_dict) > 0: |
1004 | individual_info_dict.setdefault(individual_info['applicantType'], []).append(license_dict) | 1036 | individual_info_dict.setdefault(individual_info['applicantType'], []).append(license_dict) |
1005 | 1037 | ||
... | @@ -1067,7 +1099,7 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d | ... | @@ -1067,7 +1099,7 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d |
1067 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[1], co_id if is_cdfl else main_id)) # 车贷分离 | 1099 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[1], co_id if is_cdfl else main_id)) # 车贷分离 |
1068 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[2], first_submission_date)) | 1100 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[2], first_submission_date)) |
1069 | # vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[3], consts.SE_STAMP_VALUE)) | 1101 | # vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[3], consts.SE_STAMP_VALUE)) |
1070 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[4], consts.SE_FPL_VALUE)) | 1102 | # vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[4], consts.SE_FPL_VALUE)) |
1071 | bhsj = float(amount) / 1.13 | 1103 | bhsj = float(amount) / 1.13 |
1072 | # vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[5], consts.SPLIT_STR.join([ | 1104 | # vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[5], consts.SPLIT_STR.join([ |
1073 | # format(bhsj, '.2f'), | 1105 | # format(bhsj, '.2f'), |
... | @@ -1120,16 +1152,51 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d | ... | @@ -1120,16 +1152,51 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d |
1120 | # vehicle_info[consts.UCI_EN] = vehicle_field_input | 1152 | # vehicle_info[consts.UCI_EN] = vehicle_field_input |
1121 | compare_info['vehicleInfo'] = vehicle_info | 1153 | compare_info['vehicleInfo'] = vehicle_info |
1122 | 1154 | ||
1155 | # 公户财务报表------------------------------------------------------------------------------------------------- | ||
1156 | financial_statement_info = {} | ||
1157 | financial_statement_input = [] | ||
1158 | corporateFinancialInformation = cms_info.get('corporateFinancialInformation', {}) | ||
1159 | hashCode = corporateFinancialInformation.get('hashCode', '') | ||
1160 | fiscalYear = corporateFinancialInformation.get('fiscalYear', '') | ||
1161 | totalAssets = corporateFinancialInformation.get('totaAssets', 0) | ||
1162 | totalLiabilitiesAndOwnersEquity = corporateFinancialInformation.get('totalLiabilitiesAndOwnersEquity', 0) | ||
1163 | netProfit = corporateFinancialInformation.get('netProfit', 0) | ||
1164 | if is_bo_corporate: | ||
1165 | financial_statement_input.append((consts.SE_FS_FIELD[0], hashCode)) | ||
1166 | financial_statement_input.append((consts.SE_FS_FIELD[1], consts.SE_STAMP_VALUE)) | ||
1167 | financial_statement_input.append((consts.SE_FS_FIELD[2], fiscalYear)) | ||
1168 | financial_statement_input.append((consts.SE_FS_FIELD[3], [totalAssets, totalLiabilitiesAndOwnersEquity])) | ||
1169 | financial_statement_input.append((consts.SE_FS_FIELD[4], [netProfit])) | ||
1170 | financial_statement_info[consts.FS_EN] = financial_statement_input | ||
1171 | compare_info['financialStatementInfo'] = financial_statement_info | ||
1172 | |||
1173 | # 财报情况说明 | ||
1174 | financial_statement_supplementary_info = {} | ||
1175 | financial_statement_supplementary_input = [] | ||
1176 | cashAndCashEquivalentAtEndOfPeriod = corporateFinancialInformation.get('cashAndCashEquivalentAtEndOfPeriod', '') | ||
1177 | if cashAndCashEquivalentAtEndOfPeriod == '': | ||
1178 | need_fss = False | ||
1179 | else: | ||
1180 | need_fss = float(cashAndCashEquivalentAtEndOfPeriod) == 0 | ||
1181 | if is_bo_corporate and need_fss: | ||
1182 | financial_statement_supplementary_input.append((consts.SE_FSS_FIELD[0], borrower_name)) | ||
1183 | financial_statement_supplementary_input.append((consts.SE_FSS_FIELD[1], consts.SE_STAMP_VALUE)) | ||
1184 | financial_statement_supplementary_info[consts.FSS_EN] = financial_statement_supplementary_input | ||
1185 | compare_info['financialStatementSupplementaryInfo'] = financial_statement_supplementary_info | ||
1186 | |||
1187 | |||
1123 | # 银行卡------------------------------------------------------------------------------------------------------- | 1188 | # 银行卡------------------------------------------------------------------------------------------------------- |
1124 | bank_info = {} | 1189 | bank_info = {} |
1125 | bank_name = cms_info.get('bankAccountDetails', {}).get('bankName', '') | 1190 | bank_name = cms_info.get('bankAccountDetails', {}).get('bankName', '') |
1126 | account_no = decode_des(cms_info.get('bankAccountDetails', {}).get('accountNo', ''), des_key) | 1191 | account_no = aes_decrypt_cbc(cms_info.get('bankAccountDetails', {}).get('accountNo', ''), des_key, des_iv) |
1127 | account_holder_name = cms_info.get('bankAccountDetails', {}).get('accountHolderName', '') | 1192 | account_holder_name = cms_info.get('bankAccountDetails', {}).get('accountHolderName', '') |
1128 | is_gsyh = True if '工商' in bank_name else False | 1193 | is_gsyh = True if '工商' in bank_name else False |
1129 | 1194 | ||
1130 | if isinstance(company_info, tuple) and company_info[0] == account_holder_name: | 1195 | # CHINARPA-4942 去掉注释逻辑,改为只要not ignore_bank 银行卡都要校验,不论是否公户 |
1131 | pass | 1196 | # if isinstance(company_info, tuple) and company_info[0] == account_holder_name: |
1132 | elif not ignore_bank: | 1197 | # pass |
1198 | # el | ||
1199 | if not ignore_bank: | ||
1133 | bank_field_input = [ | 1200 | bank_field_input = [ |
1134 | ('accountNo', account_no), | 1201 | ('accountNo', account_no), |
1135 | ('bankName', bank_name), | 1202 | ('bankName', bank_name), |
... | @@ -1154,9 +1221,11 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d | ... | @@ -1154,9 +1221,11 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d |
1154 | compare_info['bankInfo'] = bank_info | 1221 | compare_info['bankInfo'] = bank_info |
1155 | 1222 | ||
1156 | # 银行流水 -------------------------------------------------------------------- | 1223 | # 银行流水 -------------------------------------------------------------------- |
1224 | #增加 allow_bs_type 默认值,防止不需要比对流水的申请报错 | ||
1225 | allow_bs_type = '全部' | ||
1157 | if cms_info.get('autoApprovedDetails', {}).get('aaType', '') in ['CAA1', 'CAA2'] and \ | 1226 | if cms_info.get('autoApprovedDetails', {}).get('aaType', '') in ['CAA1', 'CAA2'] and \ |
1158 | '无需提供银行流水' not in cms_info.get('autoApprovedDetails', {}).get('PolicyComments', ''): | 1227 | '无需提供银行流水' not in cms_info.get('autoApprovedDetails', {}).get('PolicyComments', ''): |
1159 | date_timedelta = 60 if auto else 90 | 1228 | date_timedelta = 83 if auto else 83 |
1160 | bs_role_list = [] | 1229 | bs_role_list = [] |
1161 | for applicant_type in consts.APPLICANT_TYPE_ORDER[:2]: | 1230 | for applicant_type in consts.APPLICANT_TYPE_ORDER[:2]: |
1162 | if applicant_type in main_role_info: | 1231 | if applicant_type in main_role_info: |
... | @@ -1170,6 +1239,14 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d | ... | @@ -1170,6 +1239,14 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d |
1170 | (consts.SE_BS_FIELD[2], date_timedelta), | 1239 | (consts.SE_BS_FIELD[2], date_timedelta), |
1171 | ] | 1240 | ] |
1172 | 1241 | ||
1242 | #在比对逻辑中添加字段 | ||
1243 | if '仅接受银行流水' in cms_info.get('autoApprovedDetails', {}).get('PolicyComments', ''): | ||
1244 | #bs_field_input.append((consts.SE_BS_FIELD[9], '仅接受银行流水')) | ||
1245 | allow_bs_type = '仅接受银行流水' | ||
1246 | else: | ||
1247 | #bs_field_input.append((consts.SE_BS_FIELD[9], '全部')) | ||
1248 | allow_bs_type = '全部' | ||
1249 | |||
1173 | dbr_bs_role_list = [] | 1250 | dbr_bs_role_list = [] |
1174 | for dbr_bs_role, _, _ in main_role_info.get(consts.APPLICANT_TYPE_ORDER[2], []): | 1251 | for dbr_bs_role, _, _ in main_role_info.get(consts.APPLICANT_TYPE_ORDER[2], []): |
1175 | dbr_bs_role_list.append(dbr_bs_role) | 1252 | dbr_bs_role_list.append(dbr_bs_role) |
... | @@ -1251,9 +1328,9 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d | ... | @@ -1251,9 +1328,9 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d |
1251 | tmp_gzs_list = [amount, ] | 1328 | tmp_gzs_list = [amount, ] |
1252 | 1329 | ||
1253 | # 保单 ----------------------------------------------------------------------------------------------------------- | 1330 | # 保单 ----------------------------------------------------------------------------------------------------------- |
1331 | # 以前被注释的 start | ||
1254 | # is_insurance = 0 | 1332 | # is_insurance = 0 |
1255 | # fp_campaign = cms_info.get('fpCampaign', '') | 1333 | # fp_campaign = cms_info.get('fpCampaign', '') |
1256 | fp_group = cms_info.get('fpGroup', '') | ||
1257 | # insurance_type = cms_info.get('insuranceDetails', {}).get('insuranceType', '') | 1334 | # insurance_type = cms_info.get('insuranceDetails', {}).get('insuranceType', '') |
1258 | # if insurance_type == 'Waive Insurance' and isinstance(insurance_price, str): | 1335 | # if insurance_type == 'Waive Insurance' and isinstance(insurance_price, str): |
1259 | # is_insurance = 1 | 1336 | # is_insurance = 1 |
... | @@ -1283,6 +1360,40 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d | ... | @@ -1283,6 +1360,40 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d |
1283 | # if is_insurance == 1: | 1360 | # if is_insurance == 1: |
1284 | # bd_field_input.append((consts.SE_BD_FIELD[10], insurance_price)) | 1361 | # bd_field_input.append((consts.SE_BD_FIELD[10], insurance_price)) |
1285 | # other_info[consts.BD_EN] = bd_field_input | 1362 | # other_info[consts.BD_EN] = bd_field_input |
1363 | # 以前被注释的 end | ||
1364 | |||
1365 | is_insurance = 0 | ||
1366 | fp_campaign = cms_info.get('fpCampaign', '') | ||
1367 | fp_group = cms_info.get('fpGroup', '') | ||
1368 | insurance_type = cms_info.get('insuranceDetails', {}).get('insuranceType', '') | ||
1369 | if isinstance(insurance_price, str): | ||
1370 | is_insurance = 1 | ||
1371 | elif insurance_type == 'Comprehensive Insurance': | ||
1372 | is_insurance = 2 | ||
1373 | if is_insurance != 0: | ||
1374 | if fp_campaign.find('OCU') == -1: | ||
1375 | ssx_amount = amount | ||
1376 | else: | ||
1377 | ssx_amount = format(float(amount) * 0.8, '.2f') | ||
1378 | if fp_campaign.find('Joy_Plus') == -1 or fp_campaign.find('JoyPlus') == -1: | ||
1379 | dszx_amount = '200000' | ||
1380 | else: | ||
1381 | dszx_amount = '500000' | ||
1382 | bd_field_input = [ | ||
1383 | (consts.SE_BD_FIELD[0], [co_name, bo_name] if is_cdfl else [main_name, ]), # 车贷分离 | ||
1384 | (consts.SE_BD_FIELD[1], [co_id, bo_id] if is_cdfl else [main_id, ]), # 车贷分离 | ||
1385 | (consts.SE_BD_FIELD[2], vin_no), | ||
1386 | # (consts.SE_BD_FIELD[3], ssx_amount), | ||
1387 | # (consts.SE_BD_FIELD[4], dszx_amount), | ||
1388 | # (consts.SE_BD_FIELD[5], consts.JDMPV_VALUE), | ||
1389 | (consts.SE_BD_FIELD[6], cms_info.get('insuranceDetails', {}).get('startDate', '')), | ||
1390 | (consts.SE_BD_FIELD[7], cms_info.get('insuranceDetails', {}).get('endDate', '')), | ||
1391 | (consts.SE_BD_FIELD[8], consts.SE_STAMP_VALUE), | ||
1392 | # (consts.SE_BD_FIELD[9], consts.SE_DYSYR_VALUE), | ||
1393 | ] | ||
1394 | if is_insurance == 1: | ||
1395 | bd_field_input.append((consts.SE_BD_FIELD[10], insurance_price)) | ||
1396 | other_info[consts.BD_EN] = bd_field_input | ||
1286 | 1397 | ||
1287 | if len(other_info) > 0: | 1398 | if len(other_info) > 0: |
1288 | compare_info['other'] = other_info | 1399 | compare_info['other'] = other_info |
... | @@ -1341,7 +1452,10 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d | ... | @@ -1341,7 +1452,10 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d |
1341 | if len(main_role_info[app_type]) >= id_idx+1: | 1452 | if len(main_role_info[app_type]) >= id_idx+1: |
1342 | is_find = True | 1453 | is_find = True |
1343 | if isinstance(field_idx, int): | 1454 | if isinstance(field_idx, int): |
1344 | hil_contract_1_input.append((key, main_role_info[app_type][id_idx][field_idx])) | 1455 | if key == '承租人签字' and is_bo_corporate: |
1456 | hil_contract_1_input.append((key, legal_name)) | ||
1457 | else: | ||
1458 | hil_contract_1_input.append((key, main_role_info[app_type][id_idx][field_idx])) | ||
1345 | else: | 1459 | else: |
1346 | hil_contract_1_input.append((key, field_idx)) | 1460 | hil_contract_1_input.append((key, field_idx)) |
1347 | if not is_find and is_force: | 1461 | if not is_find and is_force: |
... | @@ -1383,14 +1497,17 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d | ... | @@ -1383,14 +1497,17 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d |
1383 | if len(main_role_info[app_type]) >= id_idx+1: | 1497 | if len(main_role_info[app_type]) >= id_idx+1: |
1384 | is_find = True | 1498 | is_find = True |
1385 | if isinstance(field_idx, int): | 1499 | if isinstance(field_idx, int): |
1386 | hil_contract_2_input.append((key, main_role_info[app_type][id_idx][field_idx])) | 1500 | if key == '抵押人签字' and is_bo_corporate: |
1501 | hil_contract_2_input.append((key, legal_name)) | ||
1502 | else: | ||
1503 | hil_contract_2_input.append((key, main_role_info[app_type][id_idx][field_idx])) | ||
1387 | else: | 1504 | else: |
1388 | hil_contract_2_input.append((key, field_idx)) | 1505 | hil_contract_2_input.append((key, field_idx)) |
1389 | if not is_find and is_force: | 1506 | if not is_find and is_force: |
1390 | hil_contract_2_input.append((key, empty_str)) | 1507 | hil_contract_2_input.append((key, empty_str)) |
1391 | contract_info[consts.HIL_CONTRACT_2_EN] = hil_contract_2_input | 1508 | contract_info[consts.HIL_CONTRACT_2_EN] = hil_contract_2_input |
1392 | compare_info['contract'] = contract_info | 1509 | compare_info['contract'] = contract_info |
1393 | return compare_info, cms_info.get('autoApprovedDetails', {}).get('aaType', ''), is_gsyh | 1510 | return compare_info, cms_info.get('autoApprovedDetails', {}).get('aaType', ''), is_gsyh, allow_bs_type |
1394 | else: | 1511 | else: |
1395 | # AFC合同------------------------------------------------------------------------------------------------------ | 1512 | # AFC合同------------------------------------------------------------------------------------------------------ |
1396 | vehicle_principal_str = str(cms_info.get('financialInformation', {}).get('vehiclePrincipal', '0.0')) | 1513 | vehicle_principal_str = str(cms_info.get('financialInformation', {}).get('vehiclePrincipal', '0.0')) |
... | @@ -1450,7 +1567,10 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d | ... | @@ -1450,7 +1567,10 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d |
1450 | if len(main_role_info[app_type]) >= id_idx+1: | 1567 | if len(main_role_info[app_type]) >= id_idx+1: |
1451 | is_find = True | 1568 | is_find = True |
1452 | if isinstance(field_idx, int): | 1569 | if isinstance(field_idx, int): |
1453 | afc_contract_input.append((key, main_role_info[app_type][id_idx][field_idx])) | 1570 | if (key == '借款人签字及时间' or key == '主借人签字') and is_bo_corporate: |
1571 | afc_contract_input.append((key, legal_name)) | ||
1572 | else: | ||
1573 | afc_contract_input.append((key, main_role_info[app_type][id_idx][field_idx])) | ||
1454 | else: | 1574 | else: |
1455 | afc_contract_input.append((key, field_idx)) | 1575 | afc_contract_input.append((key, field_idx)) |
1456 | if not is_find and is_force: | 1576 | if not is_find and is_force: |
... | @@ -1466,7 +1586,21 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d | ... | @@ -1466,7 +1586,21 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d |
1466 | contract_info[consts.AFC_CONTRACT_QRS_EN] = afc_contract_qrs_input | 1586 | contract_info[consts.AFC_CONTRACT_QRS_EN] = afc_contract_qrs_input |
1467 | 1587 | ||
1468 | compare_info['contract'] = contract_info | 1588 | compare_info['contract'] = contract_info |
1469 | return compare_info, cms_info.get('autoApprovedDetails', {}).get('aaType', ''), is_gsyh | 1589 | |
1590 | # 首付款承诺书 | ||
1591 | down_payment_info = {} | ||
1592 | down_payment_input = [] | ||
1593 | totalDownPayment = str(cms_info.get('financialInformation', {}).get('totalDownPayment')) | ||
1594 | if totalDownPayment and totalDownPayment != '0.00': | ||
1595 | down_payment_input.append((consts.SE_DP_FIELD[0], cms_info.get('financeCompany', ''))) | ||
1596 | down_payment_input.append((consts.SE_DP_FIELD[1], borrower_name)) | ||
1597 | down_payment_input.append((consts.SE_DP_FIELD[2], borrower_idnum)) | ||
1598 | down_payment_input.append((consts.SE_DP_FIELD[3], cms_info.get('settlemnetVerification', {}).get('applicationNo', ''))) | ||
1599 | down_payment_input.append((consts.SE_DP_FIELD[4], legal_name if is_bo_corporate else borrower_name )) | ||
1600 | down_payment_input.append((consts.SE_DP_FIELD[5], '有/无')) | ||
1601 | down_payment_info[consts.DP_EN] = down_payment_input | ||
1602 | compare_info['downPayment'] = down_payment_info | ||
1603 | return compare_info, cms_info.get('autoApprovedDetails', {}).get('aaType', ''), is_gsyh, allow_bs_type | ||
1470 | 1604 | ||
1471 | 1605 | ||
1472 | def get_se_cms_compare_info(application_id, last_obj, application_entity, detect_list, data_source, auto=False, ignore_bank=False): | 1606 | def get_se_cms_compare_info(application_id, last_obj, application_entity, detect_list, data_source, auto=False, ignore_bank=False): |
... | @@ -1500,7 +1634,11 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect | ... | @@ -1500,7 +1634,11 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect |
1500 | # 个人信息证件------------------------------------------------------------------------------------------------------ | 1634 | # 个人信息证件------------------------------------------------------------------------------------------------------ |
1501 | is_cdfl_bo = False # 车贷分离,主借 | 1635 | is_cdfl_bo = False # 车贷分离,主借 |
1502 | is_cdfl_co = False # 车贷分离,共借 | 1636 | is_cdfl_co = False # 车贷分离,共借 |
1637 | is_bo_corporate = False | ||
1503 | role_count = 0 | 1638 | role_count = 0 |
1639 | borrower_name = '' | ||
1640 | borrower_idnum = '' | ||
1641 | legal_name = '' | ||
1504 | # province = cms_info.get('province', '') | 1642 | # province = cms_info.get('province', '') |
1505 | for individual_info in cms_info.get('applicantInformation', []): | 1643 | for individual_info in cms_info.get('applicantInformation', []): |
1506 | role_count += 1 | 1644 | role_count += 1 |
... | @@ -1509,7 +1647,8 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect | ... | @@ -1509,7 +1647,8 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect |
1509 | license_dict = {} | 1647 | license_dict = {} |
1510 | 1648 | ||
1511 | customer_name = individual_info.get('name', '').strip() | 1649 | customer_name = individual_info.get('name', '').strip() |
1512 | legal_name = individual_info.get('legalRepName', '') | 1650 | if legal_name == '': |
1651 | legal_name = individual_info.get('legalRepName', '') | ||
1513 | establishment_date = individual_info.get('establishmentDate', '') | 1652 | establishment_date = individual_info.get('establishmentDate', '') |
1514 | # date_of_birth = individual_info.get('dateOfBirth', '') | 1653 | # date_of_birth = individual_info.get('dateOfBirth', '') |
1515 | 1654 | ||
... | @@ -1520,11 +1659,26 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect | ... | @@ -1520,11 +1659,26 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect |
1520 | if individual_info['applicantType'] == consts.APPLICANT_TYPE_ORDER[0] and not is_corporate: | 1659 | if individual_info['applicantType'] == consts.APPLICANT_TYPE_ORDER[0] and not is_corporate: |
1521 | is_cdfl_bo = True | 1660 | is_cdfl_bo = True |
1522 | 1661 | ||
1662 | # CHINARPA-4660 是否公户判断 | ||
1663 | customersubType = individual_info.get('customersubType', '') | ||
1664 | if individual_info['applicantType'] == consts.APPLICANT_TYPE_ORDER[0] and is_corporate: | ||
1665 | is_bo_corporate = True | ||
1666 | |||
1667 | # CHINARPA-4660 财报主借人姓名赋值 | ||
1668 | # CHINARPA-5075 首付款承诺书主借人证件号赋值 | ||
1669 | if individual_info['applicantType'] == consts.APPLICANT_TYPE_ORDER[0]: | ||
1670 | borrower_name = customer_name | ||
1671 | for id_info in individual_info.get('IDInformation', []): | ||
1672 | if id_info.get('idType') in consts.SE_CMS_FIRST_ID_FIELD_MAPPING: | ||
1673 | borrower_idnum = aes_decrypt_cbc(id_info.get('idNum', ''), des_key, des_iv) | ||
1674 | elif is_corporate and id_info.get('idType') in ['Unified Social Credit Code', 'Tax Number', 'Business License Number']: | ||
1675 | borrower_idnum = aes_decrypt_cbc(id_info.get('idNum', ''), des_key, des_iv) | ||
1676 | |||
1523 | for id_info in individual_info.get('IDInformation', []): | 1677 | for id_info in individual_info.get('IDInformation', []): |
1524 | if id_info.get('idType') in consts.SE_CMS_FIRST_ID_FIELD_MAPPING: | 1678 | if id_info.get('idType') in consts.SE_CMS_FIRST_ID_FIELD_MAPPING: |
1525 | license_en, is_prc = consts.SE_CMS_FIRST_ID_FIELD_MAPPING[id_info['idType']] | 1679 | license_en, is_prc = consts.SE_CMS_FIRST_ID_FIELD_MAPPING[id_info['idType']] |
1526 | # ['customerName', 'idNum', 'dateOfBirth', 'idExpiryDate', 'hukouProvince'] | 1680 | # ['customerName', 'idNum', 'dateOfBirth', 'idExpiryDate', 'hukouProvince'] |
1527 | id_num = decode_des(id_info.get('idNum', ''), des_key) | 1681 | id_num = aes_decrypt_cbc(id_info.get('idNum', ''), des_key, des_iv) |
1528 | field_input = [('customerName', customer_name), ('idNum', id_num), | 1682 | field_input = [('customerName', customer_name), ('idNum', id_num), |
1529 | ('idExpiryDate', id_info.get('idExpiryDate', ''))] | 1683 | ('idExpiryDate', id_info.get('idExpiryDate', ''))] |
1530 | # if is_prc: | 1684 | # if is_prc: |
... | @@ -1536,7 +1690,7 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect | ... | @@ -1536,7 +1690,7 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect |
1536 | elif id_info.get('idType') in ['Unified Social Credit Code', 'Tax Number', 'Business License Number']: | 1690 | elif id_info.get('idType') in ['Unified Social Credit Code', 'Tax Number', 'Business License Number']: |
1537 | # ['companyName', 'legalRepName', 'businessLicenseNo', 'organizationCreditCode', | 1691 | # ['companyName', 'legalRepName', 'businessLicenseNo', 'organizationCreditCode', |
1538 | # 'taxRegistrationCertificateNo', 'establishmentDate', 'businessLicenseDueDate'] | 1692 | # 'taxRegistrationCertificateNo', 'establishmentDate', 'businessLicenseDueDate'] |
1539 | id_num = decode_des(id_info.get('idNum', ''), des_key) | 1693 | id_num = aes_decrypt_cbc(id_info.get('idNum', ''), des_key, des_iv) |
1540 | bl_field_input = [ | 1694 | bl_field_input = [ |
1541 | ('companyName', customer_name), | 1695 | ('companyName', customer_name), |
1542 | ('legalRepName', legal_name), | 1696 | ('legalRepName', legal_name), |
... | @@ -1551,6 +1705,7 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect | ... | @@ -1551,6 +1705,7 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect |
1551 | else: | 1705 | else: |
1552 | bl_field_input.append(('establishmentDate', establishment_date)) | 1706 | bl_field_input.append(('establishmentDate', establishment_date)) |
1553 | 1707 | ||
1708 | compare_log.info('{0} [bl_field_input] [{1}]'.format(log_base, bl_field_input)) | ||
1554 | license_dict[consts.BL_EN] = bl_field_input | 1709 | license_dict[consts.BL_EN] = bl_field_input |
1555 | all_id_num.append(id_num) | 1710 | all_id_num.append(id_num) |
1556 | 1711 | ||
... | @@ -1567,6 +1722,7 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect | ... | @@ -1567,6 +1722,7 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect |
1567 | (customer_name, '、'.join(all_id_num), all_id_num[0]) | 1722 | (customer_name, '、'.join(all_id_num), all_id_num[0]) |
1568 | ) | 1723 | ) |
1569 | 1724 | ||
1725 | compare_log.info('{0} [license_dict] [{1}]'.format(log_base, license_dict)) | ||
1570 | if len(license_dict) > 0: | 1726 | if len(license_dict) > 0: |
1571 | individual_info_dict.setdefault(individual_info['applicantType'], []).append(license_dict) | 1727 | individual_info_dict.setdefault(individual_info['applicantType'], []).append(license_dict) |
1572 | 1728 | ||
... | @@ -1630,7 +1786,7 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect | ... | @@ -1630,7 +1786,7 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect |
1630 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[1], co_id if is_cdfl else main_id)) # 车贷分离 | 1786 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[1], co_id if is_cdfl else main_id)) # 车贷分离 |
1631 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[2], first_submission_date)) | 1787 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[2], first_submission_date)) |
1632 | # vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[3], consts.SE_STAMP_VALUE)) | 1788 | # vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[3], consts.SE_STAMP_VALUE)) |
1633 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[4], consts.SE_FPL_VALUE)) | 1789 | # vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[4], consts.SE_FPL_VALUE)) |
1634 | bhsj = float(amount) / 1.13 | 1790 | bhsj = float(amount) / 1.13 |
1635 | # vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[5], consts.SPLIT_STR.join([ | 1791 | # vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[5], consts.SPLIT_STR.join([ |
1636 | # format(bhsj, '.2f'), | 1792 | # format(bhsj, '.2f'), |
... | @@ -1687,16 +1843,51 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect | ... | @@ -1687,16 +1843,51 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect |
1687 | vehicle_info[consts.UCI_EN] = vehicle_field_input | 1843 | vehicle_info[consts.UCI_EN] = vehicle_field_input |
1688 | compare_info['vehicleInfo'] = vehicle_info | 1844 | compare_info['vehicleInfo'] = vehicle_info |
1689 | 1845 | ||
1846 | # 公户财务报表------------------------------------------------------------------------------------------------- | ||
1847 | financial_statement_info = {} | ||
1848 | financial_statement_input = [] | ||
1849 | corporateFinancialInformation = cms_info.get('corporateFinancialInformation', {}) | ||
1850 | hashCode = corporateFinancialInformation.get('hashCode', '') | ||
1851 | fiscalYear = corporateFinancialInformation.get('fiscalYear', '') | ||
1852 | totalAssets = corporateFinancialInformation.get('totaAssets', 0) | ||
1853 | totalLiabilitiesAndOwnersEquity = corporateFinancialInformation.get('totalLiabilitiesAndOwnersEquity', 0) | ||
1854 | netProfit = corporateFinancialInformation.get('netProfit', 0) | ||
1855 | if is_bo_corporate: | ||
1856 | financial_statement_input.append((consts.SE_FS_FIELD[0], hashCode)) | ||
1857 | financial_statement_input.append((consts.SE_FS_FIELD[1], consts.SE_STAMP_VALUE)) | ||
1858 | financial_statement_input.append((consts.SE_FS_FIELD[2], fiscalYear)) | ||
1859 | financial_statement_input.append((consts.SE_FS_FIELD[3], [totalAssets, totalLiabilitiesAndOwnersEquity])) | ||
1860 | financial_statement_input.append((consts.SE_FS_FIELD[4], [netProfit])) | ||
1861 | financial_statement_info[consts.FS_EN] = financial_statement_input | ||
1862 | compare_info['financialStatementInfo'] = financial_statement_info | ||
1863 | |||
1864 | # 财报情况说明 | ||
1865 | financial_statement_supplementary_info = {} | ||
1866 | financial_statement_supplementary_input = [] | ||
1867 | cashAndCashEquivalentAtEndOfPeriod = corporateFinancialInformation.get('cashAndCashEquivalentAtEndOfPeriod', '') | ||
1868 | if cashAndCashEquivalentAtEndOfPeriod == '': | ||
1869 | need_fss = False | ||
1870 | else: | ||
1871 | need_fss = float(cashAndCashEquivalentAtEndOfPeriod) == 0 | ||
1872 | if is_bo_corporate and need_fss: | ||
1873 | financial_statement_supplementary_input.append((consts.SE_FSS_FIELD[0], borrower_name)) | ||
1874 | financial_statement_supplementary_input.append((consts.SE_FSS_FIELD[1], consts.SE_STAMP_VALUE)) | ||
1875 | financial_statement_supplementary_info[consts.FSS_EN] = financial_statement_supplementary_input | ||
1876 | compare_info['financialStatementSupplementaryInfo'] = financial_statement_supplementary_info | ||
1877 | |||
1878 | |||
1690 | # 银行卡------------------------------------------------------------------------------------------------------- | 1879 | # 银行卡------------------------------------------------------------------------------------------------------- |
1691 | bank_info = {} | 1880 | bank_info = {} |
1692 | bank_name = cms_info.get('bankAccountDetails', {}).get('bankName', '') | 1881 | bank_name = cms_info.get('bankAccountDetails', {}).get('bankName', '') |
1693 | account_no = decode_des(cms_info.get('bankAccountDetails', {}).get('accountNo', ''), des_key) | 1882 | account_no = aes_decrypt_cbc(cms_info.get('bankAccountDetails', {}).get('accountNo', ''), des_key, des_iv) |
1694 | account_holder_name = cms_info.get('bankAccountDetails', {}).get('accountHolderName', '') | 1883 | account_holder_name = cms_info.get('bankAccountDetails', {}).get('accountHolderName', '') |
1695 | is_gsyh = True if '工商' in bank_name else False | 1884 | is_gsyh = True if '工商' in bank_name else False |
1696 | 1885 | ||
1697 | if isinstance(company_info, tuple) and company_info[0] == account_holder_name: | 1886 | # CHINARPA-4942 去掉注释逻辑,改为只要not ignore_bank 银行卡都要校验,不论是否公户 |
1698 | pass | 1887 | # if isinstance(company_info, tuple) and company_info[0] == account_holder_name: |
1699 | elif not ignore_bank: | 1888 | # pass |
1889 | # el | ||
1890 | if not ignore_bank: | ||
1700 | bank_field_input = [ | 1891 | bank_field_input = [ |
1701 | ('accountNo', account_no), | 1892 | ('accountNo', account_no), |
1702 | ('bankName', bank_name), | 1893 | ('bankName', bank_name), |
... | @@ -1721,9 +1912,11 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect | ... | @@ -1721,9 +1912,11 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect |
1721 | compare_info['bankInfo'] = bank_info | 1912 | compare_info['bankInfo'] = bank_info |
1722 | 1913 | ||
1723 | # 银行流水 -------------------------------------------------------------------- | 1914 | # 银行流水 -------------------------------------------------------------------- |
1915 | #增加 allow_bs_type 默认值,防止不需要比对流水的申请报错 | ||
1916 | allow_bs_type = '全部' | ||
1724 | if cms_info.get('autoApprovedDetails', {}).get('aaType', '') in ['CAA1', 'CAA2'] and \ | 1917 | if cms_info.get('autoApprovedDetails', {}).get('aaType', '') in ['CAA1', 'CAA2'] and \ |
1725 | '无需提供银行流水' not in cms_info.get('autoApprovedDetails', {}).get('PolicyComments', ''): | 1918 | '无需提供银行流水' not in cms_info.get('autoApprovedDetails', {}).get('PolicyComments', ''): |
1726 | date_timedelta = 60 if auto else 90 | 1919 | date_timedelta = 83 if auto else 83 |
1727 | bs_role_list = [] | 1920 | bs_role_list = [] |
1728 | for applicant_type in consts.APPLICANT_TYPE_ORDER[:2]: | 1921 | for applicant_type in consts.APPLICANT_TYPE_ORDER[:2]: |
1729 | if applicant_type in main_role_info: | 1922 | if applicant_type in main_role_info: |
... | @@ -1737,6 +1930,14 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect | ... | @@ -1737,6 +1930,14 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect |
1737 | (consts.SE_BS_FIELD[2], date_timedelta), | 1930 | (consts.SE_BS_FIELD[2], date_timedelta), |
1738 | ] | 1931 | ] |
1739 | 1932 | ||
1933 | #在比对逻辑中添加字段 | ||
1934 | if '仅接受银行流水' in cms_info.get('autoApprovedDetails', {}).get('PolicyComments', ''): | ||
1935 | #bs_field_input.append((consts.SE_BS_FIELD[9], '仅接受银行流水')) | ||
1936 | allow_bs_type = '仅接受银行流水' | ||
1937 | else: | ||
1938 | #bs_field_input.append((consts.SE_BS_FIELD[9], '全部')) | ||
1939 | allow_bs_type = '全部' | ||
1940 | |||
1740 | dbr_bs_role_list = [] | 1941 | dbr_bs_role_list = [] |
1741 | for dbr_bs_role, _, _ in main_role_info.get(consts.APPLICANT_TYPE_ORDER[2], []): | 1942 | for dbr_bs_role, _, _ in main_role_info.get(consts.APPLICANT_TYPE_ORDER[2], []): |
1742 | dbr_bs_role_list.append(dbr_bs_role) | 1943 | dbr_bs_role_list.append(dbr_bs_role) |
... | @@ -1837,13 +2038,13 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect | ... | @@ -1837,13 +2038,13 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect |
1837 | (consts.SE_BD_FIELD[0], [co_name, bo_name] if is_cdfl else [main_name, ]), # 车贷分离 | 2038 | (consts.SE_BD_FIELD[0], [co_name, bo_name] if is_cdfl else [main_name, ]), # 车贷分离 |
1838 | (consts.SE_BD_FIELD[1], [co_id, bo_id] if is_cdfl else [main_id, ]), # 车贷分离 | 2039 | (consts.SE_BD_FIELD[1], [co_id, bo_id] if is_cdfl else [main_id, ]), # 车贷分离 |
1839 | (consts.SE_BD_FIELD[2], vin_no), | 2040 | (consts.SE_BD_FIELD[2], vin_no), |
1840 | (consts.SE_BD_FIELD[3], ssx_amount), | 2041 | # (consts.SE_BD_FIELD[3], ssx_amount), |
1841 | (consts.SE_BD_FIELD[4], dszx_amount), | 2042 | # (consts.SE_BD_FIELD[4], dszx_amount), |
1842 | (consts.SE_BD_FIELD[5], consts.JDMPV_VALUE), | 2043 | # (consts.SE_BD_FIELD[5], consts.JDMPV_VALUE), |
1843 | (consts.SE_BD_FIELD[6], cms_info.get('insuranceDetails', {}).get('startDate', '')), | 2044 | (consts.SE_BD_FIELD[6], cms_info.get('insuranceDetails', {}).get('startDate', '')), |
1844 | (consts.SE_BD_FIELD[7], cms_info.get('insuranceDetails', {}).get('endDate', '')), | 2045 | (consts.SE_BD_FIELD[7], cms_info.get('insuranceDetails', {}).get('endDate', '')), |
1845 | (consts.SE_BD_FIELD[8], consts.SE_STAMP_VALUE), | 2046 | (consts.SE_BD_FIELD[8], consts.SE_STAMP_VALUE), |
1846 | (consts.SE_BD_FIELD[9], consts.SE_DYSYR_VALUE), | 2047 | # (consts.SE_BD_FIELD[9], consts.SE_DYSYR_VALUE), |
1847 | ] | 2048 | ] |
1848 | if is_insurance == 1: | 2049 | if is_insurance == 1: |
1849 | bd_field_input.append((consts.SE_BD_FIELD[10], insurance_price)) | 2050 | bd_field_input.append((consts.SE_BD_FIELD[10], insurance_price)) |
... | @@ -1905,7 +2106,10 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect | ... | @@ -1905,7 +2106,10 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect |
1905 | if len(main_role_info[app_type]) >= id_idx+1: | 2106 | if len(main_role_info[app_type]) >= id_idx+1: |
1906 | is_find = True | 2107 | is_find = True |
1907 | if isinstance(field_idx, int): | 2108 | if isinstance(field_idx, int): |
1908 | hil_contract_1_input.append((key, main_role_info[app_type][id_idx][field_idx])) | 2109 | if key == '承租人签字' and is_bo_corporate: |
2110 | hil_contract_1_input.append((key, legal_name)) | ||
2111 | else: | ||
2112 | hil_contract_1_input.append((key, main_role_info[app_type][id_idx][field_idx])) | ||
1909 | else: | 2113 | else: |
1910 | hil_contract_1_input.append((key, field_idx)) | 2114 | hil_contract_1_input.append((key, field_idx)) |
1911 | if not is_find and is_force: | 2115 | if not is_find and is_force: |
... | @@ -1924,7 +2128,10 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect | ... | @@ -1924,7 +2128,10 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect |
1924 | (consts.SE_HIL_CON_3_FIELD[6], main_id), | 2128 | (consts.SE_HIL_CON_3_FIELD[6], main_id), |
1925 | ] | 2129 | ] |
1926 | if online_sign: | 2130 | if online_sign: |
1927 | hil_contract_3_input.append((consts.SE_HIL_CON_3_FIELD[7], main_name)) | 2131 | if is_bo_corporate: |
2132 | hil_contract_3_input.append((consts.SE_HIL_CON_3_FIELD[7], legal_name)) | ||
2133 | else: | ||
2134 | hil_contract_3_input.append((consts.SE_HIL_CON_3_FIELD[7], main_name)) | ||
1928 | contract_info[consts.HIL_CONTRACT_3_EN] = hil_contract_3_input | 2135 | contract_info[consts.HIL_CONTRACT_3_EN] = hil_contract_3_input |
1929 | 2136 | ||
1930 | # HIL合同 车辆租赁抵押合同 -------------------------------------------------------------------------------------- | 2137 | # HIL合同 车辆租赁抵押合同 -------------------------------------------------------------------------------------- |
... | @@ -1947,14 +2154,17 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect | ... | @@ -1947,14 +2154,17 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect |
1947 | if len(main_role_info[app_type]) >= id_idx+1: | 2154 | if len(main_role_info[app_type]) >= id_idx+1: |
1948 | is_find = True | 2155 | is_find = True |
1949 | if isinstance(field_idx, int): | 2156 | if isinstance(field_idx, int): |
1950 | hil_contract_2_input.append((key, main_role_info[app_type][id_idx][field_idx])) | 2157 | if key == '抵押人签字' and is_bo_corporate: |
2158 | hil_contract_2_input.append((key, legal_name)) | ||
2159 | else: | ||
2160 | hil_contract_2_input.append((key, main_role_info[app_type][id_idx][field_idx])) | ||
1951 | else: | 2161 | else: |
1952 | hil_contract_2_input.append((key, field_idx)) | 2162 | hil_contract_2_input.append((key, field_idx)) |
1953 | if not is_find and is_force: | 2163 | if not is_find and is_force: |
1954 | hil_contract_2_input.append((key, empty_str)) | 2164 | hil_contract_2_input.append((key, empty_str)) |
1955 | contract_info[consts.HIL_CONTRACT_2_EN] = hil_contract_2_input | 2165 | contract_info[consts.HIL_CONTRACT_2_EN] = hil_contract_2_input |
1956 | compare_info['contract'] = contract_info | 2166 | compare_info['contract'] = contract_info |
1957 | return compare_info, cms_info.get('applicationVersion', 1), cms_info.get('autoApprovedDetails', {}).get('aaType', ''), is_gsyh | 2167 | return compare_info, cms_info.get('applicationVersion', 1), cms_info.get('autoApprovedDetails', {}).get('aaType', ''), is_gsyh, allow_bs_type |
1958 | else: | 2168 | else: |
1959 | # AFC合同------------------------------------------------------------------------------------------------------ | 2169 | # AFC合同------------------------------------------------------------------------------------------------------ |
1960 | vehicle_principal_str = str(cms_info.get('financialInformation', {}).get('vehiclePrincipal', '0.0')) | 2170 | vehicle_principal_str = str(cms_info.get('financialInformation', {}).get('vehiclePrincipal', '0.0')) |
... | @@ -2014,7 +2224,10 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect | ... | @@ -2014,7 +2224,10 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect |
2014 | if len(main_role_info[app_type]) >= id_idx+1: | 2224 | if len(main_role_info[app_type]) >= id_idx+1: |
2015 | is_find = True | 2225 | is_find = True |
2016 | if isinstance(field_idx, int): | 2226 | if isinstance(field_idx, int): |
2017 | afc_contract_input.append((key, main_role_info[app_type][id_idx][field_idx])) | 2227 | if (key == '借款人签字及时间' or key == '主借人签字') and is_bo_corporate: |
2228 | afc_contract_input.append((key, legal_name)) | ||
2229 | else: | ||
2230 | afc_contract_input.append((key, main_role_info[app_type][id_idx][field_idx])) | ||
2018 | else: | 2231 | else: |
2019 | afc_contract_input.append((key, field_idx)) | 2232 | afc_contract_input.append((key, field_idx)) |
2020 | if not is_find and is_force: | 2233 | if not is_find and is_force: |
... | @@ -2029,10 +2242,24 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect | ... | @@ -2029,10 +2242,24 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect |
2029 | afc_contract_qrs_input = [(consts.SE_AFC_CON_QRS_FIELD[0], '{0}{1}{2}'.format(role_count, consts.SPLIT_STR, full_no))] | 2242 | afc_contract_qrs_input = [(consts.SE_AFC_CON_QRS_FIELD[0], '{0}{1}{2}'.format(role_count, consts.SPLIT_STR, full_no))] |
2030 | contract_info[consts.AFC_CONTRACT_QRS_EN] = afc_contract_qrs_input | 2243 | contract_info[consts.AFC_CONTRACT_QRS_EN] = afc_contract_qrs_input |
2031 | compare_info['contract'] = contract_info | 2244 | compare_info['contract'] = contract_info |
2032 | return compare_info, cms_info.get('applicationVersion', 1), cms_info.get('autoApprovedDetails', {}).get('aaType', ''), is_gsyh | ||
2033 | 2245 | ||
2034 | 2246 | # 首付款承诺书 | |
2035 | def se_bs_compare(license_en, ocr_res_dict, strip_list, is_auto, aa_type): | 2247 | down_payment_info = {} |
2248 | down_payment_input = [] | ||
2249 | totalDownPayment = str(cms_info.get('financialInformation', {}).get('totalDownPayment')) | ||
2250 | if totalDownPayment and totalDownPayment != '0.00': | ||
2251 | down_payment_input.append((consts.SE_DP_FIELD[0], cms_info.get('financeCompany', ''))) | ||
2252 | down_payment_input.append((consts.SE_DP_FIELD[1], borrower_name)) | ||
2253 | down_payment_input.append((consts.SE_DP_FIELD[2], borrower_idnum)) | ||
2254 | down_payment_input.append((consts.SE_DP_FIELD[3], cms_info.get('settlemnetVerification', {}).get('applicationNo', ''))) | ||
2255 | down_payment_input.append((consts.SE_DP_FIELD[4], legal_name if is_bo_corporate else borrower_name )) | ||
2256 | down_payment_input.append((consts.SE_DP_FIELD[5], '有/无')) | ||
2257 | down_payment_info[consts.DP_EN] = down_payment_input | ||
2258 | compare_info['downPayment'] = down_payment_info | ||
2259 | return compare_info, cms_info.get('applicationVersion', 1), cms_info.get('autoApprovedDetails', {}).get('aaType', ''), is_gsyh, allow_bs_type | ||
2260 | |||
2261 | |||
2262 | def se_bs_compare(license_en, ocr_res_dict, strip_list, is_auto, aa_type, allow_bs_type): | ||
2036 | # 主共借至少提供一个 | 2263 | # 主共借至少提供一个 |
2037 | # 有担保人,担保人必须提供。主共借没有时,修改comment:人工查看担保人亲属关系 | 2264 | # 有担保人,担保人必须提供。主共借没有时,修改comment:人工查看担保人亲属关系 |
2038 | 2265 | ||
... | @@ -2046,6 +2273,7 @@ def se_bs_compare(license_en, ocr_res_dict, strip_list, is_auto, aa_type): | ... | @@ -2046,6 +2273,7 @@ def se_bs_compare(license_en, ocr_res_dict, strip_list, is_auto, aa_type): |
2046 | field_img_path_dict = dict() | 2273 | field_img_path_dict = dict() |
2047 | 2274 | ||
2048 | if ocr_res_str is not None: | 2275 | if ocr_res_str is not None: |
2276 | # 字段在比对逻辑中添加的,这个地方不用改,如果要是在get_info时添加,要改这个 | ||
2049 | pre_field_list = strip_list[:3] | 2277 | pre_field_list = strip_list[:3] |
2050 | dbr1_field_list = strip_list[3:6] | 2278 | dbr1_field_list = strip_list[3:6] |
2051 | dbr2_field_list = strip_list[6:] | 2279 | dbr2_field_list = strip_list[6:] |
... | @@ -2062,13 +2290,21 @@ def se_bs_compare(license_en, ocr_res_dict, strip_list, is_auto, aa_type): | ... | @@ -2062,13 +2290,21 @@ def se_bs_compare(license_en, ocr_res_dict, strip_list, is_auto, aa_type): |
2062 | auto_paper_verify_list = [] | 2290 | auto_paper_verify_list = [] |
2063 | auto_elec_verify_list = [] | 2291 | auto_elec_verify_list = [] |
2064 | auto_paper_verify_false_idx_list = [] | 2292 | auto_paper_verify_false_idx_list = [] |
2293 | auto_paper_verify_true_idx_list = [] | ||
2065 | auto_elec_verify_false_idx_list = [] | 2294 | auto_elec_verify_false_idx_list = [] |
2066 | 2295 | ||
2296 | all_zhifubao_weixin = True | ||
2297 | |||
2067 | for tmp_idx, ocr_res in enumerate(ocr_res_list): | 2298 | for tmp_idx, ocr_res in enumerate(ocr_res_list): |
2068 | correct_count = 0 | 2299 | correct_count = 0 |
2069 | pre_tmp_res_part = {} | 2300 | pre_tmp_res_part = {} |
2070 | verify_bool = ocr_res.get('verify', False) | 2301 | verify_bool = ocr_res.get('verify', False) |
2071 | e_bank = ocr_res.get('e_bank', False) | 2302 | e_bank = ocr_res.get('e_bank', False) |
2303 | bankStatement_type = ocr_res.get('bankStatement_type', '') | ||
2304 | # 如果是高风险经销商,cms信息中包含‘仅接受银行流水’,但是识别出的流水是支付宝/微信,直接跳过这个文件,就当不存在 | ||
2305 | if allow_bs_type == '仅接受银行流水' and bankStatement_type in ['12', '13', '48']: | ||
2306 | continue | ||
2307 | all_zhifubao_weixin = False | ||
2072 | #verify_list.append(verify_bool) | 2308 | #verify_list.append(verify_bool) |
2073 | if not verify_bool: | 2309 | if not verify_bool: |
2074 | verify_false_idx_list.append(str(tmp_idx+1)) | 2310 | verify_false_idx_list.append(str(tmp_idx+1)) |
... | @@ -2079,8 +2315,11 @@ def se_bs_compare(license_en, ocr_res_dict, strip_list, is_auto, aa_type): | ... | @@ -2079,8 +2315,11 @@ def se_bs_compare(license_en, ocr_res_dict, strip_list, is_auto, aa_type): |
2079 | auto_elec_verify_false_idx_list.append(str(tmp_idx+1)) | 2315 | auto_elec_verify_false_idx_list.append(str(tmp_idx+1)) |
2080 | else: | 2316 | else: |
2081 | auto_paper_verify_list.append(verify_bool) | 2317 | auto_paper_verify_list.append(verify_bool) |
2082 | verify_list.append(False) | 2318 | verify_list.append(verify_bool) |
2083 | auto_paper_verify_false_idx_list.append(str(tmp_idx+1)) | 2319 | if not verify_bool: |
2320 | auto_paper_verify_false_idx_list.append(str(tmp_idx+1)) | ||
2321 | else: | ||
2322 | auto_paper_verify_true_idx_list.append(str(tmp_idx+1)) | ||
2084 | 2323 | ||
2085 | for idx, (name, value) in enumerate(pre_field_list): | 2324 | for idx, (name, value) in enumerate(pre_field_list): |
2086 | ocr_str_or_list = ocr_res.get(compare_logic[name][0]) | 2325 | ocr_str_or_list = ocr_res.get(compare_logic[name][0]) |
... | @@ -2117,47 +2356,100 @@ def se_bs_compare(license_en, ocr_res_dict, strip_list, is_auto, aa_type): | ... | @@ -2117,47 +2356,100 @@ def se_bs_compare(license_en, ocr_res_dict, strip_list, is_auto, aa_type): |
2117 | 2356 | ||
2118 | # 非FSM Full CAA1 | 2357 | # 非FSM Full CAA1 |
2119 | # 2023.12 auto CAA1 也使用此逻辑(之前非FSM auto CAA1不判断真伪) | 2358 | # 2023.12 auto CAA1 也使用此逻辑(之前非FSM auto CAA1不判断真伪) |
2120 | if aa_type == 'CAA1': | 2359 | # ---------- 以下 CHINARPA-5153 作废 |
2360 | # if aa_type == 'CAA1': | ||
2361 | # name = '真伪' | ||
2362 | # # 若仅提供纸质流水,则默认真伪为N2 | ||
2363 | # if not auto_elec_verify_list: | ||
2364 | # result = consts.RESULT_N2 | ||
2365 | # reason = '<关注>第{0}份流水为纸质版,请核查流水真伪。'.format('、'.join(auto_paper_verify_false_idx_list)) | ||
2366 | # # 若仅提供电子流水,逐一比对,有false为N1,全部true为Y | ||
2367 | # if not auto_paper_verify_list: | ||
2368 | # result = consts.RESULT_Y if all(auto_elec_verify_list) else consts.RESULT_N1 | ||
2369 | # reason = '<关注>第{0}份电子流水疑似造假,请核查excel。'.format('、'.join(auto_elec_verify_false_idx_list)) | ||
2370 | # #同时包含,同时返回N1,N2 | ||
2371 | # if auto_elec_verify_list and auto_paper_verify_list: | ||
2372 | # result = consts.RESULT_Y if all(auto_elec_verify_list) else consts.RESULT_N1 | ||
2373 | # reason1 = '<关注>第{0}份电子流水疑似造假,请核查excel。'.format('、'.join(auto_elec_verify_false_idx_list)) | ||
2374 | # reason2 = '<关注>第{0}份流水为纸质版,请核查流水真伪。'.format('、'.join(auto_paper_verify_false_idx_list)) | ||
2375 | # reason = reason1 + '\n' + reason2 | ||
2376 | # result_field_list.append((name, empty_str, result, json.dumps(verify_list, ensure_ascii=False), empty_str, empty_error_type, reason)) | ||
2377 | # # 非FSM Full & Auto CAA2 目前逻辑和上面的完全一样 | ||
2378 | # elif aa_type == 'CAA2' : | ||
2379 | # name = '真伪' | ||
2380 | # # 若仅提供纸质流水,则默认真伪为N2 | ||
2381 | # if not auto_elec_verify_list: | ||
2382 | # result = consts.RESULT_N2 | ||
2383 | # reason = '<关注>第{0}份流水为纸质版,请核查流水真伪。'.format('、'.join(auto_paper_verify_false_idx_list)) | ||
2384 | # # 若仅提供电子流水,逐一比对,有false为N1,全部true为Y | ||
2385 | # if not auto_paper_verify_list: | ||
2386 | # result = consts.RESULT_Y if all(auto_elec_verify_list) else consts.RESULT_N1 | ||
2387 | # reason = '<关注>第{0}份电子流水疑似造假,请核查excel。'.format('、'.join(auto_elec_verify_false_idx_list)) | ||
2388 | # #同时包含,同时返回N1,N2 | ||
2389 | # if auto_elec_verify_list and auto_paper_verify_list: | ||
2390 | # result = consts.RESULT_Y if all(auto_elec_verify_list) else consts.RESULT_N1 | ||
2391 | # reason1 = '<关注>第{0}份电子流水疑似造假,请核查excel。'.format('、'.join(auto_elec_verify_false_idx_list)) | ||
2392 | # reason2 = '<关注>第{0}份流水为纸质版,请核查流水真伪。'.format('、'.join(auto_paper_verify_false_idx_list)) | ||
2393 | # reason = reason1 + '\n' + reason2 | ||
2394 | # result_field_list.append((name, empty_str, result, json.dumps(verify_list, ensure_ascii=False), empty_str, empty_error_type, reason)) | ||
2395 | # ---------- 以上 CHINARPA-5153 作废 | ||
2396 | # 【具体分支描述可以看java代码】 | ||
2397 | if aa_type == 'CAA1' or aa_type == 'CAA2': | ||
2121 | name = '真伪' | 2398 | name = '真伪' |
2122 | # 若仅提供纸质流水,则默认真伪为N2 | 2399 | reason_n1 = '<关注>第{0}份电子流水疑似造假,请核查excel。'.format('、'.join(auto_elec_verify_false_idx_list)) |
2123 | if not auto_elec_verify_list: | 2400 | reason_n2 = '<关注>第{0}份流水为纸质版,请核查流水真伪。'.format('、'.join(auto_paper_verify_true_idx_list)) |
2124 | result = consts.RESULT_N2 | 2401 | reason_n3 = '<关注>第{0}份纸质流水疑似造假,请核查excel。'.format('、'.join(auto_paper_verify_false_idx_list)) |
2125 | reason = '第{0}份银行流水为纸质版,请核查流水真伪。'.format('、'.join(auto_paper_verify_false_idx_list)) | 2402 | |
2126 | # 若仅提供电子流水,逐一比对,有false为N1,全部true为Y | ||
2127 | if not auto_paper_verify_list: | ||
2128 | result = consts.RESULT_Y if all(auto_elec_verify_list) else consts.RESULT_N1 | ||
2129 | reason = '第{0}份银行流水疑似造假,需人工核查。'.format('、'.join(auto_elec_verify_false_idx_list)) | ||
2130 | #同时包含,同时返回N1,N2 | ||
2131 | if auto_elec_verify_list and auto_paper_verify_list: | 2403 | if auto_elec_verify_list and auto_paper_verify_list: |
2132 | result = consts.RESULT_Y if all(auto_elec_verify_list) else consts.RESULT_N1 | 2404 | # 有电子流水,有纸质流水,则需逐一判断电子流水属性或纸质流水检测结果 |
2133 | reason1 = '第{0}份银行流水疑似造假,需人工核查。'.format('、'.join(auto_elec_verify_false_idx_list)) | 2405 | elecTrue = len(auto_elec_verify_false_idx_list) <= 0 |
2134 | reason2 = '第{0}份银行流水为纸质版,请核查流水真伪。'.format('、'.join(auto_paper_verify_false_idx_list)) | 2406 | paperTrue = len(auto_paper_verify_false_idx_list) <= 0 |
2135 | reason = reason1 + reason2 | 2407 | paperNotClear = len(auto_paper_verify_true_idx_list) > 0 |
2136 | result_field_list.append((name, empty_str, result, json.dumps(verify_list, ensure_ascii=False), empty_str, empty_error_type, reason)) | 2408 | if not elecTrue and not paperTrue and paperNotClear: |
2137 | # 非FSM Full & Auto CAA2 目前逻辑和上面的完全一样 | 2409 | reason = reason_n1 + '\n' + reason_n2 + '\n' + reason_n3 |
2138 | elif aa_type == 'CAA2' : | 2410 | elif not elecTrue and not paperTrue: |
2139 | name = '真伪' | 2411 | reason = reason_n1 + '\n' + reason_n3 |
2140 | # 若仅提供纸质流水,则默认真伪为N2 | 2412 | elif not elecTrue and paperNotClear: |
2141 | if not auto_elec_verify_list: | 2413 | reason = reason_n1 + '\n' + reason_n2 |
2142 | result = consts.RESULT_N2 | 2414 | elif elecTrue and not paperTrue and paperNotClear: |
2143 | reason = '第{0}份银行流水为纸质版,请核查流水真伪。'.format('、'.join(auto_paper_verify_false_idx_list)) | 2415 | reason = reason_n2 + '\n' + reason_n3 |
2144 | # 若仅提供电子流水,逐一比对,有false为N1,全部true为Y | 2416 | elif elecTrue and paperNotClear: |
2145 | if not auto_paper_verify_list: | 2417 | reason = reason_n2 |
2146 | result = consts.RESULT_Y if all(auto_elec_verify_list) else consts.RESULT_N1 | 2418 | elif elecTrue and not paperTrue: |
2147 | reason = '第{0}份银行流水疑似造假,需人工核查。'.format('、'.join(auto_elec_verify_false_idx_list)) | 2419 | reason = reason_n3 |
2148 | #同时包含,同时返回N1,N2 | 2420 | result = consts.RESULT_Y if elecTrue and paperTrue and not paperNotClear else consts.RESULT_N |
2149 | if auto_elec_verify_list and auto_paper_verify_list: | 2421 | elif auto_elec_verify_list and not auto_paper_verify_list: |
2150 | result = consts.RESULT_Y if all(auto_elec_verify_list) else consts.RESULT_N1 | 2422 | # 只有电子流水,以电子为准 |
2151 | reason1 = '第{0}份银行流水疑似造假,需人工核查。'.format('、'.join(auto_elec_verify_false_idx_list)) | 2423 | reason = reason_n1 |
2152 | reason2 = '第{0}份银行流水为纸质版,请核查流水真伪。'.format('、'.join(auto_paper_verify_false_idx_list)) | 2424 | result = consts.RESULT_Y if all(auto_elec_verify_list) else consts.RESULT_N |
2153 | reason = reason1 + reason2 | 2425 | elif not auto_elec_verify_list: |
2426 | paperTrue = len(auto_paper_verify_false_idx_list) <= 0 | ||
2427 | paperNotClear = len(auto_paper_verify_true_idx_list) > 0 | ||
2428 | if not paperTrue and paperNotClear: | ||
2429 | reason = reason_n2 + '\n' + reason_n3 | ||
2430 | elif paperNotClear: | ||
2431 | reason = reason_n2 | ||
2432 | elif not paperTrue: | ||
2433 | reason = reason_n3 | ||
2434 | result = consts.RESULT_N | ||
2154 | result_field_list.append((name, empty_str, result, json.dumps(verify_list, ensure_ascii=False), empty_str, empty_error_type, reason)) | 2435 | result_field_list.append((name, empty_str, result, json.dumps(verify_list, ensure_ascii=False), empty_str, empty_error_type, reason)) |
2155 | 2436 | ||
2437 | if all_zhifubao_weixin: | ||
2438 | # 核查点名称,cms传值,比对结果,ocr结果,图片路径,错误类型,错误描述 | ||
2439 | result_field_list.append(('类型', allow_bs_type, consts.RESULT_N, '全部为支付宝/微信', empty_str, ErrorType.NF.value, '高风险经销商流水类型异常')) | ||
2440 | else: | ||
2441 | result_field_list.append(('类型', allow_bs_type, consts.RESULT_Y, '包含支持的流水类型', empty_str, empty_error_type, '')) | ||
2442 | |||
2156 | # 担保人1 | 2443 | # 担保人1 |
2157 | dbr1_best_res = {} | 2444 | dbr1_best_res = {} |
2158 | if len(dbr1_field_list) > 0: | 2445 | if len(dbr1_field_list) > 0: |
2159 | max_correct_count = 0 | 2446 | max_correct_count = 0 |
2160 | for ocr_res in ocr_res_list: | 2447 | for ocr_res in ocr_res_list: |
2448 | bankStatement_type = ocr_res.get('bankStatement_type', '') | ||
2449 | # 如果是高风险经销商,cms信息中包含‘仅接受银行流水’,但是识别出的流水是支付宝/微信,直接跳过这个文件,就当不存在 | ||
2450 | if allow_bs_type == '仅接受银行流水' and bankStatement_type in ['12', '13', '48']: | ||
2451 | continue | ||
2452 | |||
2161 | correct_count = 0 | 2453 | correct_count = 0 |
2162 | dbr1_tmp_res_part = {} | 2454 | dbr1_tmp_res_part = {} |
2163 | for idx, (name, value) in enumerate(dbr1_field_list): | 2455 | for idx, (name, value) in enumerate(dbr1_field_list): |
... | @@ -2190,6 +2482,10 @@ def se_bs_compare(license_en, ocr_res_dict, strip_list, is_auto, aa_type): | ... | @@ -2190,6 +2482,10 @@ def se_bs_compare(license_en, ocr_res_dict, strip_list, is_auto, aa_type): |
2190 | if len(dbr1_field_list) > 0: | 2482 | if len(dbr1_field_list) > 0: |
2191 | max_correct_count = 0 | 2483 | max_correct_count = 0 |
2192 | for ocr_res in ocr_res_list: | 2484 | for ocr_res in ocr_res_list: |
2485 | bankStatement_type = ocr_res.get('bankStatement_type', '') | ||
2486 | # 如果是高风险经销商,cms信息中包含‘仅接受银行流水’,但是识别出的流水是支付宝/微信,直接跳过这个文件,就当不存在 | ||
2487 | if allow_bs_type == '仅接受银行流水' and bankStatement_type in ['12', '13', '48']: | ||
2488 | continue | ||
2193 | correct_count = 0 | 2489 | correct_count = 0 |
2194 | dbr2_tmp_res_part = {} | 2490 | dbr2_tmp_res_part = {} |
2195 | for idx, (name, value) in enumerate(dbr2_field_list): | 2491 | for idx, (name, value) in enumerate(dbr2_field_list): |
... | @@ -2302,7 +2598,7 @@ def se_bs_compare(license_en, ocr_res_dict, strip_list, is_auto, aa_type): | ... | @@ -2302,7 +2598,7 @@ def se_bs_compare(license_en, ocr_res_dict, strip_list, is_auto, aa_type): |
2302 | return result_field_list, field_img_path_dict | 2598 | return result_field_list, field_img_path_dict |
2303 | 2599 | ||
2304 | 2600 | ||
2305 | def se_compare_license(license_en, ocr_res_dict, field_list): | 2601 | def se_compare_license(license_en, ocr_res_dict, field_list, is_auto): |
2306 | ocr_field, compare_logic, special_expiry_date = consts.SE_COMPARE_FIELD[license_en] | 2602 | ocr_field, compare_logic, special_expiry_date = consts.SE_COMPARE_FIELD[license_en] |
2307 | 2603 | ||
2308 | is_find = False | 2604 | is_find = False |
... | @@ -2312,6 +2608,7 @@ def se_compare_license(license_en, ocr_res_dict, field_list): | ... | @@ -2312,6 +2608,7 @@ def se_compare_license(license_en, ocr_res_dict, field_list): |
2312 | section_img_info = dict() | 2608 | section_img_info = dict() |
2313 | field_img_path_dict = dict() | 2609 | field_img_path_dict = dict() |
2314 | ocr_res_str = ocr_res_dict.get(ocr_field) | 2610 | ocr_res_str = ocr_res_dict.get(ocr_field) |
2611 | compare_log.info('{0} [{1}_compare] ocr_res:{2}'.format(log_base, license_en, ocr_res_str)) | ||
2315 | if ocr_res_str is not None: | 2612 | if ocr_res_str is not None: |
2316 | ocr_res_list = json.loads(ocr_res_str) | 2613 | ocr_res_list = json.loads(ocr_res_str) |
2317 | 2614 | ||
... | @@ -2356,16 +2653,30 @@ def se_compare_license(license_en, ocr_res_dict, field_list): | ... | @@ -2356,16 +2653,30 @@ def se_compare_license(license_en, ocr_res_dict, field_list): |
2356 | ocr_res_list[res_idx].get(consts.LOWER_AMOUNT_FIELD, ''), | 2653 | ocr_res_list[res_idx].get(consts.LOWER_AMOUNT_FIELD, ''), |
2357 | ocr_res_list[res_idx].get(consts.UPPER_AMOUNT_FIELD, ''), | 2654 | ocr_res_list[res_idx].get(consts.UPPER_AMOUNT_FIELD, ''), |
2358 | ) | 2655 | ) |
2656 | # auto 保单 保险费合计 ocr结果需要加上一个基数,再与cms结果做比对 | ||
2657 | elif is_auto and ocr_field == consts.BD_FIELD and name == consts.SE_BD_FIELD[10]: | ||
2658 | ocr_str = ocr_res_list[res_idx].get(compare_logic[name][0]) | ||
2659 | compare_log.info('{0} [bd_4962_price] [ori ocr_str:{1}] '.format(log_base, ocr_str)) | ||
2660 | add_price = conf.BD_PRICE | ||
2661 | compare_log.info('{0} [bd_4962_price] [add_price:{1}] '.format(log_base, add_price)) | ||
2662 | ocr_str = str(float(ocr_str) + float(add_price)) | ||
2663 | compare_log.info('{0} [bd_4962_price] [final ocr_str:{1}] '.format(log_base, ocr_str)) | ||
2359 | else: | 2664 | else: |
2360 | ocr_str = ocr_res_list[res_idx].get(compare_logic[name][0]) | 2665 | ocr_str = ocr_res_list[res_idx].get(compare_logic[name][0]) |
2361 | 2666 | ||
2362 | if isinstance(ocr_str, str): | 2667 | if isinstance(ocr_str, str): |
2363 | result = getattr(cp, compare_logic[name][1])(value, ocr_str, **compare_logic[name][2]) | 2668 | result = getattr(cp, compare_logic[name][1])(value, ocr_str, **compare_logic[name][2]) |
2669 | compare_log.info('{0} [{1}_license] [field:{2}] [input_str:{3}] [ocr_str:{4}] [result:{5}]'.format(log_base, license_en, name, value, ocr_str, result)) | ||
2364 | no_key = False | 2670 | no_key = False |
2365 | # 二手车交易凭证 日期 | 2671 | # 二手车交易凭证 日期 |
2366 | elif ocr_field == consts.JYPZ_OCR_FIELD and name == consts.SE_GB_USED_FIELD[2]: | 2672 | elif ocr_field == consts.JYPZ_OCR_FIELD and name == consts.SE_GB_USED_FIELD[2]: |
2367 | result = getattr(cp, compare_logic[name][1])(value, ocr_str, **compare_logic[name][2]) | 2673 | result = getattr(cp, compare_logic[name][1])(value, ocr_str, **compare_logic[name][2]) |
2368 | no_key = False | 2674 | no_key = False |
2675 | elif isinstance(ocr_str, int): | ||
2676 | # 目前应该只有财报的公章 | ||
2677 | result = getattr(cp, compare_logic[name][1])(value, ocr_str, **compare_logic[name][2]) | ||
2678 | compare_log.info('{0} [{1}_license] [field:{2}] [input_str:{3}] [ocr_str:{4}] [result:{5}]'.format(log_base, license_en, name, value, ocr_str, result)) | ||
2679 | no_key = False | ||
2369 | else: | 2680 | else: |
2370 | result = consts.RESULT_N | 2681 | result = consts.RESULT_N |
2371 | ocr_str = empty_str | 2682 | ocr_str = empty_str |
... | @@ -2489,6 +2800,113 @@ def se_compare_license(license_en, ocr_res_dict, field_list): | ... | @@ -2489,6 +2800,113 @@ def se_compare_license(license_en, ocr_res_dict, field_list): |
2489 | 2800 | ||
2490 | return result_field_list, no_ocr_result, field_img_path_dict | 2801 | return result_field_list, no_ocr_result, field_img_path_dict |
2491 | 2802 | ||
2803 | def se_fs_compare(license_en, ocr_res_dict, field_list): | ||
2804 | compare_log.info('{0} [se_fs_compare] start'.format(log_base)) | ||
2805 | ocr_field, compare_logic, special_expiry_date = consts.SE_COMPARE_FIELD[license_en] | ||
2806 | |||
2807 | is_find = False | ||
2808 | no_ocr_result = False | ||
2809 | special_expiry_date_slice = False | ||
2810 | result_field_list = [] | ||
2811 | section_img_info = dict() | ||
2812 | field_img_path_dict = dict() | ||
2813 | ocr_res_str = ocr_res_dict.get(ocr_field) | ||
2814 | compare_log.info('{0} [se_fs_compare] ocr_res:{1}'.format(log_base, ocr_res_str)) | ||
2815 | if ocr_res_str is not None: | ||
2816 | ocr_res_list = json.loads(ocr_res_str) | ||
2817 | |||
2818 | length = len(ocr_res_list) | ||
2819 | |||
2820 | last_ocr_str = ocr_res_list[length-1] | ||
2821 | compare_log.info('{0} [se_fs_compare] [code len {1}] [stamp len {2}] ]'.format(log_base, len(last_ocr_str.get('code',{})), len(last_ocr_str.get('stamp',{})))) | ||
2822 | |||
2823 | if len(last_ocr_str.get('code',{})) != 3 or len(last_ocr_str.get('stamp',{})) != 3: | ||
2824 | # 先判断最后一次上传的文件是不是包括3个,如果不是直接返回"未提供财报或财报不完整" | ||
2825 | compare_log.info('{0} [se_fs_compare error] last ocr result len < 3'.format(log_base)) | ||
2826 | else: | ||
2827 | for res_idx in range(length-1, -1, -1): | ||
2828 | if is_find: | ||
2829 | break | ||
2830 | |||
2831 | for idx, (name, value) in enumerate(field_list): | ||
2832 | compare_log.info('{0} [se_fs_compare for ... in] [idx:{1}] [name:{2}] [value:{3}]'.format(log_base, idx, name, value)) | ||
2833 | ocr_str = ocr_res_list[res_idx].get(compare_logic[name][0]) | ||
2834 | compare_log.info('{0} [se_fs_compare ocr_str] [ocr_str:{1}]'.format(log_base, ocr_str)) | ||
2835 | #财年/资产负债表内容/利润表内容 不需要ocr结果,所以即使为空也可以进入比对 | ||
2836 | if isinstance(ocr_str, str) or isinstance(ocr_str, dict) or compare_logic[name][0] == '财年' or compare_logic[name][0] == '资产负债表内容' or compare_logic[name][0] == '利润表内容': | ||
2837 | result = getattr(cp, compare_logic[name][1])(value, ocr_str, **compare_logic[name][2]) | ||
2838 | compare_log.info('{0} [se_fs_compare result:{1}]'.format(log_base, result)) | ||
2839 | no_key = False | ||
2840 | else: | ||
2841 | result = consts.RESULT_N | ||
2842 | ocr_str = empty_str | ||
2843 | no_key = True | ||
2844 | |||
2845 | if idx == 0 and result == consts.RESULT_N and length > 1: | ||
2846 | break | ||
2847 | |||
2848 | is_find = True | ||
2849 | section_img_info[consts.SECTION_IMG_PATH_KEY] = ocr_res_list[res_idx].get(consts.SECTION_IMG_PATH_KEY, '') | ||
2850 | section_img_info[consts.ALL_POSITION_KEY] = ocr_res_list[res_idx].get(consts.ALL_POSITION_KEY, {}) | ||
2851 | if special_expiry_date: | ||
2852 | section_img_info[consts.SECTION_IMG_PATH_KEY_2] = ocr_res_list[res_idx].get( | ||
2853 | consts.SECTION_IMG_PATH_KEY_2, '') | ||
2854 | section_img_info[consts.ALL_POSITION_KEY_2] = ocr_res_list[res_idx].get(consts.ALL_POSITION_KEY_2, {}) | ||
2855 | |||
2856 | img_path = ocr_res_list[res_idx].get(consts.IMG_PATH_KEY, '') if result == consts.RESULT_N else empty_str | ||
2857 | if isinstance(value, list): | ||
2858 | value = json.dumps(value, ensure_ascii=False) | ||
2859 | error_type = empty_error_type if result == consts.RESULT_Y else ErrorType.OCR.value | ||
2860 | result_field_list.append((name, value, result, ocr_str, img_path, error_type, compare_logic[name][3])) | ||
2861 | else: | ||
2862 | no_ocr_result = True | ||
2863 | |||
2864 | if not is_find: | ||
2865 | for name, value in field_list: | ||
2866 | if isinstance(value, list): | ||
2867 | value = json.dumps(value, ensure_ascii=False) | ||
2868 | no_find_str = consts.FS_NO_FIND | ||
2869 | result_field_list.append((name, value, consts.RESULT_N, empty_str, empty_str, ErrorType.NF.value, no_find_str)) | ||
2870 | |||
2871 | if is_find: | ||
2872 | section_img_path = section_img_info.get(consts.SECTION_IMG_PATH_KEY, '') | ||
2873 | if os.path.exists(section_img_path): | ||
2874 | failed_field = [] | ||
2875 | base_img_path = empty_str | ||
2876 | for name, _, result, _, img_path, _, _ in result_field_list: | ||
2877 | if result == consts.RESULT_N: | ||
2878 | if special_expiry_date_slice and name == 'idExpiryDate': | ||
2879 | continue | ||
2880 | failed_field.append(name) | ||
2881 | if base_img_path == empty_str: | ||
2882 | base_img_path = img_path | ||
2883 | if len(failed_field) > 0: | ||
2884 | info = section_img_info.get(consts.ALL_POSITION_KEY, {}) | ||
2885 | section_position = info.get(consts.POSITION_KEY, {}) | ||
2886 | section_angle = info.get(consts.ANGLE_KEY, 0) | ||
2887 | try: | ||
2888 | last_img = img_process(section_img_path, section_position, section_angle) | ||
2889 | except Exception as e: | ||
2890 | for field in failed_field: | ||
2891 | field_img_path_dict[field] = base_img_path | ||
2892 | else: | ||
2893 | pre, suf = os.path.splitext(section_img_path) | ||
2894 | for field in failed_field: | ||
2895 | try: | ||
2896 | res_field = compare_logic[field][0] | ||
2897 | is_valid, coord_tuple = field_build_coordinates(info.get(res_field, {})) | ||
2898 | if is_valid: | ||
2899 | save_path = '{0}_{1}{2}'.format(pre, field, suf) | ||
2900 | field_img = last_img[coord_tuple[0]:coord_tuple[1], coord_tuple[2]:coord_tuple[3], :] | ||
2901 | cv2.imwrite(save_path, field_img) | ||
2902 | field_img_path_dict[field] = save_path | ||
2903 | else: | ||
2904 | field_img_path_dict[field] = base_img_path | ||
2905 | except Exception as e: | ||
2906 | field_img_path_dict[field] = base_img_path | ||
2907 | |||
2908 | return result_field_list, field_img_path_dict | ||
2909 | |||
2492 | 2910 | ||
2493 | def se_compare_license_id(license_en, id_res_list, field_list, is_auto): | 2911 | def se_compare_license_id(license_en, id_res_list, field_list, is_auto): |
2494 | if is_auto: | 2912 | if is_auto: |
... | @@ -2975,7 +3393,7 @@ def se_mvc34_compare(license_en, ocr_res_dict, field_list): | ... | @@ -2975,7 +3393,7 @@ def se_mvc34_compare(license_en, ocr_res_dict, field_list): |
2975 | return result_field_list, field_img_path_dict | 3393 | return result_field_list, field_img_path_dict |
2976 | 3394 | ||
2977 | 3395 | ||
2978 | def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list, aa_type): | 3396 | def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list, aa_type, allow_bs_type): |
2979 | # individualCusInfo | 3397 | # individualCusInfo |
2980 | # corporateCusInfo | 3398 | # corporateCusInfo |
2981 | # vehicleInfo | 3399 | # vehicleInfo |
... | @@ -2989,9 +3407,11 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list | ... | @@ -2989,9 +3407,11 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list |
2989 | rpa_failure_reason = {} | 3407 | rpa_failure_reason = {} |
2990 | field_result_dict = {} | 3408 | field_result_dict = {} |
2991 | 3409 | ||
3410 | # compare_info 格式: {'financialStatementInfo': {'Financial Statement': [('11', '22'), ('111', '222'), ('1111', '2222')]}} | ||
2992 | for info_key, info_value in compare_info.items(): | 3411 | for info_key, info_value in compare_info.items(): |
2993 | if info_key in ['individualCusInfo', 'applicantInformation']: | 3412 | if info_key in ['individualCusInfo', 'applicantInformation']: |
2994 | for idx, license_list in info_value.items(): | 3413 | for idx, license_list in info_value.items(): |
3414 | compare_log.info('{0} [compare license_list] [entity={1}]'.format(log_base, license_list)) | ||
2995 | for license_dict in license_list: | 3415 | for license_dict in license_list: |
2996 | for license_en, field_list in license_dict.items(): | 3416 | for license_en, field_list in license_dict.items(): |
2997 | strip_list = [] | 3417 | strip_list = [] |
... | @@ -3015,7 +3435,7 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list | ... | @@ -3015,7 +3435,7 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list |
3015 | license_en, id_res_list, strip_list, is_auto) | 3435 | license_en, id_res_list, strip_list, is_auto) |
3016 | else: | 3436 | else: |
3017 | result_field_list, no_ocr_result, field_img_path_dict = se_compare_license( | 3437 | result_field_list, no_ocr_result, field_img_path_dict = se_compare_license( |
3018 | license_en, ocr_res_dict, strip_list) | 3438 | license_en, ocr_res_dict, strip_list, is_auto) |
3019 | each_license_failed_count = 0 | 3439 | each_license_failed_count = 0 |
3020 | for name, value, result, ocr_str, img_path, error_type, cn_reason in result_field_list: | 3440 | for name, value, result, ocr_str, img_path, error_type, cn_reason in result_field_list: |
3021 | if license_en not in consts.SKIP_CARD or not no_ocr_result: | 3441 | if license_en not in consts.SKIP_CARD or not no_ocr_result: |
... | @@ -3047,6 +3467,7 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list | ... | @@ -3047,6 +3467,7 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list |
3047 | each_license_failed_count, len(result_field_list))) | 3467 | each_license_failed_count, len(result_field_list))) |
3048 | else: | 3468 | else: |
3049 | for license_en, field_list in info_value.items(): | 3469 | for license_en, field_list in info_value.items(): |
3470 | compare_log.info('{0} [compare license_en] [entity={1}]'.format(log_base, license_en)) | ||
3050 | strip_list = [] | 3471 | strip_list = [] |
3051 | for a, b in field_list: | 3472 | for a, b in field_list: |
3052 | if isinstance(b, str): | 3473 | if isinstance(b, str): |
... | @@ -3069,9 +3490,12 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list | ... | @@ -3069,9 +3490,12 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list |
3069 | elif license_en == consts.AFC_CONTRACT_QRS_EN: | 3490 | elif license_en == consts.AFC_CONTRACT_QRS_EN: |
3070 | result_field_list, field_img_path_dict = se_contract_qrs_compare(license_en, ocr_res_dict, strip_list) | 3491 | result_field_list, field_img_path_dict = se_contract_qrs_compare(license_en, ocr_res_dict, strip_list) |
3071 | elif license_en == consts.BS_EN: | 3492 | elif license_en == consts.BS_EN: |
3072 | result_field_list, field_img_path_dict = se_bs_compare(license_en, ocr_res_dict, strip_list, is_auto, aa_type) | 3493 | # 银行流水的比对,是只要有正确的就可以,所以没有按照时间顺序,先比最新的,在比最早的,如果以后要改逻辑,切记这个 |
3494 | result_field_list, field_img_path_dict = se_bs_compare(license_en, ocr_res_dict, strip_list, is_auto, aa_type, allow_bs_type) | ||
3495 | elif license_en == consts.FS_EN: | ||
3496 | result_field_list, field_img_path_dict = se_fs_compare(license_en, ocr_res_dict, strip_list) | ||
3073 | else: | 3497 | else: |
3074 | result_field_list, _, field_img_path_dict = se_compare_license(license_en, ocr_res_dict, strip_list) | 3498 | result_field_list, _, field_img_path_dict = se_compare_license(license_en, ocr_res_dict, strip_list, is_auto) |
3075 | 3499 | ||
3076 | each_license_failed_count = 0 | 3500 | each_license_failed_count = 0 |
3077 | for name, value, result, ocr_str, img_path, error_type, cn_reason in result_field_list: | 3501 | for name, value, result, ocr_str, img_path, error_type, cn_reason in result_field_list: |
... | @@ -3126,6 +3550,8 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list | ... | @@ -3126,6 +3550,8 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list |
3126 | 3550 | ||
3127 | tmp_set = set() | 3551 | tmp_set = set() |
3128 | last_cn_reason_list = [] | 3552 | last_cn_reason_list = [] |
3553 | last_cn_reason_list_attention = [] | ||
3554 | last_cn_reason_list_not_attention = [] | ||
3129 | bs_cn_reason_list = [] | 3555 | bs_cn_reason_list = [] |
3130 | for i in cn_reason_list: | 3556 | for i in cn_reason_list: |
3131 | if i in tmp_set: | 3557 | if i in tmp_set: |
... | @@ -3135,7 +3561,13 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list | ... | @@ -3135,7 +3561,13 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list |
3135 | # bs_cn_reason_list.append(i) | 3561 | # bs_cn_reason_list.append(i) |
3136 | else: | 3562 | else: |
3137 | tmp_set.add(i) | 3563 | tmp_set.add(i) |
3138 | last_cn_reason_list.append(i) | 3564 | if '关注' in i: |
3565 | last_cn_reason_list_attention.append(i) | ||
3566 | else: | ||
3567 | last_cn_reason_list_not_attention.append(i) | ||
3568 | # 要把2个list中的元素加进去,不是加整个list所以要用extend,不能用append | ||
3569 | last_cn_reason_list.extend(last_cn_reason_list_attention) | ||
3570 | last_cn_reason_list.extend(last_cn_reason_list_not_attention) | ||
3139 | cn_failure_reason_str = '\n'.join(last_cn_reason_list) | 3571 | cn_failure_reason_str = '\n'.join(last_cn_reason_list) |
3140 | bs_failure_reason_str = '\n'.join(bs_cn_reason_list) | 3572 | bs_failure_reason_str = '\n'.join(bs_cn_reason_list) |
3141 | return compare_result, total_fields, failed_count, successful_at_this_level, failure_reason_str, \ | 3573 | return compare_result, total_fields, failed_count, successful_at_this_level, failure_reason_str, \ |
... | @@ -3156,11 +3588,11 @@ def se_compare_auto(application_id, application_entity, ocr_res_id, last_obj, oc | ... | @@ -3156,11 +3588,11 @@ def se_compare_auto(application_id, application_entity, ocr_res_id, last_obj, oc |
3156 | try: | 3588 | try: |
3157 | # 比对逻辑 | 3589 | # 比对逻辑 |
3158 | # detect_list = se_result_detect(ocr_res_dict) | 3590 | # detect_list = se_result_detect(ocr_res_dict) |
3159 | compare_info, aa_type, is_gsyh = get_se_cms_compare_info_auto( | 3591 | compare_info, aa_type, is_gsyh, allow_bs_type = get_se_cms_compare_info_auto( |
3160 | application_id, last_obj, application_entity, data_source, ignore_bank=ignore_bank) | 3592 | application_id, last_obj, application_entity, data_source, ignore_bank=ignore_bank) |
3161 | compare_result, total_fields, failed_count, successful_at_this_level, failure_reason_str, \ | 3593 | compare_result, total_fields, failed_count, successful_at_this_level, failure_reason_str, \ |
3162 | cn_failure_reason_str, bs_failure_reason_str, _, field_result_dict = se_compare_process( | 3594 | cn_failure_reason_str, bs_failure_reason_str, _, field_result_dict = se_compare_process( |
3163 | compare_info, ocr_res_dict, is_gsyh, True, id_res_list, aa_type) | 3595 | compare_info, ocr_res_dict, is_gsyh, True, id_res_list, aa_type, allow_bs_type) |
3164 | compare_log.info('{0} [Auto SE] [compare success] [entity={1}] [id={2}] [ocr_res_id={3}] [result={4}]'.format( | 3596 | compare_log.info('{0} [Auto SE] [compare success] [entity={1}] [id={2}] [ocr_res_id={3}] [result={4}]'.format( |
3165 | log_base, application_entity, application_id, ocr_res_id, compare_result)) | 3597 | log_base, application_entity, application_id, ocr_res_id, compare_result)) |
3166 | except Exception as e: | 3598 | except Exception as e: |
... | @@ -3223,11 +3655,11 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res | ... | @@ -3223,11 +3655,11 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res |
3223 | # 比对逻辑 | 3655 | # 比对逻辑 |
3224 | start_time = datetime.now() | 3656 | start_time = datetime.now() |
3225 | detect_list = se_result_detect(ocr_res_dict) | 3657 | detect_list = se_result_detect(ocr_res_dict) |
3226 | compare_info, application_version, aa_type, is_gsyh = get_se_cms_compare_info( | 3658 | compare_info, application_version, aa_type, is_gsyh, allow_bs_type = get_se_cms_compare_info( |
3227 | application_id, last_obj, application_entity, detect_list, data_source, ignore_bank=ignore_bank) | 3659 | application_id, last_obj, application_entity, detect_list, data_source, ignore_bank=ignore_bank) |
3228 | compare_result, total_fields, failed_count, successful_at_this_level, failure_reason_str, \ | 3660 | compare_result, total_fields, failed_count, successful_at_this_level, failure_reason_str, \ |
3229 | cn_failure_reason_str, bs_failure_reason_str, rpa_failure_reason, field_result_dict = se_compare_process( | 3661 | cn_failure_reason_str, bs_failure_reason_str, rpa_failure_reason, field_result_dict = se_compare_process( |
3230 | compare_info, ocr_res_dict, is_gsyh, False, id_res_list, aa_type) | 3662 | compare_info, ocr_res_dict, is_gsyh, False, id_res_list, aa_type, allow_bs_type) |
3231 | compare_log.info('{0} [SE] [compare success] [entity={1}] [id={2}] [ocr_res_id={3}] [result={4}]'.format( | 3663 | compare_log.info('{0} [SE] [compare success] [entity={1}] [id={2}] [ocr_res_id={3}] [result={4}]'.format( |
3232 | log_base, application_entity, application_id, ocr_res_id, compare_result)) | 3664 | log_base, application_entity, application_id, ocr_res_id, compare_result)) |
3233 | except Exception as e: | 3665 | except Exception as e: |
... | @@ -3327,6 +3759,24 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res | ... | @@ -3327,6 +3759,24 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res |
3327 | } | 3759 | } |
3328 | } | 3760 | } |
3329 | try: | 3761 | try: |
3762 | compare_log.info('{0} [SE] [cms sleep start] [entity={1}] [id={2}] '.format(log_base, application_entity, application_id)) | ||
3763 | # 实时查询延迟时间 | ||
3764 | try: | ||
3765 | cms_delay_time_config = Configs.objects.filter(id=5).first() | ||
3766 | if cms_delay_time_config is not None and cms_delay_time_config.value is not None and cms_delay_time_config.value.isdigit(): | ||
3767 | cms_delay_time = cms_delay_time_config.value | ||
3768 | else: | ||
3769 | cms_delay_time = 0 | ||
3770 | except Exception as e: | ||
3771 | cms_delay_time = 0 | ||
3772 | compare_log.info('[get cms_delay_time_config fail] [error={0}]'.format(traceback.format_exc())) | ||
3773 | |||
3774 | compare_log.info('cms_delay_time:{0}'.format(cms_delay_time)) | ||
3775 | try: | ||
3776 | time.sleep(int(cms_delay_time)) | ||
3777 | except Exception as e: | ||
3778 | compare_log.info('[sleep error] [error={0}]'.format(traceback.format_exc())) | ||
3779 | compare_log.info('{0} [SE] [cms sleep end] [entity={1}] [id={2}] '.format(log_base, application_entity, application_id)) | ||
3330 | response = cms.send(data) # interface_report ocr to cms | 3780 | response = cms.send(data) # interface_report ocr to cms |
3331 | except Exception as e: | 3781 | except Exception as e: |
3332 | is_success = False | 3782 | is_success = False |
... | @@ -3358,128 +3808,231 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res | ... | @@ -3358,128 +3808,231 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res |
3358 | 3808 | ||
3359 | @app.task | 3809 | @app.task |
3360 | def fsm_compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True, is_cms=False): | 3810 | def fsm_compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True, is_cms=False): |
3361 | compare_log.info('{0} [receive fsm task] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}] [is_ca={5}] ' | 3811 | # try: |
3362 | '[is_cms={6}]'.format(log_base, application_entity, application_id, uniq_seq, ocr_res_id, | 3812 | # producer_thread_fsm = threading.Thread(target=fsm_compare_thread, args=(application_id, application_entity, uniq_seq, ocr_res_id, is_ca, is_cms)) |
3363 | is_ca, is_cms)) | 3813 | # producer_thread_fsm.start() |
3364 | # 调用java fsm 比对流程接口(http) | 3814 | # except Exception as e: |
3365 | # 调用Java fsm 比对流程接口, fsm 是se流程, ca可以暂时忽略 | 3815 | # compare_log.info('[fsm thread error] [error={0}]'.format(traceback.format_exc())) |
3366 | auto_class = HILAutoSettlement if application_entity == consts.HIL_PREFIX else AFCAutoSettlement | 3816 | |
3367 | auto_obj = auto_class.objects.filter(application_id=application_id, on_off=True).first() | 3817 | # with concurrent.futures.ThreadPoolExecutor(max_workers=20) as executor: |
3368 | if auto_obj is not None: | 3818 | # # 使用map函数提交多个任务 |
3369 | url = conf.FSM_AUTO_URL | 3819 | # results = list(executor.map(fsm_compare_thread, application_id, application_entity, uniq_seq, ocr_res_id, is_ca, is_cms)) |
3370 | is_auto = True | ||
3371 | else: | ||
3372 | url = conf.FSM_URL | ||
3373 | is_auto = False | ||
3374 | 3820 | ||
3375 | body = { | 3821 | compare_log.info('[fsm thread]') |
3376 | 'applicationId': application_id, | 3822 | #pool = ThreadPoolExecutor(max_workers=6, thread_name_prefix="fsm_thread_") |
3377 | 'businessType': application_entity, | ||
3378 | 'ocrResId': ocr_res_id, | ||
3379 | 'isCa': is_ca, | ||
3380 | 'isCms': is_cms | ||
3381 | } | ||
3382 | try: | 3823 | try: |
3383 | compare_log.info("request java fsm api, url:{0}, body:{1}, is_auto:{2}".format(url, json.dumps(body), is_auto)) | 3824 | # 这个try不生效 |
3384 | headers = { | 3825 | pool.submit(fsm_compare_thread, application_id, application_entity, uniq_seq, ocr_res_id, is_ca, is_cms) |
3385 | 'Content-Type': 'application/json' | 3826 | except Exception as e: |
3827 | compare_log.info('[fsm thread fail] [error={0}]'.format(traceback.format_exc())) | ||
3828 | #pool.shutdown(wait=True) | ||
3829 | |||
3830 | |||
3831 | def fsm_compare_thread(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True, is_cms=False): | ||
3832 | try: | ||
3833 | compare_log.info('{0} [receive fsm task] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}] [is_ca={5}] ' | ||
3834 | '[is_cms={6}]'.format(log_base, application_entity, application_id, uniq_seq, ocr_res_id, | ||
3835 | is_ca, is_cms)) | ||
3836 | |||
3837 | # 查看此订单号下是否有未完成的文件,如果有,等1分钟 | ||
3838 | try: | ||
3839 | doc_wait_file_class = HILDoc if application_entity == consts.HIL_PREFIX else AFCDoc | ||
3840 | doc_wait_file_result = doc_wait_file_class.objects.filter(application_id=application_id, status=1).first() | ||
3841 | compare_log.info('doc_wait_file_result:{0}'.format(doc_wait_file_result)) | ||
3842 | compare_log.info('{0} [comparison unfinished file check] [entity={1}] [id={2}] [doc_wait_file_result={3}]'.format(log_base, application_entity, application_id, doc_wait_file_result)) | ||
3843 | except Exception as e: | ||
3844 | doc_wait_file_result = None | ||
3845 | compare_log.info('[get doc_wait_file_result fail] [error={0}]'.format(traceback.format_exc())) | ||
3846 | if doc_wait_file_result is not None: | ||
3847 | # 实时查询延迟时间 | ||
3848 | try: | ||
3849 | delay_time_config = Configs.objects.filter(id=4).first() | ||
3850 | if delay_time_config is not None and delay_time_config.value is not None and delay_time_config.value.isdigit(): | ||
3851 | delay_time = delay_time_config.value | ||
3852 | else: | ||
3853 | delay_time = 0 | ||
3854 | except Exception as e: | ||
3855 | delay_time = 0 | ||
3856 | compare_log.info('[get delay_time_config fail] [error={0}]'.format(traceback.format_exc())) | ||
3857 | compare_log.info('delay_time:{0}'.format(delay_time)) | ||
3858 | compare_log.info('{0} [comparison unfinished file wait delay_time start] [entity={1}] [id={2}] [doc_id={3}]'.format(log_base, application_entity, application_id, doc_wait_file_result.id)) | ||
3859 | try: | ||
3860 | time.sleep(int(delay_time)) | ||
3861 | except Exception as e: | ||
3862 | compare_log.info('[sleep error] [error={0}]'.format(traceback.format_exc())) | ||
3863 | compare_log.info('{0} [comparison unfinished file wait delay_time end] [entity={1}] [id={2}] [doc_id={3}]'.format(log_base, application_entity, application_id, doc_wait_file_result.id)) | ||
3864 | |||
3865 | # 调用java fsm 比对流程接口(http) | ||
3866 | # 调用Java fsm 比对流程接口, fsm 是se流程, ca可以暂时忽略 | ||
3867 | auto_class = HILAutoSettlement if application_entity == consts.HIL_PREFIX else AFCAutoSettlement | ||
3868 | auto_obj = auto_class.objects.filter(application_id=application_id, on_off=True).first() | ||
3869 | if auto_obj is not None: | ||
3870 | url = conf.FSM_AUTO_URL | ||
3871 | is_auto = True | ||
3872 | else: | ||
3873 | url = conf.FSM_URL | ||
3874 | is_auto = False | ||
3875 | |||
3876 | body = { | ||
3877 | 'applicationId': application_id, | ||
3878 | 'businessType': application_entity, | ||
3879 | 'ocrResId': ocr_res_id, | ||
3880 | 'isCa': is_ca, | ||
3881 | 'isCms': is_cms | ||
3386 | } | 3882 | } |
3387 | resp = requests.post(url, headers=headers, json=body) | 3883 | try: |
3388 | compare_log.info("response from fsm api, resp:{0}".format(resp.text)) | 3884 | compare_log.info("request java fsm api, url:{0}, body:{1}, is_auto:{2}".format(url, json.dumps(body), is_auto)) |
3885 | headers = { | ||
3886 | 'Content-Type': 'application/json' | ||
3887 | } | ||
3888 | resp = requests.post(url, headers=headers, json=body) | ||
3889 | compare_log.info("response from fsm api, resp:{0}".format(resp.text)) | ||
3890 | except Exception as e: | ||
3891 | compare_log.error("fsm full request to java error, url:{0}, param:{1}, errorMsg:{2}".format( | ||
3892 | url, json.dumps(body), traceback.format_exc())) | ||
3389 | except Exception as e: | 3893 | except Exception as e: |
3390 | compare_log.error("fsm full request to java error, url:{0}, param:{1}, errorMsg:{2}".format( | 3894 | compare_log.info('[fsm_compare_thread error] [error={0}]'.format(traceback.format_exc())) |
3391 | url, json.dumps(body), traceback.format_exc())) | ||
3392 | 3895 | ||
3393 | 3896 | ||
3394 | @app.task | 3897 | @app.task |
3395 | def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True, is_cms=False): | 3898 | def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True, is_cms=False): |
3899 | # try: | ||
3900 | # producer_thread = threading.Thread(target=compare_thread, args=(application_id, application_entity, uniq_seq, ocr_res_id, is_ca, is_cms)) | ||
3901 | # producer_thread.start() | ||
3902 | # except Exception as e: | ||
3903 | # compare_log.info('[thread error] [error={0}]'.format(traceback.format_exc())) | ||
3904 | |||
3905 | # with concurrent.futures.ThreadPoolExecutor(max_workers=20) as executor: | ||
3906 | # # 使用map函数提交多个任务 | ||
3907 | # results = list(executor.map(compare_thread, application_id, application_entity, uniq_seq, ocr_res_id, is_ca, is_cms)) | ||
3908 | |||
3909 | compare_log.info('[non fsm thread]') | ||
3910 | #pool = ThreadPoolExecutor(max_workers=6, thread_name_prefix="non_fsm_thread_") | ||
3911 | try: | ||
3912 | # 这个try不生效 | ||
3913 | pool.submit(compare_thread, application_id, application_entity, uniq_seq, ocr_res_id, is_ca, is_cms) | ||
3914 | except Exception as e: | ||
3915 | compare_log.info('[non fsm thread fail] [error={0}]'.format(traceback.format_exc())) | ||
3916 | #pool.shutdown(wait=True) | ||
3917 | |||
3918 | def compare_thread(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True, is_cms=False): | ||
3396 | # POS: application_id, application_entity, uniq_seq, None | 3919 | # POS: application_id, application_entity, uniq_seq, None |
3397 | # OCR: application_id, business_type(application_entity), None, ocr_res_id | 3920 | # OCR: application_id, business_type(application_entity), None, ocr_res_id |
3398 | 3921 | try: | |
3399 | compare_log.info('{0} [receive task] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}] [is_ca={5}] ' | 3922 | compare_log.info('{0} [receive task] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}] [is_ca={5}] ' |
3400 | '[is_cms={6}]'.format(log_base, application_entity, application_id, uniq_seq, ocr_res_id, | 3923 | '[is_cms={6}]'.format(log_base, application_entity, application_id, uniq_seq, ocr_res_id, |
3401 | is_ca, is_cms)) | 3924 | is_ca, is_cms)) |
3925 | |||
3926 | # 根据application_id查找最新的比对信息,如果没有,结束 | ||
3927 | if is_ca: | ||
3928 | comparison_class = HILComparisonInfo if application_entity == consts.HIL_PREFIX else AFCComparisonInfo | ||
3929 | else: | ||
3930 | if application_entity == consts.HIL_PREFIX: | ||
3931 | comparison_class = HILSECMSInfo if is_cms else HILSEComparisonInfo | ||
3932 | else: | ||
3933 | comparison_class = AFCSECMSInfo if is_cms else AFCSEComparisonInfo | ||
3934 | last_obj = comparison_class.objects.filter(application_id=application_id).last() | ||
3935 | if last_obj is None: | ||
3936 | compare_log.info('{0} [comparison info empty] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}] ' | ||
3937 | '[is_ca={5}] [is_cms]={6}'.format(log_base, application_entity, application_id, uniq_seq, | ||
3938 | ocr_res_id, is_ca, is_cms)) | ||
3939 | return | ||
3402 | 3940 | ||
3403 | # 根据application_id查找最新的比对信息,如果没有,结束 | 3941 | # 根据application_id查找OCR累计结果指定license字段,如果没有,结束 |
3404 | if is_ca: | 3942 | if is_ca: |
3405 | comparison_class = HILComparisonInfo if application_entity == consts.HIL_PREFIX else AFCComparisonInfo | 3943 | result_class = HILOCRResult if application_entity == consts.HIL_PREFIX else AFCOCRResult |
3406 | else: | 3944 | ca_ocr_res_dict = dict() |
3407 | if application_entity == consts.HIL_PREFIX: | ||
3408 | comparison_class = HILSECMSInfo if is_cms else HILSEComparisonInfo | ||
3409 | else: | 3945 | else: |
3410 | comparison_class = AFCSECMSInfo if is_cms else AFCSEComparisonInfo | 3946 | result_class = HILSEOCRResult if application_entity == consts.HIL_PREFIX else AFCSEOCRResult |
3411 | last_obj = comparison_class.objects.filter(application_id=application_id).last() | 3947 | ca_result_class = HILOCRResult if application_entity == consts.HIL_PREFIX else AFCOCRResult |
3412 | if last_obj is None: | 3948 | # if ocr_res_id is None: |
3413 | compare_log.info('{0} [comparison info empty] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}] ' | 3949 | ca_ocr_res_dict = ca_result_class.objects.filter(application_id=application_id).values( |
3414 | '[is_ca={5}] [is_cms]={6}'.format(log_base, application_entity, application_id, uniq_seq, | 3950 | *consts.CA_ADD_COMPARE_FIELDS).first() |
3415 | ocr_res_id, is_ca, is_cms)) | 3951 | # else: |
3416 | return | 3952 | # ca_ocr_res_dict = ca_result_class.objects.filter(id=ocr_res_id).values( |
3417 | 3953 | # *consts.CA_ADD_COMPARE_FIELDS).first() | |
3418 | # 根据application_id查找OCR累计结果指定license字段,如果没有,结束 | 3954 | if ocr_res_id is None: |
3419 | if is_ca: | 3955 | ocr_res_dict = result_class.objects.filter(application_id=application_id).values(*consts.COMPARE_FIELDS).first() |
3420 | result_class = HILOCRResult if application_entity == consts.HIL_PREFIX else AFCOCRResult | ||
3421 | ca_ocr_res_dict = dict() | ||
3422 | else: | ||
3423 | result_class = HILSEOCRResult if application_entity == consts.HIL_PREFIX else AFCSEOCRResult | ||
3424 | ca_result_class = HILOCRResult if application_entity == consts.HIL_PREFIX else AFCOCRResult | ||
3425 | # if ocr_res_id is None: | ||
3426 | ca_ocr_res_dict = ca_result_class.objects.filter(application_id=application_id).values( | ||
3427 | *consts.CA_ADD_COMPARE_FIELDS).first() | ||
3428 | # else: | ||
3429 | # ca_ocr_res_dict = ca_result_class.objects.filter(id=ocr_res_id).values( | ||
3430 | # *consts.CA_ADD_COMPARE_FIELDS).first() | ||
3431 | if ocr_res_id is None: | ||
3432 | ocr_res_dict = result_class.objects.filter(application_id=application_id).values(*consts.COMPARE_FIELDS).first() | ||
3433 | else: | ||
3434 | ocr_res_dict = result_class.objects.filter(id=ocr_res_id).values(*consts.COMPARE_FIELDS).first() | ||
3435 | if ocr_res_dict is None: | ||
3436 | compare_log.info('{0} [ocr info empty] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}] ' | ||
3437 | '[is_ca={5}] [is_cms]={6}'.format(log_base, application_entity, application_id, | ||
3438 | uniq_seq, ocr_res_id, is_ca, is_cms)) | ||
3439 | return | ||
3440 | |||
3441 | if is_ca: | ||
3442 | ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict) | ||
3443 | else: | ||
3444 | id_res_list = [] | ||
3445 | for field_name in consts.CA_ADD_COMPARE_FIELDS: | ||
3446 | if field_name == consts.IC_OCR_FIELD: | ||
3447 | id_res_list.append(ca_ocr_res_dict.get(field_name) if isinstance(ca_ocr_res_dict, dict) else None) | ||
3448 | id_res_list.append(ocr_res_dict.get(field_name)) | ||
3449 | |||
3450 | if isinstance(ca_ocr_res_dict, dict) and isinstance(ca_ocr_res_dict.get(field_name), str): | ||
3451 | tmp_ca_result = json.loads(ca_ocr_res_dict.get(field_name)) | ||
3452 | if isinstance(ocr_res_dict.get(field_name), str): | ||
3453 | tmp_se_result = json.loads(ocr_res_dict.get(field_name)) | ||
3454 | tmp_ca_result.extend(tmp_se_result) | ||
3455 | ocr_res_dict[field_name] = json.dumps(tmp_ca_result) | ||
3456 | # auto settlement | ||
3457 | auto_class = HILAutoSettlement if application_entity == consts.HIL_PREFIX else AFCAutoSettlement | ||
3458 | auto_obj = auto_class.objects.filter(application_id=application_id, on_off=True).first() | ||
3459 | bank_class = HILbankVerification if application_entity == consts.HIL_PREFIX else AFCbankVerification | ||
3460 | ignore_bank = bank_class.objects.filter(application_id=application_id, on_off=True).exists() | ||
3461 | data_source = '' | ||
3462 | if application_entity == consts.AFC_PREFIX: | ||
3463 | doc_obj = AFCDoc.objects.filter(application_id=application_id, document_name__icontains='电子签署-车辆抵押贷款合同').last() | ||
3464 | if doc_obj is not None: | ||
3465 | data_source = doc_obj.data_source | ||
3466 | compare_log.info('{0} [get data_source] [id={1}] [data_source={2}]]'.format( | ||
3467 | log_base, application_id, data_source)) | ||
3468 | if auto_obj is not None: | ||
3469 | auto_result = se_compare_auto(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict, auto_obj, ignore_bank, id_res_list, data_source) | ||
3470 | else: | 3956 | else: |
3471 | auto_result = None | 3957 | ocr_res_dict = result_class.objects.filter(id=ocr_res_id).values(*consts.COMPARE_FIELDS).first() |
3472 | 3958 | if ocr_res_dict is None: | |
3473 | 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, data_source) | 3959 | compare_log.info('{0} [ocr info empty] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}] ' |
3960 | '[is_ca={5}] [is_cms]={6}'.format(log_base, application_entity, application_id, | ||
3961 | uniq_seq, ocr_res_id, is_ca, is_cms)) | ||
3962 | return | ||
3474 | 3963 | ||
3475 | if auto_obj is not None: | 3964 | # 查看此订单号下是否有未完成的文件,如果有,等?分钟 |
3965 | try: | ||
3966 | doc_wait_file_class = HILDoc if application_entity == consts.HIL_PREFIX else AFCDoc | ||
3967 | doc_wait_file_result = doc_wait_file_class.objects.filter(application_id=application_id, status=1).first() | ||
3968 | compare_log.info('doc_wait_file_result:{0}'.format(doc_wait_file_result)) | ||
3969 | compare_log.info('{0} [comparison unfinished file check] [entity={1}] [id={2}] [doc_wait_file_result={3}]'.format(log_base, application_entity, application_id, doc_wait_file_result)) | ||
3970 | except Exception as e: | ||
3971 | doc_wait_file_result = None | ||
3972 | compare_log.info('[get doc_wait_file_result fail] [error={0}]'.format(traceback.format_exc())) | ||
3973 | if doc_wait_file_result is not None: | ||
3974 | # 实时查询延迟时间 | ||
3476 | try: | 3975 | try: |
3477 | auto_obj.ocr_whole_result_pass = full_result | 3976 | delay_time_config = Configs.objects.filter(id=4).first() |
3478 | auto_obj.save() | 3977 | if delay_time_config is not None and delay_time_config.value is not None and delay_time_config.value.isdigit(): |
3479 | compare_log.info('{0} [Auto SE] [result save success] [entity={1}] [id={2}] [ocr_res_id={3}]'.format( | 3978 | delay_time = delay_time_config.value |
3480 | log_base, application_entity, application_id, ocr_res_id)) | 3979 | else: |
3980 | delay_time = 0 | ||
3481 | except Exception as e: | 3981 | except Exception as e: |
3482 | compare_log.error('{0} [Auto SE] [result save error] [entity={1}] [id={2}] [ocr_res_id={3}] ' | 3982 | delay_time = 0 |
3483 | '[error={4}]'.format(log_base, application_entity, application_id, ocr_res_id, | 3983 | compare_log.info('[get delay_time_config fail] [error={0}]'.format(traceback.format_exc())) |
3484 | traceback.format_exc())) | 3984 | compare_log.info('delay_time:{0}'.format(delay_time)) |
3985 | compare_log.info('{0} [comparison unfinished file wait delay_time start] [entity={1}] [id={2}] [doc_id={3}]'.format(log_base, application_entity, application_id, doc_wait_file_result.id)) | ||
3986 | try: | ||
3987 | time.sleep(int(delay_time)) | ||
3988 | except Exception as e: | ||
3989 | compare_log.info('[sleep error] [error={0}]'.format(traceback.format_exc())) | ||
3990 | compare_log.info('{0} [comparison unfinished file wait delay_time end] [entity={1}] [id={2}] [doc_id={3}]'.format(log_base, application_entity, application_id, doc_wait_file_result.id)) | ||
3991 | |||
3485 | 3992 | ||
3993 | if is_ca: | ||
3994 | ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict) | ||
3995 | else: | ||
3996 | id_res_list = [] | ||
3997 | for field_name in consts.CA_ADD_COMPARE_FIELDS: | ||
3998 | if field_name == consts.IC_OCR_FIELD: | ||
3999 | id_res_list.append(ca_ocr_res_dict.get(field_name) if isinstance(ca_ocr_res_dict, dict) else None) | ||
4000 | id_res_list.append(ocr_res_dict.get(field_name)) | ||
4001 | |||
4002 | if isinstance(ca_ocr_res_dict, dict) and isinstance(ca_ocr_res_dict.get(field_name), str): | ||
4003 | tmp_ca_result = json.loads(ca_ocr_res_dict.get(field_name)) | ||
4004 | if isinstance(ocr_res_dict.get(field_name), str): | ||
4005 | tmp_se_result = json.loads(ocr_res_dict.get(field_name)) | ||
4006 | tmp_ca_result.extend(tmp_se_result) | ||
4007 | ocr_res_dict[field_name] = json.dumps(tmp_ca_result) | ||
4008 | # auto settlement | ||
4009 | auto_class = HILAutoSettlement if application_entity == consts.HIL_PREFIX else AFCAutoSettlement | ||
4010 | auto_obj = auto_class.objects.filter(application_id=application_id, on_off=True).first() | ||
4011 | bank_class = HILbankVerification if application_entity == consts.HIL_PREFIX else AFCbankVerification | ||
4012 | ignore_bank = bank_class.objects.filter(application_id=application_id, on_off=True).exists() | ||
4013 | data_source = '' | ||
4014 | if application_entity == consts.AFC_PREFIX: | ||
4015 | doc_obj = AFCDoc.objects.filter(application_id=application_id, document_name__icontains='电子签署-车辆抵押贷款合同').last() | ||
4016 | if doc_obj is not None: | ||
4017 | data_source = doc_obj.data_source | ||
4018 | compare_log.info('{0} [get data_source] [id={1}] [data_source={2}]]'.format( | ||
4019 | log_base, application_id, data_source)) | ||
4020 | if auto_obj is not None: | ||
4021 | auto_result = se_compare_auto(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict, auto_obj, ignore_bank, id_res_list, data_source) | ||
4022 | else: | ||
4023 | auto_result = None | ||
4024 | |||
4025 | 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, data_source) | ||
4026 | |||
4027 | if auto_obj is not None: | ||
4028 | try: | ||
4029 | auto_obj.ocr_whole_result_pass = full_result | ||
4030 | auto_obj.save() | ||
4031 | compare_log.info('{0} [Auto SE] [result save success] [entity={1}] [id={2}] [ocr_res_id={3}]'.format( | ||
4032 | log_base, application_entity, application_id, ocr_res_id)) | ||
4033 | except Exception as e: | ||
4034 | compare_log.error('{0} [Auto SE] [result save error] [entity={1}] [id={2}] [ocr_res_id={3}] ' | ||
4035 | '[error={4}]'.format(log_base, application_entity, application_id, ocr_res_id, | ||
4036 | traceback.format_exc())) | ||
4037 | except Exception as e: | ||
4038 | compare_log.info('[compare_thread error] [error={0}]'.format(traceback.format_exc())) | ... | ... |
... | @@ -19,10 +19,18 @@ class HMHRetriever: | ... | @@ -19,10 +19,18 @@ class HMHRetriever: |
19 | def get_target_fields(self, pdf_text_list): | 19 | def get_target_fields(self, pdf_text_list): |
20 | result = dict() | 20 | result = dict() |
21 | is_find_name_id_company, is_find_application_no, is_find_name_date = False, False, False | 21 | is_find_name_id_company, is_find_application_no, is_find_name_date = False, False, False |
22 | for bbox, text in pdf_text_list.pop(str(0), []): | 22 | # for bbox, text in pdf_text_list.pop(str(0), []): |
23 | # print(text) | 23 | pdf_text_items = pdf_text_list.pop(str(0), []) |
24 | |||
25 | for i in range(len(pdf_text_items)): | ||
26 | bbox, text = pdf_text_items[i] | ||
27 | combined_text = text | ||
28 | if i < len(pdf_text_items) - 1: | ||
29 | combined_text += pdf_text_items[i + 1][1] | ||
30 | |||
24 | if not is_find_name_id_company: | 31 | if not is_find_name_id_company: |
25 | name_id_company_list = re.findall(r'姓名(.*)证件号码(.*)与(.*公司)', text) | 32 | # name_id_company_list = re.findall(r'姓名(.*?)证件号码(.*?)与(.*?公司|.*)', combined_text) |
33 | name_id_company_list = re.findall(r'姓名(.*)证件号码(.*)与(.*公司)', combined_text) | ||
26 | for name_id_company_tuple in name_id_company_list: | 34 | for name_id_company_tuple in name_id_company_list: |
27 | if len(name_id_company_tuple) == 3: | 35 | if len(name_id_company_tuple) == 3: |
28 | result[self.search_fields_list[0][0]] = { | 36 | result[self.search_fields_list[0][0]] = { |
... | @@ -40,7 +48,7 @@ class HMHRetriever: | ... | @@ -40,7 +48,7 @@ class HMHRetriever: |
40 | is_find_name_id_company = True | 48 | is_find_name_id_company = True |
41 | break | 49 | break |
42 | if not is_find_application_no: | 50 | if not is_find_application_no: |
43 | application_no_list = re.findall(r'合同编号.*(CH-B\d*-\d*).*', text) | 51 | application_no_list = re.findall(r'合同编号.*(CH-B\d*-\d*).*', combined_text) |
44 | if len(application_no_list) == 1: | 52 | if len(application_no_list) == 1: |
45 | result[self.search_fields_list[3][0]] = { | 53 | result[self.search_fields_list[3][0]] = { |
46 | self.words_str: application_no_list[0], | 54 | self.words_str: application_no_list[0], |
... | @@ -48,7 +56,7 @@ class HMHRetriever: | ... | @@ -48,7 +56,7 @@ class HMHRetriever: |
48 | } | 56 | } |
49 | is_find_application_no = True | 57 | is_find_application_no = True |
50 | if not is_find_name_date: | 58 | if not is_find_name_date: |
51 | name_date_list = re.findall(r'(.*).*签署日期.*(\d{4}-\d{2}-\d{2})', text) | 59 | name_date_list = re.findall(r'(.*).*签署日期.*(\d{4}-\d{2}-\d{2})', combined_text) |
52 | for name_date_tuple in name_date_list: | 60 | for name_date_tuple in name_date_list: |
53 | if len(name_date_tuple) == 2: | 61 | if len(name_date_tuple) == 2: |
54 | result[self.search_fields_list[4][0]] = { | 62 | result[self.search_fields_list[4][0]] = { | ... | ... |
src/common/tools/aes.py
0 → 100644
1 | #这个有问题 | ||
2 | from Crypto.Cipher import AES | ||
3 | from base64 import b64encode, b64decode | ||
4 | |||
5 | |||
6 | def encrypt_ecb(data, key): | ||
7 | data = data.encode() | ||
8 | key = key.encode() | ||
9 | aes = AES.new(key, AES.MODE_CBC, bytes(16)) | ||
10 | res = aes.encrypt(pad(data, 32)) | ||
11 | return b64encode(res).decode() | ||
12 | |||
13 | |||
14 | def decrypt(data, key, iv): | ||
15 | key = key.encode() | ||
16 | iv = iv.encode() | ||
17 | # aes = AES.new(key, AES.MODE_CBC, bytes(16)) | ||
18 | aes = AES.new(key, AES.MODE_CBC, iv) | ||
19 | res = aes.decrypt(b64decode(data)) | ||
20 | return unpad(res, 32).decode() | ||
21 | |||
22 | |||
23 | def unpad(padded_data, block_size, style='pkcs7'): | ||
24 | pdata_len = len(padded_data) | ||
25 | if pdata_len == 0: | ||
26 | raise ValueError("Zero-length input cannot be unpadded") | ||
27 | if pdata_len % block_size: | ||
28 | raise ValueError("Input data is not padded") | ||
29 | if style in ('pkcs7', 'x923'): | ||
30 | padding_len = bord(padded_data[-1]) | ||
31 | if padding_len<1 or padding_len>min(block_size, pdata_len): | ||
32 | raise ValueError("Padding is incorrect.") | ||
33 | if style == 'pkcs7': | ||
34 | if padded_data[-padding_len:]!=bchr(padding_len)*padding_len: | ||
35 | raise ValueError("PKCS#7 padding is incorrect.") | ||
36 | else: | ||
37 | if padded_data[-padding_len:-1]!=bchr(0)*(padding_len-1): | ||
38 | raise ValueError("ANSI X.923 padding is incorrect.") | ||
39 | elif style == 'iso7816': | ||
40 | padding_len = pdata_len - padded_data.rfind(bchr(128)) | ||
41 | if padding_len<1 or padding_len>min(block_size, pdata_len): | ||
42 | raise ValueError("Padding is incorrect.") | ||
43 | if padding_len>1 and padded_data[1-padding_len:]!=bchr(0)*(padding_len-1): | ||
44 | raise ValueError("ISO 7816-4 padding is incorrect.") | ||
45 | else: | ||
46 | raise ValueError("Unknown padding style") | ||
47 | return padded_data[:-padding_len] | ||
48 | |||
49 | def pad(data_to_pad, block_size, style='pkcs7'): | ||
50 | padding_len = block_size-len(data_to_pad)%block_size | ||
51 | if style == 'pkcs7': | ||
52 | padding = bchr(padding_len)*padding_len | ||
53 | elif style == 'x923': | ||
54 | padding = bchr(0)*(padding_len-1) + bchr(padding_len) | ||
55 | elif style == 'iso7816': | ||
56 | padding = bchr(128) + bchr(0)*(padding_len-1) | ||
57 | else: | ||
58 | raise ValueError("Unknown padding style") | ||
59 | return data_to_pad + padding | ||
60 | |||
61 | def bord(s): | ||
62 | return s | ||
63 | def bchr(s): | ||
64 | return bytes([s]) | ||
65 | |||
66 | if __name__ == '__main__': | ||
67 | |||
68 | decrypt_data = decrypt('QkjNiuixpmtcxxqxaIZ30A==', 'm0XsOHC52YZ5KtakhpuMSZtF7DhwudmG', 'OCRocr2024UATocr') | ||
69 | print('解密:', decrypt_data) | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
src/common/tools/aes_util.py
0 → 100644
1 | from Crypto.Cipher import AES | ||
2 | from base64 import b64encode, b64decode | ||
3 | |||
4 | def aes_encrypt_cbc(data, key, iv): | ||
5 | cipher = AES.new(key, AES.MODE_CBC, iv) | ||
6 | return cipher.encrypt(data) | ||
7 | |||
8 | def aes_decrypt_cbc(data, key, iv): | ||
9 | res = '' | ||
10 | try: | ||
11 | cipher = AES.new(key.encode(), AES.MODE_CBC, iv.encode()) | ||
12 | res = cipher.decrypt(b64decode(data)) | ||
13 | res = res.decode('utf-8').replace('\x0e', '') | ||
14 | except Exception as e: | ||
15 | res = '' | ||
16 | return res | ||
17 | |||
18 | |||
19 | # 示例使用 | ||
20 | key = 'm0XsOHC52YZ5KtakhpuMSZtF7DhwudmG' # 密钥长度必须是16、24或32字节 | ||
21 | iv = 'OCRocr2024UATocr' | ||
22 | decrypted_data = aes_decrypt_cbc('QkjNiuixpmtcxxqxaIZ30A==', key, iv) | ||
23 | print("解密:", decrypted_data) | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -12,6 +12,7 @@ import logging | ... | @@ -12,6 +12,7 @@ import logging |
12 | 12 | ||
13 | compare_log = logging.getLogger('compare') | 13 | compare_log = logging.getLogger('compare') |
14 | 14 | ||
15 | |||
15 | class Comparison: | 16 | class Comparison: |
16 | 17 | ||
17 | def __init__(self): | 18 | def __init__(self): |
... | @@ -192,7 +193,7 @@ class Comparison: | ... | @@ -192,7 +193,7 @@ class Comparison: |
192 | def se_input_list_compare(self, input_list, ocr_str, **kwargs): | 193 | def se_input_list_compare(self, input_list, ocr_str, **kwargs): |
193 | if isinstance(input_list, list) and len(input_list) > 0 and isinstance(ocr_str, str): | 194 | if isinstance(input_list, list) and len(input_list) > 0 and isinstance(ocr_str, str): |
194 | ocr_str = ocr_str.translate(self.KH_TRANS) | 195 | ocr_str = ocr_str.translate(self.KH_TRANS) |
195 | 196 | ||
196 | for input_str in input_list: | 197 | for input_str in input_list: |
197 | input_str = input_str.translate(self.KH_TRANS) | 198 | input_str = input_str.translate(self.KH_TRANS) |
198 | compare_log.info('[se_input_list_compare] [input_str {0}] [ocr_str {1}]'.format(input_str, ocr_str)) | 199 | compare_log.info('[se_input_list_compare] [input_str {0}] [ocr_str {1}]'.format(input_str, ocr_str)) |
... | @@ -221,7 +222,7 @@ class Comparison: | ... | @@ -221,7 +222,7 @@ class Comparison: |
221 | for idx in range(len(src_str)): | 222 | for idx in range(len(src_str)): |
222 | if src_str[idx].isdigit(): | 223 | if src_str[idx].isdigit(): |
223 | replace_char_list.append(src_str[idx]) | 224 | replace_char_list.append(src_str[idx]) |
224 | elif idx == len(src_str)-3: | 225 | elif idx == len(src_str) - 3: |
225 | replace_char_list.append('.') | 226 | replace_char_list.append('.') |
226 | return ''.join(replace_char_list) | 227 | return ''.join(replace_char_list) |
227 | 228 | ||
... | @@ -323,6 +324,9 @@ class Comparison: | ... | @@ -323,6 +324,9 @@ class Comparison: |
323 | return self.RESULT_Y | 324 | return self.RESULT_Y |
324 | if kwargs.get('remove_space', False): | 325 | if kwargs.get('remove_space', False): |
325 | input_str = input_str.replace(' ', '') | 326 | input_str = input_str.replace(' ', '') |
327 | if kwargs.get('remove_all_space', False): | ||
328 | input_str = input_str.replace(' ', '') | ||
329 | ocr_str = ocr_str.replace(' ', '') | ||
326 | if kwargs.get('brackets_replace', False): | 330 | if kwargs.get('brackets_replace', False): |
327 | input_str = input_str.translate(self.KH_TRANS) | 331 | input_str = input_str.translate(self.KH_TRANS) |
328 | ocr_str = ocr_str.translate(self.KH_TRANS) | 332 | ocr_str = ocr_str.translate(self.KH_TRANS) |
... | @@ -603,6 +607,33 @@ class Comparison: | ... | @@ -603,6 +607,33 @@ class Comparison: |
603 | except Exception as e: | 607 | except Exception as e: |
604 | return self.RESULT_N | 608 | return self.RESULT_N |
605 | 609 | ||
610 | def se_bd_date_2_compare(self, input_str, ocr_str, **kwargs): | ||
611 | try: | ||
612 | # Convert strings to date objects | ||
613 | ocr_date = datetime.strptime(ocr_str, "%Y-%m-%d").date() | ||
614 | |||
615 | # Get today's date | ||
616 | today_date = datetime.today().date() | ||
617 | ''' | ||
618 | 开始时间<后天(不包含), 结束时间>昨天(不包含) | ||
619 | ''' | ||
620 | if kwargs.get('start', False): | ||
621 | # 开始时间 < 后天(不包含) | ||
622 | day_after_tomorrow_date = today_date + relativedelta(days=2) | ||
623 | if ocr_date < day_after_tomorrow_date: | ||
624 | return self.RESULT_Y | ||
625 | else: | ||
626 | # 结束时间>昨天(不包含) | ||
627 | yesterday_date = today_date + relativedelta(days=-1) | ||
628 | if ocr_date > yesterday_date: | ||
629 | return self.RESULT_Y | ||
630 | |||
631 | # Default return value if conditions are not met | ||
632 | return self.RESULT_N | ||
633 | except Exception as e: | ||
634 | # Return RESULT_N in case of any exception | ||
635 | return self.RESULT_N | ||
636 | |||
606 | def se_bs_print_date_compare(self, input_str, ocr_str, **kwargs): | 637 | def se_bs_print_date_compare(self, input_str, ocr_str, **kwargs): |
607 | try: | 638 | try: |
608 | input_date = datetime.strptime(input_str, "%Y-%m-%d") | 639 | input_date = datetime.strptime(input_str, "%Y-%m-%d") |
... | @@ -661,7 +692,7 @@ class Comparison: | ... | @@ -661,7 +692,7 @@ class Comparison: |
661 | # input_str = input_str.replace('-', '') | 692 | # input_str = input_str.replace('-', '') |
662 | 693 | ||
663 | return self.is_after_today_pre(ocr_str) | 694 | return self.is_after_today_pre(ocr_str) |
664 | 695 | ||
665 | def se_qrs_compare(self, input_str, ocr_str_or_list, **kwargs): | 696 | def se_qrs_compare(self, input_str, ocr_str_or_list, **kwargs): |
666 | try: | 697 | try: |
667 | target_count_str, application_id = input_str.split('_') | 698 | target_count_str, application_id = input_str.split('_') |
... | @@ -676,7 +707,58 @@ class Comparison: | ... | @@ -676,7 +707,58 @@ class Comparison: |
676 | except Exception as e: | 707 | except Exception as e: |
677 | return self.RESULT_N | 708 | return self.RESULT_N |
678 | 709 | ||
710 | def hash_code_compare(self, input_str, ocr_dict, **kwargs): | ||
711 | try: | ||
712 | balance_sheet_hash = ocr_dict.get('balance_sheet','') | ||
713 | income_statement_hash = ocr_dict.get('income_statement','') | ||
714 | cash_flow_statement_hash = ocr_dict.get('cash_flow_statement','') | ||
715 | if balance_sheet_hash != input_str or income_statement_hash != input_str or cash_flow_statement_hash != input_str: | ||
716 | return self.RESULT_N | ||
717 | else: | ||
718 | return self.RESULT_Y | ||
719 | except Exception as e: | ||
720 | return self.RESULT_N | ||
679 | 721 | ||
680 | cp = Comparison() | 722 | def stamp_dict_compare(self, input_str, ocr_dict, **kwargs): |
723 | try: | ||
724 | balance_sheet_stamp = ocr_dict.get('balance_sheet','') | ||
725 | income_statement_stamp = ocr_dict.get('income_statement','') | ||
726 | cash_flow_statement_stamp = ocr_dict.get('cash_flow_statement','') | ||
727 | if balance_sheet_stamp != 1 or income_statement_stamp != 1 or cash_flow_statement_stamp != 1: | ||
728 | return self.RESULT_N | ||
729 | else: | ||
730 | return self.RESULT_Y | ||
731 | except Exception as e: | ||
732 | return self.RESULT_N | ||
733 | |||
734 | def stamp_str_compare(self, input_str, ocr_str, **kwargs): | ||
735 | try: | ||
736 | if ocr_str != 1: | ||
737 | return self.RESULT_N | ||
738 | else: | ||
739 | return self.RESULT_Y | ||
740 | except Exception as e: | ||
741 | return self.RESULT_N | ||
742 | |||
743 | def fiscal_year_compare(self, input_str, ocr_list, **kwargs): | ||
744 | try: | ||
745 | this_year_str = datetime.now().strftime('%Y') | ||
746 | this_year = int(this_year_str) | ||
747 | last_year = this_year - 1 | ||
748 | if str(input_str) != str(this_year) and str(input_str) != str(last_year): | ||
749 | return self.RESULT_N | ||
750 | return self.RESULT_Y | ||
751 | except Exception as e: | ||
752 | return self.RESULT_N | ||
753 | |||
754 | def input_list_not_zero_compare(self, input_list, ocr_list, **kwargs): | ||
755 | try: | ||
756 | for item in input_list: | ||
757 | if float(item) == 0: | ||
758 | return self.RESULT_N | ||
759 | return self.RESULT_Y | ||
760 | except Exception as e: | ||
761 | return self.RESULT_N | ||
681 | 762 | ||
682 | 763 | ||
764 | cp = Comparison() | ... | ... |
src/common/tools/mssql_script28.py
0 → 100644
1 | import pyodbc | ||
2 | |||
3 | hil_sql = """ | ||
4 | ALTER TABLE hil_ocr_result ADD fs_ocr nvarchar(max); | ||
5 | ALTER TABLE hil_se_ocr_result ADD fs_ocr nvarchar(max); | ||
6 | ALTER TABLE hil_ocr_result ADD fss_ocr nvarchar(max); | ||
7 | ALTER TABLE hil_se_ocr_result ADD fss_ocr nvarchar(max); | ||
8 | """ | ||
9 | |||
10 | afc_sql = """ | ||
11 | ALTER TABLE afc_ocr_result ADD fs_ocr nvarchar(max); | ||
12 | ALTER TABLE afc_se_ocr_result ADD fs_ocr nvarchar(max); | ||
13 | ALTER TABLE afc_ocr_result ADD fss_ocr nvarchar(max); | ||
14 | ALTER TABLE afc_se_ocr_result ADD fss_ocr nvarchar(max); | ||
15 | """ | ||
16 | |||
17 | hil_cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};', autocommit=True) | ||
18 | |||
19 | hil_cursor = hil_cnxn.cursor() | ||
20 | hil_cursor.execute(hil_sql) | ||
21 | |||
22 | hil_cursor.close() | ||
23 | hil_cnxn.close() | ||
24 | |||
25 | afc_cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};', autocommit=True) | ||
26 | |||
27 | afc_cursor = afc_cnxn.cursor() | ||
28 | afc_cursor.execute(afc_sql) | ||
29 | |||
30 | afc_cursor.close() | ||
31 | afc_cnxn.close() |
src/common/tools/mssql_script29.py
0 → 100644
1 | import pyodbc | ||
2 | |||
3 | hil_sql = """ | ||
4 | ALTER TABLE hil_ocr_result ADD dp_ocr nvarchar(max); | ||
5 | ALTER TABLE hil_se_ocr_result ADD dp_ocr nvarchar(max); | ||
6 | """ | ||
7 | |||
8 | afc_sql = """ | ||
9 | ALTER TABLE afc_ocr_result ADD dp_ocr nvarchar(max); | ||
10 | ALTER TABLE afc_se_ocr_result ADD dp_ocr nvarchar(max); | ||
11 | """ | ||
12 | |||
13 | hil_cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};', autocommit=True) | ||
14 | |||
15 | hil_cursor = hil_cnxn.cursor() | ||
16 | hil_cursor.execute(hil_sql) | ||
17 | |||
18 | hil_cursor.close() | ||
19 | hil_cnxn.close() | ||
20 | |||
21 | afc_cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};', autocommit=True) | ||
22 | |||
23 | afc_cursor = afc_cnxn.cursor() | ||
24 | afc_cursor.execute(afc_sql) | ||
25 | |||
26 | afc_cursor.close() | ||
27 | afc_cnxn.close() |
src/common/tools/mssql_script30.py
0 → 100644
1 | import pyodbc | ||
2 | |||
3 | hil_sql = """ | ||
4 | CREATE TABLE [dbo].[hil_gb_history_file] ( | ||
5 | [id] int IDENTITY(1,1) NOT NULL, | ||
6 | [object_id] varchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, | ||
7 | [object_name] varchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, | ||
8 | [application_no] varchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, | ||
9 | [object_type] varchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, | ||
10 | [customer_name] varchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, | ||
11 | [content_size] varchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, | ||
12 | [owner_name] varchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, | ||
13 | [input_date] datetime NULL, | ||
14 | [modify_date] datetime NULL, | ||
15 | [location] varchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, | ||
16 | [download_finish] int NOT NULL, | ||
17 | [update_time] datetime NULL, | ||
18 | [create_time] datetime NULL | ||
19 | ) | ||
20 | GO; | ||
21 | |||
22 | alter table hil_gb_history_file ADD CONSTRAINT unique_object_id unique(object_id) | ||
23 | |||
24 | """ | ||
25 | |||
26 | afc_sql = """ | ||
27 | CREATE TABLE [dbo].[afc_gb_history_file] ( | ||
28 | [id] int IDENTITY(1,1) NOT NULL, | ||
29 | [object_id] varchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, | ||
30 | [object_name] varchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, | ||
31 | [application_no] varchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, | ||
32 | [object_type] varchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, | ||
33 | [customer_name] varchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, | ||
34 | [content_size] varchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, | ||
35 | [owner_name] varchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, | ||
36 | [input_date] datetime NULL, | ||
37 | [modify_date] datetime NULL, | ||
38 | [location] varchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, | ||
39 | [download_finish] int NOT NULL, | ||
40 | [update_time] datetime NULL, | ||
41 | [create_time] datetime NULL | ||
42 | ) | ||
43 | GO; | ||
44 | |||
45 | alter table afc_gb_history_file ADD CONSTRAINT unique_object_id unique(object_id) | ||
46 | |||
47 | """ | ||
48 | |||
49 | hil_cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};', autocommit=True) | ||
50 | |||
51 | hil_cursor = hil_cnxn.cursor() | ||
52 | hil_cursor.execute(hil_sql) | ||
53 | |||
54 | hil_cursor.close() | ||
55 | hil_cnxn.close() | ||
56 | |||
57 | afc_cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};', autocommit=True) | ||
58 | |||
59 | afc_cursor = afc_cnxn.cursor() | ||
60 | afc_cursor.execute(afc_sql) | ||
61 | |||
62 | afc_cursor.close() | ||
63 | afc_cnxn.close() |
... | @@ -100,9 +100,9 @@ DATABASES = { | ... | @@ -100,9 +100,9 @@ DATABASES = { |
100 | for db_setting in DATABASES.values(): | 100 | for db_setting in DATABASES.values(): |
101 | db_setting['OPTIONS'] = { | 101 | db_setting['OPTIONS'] = { |
102 | 'driver': 'ODBC Driver 17 for SQL Server', | 102 | 'driver': 'ODBC Driver 17 for SQL Server', |
103 | 'extra_params': "odbc_cursortype=2" | 103 | 'extra_params': "odbc_cursortype=2;TrustServerCertificate=yes;Encrypt=yes" |
104 | } | 104 | } |
105 | 105 | db_setting['CONN_MAX_AGE'] = 0 | |
106 | # set this to False if you want to turn off pyodbc's connection pooling | 106 | # set this to False if you want to turn off pyodbc's connection pooling |
107 | DATABASE_CONNECTION_POOLING = True | 107 | DATABASE_CONNECTION_POOLING = True |
108 | 108 | ... | ... |
... | @@ -14,4 +14,6 @@ DEALER_CODE = ocr_situ_group | ... | @@ -14,4 +14,6 @@ DEALER_CODE = ocr_situ_group |
14 | 14 | ||
15 | BASE_URL = https://staging-bmw-ocr.situdata.com | 15 | BASE_URL = https://staging-bmw-ocr.situdata.com |
16 | 16 | ||
17 | DELAY_SECONDS = 60 | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
17 | DELAY_SECONDS = 60 | ||
18 | |||
19 | BD_PRICE = 950 | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -14,4 +14,6 @@ DEALER_CODE = ocr_situ_group | ... | @@ -14,4 +14,6 @@ DEALER_CODE = ocr_situ_group |
14 | 14 | ||
15 | BASE_URL = https://sfocr-uat.bmwgroup.net | 15 | BASE_URL = https://sfocr-uat.bmwgroup.net |
16 | 16 | ||
17 | DELAY_SECONDS = 60 | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
17 | DELAY_SECONDS = 60 | ||
18 | |||
19 | BD_PRICE = 950 | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or sign in to post a comment