diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/AlertDao.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/AlertDao.java index 487d42a4a1..ec803b6beb 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/AlertDao.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/AlertDao.java @@ -25,10 +25,9 @@ import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.dao.entity.Alert; import org.apache.dolphinscheduler.dao.entity.AlertPluginInstance; import org.apache.dolphinscheduler.dao.entity.ProcessAlertContent; -import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; +import org.apache.dolphinscheduler.dao.entity.ProjectUser; import org.apache.dolphinscheduler.dao.entity.ServerAlertContent; -import org.apache.dolphinscheduler.dao.entity.TaskDefinition; import org.apache.dolphinscheduler.dao.entity.TaskInstance; import org.apache.dolphinscheduler.dao.mapper.AlertGroupMapper; import org.apache.dolphinscheduler.dao.mapper.AlertMapper; @@ -116,19 +115,22 @@ public class AlertDao { * process time out alert * * @param processInstance processInstance - * @param processDefinition processDefinition + * @param projectUser projectUser */ - public void sendProcessTimeoutAlert(ProcessInstance processInstance, ProcessDefinition processDefinition) { + public void sendProcessTimeoutAlert(ProcessInstance processInstance, ProjectUser projectUser) { int alertGroupId = processInstance.getWarningGroupId(); Alert alert = new Alert(); List processAlertContentList = new ArrayList<>(1); ProcessAlertContent processAlertContent = ProcessAlertContent.newBuilder() - .projectCode(processDefinition.getProjectCode()) - .projectName(processDefinition.getProjectName()) - .owner(processDefinition.getUserName()) + .projectCode(projectUser.getProjectCode()) + .projectName(projectUser.getProjectName()) + .owner(projectUser.getUserName()) .processId(processInstance.getId()) .processDefinitionCode(processInstance.getProcessDefinitionCode()) .processName(processInstance.getName()) + .processType(processInstance.getCommandType()) + .processState(processInstance.getState()) + .runTimes(processInstance.getRunTimes()) .processStartTime(processInstance.getStartTime()) .processHost(processInstance.getHost()) .event(AlertEvent.TIME_OUT) @@ -154,15 +156,15 @@ public class AlertDao { * * @param processInstance processInstanceId * @param taskInstance taskInstance - * @param taskDefinition taskDefinition + * @param projectUser projectUser */ - public void sendTaskTimeoutAlert(ProcessInstance processInstance, TaskInstance taskInstance, TaskDefinition taskDefinition) { + public void sendTaskTimeoutAlert(ProcessInstance processInstance, TaskInstance taskInstance, ProjectUser projectUser) { Alert alert = new Alert(); List processAlertContentList = new ArrayList<>(1); ProcessAlertContent processAlertContent = ProcessAlertContent.newBuilder() - .projectCode(taskDefinition.getProjectCode()) - .projectName(taskDefinition.getProjectName()) - .owner(taskDefinition.getUserName()) + .projectCode(projectUser.getProjectCode()) + .projectName(projectUser.getProjectName()) + .owner(projectUser.getUserName()) .processId(processInstance.getId()) .processDefinitionCode(processInstance.getProcessDefinitionCode()) .processName(processInstance.getName()) diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProjectUser.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProjectUser.java index bf959b493b..63c292ea10 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProjectUser.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProjectUser.java @@ -38,6 +38,12 @@ public class ProjectUser { @TableField("project_id") private int projectId; + /** + * project code + */ + @TableField(exist = false) + private long projectCode; + /** * project name */ @@ -125,12 +131,21 @@ public class ProjectUser { this.perm = perm; } + public long getProjectCode() { + return projectCode; + } + + public void setProjectCode(long projectCode) { + this.projectCode = projectCode; + } + @Override public String toString() { return "ProjectUser{" + "id=" + id + ", userId=" + userId + ", projectId=" + projectId + + ", projectCode=" + projectCode + ", projectName='" + projectName + '\'' + ", userName='" + userName + '\'' + ", perm=" + perm diff --git a/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProjectMapper.xml b/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProjectMapper.xml index dcbb659b5b..26602a8bcb 100644 --- a/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProjectMapper.xml +++ b/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProjectMapper.xml @@ -150,6 +150,7 @@