Browse Source

优化代码

tianboguang 3 years ago
parent
commit
9064215090
33 changed files with 291 additions and 778 deletions
  1. 11 1
      .gitignore
  2. 1 21
      4dkankan-common-utils/pom.xml
  3. 0 61
      4dkankan-common-utils/src/main/java/com/fdkankan/common/util/StreamGobbler.java
  4. 0 76
      4dkankan-common-utils/src/main/java/com/fdkankan/common/util/TestUtil.java
  5. 0 163
      4dkankan-common-utils/src/main/java/com/fdkankan/common/validation/SensitiveWord.java
  6. 0 169
      4dkankan-common-utils/src/main/java/com/fdkankan/common/validation/SensitiveWordConfig.java
  7. 0 2
      4dkankan-common-utils/src/main/java/com/fdkankan/common/validation/Variable.java
  8. 1 2
      4dkankan-utils-fyun-oss/src/main/java/com/fdkankan/fyun/oss/OssFileService.java
  9. 20 0
      4dkankan-utils-fyun-parent/src/main/java/com/fdkankan/fyun/face/AbstractFYunFileService.java
  10. 61 0
      4dkankan-utils-fyun-parent/src/main/java/com/fdkankan/fyun/model/StreamGobbler.java
  11. 1 2
      4dkankan-utils-fyun-s3/src/main/java/com/fdkankan/fyun/s3/S3FileService.java
  12. 61 0
      4dkankan-utils-fyun/src/main/java/com/fdkankan/fyun/model/StreamGobbler.java
  13. 26 13
      4dkankan-utils-fyun/src/main/java/com/fdkankan/fyun/oss/UploadToOssUtil.java
  14. 1 1
      4dkankan-common-utils/src/main/java/com/fdkankan/common/util/ConstantCmd.java
  15. 1 1
      4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/ConstantFileName.java
  16. 1 3
      4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/ConstantFilePath.java
  17. 1 4
      4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/UploadFilePath.java
  18. 1 1
      4dkankan-common-utils/src/main/java/com/fdkankan/common/proto/BigSceneProto.java
  19. 1 1
      4dkankan-common-utils/src/main/java/com/fdkankan/common/proto/Common.java
  20. 1 1
      4dkankan-common-utils/src/main/java/com/fdkankan/common/proto/Visionmodeldata.java
  21. 1 1
      4dkankan-common-utils/src/main/java/com/fdkankan/common/proto/format/CouchDBFormat.java
  22. 1 1
      4dkankan-common-utils/src/main/java/com/fdkankan/common/proto/format/HtmlFormat.java
  23. 2 2
      4dkankan-common-utils/src/main/java/com/fdkankan/common/proto/format/JavaPropsFormat.java
  24. 1 1
      4dkankan-common-utils/src/main/java/com/fdkankan/common/proto/format/JsonFormat.java
  25. 1 2
      4dkankan-common-utils/src/main/java/com/fdkankan/common/proto/format/SmileFormat.java
  26. 1 2
      4dkankan-common-utils/src/main/java/com/fdkankan/common/proto/format/XmlFormat.java
  27. 11 179
      4dkankan-common-utils/src/main/java/com/fdkankan/common/util/ComputerUtil.java
  28. 3 3
      4dkankan-common-utils/src/main/java/com/fdkankan/common/util/ConvertCommonUtils.java
  29. 3 3
      4dkankan-common-utils/src/main/java/com/fdkankan/common/util/ConvertUtils.java
  30. 2 1
      4dkankan-common-utils/src/main/java/com/fdkankan/common/util/CreateHouseJsonUtil.java
  31. 12 59
      4dkankan-common-utils/src/main/java/com/fdkankan/common/util/CreateObjUtil.java
  32. 3 2
      4dkankan-common-utils/src/main/java/com/fdkankan/common/util/SceneUtil.java
  33. 61 0
      4dkankan-utils-model/src/main/java/com/fdkankan/model/utils/StreamGobbler.java

+ 11 - 1
.gitignore

@@ -30,9 +30,19 @@ hs_err_pid*
 # IntelliJ project files
 .idea
 *.iml
-/**/target/
 out
 gen
+/4dkankan-center-scene/target/
+/4dkankan-common/target/
+/4dkankan-gateway/target/
+/4dkankan-pom/target/
+/4dkankan-center-platform/target/
+/4dkankan-center-modeling/target/
+/4dkankan-center-statistics/target/
+/4dkankan-center-log/target/
+/4dkankan-center-auth/target/
+/4dkankan-sdk-oss/target/
+
 
 /4dkankan-pom/src/test/java/TestAutoGenerate.java
 

+ 1 - 21
4dkankan-common-utils/pom.xml

@@ -17,11 +17,7 @@
     </properties>
 
     <dependencies>
-        <dependency>
-            <groupId>com.google.protobuf</groupId>
-            <artifactId>protobuf-java</artifactId>
-            <version>3.2.0</version>
-        </dependency>
+
         <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
@@ -32,33 +28,17 @@
             <artifactId>fastjson</artifactId>
         </dependency>
         <dependency>
-            <groupId>org.apache.ant</groupId>
-            <artifactId>ant</artifactId>
-            <version>${ant-version}</version>
-        </dependency>
-        <dependency>
             <groupId>org.bytedeco</groupId>
             <artifactId>javacv</artifactId>
             <version>1.4.3</version>
         </dependency>
 
         <dependency>
-            <groupId>org.bytedeco.javacpp-presets</groupId>
-            <artifactId>ffmpeg-platform</artifactId>
-            <version>4.0.2-1.4.3</version>
-        </dependency>
-
-        <dependency>
             <groupId>org.bytedeco</groupId>
             <artifactId>javacpp</artifactId>
             <version>1.4.3</version>
         </dependency>
         <dependency>
-            <groupId>joinery</groupId>
-            <artifactId>jave</artifactId>
-            <version>1.0.2.2</version>
-        </dependency>
-        <dependency>
             <groupId>org.springframework</groupId>
             <artifactId>spring-core</artifactId>
         </dependency>

+ 0 - 61
4dkankan-common-utils/src/main/java/com/fdkankan/common/util/StreamGobbler.java

