e3d719b8 by 周伟奇

fix db bug

1 parent 1f46e609
......@@ -55,14 +55,14 @@ class Command(BaseCommand, LoggerMixin):
def signal_handler(self, sig, frame):
self.switch = False # 停止处理文件
def get_doc_object(self, task_str):
business_type, doc_id_str = task_str.split(consts.SPLIT_STR)
doc_id = int(doc_id_str)
doc_class = HILDoc if business_type == consts.HIL_PREFIX else AFCDoc
# doc_info = doc_class.objects.filter(id=doc_id, status=DocStatus.INIT.value).values(
# 'id', 'metadata_version_id', 'application_id', 'document_name', 'document_scheme').first()
doc = doc_class.objects.filter(id=doc_id).first()
return doc, business_type
# def get_doc_object(self, task_str):
# business_type, doc_id_str = task_str.split(consts.SPLIT_STR)
# doc_id = int(doc_id_str)
# doc_class = HILDoc if business_type == consts.HIL_PREFIX else AFCDoc
# # doc_info = doc_class.objects.filter(id=doc_id, status=DocStatus.INIT.value).values(
# # 'id', 'metadata_version_id', 'application_id', 'document_name', 'document_scheme').first()
# doc = doc_class.objects.filter(id=doc_id).first()
# return doc, business_type
def get_doc_info(self):
task_str, is_priority = rh.dequeue()
......@@ -73,7 +73,12 @@ class Command(BaseCommand, LoggerMixin):
self.cronjob_log.info('{0} [get_doc_info] [task={1}] [is_priority={2}]'.format(
self.log_base, task_str, is_priority))
try:
doc, business_type = self.get_doc_object(task_str)
# doc, business_type = self.get_doc_object(task_str)
business_type, doc_id_str = task_str.split(consts.SPLIT_STR)
doc_id = int(doc_id_str)
doc_class = HILDoc if business_type == consts.HIL_PREFIX else AFCDoc
doc = doc_class.objects.filter(id=doc_id).first()
if doc is None:
self.cronjob_log.warn('{0} [get_doc_info] [doc not exist] [task_str={1}] [is_priority={2}]'.format(
self.log_base, task_str, is_priority))
......@@ -627,7 +632,11 @@ class Command(BaseCommand, LoggerMixin):
del unknown_summary
# 4.2 重构Excel文件
doc, business_type = self.get_doc_object(task_str)
# doc, business_type = self.get_doc_object(task_str)
business_type, doc_id_str = task_str.split(consts.SPLIT_STR)
doc_id = int(doc_id_str)
doc_class = HILDoc if business_type == consts.HIL_PREFIX else AFCDoc
doc = doc_class.objects.filter(id=doc_id).first()
doc_data_path = os.path.join(self.data_dir, business_type, consts.TMP_DIR_NAME, str(doc.id))
excel_path = os.path.join(doc_data_path, '{0}.xlsx'.format(doc.id))
# src_excel_path = os.path.join(doc_data_path, 'src.xlsx')
......@@ -639,7 +648,11 @@ class Command(BaseCommand, LoggerMixin):
with lock:
if task_str in res_dict:
del res_dict[task_str]
doc, business_type = self.get_doc_object(task_str)
# doc, business_type = self.get_doc_object(task_str)
business_type, doc_id_str = task_str.split(consts.SPLIT_STR)
doc_id = int(doc_id_str)
doc_class = HILDoc if business_type == consts.HIL_PREFIX else AFCDoc
doc = doc_class.objects.filter(id=doc_id).first()
doc.status = DocStatus.PROCESS_FAILED.value
doc.save()
self.cronjob_log.warn('{0} [process failed (res to wb)] [task={1}] [error={2}]'.format(
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!