修改
This commit is contained in:
@@ -10,6 +10,7 @@ import com.ccag.common.util.DateUtils;
|
||||
import com.ccag.config.TenantProperties;
|
||||
import com.ccag.dao.ProjectMapper;
|
||||
import com.ccag.dao.SystemMapper;
|
||||
import com.ccag.entity.bo.system.office.OfficeProxy;
|
||||
import com.ccag.entity.bo.task.*;
|
||||
import com.ccag.entity.pojo.pbs.ProjectRunFile;
|
||||
import com.ccag.entity.pojo.project.*;
|
||||
@@ -512,32 +513,34 @@ public class ProjectServiceImpl implements ProjectService {
|
||||
return SdmResponse.success();
|
||||
}
|
||||
List<String> result = new ArrayList<>();
|
||||
int runningStatus = -1;
|
||||
try {
|
||||
log.info("开始同步执行脚本");
|
||||
Process process = Runtime.getRuntime().exec(commands);
|
||||
log.info("准备获取脚本输出");
|
||||
if (req.getHasReturn() != null && req.getHasReturn() == 1) {
|
||||
log.info("开始获取脚本输出");
|
||||
BufferedInputStream reader = new BufferedInputStream(process.getInputStream());
|
||||
byte[] line = new byte[1024];
|
||||
while (reader.read(line) > 0) {
|
||||
log.info("executePython:" + line);
|
||||
result.add(Arrays.toString(line));
|
||||
}
|
||||
}
|
||||
log.info("脚本执行完成");
|
||||
runningStatus = process.waitFor();
|
||||
log.info("脚本运行状态:" + runningStatus);
|
||||
} catch (IOException | InterruptedException e) {
|
||||
log.error("执行脚本失败:" + e);
|
||||
return SdmResponse.failed("执行脚本失败:" + e);
|
||||
String[] cmdParams = commands.split(" ");
|
||||
if(cmdParams.length != 4)
|
||||
{
|
||||
return SdmResponse.failed("param size error");
|
||||
}
|
||||
if (runningStatus != 0) {
|
||||
log.error(EXECUTE_SCRIPT_FAIL);
|
||||
return SdmResponse.failed(EXECUTE_SCRIPT_FAIL);
|
||||
} else {
|
||||
log.info(commands + "执行脚本完成!");
|
||||
OfficeProxy officeProxy = new OfficeProxy();
|
||||
if(commands.contains("excelToJson.py")) //excel转为json库
|
||||
{
|
||||
String excelPath = cmdParams[1];
|
||||
String dictPath = cmdParams[3];
|
||||
String jsonContents = officeProxy.excelToJson(excelPath,dictPath);
|
||||
result.add(jsonContents);
|
||||
}
|
||||
else if(commands.contains("jsonToExcel.py"))//json库导出excel
|
||||
{
|
||||
String jsonPath = cmdParams[1];
|
||||
int type = Integer.parseInt(cmdParams[2]);
|
||||
String dictPath = cmdParams[3];
|
||||
int index = dictPath.lastIndexOf(File.separator);
|
||||
if(index > 0) {
|
||||
String savePath = dictPath.substring(0, index);
|
||||
String excelPath = savePath + File.separator + "分析项清单.xlsx";
|
||||
officeProxy.jsonToExcel(jsonPath, dictPath, excelPath, type);
|
||||
result.add(excelPath);
|
||||
}
|
||||
else {
|
||||
log.error("生成excel保存路径错误");
|
||||
}
|
||||
}
|
||||
return SdmResponse.success(result);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user