Merge branch 'hotfix/2025-02'
Showing
3 changed files
with
68 additions
and
29 deletions
... | @@ -2130,9 +2130,19 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -2130,9 +2130,19 @@ class Command(BaseCommand, LoggerMixin): |
2130 | # 更新OCR累计识别结果表 | 2130 | # 更新OCR累计识别结果表 |
2131 | if business_type == consts.HIL_PREFIX: | 2131 | if business_type == consts.HIL_PREFIX: |
2132 | result_class = HILOCRResult if is_ca else HILSEOCRResult | 2132 | result_class = HILOCRResult if is_ca else HILSEOCRResult |
2133 | try: | ||
2134 | res_obj = atomicSaveDBHIL(self,result_class,doc,license_summary,ic_merge,rp_merge, task_str, financial_statement_dict, financial_explanation_dict) | ||
2135 | except Exception as e: | ||
2136 | # 遇到报错重试一次,希望解决两个文件首次入库都插入的问题 | ||
2137 | self.online_log.error('{0} [process error (ocr result save) retry] [task={1}] [error={2}]'.format(self.log_base, task_str, traceback.format_exc())) | ||
2133 | res_obj = atomicSaveDBHIL(self,result_class,doc,license_summary,ic_merge,rp_merge, task_str, financial_statement_dict, financial_explanation_dict) | 2138 | res_obj = atomicSaveDBHIL(self,result_class,doc,license_summary,ic_merge,rp_merge, task_str, financial_statement_dict, financial_explanation_dict) |
2134 | else: | 2139 | else: |
2135 | result_class = AFCOCRResult if is_ca else AFCSEOCRResult | 2140 | result_class = AFCOCRResult if is_ca else AFCSEOCRResult |
2141 | try: | ||
2142 | res_obj = atomicSaveDBAFC(self,result_class,doc,license_summary,ic_merge,rp_merge, task_str, financial_statement_dict, financial_explanation_dict) | ||
2143 | except Exception as e: | ||
2144 | # 遇到报错重试一次,希望解决两个文件首次入库都插入的问题 | ||
2145 | self.online_log.error('{0} [process error (ocr result save) retry] [task={1}] [error={2}]'.format(self.log_base, task_str, traceback.format_exc())) | ||
2136 | res_obj = atomicSaveDBAFC(self,result_class,doc,license_summary,ic_merge,rp_merge, task_str, financial_statement_dict, financial_explanation_dict) | 2146 | res_obj = atomicSaveDBAFC(self,result_class,doc,license_summary,ic_merge,rp_merge, task_str, financial_statement_dict, financial_explanation_dict) |
2137 | 2147 | ||
2138 | except Exception as e: | 2148 | except Exception as e: |
... | @@ -2172,9 +2182,19 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -2172,9 +2182,19 @@ class Command(BaseCommand, LoggerMixin): |
2172 | # 更新OCR累计识别结果表 | 2182 | # 更新OCR累计识别结果表 |
2173 | if business_type == consts.HIL_PREFIX: | 2183 | if business_type == consts.HIL_PREFIX: |
2174 | result_class = HILOCRResult if is_ca else HILSEOCRResult | 2184 | result_class = HILOCRResult if is_ca else HILSEOCRResult |
2185 | try: | ||
2186 | res_obj = atomicSaveDBHIL(self,result_class,doc,license_summary,ic_merge,rp_merge, task_str, financial_statement_dict, financial_explanation_dict) | ||
2187 | except Exception as e: | ||
2188 | # 遇到报错重试一次,希望解决两个文件首次入库都插入的问题 | ||
2189 | self.online_log.error('{0} [process error (ocr result save) retry] [task={1}] [error={2}]'.format(self.log_base, task_str, traceback.format_exc())) | ||
2175 | res_obj = atomicSaveDBHIL(self,result_class,doc,license_summary,ic_merge,rp_merge, task_str, financial_statement_dict, financial_explanation_dict) | 2190 | res_obj = atomicSaveDBHIL(self,result_class,doc,license_summary,ic_merge,rp_merge, task_str, financial_statement_dict, financial_explanation_dict) |
2176 | else: | 2191 | else: |
2177 | result_class = AFCOCRResult if is_ca else AFCSEOCRResult | 2192 | result_class = AFCOCRResult if is_ca else AFCSEOCRResult |
2193 | try: | ||
2194 | res_obj = atomicSaveDBAFC(self,result_class,doc,license_summary,ic_merge,rp_merge, task_str, financial_statement_dict, financial_explanation_dict) | ||
2195 | except Exception as e: | ||
2196 | # 遇到报错重试一次,希望解决两个文件首次入库都插入的问题 | ||
2197 | self.online_log.error('{0} [process error (ocr result save) retry] [task={1}] [error={2}]'.format(self.log_base, task_str, traceback.format_exc())) | ||
2178 | res_obj = atomicSaveDBAFC(self,result_class,doc,license_summary,ic_merge,rp_merge, task_str, financial_statement_dict, financial_explanation_dict) | 2198 | res_obj = atomicSaveDBAFC(self,result_class,doc,license_summary,ic_merge,rp_merge, task_str, financial_statement_dict, financial_explanation_dict) |
2179 | except Exception as e: | 2199 | except Exception as e: |
2180 | self.online_log.error( | 2200 | self.online_log.error( | ... | ... |
... | @@ -3773,20 +3773,29 @@ def fsm_compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca= | ... | @@ -3773,20 +3773,29 @@ def fsm_compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca= |
3773 | 3773 | ||
3774 | compare_log.info('[fsm thread]') | 3774 | compare_log.info('[fsm thread]') |
3775 | #pool = ThreadPoolExecutor(max_workers=6, thread_name_prefix="fsm_thread_") | 3775 | #pool = ThreadPoolExecutor(max_workers=6, thread_name_prefix="fsm_thread_") |
3776 | try: | ||
3777 | # 这个try不生效 | ||
3776 | pool.submit(fsm_compare_thread, application_id, application_entity, uniq_seq, ocr_res_id, is_ca, is_cms) | 3778 | pool.submit(fsm_compare_thread, application_id, application_entity, uniq_seq, ocr_res_id, is_ca, is_cms) |
3779 | except Exception as e: | ||
3780 | compare_log.info('[fsm thread fail] [error={0}]'.format(traceback.format_exc())) | ||
3777 | #pool.shutdown(wait=True) | 3781 | #pool.shutdown(wait=True) |
3778 | 3782 | ||
3779 | 3783 | ||
3780 | def fsm_compare_thread(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True, is_cms=False): | 3784 | def fsm_compare_thread(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True, is_cms=False): |
3785 | try: | ||
3781 | compare_log.info('{0} [receive fsm task] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}] [is_ca={5}] ' | 3786 | compare_log.info('{0} [receive fsm task] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}] [is_ca={5}] ' |
3782 | '[is_cms={6}]'.format(log_base, application_entity, application_id, uniq_seq, ocr_res_id, | 3787 | '[is_cms={6}]'.format(log_base, application_entity, application_id, uniq_seq, ocr_res_id, |
3783 | is_ca, is_cms)) | 3788 | is_ca, is_cms)) |
3784 | 3789 | ||
3785 | # 查看此订单号下是否有未完成的文件,如果有,等1分钟 | 3790 | # 查看此订单号下是否有未完成的文件,如果有,等1分钟 |
3791 | try: | ||
3786 | doc_wait_file_class = HILDoc if application_entity == consts.HIL_PREFIX else AFCDoc | 3792 | doc_wait_file_class = HILDoc if application_entity == consts.HIL_PREFIX else AFCDoc |
3787 | doc_wait_file_result = doc_wait_file_class.objects.filter(application_id=application_id, status=1).first() | 3793 | doc_wait_file_result = doc_wait_file_class.objects.filter(application_id=application_id, status=1).first() |
3788 | compare_log.info('doc_wait_file_result:{0}'.format(doc_wait_file_result)) | 3794 | compare_log.info('doc_wait_file_result:{0}'.format(doc_wait_file_result)) |
3789 | 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)) | 3795 | 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)) |
3796 | except Exception as e: | ||
3797 | doc_wait_file_result = None | ||
3798 | compare_log.info('[get doc_wait_file_result fail] [error={0}]'.format(traceback.format_exc())) | ||
3790 | if doc_wait_file_result is not None: | 3799 | if doc_wait_file_result is not None: |
3791 | # 实时查询延迟时间 | 3800 | # 实时查询延迟时间 |
3792 | try: | 3801 | try: |
... | @@ -3806,7 +3815,6 @@ def fsm_compare_thread(application_id, application_entity, uniq_seq, ocr_res_id, | ... | @@ -3806,7 +3815,6 @@ def fsm_compare_thread(application_id, application_entity, uniq_seq, ocr_res_id, |
3806 | compare_log.info('[sleep error] [error={0}]'.format(traceback.format_exc())) | 3815 | compare_log.info('[sleep error] [error={0}]'.format(traceback.format_exc())) |
3807 | 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)) | 3816 | 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)) |
3808 | 3817 | ||
3809 | |||
3810 | # 调用java fsm 比对流程接口(http) | 3818 | # 调用java fsm 比对流程接口(http) |
3811 | # 调用Java fsm 比对流程接口, fsm 是se流程, ca可以暂时忽略 | 3819 | # 调用Java fsm 比对流程接口, fsm 是se流程, ca可以暂时忽略 |
3812 | auto_class = HILAutoSettlement if application_entity == consts.HIL_PREFIX else AFCAutoSettlement | 3820 | auto_class = HILAutoSettlement if application_entity == consts.HIL_PREFIX else AFCAutoSettlement |
... | @@ -3835,6 +3843,8 @@ def fsm_compare_thread(application_id, application_entity, uniq_seq, ocr_res_id, | ... | @@ -3835,6 +3843,8 @@ def fsm_compare_thread(application_id, application_entity, uniq_seq, ocr_res_id, |
3835 | except Exception as e: | 3843 | except Exception as e: |
3836 | compare_log.error("fsm full request to java error, url:{0}, param:{1}, errorMsg:{2}".format( | 3844 | compare_log.error("fsm full request to java error, url:{0}, param:{1}, errorMsg:{2}".format( |
3837 | url, json.dumps(body), traceback.format_exc())) | 3845 | url, json.dumps(body), traceback.format_exc())) |
3846 | except Exception as e: | ||
3847 | compare_log.info('[fsm_compare_thread error] [error={0}]'.format(traceback.format_exc())) | ||
3838 | 3848 | ||
3839 | 3849 | ||
3840 | @app.task | 3850 | @app.task |
... | @@ -3851,42 +3861,21 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True | ... | @@ -3851,42 +3861,21 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True |
3851 | 3861 | ||
3852 | compare_log.info('[non fsm thread]') | 3862 | compare_log.info('[non fsm thread]') |
3853 | #pool = ThreadPoolExecutor(max_workers=6, thread_name_prefix="non_fsm_thread_") | 3863 | #pool = ThreadPoolExecutor(max_workers=6, thread_name_prefix="non_fsm_thread_") |
3864 | try: | ||
3865 | # 这个try不生效 | ||
3854 | pool.submit(compare_thread, application_id, application_entity, uniq_seq, ocr_res_id, is_ca, is_cms) | 3866 | pool.submit(compare_thread, application_id, application_entity, uniq_seq, ocr_res_id, is_ca, is_cms) |
3867 | except Exception as e: | ||
3868 | compare_log.info('[non fsm thread fail] [error={0}]'.format(traceback.format_exc())) | ||
3855 | #pool.shutdown(wait=True) | 3869 | #pool.shutdown(wait=True) |
3856 | 3870 | ||
3857 | def compare_thread(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True, is_cms=False): | 3871 | def compare_thread(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True, is_cms=False): |
3858 | # POS: application_id, application_entity, uniq_seq, None | 3872 | # POS: application_id, application_entity, uniq_seq, None |
3859 | # OCR: application_id, business_type(application_entity), None, ocr_res_id | 3873 | # OCR: application_id, business_type(application_entity), None, ocr_res_id |
3860 | 3874 | try: | |
3861 | compare_log.info('{0} [receive task] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}] [is_ca={5}] ' | 3875 | compare_log.info('{0} [receive task] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}] [is_ca={5}] ' |
3862 | '[is_cms={6}]'.format(log_base, application_entity, application_id, uniq_seq, ocr_res_id, | 3876 | '[is_cms={6}]'.format(log_base, application_entity, application_id, uniq_seq, ocr_res_id, |
3863 | is_ca, is_cms)) | 3877 | is_ca, is_cms)) |
3864 | 3878 | ||
3865 | # 查看此订单号下是否有未完成的文件,如果有,等?分钟 | ||
3866 | doc_wait_file_class = HILDoc if application_entity == consts.HIL_PREFIX else AFCDoc | ||
3867 | doc_wait_file_result = doc_wait_file_class.objects.filter(application_id=application_id, status=1).first() | ||
3868 | compare_log.info('doc_wait_file_result:{0}'.format(doc_wait_file_result)) | ||
3869 | 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)) | ||
3870 | if doc_wait_file_result is not None: | ||
3871 | # 实时查询延迟时间 | ||
3872 | try: | ||
3873 | delay_time_config = Configs.objects.filter(id=4).first() | ||
3874 | if delay_time_config is not None and delay_time_config.value is not None and delay_time_config.value.isdigit(): | ||
3875 | delay_time = delay_time_config.value | ||
3876 | else: | ||
3877 | delay_time = 0 | ||
3878 | except Exception as e: | ||
3879 | delay_time = 0 | ||
3880 | compare_log.info('[get delay_time_config fail] [error={0}]'.format(traceback.format_exc())) | ||
3881 | compare_log.info('delay_time:{0}'.format(delay_time)) | ||
3882 | 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)) | ||
3883 | try: | ||
3884 | time.sleep(int(delay_time)) | ||
3885 | except Exception as e: | ||
3886 | compare_log.info('[sleep error] [error={0}]'.format(traceback.format_exc())) | ||
3887 | 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)) | ||
3888 | |||
3889 | |||
3890 | # 根据application_id查找最新的比对信息,如果没有,结束 | 3879 | # 根据application_id查找最新的比对信息,如果没有,结束 |
3891 | if is_ca: | 3880 | if is_ca: |
3892 | comparison_class = HILComparisonInfo if application_entity == consts.HIL_PREFIX else AFCComparisonInfo | 3881 | comparison_class = HILComparisonInfo if application_entity == consts.HIL_PREFIX else AFCComparisonInfo |
... | @@ -3925,6 +3914,35 @@ def compare_thread(application_id, application_entity, uniq_seq, ocr_res_id, is_ | ... | @@ -3925,6 +3914,35 @@ def compare_thread(application_id, application_entity, uniq_seq, ocr_res_id, is_ |
3925 | uniq_seq, ocr_res_id, is_ca, is_cms)) | 3914 | uniq_seq, ocr_res_id, is_ca, is_cms)) |
3926 | return | 3915 | return |
3927 | 3916 | ||
3917 | # 查看此订单号下是否有未完成的文件,如果有,等?分钟 | ||
3918 | try: | ||
3919 | doc_wait_file_class = HILDoc if application_entity == consts.HIL_PREFIX else AFCDoc | ||
3920 | doc_wait_file_result = doc_wait_file_class.objects.filter(application_id=application_id, status=1).first() | ||
3921 | compare_log.info('doc_wait_file_result:{0}'.format(doc_wait_file_result)) | ||
3922 | 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)) | ||
3923 | except Exception as e: | ||
3924 | doc_wait_file_result = None | ||
3925 | compare_log.info('[get doc_wait_file_result fail] [error={0}]'.format(traceback.format_exc())) | ||
3926 | if doc_wait_file_result is not None: | ||
3927 | # 实时查询延迟时间 | ||
3928 | try: | ||
3929 | delay_time_config = Configs.objects.filter(id=4).first() | ||
3930 | if delay_time_config is not None and delay_time_config.value is not None and delay_time_config.value.isdigit(): | ||
3931 | delay_time = delay_time_config.value | ||
3932 | else: | ||
3933 | delay_time = 0 | ||
3934 | except Exception as e: | ||
3935 | delay_time = 0 | ||
3936 | compare_log.info('[get delay_time_config fail] [error={0}]'.format(traceback.format_exc())) | ||
3937 | compare_log.info('delay_time:{0}'.format(delay_time)) | ||
3938 | 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)) | ||
3939 | try: | ||
3940 | time.sleep(int(delay_time)) | ||
3941 | except Exception as e: | ||
3942 | compare_log.info('[sleep error] [error={0}]'.format(traceback.format_exc())) | ||
3943 | 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)) | ||
3944 | |||
3945 | |||
3928 | if is_ca: | 3946 | if is_ca: |
3929 | ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict) | 3947 | ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict) |
3930 | else: | 3948 | else: |
... | @@ -3969,4 +3987,5 @@ def compare_thread(application_id, application_entity, uniq_seq, ocr_res_id, is_ | ... | @@ -3969,4 +3987,5 @@ def compare_thread(application_id, application_entity, uniq_seq, ocr_res_id, is_ |
3969 | compare_log.error('{0} [Auto SE] [result save error] [entity={1}] [id={2}] [ocr_res_id={3}] ' | 3987 | compare_log.error('{0} [Auto SE] [result save error] [entity={1}] [id={2}] [ocr_res_id={3}] ' |
3970 | '[error={4}]'.format(log_base, application_entity, application_id, ocr_res_id, | 3988 | '[error={4}]'.format(log_base, application_entity, application_id, ocr_res_id, |
3971 | traceback.format_exc())) | 3989 | traceback.format_exc())) |
3972 | 3990 | except Exception as e: | |
3991 | compare_log.info('[compare_thread error] [error={0}]'.format(traceback.format_exc())) | ... | ... |
... | @@ -102,7 +102,7 @@ for db_setting in DATABASES.values(): | ... | @@ -102,7 +102,7 @@ for db_setting in DATABASES.values(): |
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" |
104 | } | 104 | } |
105 | 105 | db_setting['CONN_MAX_AGE'] = 60 | |
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 | ... | ... |
-
Please register or sign in to post a comment