@@ -1,61 +0,0 @@
-package com.fdkankan.common.util;
-
-import java.io.*;
-
-public class StreamGobbler extends Thread {
-
-	InputStream is;  
-    String type;  
-    OutputStream os;  
-
-    public StreamGobbler(InputStream is, String type) {  
-        this(is, type, null);  
-    }  
-
-    StreamGobbler(InputStream is, String type, OutputStream redirect) {  
-        this.is = is;  
-        this.type = type;  
-        this.os = redirect;  
-    }  
-
-    public void run() {  
-        InputStreamReader isr = null;  
-        BufferedReader br = null;  
-        PrintWriter pw = null;  
-        try {  
-            if (os != null)  
-                pw = new PrintWriter(os);  
-
-            isr = new InputStreamReader(is);  
-            br = new BufferedReader(isr);  
-            String line=null;  
-            while ( (line = br.readLine()) != null) {  
-                if (pw != null)  
-                    pw.println(line);  
-                System.out.println(type + ">" + line);      
-            }  
-
-            if (pw != null)  
-                pw.flush();  
-        } catch (IOException ioe) {  
-            ioe.printStackTrace();    
-        } finally{  
-            try {  
-            	if(pw!=null)
-            	{
-            		 pw.close();  
-            	}
-            	if(br!=null)
-            	{
-            		br.close();  
-            	}
-            	if(isr!=null)
-            	{
-            		isr.close();  
-            	}
-            } catch (IOException e) {  
-                e.printStackTrace();  
-            }  
-        }  
-    }  
-}

+ 0 - 76
4dkankan-common-utils/src/main/java/com/fdkankan/common/util/TestUtil.java

@@ -1,76 +0,0 @@
-package com.fdkankan.common.util;
-
-import cn.hutool.core.bean.BeanUtil;
-import cn.hutool.core.collection.ListUtil;
-import cn.hutool.core.img.ImgUtil;
-import cn.hutool.core.io.IoUtil;
-import cn.hutool.core.util.StrUtil;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.fdkankan.common.constant.ConstantFilePath;
-import com.fdkankan.common.constant.TbStatus;
-import java.awt.Image;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.function.Consumer;
-import lombok.Data;
-
-/**
- * <p>
- * TODO
- * </p>
- *
- * @author dengsixing
- * @since 2022/4/14
- **/
-public class TestUtil {
-
-    public static String hostName = "aaa";
-
-    public static List<String> residenceServiceHostName = new ArrayList<>();
-
-    static{
-        residenceServiceHostName.add("aaa");
-        residenceServiceHostName.add("bbb");
-    }
-
-    public static void main(String[] args) throws Exception {
-
-        test test = new test();
-        test1 test1 = new test1();
-        test1.setTest("test1");
-        test2 test2 = new test2();
-        test2.setTest("test2");
-        BeanUtil.copyProperties(test1, test);
-        BeanUtil.copyProperties(test2, test);
-        System.out.println(test.getTest());
-
-
-    }
-
-}
-
-@Data
-class test{
-    private String test;
-}
-
-@Data
-class test1{
-    private String test;
-}
-
-@Data
-class test2{
-    private String test;
-}

+ 0 - 163
4dkankan-common-utils/src/main/java/com/fdkankan/common/validation/SensitiveWord.java

@@ -1,163 +0,0 @@
-package com.fdkankan.common.validation;
-
-import com.fdkankan.common.constant.ConstantFileName;
-
-import com.fdkankan.common.constant.ServerCode;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import javax.annotation.PostConstruct;
-import lombok.extern.slf4j.Slf4j;
-import net.sf.jsqlparser.schema.Server;
-import org.springframework.core.io.ClassPathResource;
-
-/**
- *  敏感词过滤
- */
-@Slf4j
-public class SensitiveWord {
-    @SuppressWarnings("rawtypes")
-    public Map sensitiveWordMap = null;
-    public static int minMatchTYpe = 1;      //最小匹配规则
-    public static int maxMatchType = 2;      //最大匹配规则
-
-    /**
-     * 构造函数,初始化敏感词库
-     */
-    public SensitiveWord(){
-        if (sensitiveWordMap == null){
-            ClassPathResource classPathResource = new ClassPathResource("static/txt/" + ConstantFileName.BBS_SENSITIVE);
-            try {
-                sensitiveWordMap = new SensitiveWordConfig().initKeyWord(classPathResource.getFile());
-            }catch (Exception e){
-                log.error("初始化敏感词失败!", e);
-            }
-        }
-    }
-
-
-    /**
-     * 判断文字是否包含敏感字符
-     * @author chenming
-     * @date 2014年4月20日 下午4:28:30
-     * @param txt  文字
-     * @param matchType  匹配规则&nbsp;1:最小匹配规则,2:最大匹配规则
-     * @return 若包含返回true,否则返回false
-     * @version 1.0
-     */
-    public boolean isContaintSensitiveWord(String txt,int matchType){
-        boolean flag = false;
-        for(int i = 0 ; i < txt.length() ; i++){
-            int matchFlag = this.CheckSensitiveWord(txt, i, matchType); //判断是否包含敏感字符
-            if(matchFlag > 0){    //大于0存在,返回true
-                flag = true;
-            }
-        }
-        return flag;
-    }
-
-    /**
-     * 获取文字中的敏感词
-     * @author chenming
-     * @date 2014年4月20日 下午5:10:52
-     * @param txt 文字
-     * @param matchType 匹配规则&nbsp;1:最小匹配规则,2:最大匹配规则
-     * @return
-     * @version 1.0
-     */
-    public Set<String> getSensitiveWord(String txt , int matchType){
-        Set<String> sensitiveWordList = new HashSet<String>();
-
-        for(int i = 0 ; i < txt.length() ; i++){
-            int length = CheckSensitiveWord(txt, i, matchType);    //判断是否包含敏感字符
-            if(length > 0){    //存在,加入list中
-                sensitiveWordList.add(txt.substring(i, i+length));
-                i = i + length - 1;    //减1的原因,是因为for会自增
-            }
-        }
-
-        return sensitiveWordList;
-    }
-
-    /**
-     * 替换敏感字字符
-     * @author chenming
-     * @date 2014年4月20日 下午5:12:07
-     * @param txt
-     * @param matchType
-     * @param replaceChar 替换字符,默认*
-     * @version 1.0
-     */
-    public String replaceSensitiveWord(String txt,int matchType,String replaceChar){
-        String resultTxt = txt;
-        Set<String> set = getSensitiveWord(txt, matchType);     //获取所有的敏感词
-        Iterator<String> iterator = set.iterator();
-        String word = null;
-        String replaceString = null;
-        while (iterator.hasNext()) {
-            word = iterator.next();
-            replaceString = getReplaceChars(replaceChar, word.length());
-            resultTxt = resultTxt.replaceAll(word, replaceString);
-        }
-
-        return resultTxt;
-    }
-
-    /**
-     * 获取替换字符串
-     * @author chenming
-     * @date 2014年4月20日 下午5:21:19
-     * @param replaceChar
-     * @param length
-     * @return
-     * @version 1.0
-     */
-    private String getReplaceChars(String replaceChar,int length){
-        String resultReplace = replaceChar;
-        for(int i = 1 ; i < length ; i++){
-            resultReplace += replaceChar;
-        }
-
-        return resultReplace;
-    }
-
-    /**
-     * 检查文字中是否包含敏感字符,检查规则如下:<br>
-     * @author chenming
-     * @date 2014年4月20日 下午4:31:03
-     * @param txt
-     * @param beginIndex
-     * @param matchType
-     * @return,如果存在,则返回敏感词字符的长度,不存在返回0
-     * @version 1.0
-     */
-    @SuppressWarnings({ "rawtypes"})
-    public int CheckSensitiveWord(String txt,int beginIndex,int matchType){
-        boolean  flag = false;    //敏感词结束标识位:用于敏感词只有1位的情况
-        int matchFlag = 0;     //匹配标识数默认为0
-        char word = 0;
-
-        Map nowMap = sensitiveWordMap;
-        for(int i = beginIndex; i < txt.length() ; i++){
-            word = txt.charAt(i);
-            nowMap = (Map) nowMap.get(word);     //获取指定key
-            if(nowMap != null){     //存在,则判断是否为最后一个
-                matchFlag++;     //找到相应key,匹配标识+1
-                if("1".equals(nowMap.get("isEnd"))){       //如果为最后一个匹配规则,结束循环,返回匹配标识数
-                    flag = true;       //结束标志位为true
-                    if(SensitiveWord.minMatchTYpe == matchType){    //最小规则,直接返回,最大规则还需继续查找
-                        break;
-                    }
-                }
-            }
-            else{     //不存在,直接返回
-                break;
-            }
-        }
-        if(matchFlag < 2 || !flag){        //长度必须大于等于1,为词
-            matchFlag = 0;
-        }
-        return matchFlag;
-    }
-}

