瀏覽代碼

区分生产和测试环境的配置文件

xiewenjie 3 年之前
父節點
當前提交
e189e8f41a

+ 24 - 0
pom.xml

@@ -22,7 +22,31 @@
 
 		<docker.image.prefix>fbxtoobj</docker.image.prefix>
 	</properties>
+	<profiles>
+		<profile>
+			<id>dev</id>
+			<properties>
+				<package.environment>dev</package.environment>
+			</properties>
 
+		</profile>
+		<profile>
+			<id>uat</id>
+			<properties>
+				<package.environment>uat</package.environment>
+			</properties>
+		</profile>
+		<profile>
+			<!-- 生产环境 -->
+			<id>prod</id>
+			<properties>
+				<package.environment>prod</package.environment>
+			</properties>
+			<activation>
+				<activeByDefault>true</activeByDefault>
+			</activation>
+		</profile>
+	</profiles>
 	<dependencies>
 		<dependency>
 			<groupId>org.springframework.boot</groupId>

+ 52 - 27
src/main/java/com/fdkankan/controller/FbxToObjController.java

@@ -21,20 +21,43 @@ public class FbxToObjController {
     @Value("${server.file.location}")
     private String path;
 
+    @Value("${fbxToObj.combineFbxClassPath}")
+    private String combineFbxClassPath;
+
+    @Value("${fbxToObj.compressImagePath}")
+    private String compressImagePath;
+
+    @Value("${fbxToObjNoImg.fbxMeshReducePath}")
+    private String fbxMeshReducePath;
+
+    @Value("${maxToDatasmithPath.detachModelPyPath}")
+    private String detachModelPyPath;
+
+    @Value("${maxToDatasmithPath.detachModelBatPath}")
+    private String detachModelBatPath;
+
+    @Value("${objToObj.reduceObjOnlyPath}")
+    private String reduceObjOnlyPath;
+
+    @Value("${objToObjPercentage.reduceObjOnlyPercentPath}")
+    private String reduceObjOnlyPercentPath;
+
+
     /**
      * 上传模型文件
+     *
      * @param
      * @return
      */
     @RequestMapping(value = "/fbxToObj")
-    public String fbxToObj(HttpServletRequest request){
+    public String fbxToObj(HttpServletRequest request) {
         String uuid = request.getParameter("uuid");
         String fbx = request.getParameter("fbx");
         String obj = request.getParameter("obj");
         String jpg = request.getParameter("jpg");
         String r = request.getParameter("r");
 
-        if(StringUtils.isEmpty(r)){
+        if (StringUtils.isEmpty(r)) {
             r = "30";
         }
         String filePath = path + uuid + File.separator;
@@ -43,13 +66,14 @@ public class FbxToObjController {
 //        String command = "hython C:\\user\\FbxMeshReduce.py -i " +  filePath + fbx + " -obj " + filePath + obj +
 //                " -oj " + filePath + "baker.jpg -r " + r;
 
-        String command = "hython C:\\user\\CombineFbxClass.py -i " +  filePath + fbx + " -obj " + filePath + obj +
+        String command = "hython " + combineFbxClassPath + " -i " + filePath + fbx + " -obj " + filePath + obj +
                 " -oj " + filePath + "baker.jpg -r " + r;
         callshell(command);
         log.info(("fbx转换obj完毕:" + command));
 
         log.info(("图片开始压缩"));
-        command = "python C:\\user\\compressImage\\CompressImage.cpython-39.pyc -i " + filePath + "baker.jpg -o " + filePath + jpg;
+        command = "python " + compressImagePath + " -i " + filePath + "baker.jpg -o " + filePath + jpg;
+
         callshell(command);
         log.info(("图片压缩完毕:" + command));
         return "0";
@@ -57,54 +81,56 @@ public class FbxToObjController {
 
     /**
      * 上传模型文件不烘焙图片
+     *
      * @param
      * @return
      */
     @RequestMapping(value = "/fbxToObjNoImg")
-    public String fbxToObjNoImg(HttpServletRequest request){
+    public String fbxToObjNoImg(HttpServletRequest request) {
         String uuid = request.getParameter("uuid");
         String fbx = request.getParameter("fbx");
         String obj = request.getParameter("obj");
         String r = request.getParameter("r");
 
-        if(StringUtils.isEmpty(r)){
+        if (StringUtils.isEmpty(r)) {
             r = "30";
         }
         String filePath = path + uuid + File.separator;
         FileUtils.deleteFile(filePath + obj);
         log.info(("fbx转换obj开始"));
-        String command = "hython C:\\user\\FbxMeshReduce.py -i " +  filePath + fbx + " -obj " + filePath + obj +
+        String command = "hython " + fbxMeshReducePath + " -i " + filePath + fbx + " -obj " + filePath + obj +
                 " -r " + r + " -ba a ";
         callshell(command);
         log.info(("fbx转换obj完毕:" + command));
         return "0";
     }
 
-    /**
-     * 上传.max文件转成datasmith
-     * @param
-     * @return
-     */
-    @RequestMapping(value = "/maxToDatasmith")
-    public String maxToDatasmith(HttpServletRequest request){
+    @RequestMapping({"/maxToDatasmith"})
+    public String maxToDatasmith(HttpServletRequest request) {
         String uuid = request.getParameter("uuid");
         String max = request.getParameter("max");
+        String flag = request.getParameter("flag");
 
+        if (flag == null || flag.equals("")) {
+            flag = "false";
+        }
         String filePath = path + uuid;
-        String command = "hython C:\\Users\\Administrator\\Documents\\fbxTodatasmith\\DetachModel.py C:\\Users\\Administrator\\Documents\\fbxTodatasmith\\DetachModel.bat " + filePath + " " + filePath + File.separator + max;
-        log.info(("max转换datasmith开始: " + command));
+        String command = "hython " + detachModelPyPath + " " + detachModelBatPath + " " + filePath + " " + filePath + File.separator + max + " " + flag;
+        ;
+        log.info("max转换datasmith开始: " + command);
         callshell(command);
-        log.info(("max转换datasmith完毕:" + command));
+        log.info("max转换datasmith完毕:" + command);
         return "0";
     }
 
     /**
      * obj转成obj并进行压缩
+     *
      * @param
      * @return
      */
     @RequestMapping(value = "/objToObj")
-    public String objToObj(HttpServletRequest request) throws Exception{
+    public String objToObj(HttpServletRequest request) throws Exception {
         String uuid = request.getParameter("uuid");
         String inObj = request.getParameter("inObj");
         String outObj = request.getParameter("outObj");
@@ -112,8 +138,7 @@ public class FbxToObjController {
 
         String filePath = path + uuid + File.separator;
 
-        String command = "hython C:\\Users\\Administrator\\Documents\\user\\ReduceObjOnly.py -i " + filePath + inObj +
-                " -o " + filePath + outObj + " -r " + r;
+        String command = "hython " + reduceObjOnlyPath + " -i " + filePath + inObj + " -o " + filePath + outObj + " -r " + r;
 
 //        String faceTxt = r + "\n" + filePath + inObj + "\n" + filePath + outObj + "\n";
 //        FileUtils.writeFile(filePath + "face.txt", faceTxt);
@@ -133,19 +158,18 @@ public class FbxToObjController {
 
     /**
      * obj转成obj并进行压缩
+     *
      * @param
      * @return
      */
     @RequestMapping(value = "/objToObjPercentage")
-    public String objToObjPercentage(HttpServletRequest request) throws Exception{
+    public String objToObjPercentage(HttpServletRequest request) throws Exception {
         String inObj = request.getParameter("inObj");
         String outObj = request.getParameter("outObj");
         String r = request.getParameter("r");
 
-//        String filePath = path + uuid + File.separator;
 
-        String command = "hython C:\\Users\\Administrator\\Documents\\user\\ReduceObjOnly_percent.py -i " + inObj +
-                " -o " + outObj + " -r " + r;
+        String command = "hython " + reduceObjOnlyPercentPath + " -i " + inObj + " -o " + outObj + " -r " + r;
 
         log.info(("obj转换obj百分比压缩开始: " + command));
         callshell(command);
@@ -153,8 +177,10 @@ public class FbxToObjController {
         return "0";
     }
 
+
+
     @RequestMapping(value = "/testRun")
-    public String testRun(HttpServletRequest request){
+    public String testRun(HttpServletRequest request) {
 
         return "isRunning";
     }
@@ -176,8 +202,7 @@ public class FbxToObjController {
     }
 
 
-    public void callshell(String command)
-    {
+    public void callshell(String command) {
         try {
             Process process = Runtime.getRuntime().exec(command);
 

+ 105 - 0
src/main/java/com/fdkankan/controller/ToolbagController.java

@@ -0,0 +1,105 @@
+//
+// Source code recreated from a .class file by IntelliJ IDEA
+// (powered by FernFlower decompiler)
+//
+
+package com.fdkankan.controller;
+
+import com.fdkankan.util.FileUtils;
+import com.fdkankan.util.StreamGobbler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+import java.io.*;
+
+@RestController
+public class ToolbagController {
+    private static final Logger log = LoggerFactory.getLogger(ToolbagController.class);
+    @Value("${server.file.location}")
+    private String path;
+
+
+    @Value("${toToolbagPath}")
+    private String toToolbagPath;
+
+    @Value("${driveLetter}")
+    private String driveLetter;
+
+
+    @RequestMapping({"/toToolbag"})
+    public String toToolbag(HttpServletRequest request) {
+        String uuid = request.getParameter("uuid");
+        String inObj =  request.getParameter("inObj");
+        if (inObj.contains("web-shared")){
+            inObj=inObj.replaceAll("/web-shared",driveLetter);
+        }else if (inObj.contains("mnt")){
+            inObj=inObj.replaceAll("/mnt",driveLetter);
+        }
+        String outFilePath = request.getParameter("outFilePath");
+        if (outFilePath.contains("web-shared")){
+            outFilePath=outFilePath.replaceAll("/web-shared",driveLetter);
+        }else if (outFilePath.contains("mnt")){
+            outFilePath=outFilePath.replaceAll("/mnt",driveLetter);
+        }
+
+        log.info("toToolbag开始: "+  toToolbagPath);
+        execShell(toToolbagPath, new String[]{inObj, outFilePath});
+        log.info("toToolbag完毕:" + toToolbagPath);
+        return "0";
+    }
+
+
+    public static String execShell(String shpath, String... params)   {
+        StringBuilder bashCommand = new StringBuilder(shpath).append(" ");
+        log.info("开始调用shell");
+        //拼接参数
+        for (String param : params) {
+            bashCommand.append(param).append(" ");
+            log.info("参数-{}",param);
+        }
+        log.info("执行-{}",bashCommand);
+        Process process = null;
+        try {
+            process = Runtime.getRuntime().exec(bashCommand.toString());
+            process.waitFor();
+            int exitValue = process.waitFor();
+            if (0 != exitValue) {
+                log.error("调用shell脚本失败 :" + exitValue);
+            }
+            BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
+            StringBuffer sb = new StringBuffer();
+            String line;
+            while ((line = br.readLine()) != null) {
+                sb.append(line + "\n");
+            }
+            br.close();
+            String result = sb.toString();
+            log.info("shell打印{}",result);
+            return  result;
+        } catch (Exception e) {
+            log.error("调用shell出错{}",e.getMessage());
+            e.printStackTrace();
+
+        }
+        return "";
+    }
+
+    public void callshell(String command) {
+        try {
+            Process process = Runtime.getRuntime().exec(command);
+            StreamGobbler errorGobbler = new StreamGobbler(process.getErrorStream(), "ERROR");
+            errorGobbler.start();
+            StreamGobbler outGobbler = new StreamGobbler(process.getInputStream(), "STDOUT");
+            outGobbler.start();
+            process.waitFor();
+        } catch (Exception var5) {
+            var5.printStackTrace();
+        }
+
+    }
+}

+ 24 - 0
src/main/resources/application-dev.properties

@@ -0,0 +1,24 @@
+server.port=8081
+server.file.location=Z:\\OneKeyDecorate\\upload\\
+spring.mvc.async.request-timeout=600000
+spring.datasource.url=jdbc:mysql://192.168.0.47:3306/change_clothes?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
+spring.datasource.username=root
+spring.datasource.password=123123
+spring.datasource.driverClassName=com.mysql.jdbc.Driver
+logging.level.com.fdkankan=debug
+#\u4E0A\u4F20\u6A21\u578B\u6587\u4EF6
+fbxToObj.combineFbxClassPath=C:\\user\\CombineFbxClass.py 
+fbxToObj.compressImagePath=C:\\user\\compressImage\\CompressImage.cpython-39.pyc 
+#\u4E0A\u4F20\u6A21\u578B\u6587\u4EF6\u4E0D\u70D8\u7119\u56FE\u7247
+fbxToObjNoImg.fbxMeshReducePath=C:\\user\\FbxMeshReduce.py 
+#maxToDatasmith
+maxToDatasmithPath.detachModelPyPath=E:\\fbxToDatasmith\\DetachModel.py  
+maxToDatasmithPath.detachModelBatPath=E:\\fbxToDatasmith\\DetachModel.bat 
+#obj\u8F6C\u6210obj\u5E76\u8FDB\u884C\u538B\u7F29
+objToObj.reduceObjOnlyPath=C:\\user\\ReduceObjOnly.py 
+#obj\u8F6C\u6210obj\u5E76\u8FDB\u884C\u538B\u7F29
+objToObjPercentage.reduceObjOnlyPercentPath=C:\\user\\ReduceObjOnly.py 
+##toolbag
+toToolbagPath=E:\\4dageToolbag\\4dageToolbag.bat 
+##
+convertMViewStartPath=E:\\convertMView\\convertMViewStart.py 

+ 30 - 0
src/main/resources/application-prod.properties

@@ -0,0 +1,30 @@
+server.port=8080
+
+server.file.location=Z:\\OneKeyDecorate\\upload\\
+
+spring.mvc.async.request-timeout=600000
+
+spring.datasource.url=jdbc:mysql://192.168.0.47:3306/change_clothes?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
+spring.datasource.username=root
+spring.datasource.password=123123
+spring.datasource.driverClassName=com.mysql.jdbc.Driver
+
+logging.level.com.fdkankan=debug
+
+
+#\u4E0A\u4F20\u6A21\u578B\u6587\u4EF6
+fbxToObj.combineFbxClassPath=C:\\Users\\Administrator\\Documents\\user\\CombineFbxClass.py 
+fbxToObj.compressImagePath=C:\\Users\\Administrator\\Documents\\user\\compressImage\\CompressImage.cpython-39.pyc 
+#\u4E0A\u4F20\u6A21\u578B\u6587\u4EF6\u4E0D\u70D8\u7119\u56FE\u7247
+fbxToObjNoImg.fbxMeshReducePath=C:\\Users\\Administrator\\Documents\\user\\FbxMeshReduce.py 
+#maxToDatasmith
+maxToDatasmithPath.detachModelPyPath=C:\\Users\\Administrator\\Documents\\fbxTodatasmith\\DetachModel.py 
+maxToDatasmithPath.detachModelBatPath=C:\\Users\\Administrator\\Documents\\fbxTodatasmith\\DetachModel.bat 
+#obj\u8F6C\u6210obj\u5E76\u8FDB\u884C\u538B\u7F29
+objToObj.reduceObjOnlyPath=C:\\Users\\Administrator\\Documents\\user\\ReduceObjOnly.py 
+#obj\u8F6C\u6210obj\u5E76\u8FDB\u884C\u538B\u7F29
+objToObjPercentage.reduceObjOnlyPercentPath=C:\\Users\\Administrator\\Documents\\user\\ReduceObjOnly_percent.py 
+##toolbag
+toToolbagPath=C:\\Users\\Administrator\\Documents\\4dageToolbag\\4dageToolbag.bat 
+
+driveLetter=z:

+ 30 - 0
src/main/resources/application-uat.properties

@@ -0,0 +1,30 @@
+server.port=8080
+
+server.file.location=Z:\\OneKeyDecorate\\upload\\
+
+spring.mvc.async.request-timeout=600000
+
+spring.datasource.url=jdbc:mysql://192.168.0.47:3306/change_clothes?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
+spring.datasource.username=root
+spring.datasource.password=123123
+spring.datasource.driverClassName=com.mysql.jdbc.Driver
+
+logging.level.com.fdkankan=debug
+
+
+#\u4E0A\u4F20\u6A21\u578B\u6587\u4EF6
+fbxToObj.combineFbxClassPath=C:\\user\\CombineFbxClass.py 
+fbxToObj.compressImagePath=C:\\user\\compressImage\\CompressImage.cpython-39.pyc 
+#\u4E0A\u4F20\u6A21\u578B\u6587\u4EF6\u4E0D\u70D8\u7119\u56FE\u7247
+fbxToObjNoImg.fbxMeshReducePath=C:\\user\\FbxMeshReduce.py 
+#maxToDatasmith
+maxToDatasmithPath.detachModelPyPath=E:\\fbxToDatasmith\\DetachModel.py 
+maxToDatasmithPath.detachModelBatPath=E:\\fbxToDatasmith\\DetachModel.bat 
+#obj\u8F6C\u6210obj\u5E76\u8FDB\u884C\u538B\u7F29
+objToObj.reduceObjOnlyPath=C:\\user\\ReduceObjOnly.py 
+#obj\u8F6C\u6210obj\u5E76\u8FDB\u884C\u538B\u7F29
+objToObjPercentage.reduceObjOnlyPercentPath=C:\\user\\ReduceObjOnly.py 
+##toolbag
+toToolbagPath=E:\\4dageToolbag\\4dageToolbag.bat 
+
+driveLetter=z:

+ 2 - 8
src/main/resources/application.properties

@@ -1,12 +1,6 @@
-server.port=8080
 
-server.file.location=Z:\\OneKeyDecorate\\upload\\
 
-spring.mvc.async.request-timeout=600000
+spring.profiles.active=@package.environment@
+
 
-spring.datasource.url=jdbc:mysql://192.168.0.47:3306/change_clothes?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
-spring.datasource.username=root
-spring.datasource.password=123123
-spring.datasource.driverClassName=com.mysql.jdbc.Driver
 
-logging.level.com.fdkankan=debug