Explorar o código

Merge remote-tracking branch 'origin/release-swsx' into test

# Conflicts:
#	src/main/java/com/fdkankan/modeling/receiver/RabbitMqListener.java
dengsixing hai 3 meses
pai
achega
70ae332f9f

+ 6 - 0
pom.xml

@@ -129,6 +129,12 @@
 			<version>1.5.0</version>
 		</dependency>
 
+		<dependency>
+			<groupId>com.fdkankan</groupId>
+			<artifactId>4dkankan-utils-fyun-oss</artifactId>
+			<version>3.0.0-SNAPSHOT</version>
+		</dependency>
+
 	</dependencies>
 
 	<build>

+ 28 - 23
src/main/java/com/fdkankan/modeling/ModelingApplication.java

@@ -1,16 +1,14 @@
 package com.fdkankan.modeling;
 
-import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.util.StrUtil;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
 import com.fdkankan.model.utils.CreateObjUtil;
-import com.fdkankan.modeling.constants.SysConstants;
-import com.fdkankan.modeling.entity.BuildLog;
-import com.fdkankan.modeling.service.IBuildLogService;
+import com.fdkankan.redis.util.RedisLockUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.CommandLineRunner;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -18,7 +16,8 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.scheduling.annotation.EnableScheduling;
 
-import java.util.List;
+import javax.annotation.Resource;
+import java.util.Optional;
 
 @SpringBootApplication
 @EnableScheduling
