Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 28 additions & 6 deletions internal/dms/service/data_export_workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,8 @@ func (d *DMSService) ListDataExportWorkflow(ctx context.Context, req *dmsV1.List
if len(creater) > 0 {
ret[i].Creater = creater[0]
}
// 结束时不显示当前步骤操作人,其他状态显示当前步骤操作人
if w.Status != string(dmsV1.StatusFinish) {
ret[i].CurrentStepAssigneeUsers = convertBizUidWithName(d.UserUsecase.GetBizUserIncludeDeletedWithNameByUids(ctx, w.WorkflowRecord.WorkflowSteps[w.WorkflowRecord.CurrentWorkflowStepId-1].Assignees))
if uids := currentStepAssigneeUIDsForList(w); len(uids) > 0 {
ret[i].CurrentStepAssigneeUsers = convertBizUidWithName(d.UserUsecase.GetBizUserIncludeDeletedWithNameByUids(ctx, uids))
}
}

Expand Down Expand Up @@ -191,9 +190,8 @@ func (d *DMSService) GetGlobalWorkflowsList(ctx context.Context, req *dmsV1.Filt
if len(creater) > 0 {
ret[i].Creater = creater[0]
}
// 结束时不显示当前步骤操作人,其他状态显示当前步骤操作人
if w.Status != string(dmsV1.StatusFinish) {
ret[i].CurrentStepAssigneeUsers = convertBizUidWithName(d.UserUsecase.GetBizUserIncludeDeletedWithNameByUids(ctx, w.WorkflowRecord.WorkflowSteps[w.WorkflowRecord.CurrentWorkflowStepId-1].Assignees))
if uids := currentStepAssigneeUIDsForList(w); len(uids) > 0 {
ret[i].CurrentStepAssigneeUsers = convertBizUidWithName(d.UserUsecase.GetBizUserIncludeDeletedWithNameByUids(ctx, uids))
}
}

Expand Down Expand Up @@ -376,3 +374,27 @@ func (d *DMSService) DownloadDataExportTask(ctx context.Context, req *dmsV1.Down
func (d *DMSService) DownloadDataExportTaskSQLs(ctx context.Context, req *dmsV1.DownloadDataExportTaskSQLsReq, userId string) (string, []byte, error) {
return d.DataExportWorkflowUsecase.DownloadDataExportTaskSQLs(ctx, req, userId)
}

func currentStepAssigneeUIDsForList(w *biz.Workflow) []string {
if w == nil || w.WorkflowRecord == nil {
return nil
}
switch w.WorkflowRecord.Status {
case biz.DataExportWorkflowStatusFinish, biz.DataExportWorkflowStatusCancel:
return nil
case biz.DataExportWorkflowStatusWaitForExport, biz.DataExportWorkflowStatusRejected, biz.DataExportWorkflowStatusFailed:
if w.CreateUserUID == "" {
return nil
}
return []string{w.CreateUserUID}
default:
if w.WorkflowRecord.CurrentWorkflowStepId == 0 {
return nil
}
idx := w.WorkflowRecord.CurrentWorkflowStepId - 1
if int(idx) >= len(w.WorkflowRecord.WorkflowSteps) {
return nil
}
return w.WorkflowRecord.WorkflowSteps[idx].Assignees
}
}
8 changes: 6 additions & 2 deletions internal/dms/storage/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,11 @@ SELECT
w.create_user_uid,
CAST("" AS DATETIME) AS create_user_deleted_at,
w.created_at AS create_time,
IF(wr.status = 'rejected', JSON_ARRAY(w.create_user_uid), curr_ws.assignees) AS current_step_assignee_user_id_list,
CASE
WHEN wr.status IN ('finish', 'cancel') THEN JSON_ARRAY()
WHEN wr.status IN ('rejected', 'wait_for_export', 'failed') THEN JSON_ARRAY(w.create_user_uid)
ELSE curr_ws.assignees
END AS current_step_assignee_user_id_list,
curr_ws.state AS current_step_state,
wr.status,
wr.current_workflow_step_id AS current_workflow_step_id,
Expand Down Expand Up @@ -441,7 +445,7 @@ AND wr.status IN (:filter_status)
{{- end }}

{{- if .filter_current_step_assignee_user_id }}
AND ((wr.status != 'rejected' AND curr_ws.assignees REGEXP :filter_current_step_assignee_user_id) OR (wr.status = 'rejected' AND w.create_user_uid = :filter_current_step_assignee_user_id))
AND ((wr.status NOT IN ('rejected', 'wait_for_export', 'failed') AND curr_ws.assignees REGEXP :filter_current_step_assignee_user_id) OR (wr.status IN ('rejected', 'wait_for_export', 'failed') AND w.create_user_uid = :filter_current_step_assignee_user_id))
{{- end }}

{{- if .filter_db_service_uid }}
Expand Down