ADD:财报逻辑
Showing
4 changed files
with
218 additions
and
10 deletions
| ... | @@ -1247,6 +1247,7 @@ FSM_CONTRACT_WEP_FIELD = 'fsm_wep_ocr' | ... | @@ -1247,6 +1247,7 @@ FSM_CONTRACT_WEP_FIELD = 'fsm_wep_ocr' |
| 1247 | FSM_CONTRACT_MSI_FIELD = 'fsm_msi_ocr' | 1247 | FSM_CONTRACT_MSI_FIELD = 'fsm_msi_ocr' |
| 1248 | FSM_CONTRACT_SC_FIELD = 'fsm_sc_ocr' | 1248 | FSM_CONTRACT_SC_FIELD = 'fsm_sc_ocr' |
| 1249 | FSM_CONTRACT_SC2_FIELD = 'fsm_sc2_ocr' | 1249 | FSM_CONTRACT_SC2_FIELD = 'fsm_sc2_ocr' |
| 1250 | FS_FIELD = 'fs_ocr' | ||
| 1250 | 1251 | ||
| 1251 | 1252 | ||
| 1252 | BS_CLASSIFY = 10089 | 1253 | BS_CLASSIFY = 10089 |
| ... | @@ -1504,6 +1505,7 @@ SE_BD_FIELD = ['被保险人姓名', '被保险人证件号码', '车架号', ' | ... | @@ -1504,6 +1505,7 @@ SE_BD_FIELD = ['被保险人姓名', '被保险人证件号码', '车架号', ' |
| 1504 | JDMPV_VALUE = ['-', '--', '0%', '0.00', '/', '0', ''] | 1505 | JDMPV_VALUE = ['-', '--', '0%', '0.00', '/', '0', ''] |
| 1505 | JYPZ_TYPE_1 = ['二手车交易凭证'] | 1506 | JYPZ_TYPE_1 = ['二手车交易凭证'] |
| 1506 | JYPZ_TYPE_2 = ['BMW官方认证二手车交易凭证', '二手车交易凭证'] | 1507 | JYPZ_TYPE_2 = ['BMW官方认证二手车交易凭证', '二手车交易凭证'] |
| 1508 | SE_FS_FIELD = ['Hash值', '公章', '财年', '资产负债表内容', '利润表内容'] | ||
| 1507 | 1509 | ||
| 1508 | SE_BANK_FIELD = ['accountNo', 'bankName'] | 1510 | SE_BANK_FIELD = ['accountNo', 'bankName'] |
| 1509 | SE_DDA_FIELD = ['applicationId(1)', 'applicationId(2)', 'bankName', 'companyName', 'customerName', 'idNum', 'accountHolderName', 'accountNo'] | 1511 | SE_DDA_FIELD = ['applicationId(1)', 'applicationId(2)', 'bankName', 'companyName', 'customerName', 'idNum', 'accountHolderName', 'accountNo'] |
| ... | @@ -1817,8 +1819,11 @@ BS_EN = 'Bank Statement' | ... | @@ -1817,8 +1819,11 @@ BS_EN = 'Bank Statement' |
| 1817 | HIL_CONTRACT_1_EN = '售后回租合同' | 1819 | HIL_CONTRACT_1_EN = '售后回租合同' |
| 1818 | HIL_CONTRACT_2_EN = '车辆租赁抵押合同' | 1820 | HIL_CONTRACT_2_EN = '车辆租赁抵押合同' |
| 1819 | HIL_CONTRACT_3_EN = '车辆处置协议' | 1821 | HIL_CONTRACT_3_EN = '车辆处置协议' |
| 1822 | FS_EN = 'Financial Statement' | ||
| 1823 | FSS_EN = 'Financial Statement Supplementary' | ||
| 1820 | 1824 | ||
| 1821 | DDA_NO_FIND = '需人工查看DDA或截图' | 1825 | DDA_NO_FIND = '需人工查看DDA或截图' |
| 1826 | FS_NO_FIND = '未提供财报或财报不完整' | ||
| 1822 | 1827 | ||
| 1823 | SKIP_CARD = {SME_BL_EN} | 1828 | SKIP_CARD = {SME_BL_EN} |
| 1824 | 1829 | ||
| ... | @@ -2105,16 +2110,6 @@ HT_QRS_COMPARE_LOGIC = { | ... | @@ -2105,16 +2110,6 @@ HT_QRS_COMPARE_LOGIC = { |
| 2105 | '合同编号': ('合同编号', 'se_qrs_compare', {}, '请确认是否提供合格的送达地址确认书'), | 2110 | '合同编号': ('合同编号', 'se_qrs_compare', {}, '请确认是否提供合格的送达地址确认书'), |
| 2106 | } | 2111 | } |
| 2107 | 2112 | ||
| 2108 | FINANCIAL_STATEMENT_COMPARE_LOGIC = { | ||
| 2109 | 'Hash值': ('Hash值', '', {}, '财报Hash值与系统不一致'), | ||
| 2110 | '公章': ('公章', '', {}, '财报无公章'), | ||
| 2111 | } | ||
| 2112 | |||
| 2113 | FINANCIAL_STATEMENT_SUPPLEMENTARY_COMPARE_LOGIC = { | ||
| 2114 | '公司名称': ('公司名称', '', {}, '财报情况说明公司名称错误'), | ||
| 2115 | '公章': ('公章', '', {}, '财报情况说明无公章'), | ||
| 2116 | } | ||
| 2117 | |||
| 2118 | HT_COMPARE_LOGIC = { | 2113 | HT_COMPARE_LOGIC = { |
| 2119 | '合同编号-每页': ('合同编号-每页', 'se_list_compare', {}, '合同编号与系统不一致'), | 2114 | '合同编号-每页': ('合同编号-每页', 'se_list_compare', {}, '合同编号与系统不一致'), |
| 2120 | # '合同编号-每页(no-asp)': ('合同编号-每页', 'se_list_compare', {'pop_last': True}, '合同编号与系统不一致'), | 2115 | # '合同编号-每页(no-asp)': ('合同编号-每页', 'se_list_compare', {'pop_last': True}, '合同编号与系统不一致'), |
| ... | @@ -2169,6 +2164,15 @@ HT_COMPARE_LOGIC = { | ... | @@ -2169,6 +2164,15 @@ HT_COMPARE_LOGIC = { |
| 2169 | '无ASP产品': ('无ASP产品', 'se_self_compare_other_asp', {}, GZS_REASON_1), | 2164 | '无ASP产品': ('无ASP产品', 'se_self_compare_other_asp', {}, GZS_REASON_1), |
| 2170 | } | 2165 | } |
| 2171 | 2166 | ||
| 2167 | # 格式:'excel字段名':('数据库字段名','比对逻辑','特殊处理可以忽略','比对不合格时的返回内容') | ||
| 2168 | FS_COMPARE_LOGIC = { | ||
| 2169 | 'Hash值': ('code', 'hash_code_compare', {}, '财报Hash值与系统不一致'), | ||
| 2170 | '公章': ('stamp', 'stamp_dict_compare', {}, '财报无公章'), | ||
| 2171 | '财年': ('财年', 'fiscal_year_compare', {}, '财报所属财年错误'), | ||
| 2172 | '资产负债表内容': ('资产负债表内容', 'ocr_list_not_zero_compare', {}, '财报资产负债表为空'), | ||
| 2173 | '利润表内容': ('利润表内容', 'ocr_list_not_zero_compare', {}, '财报利润表为空'), | ||
| 2174 | } | ||
| 2175 | |||
| 2172 | AFC_HT_DATE_FIELDS = ['主借人日期', '共借人日期', '保证人日期1', '保证人日期2'] | 2176 | AFC_HT_DATE_FIELDS = ['主借人日期', '共借人日期', '保证人日期1', '保证人日期2'] |
| 2173 | 2177 | ||
| 2174 | # MVC_OCR_FIELD = 'mvc_ocr' | 2178 | # MVC_OCR_FIELD = 'mvc_ocr' |
| ... | @@ -2197,6 +2201,7 @@ SE_COMPARE_FIELD = { | ... | @@ -2197,6 +2201,7 @@ SE_COMPARE_FIELD = { |
| 2197 | HIL_CONTRACT_1_EN: (HIL_CONTRACT_1_FIELD, HIL_CONTRACT_1_COMPARE_LOGIC, False), | 2201 | HIL_CONTRACT_1_EN: (HIL_CONTRACT_1_FIELD, HIL_CONTRACT_1_COMPARE_LOGIC, False), |
| 2198 | HIL_CONTRACT_2_EN: (HIL_CONTRACT_2_FIELD, HIL_CONTRACT_2_COMPARE_LOGIC, False), | 2202 | HIL_CONTRACT_2_EN: (HIL_CONTRACT_2_FIELD, HIL_CONTRACT_2_COMPARE_LOGIC, False), |
| 2199 | HIL_CONTRACT_3_EN: (HIL_CONTRACT_3_FIELD, HIL_CONTRACT_3_COMPARE_LOGIC, False), | 2203 | HIL_CONTRACT_3_EN: (HIL_CONTRACT_3_FIELD, HIL_CONTRACT_3_COMPARE_LOGIC, False), |
| 2204 | FS_EN: (FS_FIELD, FS_COMPARE_LOGIC, False), | ||
| 2200 | } | 2205 | } |
| 2201 | 2206 | ||
| 2202 | SE_COMPARE_FIELD_AUTO = { | 2207 | SE_COMPARE_FIELD_AUTO = { | ... | ... |
| ... | @@ -953,6 +953,12 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d | ... | @@ -953,6 +953,12 @@ 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: | 953 | if individual_info['applicantType'] == consts.APPLICANT_TYPE_ORDER[0] and not is_corporate: |
| 954 | is_cdfl_bo = True | 954 | is_cdfl_bo = True |
| 955 | 955 | ||
| 956 | # CHINARPA-4660 是否公户判断 | ||
| 957 | is_bo_tccor = False | ||
| 958 | customersubType = individual_info.get('customersubType', '') | ||
| 959 | if individual_info['applicantType'] == consts.APPLICANT_TYPE_ORDER[0] and customersubType == 'TCCOR': | ||
| 960 | is_bo_tccor = True | ||
| 961 | |||
| 956 | for id_info in individual_info.get('IDInformation', []): | 962 | for id_info in individual_info.get('IDInformation', []): |
| 957 | if id_info.get('idType') in consts.SE_CMS_FIRST_ID_FIELD_MAPPING: | 963 | 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']] | 964 | license_en, is_prc = consts.SE_CMS_FIRST_ID_FIELD_MAPPING[id_info['idType']] |
| ... | @@ -1120,6 +1126,24 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d | ... | @@ -1120,6 +1126,24 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d |
| 1120 | # vehicle_info[consts.UCI_EN] = vehicle_field_input | 1126 | # vehicle_info[consts.UCI_EN] = vehicle_field_input |
| 1121 | compare_info['vehicleInfo'] = vehicle_info | 1127 | compare_info['vehicleInfo'] = vehicle_info |
| 1122 | 1128 | ||
| 1129 | # 公户财务报表------------------------------------------------------------------------------------------------- | ||
| 1130 | financial_statement_info = {} | ||
| 1131 | financial_statement_input = [] | ||
| 1132 | hashCode = cms_info.get('hashCode', '') | ||
| 1133 | fiscalYear = cms_info.get('fiscalYear', '') | ||
| 1134 | totalAssets = cms_info.get('totalAssets', 0) | ||
| 1135 | totalLiabilitiesAndOwnersEquity = cms_info.get('totalLiabilitiesAndOwnersEquity', 0) | ||
| 1136 | netProfit = cms_info.get('netProfit', 0) | ||
| 1137 | if is_bo_tccor: | ||
| 1138 | financial_statement_input.append((consts.SE_FS_FIELD[0], hashCode)) | ||
| 1139 | financial_statement_input.append((consts.SE_FS_FIELD[1], consts.SE_STAMP_VALUE)) | ||
| 1140 | financial_statement_input.append((consts.SE_FS_FIELD[2], fiscalYear)) | ||
| 1141 | financial_statement_input.append((consts.SE_FS_FIELD[3], [totalAssets, totalLiabilitiesAndOwnersEquity])) | ||
| 1142 | financial_statement_input.append((consts.SE_FS_FIELD[4], netProfit)) | ||
| 1143 | financial_statement_info[consts.FS_EN] = financial_statement_input | ||
| 1144 | compare_info['financialStatementInfo'] = financial_statement_info | ||
| 1145 | |||
| 1146 | |||
| 1123 | # 银行卡------------------------------------------------------------------------------------------------------- | 1147 | # 银行卡------------------------------------------------------------------------------------------------------- |
| 1124 | bank_info = {} | 1148 | bank_info = {} |
| 1125 | bank_name = cms_info.get('bankAccountDetails', {}).get('bankName', '') | 1149 | bank_name = cms_info.get('bankAccountDetails', {}).get('bankName', '') |
| ... | @@ -2523,6 +2547,107 @@ def se_compare_license(license_en, ocr_res_dict, field_list): | ... | @@ -2523,6 +2547,107 @@ def se_compare_license(license_en, ocr_res_dict, field_list): |
| 2523 | 2547 | ||
| 2524 | return result_field_list, no_ocr_result, field_img_path_dict | 2548 | return result_field_list, no_ocr_result, field_img_path_dict |
| 2525 | 2549 | ||
| 2550 | def se_fs_compare(license_en, ocr_res_dict, field_list): | ||
| 2551 | ocr_field, compare_logic, special_expiry_date = consts.SE_COMPARE_FIELD[license_en] | ||
| 2552 | |||
| 2553 | is_find = False | ||
| 2554 | no_ocr_result = False | ||
| 2555 | special_expiry_date_slice = False | ||
| 2556 | result_field_list = [] | ||
| 2557 | section_img_info = dict() | ||
| 2558 | field_img_path_dict = dict() | ||
| 2559 | ocr_res_str = ocr_res_dict.get(ocr_field) | ||
| 2560 | if ocr_res_str is not None: | ||
| 2561 | ocr_res_list = json.loads(ocr_res_str) | ||
| 2562 | |||
| 2563 | length = len(ocr_res_list) | ||
| 2564 | |||
| 2565 | # 先判断最后一次上传的文件是不是包括3个,如果不是直接返回"未提供财报或财报不完整" | ||
| 2566 | last_ocr_str = ocr_res_list[length-1] | ||
| 2567 | if len(last_ocr_str.get('code',{})) != 3 or len(last_ocr_str.get('stamp',{})) != 3: | ||
| 2568 | compare_log.info('{0} [se_fs_compare] last ocr result len < 3'.format(log_base)) | ||
| 2569 | else: | ||
| 2570 | for res_idx in range(length-1, -1, -1): | ||
| 2571 | if is_find: | ||
| 2572 | break | ||
| 2573 | |||
| 2574 | for idx, (name, value) in enumerate(field_list): | ||
| 2575 | ocr_str = ocr_res_list[res_idx].get(compare_logic[name][0]) | ||
| 2576 | |||
| 2577 | #hash值/公章 不需要ocr结果,所以即使为空也可以进入比对 | ||
| 2578 | if isinstance(ocr_str, str) or ocr_str == 'code' or ocr_str == 'stamp': | ||
| 2579 | result = getattr(cp, compare_logic[name][1])(value, ocr_str, **compare_logic[name][2]) | ||
| 2580 | no_key = False | ||
| 2581 | else: | ||
| 2582 | result = consts.RESULT_N | ||
| 2583 | ocr_str = empty_str | ||
| 2584 | no_key = True | ||
| 2585 | |||
| 2586 | if idx == 0 and result == consts.RESULT_N and length > 1: | ||
| 2587 | break | ||
| 2588 | |||
| 2589 | is_find = True | ||
| 2590 | section_img_info[consts.SECTION_IMG_PATH_KEY] = ocr_res_list[res_idx].get(consts.SECTION_IMG_PATH_KEY, '') | ||
| 2591 | section_img_info[consts.ALL_POSITION_KEY] = ocr_res_list[res_idx].get(consts.ALL_POSITION_KEY, {}) | ||
| 2592 | if special_expiry_date: | ||
| 2593 | section_img_info[consts.SECTION_IMG_PATH_KEY_2] = ocr_res_list[res_idx].get( | ||
| 2594 | consts.SECTION_IMG_PATH_KEY_2, '') | ||
| 2595 | section_img_info[consts.ALL_POSITION_KEY_2] = ocr_res_list[res_idx].get(consts.ALL_POSITION_KEY_2, {}) | ||
| 2596 | |||
| 2597 | img_path = ocr_res_list[res_idx].get(consts.IMG_PATH_KEY, '') if result == consts.RESULT_N else empty_str | ||
| 2598 | if isinstance(value, list): | ||
| 2599 | value = json.dumps(value, ensure_ascii=False) | ||
| 2600 | error_type = empty_error_type if result == consts.RESULT_Y else ErrorType.OCR.value | ||
| 2601 | result_field_list.append((name, value, result, ocr_str, img_path, error_type, compare_logic[name][3])) | ||
| 2602 | else: | ||
| 2603 | no_ocr_result = True | ||
| 2604 | |||
| 2605 | if not is_find: | ||
| 2606 | for name, value in field_list: | ||
| 2607 | if isinstance(value, list): | ||
| 2608 | value = json.dumps(value, ensure_ascii=False) | ||
| 2609 | no_find_str = consts.FS_NO_FIND | ||
| 2610 | result_field_list.append((name, value, consts.RESULT_N, empty_str, empty_str, ErrorType.NF.value, no_find_str)) | ||
| 2611 | |||
| 2612 | if is_find: | ||
| 2613 | section_img_path = section_img_info.get(consts.SECTION_IMG_PATH_KEY, '') | ||
| 2614 | if os.path.exists(section_img_path): | ||
| 2615 | failed_field = [] | ||
| 2616 | base_img_path = empty_str | ||
| 2617 | for name, _, result, _, img_path, _, _ in result_field_list: | ||
| 2618 | if result == consts.RESULT_N: | ||
| 2619 | if special_expiry_date_slice and name == 'idExpiryDate': | ||
| 2620 | continue | ||
| 2621 | failed_field.append(name) | ||
| 2622 | if base_img_path == empty_str: | ||
| 2623 | base_img_path = img_path | ||
| 2624 | if len(failed_field) > 0: | ||
| 2625 | info = section_img_info.get(consts.ALL_POSITION_KEY, {}) | ||
| 2626 | section_position = info.get(consts.POSITION_KEY, {}) | ||
| 2627 | section_angle = info.get(consts.ANGLE_KEY, 0) | ||
| 2628 | try: | ||
| 2629 | last_img = img_process(section_img_path, section_position, section_angle) | ||
| 2630 | except Exception as e: | ||
| 2631 | for field in failed_field: | ||
| 2632 | field_img_path_dict[field] = base_img_path | ||
| 2633 | else: | ||
| 2634 | pre, suf = os.path.splitext(section_img_path) | ||
| 2635 | for field in failed_field: | ||
| 2636 | try: | ||
| 2637 | res_field = compare_logic[field][0] | ||
| 2638 | is_valid, coord_tuple = field_build_coordinates(info.get(res_field, {})) | ||
| 2639 | if is_valid: | ||
| 2640 | save_path = '{0}_{1}{2}'.format(pre, field, suf) | ||
| 2641 | field_img = last_img[coord_tuple[0]:coord_tuple[1], coord_tuple[2]:coord_tuple[3], :] | ||
| 2642 | cv2.imwrite(save_path, field_img) | ||
| 2643 | field_img_path_dict[field] = save_path | ||
| 2644 | else: | ||
| 2645 | field_img_path_dict[field] = base_img_path | ||
| 2646 | except Exception as e: | ||
| 2647 | field_img_path_dict[field] = base_img_path | ||
| 2648 | |||
| 2649 | return result_field_list, field_img_path_dict | ||
| 2650 | |||
| 2526 | 2651 | ||
| 2527 | def se_compare_license_id(license_en, id_res_list, field_list, is_auto): | 2652 | def se_compare_license_id(license_en, id_res_list, field_list, is_auto): |
| 2528 | if is_auto: | 2653 | if is_auto: |
| ... | @@ -3023,6 +3148,7 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list | ... | @@ -3023,6 +3148,7 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list |
| 3023 | rpa_failure_reason = {} | 3148 | rpa_failure_reason = {} |
| 3024 | field_result_dict = {} | 3149 | field_result_dict = {} |
| 3025 | 3150 | ||
| 3151 | # compare_info 格式: {'financialStatementInfo': {'Financial Statement': [('11', '22'), ('111', '222'), ('1111', '2222')]}} | ||
| 3026 | for info_key, info_value in compare_info.items(): | 3152 | for info_key, info_value in compare_info.items(): |
| 3027 | if info_key in ['individualCusInfo', 'applicantInformation']: | 3153 | if info_key in ['individualCusInfo', 'applicantInformation']: |
| 3028 | for idx, license_list in info_value.items(): | 3154 | for idx, license_list in info_value.items(): |
| ... | @@ -3104,6 +3230,8 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list | ... | @@ -3104,6 +3230,8 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list |
| 3104 | result_field_list, field_img_path_dict = se_contract_qrs_compare(license_en, ocr_res_dict, strip_list) | 3230 | result_field_list, field_img_path_dict = se_contract_qrs_compare(license_en, ocr_res_dict, strip_list) |
| 3105 | elif license_en == consts.BS_EN: | 3231 | elif license_en == consts.BS_EN: |
| 3106 | result_field_list, field_img_path_dict = se_bs_compare(license_en, ocr_res_dict, strip_list, is_auto, aa_type) | 3232 | result_field_list, field_img_path_dict = se_bs_compare(license_en, ocr_res_dict, strip_list, is_auto, aa_type) |
| 3233 | elif license_en == consts.FS_EN: | ||
| 3234 | result_field_list, field_img_path_dict = se_fs_compare(license_en, ocr_res_dict, strip_list, is_auto, aa_type) | ||
| 3107 | else: | 3235 | else: |
| 3108 | result_field_list, _, field_img_path_dict = se_compare_license(license_en, ocr_res_dict, strip_list) | 3236 | result_field_list, _, field_img_path_dict = se_compare_license(license_en, ocr_res_dict, strip_list) |
| 3109 | 3237 | ... | ... |
| ... | @@ -676,6 +676,50 @@ class Comparison: | ... | @@ -676,6 +676,50 @@ class Comparison: |
| 676 | except Exception as e: | 676 | except Exception as e: |
| 677 | return self.RESULT_N | 677 | return self.RESULT_N |
| 678 | 678 | ||
| 679 | def hash_code_compare(self, input_str, ocr_dict, **kwargs): | ||
| 680 | try: | ||
| 681 | balance_sheet_hash = ocr_dict.get('balance_sheet','') | ||
| 682 | income_statement_hash = ocr_dict.get('income_statement','') | ||
| 683 | cash_flow_statement_hash = ocr_dict.get('cash_flow_statement','') | ||
| 684 | if balance_sheet_hash != input_str or income_statement_hash != input_str or cash_flow_statement_hash != input_str: | ||
| 685 | return self.RESULT_N | ||
| 686 | else: | ||
| 687 | return self.RESULT_Y | ||
| 688 | except Exception as e: | ||
| 689 | return self.RESULT_N | ||
| 690 | |||
| 691 | def stamp_dict_compare(self, input_str, ocr_dict, **kwargs): | ||
| 692 | try: | ||
| 693 | balance_sheet_stamp = ocr_dict.get('balance_sheet','') | ||
| 694 | income_statement_stamp = ocr_dict.get('income_statement','') | ||
| 695 | cash_flow_statement_stamp = ocr_dict.get('cash_flow_statement','') | ||
| 696 | if balance_sheet_stamp != 1 or income_statement_stamp != 1 or cash_flow_statement_stamp != 1: | ||
| 697 | return self.RESULT_N | ||
| 698 | else: | ||
| 699 | return self.RESULT_Y | ||
| 700 | except Exception as e: | ||
| 701 | return self.RESULT_N | ||
| 702 | |||
| 703 | def fiscal_year_compare(self, input_str, ocr_list, **kwargs): | ||
| 704 | try: | ||
| 705 | this_year_str = datetime.now().strftime('%Y') | ||
| 706 | this_year = int(this_year_str) | ||
| 707 | last_year = this_year - 1 | ||
| 708 | if input_str != this_year and input_str != last_year: | ||
| 709 | return self.RESULT_N | ||
| 710 | return self.RESULT_Y | ||
| 711 | except Exception as e: | ||
| 712 | return self.RESULT_N | ||
| 713 | |||
| 714 | def input_list_not_zero_compare(self, input_list, ocr_list, **kwargs): | ||
| 715 | try: | ||
| 716 | for item in input_list: | ||
| 717 | if item == 0: | ||
| 718 | return self.RESULT_N | ||
| 719 | return self.RESULT_Y | ||
| 720 | except Exception as e: | ||
| 721 | return self.RESULT_N | ||
| 722 | |||
| 679 | 723 | ||
| 680 | cp = Comparison() | 724 | cp = Comparison() |
| 681 | 725 | ... | ... |
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() |
-
Please register or sign in to post a comment