Commit 5322244f by huangfusuper

邮件信息增加运行类型

parent 16799693
......@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import com.byit.dto.EmailMappingDto;
import com.byit.enums.EmailEnum;
import com.byit.enums.ScheduleTypeEnum;
import com.byit.model.EmailAlarm;
import com.byit.model.JobTaskRunLogWithBLOBs;
import com.byit.model.RunRecording;
......@@ -84,7 +85,7 @@ public class RunRecordingAndEmailServiceImpl implements RunRecordingAndEmailServ
}
long flowEndTime = runRecording.getEndTime() == null? System.currentTimeMillis():runRecording.getEndTime().getTime();
long flowStartTime = runRecording.getStartTime() == null? System.currentTimeMillis():runRecording.getStartTime().getTime();
String senContentHtml = buildHtml(flowName,workspaceName,jobTaskRunLogByFlowIdAndRunId,flowEndTime-flowStartTime);
String senContentHtml = buildHtml(flowName,workspaceName,jobTaskRunLogByFlowIdAndRunId,flowEndTime-flowStartTime,runRecording);
EmailAlarm emailAlarm = EmailAlarm.builder()
.flowId(runRecording.getFlowId())
.flowName(flowName)
......@@ -107,17 +108,20 @@ public class RunRecordingAndEmailServiceImpl implements RunRecordingAndEmailServ
/**
* 根据模板引擎构建html代码
* @param title
* @param env
* @param jobTaskRunLogs
* @param flowConsumeDate
* @return
* @param title 主题
* @param env 环境名称
* @param jobTaskRunLogs 日志节点
* @param flowConsumeDate 消耗时间
* @param runRecording 对应的运行实例
* @return 构建好的html
*/
public String buildHtml(String title,String env, List<JobTaskRunLogWithBLOBs> jobTaskRunLogs,Long flowConsumeDate){
public String buildHtml(String title,String env, List<JobTaskRunLogWithBLOBs> jobTaskRunLogs,Long flowConsumeDate, RunRecording runRecording){
Map<String, Object> data = new HashMap<>(4);
data.put("title",title);
data.put("env",env);
data.put("flowConsumeDate",TimeFormatUtil.timeFormat(flowConsumeDate));
int scheduleType = runRecording.getScheduleType();
data.put("schedulingType",ScheduleTypeEnum.matchScheduleType(scheduleType));
List<EmailMappingDto> emailMappings = new ArrayList<>(8);
if (CollectionUtil.isNotEmpty(jobTaskRunLogs)) {
jobTaskRunLogs.forEach(jobTaskRunLog -> {
......
......@@ -9,7 +9,7 @@
<table border='1' width='80%' align='center' cellspacing='0' cellpadding='6'>
<div style="margin-bottom: 20px;">
<h1 style='text-align:center;color:red;'>工作流执行报告</h1>
<h1 style='text-align:center;color:red;' th:text="${schedulingType}+'工作流执行报告'"></h1>
<br/>
<span style="margin-left: 10%;font-size: 16px;color: #646256;" th:text="'工作流名称:'+${title}"></span>
<span style="margin-left: 10%;font-size: 16px;color: #646256;" th:text="'总耗时:'+${flowConsumeDate}"></span>
......
package com.byit.enums;
import java.util.Arrays;
/**
* @description: 调度类型枚举
* @author: gml
......@@ -30,4 +32,14 @@ public enum ScheduleTypeEnum {
return this.msg;
}
public static String matchScheduleType(int code) {
ScheduleTypeEnum[] scheduleTypeEnums = ScheduleTypeEnum.values();
for (ScheduleTypeEnum scheduleTypeEnum : Arrays.asList(scheduleTypeEnums)) {
if (scheduleTypeEnum.code == code) {
return scheduleTypeEnum.msg;
}
}
return "未知类型$";
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment