Browse Source

loc commit

xiewj 2 years ago
parent
commit
6d5f2de25a

+ 11 - 10
pom.xml

@@ -72,6 +72,10 @@
                     <groupId>org.bytedeco</groupId>
                     <artifactId>javacpp</artifactId>
                 </exclusion>
+                <exclusion>
+                    <groupId>org.bytedeco</groupId>
+                    <artifactId>javacv-platform</artifactId>
+                </exclusion>
             </exclusions>
         </dependency>
 
@@ -100,6 +104,10 @@
                     <groupId>org.bytedeco</groupId>
                     <artifactId>javacpp</artifactId>
                 </exclusion>
+                <exclusion>
+                    <groupId>org.bytedeco</groupId>
+                    <artifactId>javacv-platform</artifactId>
+                </exclusion>
             </exclusions>
         </dependency>
 
@@ -198,18 +206,11 @@
         </dependency>
         <dependency>
             <groupId>org.bytedeco</groupId>
-            <artifactId>opencv</artifactId>
-            <version>4.5.5-${javacv.version}</version>
-            <classifier>linux-x86_64</classifier>
-        </dependency>
-        <dependency>
-            <groupId>org.bytedeco</groupId>
-            <artifactId>openblas</artifactId>
-            <version>0.3.19-${javacv.version}</version>
-            <classifier>linux-x86_64</classifier>
+            <artifactId>ffmpeg</artifactId>
+            <version>5.0-${javacv.version}</version>
+            <classifier>windows-x86_64</classifier>
         </dependency>
 
-
     </dependencies>
 
     <dependencyManagement>

+ 13 - 0
src/main/java/com/fdkankan/scene/SceneApplication.java

@@ -2,23 +2,29 @@ package com.fdkankan.scene;
 
 import cn.hutool.core.io.FileUtil;
 import cn.hutool.extra.spring.SpringUtil;
+import com.fdkankan.redis.constant.RedisKey;
+import com.fdkankan.redis.util.RedisUtil;
 import com.fdkankan.scene.config.FdkkLaserConfig;
 import lombok.extern.slf4j.Slf4j;
 import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.context.annotation.ComponentScan;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.transaction.annotation.EnableTransactionManagement;
 
 import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
+import java.util.Collection;
 
 @SpringBootApplication
 @EnableTransactionManagement//开启事务
 @ComponentScan(basePackages = {"com.fdkankan.*"})
 @MapperScan("com.fdkankan.**.mapper")
 @Slf4j
+@EnableScheduling
 public class SceneApplication {
     public static void main(String[] args) throws IOException {
         SpringApplication.run(SceneApplication.class, args);
@@ -32,5 +38,12 @@ public class SceneApplication {
             writer.write("1");
             writer.flush();
         }
+        RedisUtil redisUtil = SpringUtil.getBean(RedisUtil.class);
+        redisUtil.del(RedisKey.SCENE_DOWNLOAD_ING);
+//        String nameSpace = SocketIoConstant.SCENE_HANDLER_SPACE.replace("/", "");
+//        Collection<String> keys = cache.keys(nameSpace + "*");
+//        for (String key : keys) {
+//            cache.deleteObject(key);
+//        }
     }
 }

+ 9 - 8
src/main/java/com/fdkankan/scene/config/InterceptorConfig.java

