提交 9651099a authored 作者: 孙洁清's avatar 孙洁清

路由规则

上级 e5dccc09
...@@ -7,6 +7,8 @@ import org.springframework.data.jpa.repository.Modifying; ...@@ -7,6 +7,8 @@ import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param; import org.springframework.data.repository.query.Param;
import javax.transaction.Transactional;
import java.beans.Transient;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -25,6 +27,10 @@ public interface TestReportDao extends JpaRepository<TestReport,String>, JpaSpec ...@@ -25,6 +27,10 @@ public interface TestReportDao extends JpaRepository<TestReport,String>, JpaSpec
TestReport findByResultId(@Param("resultId") String resultId); TestReport findByResultId(@Param("resultId") String resultId);
@Modifying @Modifying
int deleteByResultId(@Param("resultId") String resultId); int deleteByResultId(@Param("resultId") String resultId);
@Modifying
@Transactional
@Query("update TestReport set outReport=:outReport,status=1 where resultId=:resultId")
void updateOut(String outReport,String resultId);
@Query(value = "select result_id,status from test_report ",nativeQuery = true) @Query(value = "select result_id,status from test_report ",nativeQuery = true)
List<Map<String,Object>> findAllStatus(); List<Map<String,Object>> findAllStatus();
......
...@@ -17,6 +17,9 @@ import org.springframework.stereotype.Component; ...@@ -17,6 +17,9 @@ import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.util.*; import java.util.*;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@Component @Component
@Slf4j @Slf4j
...@@ -29,10 +32,10 @@ public class TestTask { ...@@ -29,10 +32,10 @@ public class TestTask {
@Scheduled(cron = "0/1 * * * * ?") @Scheduled(cron = "0/1 * * * * ?")
@Async("asyncServiceExecutor") @Async("asyncServiceExecutor")
public void getMessage(){ public void getMessage() {
String take = QueueManager.take(); String take = QueueManager.take();
log.info("获取到消息:{}",take); log.info("获取到消息:{}", take);
if(!StringUtils.isEmpty(take)){ if (!StringUtils.isEmpty(take)) {
doBusiness(take); doBusiness(take);
} }
} }
...@@ -42,7 +45,7 @@ public class TestTask { ...@@ -42,7 +45,7 @@ public class TestTask {
TestChannel testChannel = (TestChannel) CacheManager.getCache(id); TestChannel testChannel = (TestChannel) CacheManager.getCache(id);
if (testChannel != null) { if (testChannel != null) {
log.info("testChannel不为空:{}",testChannel); log.info("testChannel不为空:{}", testChannel);
try { try {
EvaReport evaReport = new EvaReport(); EvaReport evaReport = new EvaReport();
evaReport.setBrowser(testChannel.getBrowser()); evaReport.setBrowser(testChannel.getBrowser());
...@@ -101,25 +104,34 @@ public class TestTask { ...@@ -101,25 +104,34 @@ public class TestTask {
Thread.sleep(600); Thread.sleep(600);
if (testChannel.getCodeUrl() != null) { if (testChannel.getCodeUrl() != null) {
//解压上传得代码 //解压上传得代码
String fileRoutes = FileHtmlUtil.getFileRoutes(testChannel.getCodeUrl());
FileHtmlUtil.getFiles(testChannel.getCodeUrl(),null); FileHtmlUtil.getFiles(testChannel.getCodeUrl(), null);
Map<String, List<FileBean>> alls = FileHtmlUtil.getAlls(); Map<String, List<FileType>> alls = FileHtmlUtil.getAlls();
//所有的路由
List<String> allRouters=new ArrayList<>(); //获取项目类型
Set<String> all = alls.keySet(); FileHtmlUtil.getFileRoutes(testChannel.getCodeUrl());
for (String s1 : all) { int jspcount=FileHtmlUtil.jspNum;
List<FileBean> fileBeans = alls.get(s1); int jscount=FileHtmlUtil.jsNum;
if(fileRoutes!=null) { int vuecount=FileHtmlUtil.vueNum;
if (s1.contains("router")) { int angularcount=FileHtmlUtil.angularNum;
for (FileBean fileBean : fileBeans) { int htmlcount=FileHtmlUtil.count;
allRouters.addAll(FileHtmlUtil.readTxtFile(fileBean.getUrl(), "(\\/:*[a-zA-Z0-9]*)+")); String fileRoutes=null;
} if(jspcount>0){
} fileRoutes="jsp";
} }else if(vuecount>0){
fileRoutes="vue";
}else if(jscount>0){
fileRoutes="react";
}else if(angularcount>0){
fileRoutes="angular";
} }
for (String allRouter : allRouters) { if (fileRoutes != null) {
System.out.println("路由:"+allRouter); List<String> routerList = getRouterList(alls, fileRoutes);
List<String> collect = routerList.stream().map(String::toLowerCase).distinct().collect(Collectors.toList());
System.out.println(collect.toString());
} }
FileHtmlUtil.clearAll(); FileHtmlUtil.clearAll();
//获取前端代码中得网页路由地址 //获取前端代码中得网页路由地址
//比对黄承天代码中访问得地址和路由地址,黄承天是否访问全了。 //比对黄承天代码中访问得地址和路由地址,黄承天是否访问全了。
...@@ -141,4 +153,47 @@ public class TestTask { ...@@ -141,4 +153,47 @@ public class TestTask {
} }
} }
private List<String> getRouterList(Map<String, List<FileType>> alls, String fileRoutes) {
List<String> allRouters = new ArrayList<>();
Set<String> all = alls.keySet();
//所有的路由
if (fileRoutes.equals("vue")) {
for (String s1 : all) {
List<FileType> fileBeans = alls.get(s1);
if (fileRoutes != null) {
if (s1.contains("router")) {
for (FileType fileBean : fileBeans) {
allRouters.addAll(FileHtmlUtil.readTxtFile(fileBean.getAddress(), "(\\/:*[a-zA-Z0-9]*)+"));
}
}
}
}
}else if(fileRoutes.equals("angular")||fileRoutes.equals("react")){
for (String s1 : all) {
List<FileType> fileBeans = alls.get(s1);
if (fileRoutes != null) {
if (s1.contains("router")||s1.contains("js")) {
for (FileType fileBean : fileBeans) {
allRouters.addAll(FileHtmlUtil.readTxtFile(fileBean.getAddress(), "(\\/:*[a-zA-Z0-9]*)+"));
}
}
}
}
}else{
for (String s1 : all) {
List<FileType> fileBeans = alls.get(s1);
if (fileRoutes != null) {
for (FileType fileBean : fileBeans) {
if(fileBean.getSuffix().equals("jsp")) {
allRouters.addAll(FileHtmlUtil.readTxtFile(fileBean.getAddress(), "(\\/:*[a-zA-Z0-9]*)+"));
}
}
}
}
}
return allRouters;
}
} }
package com.zjty.autotest.pojo.sjq;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
public class FileType {
private String address;
private String suffix;
private String fileName;
}
...@@ -105,6 +105,7 @@ public class AutoResultSetServiceImpl implements AutoResultSetService { ...@@ -105,6 +105,7 @@ public class AutoResultSetServiceImpl implements AutoResultSetService {
AutoResultSet save = autoResultSetDao.save(autoResultSet); AutoResultSet save = autoResultSetDao.save(autoResultSet);
String in = JSON.toJSONString(testChannel); String in = JSON.toJSONString(testChannel);
TestReport testReport = new TestReport(); TestReport testReport = new TestReport();
testReport.setId(idWorker.nextId()+"");
testReport.setResultId(tid); testReport.setResultId(tid);
testReport.setStatus(0); testReport.setStatus(0);
testReport.setInputReport(in); testReport.setInputReport(in);
......
...@@ -76,12 +76,7 @@ public class TestReportServiceImpl implements TestReportService { ...@@ -76,12 +76,7 @@ public class TestReportServiceImpl implements TestReportService {
* @param testReport * @param testReport
*/ */
public void update(TestReport testReport) { public void update(TestReport testReport) {
TestReport report = testReportDao.findByResultId(testReport.getResultId()); testReportDao.updateOut(testReport.getOutReport(),testReport.getResultId());
if(report!=null) {
report.setStatus(1);
report.setOutReport(testReport.getOutReport());
testReportDao.save(testReport);
}
} }
/** /**
...@@ -96,17 +91,8 @@ public class TestReportServiceImpl implements TestReportService { ...@@ -96,17 +91,8 @@ public class TestReportServiceImpl implements TestReportService {
@Transient @Transient
@Override @Override
public ResponseResult save(TestReport testReport) { public ResponseResult save(TestReport testReport) {
System.out.println(testReport);
if(testReport!=null){
testReport.setId(idWorker.nextId()+"");
// testReport.setOutReport(testReport.getOutReport());
testReport.setStatus(testReport.getStatus());
testReport.setInputReport(testReport.getInputReport());
testReport.setResultId(testReport.getResultId());
testReportDao.save(testReport); testReportDao.save(testReport);
return ResponseResult.okResult(AppHttpCodeEnum.SUCCESS); return ResponseResult.okResult(AppHttpCodeEnum.SUCCESS);
}
return ResponseResult.errorResult(AppHttpCodeEnum.ERROR);
} }
@Transient @Transient
@Override @Override
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论