@@ -28,8 +27,14 @@ import java.util.List;
 @Slf4j
 public class ModelingApplication implements CommandLineRunner {
 
-	@Autowired
-	private IBuildLogService buildLogService;
+	@Resource
+	private RedisLockUtil redisLockUtil;
+
+	@Value("${spring.profiles.active:#{null}}")
+	private String profiles;
+
+	@Autowired(required = false)
+	private Optional<FYunFileServiceInterface> fYunFileService;
 
 	public static void main(String[] args) {
 
@@ -43,20 +48,20 @@ public class ModelingApplication implements CommandLineRunner {
 	@Override
 	public void run(String... args) throws Exception {
 
-//		String lockPath = null;
-//		try {
-//			if(StrUtil.isNotEmpty(SysConstants.hostName)){
-//				List<BuildLog> list = buildLogService.list(new LambdaQueryWrapper<BuildLog>().eq(BuildLog::getHostName, SysConstants.hostName).eq(BuildLog::getStatus, 0).orderByDesc(BuildLog::getId));
-//				if(CollUtil.isNotEmpty(list)){
-//					BuildLog buildLog = list.get(0);
-//					lockPath = buildLog.getDataSource() + "/.lockdirectory";
-//					if(FileUtil.exist(lockPath)){
-//						FileUtil.del(lockPath);
-//					}
-//				}
-//			}
-//		}catch (Exception e){
-//			log.warn("删除上一计算中场景文件锁失败,logPath:{}", lockPath, e);
-//		}
+		log.info("fYunFileService.isPresent():{}", fYunFileService.isPresent());
+		if(fYunFileService.isPresent() && StrUtil.isNotEmpty(profiles)){
+			//更新弹性伸缩jar包
+			boolean lock = redisLockUtil.lock("uploadModelingJar", 300);
+			try {
+				if(lock){
+					String jarPath = System.getProperty("java.class.path");
+					fYunFileService.get().uploadFile(jarPath, "elastic_model_jar/fdkk_" + profiles + "/" + FileUtil.getName(jarPath));
+				}
+			}finally {
+				redisLockUtil.unlockLua("uploadModelingJar");
+			}
+
+		}
+
 	}
 }

+ 0 - 12
src/main/java/com/fdkankan/modeling/handler/LaserSceneObjGenerateHandler.java

@@ -19,18 +19,6 @@ public class LaserSceneObjGenerateHandler implements SceneHandler {
     public void handle(Map<String, String> context) throws Exception {
         try {
             String laserObjFilePath = context.get("path");
-            String cameraType = context.get("cameraType");
-            String algorithm = context.get("algorithm");
-            String resolution = context.get("resolution");
-            JSONObject fdageData = JSONObject.parseObject(context.get("dataJson"));
-            String projectNum = context.get("projectNum");
-
-            Map<String, String> dataMap = ComputerUtil.getTypeString(cameraType, algorithm, resolution, fdageData);
-            Map<String, Object> dataExtras = new HashMap<>(1);
-            dataExtras.put("big_depthmap", true);
-            ComputerUtil.createProjectAndDataFile(laserObjFilePath, projectNum, dataMap.get("splitType"),
-                    dataMap.get("skyboxType"), null, dataExtras);
-
             //计算模型并返回需要上传oss的文件集合
             CreateObjUtil.build3dModel(laserObjFilePath, "");
 

+ 4 - 62
src/main/java/com/fdkankan/modeling/receiver/RabbitMqListener.java

@@ -106,7 +106,6 @@ public class RabbitMqListener {
      * @throws Exception
      */
     @RabbitListener(
-            //queuesToDeclare = @Queue("${queue.modeling.modeling-call}"),
             queuesToDeclare = @Queue("#{queueNameService.getQueueName()}"),
             concurrency = "${maxThread.modeling.modeling-call}",
             priority = "${mq.consumerPriority}"
@@ -177,8 +176,6 @@ public class RabbitMqListener {
         StopWatch watch = new StopWatch();
         watch.start();
 
-        String num = message.getSceneNum();
-
         //发送记录计算状态为计算中
         this.sendCallBuildProcessLog(message, ModelingBuildStatus.CALCULATING);
 
@@ -248,68 +245,17 @@ public class RabbitMqListener {
         String num = message.getSceneNum();
         //不同的相机不同的方法
         String cameraType = message.getCameraType();
-        String algorithm = message.getAlgorithm();
-        //0表示有4k图,1表示没有
-        String resolution = message.getResolution();
         //判断调用V2还是V3版本的算法
         String buildType = ObjectUtils.isEmpty(message.getBuildType()) ? "V2" : message.getBuildType();
+        if(StrUtil.isEmpty(buildType)){
+            buildType = "V3";
+        }
 
         buildSceneResult.setCameraType(cameraType);
         buildSceneResult.setNum(num);
         buildSceneResult.setPath(path);
 
-        log.info("用的算法是:" + algorithm);
-
-        String dataFdagePath = path + File.separator + "capture" +File.separator+"data.fdage";
-        log.info("dataFdagePath 文件路径 :{}", dataFdagePath);
-        String data = FileUtils.readFile(dataFdagePath);
-        //获取data.fdage的内容
-        JSONObject dataJson = new JSONObject();
-        if(data!=null){
-            dataJson = JSONObject.parseObject(data);
-        }
-
-        if (dataJson.containsKey("OnlyExportMeshObj")) {
-            logRecord.setBuildType(2);
-            Map<String, String> context = new HashMap<>();
-            context.put("path", path);
-            context.put("cameraType", cameraType);
-            context.put("algorithm", algorithm);
-            context.put("resolution", resolution);
-            context.put("projectNum", num);
-            context.put("dataJson", data);
-            try {
-                laserSceneObjGenerateHandler.handle(context);
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
-
-            // 检测计算结果文件是否有生成
-            String resultsPath = path + File.separator + "results" + File.separator;
-            if (!new File(resultsPath + "upload.json").exists()) {
-                log.error("未检测到计算结果文件:upload.json");
-                result.put("status", ModelingBuildStatus.FAILED);
-                result.put("errorType", 2);
-                return result;
-            }
-
-            result.put("status", ModelingBuildStatus.SUCCESS);
-            return result;
-        }
-
-        Map<String, String> dataMap = buildService.getTypeString(cameraType, algorithm, resolution,dataJson);
-
-        String splitType = dataMap.get("splitType");
-        String skyboxType = dataMap.get("skyboxType");
-        if(Objects.nonNull(message.getExt().get("splitType"))){
-            splitType = (String) message.getExt().get("splitType");
-        }
-        if(Objects.nonNull(message.getExt().get("skyboxType"))){
-            skyboxType = (String) message.getExt().get("skyboxType");
-        }
-
-        ComputerUtil.createProjectAndDataFile(path,num, splitType, skyboxType,null,null);
-        //计算模型并返回需要上传oss的文件集合
+        //调用算法
         ComputerUtil.computer(num, path, buildType);
 
         // 检测计算结果文件是否有生成
@@ -358,10 +304,6 @@ public class RabbitMqListener {
         buildSceneResult.setNum(num);
         buildSceneResult.setPath(path);
 
-        String splitType = "SPLIT_V27";
-        String skyboxType = "SKYBOX_V5";
-
-        ComputerUtil.createProjectAndDataFile(path,num, splitType, skyboxType,null,null);
         //计算模型并返回需要上传oss的文件集合
         ComputerUtil.computer(num, path, "V3");
 

+ 1 - 6
src/main/java/com/fdkankan/modeling/service/impl/BuildServiceImpl.java

@@ -20,7 +20,6 @@ public class BuildServiceImpl implements IBuildService {
         Map<String, String> map = new HashMap<>();
         String splitType = "";
         String skyboxType = "";
-        String dataDescribe = "";
         if(Integer.parseInt(cameraType) >= 4){
             if("0".equals(resolution)){
 //            skyboxType = "SKYBOX_V4";  //tiles
@@ -31,9 +30,8 @@ public class BuildServiceImpl implements IBuildService {
             }
             splitType = "SPLIT_V1";
 //            skyboxType = "SKYBOX_V4";  //tiles
-            dataDescribe = "double spherical";
 
-            if(Integer.parseInt(cameraType) == 5 ){
+            if(Integer.parseInt(cameraType) == 5){
                 //新双目相机
 //              skyboxType = "SKYBOX_V9";
                 splitType = "SPLIT_V9";
@@ -76,11 +74,9 @@ public class BuildServiceImpl implements IBuildService {
             if("sfm".equals(algorithm)){
                 splitType = "SPLIT_V2";
                 skyboxType = "SKYBOX_V1";
-                dataDescribe = "old sfm";
             }else {
                 splitType = "SPLIT_V3";
                 skyboxType = "SKYBOX_V1";
-                dataDescribe = "old slam";
             }
         }
         if (!ObjectUtils.isEmpty(fdageData) && !ObjectUtils.isEmpty(fdageData.getString("modelType"))) {
@@ -101,7 +97,6 @@ public class BuildServiceImpl implements IBuildService {
         }
         map.put("splitType", splitType);
         map.put("skyboxType", skyboxType);
-        map.put("dataDescribe", dataDescribe);
         return map;
     }
 }

+ 0 - 32
src/main/java/com/fdkankan/modeling/service/impl/ReverseE57ServiceImpl.java

@@ -173,18 +173,6 @@ public class ReverseE57ServiceImpl implements IReverseE57Service {
         buildSceneResult.setNum(num);
         buildSceneResult.setPath(path);
 
-        String splitType = "SPLIT_V29";
-        String skyboxType = "SKYBOX_V11";
-        String otherType = (String)message.getExt().get("otherType");
-        Integer isObj = (Integer) message.getExt().get("isObj");
-        if(StrUtil.isNotEmpty(modelType) && ModelTypeEnums.TILE_CODE.equals(modelType)){
-            skyboxType = "SKYBOX_V15";
-        }
-        if(Objects.nonNull(isObj) && isObj == CommonStatus.YES.code().intValue()){
-            splitType = "SPLIT_V30";
-        }
-
-        this.createProjectAndDataFile(path,num, splitType, skyboxType,otherType,null,null);
         //计算模型并返回需要上传oss的文件集合
         ComputerUtil.computer(num, path, buildType);
 
@@ -199,25 +187,5 @@ public class ReverseE57ServiceImpl implements IReverseE57Service {
         return ModelingBuildStatus.SUCCESS;
     }
 
-    public void createProjectAndDataFile(String path, String sceneNum, String splitType, String skyboxType, String otherType, Map<String, Object> projectExtras, Map<String, Object> dataExtras) {
-        JSONObject projectJson = new JSONObject();
-        if (!org.apache.commons.lang3.ObjectUtils.isEmpty(projectExtras)) {
-            projectJson.putAll(projectExtras);
-        }
-
-        projectJson.put("sceneNum", sceneNum);
-        FileUtils.writeFile(path + File.separator + "project.json", projectJson.toString());
-        JSONObject dataJson = new JSONObject();
-        if (!org.apache.commons.lang3.ObjectUtils.isEmpty(dataExtras)) {
-            dataJson.putAll(dataExtras);
-        }
-
-        dataJson.put("split_type", splitType);
-        dataJson.put("skybox_type", skyboxType);
-        dataJson.put("extras", (Object)null);
-        dataJson.put("other_type", otherType);
-        FileUtils.writeFile(path + File.separator + "data.json", dataJson.toString());
-    }
-
 
 }