fix db bug
Showing
1 changed file
with
24 additions
and
11 deletions
| ... | @@ -55,14 +55,14 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -55,14 +55,14 @@ class Command(BaseCommand, LoggerMixin): |
| 55 | def signal_handler(self, sig, frame): | 55 | def signal_handler(self, sig, frame): |
| 56 | self.switch = False # 停止处理文件 | 56 | self.switch = False # 停止处理文件 |
| 57 | 57 | ||
| 58 | def get_doc_object(self, task_str): | 58 | # def get_doc_object(self, task_str): |
| 59 | business_type, doc_id_str = task_str.split(consts.SPLIT_STR) | 59 | # business_type, doc_id_str = task_str.split(consts.SPLIT_STR) |
| 60 | doc_id = int(doc_id_str) | 60 | # doc_id = int(doc_id_str) |
| 61 | doc_class = HILDoc if business_type == consts.HIL_PREFIX else AFCDoc | 61 | # doc_class = HILDoc if business_type == consts.HIL_PREFIX else AFCDoc |
| 62 | # doc_info = doc_class.objects.filter(id=doc_id, status=DocStatus.INIT.value).values( | 62 | # # doc_info = doc_class.objects.filter(id=doc_id, status=DocStatus.INIT.value).values( |
| 63 | # 'id', 'metadata_version_id', 'application_id', 'document_name', 'document_scheme').first() | 63 | # # 'id', 'metadata_version_id', 'application_id', 'document_name', 'document_scheme').first() |
| 64 | doc = doc_class.objects.filter(id=doc_id).first() | 64 | # doc = doc_class.objects.filter(id=doc_id).first() |
| 65 | return doc, business_type | 65 | # return doc, business_type |
| 66 | 66 | ||
| 67 | def get_doc_info(self): | 67 | def get_doc_info(self): |
| 68 | task_str, is_priority = rh.dequeue() | 68 | task_str, is_priority = rh.dequeue() |
| ... | @@ -73,7 +73,12 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -73,7 +73,12 @@ class Command(BaseCommand, LoggerMixin): |
| 73 | self.cronjob_log.info('{0} [get_doc_info] [task={1}] [is_priority={2}]'.format( | 73 | self.cronjob_log.info('{0} [get_doc_info] [task={1}] [is_priority={2}]'.format( |
| 74 | self.log_base, task_str, is_priority)) | 74 | self.log_base, task_str, is_priority)) |
| 75 | try: | 75 | try: |
| 76 | doc, business_type = self.get_doc_object(task_str) | 76 | # doc, business_type = self.get_doc_object(task_str) |
| 77 | business_type, doc_id_str = task_str.split(consts.SPLIT_STR) | ||
| 78 | doc_id = int(doc_id_str) | ||
| 79 | doc_class = HILDoc if business_type == consts.HIL_PREFIX else AFCDoc | ||
| 80 | doc = doc_class.objects.filter(id=doc_id).first() | ||
| 81 | |||
| 77 | if doc is None: | 82 | if doc is None: |
| 78 | self.cronjob_log.warn('{0} [get_doc_info] [doc not exist] [task_str={1}] [is_priority={2}]'.format( | 83 | self.cronjob_log.warn('{0} [get_doc_info] [doc not exist] [task_str={1}] [is_priority={2}]'.format( |
| 79 | self.log_base, task_str, is_priority)) | 84 | self.log_base, task_str, is_priority)) |
| ... | @@ -627,7 +632,11 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -627,7 +632,11 @@ class Command(BaseCommand, LoggerMixin): |
| 627 | del unknown_summary | 632 | del unknown_summary |
| 628 | 633 | ||
| 629 | # 4.2 重构Excel文件 | 634 | # 4.2 重构Excel文件 |
| 630 | doc, business_type = self.get_doc_object(task_str) | 635 | # doc, business_type = self.get_doc_object(task_str) |
| 636 | business_type, doc_id_str = task_str.split(consts.SPLIT_STR) | ||
| 637 | doc_id = int(doc_id_str) | ||
| 638 | doc_class = HILDoc if business_type == consts.HIL_PREFIX else AFCDoc | ||
| 639 | doc = doc_class.objects.filter(id=doc_id).first() | ||
| 631 | doc_data_path = os.path.join(self.data_dir, business_type, consts.TMP_DIR_NAME, str(doc.id)) | 640 | doc_data_path = os.path.join(self.data_dir, business_type, consts.TMP_DIR_NAME, str(doc.id)) |
| 632 | excel_path = os.path.join(doc_data_path, '{0}.xlsx'.format(doc.id)) | 641 | excel_path = os.path.join(doc_data_path, '{0}.xlsx'.format(doc.id)) |
| 633 | # src_excel_path = os.path.join(doc_data_path, 'src.xlsx') | 642 | # src_excel_path = os.path.join(doc_data_path, 'src.xlsx') |
| ... | @@ -639,7 +648,11 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -639,7 +648,11 @@ class Command(BaseCommand, LoggerMixin): |
| 639 | with lock: | 648 | with lock: |
| 640 | if task_str in res_dict: | 649 | if task_str in res_dict: |
| 641 | del res_dict[task_str] | 650 | del res_dict[task_str] |
| 642 | doc, business_type = self.get_doc_object(task_str) | 651 | # doc, business_type = self.get_doc_object(task_str) |
| 652 | business_type, doc_id_str = task_str.split(consts.SPLIT_STR) | ||
| 653 | doc_id = int(doc_id_str) | ||
| 654 | doc_class = HILDoc if business_type == consts.HIL_PREFIX else AFCDoc | ||
| 655 | doc = doc_class.objects.filter(id=doc_id).first() | ||
| 643 | doc.status = DocStatus.PROCESS_FAILED.value | 656 | doc.status = DocStatus.PROCESS_FAILED.value |
| 644 | doc.save() | 657 | doc.save() |
| 645 | self.cronjob_log.warn('{0} [process failed (res to wb)] [task={1}] [error={2}]'.format( | 658 | self.cronjob_log.warn('{0} [process failed (res to wb)] [task={1}] [error={2}]'.format( | ... | ... |
-
Please register or sign in to post a comment