@@ -12,18 +12,18 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 @Configuration
 public class InterceptorConfig implements WebMvcConfigurer {
 
-	@Autowired
-	private TokenInterceptor tokenInterceptor;
+//	@Autowired
+//	private TokenInterceptor tokenInterceptor;
 
-//	@Override
-//	public void addCorsMappings(CorsRegistry registry) {
-//		registry.addMapping("/**").allowCredentials(true).allowedHeaders("*").allowedOrigins("*").allowedMethods("*");
-//
-//	}
+	@Override
+	public void addCorsMappings(CorsRegistry registry) {
+		registry.addMapping("/**").allowCredentials(true).allowedHeaders("*").allowedOrigins("*").allowedMethods("*");
+
+	}
 
 	@Override
 	public void addInterceptors(InterceptorRegistry registry) {
-		registry.addInterceptor(tokenInterceptor).addPathPatterns("/service/scene/edit/**");
+//		registry.addInterceptor(tokenInterceptor).addPathPatterns("/service/scene/edit/**");
 //				.excludePathPatterns("/**/sso/**","/app/**","/test/**","/**/inner/**")
 
 		WebMvcConfigurer.super.addInterceptors(registry);
@@ -31,6 +31,7 @@ public class InterceptorConfig implements WebMvcConfigurer {
 
 	@Override
 	public void addResourceHandlers(ResourceHandlerRegistry registry) {
+		registry.addResourceHandler( "/profile/**").addResourceLocations("file:" + FdkkLaserConfig.getProfile() + "/");
 		WebMvcConfigurer.super.addResourceHandlers(registry);
 	}
 

+ 7 - 1
src/main/java/com/fdkankan/scene/oss/OssUtil.java

@@ -319,7 +319,13 @@ public class OssUtil {
                 return aliyunOssTemplate.downloadFile(pathKey, file);
             }
         }else{
-            File copy = FileUtil.copy(new File(FdkkLaserConfig.getProfile() + File.separator + pathKey),
+            String copyPath="";
+            if (pathKey.contains(FdkkLaserConfig.getProfile())){
+                copyPath=pathKey;
+            }else {
+                copyPath=FdkkLaserConfig.getProfile() + File.separator + pathKey;
+            }
+            File copy = FileUtil.copy(new File(copyPath),
                     new File(file), true);
             return copy.exists();
         }

+ 24 - 14
src/main/java/com/fdkankan/scene/service/impl/SceneDownloadHandlerServiceImpl.java

@@ -8,9 +8,11 @@ import cn.hutool.core.exceptions.ExceptionUtil;
 import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.core.util.ZipUtil;
+import cn.hutool.extra.spring.SpringUtil;
 import cn.hutool.http.HttpUtil;
 import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.fdkankan.common.constant.ErrorCode;
 import com.fdkankan.common.constant.SceneDownloadProgressStatus;
 import com.fdkankan.common.constant.SceneKind;
@@ -18,13 +20,11 @@ import com.fdkankan.common.constant.ServerCode;
 import com.fdkankan.common.exception.BusinessException;
 import com.fdkankan.common.util.FileUtils;
 import com.fdkankan.scene.bean.*;
-import com.fdkankan.scene.entity.ScenePlus;
-import com.fdkankan.scene.entity.ScenePlusExt;
-import com.fdkankan.scene.entity.ScenePro;
+import com.fdkankan.scene.config.FdkkLaserConfig;
+import com.fdkankan.scene.config.ServiceConfig;
+import com.fdkankan.scene.entity.*;
 import com.fdkankan.scene.oss.OssUtil;
-import com.fdkankan.scene.service.IScenePlusExtService;
-import com.fdkankan.scene.service.IScenePlusService;
-import com.fdkankan.scene.service.ISceneProService;
+import com.fdkankan.scene.service.*;
 import com.fdkankan.model.constants.UploadFilePath;
 import com.fdkankan.redis.constant.RedisKey;
 import com.fdkankan.redis.util.RedisUtil;
@@ -99,8 +99,6 @@ public class SceneDownloadHandlerServiceImpl {
     private int zipNthreads;
     @Value("${fyun.bucket:4dkankan}")
     private String bucket;
-    @Value("${fyun.type}")
-    private String uploadType;
     @Value("${download.config.resource-url}")
     private String resourceUrl;
     @Value("${download.config.public-url}")
@@ -122,6 +120,8 @@ public class SceneDownloadHandlerServiceImpl {
     private IScenePlusExtService scenePlusExtService;
     @Autowired
     private ISceneProService sceneProService;
+    @Autowired
+    ISceneDownloadLogService sceneDownloadLogService;
 
     @Async("sceneDownLoadExecutror")
     public void download(DownLoadTaskBean downLoadTaskBean){
@@ -144,6 +144,11 @@ public class SceneDownloadHandlerServiceImpl {
             log.info("场景下载结束 - num[{}] - threadName[{}] - consumeTime[{}]", num, Thread.currentThread().getName(), consumeTime);
 
         }catch (Exception e){
+            sceneDownloadLogService.update(
+                    new LambdaUpdateWrapper<SceneDownloadLog>()
+                    .eq(SceneDownloadLog::getSceneNum,num)
+                    .set(SceneDownloadLog::getStatus,2)
+            );
             log.error(ExceptionUtil.stacktraceToString(e));
         }finally {
             if(StrUtil.isNotEmpty(num)){
@@ -255,9 +260,10 @@ public class SceneDownloadHandlerServiceImpl {
             //上传压缩包
             String uploadPath = String.format(this.zipOssFormat, num);
             ossUtil.uploadFile(uploadPath, zipPath, false);
+            ServiceConfig serviceConfig = SpringUtil.getBean(ServiceConfig.class);
 
             //更新进度100
-            String url = this.publicUrl + uploadPath + "?t=" + Calendar.getInstance().getTimeInMillis();
+            String url = "/" + uploadPath + "?t=" + Calendar.getInstance().getTimeInMillis();
             this.updateProgress(null, num, SceneDownloadProgressStatus.DOWNLOAD_SUCCESS.code(), url, "v4");
 
         }catch (Exception e){
@@ -332,9 +338,10 @@ public class SceneDownloadHandlerServiceImpl {
             //上传压缩包
             String uploadPath = String.format(this.zipOssFormat, num);
             ossUtil.uploadFile(uploadPath, zipPath, false);
+            ServiceConfig serviceConfig = SpringUtil.getBean(ServiceConfig.class);
 
             //更新进度100
-            String url = this.publicUrl + uploadPath + "?t=" + Calendar.getInstance().getTimeInMillis();
+            String url = "/" + uploadPath + "?t=" + Calendar.getInstance().getTimeInMillis();
             this.updateProgress(null, num, SceneDownloadProgressStatus.DOWNLOAD_SUCCESS.code(), url, "v3");
 
         }catch (Exception e){
@@ -536,6 +543,7 @@ public class SceneDownloadHandlerServiceImpl {
         JSONObject controls = sceneJson.getJSONObject("controls");
         controls.set("showLock", 0);
         String sceneJsonPath = String.format(UploadFilePath.DATA_VIEW_PATH, num) + "scene.json";
+
         String sceneJsonStr = sceneJson.toString().replace(this.publicUrl, "");
         FileUtil.writeUtf8String(sceneJsonStr, String.format(this.sourceLocal, num, this.wwwroot + sceneJsonPath));
     }
@@ -544,7 +552,8 @@ public class SceneDownloadHandlerServiceImpl {
 
         //访问密码置0
         String getInfoKey = String.format("data/data%s/", num) + "getInfo.json";
-        String getInfoStr = getInfo.toString().replace(this.publicUrl, "");
+
+        String getInfoStr = getInfo.toString().replace(this.publicUrl , "");
         FileUtil.writeUtf8String(getInfoStr, String.format(this.sourceLocal, num, this.wwwroot + getInfoKey));
     }
 
@@ -633,14 +642,15 @@ public class SceneDownloadHandlerServiceImpl {
                 .replace("https://spc.html","spc.html")
                 .replace("https://smobile.html", "smobile.html");
 
-            FileUtil.writeUtf8String(content, String.format(sourceLocal, num, prefix + key));
+            FileUtil.writeUtf8String(content, String.format(sourceLocal, num, prefix + key.replace(FdkkLaserConfig.getProfile(),"")));
         }else{
 //            HttpUtil.downloadFile(url, String.format(sourceLocal, num, prefix + key));
             try {
-                ossUtil.downloadFile(key, String.format(sourceLocal, num, prefix + key));
+
+                ossUtil.downloadFile(key,String.format(sourceLocal, num, prefix + key.replace(FdkkLaserConfig.getProfile(),"")));
 //                this.downloadFile(url, String.format(sourceLocal, num, prefix + key));
             }catch (Exception e){
-                log.info("下载文件报错,path:{}", String.format(sourceLocal, num, prefix + key));
+                log.info("下载文件报错,path:{}", key);
             }
         }
     }

+ 27 - 9
src/main/java/com/fdkankan/scene/service/impl/SceneDownloadLogServiceImpl.java

@@ -1,15 +1,20 @@
 package com.fdkankan.scene.service.impl;
 
+import cn.hutool.extra.spring.SpringUtil;
 import com.alibaba.fastjson.JSON;
 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.SceneVersionType;
+import com.fdkankan.common.constant.UploadStatus;
 import com.fdkankan.common.exception.BusinessException;
 import com.fdkankan.common.util.JwtUtil;
+import com.fdkankan.model.constants.UploadFilePath;
 import com.fdkankan.redis.constant.RedisKey;
 import com.fdkankan.redis.util.RedisUtil;
 import com.fdkankan.scene.bean.SceneJsonBean;
+import com.fdkankan.scene.config.ServiceConfig;
 import com.fdkankan.scene.entity.SceneDownloadLog;
 import com.fdkankan.scene.entity.SceneEditInfo;
 import com.fdkankan.scene.entity.ScenePlus;
@@ -23,6 +28,7 @@ import com.fdkankan.web.bean.DownLoadProgressBean;
 import com.fdkankan.web.response.ResultData;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import java.util.HashMap;
@@ -41,7 +47,8 @@ import java.util.Objects;
 public class SceneDownloadLogServiceImpl extends ServiceImpl<ISceneDownloadLogMapper, SceneDownloadLog> implements ISceneDownloadLogService {
 
     private static String keyFormat = "touch:scene:download:num:%s";
-
+    @Value("${download.config.public-url}")
+    private String publicUrl;
     @Autowired
     private IScenePlusService scenePlusService;
     @Autowired
@@ -51,6 +58,9 @@ public class SceneDownloadLogServiceImpl extends ServiceImpl<ISceneDownloadLogMa
     @Autowired
     private RedisUtil redisUtil;
 
+    @Autowired
+    private ServiceConfig serviceConfig;
+
 
     @Override
     public ResultData downOfflineScene(String num) {
@@ -61,10 +71,11 @@ public class SceneDownloadLogServiceImpl extends ServiceImpl<ISceneDownloadLogMa
         }
 
         Map<String, Object> result = new HashMap<>();
-
-        String sceneJson = ossUtil.getFileContent(String.format(RedisKey.SCENE_JSON, num));
+        String sceneJsonPath = String.format(UploadFilePath.DATA_VIEW_PATH+"scene.json", num);
+        String sceneJson = ossUtil.getFileContent(sceneJsonPath);
         SceneJsonBean sceneJsonBean = JSON.parseObject(sceneJson, SceneJsonBean.class);
         int version = sceneJsonBean.getVersion();
+        redisUtil.set(String.format(keyFormat, num), "1");
 
         SceneDownloadLog sceneDownloadLog = this.getOne(
                 new LambdaQueryWrapper<SceneDownloadLog>()
@@ -78,13 +89,12 @@ public class SceneDownloadLogServiceImpl extends ServiceImpl<ISceneDownloadLogMa
                 return ResultData.ok(result);
             }
             if(sceneDownloadLog.getStatus() == 2){
-                result.put("status", -1);
-                return ResultData.ok(result);
+                result.put("status", 3);
+                download = true;
             }
             if(version == sceneDownloadLog.getSceneVersion()){
                 result.put("status", 2);
-                result.put("url", sceneDownloadLog.getDownloadUrl());
-                redisUtil.set(String.format(keyFormat, num), "1");
+                result.put("url",this.publicUrl+":"+serviceConfig.getServerPort()+ sceneDownloadLog.getDownloadUrl());
                 return ResultData.ok(result);
             }else{
                 result.put("status", 3);
@@ -96,8 +106,6 @@ public class SceneDownloadLogServiceImpl extends ServiceImpl<ISceneDownloadLogMa
         }
         if(download){
 
-            redisUtil.set(String.format(keyFormat, num), "1");
-
             //清除之前的下载记录
             this.remove(new LambdaQueryWrapper<SceneDownloadLog>().eq(SceneDownloadLog::getSceneNum, num));
 
@@ -121,6 +129,16 @@ public class SceneDownloadLogServiceImpl extends ServiceImpl<ISceneDownloadLogMa
     public ResultData downloadProcess(String num) {
         String processStr = redisUtil.get(String.format(RedisKey.PREFIX_DOWNLOAD_PROGRESS_V4,num));
         DownLoadProgressBean downLoadProgressBean = JSONObject.parseObject(processStr, DownLoadProgressBean.class);
+        if (downLoadProgressBean.getStatus()== 1002){
+            //写库
+            update(
+                    new LambdaUpdateWrapper<SceneDownloadLog>()
+                            .eq(SceneDownloadLog::getSceneNum,num)
+                            .set(SceneDownloadLog::getDownloadUrl,downLoadProgressBean.getUrl())
+            );
+
+            downLoadProgressBean.setUrl(this.publicUrl+":"+serviceConfig.getServerPort()+downLoadProgressBean.getUrl());
+        }
         return ResultData.ok(downLoadProgressBean);
     }
 

+ 0 - 4
src/main/java/com/fdkankan/scene/service/impl/SceneEditInfoServiceImpl.java

@@ -57,10 +57,6 @@ import java.util.stream.Collectors;
 @Service
 public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper, SceneEditInfo> implements ISceneEditInfoService {
 
-    @Value("${fyun.host}")
-    private String ossUrlPrefix;
-    @Value("${fyun.type}")
-    private String fyunType;
     @Value("${ecs.checkFile.maxTimes:20}")
     private int maxCheckTimes;
     @Value("${ecs.checkFile.waitTime:1000}")

+ 1 - 0
src/main/java/com/fdkankan/scene/service/impl/ScenePlusServiceImpl.java

@@ -283,6 +283,7 @@ public class ScenePlusServiceImpl extends ServiceImpl<IScenePlusMapper, ScenePlu
         scenePlusExt.setSceneScheme(sceneScheme);
         scenePlusExt.setSceneResolution(sceneResolution);
         scenePlusExt.setSceneFrom(sceneFrom);
+        scenePlusExt.setModelKind("3dtiles");
         scenePlusExt.setSceneKind(SceneKind.FACE.code());
         scenePlusExtService.save(scenePlusExt);
 

+ 0 - 4
src/main/java/com/fdkankan/scene/service/impl/SceneProServiceImpl.java

@@ -64,10 +64,6 @@ import java.util.stream.Collectors;
 @Service
 public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro> implements ISceneProService {
 
-    @Value("${fyun.host}")
-    private String ossUrlPrefix;
-    @Value("${fyun.type}")
-    private String fyunType;
     @Value("${main.url}")
     private String mainUrl;
     @Value("${scene.url}")

+ 34 - 7
src/main/resources/application-dev.yml

@@ -32,7 +32,7 @@ minio:
     bucket-custom-domain:
       laser-data: 1
 server:
-  port: 8085
+  port: 9101
   servlet:
     context-path: /
   tomcat:
@@ -43,9 +43,9 @@ spring:
     type: com.alibaba.druid.pool.DruidDataSource
     druid:
       druid:
-      url: jdbc:mysql://192.168.0.211:13306/4dkankan_v4?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8
+      url: jdbc:mysql://127.0.0.1:3307/laser?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8
       username: root
-      password: 4dkk2020cuikuan%
+      password: laser
       driver-class-name: com.mysql.cj.jdbc.Driver
       filters: stat,wall,config
       max-active: 100
@@ -62,8 +62,8 @@ spring:
       max-open-prepared-statements: 50
       max-pool-prepared-statement-per-connection-size: 20
   redis:
-    host: 192.168.0.211
-    port: 6379
+    host: 127.0.0.1
+    port: 16379
     password:
     timeout: 6000ms
     jedis:
@@ -87,5 +87,32 @@ scene:
     new:
       url: smg.html?m=
 
-
-
+##场景下载相关-----------------------------------------start
+zip:
+  nThreads: 10
+path:
+  v4school: ${PROFILE_PATH}v4local
+  v3school:
+  source-local: ${PROFILE_PATH}offline/%s/%s
+  zip-root: wwwroot/
+  zip-local: ${PROFILE_PATH}offline/%s.zip
+  zip-oss: downloads/scenes/%s.zip
+download:
+  config:
+    public-url: http://127.0.0.1
+    resource-url:
+    exe-name: start-browser.bat
+    exe-content: | # | 表示不转义特殊字符
+      taskkill /f /t /im http.exe
+      start http://127.0.0.1:9000/spg.html?m=%s
+      http.exe -nc -p 9000 -r wwwroot
+    exe-content-v3: | # | 表示不转义特殊字符
+      taskkill /f /t /im http.exe
+      start http://127.0.0.1:9000/spc.html?m=%s
+      http.exe -nc -p 9000 -r wwwroot
+url:
+  v3:
+    getInfo:
+##场景下载相关-----------------------------------------end
+inner:
+  customToken:

+ 9 - 9
src/main/resources/application-standAloneProd.yml

@@ -32,7 +32,7 @@ minio:
     bucket-custom-domain:
       laser-data: 1
 server:
-  port: 8085
+  port: 9101
   servlet:
     context-path: /
   tomcat:
@@ -79,7 +79,7 @@ logging:
   fdkk:
     maxHistory: 1
     level: off
-  path: ${4DKK_HOME}/log
+  path: ${FDMGEA_HOME}/bin/log
 
 main:
   url: https://test.4dkankan.com
@@ -94,15 +94,15 @@ scene:
 zip:
   nThreads: 10
 path:
-  v4school: /home/backend/4dkankan_v4/download/v4local/
-  v3school: /home/backend/4dkankan_v4/download/v3local/
-  source-local: /home/backend/downloads/scenes/%s/%s
+  v4school: ${PROFILE_PATH}v4local
+  v3school:
+  source-local: ${PROFILE_PATH}offline/%s/%s
   zip-root: wwwroot/
-  zip-local: /home/backend/downloads/scenes/%s.zip
+  zip-local: ${PROFILE_PATH}offline/%s.zip
   zip-oss: downloads/scenes/%s.zip
 download:
   config:
-    public-url: https://4dkk.4dage.com/
+    public-url: http://127.0.0.1
     resource-url:
     exe-name: start-browser.bat
     exe-content: | # | 表示不转义特殊字符
@@ -117,6 +117,6 @@ url:
   v3:
     getInfo:
 ##场景下载相关-----------------------------------------end
-
-
+inner:
+  customToken:
 

+ 1 - 1
src/main/resources/logback-spring.xml

@@ -144,7 +144,7 @@
 	<logger name="java.sql.Statement" level="${LOG_LEVEL}"/>
 	<logger name="java.sql.PreparedStatement" level="${LOG_LEVEL}"/>
 	<logger name="io.lettuce.core.protocol" level="ERROR"/>
-	<logger name=" org.apache.http.impl.conn.PoolingHttpClientConnectionManager" level="ERROR"/>
+	<logger name="org.apache.http.impl.conn.PoolingHttpClientConnectionManager" level="ERROR"/>
 
 	<!-- ${LOG_ROOT_LEVEL} 日志级别 -->
 	<root level="${LOG_ROOT_LEVEL}">