|
@@ -6,18 +6,20 @@ import cn.hutool.core.io.FileUtil;
|
|
|
import cn.hutool.core.lang.UUID;
|
|
|
import cn.hutool.core.util.ZipUtil;
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
+import com.alibaba.excel.EasyExcel;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.fdkankan.common.constant.ErrorCode;
|
|
|
+import com.fdkankan.common.constant.SceneStatus;
|
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
|
import com.fdkankan.common.util.CmdUtils;
|
|
|
import com.fdkankan.contro.bean.SendCallAlgorithmDetail;
|
|
|
import com.fdkankan.contro.constant.ZipConstant;
|
|
|
-import com.fdkankan.contro.entity.OrigFileUpload;
|
|
|
-import com.fdkankan.contro.entity.OrigFileUploadBatch;
|
|
|
-import com.fdkankan.contro.entity.User;
|
|
|
+import com.fdkankan.contro.entity.*;
|
|
|
+import com.fdkankan.contro.mq.service.IBuildLogService;
|
|
|
import com.fdkankan.contro.service.*;
|
|
|
import com.fdkankan.contro.vo.SendCallAlgorithmParam;
|
|
|
import com.fdkankan.contro.vo.UploadSceneOrigParamVo;
|
|
@@ -55,6 +57,14 @@ public class JmgaServiceImpl implements IJmgaService {
|
|
|
private ISceneFileBuildService sceneFileBuildService;
|
|
|
@Autowired
|
|
|
private IUserService userService;
|
|
|
+ @Autowired
|
|
|
+ private IScenePlusService scenePlusService;
|
|
|
+ @Autowired
|
|
|
+ private IScenePlusExtService scenePlusExtService;
|
|
|
+ @Autowired
|
|
|
+ private ISceneBuildProcessLogService sceneBuildProcessLogService;
|
|
|
+ @Autowired
|
|
|
+ private IBuildLogService buildLogService;
|
|
|
|
|
|
@Override
|
|
|
public void checkFileWhole(String uuid, String dataSource, JSONObject fdageData) {
|
|
@@ -260,4 +270,79 @@ public class JmgaServiceImpl implements IJmgaService {
|
|
|
HttpUtil.post("http://127.0.0.1:8085/api/scene/file/sendCallAlgorithm", JSON.toJSONString(param));
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void updateSceneFailAndZipLog(String num, String failReason) {
|
|
|
+ scenePlusService.update(new LambdaUpdateWrapper<ScenePlus>()
|
|
|
+ .set(ScenePlus::getSceneStatus, SceneStatus.FAILD.code())
|
|
|
+ .set(ScenePlus::getBuildFailReason, failReason)
|
|
|
+ .eq(ScenePlus::getNum, num));
|
|
|
+
|
|
|
+ String logBasePath = File.separator + "mnt" + File.separator + "logs" + File.separator;
|
|
|
+ String tmpPath = logBasePath + "tmp" + File.separator;
|
|
|
+ String logPath = tmpPath + num + "-" + Calendar.getInstance().getTimeInMillis() + File.separator;
|
|
|
+ String zipPath = tmpPath + num + "-" + Calendar.getInstance().getTimeInMillis() + ".zip";
|
|
|
+ //打包服务端日志
|
|
|
+ File[] ls = FileUtil.ls(logBasePath);
|
|
|
+ for (File l : ls) {
|
|
|
+ if(l.isFile() || !l.getName().startsWith("modeling-control")){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ this.copyLog(l.getAbsolutePath(), tmpPath, "info","sql","error");
|
|
|
+ }
|
|
|
+ //打包算法日志
|
|
|
+ ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
|
|
|
+ ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
|
|
|
+ String consoleLogPath = scenePlusExt.getDataSource() + "console.log";
|
|
|
+ String consoleOldLogPath = scenePlusExt.getDataSource() + "console.old.log";
|
|
|
+ if(FileUtil.exist(consoleLogPath)){
|
|
|
+ FileUtil.copy(consoleLogPath, logPath,true);
|
|
|
+ }
|
|
|
+ if(FileUtil.exist(consoleOldLogPath)){
|
|
|
+ FileUtil.copy(consoleOldLogPath, logPath,true);
|
|
|
+ }
|
|
|
+ //打包数据库记录
|
|
|
+ String[] split = scenePlusExt.getDataSource().split("/");
|
|
|
+ String uuid = split[split.length -1];
|
|
|
+ List<OrigFileUploadBatch> batchList = origFileUploadBatchService.list(new LambdaQueryWrapper<OrigFileUploadBatch>().eq(OrigFileUploadBatch::getUuid, uuid));
|
|
|
+ if(CollUtil.isNotEmpty(batchList)){
|
|
|
+ EasyExcel.write(logPath.concat("origFileUploadBatch.xlsx"), OrigFileUploadBatch.class).sheet("origFileUploadBatch").doWrite(batchList);
|
|
|
+ List<String> batchIdList = batchList.stream().map(v -> v.getBatchId()).collect(Collectors.toList());
|
|
|
+ List<OrigFileUpload> uploadList = origFileUploadService.list(new LambdaQueryWrapper<OrigFileUpload>().in(OrigFileUpload::getBatchId, batchIdList));
|
|
|
+ if(CollUtil.isNotEmpty(uploadList)){
|
|
|
+ EasyExcel.write(logPath.concat("origFileUpload.xlsx"), OrigFileUpload.class).sheet("origFileUpload").doWrite(uploadList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<SceneBuildProcessLog> processLogList = sceneBuildProcessLogService.listByNum(num);
|
|
|
+ if(CollUtil.isNotEmpty(processLogList)){
|
|
|
+ EasyExcel.write(logPath.concat("sceneBuildProcessLog.xlsx"), SceneBuildProcessLog.class).sheet("sceneBuildProcessLog").doWrite(processLogList);
|
|
|
+ }
|
|
|
+ List<BuildLog> buildLogList = buildLogService.list(new LambdaQueryWrapper<BuildLog>().eq(BuildLog::getSceneNum, num));
|
|
|
+ if(CollUtil.isNotEmpty(buildLogList)){
|
|
|
+ EasyExcel.write(logPath.concat("buildLog.xlsx"), BuildLog.class).sheet("buildLog").doWrite(buildLogList);
|
|
|
+ }
|
|
|
+
|
|
|
+ //上传日志,删除本地压缩包
|
|
|
+ ZipUtil.zip(logPath, zipPath, false);
|
|
|
+ fYunFileService.uploadFile(zipPath, "build_log/");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void copyLog(String serverPath, String tmpPath, String... levels){
|
|
|
+ level: for (String level : levels) {
|
|
|
+ String infoPath = serverPath + File.separator + level + File.separator;
|
|
|
+ List<File> fileList = FileUtil.loopFiles(infoPath);
|
|
|
+ if(CollUtil.isEmpty(fileList)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ CollUtil.reverse(fileList);
|
|
|
+ for (File file : fileList) {
|
|
|
+ int i = fileList.indexOf(file);
|
|
|
+ if(i > 7){
|
|
|
+ continue level;
|
|
|
+ }
|
|
|
+ FileUtil.copy(file.getAbsolutePath(), file.getAbsolutePath().replace(FileUtil.getParent(serverPath, 1), tmpPath), true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|