ソースを参照

新增获取进度接口

xiewj 1 年間 前
コミット
6f553710dd

+ 20 - 4
src/main/java/com/fdkankan/manage/inner/controller/InnerController.java

@@ -6,13 +6,14 @@ import com.fdkankan.manage.common.ResultCode;
 import com.fdkankan.manage.common.ResultData;
 import com.fdkankan.manage.common.ResultData;
 import com.fdkankan.manage.controller.BaseController;
 import com.fdkankan.manage.controller.BaseController;
 import com.fdkankan.manage.entity.RtkInfo;
 import com.fdkankan.manage.entity.RtkInfo;
+import com.fdkankan.manage.entity.ScenePlus;
+import com.fdkankan.manage.entity.ScenePlusExt;
+import com.fdkankan.manage.entity.ScenePro;
 import com.fdkankan.manage.exception.BusinessException;
 import com.fdkankan.manage.exception.BusinessException;
-import com.fdkankan.manage.service.ICommonService;
-import com.fdkankan.manage.service.IRtkInfoService;
-import com.fdkankan.manage.service.ISceneProService;
-import com.fdkankan.manage.service.IServiceUpTipService;
+import com.fdkankan.manage.service.*;
 import com.fdkankan.manage.util.RsaUtils;
 import com.fdkankan.manage.util.RsaUtils;
 import com.fdkankan.manage.vo.request.SceneParam;
 import com.fdkankan.manage.vo.request.SceneParam;
+import com.fdkankan.manage.vo.response.BuildSceneVO;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
@@ -36,6 +37,14 @@ public class InnerController extends BaseController {
     private ISceneProService sceneProService;
     private ISceneProService sceneProService;
     @Autowired
     @Autowired
     IServiceUpTipService serviceUpTipService;
     IServiceUpTipService serviceUpTipService;
+    @Autowired
+    IScenePlusService scenePlusService;
+    @Autowired
+    IScenePlusExtService scenePlusExtService;
+
+    @Autowired
+    IDataService dataService;
+
 
 
     @PostMapping("/move")
     @PostMapping("/move")
     public ResultData move(@RequestBody SceneParam param){
     public ResultData move(@RequestBody SceneParam param){
@@ -108,4 +117,11 @@ public class InnerController extends BaseController {
 //        }
 //        }
         return ResultData.ok(rtkInfo);
         return ResultData.ok(rtkInfo);
     }
     }
+
+
+    @GetMapping("/getSceneProgress")
+    public ResultData getSceneProgress(@RequestParam(required = false) String num){
+        BuildSceneVO progress=sceneProService.getSceneProgress(num);
+        return ResultData.ok(progress);
+    }
 }
 }

+ 3 - 0
src/main/java/com/fdkankan/manage/service/ISceneProService.java

@@ -6,6 +6,7 @@ import com.fdkankan.manage.entity.ScenePlus;
 import com.fdkankan.manage.entity.ScenePro;
 import com.fdkankan.manage.entity.ScenePro;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.fdkankan.manage.vo.request.SceneParam;
 import com.fdkankan.manage.vo.request.SceneParam;
+import com.fdkankan.manage.vo.response.BuildSceneVO;
 import com.fdkankan.manage.vo.response.GroupByCount;
 import com.fdkankan.manage.vo.response.GroupByCount;
 
 
 import java.util.HashMap;
 import java.util.HashMap;
@@ -63,4 +64,6 @@ public interface ISceneProService extends IService<ScenePro> {
     Object getRestStoreProcess(String num);
     Object getRestStoreProcess(String num);
 
 
     void restStoreSuccess(String num);
     void restStoreSuccess(String num);
+
+    BuildSceneVO getSceneProgress(String num);
 }
 }

+ 63 - 1
src/main/java/com/fdkankan/manage/service/impl/SceneProServiceImpl.java

