Skip to content

Commit

Permalink
Fix the missing project information in the process instance timeout a…
Browse files Browse the repository at this point in the history
…larm (#7324)
  • Loading branch information
zhuangchong authored Dec 10, 2021
1 parent 0f7e38e commit f1b85cf
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,11 @@ public void sendProcessTimeoutAlert(ProcessInstance processInstance, ProcessDefi
Alert alert = new Alert();
List<ProcessAlertContent> processAlertContentList = new ArrayList<>(1);
ProcessAlertContent processAlertContent = ProcessAlertContent.newBuilder()
.projectId(processDefinition.getId())
.projectCode(processDefinition.getProjectCode())
.projectName(processDefinition.getProjectName())
.owner(processDefinition.getUserName())
.processId(processInstance.getId())
.processDefinitionCode(processInstance.getProcessDefinitionCode())
.processName(processInstance.getName())
.processStartTime(processInstance.getStartTime())
.processHost(processInstance.getHost())
Expand Down Expand Up @@ -156,11 +157,13 @@ public void sendTaskTimeoutAlert(ProcessInstance processInstance, TaskInstance t
Alert alert = new Alert();
List<ProcessAlertContent> processAlertContentList = new ArrayList<>(1);
ProcessAlertContent processAlertContent = ProcessAlertContent.newBuilder()
.projectCode(taskDefinition.getProjectCode())
.projectName(taskDefinition.getProjectName())
.owner(taskDefinition.getUserName())
.processId(processInstance.getId())
.processDefinitionCode(processInstance.getProcessDefinitionCode())
.processName(processInstance.getName())
.taskId(taskInstance.getId())
.taskCode(taskInstance.getTaskCode())
.taskName(taskInstance.getName())
.taskType(taskInstance.getTaskType())
.taskStartTime(taskInstance.getStartTime())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,19 @@

@JsonInclude(Include.NON_NULL)
public class ProcessAlertContent implements Serializable {

@JsonProperty("projectId")
private int projectId;
private Integer projectId;
@JsonProperty("projectCode")
private Long projectCode;
@JsonProperty("projectName")
private String projectName;
@JsonProperty("owner")
private String owner;
@JsonProperty("processId")
private int processId;
private Integer processId;
@JsonProperty("processDefinitionCode")
private Long processDefinitionCode;
@JsonProperty("processName")
private String processName;
@JsonProperty("processType")
Expand All @@ -50,7 +55,7 @@ public class ProcessAlertContent implements Serializable {
@JsonProperty("recovery")
private Flag recovery;
@JsonProperty("runTimes")
private int runTimes;
private Integer runTimes;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@JsonProperty("processStartTime")
private Date processStartTime;
Expand All @@ -59,8 +64,8 @@ public class ProcessAlertContent implements Serializable {
private Date processEndTime;
@JsonProperty("processHost")
private String processHost;
@JsonProperty("taskId")
private int taskId;
@JsonProperty("taskCode")
private Long taskCode;
@JsonProperty("taskName")
private String taskName;
@JsonProperty("event")
Expand All @@ -70,7 +75,7 @@ public class ProcessAlertContent implements Serializable {
@JsonProperty("taskType")
private String taskType;
@JsonProperty("retryTimes")
private int retryTimes;
private Integer retryTimes;
@JsonProperty("taskState")
private ExecutionStatus taskState;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
Expand All @@ -86,9 +91,11 @@ public class ProcessAlertContent implements Serializable {

private ProcessAlertContent(Builder builder) {
this.projectId = builder.projectId;
this.projectCode = builder.projectCode;
this.projectName = builder.projectName;
this.owner = builder.owner;
this.processId = builder.processId;
this.processDefinitionCode = builder.processDefinitionCode;
this.processName = builder.processName;
this.processType = builder.processType;
this.recovery = builder.recovery;
Expand All @@ -97,7 +104,7 @@ private ProcessAlertContent(Builder builder) {
this.processStartTime = builder.processStartTime;
this.processEndTime = builder.processEndTime;
this.processHost = builder.processHost;
this.taskId = builder.taskId;
this.taskCode = builder.taskCode;
this.taskName = builder.taskName;
this.event = builder.event;
this.warnLevel = builder.warnLevel;
Expand All @@ -116,34 +123,40 @@ public static Builder newBuilder() {
}

public static class Builder {
private int projectId;
private Integer projectId;
private Long projectCode;
private String projectName;
private String owner;
private int processId;
private Integer processId;
private Long processDefinitionCode;
private String processName;
private CommandType processType;
private Flag recovery;
private ExecutionStatus processState;
private int runTimes;
private Integer runTimes;
private Date processStartTime;
private Date processEndTime;
private String processHost;
private int taskId;
private Long taskCode;
private String taskName;
private AlertEvent event;
private AlertWarnLevel warnLevel;
private String taskType;
private int retryTimes;
private Integer retryTimes;
private ExecutionStatus taskState;
private Date taskStartTime;
private Date taskEndTime;
private String taskHost;
private String logPath;

public Builder projectId(int projectId) {
public Builder projectId(Integer projectId) {
this.projectId = projectId;
return this;
}
public Builder projectCode(Long projectCode) {
this.projectCode = projectCode;
return this;
}

public Builder projectName(String projectName) {
this.projectName = projectName;
Expand All @@ -155,10 +168,14 @@ public Builder owner(String owner) {
return this;
}

public Builder processId(int processId) {
public Builder processId(Integer processId) {
this.processId = processId;
return this;
}
public Builder processDefinitionCode(Long processDefinitionCode) {
this.processDefinitionCode = processDefinitionCode;
return this;
}

public Builder processName(String processName) {
this.processName = processName;
Expand All @@ -180,7 +197,7 @@ public Builder processState(ExecutionStatus processState) {
return this;
}

public Builder runTimes(int runTimes) {
public Builder runTimes(Integer runTimes) {
this.runTimes = runTimes;
return this;
}
Expand All @@ -200,8 +217,8 @@ public Builder processHost(String processHost) {
return this;
}

public Builder taskId(int taskId) {
this.taskId = taskId;
public Builder taskCode(Long taskCode) {
this.taskCode = taskCode;
return this;
}

Expand All @@ -225,7 +242,7 @@ public Builder taskType(String taskType) {
return this;
}

public Builder retryTimes(int retryTimes) {
public Builder retryTimes(Integer retryTimes) {
this.retryTimes = retryTimes;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public String getContentProcessInstance(ProcessInstance processInstance,
.projectName(projectUser.getProjectName())
.owner(projectUser.getUserName())
.processId(processInstance.getId())
.processDefinitionCode(processInstance.getProcessDefinitionCode())
.processName(processInstance.getName())
.processType(processInstance.getCommandType())
.processState(processInstance.getState())
Expand All @@ -131,8 +132,9 @@ public String getContentProcessInstance(ProcessInstance processInstance,
.projectName(projectUser.getProjectName())
.owner(projectUser.getUserName())
.processId(processInstance.getId())
.processDefinitionCode(processInstance.getProcessDefinitionCode())
.processName(processInstance.getName())
.taskId(task.getId())
.taskCode(task.getTaskCode())
.taskName(task.getName())
.taskType(task.getTaskType())
.taskState(task.getState())
Expand Down Expand Up @@ -162,7 +164,10 @@ private String getWorkerToleranceContent(ProcessInstance processInstance, List<T

for (TaskInstance taskInstance : toleranceTaskList) {
ProcessAlertContent processAlertContent = ProcessAlertContent.newBuilder()
.processId(processInstance.getId())
.processDefinitionCode(processInstance.getProcessDefinitionCode())
.processName(processInstance.getName())
.taskCode(taskInstance.getTaskCode())
.taskName(taskInstance.getName())
.taskHost(taskInstance.getHost())
.retryTimes(taskInstance.getRetryTimes())
Expand Down

0 comments on commit f1b85cf

Please sign in to comment.