|
@@ -7,15 +7,24 @@ import cn.hutool.core.util.ZipUtil;
|
|
|
import cn.hutool.http.HttpUtil;
|
|
import cn.hutool.http.HttpUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
+import com.fdkankan.common.constant.CommonSuccessStatus;
|
|
|
import com.fdkankan.common.util.DateExtUtil;
|
|
import com.fdkankan.common.util.DateExtUtil;
|
|
|
import com.fdkankan.deploy.bean.SceneDeployBean;
|
|
import com.fdkankan.deploy.bean.SceneDeployBean;
|
|
|
import com.fdkankan.deploy.entity.Scene;
|
|
import com.fdkankan.deploy.entity.Scene;
|
|
|
|
|
+import com.fdkankan.deploy.entity.SceneReceiveLog;
|
|
|
import com.fdkankan.deploy.mapper.SceneMapper;
|
|
import com.fdkankan.deploy.mapper.SceneMapper;
|
|
|
|
|
+import com.fdkankan.deploy.request.ScenePageRequest;
|
|
|
|
|
+import com.fdkankan.deploy.response.PageInfo;
|
|
|
|
|
+import com.fdkankan.deploy.service.SceneReceiveLogService;
|
|
|
import com.fdkankan.deploy.service.SceneService;
|
|
import com.fdkankan.deploy.service.SceneService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fdkankan.web.response.ResultData;
|
|
import com.fdkankan.web.response.ResultData;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import net.lingala.zip4j.core.ZipFile;
|
|
import net.lingala.zip4j.core.ZipFile;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
@@ -55,6 +64,12 @@ public class SceneServiceImpl extends ServiceImpl<SceneMapper, Scene> implements
|
|
|
@Value("${scene.list-file-path}")
|
|
@Value("${scene.list-file-path}")
|
|
|
private String listFilePath;
|
|
private String listFilePath;
|
|
|
private static final String pattern = "^\\[\\d{2}:\\d{2}:\\d{2}\\]";
|
|
private static final String pattern = "^\\[\\d{2}:\\d{2}:\\d{2}\\]";
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private SceneReceiveLogService sceneReceiveLogService;
|
|
|
|
|
+ @Value("${scene.log.path}")
|
|
|
|
|
+ private String sceneLogPath;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public ResultData receive(Map<String, Object> params) {
|
|
public ResultData receive(Map<String, Object> params) {
|
|
@@ -139,6 +154,64 @@ public class SceneServiceImpl extends ServiceImpl<SceneMapper, Scene> implements
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
|
+ public ResultData receive3(HttpServletRequest request) throws Exception {
|
|
|
|
|
+ String id = request.getParameter("id");
|
|
|
|
|
+ String action = request.getParameter("action");
|
|
|
|
|
+ String fileName = request.getParameter("fileName");
|
|
|
|
|
+ String num = request.getParameter("num");
|
|
|
|
|
+ String zipPath = zipDir + id + "/";
|
|
|
|
|
+ String zipFilePath = zipPath.concat(fileName);
|
|
|
|
|
+ String zipType = request.getParameter("zipType");
|
|
|
|
|
+ String title = request.getParameter("title");
|
|
|
|
|
+ String shootCount = request.getParameter("shootCount");
|
|
|
|
|
+ SceneReceiveLog sceneReceiveLog = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ sceneReceiveLog = sceneReceiveLogService.getOne(new LambdaQueryWrapper<SceneReceiveLog>().eq(SceneReceiveLog::getTaskId, id));
|
|
|
|
|
+ if(sceneReceiveLog == null){
|
|
|
|
|
+ sceneReceiveLog = new SceneReceiveLog();
|
|
|
|
|
+ sceneReceiveLog.setTaskId(id);
|
|
|
|
|
+ sceneReceiveLog.setNum(num);
|
|
|
|
|
+ sceneReceiveLog.setStatus(CommonSuccessStatus.WAITING.code());
|
|
|
|
|
+ sceneReceiveLog.setCreateTime(DateExtUtil.format(new Date(), DateExtUtil.dateStyle));
|
|
|
|
|
+ sceneReceiveLog.setType(zipType);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if("upload".equals(action)){
|
|
|
|
|
+ InputStream ins = request.getPart("file").getInputStream();
|
|
|
|
|
+ FileUtil.mkParentDirs(zipFilePath);
|
|
|
|
|
+ FileUtil.writeFromStream(ins,zipFilePath);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ ZipFile zipFile = new ZipFile(new File(zipFilePath));
|
|
|
|
|
+ zipFile.extractAll(zipPath);
|
|
|
|
|
+ String scenePath = "kankan".equals(zipType) ? delpoyKankan : delpoyLaser;
|
|
|
|
|
+ FileUtil.copy(zipPath + num, scenePath, true);
|
|
|
|
|
+ Scene scene = lambdaQuery().eq(Scene::getNum, num).eq(Scene::getType, zipType).one();
|
|
|
|
|
+ if(scene == null){
|
|
|
|
|
+ scene = new Scene();
|
|
|
|
|
+ }
|
|
|
|
|
+ scene.setNum(num);
|
|
|
|
|
+ scene.setTitle(title);
|
|
|
|
|
+ scene.setType(zipType);
|
|
|
|
|
+ scene.setStatus(CommonSuccessStatus.SUCCESS.code());
|
|
|
|
|
+ scene.setUploadTime(DateExtUtil.format(new Date(), DateExtUtil.dateStyle));
|
|
|
|
|
+ scene.setShootCount(Integer.valueOf(shootCount));
|
|
|
|
|
+ scene.setSpace(FileUtil.size(new File(scenePath + num)));
|
|
|
|
|
+ this.saveOrUpdate(scene);
|
|
|
|
|
+
|
|
|
|
|
+ sceneReceiveLog.setStatus(CommonSuccessStatus.SUCCESS.code());
|
|
|
|
|
+ sceneReceiveLog.setCompletedTime(DateExtUtil.format(new Date(), DateExtUtil.dateStyle));
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }catch (Exception e){
|
|
|
|
|
+ log.error("场景部署失败,num:{}", num, e);
|
|
|
|
|
+ sceneReceiveLog.setStatus(CommonSuccessStatus.FAIL.code());
|
|
|
|
|
+ }finally {
|
|
|
|
|
+ sceneReceiveLogService.saveOrUpdate(sceneReceiveLog);
|
|
|
|
|
+ }
|
|
|
|
|
+ return ResultData.ok();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
public ResultData receive2(HttpServletRequest request) throws Exception {
|
|
public ResultData receive2(HttpServletRequest request) throws Exception {
|
|
|
String id = request.getParameter("id");
|
|
String id = request.getParameter("id");
|
|
|
String action = request.getParameter("action");
|
|
String action = request.getParameter("action");
|
|
@@ -176,9 +249,6 @@ public class SceneServiceImpl extends ServiceImpl<SceneMapper, Scene> implements
|
|
|
return ResultData.ok();
|
|
return ResultData.ok();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @Value("${scene.log.path}")
|
|
|
|
|
- private String sceneLogPath;
|
|
|
|
|
-
|
|
|
|
|
private void reWriteLog(String num, String logPath, int time){
|
|
private void reWriteLog(String num, String logPath, int time){
|
|
|
List<String> strings = FileUtil.readLines(logPath, StandardCharsets.UTF_8);
|
|
List<String> strings = FileUtil.readLines(logPath, StandardCharsets.UTF_8);
|
|
|
Date endTime = Calendar.getInstance().getTime();
|
|
Date endTime = Calendar.getInstance().getTime();
|
|
@@ -271,4 +341,24 @@ public class SceneServiceImpl extends ServiceImpl<SceneMapper, Scene> implements
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public PageInfo<Scene> listScene(ScenePageRequest request) {
|
|
|
|
|
+ Page<Scene> page = lambdaQuery().like(Scene::getTitle, request.getTitle()).page(Page.of(request.getPageNum(), request.getPageSize()));
|
|
|
|
|
+ return PageInfo.convert(page);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Scene getByNum(String num, String type) {
|
|
|
|
|
+ return lambdaQuery().eq(Scene::getNum, num).eq(Scene::getType, type).one();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public ResultData getDeployStatus(String taskId) {
|
|
|
|
|
+ SceneReceiveLog one = sceneReceiveLogService.getOne(new LambdaQueryWrapper<SceneReceiveLog>().eq(SceneReceiveLog::getTaskId, taskId));
|
|
|
|
|
+ if(one == null){
|
|
|
|
|
+ return ResultData.ok(0);
|
|
|
|
|
+ }
|
|
|
|
|
+ return ResultData.ok(one.getStatus());
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|