@@ -3,6 +3,9 @@ package com.fdkankan.manage.service.impl;
 import cn.dev33.satoken.stp.StpUtil;
 import cn.dev33.satoken.stp.StpUtil;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.io.file.FileReader;
+import cn.hutool.core.util.NumberUtil;
+import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.json.JSONUtil;
 import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
@@ -38,6 +41,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
+import java.io.File;
 import java.util.*;
 import java.util.*;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 
 
@@ -105,7 +109,8 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
     IMqSendLogService mqSendLogService;
     IMqSendLogService mqSendLogService;
     @Autowired
     @Autowired
     OverallService overallService;
     OverallService overallService;
-
+    @Autowired
+    private ISceneProService sceneProService;
 
 
     @Override
     @Override
     public ScenePro getByNum(String num) {
     public ScenePro getByNum(String num) {
@@ -925,4 +930,61 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
         wrapper.in(ScenePro::getStatus,0,-2);
         wrapper.in(ScenePro::getStatus,0,-2);
         return this.count(wrapper);
         return this.count(wrapper);
     }
     }
+
+    @Override
+    public BuildSceneVO getSceneProgress(String num) {
+        //V3
+        ScenePro scenePro = sceneProService.getByNum(num);
+        //V4
+        ScenePlus plus = scenePlusService.getByNum(num);
+        if(scenePro == null && plus == null){
+            throw new BusinessException(SceneConstant.FAILURE_CODE_5005, SceneConstant.FAILURE_MSG_5005);
+        }
+        String dataSource ="";
+        Integer sceneStatus =null;
+        if (ObjectUtil.isNotNull(plus)){
+            ScenePlus scenePlus = scenePlusService.getByNum(num);
+            sceneStatus = scenePlus.getSceneStatus();
+            //=-2 =0计算中 -1=失败
+            ScenePlusExt scenePlusExt = scenePlusExtService.getByPlusId(scenePlus.getId());
+            if (ObjectUtil.isNotNull(scenePlus)){
+                dataSource=scenePlusExt.getDataSource();
+            }
+        }else {
+              dataSource = scenePro.getDataSource();
+            sceneStatus = scenePro.getStatus();
+        }
+        BuildSceneVO buildSceneVO = new BuildSceneVO();
+        //=-2 =0计算中 -1=失败
+        if (sceneStatus == 0){
+            //去目录检查project.json
+            File projectJson = FileUtil.file(dataSource + File.separator + "project.json");
+            if (FileUtil.exist(projectJson)) {
+                FileReader reader = new FileReader(projectJson);
+                String data = reader.readString();
+                JSONObject data_project = JSONObject.parseObject(data);
+                if (data_project.containsKey("progress")) {
+                    JSONObject state = data_project.getJSONObject("state");
+                    Double progress = state.getDouble("progress");
+                    if (ObjectUtil.isNotNull(progress)) {
+                        if (progress == 1){
+                            buildSceneVO.setProgress(90);
+                        }else {
+                            progress = NumberUtil.mul(progress, new Double(100.00));
+                            buildSceneVO.setProgress(progress.intValue());
+                        }
+                    }
+                }else {
+                    buildSceneVO.setProgress(0);
+                }
+            }
+        }else if (sceneStatus == -2){
+            buildSceneVO.setProgress(100);
+        }else if (sceneStatus == -1){
+            buildSceneVO.setProgress(0);
+        }
+        buildSceneVO.setProgress(sceneStatus);
+        buildSceneVO.setNum(num);
+        return buildSceneVO;
+    }
 }
 }

+ 18 - 0
src/main/java/com/fdkankan/manage/vo/response/BuildSceneVO.java

@@ -0,0 +1,18 @@
+package com.fdkankan.manage.vo.response;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * Created by Xiewj on 2021/11/24 0026 10:14
+ * 特殊点坐标
+ */
+@Data
+public class BuildSceneVO {
+
+    private int progress;
+    private String num;
+    private int status;
+
+}