Commit 6f0b1eff by guo_minglei@163.com

Merge remote-tracking branch 'origin/developer' into developer

parents 900e277b d419cf76
......@@ -6,6 +6,7 @@ import com.byit.job.dto.DispatchResponseDto;
import com.byit.job.dto.ScriptDto;
import com.byit.model.JobTaskSchedule;
import com.byit.service.RunScriptService;
import com.byit.util.FlowContent;
import com.byit.util.SpringUtil;
import io.netty.util.Timeout;
import io.netty.util.TimerTask;
......
connect_timeout = 2
network_timeout = 30
charset = UTF-8
http.tracker_http_port = 8080
http.tracker_http_port = 88
http.anti_steal_token = no
http.secret_key = FastDFS1234567890
......
......@@ -17,6 +17,8 @@ import org.springframework.stereotype.Service;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.Map;
import java.util.UUID;
......@@ -46,7 +48,7 @@ public class ScriptExecutorServiceImpl implements ScriptExecutorService {
DispatchResponseDto dispatchResponseDto;
try {
RunThreadPool.SCRIPT_RUN_THREAD_POOL.execute(()->{
log.debug("--------------脚本调用开始-----------");
log.info("--------------runPythonScript,脚本调用开始-----------");
//创建回复对象
JobRunResultDto jobRunResultDto = new JobRunResultDto();
jobRunResultDto.setStartTime(new Date());
......@@ -65,7 +67,7 @@ public class ScriptExecutorServiceImpl implements ScriptExecutorService {
jobRunResultDto.setReturnResult(ReturnResult.SUCCESS);
jobRunResultDto.setLogId(scriptDto.getLogId());
cn.hutool.http.HttpUtil.post(callbackUrl, JSON.toJSONString(jobRunResultDto));
log.debug("--------------脚本调用结束-----------");
log.info("--------------runPythonScript,脚本调用结束-----------");
});
dispatchResponseDto = DispatchResponseDto.builder()
......@@ -86,8 +88,8 @@ public class ScriptExecutorServiceImpl implements ScriptExecutorService {
* @return 生成文件的本地路径
*/
private String byteArrayToFile(String remotePath){
File rootPathMkdir = new File(rootScriptPath);
//创建目录
File rootPathMkdir = new File(rootScriptPath,formatDate());
if(!rootPathMkdir.exists()){
rootPathMkdir.mkdirs();
}
......@@ -96,17 +98,15 @@ public class ScriptExecutorServiceImpl implements ScriptExecutorService {
OutputStream out = null;
File file = null;
try {
//下载脚本文件
byte[] scriptByteArray = fileSystem.downloaderFile(remotePath);
//获取文件元信息
Map<String, String> fileMate = fileSystem.getFileMate(remotePath);
String fileName = fileMate.get("filename");
fileName = UUID.randomUUID().toString().replace("-","")+fileName;
file = new File(rootPathMkdir,fileName);
if(!file.exists()){
file.createNewFile();
}
out = new FileOutputStream(file);
//写出脚本文件
out.write(scriptByteArray);
return file.getPath();
} catch (IOException | MyException e) {
......@@ -133,4 +133,13 @@ public class ScriptExecutorServiceImpl implements ScriptExecutorService {
return logData.getBytes(StandardCharsets.UTF_8);
}
/**
* 格式化当前时间
* @return
*/
private String formatDate(){
LocalDate date = LocalDate.now();
return date.format(DateTimeFormatter.ofPattern("yyyyMMdd"));
}
}
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