Skip to content

Commit

Permalink
优化一下写法不要过多判断
Browse files Browse the repository at this point in the history
  • Loading branch information
woshiyanghai committed Jul 4, 2024
1 parent e3ab1b7 commit 8560e7e
Showing 1 changed file with 30 additions and 24 deletions.
54 changes: 30 additions & 24 deletions sql/utils/workflow_audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,29 +300,34 @@ def create_audit(self) -> str:
create_user=create_user,
create_user_display=create_user_display,
)
if self.workflow.status != "workflow_autoreviewwrong":
# 自动通过的情况
if audit_setting.auto_pass:
self.audit.current_status = WorkflowStatus.PASSED
self.audit.save()
WorkflowLog.objects.create(
audit_id=self.audit.audit_id,
operation_type=WorkflowAction.SUBMIT,
operation_type_desc=WorkflowAction.SUBMIT.label,
operation_info="无需审批,系统直接审核通过",
operator=self.audit.create_user,
operator_display=self.audit.create_user_display,
)

return "无需审批, 直接审核通过"
else:
self.audit.current_status = WorkflowStatus.WAITING
readable_review_flow, _ = self.review_info
operation_info = "等待审批,审批流程:{}".format(readable_review_flow)
else:
# sql检测存在错误
if self.workflow.status == "workflow_autoreviewwrong":
self.audit.current_status = WorkflowStatus.REJECTED
readable_review_flow = "自动审核不通过"
operation_info = "无需审批,审批备注:{}".format(readable_review_flow)
self.audit.save()
WorkflowLog.objects.create(
audit_id=self.audit.audit_id,
operation_type=WorkflowAction.SUBMIT,
operation_type_desc=WorkflowAction.SUBMIT.label,
operation_info="无需审批,sql检测存在错误,系统自动驳回",
operator=self.audit.create_user,
operator_display=self.audit.create_user_display,
)

return "工单已自动驳回"
# 自动通过的情况
if audit_setting.auto_pass:
self.audit.current_status = WorkflowStatus.PASSED
self.audit.save()
WorkflowLog.objects.create(
audit_id=self.audit.audit_id,
operation_type=WorkflowAction.SUBMIT,
operation_type_desc=WorkflowAction.SUBMIT.label,
operation_info="无需审批,系统直接审核通过",
operator=self.audit.create_user,
operator_display=self.audit.create_user_display,
)

return "无需审批, 直接审核通过"

# 向审核主表插入待审核数据
self.audit.current_audit = audit_setting.audit_auth_groups[0]
Expand All @@ -332,15 +337,16 @@ def create_audit(self) -> str:
else:
self.audit.next_audit = audit_setting.audit_auth_groups[1]

self.audit.current_status = WorkflowStatus.WAITING
self.audit.create_user = create_user
self.audit.create_user_display = create_user_display
self.audit.save()
readable_review_flow, _ = self.review_info
audit_log = WorkflowLog(
audit_id=self.audit.audit_id,
operation_type=WorkflowAction.SUBMIT,
operation_type_desc=WorkflowAction.SUBMIT.label,
# operation_info="等待审批,审批流程:{}".format(readable_review_flow),
operation_info=operation_info,
operation_info="等待审批,审批流程:{}".format(readable_review_flow),
operator=self.audit.create_user,
operator_display=self.audit.create_user_display,
)
Expand Down

0 comments on commit 8560e7e

Please sign in to comment.