+ 0 - 169
4dkankan-common-utils/src/main/java/com/fdkankan/common/validation/SensitiveWordConfig.java

@@ -1,169 +0,0 @@
-package com.fdkankan.common.validation;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStreamReader;
-import java.util.*;
-
-/**
- * 初始化敏感词库,将敏感词加入到HashMap中,构建DFA算法模型
- */
-public class SensitiveWordConfig {
-    private String ENCODING = "utf-8";    //字符编码
-    @SuppressWarnings("rawtypes")
-    public HashMap sensitiveWordMap;
-
-    public SensitiveWordConfig(){
-        super();
-    }
-
-    /**
-     * @date 2014年4月20日 下午2:28:32
-     * @version 1.0
-     */
-    @SuppressWarnings("rawtypes")
-    public Map initKeyWord(String filePath){
-        try {
-            //读取敏感词库
-            Set<String> keyWordSet = readSensitiveWordFile(filePath);
-            //将敏感词库加入到HashMap中
-            addSensitiveWordToHashMap(keyWordSet);
-            //spring获取application,然后application.setAttribute("sensitiveWordMap",sensitiveWordMap);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return sensitiveWordMap;
-    }
-
-    public Map initKeyWord(File file){
-        try {
-            //读取敏感词库
-            Set<String> keyWordSet = readSensitiveWordFile(file);
-            //将敏感词库加入到HashMap中
-            addSensitiveWordToHashMap(keyWordSet);
-            //spring获取application,然后application.setAttribute("sensitiveWordMap",sensitiveWordMap);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return sensitiveWordMap;
-    }
-
-    /**
-     * 读取敏感词库,将敏感词放入HashSet中,构建一个DFA算法模型:<br>
-     * 中 = {
-     *      isEnd = 0
-     *      国 = {<br>
-     *      	 isEnd = 1
-     *           人 = {isEnd = 0
-     *                民 = {isEnd = 1}
-     *                }
-     *           男  = {
-     *           	   isEnd = 0
-     *           		人 = {
-     *           			 isEnd = 1
-     *           			}
-     *           	}
-     *           }
-     *      }
-     *  五 = {
-     *      isEnd = 0
-     *      星 = {
-     *      	isEnd = 0
-     *      	红 = {
-     *              isEnd = 0
-     *              旗 = {
-     *                   isEnd = 1
-     *                  }
-     *              }
-     *      	}
-     *      }
-     * @param keyWordSet  敏感词库
-     */
-    @SuppressWarnings({ "rawtypes", "unchecked" })
-    private void addSensitiveWordToHashMap(Set<String> keyWordSet) {
-        sensitiveWordMap = new HashMap(keyWordSet.size());     //初始化敏感词容器,减少扩容操作
-        String key = null;
-        Map nowMap = null;
-        Map<String, String> newWorMap = null;
-        //迭代keyWordSet
-        Iterator<String> iterator = keyWordSet.iterator();
-        while(iterator.hasNext()){
-            key = iterator.next();    //关键字
-            nowMap = sensitiveWordMap;
-            for(int i = 0 ; i < key.length() ; i++){
-                char keyChar = key.charAt(i);       //转换成char型
-                Object wordMap = nowMap.get(keyChar);       //获取
-
-                if(wordMap != null){        //如果存在该key,直接赋值
-                    nowMap = (Map) wordMap;
-                }
-                else{     //不存在则,则构建一个map,同时将isEnd设置为0,因为他不是最后一个
-                    newWorMap = new HashMap<String,String>();
-                    newWorMap.put("isEnd", "0");     //不是最后一个
-                    nowMap.put(keyChar, newWorMap);
-                    nowMap = newWorMap;
-                }
-
-                if(i == key.length() - 1){
-                    nowMap.put("isEnd", "1");    //最后一个
-                }
-            }
-        }
-    }
-
-    /**
-     * 读取敏感词库中的内容,将内容添加到set集合中
-     */
-    @SuppressWarnings("resource")
-    private Set<String> readSensitiveWordFile(String path) throws Exception{
-        Set<String> set = null;
-        //File file = new File("E:\\2017\\4Dweb\\bug汇总\\过滤敏感词\\敏感词库\\敏感词库\\2012年最新敏感词列表\\论坛需要过滤的不良词语大全.txt");    //读取文件
-        //File file = new File("D:\\SensitiveWord.txt");    //读取文件
-        File file = new File(path);
-        InputStreamReader read = new InputStreamReader(new FileInputStream(file),ENCODING);
-        try {
-            if(file.isFile() && file.exists()){      //文件流是否存在
-                set = new HashSet<String>();
-                BufferedReader bufferedReader = new BufferedReader(read);
-                String txt = null;
-                while((txt = bufferedReader.readLine()) != null){    //读取文件,将文件内容放入到set中
-                    set.add(txt);
-                }
-            }
-            else{         //不存在抛出异常信息
-                throw new Exception("敏感词库文件不存在");
-            }
-        } catch (Exception e) {
-            throw e;
-        }finally{
-            read.close();     //关闭文件流
-        }
-        return set;
-    }
-
-    private Set<String> readSensitiveWordFile(File file) throws Exception{
-        Set<String> set = null;
-        //File file = new File("E:\\2017\\4Dweb\\bug汇总\\过滤敏感词\\敏感词库\\敏感词库\\2012年最新敏感词列表\\论坛需要过滤的不良词语大全.txt");    //读取文件
-        //File file = new File("D:\\SensitiveWord.txt");    //读取文件
-        InputStreamReader read = new InputStreamReader(new FileInputStream(file),ENCODING);
-        try {
-            if(file.isFile() && file.exists()){      //文件流是否存在
-                set = new HashSet<String>();
-                BufferedReader bufferedReader = new BufferedReader(read);
-                String txt = null;
-                while((txt = bufferedReader.readLine()) != null){    //读取文件,将文件内容放入到set中
-                    set.add(txt);
-                }
-            }
-            else{         //不存在抛出异常信息
-                throw new Exception("敏感词库文件不存在");
-            }
-        } catch (Exception e) {
-            throw e;
-        }finally{
-            read.close();     //关闭文件流
-        }
-        return set;
-    }
-}

+ 0 - 2
4dkankan-common-utils/src/main/java/com/fdkankan/common/validation/Variable.java

@@ -13,8 +13,6 @@ public class Variable {
     public static Map<String,String> globalCodeLogin = new HashMap<String,String>();
 
     public static ConcurrentLinkedQueue<String> queue = new ConcurrentLinkedQueue<String>();
-    //论坛过滤
-    public static SensitiveWord sensitiveWord = new SensitiveWord();
 
     //更新浏览大场景次数
     public static Map<String, Integer> globalViewCount = new ConcurrentHashMap<String, Integer>();

+ 1 - 2
4dkankan-utils-fyun-oss/src/main/java/com/fdkankan/fyun/oss/OssFileService.java

@@ -2,7 +2,6 @@ package com.fdkankan.fyun.oss;
 
 import com.aliyun.oss.OSS;
 import com.aliyun.oss.model.*;
-import com.fdkankan.common.util.CreateObjUtil;
 import com.fdkankan.fyun.face.AbstractFYunFileService;
 import com.fdkankan.fyun.oss.constant.OssConstants;
 import org.slf4j.Logger;
@@ -87,7 +86,7 @@ public class OssFileService extends AbstractFYunFileService {
         try {
             String command = String.format(OssConstants.UPLOAD_SH, ossPath, filePath);
             log.info("开始上传文件, ossPath:{}, srcPath:{}", ossPath, filePath);
-            CreateObjUtil.callshell(command);
+            callshell(command);
             return fYunFileConfig.getHost().concat(remoteFilePath);
         } catch (Exception e) {
             log.error("上传文件失败, ossPath:{}, srcPath:{}", ossPath, filePath);

+ 20 - 0
4dkankan-utils-fyun-parent/src/main/java/com/fdkankan/fyun/face/AbstractFYunFileService.java

@@ -1,6 +1,9 @@
 package com.fdkankan.fyun.face;
 
 import com.fdkankan.fyun.config.FYunFileConfig;
+import com.fdkankan.fyun.model.StreamGobbler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
@@ -11,6 +14,8 @@ import java.util.Map;
 @Component
 public abstract class AbstractFYunFileService implements FYunFileServiceInterface {
 
+    private Logger log = LoggerFactory.getLogger(this.getClass().getName());
+
     @Autowired
     public FYunFileConfig fYunFileConfig;
 
@@ -90,4 +95,19 @@ public abstract class AbstractFYunFileService implements FYunFileServiceInterfac
     public void downloadFile(String remoteFilePath, String localPath) {
         downloadFile(fYunFileConfig.getBucket(), remoteFilePath, localPath);
     }
+
+    public void callshell(String command){
+        try {
+            Long start = System.currentTimeMillis();
+            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();
+            log.info("脚本{}执行完毕,用时:{}ms",command,System.currentTimeMillis()-start);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
 }

+ 61 - 0
4dkankan-utils-fyun-parent/src/main/java/com/fdkankan/fyun/model/StreamGobbler.java

@@ -0,0 +1,61 @@
+package com.fdkankan.fyun.model;
+
+import java.io.*;
+
+public class StreamGobbler extends Thread {
+
+	InputStream is;
+    String type;
+    OutputStream os;
+
+    public StreamGobbler(InputStream is, String type) {
+        this(is, type, null);
+    }
+
+    StreamGobbler(InputStream is, String type, OutputStream redirect) {
+        this.is = is;
+        this.type = type;
+        this.os = redirect;
+    }
+
+    public void run() {
+        InputStreamReader isr = null;
+        BufferedReader br = null;
+        PrintWriter pw = null;
+        try {
+            if (os != null)
+                pw = new PrintWriter(os);
+
+            isr = new InputStreamReader(is);
+            br = new BufferedReader(isr);
+            String line=null;
+            while ( (line = br.readLine()) != null) {
+                if (pw != null)
+                    pw.println(line);
+                System.out.println(type + ">" + line);
+            }
+
+            if (pw != null)
+                pw.flush();
+        } catch (IOException ioe) {
+            ioe.printStackTrace();
+        } finally{
+            try {
+            	if(pw!=null)
+            	{
+            		 pw.close();
+            	}
+            	if(br!=null)
+            	{
+            		br.close();
+            	}
+            	if(isr!=null)
+            	{
+            		isr.close();
+            	}
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+}

+ 1 - 2
4dkankan-utils-fyun-s3/src/main/java/com/fdkankan/fyun/s3/S3FileService.java

@@ -3,7 +3,6 @@ package com.fdkankan.fyun.s3;
 import cn.hutool.core.collection.CollUtil;
 import com.amazonaws.services.s3.AmazonS3;
 import com.amazonaws.services.s3.model.*;
-import com.fdkankan.common.util.CreateObjUtil;
 import com.fdkankan.fyun.constant.FYunConstants;
 import com.fdkankan.fyun.face.AbstractFYunFileService;
 import org.apache.commons.lang3.StringUtils;
@@ -97,7 +96,7 @@ public class S3FileService extends AbstractFYunFileService {
         try {
             String command = String.format(FYunConstants.UPLOAD_SH, ossPath, filePath);
             log.info("开始上传文件, ossPath:{}, srcPath:{}", ossPath, filePath);
-            CreateObjUtil.callshell(command);
+            callshell(command);
             return fYunFileConfig.getHost().concat(remoteFilePath);
         } catch (Exception e) {
             log.error("上传文件失败, ossPath:{}, srcPath:{}", ossPath, filePath);

+ 61 - 0
4dkankan-utils-fyun/src/main/java/com/fdkankan/fyun/model/StreamGobbler.java

@@ -0,0 +1,61 @@
+package com.fdkankan.fyun.model;
+
+import java.io.*;
+
+public class StreamGobbler extends Thread {
+
+	InputStream is;
+    String type;
+    OutputStream os;
+
+    public StreamGobbler(InputStream is, String type) {
+        this(is, type, null);
+    }
+
+    StreamGobbler(InputStream is, String type, OutputStream redirect) {
+        this.is = is;
+        this.type = type;
+        this.os = redirect;
+    }
+
+    public void run() {
+        InputStreamReader isr = null;
+        BufferedReader br = null;
+        PrintWriter pw = null;
+        try {
+            if (os != null)
+                pw = new PrintWriter(os);
+
+            isr = new InputStreamReader(is);
+            br = new BufferedReader(isr);
+            String line=null;
+            while ( (line = br.readLine()) != null) {
+                if (pw != null)
+                    pw.println(line);
+                System.out.println(type + ">" + line);
+            }
+
+            if (pw != null)
+                pw.flush();
+        } catch (IOException ioe) {
+            ioe.printStackTrace();
+        } finally{
+            try {
+            	if(pw!=null)
+            	{
+            		 pw.close();
+            	}
+            	if(br!=null)
+            	{
+            		br.close();
+            	}
+            	if(isr!=null)
+            	{
+            		isr.close();
+            	}
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+}

+ 26 - 13
4dkankan-utils-fyun/src/main/java/com/fdkankan/fyun/oss/UploadToOssUtil.java

@@ -1,18 +1,18 @@
 package com.fdkankan.fyun.oss;
 
 import cn.hutool.core.collection.CollUtil;
-import cn.hutool.core.collection.ListUtil;
 import cn.hutool.core.io.FileUtil;
-import cn.hutool.core.util.StrUtil;
-import com.alibaba.fastjson.JSON;
-import com.aliyun.oss.OSS;
 import com.aliyun.oss.OSSClient;
+import com.aliyun.oss.model.DeleteObjectsRequest;
+import com.aliyun.oss.model.DeleteObjectsResult;
+import com.aliyun.oss.model.ListObjectsRequest;
+import com.aliyun.oss.model.ObjectListing;
+import com.aliyun.oss.model.ObjectMetadata;
+import com.aliyun.oss.model.PutObjectResult;
 import com.aliyun.oss.model.*;
 import com.amazonaws.HttpMethod;
 import com.amazonaws.auth.AWSStaticCredentialsProvider;
 import com.amazonaws.auth.BasicAWSCredentials;
-import com.amazonaws.client.builder.AwsClientBuilder;
-import com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration;
 import com.amazonaws.regions.Regions;
 import com.amazonaws.services.s3.AmazonS3;
 import com.amazonaws.services.s3.AmazonS3ClientBuilder;
@@ -21,13 +21,9 @@ import com.amazonaws.services.s3.model.DeleteObjectsRequest.KeyVersion;
 import com.amazonaws.services.s3.model.GeneratePresignedUrlRequest;
 import com.amazonaws.services.s3.model.GetObjectRequest;
 import com.amazonaws.services.s3.model.PutObjectRequest;
-import com.amazonaws.services.s3.model.S3Object;
-import com.amazonaws.services.s3.model.S3ObjectInputStream;
-import com.amazonaws.services.s3.model.S3ObjectSummary;
-import com.fdkankan.common.util.CreateObjUtil;
+import com.amazonaws.services.s3.model.*;
 import com.fdkankan.fyun.constant.StorageType;
-import java.net.URLDecoder;
-import java.util.stream.Collectors;
+import com.fdkankan.fyun.model.StreamGobbler;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.fileupload.FileItem;
 import org.apache.commons.fileupload.FileItemFactory;
@@ -43,10 +39,12 @@ import java.io.*;
 import java.net.FileNameMap;
 import java.net.URL;
 import java.net.URLConnection;
+import java.net.URLDecoder;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 @Slf4j
 @Component
@@ -131,7 +129,7 @@ public class UploadToOssUtil {
 		try {
 			String command = String.format(UploadToOssUtil.UPLOAD_SH, ossPath, filePath);
 			log.info("开始上传文件, ossPath:{}, srcPath:{}", ossPath, filePath);
-			CreateObjUtil.callshell(command);
+			callshell(command);
 			log.info("上传文件完毕, ossPath:{}, srcPath:{}", ossPath, filePath);
 		} catch(Exception e) {
 			log.error("上传文件失败, ossPath:{}, srcPath:{}", ossPath, filePath);
@@ -139,6 +137,21 @@ public class UploadToOssUtil {
 		}
 	}
 
+	public static void callshell(String command){
+		try {
+			Long start = System.currentTimeMillis();
+			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();
+			log.info("脚本{}执行完毕,用时:{}ms",command,System.currentTimeMillis()-start);
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+
 	public void uploadSdk(String bucket, String filePath, String key1) {
 		log.info("开始上传文件 源路径:{},目标路径:{},type:{}" , filePath,key1,type);
 		switch (type){

+ 1 - 1
4dkankan-common-utils/src/main/java/com/fdkankan/common/util/ConstantCmd.java

@@ -1,4 +1,4 @@
-package com.fdkankan.common.util;
+package com.fdkankan.model.constants;
 
 public class ConstantCmd {
 

+ 1 - 1
4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/ConstantFileName.java

@@ -1,4 +1,4 @@
-package com.fdkankan.common.constant;
+package com.fdkankan.model.constants;
 
 public class ConstantFileName {
     //背景音乐

+ 1 - 3
4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/ConstantFilePath.java

@@ -1,6 +1,4 @@
-package com.fdkankan.common.constant;
-
-import java.io.File;
+package com.fdkankan.model.constants;
 
 public class ConstantFilePath {
     public static final String BASE_PATH = "/mnt/4Dkankan";

+ 1 - 4
4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/UploadFilePath.java

@@ -1,7 +1,4 @@
-package com.fdkankan.common.constant;
-
-import java.util.HashMap;
-import java.util.Map;
+package com.fdkankan.model.constants;
 
 public class UploadFilePath {
 

+ 1 - 1
4dkankan-common-utils/src/main/java/com/fdkankan/common/proto/BigSceneProto.java

@@ -1,4 +1,4 @@
-package com.fdkankan.common.proto;
+package com.fdkankan.model.proto;
 
 public final class BigSceneProto {
   private BigSceneProto() {}

+ 1 - 1
4dkankan-common-utils/src/main/java/com/fdkankan/common/proto/Common.java

@@ -1,7 +1,7 @@
 // Generated by the protocol buffer compiler.  DO NOT EDIT!
 // source: Common.proto
 
-package com.fdkankan.common.proto;
+package com.fdkankan.model.proto;
 
 public final class Common {
   private Common() {}

+ 1 - 1
4dkankan-common-utils/src/main/java/com/fdkankan/common/proto/Visionmodeldata.java

@@ -1,7 +1,7 @@
 // Generated by the protocol buffer compiler.  DO NOT EDIT!
 // source: visionmodeldata.proto
 
-package com.fdkankan.common.proto;
+package com.fdkankan.model.proto;
 
 public final class Visionmodeldata {
   private Visionmodeldata() {}

+ 1 - 1
4dkankan-common-utils/src/main/java/com/fdkankan/common/proto/format/CouchDBFormat.java

@@ -1,4 +1,4 @@
-package com.fdkankan.common.proto.format;
+package com.fdkankan.model.proto.format;
 
 
 import com.google.protobuf.ExtensionRegistry;

+ 1 - 1
4dkankan-common-utils/src/main/java/com/fdkankan/common/proto/format/HtmlFormat.java

@@ -1,4 +1,4 @@
-package com.fdkankan.common.proto.format;
+package com.fdkankan.model.proto.format;
 /* 
     Copyright (c) 2009, Orbitz World Wide
     All rights reserved.

+ 2 - 2
4dkankan-common-utils/src/main/java/com/fdkankan/common/proto/format/JavaPropsFormat.java

@@ -1,6 +1,6 @@
-package com.fdkankan.common.proto.format;
+package com.fdkankan.model.proto.format;
 
-import com.google.protobuf.*;
+import com.google.protobuf.ByteString;
 
 import java.io.IOException;
 import java.math.BigInteger;

+ 1 - 1
4dkankan-common-utils/src/main/java/com/fdkankan/common/proto/format/JsonFormat.java

@@ -1,4 +1,4 @@
-package com.fdkankan.common.proto.format;
+package com.fdkankan.model.proto.format;
 /* 
 	Copyright (c) 2009, Orbitz World Wide
 	All rights reserved.

+ 1 - 2
4dkankan-common-utils/src/main/java/com/fdkankan/common/proto/format/SmileFormat.java

@@ -1,4 +1,4 @@
-package com.fdkankan.common.proto.format;
+package com.fdkankan.model.proto.format;
 /* 
 	Copyright (c) 2009, Orbitz World Wide
 	All rights reserved.
@@ -29,7 +29,6 @@ package com.fdkankan.common.proto.format;
 */
 
 
-import com.google.protobuf.*;
 import com.google.protobuf.Descriptors.Descriptor;
 import com.google.protobuf.Descriptors.EnumDescriptor;
 import com.google.protobuf.Descriptors.EnumValueDescriptor;

+ 1 - 2
4dkankan-common-utils/src/main/java/com/fdkankan/common/proto/format/XmlFormat.java

@@ -1,4 +1,4 @@
-package com.fdkankan.common.proto.format;
+package com.fdkankan.model.proto.format;
 /* 
     Copyright (c) 2009, Orbitz World Wide
     All rights reserved.
@@ -29,7 +29,6 @@ package com.fdkankan.common.proto.format;
 */
 
 
-import com.google.protobuf.*;
 import com.google.protobuf.Descriptors.EnumValueDescriptor;
 import com.google.protobuf.Descriptors.FieldDescriptor;
 

+ 11 - 179
4dkankan-common-utils/src/main/java/com/fdkankan/common/util/ComputerUtil.java

@@ -1,29 +1,31 @@
-package com.fdkankan.common.util;
+package com.fdkankan.model.utils;
 
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import com.fdkankan.common.constant.ConstantFileName;
-import com.fdkankan.common.constant.ConstantFilePath;
 import com.fdkankan.common.constant.ErrorCode;
-import com.fdkankan.common.constant.UploadFilePath;
 import com.fdkankan.common.exception.BusinessException;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Component;
+import com.fdkankan.common.util.FileUtils;
+import com.fdkankan.model.constants.ConstantFileName;
+import com.fdkankan.model.constants.ConstantFilePath;
+import com.fdkankan.model.constants.UploadFilePath;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.io.File;
-import java.util.*;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
 
 /**
  * 生成场景和计算场景
  * Created by Hb_zzZ on 2019/5/8.
  */
-@Slf4j
-@Component
 public class ComputerUtil {
 
+    private static Logger log = LoggerFactory.getLogger(ComputerUtil.class.getName());
 
     public static Map<String,String> computer(String projectNum, String path, String buildType) throws Exception{
 
@@ -410,176 +412,6 @@ public class ComputerUtil {
         return map;
     }
 
-//    public static SceneEntity createScene(String projectNum, Long cameraId, String cameraName, String phoneId, String scenepsd,
-//                                          String unicode, Long cameraType, String fileId, String prefix,
-//                                          String imgsName, String pic, String isModel, Long userId, String userName,
-//                                          String algorithm, Integer sceneShootCount, String sceneName,
-//                                          String sceneDec, Integer sceneType, String gps, ISceneService sceneService,
-//                                          Integer type, ModelingMsgProducer producer, String url, String ecsType,
-//                                          RubberSheetingUtil rubberSheetingUtil)throws Exception{
-//        //先返回链接地址
-//        SceneEntity scene = new SceneEntity();
-//        scene.setWebSite(url+projectNum);
-//        scene.setCameraId(cameraId);
-//        scene.setPhoneId(phoneId);
-//        scene.setNum(String.valueOf(projectNum));
-//        if(scenepsd == null)
-//        {
-//            scenepsd = "";
-//        }
-//        if(!scenepsd.equals(""))
-//        {
-//            scene.setSceneKey(scenepsd);
-//        }
-//
-//        if(!StringUtils.isEmpty(ecsType)){
-//            scene.setEcs(ecsType);
-//        }
-//
-//        String path =  ConstantFilePath.BUILD_MODEL_PATH + unicode;
-//
-//        if(cameraType.longValue() >= 4){
-//            scene.setDataSource(ConstantFilePath.BUILD_MODEL_PATH +
-//                    cameraName.replace("4DKKPRO_", "").replace("-fdage", "").toLowerCase() + File.separator + fileId + File.separator + unicode);
-//        }else {
-//            scene.setDataSource(prefix+imgsName);
-//        }
-//
-//        if(cameraType.longValue() == 14){
-//
-//            scene.setDataSource(ConstantFilePath.BUILD_MODEL_LASER_PATH +
-//                    cameraName.replace("4DKKPRO_", "").replace("-fdage", "").toLowerCase() + File.separator +
-//                    fileId + File.separator + unicode);
-//
-//            log.info("激光相机 dataSource :" + scene.getDataSource());
-//
-//        }
-//
-//
-//        if(pic!=null&&pic.length()>5)
-//        {
-//            scene.setThumb(pic);
-//        }
-//        else
-//        {
-//            scene.setThumb(ConstantUrl.DEFAULT_SCENE_PIC);
-//        }
-//
-//        String parametr = "";
-//        parametr+=unicode+":;"+path+":;"+prefix+":;"+imgsName+":;"+projectNum+":;"+isModel;
-//        if(userName!=null&&!userName.trim().equals(""))
-//        {
-//            parametr+=":;"+userName;
-//            scene.setUserId(userId);
-//        }
-//        else
-//        {
-//            parametr+=":;noMan";
-//        }
-//        parametr+=":;"+cameraType;
-//        parametr+=":;"+algorithm;
-//        parametr += ":;" + fileId;
-//        parametr += ":;" + cameraName;
-//        parametr += ":;1";
-//        log.info("大场景添加到队列:"+parametr);
-//        producer.sendMsg(parametr);
-//
-//        if(sceneShootCount == null)
-//        {
-//            scene.setShootCount(0);
-//        }
-//        else
-//        {
-//            scene.setShootCount(sceneShootCount);
-//        }
-//        if(sceneName!=null)
-//        {
-//            scene.setSceneName(sceneName);
-//        }
-//        if(sceneDec!=null)
-//        {
-//            scene.setSceneDec("<p>"+sceneDec+"</p>");
-//        }
-//
-//        if(sceneType!=null)
-//        {
-//            scene.setSceneType(sceneType);
-//        }
-//
-//        if(gps!=null&&!gps.trim().equals(""))
-//        {
-//            scene.setGps(gps);
-//        }
-//
-//        scene.setSceneScheme(cameraType.intValue());
-//        scene.setAlgorithm(algorithm);
-//        log.info("场景记录添加到数据库:"+projectNum);
-//        if(type == 0){
-//            sceneService.save(scene);
-//        }
-//
-//        JSONObject scenejson = JSONObject.parseObject(JSONObject.toJSONString(scene));
-//        scenejson.put("thumbImg", 0);
-//        scenejson.put("version", 0);
-//        scenejson.put("floorLogo", 0);
-//        if(!scenepsd.equals("")){
-//            scenejson.put("scenePsd", scenepsd);
-//            scenejson.put("public", 1);
-//        }else{
-//            scenejson.put("scenePsd", "");
-//            scenejson.put("public", 0);
-//        }
-//        if(cameraType < 4){
-//            scenejson.put("visions", 1);
-//        }else {
-//            scenejson.put("visions", 2);
-//        }
-//        scenejson.put("createTime", new DateTime(new Date()).toString("yyyy-MM-dd HH:mm"));
-//
-//        File file = new File(ConstantFilePath.SCENE_PATH+"data/data"+projectNum);
-//        if(!file.exists()||!file.isDirectory())
-//        {
-//            file.mkdirs();
-//        }
-//        FileUtils.writeFile(ConstantFilePath.SCENE_PATH+"data/data"+projectNum+File.separator+"scene.json", scenejson.toString());
-//
-//        //生成二维码
-//        MatrixToImageWriterUtil.createQRCode(url + projectNum, ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+projectNum+".png", null);
-//        MatrixToImageWriterUtil.createQRCode(url + projectNum + "&lang=en", ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+projectNum+"_en.png", null);
-//        log.info("二维码生成完成");
-//
-//        return scene;
-//    }
-
-
-    public static String getMQMsg(String projectNum, String cameraName, String unicode, Long cameraType, String fileId,
-                                  String prefix, String imgsName, String isModel,String userName,
-                                  String algorithm, Integer resolution, String buildType, String path) {
-        String parametr = "";
-        parametr+= unicode +":;"+ path +":;"+ prefix +":;"+ imgsName +":;"+ projectNum +":;"+ isModel;
-        if(userName !=null&&!userName.trim().equals("")){
-            parametr+=":;"+ userName;
-        }else{
-            parametr+=":;noMan";
-        }
-        parametr+=":;"+ cameraType;
-        parametr+=":;"+ algorithm;
-        parametr += ":;" + fileId;
-        parametr += ":;" + cameraName;
-        if(resolution == null){
-            parametr += ":;0";
-        }else {
-            parametr += ":;" + resolution.intValue();
-        }
-
-        if(buildType != null){
-            parametr += ":;" + buildType;
-        }
-
-        log.info("pro大场景添加到队列:"+parametr);
-        return parametr;
-    }
-
     /**
      * 循环检测算法是否计算成功
      * @param uploadJsonPath uploadjson路径

+ 3 - 3
4dkankan-common-utils/src/main/java/com/fdkankan/common/util/ConvertCommonUtils.java

@@ -1,7 +1,7 @@
-package com.fdkankan.common.util;
+package com.fdkankan.model.utils;
 
-import com.fdkankan.common.proto.Common;
-import com.fdkankan.common.proto.format.JsonFormat;
+import com.fdkankan.model.proto.Common;
+import com.fdkankan.model.proto.format.JsonFormat;
 import lombok.extern.slf4j.Slf4j;
 
 import java.io.*;

+ 3 - 3
4dkankan-common-utils/src/main/java/com/fdkankan/common/util/ConvertUtils.java

@@ -1,7 +1,7 @@
-package com.fdkankan.common.util;
+package com.fdkankan.model.utils;
 
-import com.fdkankan.common.proto.Visionmodeldata;
-import com.fdkankan.common.proto.format.JsonFormat;
+import com.fdkankan.model.proto.Visionmodeldata;
+import com.fdkankan.model.proto.format.JsonFormat;
 import lombok.extern.slf4j.Slf4j;
 
 import java.io.*;

+ 2 - 1
4dkankan-common-utils/src/main/java/com/fdkankan/common/util/CreateHouseJsonUtil.java

@@ -1,4 +1,4 @@
-package com.fdkankan.common.util;
+package com.fdkankan.model.utils;
 
 import java.io.IOException;
 import java.io.Serializable;
@@ -9,6 +9,7 @@ import java.util.Map;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.fdkankan.common.util.FileUtil;
 import lombok.AllArgsConstructor;
 import lombok.Builder;
 import lombok.Data;

+ 12 - 59
4dkankan-common-utils/src/main/java/com/fdkankan/common/util/CreateObjUtil.java

@@ -1,16 +1,16 @@
-package com.fdkankan.common.util;
+package com.fdkankan.model.utils;
 
 import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.util.ZipUtil;
-import com.fdkankan.common.constant.ConstantFileName;
-import com.fdkankan.common.constant.ConstantFilePath;
-import com.fdkankan.common.proto.BigSceneProto;
-import com.fdkankan.common.proto.Common;
-import com.fdkankan.common.proto.Visionmodeldata;
-import com.fdkankan.common.proto.format.JsonFormat;
+import com.fdkankan.model.constants.ConstantCmd;
+import com.fdkankan.model.constants.ConstantFileName;
+import com.fdkankan.model.constants.ConstantFilePath;
+import com.fdkankan.model.proto.BigSceneProto;
+import com.fdkankan.model.proto.Common;
+import com.fdkankan.model.proto.Visionmodeldata;
+import com.fdkankan.model.proto.format.JsonFormat;
 import com.google.protobuf.TextFormat;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.util.StopWatch;
 
 import java.io.*;
 import java.util.HashMap;
@@ -276,7 +276,7 @@ public class CreateObjUtil {
 		bos.close();
 
 		// gzip压缩
-		cn.hutool.core.io.FileUtil.writeBytes(ZipUtil.gzip(new File(despath)),despath + ".gzip");
+		FileUtil.writeBytes(ZipUtil.gzip(new File(despath)),despath + ".gzip");
 
 		// 重命名
 		FileUtil.rename(new File(despath + ".gzip"), despath, true);
@@ -397,18 +397,16 @@ public class CreateObjUtil {
 		}
 	}
 	
-	public static void callshell(String command)
-	{ 
+	public static void callshell(String command){
         try {
-			 StopWatch stopWatch = new StopWatch();
-			 stopWatch.start();
+			 Long start = System.currentTimeMillis();
 			 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();
-			log.info("脚本{}执行完毕,用时:{}",command,stopWatch.toString());
+			log.info("脚本{}执行完毕,用时:{}ms",command,System.currentTimeMillis()-start);
         } catch (Exception e) {  
             e.printStackTrace();  
         }  
@@ -624,49 +622,4 @@ public class CreateObjUtil {
 		log.info("matterpro获取阿里云图片方法完成,时间为:" + (System.currentTimeMillis() - start));
 	}
 
-	public static void main(String[] args) throws Exception{
-		CreateObjUtil.convertTxtToVisionmodeldata("F:\\visiontest\\KJ-HXMNTDYs1E_3.txt", "F:\\visiontest\\vision.modeldata");
-//		String type = FileTypeUtil.getType(new File("F:\\visiontest\\KJ-HXMNTDYs1E_3.txt"));
-//		System.out.println(type);
-//		CreateObjUtil.convertTxtToDam("F:\\visiontest\\modeldata.txt", "F:\\visiontest\\dacf7dfa24ae47fab8fcebfe4dc41ab9_50k.dam");
-
-//		String text = "web:web";
-//		byte[] data = text.getBytes("UTF-8");
-//		String s = Base64.getEncoder().encodeToString(data);
-//		System.out.println(s);
-
-//		org.apache.commons.lang3.time.StopWatch stopWatch = new org.apache.commons.lang3.time.StopWatch();
-//		stopWatch.start();
-//		Thread.sleep(2000);
-//		stopWatch.stop();
-//		System.out.println(stopWatch.getTime(TimeUnit.SECONDS));
-//		ExecutorService executorService = Executors.newFixedThreadPool(1);
-//		Future<String> future = executorService.submit(()->{
-//			return CreateObjUtil.test();
-//		});
-//
-//		try {
-//			String s = future.get();
-//		}catch (Exception e){
-//
-//			System.out.println(ExceptionUtil.stacktraceToString(e));
-//		}
-
-
-
-	}
-
-	private static String test() throws Exception{
-		try {
-			String test = null;
-			test.equals("123");
-		}catch (Exception e){
-			throw e;
-		}finally {
-
-		}
-		return "123";
-
-	}
-
 }

+ 3 - 2
4dkankan-common-utils/src/main/java/com/fdkankan/common/util/SceneUtil.java

@@ -1,10 +1,11 @@
-package com.fdkankan.common.util;
+package com.fdkankan.model.utils;
 
 import cn.hutool.core.io.FileUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import com.fdkankan.common.constant.ConstantFilePath;
+import com.fdkankan.model.constants.ConstantFilePath;
+
 import java.io.File;
 import java.nio.charset.Charset;
 import java.util.List;

+ 61 - 0
4dkankan-utils-model/src/main/java/com/fdkankan/model/utils/StreamGobbler.java

@@ -0,0 +1,61 @@
+package com.fdkankan.model.utils;
+
+import java.io.*;
+
+public class StreamGobbler extends Thread {
+
+	InputStream is;
+    String type;
+    OutputStream os;
+
+    public StreamGobbler(InputStream is, String type) {
+        this(is, type, null);
+    }
+
+    StreamGobbler(InputStream is, String type, OutputStream redirect) {
+        this.is = is;
+        this.type = type;
+        this.os = redirect;
+    }
+
+    public void run() {
+        InputStreamReader isr = null;
+        BufferedReader br = null;
+        PrintWriter pw = null;
+        try {
+            if (os != null)
+                pw = new PrintWriter(os);
+
+            isr = new InputStreamReader(is);
+            br = new BufferedReader(isr);
+            String line=null;
+            while ( (line = br.readLine()) != null) {
+                if (pw != null)
+                    pw.println(line);
+                System.out.println(type + ">" + line);
+            }
+
+            if (pw != null)
+                pw.flush();
+        } catch (IOException ioe) {
+            ioe.printStackTrace();
+        } finally{
+            try {
+            	if(pw!=null)
+            	{
+            		 pw.close();
+            	}
+            	if(br!=null)
+            	{
+            		br.close();
+            	}
+            	if(isr!=null)
+            	{
+            		isr.close();
+            	}
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+}