Commit a0c26e09 by huangfusuper

切分工作空间名称

parent c3508b3b
...@@ -22,6 +22,8 @@ import org.thymeleaf.TemplateEngine; ...@@ -22,6 +22,8 @@ import org.thymeleaf.TemplateEngine;
import org.thymeleaf.context.Context; import org.thymeleaf.context.Context;
import java.util.*; import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/** /**
* @author huangfu * @author huangfu
...@@ -35,6 +37,7 @@ public class RunRecordingAndEmailServiceImpl implements RunRecordingAndEmailServ ...@@ -35,6 +37,7 @@ public class RunRecordingAndEmailServiceImpl implements RunRecordingAndEmailServ
public static final String NODE_RE_RUN_ERROR = "4"; public static final String NODE_RE_RUN_ERROR = "4";
public static final String NODE_RUN_KILL = "5"; public static final String NODE_RUN_KILL = "5";
public static final String NODE_UP_RUN_ERROR = "6"; public static final String NODE_UP_RUN_ERROR = "6";
public static final String WORKSPACE_NAME_PATTERN = "(.*_.*[A-Za-z]+)(\\d+$)";
private final TemplateEngine templateEngine; private final TemplateEngine templateEngine;
/** /**
* 邮箱表操作 * 邮箱表操作
...@@ -75,7 +78,7 @@ public class RunRecordingAndEmailServiceImpl implements RunRecordingAndEmailServ ...@@ -75,7 +78,7 @@ public class RunRecordingAndEmailServiceImpl implements RunRecordingAndEmailServ
String workspaceName = null; String workspaceName = null;
if(workspace != null){ if(workspace != null){
workspaceName = workspace.getWorkspaceName(); workspaceName = formatWorkspaceName(workspace.getWorkspaceName());
} }
long flowEndTime = runRecording.getEndTime() == null? System.currentTimeMillis():runRecording.getEndTime().getTime(); long flowEndTime = runRecording.getEndTime() == null? System.currentTimeMillis():runRecording.getEndTime().getTime();
long flowStartTime = runRecording.getStartTime() == null? System.currentTimeMillis():runRecording.getStartTime().getTime(); long flowStartTime = runRecording.getStartTime() == null? System.currentTimeMillis():runRecording.getStartTime().getTime();
...@@ -243,19 +246,32 @@ public class RunRecordingAndEmailServiceImpl implements RunRecordingAndEmailServ ...@@ -243,19 +246,32 @@ public class RunRecordingAndEmailServiceImpl implements RunRecordingAndEmailServ
return stringBuilder.toString(); return stringBuilder.toString();
} }
/**
* 格式化工作空间名称
* @param workspaceName
* @return
*/
private String formatWorkspaceName(String workspaceName){
Pattern compile = Pattern.compile(WORKSPACE_NAME_PATTERN);
Matcher matcher = compile.matcher(workspaceName);
if (matcher.find()) {
String group = matcher.group(1);
return group;
}else {
return "匹配错误";
}
}
public static void main(String[] args) { public static void main(String[] args) {
List<String> trackerListTest = new ArrayList<>(); String wName = "mysql00000_000000dev0003232323230";
trackerListTest.add("127.0.0.1:8989"); Pattern compile = Pattern.compile(WORKSPACE_NAME_PATTERN);
trackerListTest.add("127.0.0.2:8989"); Matcher matcher = compile.matcher(wName);
trackerListTest.add("127.0.0.3:8989"); if (matcher.find()) {
StringBuilder logStr = new StringBuilder("<br/>"); String group = matcher.group(1);
String path = "ddmp/M00/00/0B/CgB42F7DTa6AdGG1AAAABH0VDjQ718.log"; System.out.println(group);
for (String ipPort : trackerListTest) {
String ip = ipPort.split(":")[0];
String baseUrl = "http://"+ip+":"+"8888"+"/";
String hrefUrl = baseUrl + path;
logStr.append("<a href='").append(hrefUrl).append("'target='_blank'>").append(baseUrl).append("</a><br/><br/>");
} }
System.out.println(logStr);
} }
} }
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