Commit e2d4edaa authored by wdy's avatar wdy

Merge branch 'wangdingyi' into 'dev'

定时任务

See merge request !289
parents 0da67341 e3e3d842
...@@ -9,6 +9,11 @@ import com.ruoyi.domain.vo.CaseResultVO; ...@@ -9,6 +9,11 @@ import com.ruoyi.domain.vo.CaseResultVO;
import com.ruoyi.domain.vo.StepResultVO; import com.ruoyi.domain.vo.StepResultVO;
import com.ruoyi.mapper.TestRecordsMapper; import com.ruoyi.mapper.TestRecordsMapper;
import com.ruoyi.service.TestRecordsService; import com.ruoyi.service.TestRecordsService;
import org.commonmark.node.Node;
import org.commonmark.parser.Parser;
import org.commonmark.renderer.html.HtmlRenderer;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Entities;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -88,6 +93,7 @@ public class TestRecordsServiceImpl extends ServiceImpl<TestRecordsMapper, TestR ...@@ -88,6 +93,7 @@ public class TestRecordsServiceImpl extends ServiceImpl<TestRecordsMapper, TestR
List<String> stepList = new ArrayList<>(); List<String> stepList = new ArrayList<>();
List<String> testDetailsList = new ArrayList<>(); List<String> testDetailsList = new ArrayList<>();
int index = 1; // 序号从1开始 int index = 1; // 序号从1开始
String testDetailsVO = "";
for (StepResultVO stepResultVO :stepResultVOS) { for (StepResultVO stepResultVO :stepResultVOS) {
// 测试方法 // 测试方法
String stepName = stepResultVO.getName(); String stepName = stepResultVO.getName();
...@@ -100,10 +106,14 @@ public class TestRecordsServiceImpl extends ServiceImpl<TestRecordsMapper, TestR ...@@ -100,10 +106,14 @@ public class TestRecordsServiceImpl extends ServiceImpl<TestRecordsMapper, TestR
// 测试详情 // 测试详情
String testDetails = stepResultVO.getDescription(); String testDetails = stepResultVO.getDescription();
testDetailsList.add(testDetails); if (testDetails != null) {
convertMarkdownToHtml(testDetails);
} }
testDetailsVO += testDetails + "`";
}
testDetailsVO = testDetailsVO.substring(0, testDetailsVO.length() - 1);
testRecords.setTestMethod(StringUtils.join(stepList,"`")); testRecords.setTestMethod(StringUtils.join(stepList,"`"));
testRecords.setTestDetails(StringUtils.join(testDetailsList,"\n")); testRecords.setTestDetails(testDetailsVO);
} }
list.add(testRecords); list.add(testRecords);
...@@ -161,6 +171,7 @@ public class TestRecordsServiceImpl extends ServiceImpl<TestRecordsMapper, TestR ...@@ -161,6 +171,7 @@ public class TestRecordsServiceImpl extends ServiceImpl<TestRecordsMapper, TestR
List<String> stepList = new ArrayList<>(); List<String> stepList = new ArrayList<>();
List<String> testDetailsList = new ArrayList<>(); List<String> testDetailsList = new ArrayList<>();
int index = 1; // 序号从1开始 int index = 1; // 序号从1开始
String testDetailsVO = "";
for (StepResultVO stepResultVO :stepResultVOS) { for (StepResultVO stepResultVO :stepResultVOS) {
// 测试方法 // 测试方法
String stepName = stepResultVO.getName(); String stepName = stepResultVO.getName();
...@@ -173,10 +184,14 @@ public class TestRecordsServiceImpl extends ServiceImpl<TestRecordsMapper, TestR ...@@ -173,10 +184,14 @@ public class TestRecordsServiceImpl extends ServiceImpl<TestRecordsMapper, TestR
// 测试详情 // 测试详情
String testDetails = stepResultVO.getDescription(); String testDetails = stepResultVO.getDescription();
testDetailsList.add(testDetails); if (testDetails != null) {
convertMarkdownToHtml(testDetails);
}
testDetailsVO += testDetails + "`";
} }
testDetailsVO = testDetailsVO.substring(0, testDetailsVO.length() - 1);
testRecords.setTestMethod(StringUtils.join(stepList,"`")); testRecords.setTestMethod(StringUtils.join(stepList,"`"));
testRecords.setTestDetails(StringUtils.join(testDetailsList,"\n")); testRecords.setTestDetails(testDetailsVO);
} }
list.add(testRecords); list.add(testRecords);
...@@ -189,6 +204,25 @@ public class TestRecordsServiceImpl extends ServiceImpl<TestRecordsMapper, TestR ...@@ -189,6 +204,25 @@ public class TestRecordsServiceImpl extends ServiceImpl<TestRecordsMapper, TestR
} }
} }
public static String convertMarkdownToHtml(String markdownContent) {
// 创建 Markdown 解析器
Parser parser = Parser.builder().build();
// 解析 Markdown
Node document = parser.parse(markdownContent);
// 创建 HTML 渲染器
HtmlRenderer renderer = HtmlRenderer.builder().build();
// 渲染 HTML
org.jsoup.nodes.Document doc = Jsoup.parse(renderer.render(document).replaceAll("\\\\n", "<br>"));
// jsoup标准化标签,生成闭合标签
doc.outputSettings().syntax(org.jsoup.nodes.Document.OutputSettings.Syntax.xml);
doc.outputSettings().escapeMode(Entities.EscapeMode.xhtml);
return doc.html();
}
@Override @Override
public List<TestRecords> findByTaskId(String id) { public List<TestRecords> findByTaskId(String id) {
return testRecordsMapper.findByTaskId(id); return testRecordsMapper.findByTaskId(id);
......
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