stopAll:function(){
let that = this;
that.axios.post("/test/stressFile/stopAll")
.then(function (res) {
if (res.data.code==0){that.$notify.success({title:"Success", message:"停止成功"});}
else{that.$notify.error({title:"Error", message:"停止失败,错误信息:"+res.data.msg});}
}).catch(function (error) {
that.$notify.error({title:"Error", message:"删除失败,错误信息:"+error});
});
},
/**
* 根据模板生成OSP压测脚本
*/
@RequestMapping("/generateJmx")
public void generateJmx(HttpServletRequest request){
Long caseId = Long.valueOf(request.getParameter("caseId"));
String jmxName = request.getParameter("jmxName");
Map contextMap = new HashMap();
String contextStr = request.getParameter("context");
Gson gson = new Gson();
contextMap = gson.fromJson(contextStr,contextMap.getClass());
StressTestFileEntity stressCaseFile = new StressTestFileEntity();
try {
//获取case信息
StressTestEntity stressTestEntity = stressTestService.queryObject(caseId);
String casePath = stressTestUtils.getCasePath();
//filePath=E:/worktools/apache-jmeter-4.0/stressTestCases/2018110915275893/case20181109152758960.jmx
String filePath;
Map<String, Object> query = new HashMap<String, Object>();
query.put("originName", jmxName);
// fileList中最多有一条记录
List<StressTestFileEntity> fileList = stressTestFileService.queryList(query);
if (!fileList.isEmpty()){
throw new RRException("系统中已经存在此文件记录!不允许生成同名文件!");
}else{
stressCaseFile.setOriginName(jmxName+".jmx");
Date caseAddTime = stressTestEntity.getAddTime();
String caseAddTimeStr = DateUtils.format(caseAddTime, DateUtils.DATE_TIME_PATTERN_4DIR);
String caseFilePath;
if (StringUtils.isEmpty(stressTestEntity.getCaseDir())) {
//random使用时间种子的随机数,避免了轻度并发造成文件夹重名.
caseFilePath = caseAddTimeStr + new Random(System.nanoTime()).nextInt(1000);
stressTestEntity.setCaseDir