dengsixing 5 ay önce
ebeveyn
işleme
dea4f4aed6

+ 1 - 1
src/main/java/com/fdkankan/project/tieta/bean/ResultData.java

@@ -23,7 +23,7 @@ public class ResultData<T> implements Serializable {
     /**
      * 后端返回结果
      */
-    private T data;
+    private transient T data;
     /**
      * 请求是否成功
      */

+ 4 - 7
src/main/java/com/fdkankan/project/tieta/controller/ConvertController.java

@@ -37,6 +37,10 @@ public class ConvertController {
     private RedisClient redisClient;
     @Autowired
     FullphotoUprecordService fullphotoUprecordService;
+    @Autowired
+    private FdfsUtil fdfsUtil;
+    @Autowired
+    FullphotoFileindexService fullphotoFileindexService;
 
     @PostMapping("/sendConvert")
     public ResultData sendConvert(@RequestBody @Validated SendConvertDTO dto){
@@ -61,8 +65,6 @@ public class ConvertController {
         return ResultData.ok();
     }
 
-    @Autowired
-    FullphotoFileindexService fullphotoFileindexService;
     @GetMapping("/pushHistory2")
     public ResultData pushHistory2(){
 //        List<FullphotoFileindex> fullphotoFileindices = null;
@@ -170,15 +172,10 @@ public class ConvertController {
 
         }
 
-
         return ResultData.ok();
 
     }
 
-    @Autowired
-    private FdfsUtil fdfsUtil;
-
-
     @GetMapping("pushOldHistory")
     public ResultData pushOldHistory(@RequestParam(value = "stationCode", required = false) String stationCode, @RequestParam(value = "entityId", required = false)String entityId){
         convertService.pushOldHistory(stationCode, entityId);

+ 0 - 33
src/main/java/com/fdkankan/project/tieta/controller/SceneController.java

@@ -1,25 +1,15 @@
 package com.fdkankan.project.tieta.controller;
 
 
-import cn.hutool.core.img.ImgUtil;
-import cn.hutool.core.io.FileUtil;
-import cn.hutool.http.HttpUtil;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.fdkankan.project.tieta.bean.ResultData;
-import com.fdkankan.project.tieta.entity.FullphotoFileindex;
 import com.fdkankan.project.tieta.entity.Scene;
 import com.fdkankan.project.tieta.service.FullphotoFileindexService;
 import com.fdkankan.project.tieta.service.SceneService;
-import com.fdkankan.project.tieta.utils.CreateObjUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
-
 import org.springframework.web.bind.annotation.RestController;
 
-import java.io.File;
-import java.util.List;
-
 /**
  * <p>
  *  前端控制器
@@ -51,29 +41,6 @@ public class SceneController {
     @Autowired
     private FullphotoFileindexService fullphotoFileindexService;
 
-    @GetMapping("/test2")
-    public ResultData test2(String stationCode, String roomEntityID) throws Exception {
-
-        String path = "D:\\test\\tieta\\" + stationCode + "_" + roomEntityID + "\\";
-        List<FullphotoFileindex> list = fullphotoFileindexService.list(new LambdaQueryWrapper<FullphotoFileindex>().eq(FullphotoFileindex::getStationCode, stationCode).eq(FullphotoFileindex::getEntityId, roomEntityID));
-        list.stream().forEach(v->{
-            String localPath = path + v.getFileName();
-            HttpUtil.downloadFile(v.getFileUrl(), localPath);
-            if(v.getFileName().endsWith("jpg")){
-                String highPath = path + "pan\\high\\" + v.getFileName();
-                FileUtil.mkParentDirs(highPath);
-                String lowPath = path + "pan\\low\\" + v.getFileName();
-                FileUtil.mkParentDirs(lowPath);
-                ImgUtil.scale(new File(localPath),new File(highPath), 0.5f);
-                ImgUtil.scale(new File(localPath),new File(lowPath), 0.0625f);
-
-            }
-        });
-
-        CreateObjUtil.convertTxtToVisionmodeldata(path + "vision.txt", path + "vision.modeldata");
-
-        return  ResultData.ok();
-    }
 
     @GetMapping(value = "/ping")
     public ResultData ping(){

Dosya farkı çok büyük olduğundan ihmal edildi
+ 0 - 7340
src/main/java/com/fdkankan/project/tieta/proto/BigSceneProto.java


Dosya farkı çok büyük olduğundan ihmal edildi
+ 0 - 4345
src/main/java/com/fdkankan/project/tieta/proto/Visionmodeldata.java


Dosya farkı çok büyük olduğundan ihmal edildi
+ 0 - 1603
src/main/java/com/fdkankan/project/tieta/proto/format/JsonFormat.java


+ 10 - 9
src/main/java/com/fdkankan/project/tieta/service/impl/ConvertServiceImpl.java

@@ -34,6 +34,9 @@ import java.util.stream.Collectors;
 @Service
 public class ConvertServiceImpl implements IConvertService {
 
+    private static String can_download_host = "192.168.53.186";
+    private static String upTime = "upTime";
+
     @Autowired
     private RabbitMqProducer mqProducer;
     @Autowired
@@ -60,7 +63,7 @@ public class ConvertServiceImpl implements IConvertService {
         if(StrUtil.isNotEmpty(convertType)){
             playload.put("convertType", convertType);
         }
-        if(StrUtil.isNotEmpty(convertType) && convertType.equals("upTime")){//只更新上传时间,直接发送,不需要查文件列表数据
+        if(StrUtil.isNotEmpty(convertType) && convertType.equals(upTime)){//只更新上传时间,直接发送,不需要查文件列表数据
             mqProducer.sendByWorkQueue(Constant.QUEUE_SCENE_CONVERT, playload);
             return ResultData.ok();
         }
@@ -72,7 +75,7 @@ public class ConvertServiceImpl implements IConvertService {
             JSONObject item = new JSONObject();
             item.put("fileName", v.getFileName());
             item.put("fileType", v.getFileType());
-            item.put("fileUrl", v.getFileUrl().replace("120.52.40.57", "192.168.53.186").replace("ziyuanfastdfs.chinatowercom.cn", "192.168.53.186"));
+            item.put("fileUrl", v.getFileUrl().replace("120.52.40.57", can_download_host).replace("ziyuanfastdfs.chinatowercom.cn", can_download_host));
             return item;
         }).collect(Collectors.toList());
         playload.put("fileList", fileList);
@@ -80,11 +83,6 @@ public class ConvertServiceImpl implements IConvertService {
         return ResultData.ok();
     }
 
-    public static void main(String[] args) {
-        String str =  "http://ziyuanfastdfs.chinatowercom.cn:1888/asfsdf/dfsdf.jpg";
-        System.out.println(str.replace("120.52.40.57", "192.168.53.186").replace("ziyuanfastdfs.chinatowercom.cn", "192.168.53.186"));
-    }
-
     @Override
     public void scenePushHistory() {
         List<FullphotoFileindex> fullphotoFileindices = null;
@@ -116,7 +114,10 @@ public class ConvertServiceImpl implements IConvertService {
     public void pushOldHistory(String stationCode, String entityId) {
 
         log.info("推送历史数据开始");
-        List<FullphotoUprecord> list = fullphotoUprecordService.list(new LambdaQueryWrapper<FullphotoUprecord>().select(FullphotoUprecord::getStationCode, FullphotoUprecord::getEntityId).groupBy(FullphotoUprecord::getStationCode, FullphotoUprecord::getEntityId));
+        List<FullphotoUprecord> list = fullphotoUprecordService.list(
+                new LambdaQueryWrapper<FullphotoUprecord>()
+                        .select(FullphotoUprecord::getStationCode, FullphotoUprecord::getEntityId)
+                        .groupBy(FullphotoUprecord::getStationCode, FullphotoUprecord::getEntityId));
         for (FullphotoUprecord fullphotoUprecord : list) {
 
             if(StrUtil.isNotEmpty(entityId) && !entityId.equals(fullphotoUprecord.getEntityId())){
@@ -140,7 +141,7 @@ public class ConvertServiceImpl implements IConvertService {
                     String convertType = null;
                     Boolean push = false;
                     if(i == 0){
-                        convertType = "upTime";//默认vr系统已经是
+                        convertType = upTime;//默认vr系统已经是
                         push = true;
                     }else{
                         convertType = "old";

+ 161 - 168
src/main/java/com/fdkankan/project/tieta/utils/ConvertUtil.java

@@ -1,168 +1,161 @@
-package com.fdkankan.project.tieta.utils;
-
-import cn.hutool.core.io.FileUtil;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-
-import java.io.File;
-import java.util.Objects;
-
-public class ConvertUtil {
-
-    public static void main(String[] args) throws Exception {
-
-        String srcPath = args[0];
-        System.out.println(srcPath);
-        String targetPath = args[1];
-        System.out.println(targetPath);
-
-        convert(srcPath, targetPath);
-//		scanner.close();
-    }
-
-    /**
-     *
-     * @param sourcePath 原始资源目录
-     * @param targetPath 目标资源目录
-     * @return boolean true-转换成功  false-转换失败
-     */
-    public static void convert(String sourcePath, String targetPath) throws Exception {
-
-        String obj2TxtPath = null;
-
-        try {
-            if(!sourcePath.endsWith(File.separator)){
-                sourcePath = sourcePath + File.separator;
-            }
-            if(!targetPath.endsWith(File.separator)){
-                targetPath = targetPath + File.separator;
-            }
-            String targetDataPath = targetPath + "data";
-            FileUtil.mkdir(new File(targetDataPath));
-            String targetImagePath = targetPath + "images";
-            FileUtil.mkdir(new File(targetImagePath));
-
-            obj2TxtPath = sourcePath.substring(0, sourcePath.length() - 1) + "_obj2txt";
-            FileUtil.mkdir(obj2TxtPath);
-            //调用算法生成modeldata.txt
-            String extrasPath = obj2TxtPath + File.separator + "extras";
-            FileUtil.mkdir(extrasPath);
-            FileUtil.copyContent(new File(sourcePath + "data" + File.separator + "mesh"), new File(extrasPath), true);
-
-            //写data.json
-            writeDataJson(obj2TxtPath);
-
-            //调用算法建模
-            build3dModel(obj2TxtPath);
-
-            //校验算法是否正常结束
-            String uploadJsonPath = obj2TxtPath + File.separator + "results" +File.separator+"upload.json";
-            boolean success = checkComputeCompleted(uploadJsonPath, 5, 300);
-            if(!success){
-                throw new RuntimeException("计算失败,obj2TxtPath:" + obj2TxtPath);
-            }
-
-            //压缩成dam
-            String damPath = targetImagePath + File.separator + "tieta.dam";
-            CreateObjUtil.convertTxtToDam( obj2TxtPath + File.separator + "results" +File.separator+"modeldata.txt", damPath);
-
-            //复制贴图
-            String uploadData = FileUtil.readUtf8String(uploadJsonPath);
-            JSONObject uploadJson = null;
-            JSONArray array = null;
-            if(uploadData!=null) {
-                uploadJson = JSONObject.parseObject(uploadData);
-                array = uploadJson.getJSONArray("upload");
-            }
-            JSONObject fileJson = null;
-            String fileName = "";
-            for(int i = 0, len = array.size(); i < len; i++) {
-                fileJson = array.getJSONObject(i);
-                fileName = fileJson.getString("file");
-                //文件不存在抛出异常
-                if (!new File(obj2TxtPath + File.separator + "results" + File.separator + fileName).exists()) {
-                    throw new Exception(obj2TxtPath + File.separator + "results" + File.separator + fileName + "文件不存在");
-                }
-
-                //tex文件夹
-                if (fileJson.getIntValue("clazz") == 15) {
-                    FileUtil.copy(obj2TxtPath + File.separator + "results" + File.separator + fileName,
-                            targetImagePath + File.separator + "tieta_texture/" + fileName.replace("tex/", ""),true);
-                }
-            }
-
-            //复制文件
-            FileUtil.copyContent(new File(sourcePath + "data"), new File(targetDataPath), true);
-            if(FileUtil.exist(targetDataPath + "/floorplan.json")){
-                String floorplanJson = FileUtil.readUtf8String(targetDataPath + "/floorplan.json");
-                JSONObject jsonObject = JSON.parseObject(floorplanJson);
-                Integer currentId = jsonObject.getInteger("currentId");
-                if(Objects.nonNull(currentId) && currentId == 0){
-                    FileUtil.del(targetDataPath + "/floorplan.json");
-                }
-            }
-
-
-            String finalSourcePath = sourcePath;
-            if(FileUtil.exist(finalSourcePath + "images/4k/")){
-                FileUtil.listFileNames(sourcePath + "images/4k/").stream().forEach(v->{
-                    FileUtil.copy(finalSourcePath + "images/4k/" + v, targetImagePath + "/pan/high/" + v.replaceAll("-", ""), true);
-                });
-            }
-
-            if(FileUtil.exist(finalSourcePath + "images/512/")){
-                FileUtil.listFileNames(finalSourcePath + "images/512/").stream().forEach(v->{
-                    FileUtil.copy(finalSourcePath + "images/512/" + v, targetImagePath + "/pan/low/" + v.replaceAll("-", ""), true);
-                });
-            }
-
-            if(FileUtil.exist(finalSourcePath + "images/8k/")) {
-                FileUtil.listFileNames(finalSourcePath + "images/8k/").stream().forEach(v -> {
-                    FileUtil.copy(finalSourcePath + "images/8k/" + v, targetImagePath + "/pan/8k/" + v.replaceAll("-", ""), true);
-                });
-
-            }
-            FileUtil.copy(sourcePath + "images/vision.txt", targetImagePath + "/vision.txt", true);
-
-            //生成vison.modeldata
-            CreateObjUtil.convertTxtToVisionmodeldata(targetImagePath + "/vision.txt", targetImagePath + "/vision.modeldata");
-        }finally {
-//            FileUtil.del(obj2TxtPath);
-        }
-    }
-
-    public static void writeDataJson(String path){
-        JSONObject dataJson = new JSONObject();
-        dataJson.put("obj2txt", true);
-        dataJson.put("split_type", "SPLIT_V6");
-        dataJson.put("data_describe", "double spherical");
-        dataJson.put("skybox_type", "SKYBOX_V5");
-        FileUtil.writeUtf8String(dataJson.toString(), path + File.separator + "data.json");
-    }
-
-    public static void build3dModel(String folderName) throws Exception {
-        System.out.println("开始建模");
-        String command = "sudo bash /home/ubuntu/bin/Launcher.sh " + folderName;
-        CmdUtils.callLineSh(command);
-        System.out.println("计算完毕:" + command);
-    }
-
-    public static boolean checkComputeCompleted(String uploadJsonPath, int maxCheckTimes, long waitTime) throws Exception {
-        int checkTimes = 1;
-        boolean exist = false;
-
-        do {
-            if ((new File(uploadJsonPath)).exists()) {
-                exist = true;
-                break;
-            }
-
-            Thread.sleep(waitTime);
-            ++checkTimes;
-        } while(checkTimes <= maxCheckTimes);
-
-        return exist;
-    }
-
-}
+//package com.fdkankan.project.tieta.utils;
+//
+//import cn.hutool.core.io.FileUtil;
+//import com.alibaba.fastjson.JSON;
+//import com.alibaba.fastjson.JSONArray;
+//import com.alibaba.fastjson.JSONObject;
+//
+//import java.io.File;
+//import java.util.Objects;
+//
+//public class ConvertUtil {
+//
+//    private static String result_dir = "results";
+//
+//    private static String floorplanJson_Name = "floorplan.json";
+//
+//    /**
+//     *
+//     * @param sourcePath 原始资源目录
+//     * @param targetPath 目标资源目录
+//     * @return boolean true-转换成功  false-转换失败
+//     */
+//    public static void convert(String sourcePath, String targetPath) throws Exception {
+//
+//        String obj2TxtPath = null;
+//
+//        try {
+//            if(!sourcePath.endsWith(File.separator)){
+//                sourcePath = sourcePath + File.separator;
+//            }
+//            if(!targetPath.endsWith(File.separator)){
+//                targetPath = targetPath + File.separator;
+//            }
+//            String targetDataPath = targetPath + "data";
+//            FileUtil.mkdir(new File(targetDataPath));
+//            String targetImagePath = targetPath + "images";
+//            FileUtil.mkdir(new File(targetImagePath));
+//
+//            obj2TxtPath = sourcePath.substring(0, sourcePath.length() - 1) + "_obj2txt";
+//            FileUtil.mkdir(obj2TxtPath);
+//            //调用算法生成modeldata.txt
+//            String extrasPath = obj2TxtPath + File.separator + "extras";
+//            FileUtil.mkdir(extrasPath);
+//            FileUtil.copyContent(new File(sourcePath + "data" + File.separator + "mesh"), new File(extrasPath), true);
+//
+//            //写data.json
+//            writeDataJson(obj2TxtPath);
+//
+//            //调用算法建模
+//            build3dModel(obj2TxtPath);
+//
+//            //校验算法是否正常结束
+//            String uploadJsonPath = obj2TxtPath + File.separator + result_dir +File.separator+"upload.json";
+//            boolean success = checkComputeCompleted(uploadJsonPath, 5, 300);
+//            if(!success){
+//                throw new RuntimeException("计算失败,obj2TxtPath:" + obj2TxtPath);
+//            }
+//
+//            //压缩成dam
+//            String damPath = targetImagePath + File.separator + "tieta.dam";
+//            CreateObjUtil.convertTxtToDam( obj2TxtPath + File.separator + result_dir +File.separator+"modeldata.txt", damPath);
+//
+//            //复制贴图
+//            String uploadData = FileUtil.readUtf8String(uploadJsonPath);
+//            JSONObject uploadJson = null;
+//            JSONArray array = null;
+//            if(uploadData!=null) {
+//                uploadJson = JSONObject.parseObject(uploadData);
+//                array = uploadJson.getJSONArray("upload");
+//            }
+//            JSONObject fileJson = null;
+//            String fileName = "";
+//            for(int i = 0, len = array.size(); i < len; i++) {
+//                fileJson = array.getJSONObject(i);
+//                fileName = fileJson.getString("file");
+//                //文件不存在抛出异常
+//                if (!new File(obj2TxtPath + File.separator + result_dir + File.separator + fileName).exists()) {
+//                    throw new Exception(obj2TxtPath + File.separator + result_dir + File.separator + fileName + "文件不存在");
+//                }
+//
+//                //tex文件夹
+//                if (fileJson.getIntValue("clazz") == 15) {
+//                    FileUtil.copy(obj2TxtPath + File.separator + result_dir + File.separator + fileName,
+//                            targetImagePath + File.separator + "tieta_texture/" + fileName.replace("tex/", ""),true);
+//                }
+//            }
+//
+//            //复制文件
+//            FileUtil.copyContent(new File(sourcePath + "data"), new File(targetDataPath), true);
+//            if(FileUtil.exist(targetDataPath + "/" + floorplanJson_Name)){
+//                String floorplanJson = FileUtil.readUtf8String(targetDataPath + "/" + floorplanJson_Name);
+//                JSONObject jsonObject = JSON.parseObject(floorplanJson);
+//                Integer currentId = jsonObject.getInteger("currentId");
+//                if(Objects.nonNull(currentId) && currentId == 0){
+//                    FileUtil.del(targetDataPath + "/" + floorplanJson_Name);
+//                }
+//            }
+//
+//
+//            String finalSourcePath = sourcePath;
+//            if(FileUtil.exist(finalSourcePath + "images/4k/")){
+//                FileUtil.listFileNames(sourcePath + "images/4k/").stream().forEach(v->{
+//                    FileUtil.copy(finalSourcePath + "images/4k/" + v, targetImagePath + "/pan/high/" + v.replaceAll("-", ""), true);
+//                });
+//            }
+//
+//            if(FileUtil.exist(finalSourcePath + "images/512/")){
+//                FileUtil.listFileNames(finalSourcePath + "images/512/").stream().forEach(v->{
+//                    FileUtil.copy(finalSourcePath + "images/512/" + v, targetImagePath + "/pan/low/" + v.replaceAll("-", ""), true);
+//                });
+//            }
+//
+//            if(FileUtil.exist(finalSourcePath + "images/8k/")) {
+//                FileUtil.listFileNames(finalSourcePath + "images/8k/").stream().forEach(v -> {
+//                    FileUtil.copy(finalSourcePath + "images/8k/" + v, targetImagePath + "/pan/8k/" + v.replaceAll("-", ""), true);
+//                });
+//
+//            }
+//            FileUtil.copy(sourcePath + "images/vision.txt", targetImagePath + "/vision.txt", true);
+//
+//            //生成vison.modeldata
+//            CreateObjUtil.convertTxtToVisionmodeldata(targetImagePath + "/vision.txt", targetImagePath + "/vision.modeldata");
+//        }finally {
+////            FileUtil.del(obj2TxtPath);
+//        }
+//    }
+//
+//    public static void writeDataJson(String path){
+//        JSONObject dataJson = new JSONObject();
+//        dataJson.put("obj2txt", true);
+//        dataJson.put("split_type", "SPLIT_V6");
+//        dataJson.put("data_describe", "double spherical");
+//        dataJson.put("skybox_type", "SKYBOX_V5");
+//        FileUtil.writeUtf8String(dataJson.toString(), path + File.separator + "data.json");
+//    }
+//
+//    public static void build3dModel(String folderName) throws Exception {
+//        System.out.println("开始建模");
+//        String command = "sudo bash /home/ubuntu/bin/Launcher.sh " + folderName;
+//        CmdUtils.callLineSh(command);
+//        System.out.println("计算完毕:" + command);
+//    }
+//
+//    public static boolean checkComputeCompleted(String uploadJsonPath, int maxCheckTimes, long waitTime) throws Exception {
+//        int checkTimes = 1;
+//        boolean exist = false;
+//
+//        do {
+//            if ((new File(uploadJsonPath)).exists()) {
+//                exist = true;
+//                break;
+//            }
+//
+//            Thread.sleep(waitTime);
+//            ++checkTimes;
+//        } while(checkTimes <= maxCheckTimes);
+//
+//        return exist;
+//    }
+//
+//}

+ 171 - 171
src/main/java/com/fdkankan/project/tieta/utils/CreateObjUtil.java

@@ -1,171 +1,171 @@
-package com.fdkankan.project.tieta.utils;
-
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.fdkankan.project.tieta.proto.BigSceneProto;
-import com.fdkankan.project.tieta.proto.Visionmodeldata;
-import com.fdkankan.project.tieta.proto.format.JsonFormat;
-import com.google.protobuf.TextFormat;
-import lombok.extern.slf4j.Slf4j;
-
-import java.io.*;
-import java.util.HashMap;
-import java.util.Map;
-
-@Slf4j
-public class CreateObjUtil {
-
-
-	public static void main(String[] args) throws Exception {
-//		Scanner scanner = new Scanner(System.in);
-//		System.out.println("输入需要调用的转换方法:");
-//		System.out.println("convertTxtToVisionmodeldata:输入1");
-//		System.out.println("convertTxtToDam:输入2");
-//		int type = scanner.nextInt();
-//		scanner.reset();
-//		System.out.println("输入源文件路径:");
-//		String srcPath = scanner.next();
-//		System.out.println("输入目标文件路径:");
-//		String targetPath = scanner.next();
-
-		String type = args[0];//类型(1-vision.txt转为vision.modeldata, 2-modeldata.txt转为tieta.dam)
-		String srcPath = args[1];//源文件目录(需要提前源文件放到此目录中再调用方法)
-		String targetPath = args[2];//目标文件路径(目录,转换后文件会放到此目录中,文件名固定为vision.modeldata或tieta.dam)
-
-		if(type.equals("1")){
-			String srcFileName = "vision.txt";
-			String targetFileName = "vision.modeldata";
-			CreateObjUtil.convertTxtToVisionmodeldata(srcPath.concat(File.separator).concat(srcFileName),targetPath.concat(File.separator).concat(targetFileName));
-		}
-		if(type.equals("2")){
-			String srcFileName = "modeldata.txt";
-			String targetFileName = "tieta.dam";
-			CreateObjUtil.convertTxtToDam(srcPath.concat(File.separator).concat(srcFileName),targetPath.concat(File.separator).concat(targetFileName));
-		}
-
-//		scanner.close();
-	}
-
-	/**
-	 * modeldata.txt 转 dam
-	 * @param srcpath 源文件全路径,如D:\test\modeldata.txt
-	 * @param despath 目标文件全路径,如D:\test\tieta.dam
-	 * @throws Exception
-	 */
-	public static void convertTxtToDam(String srcpath,String despath)throws Exception{
-		InputStream inputStream = null;
-		InputStreamReader reader = null;
-		ByteArrayInputStream stream = null;
-		BufferedOutputStream bos = null;
-		BufferedInputStream bis = null;
-		try{
-			BigSceneProto.binary_mesh.Builder builder = BigSceneProto.binary_mesh.newBuilder();
-			inputStream = new FileInputStream(srcpath);
-			reader = new InputStreamReader(inputStream, "ASCII");
-			TextFormat.merge(reader, builder);
-			byte[] buf = builder.build().toByteArray();
-
-			//把序列化后的数据写入本地磁盘
-			stream = new ByteArrayInputStream(buf);
-			bos = new BufferedOutputStream(new FileOutputStream(despath));//设置输出路径
-			bis = new BufferedInputStream(stream);
-			int b = -1;
-			while ((b = bis.read()) != -1) {
-				bos.write(b);
-			}
-		}catch (Exception e){
-			log.error("txt转dam出错,srcpath:{}, despath:{}",srcpath, despath);
-			throw e;
-		}finally {
-			if(inputStream != null){
-				inputStream.close();
-			}
-			if(reader != null){
-				reader.close();
-			}
-			if(stream != null){
-				stream.close();
-			}
-			if(bos != null){
-				bos.close();
-			}
-			if(bis != null){
-				bis.close();
-			}
-		}
-
-	}
-
-	/**
-	 * vision.txt 转 vision.modeldata
-	 * @param srcpath 源文件全路径,如D:\test\vision.txt
-	 * @param despath 目标文件全路径,如D:\test\vision.modeldata
-	 * @throws Exception
-	 */
-	public static void convertTxtToVisionmodeldata(String srcpath,String despath)throws Exception {
-
-		Visionmodeldata.NavigationInfo.Builder builder = Visionmodeldata.NavigationInfo.newBuilder();
-		String jsonFormat = transferVisionUuidToIndex(srcpath);
-		JsonFormat.merge(jsonFormat, builder);
-		byte[] buf= builder.build().toByteArray();
-
-		//把序列化后的数据写入本地磁盘
-		try(ByteArrayInputStream stream = new ByteArrayInputStream(buf);
-			BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(despath));//设置输出路径
-			BufferedInputStream bis = new BufferedInputStream(stream)){
-			int b = -1;
-			while ((b = bis.read()) != -1) {
-				bos.write(b);
-			}
-		}
-	}
-
-	public static String readTxtFileToJson(String filePath){
-		try {
-			String encoding="UTF-8";
-			File file=new File(filePath);
-			if(file.isFile() && file.exists()){
-				InputStreamReader read = new InputStreamReader(
-						new FileInputStream(file),encoding);
-				BufferedReader bufferedReader = new BufferedReader(read);
-				String lineTxt = null;
-				String result="";
-				while((lineTxt = bufferedReader.readLine()) != null){
-					result+=lineTxt;
-					//log.info(lineTxt);
-				}
-				read.close();
-				return result;
-			}else{
-				return null;
-			}
-		} catch (Exception e) {
-			e.printStackTrace();
-			return null;
-		}
-
-	}
-
-	public static String transferVisionUuidToIndex(String srcPath){
-		String visionJsonStr = readTxtFileToJson(srcPath);
-		JSONObject visionJson = JSON.parseObject(visionJsonStr);
-		JSONArray sweepLocationArr = visionJson.getJSONArray("sweepLocations");
-		Map<String, Integer> uuidIndexMap = new HashMap<>();
-		for (int i = 0; i < sweepLocationArr.size(); i++) {
-			JSONObject sweepLocationObj = (JSONObject)sweepLocationArr.get(i);
-			uuidIndexMap.put(sweepLocationObj.getString("uuid"), i);
-		}
-		for (Object o : sweepLocationArr) {
-			JSONObject sweepLocationObj = (JSONObject)o;
-			JSONArray visibles =  sweepLocationObj.getJSONArray("visibles");
-			int[] visiblesArr = new int[visibles.size()];
-			for(int i = 0; i < visibles.size(); i++){
-				visiblesArr[i] = uuidIndexMap.get(visibles.get(i));
-			}
-			sweepLocationObj.put("visibles", visiblesArr);
-		}
-		return JSON.toJSONString(visionJson);
-	}
-
-}
+//package com.fdkankan.project.tieta.utils;
+//
+//import com.alibaba.fastjson.JSON;
+//import com.alibaba.fastjson.JSONArray;
+//import com.alibaba.fastjson.JSONObject;
+//import com.fdkankan.project.tieta.proto.BigSceneProto;
+//import com.fdkankan.project.tieta.proto.Visionmodeldata;
+//import com.fdkankan.project.tieta.proto.format.JsonFormat;
+//import com.google.protobuf.TextFormat;
+//import lombok.extern.slf4j.Slf4j;
+//
+//import java.io.*;
+//import java.util.HashMap;
+//import java.util.Map;
+//
+//@Slf4j
+//public class CreateObjUtil {
+//
+//
+//	public static void main(String[] args) throws Exception {
+////		Scanner scanner = new Scanner(System.in);
+////		System.out.println("输入需要调用的转换方法:");
+////		System.out.println("convertTxtToVisionmodeldata:输入1");
+////		System.out.println("convertTxtToDam:输入2");
+////		int type = scanner.nextInt();
+////		scanner.reset();
+////		System.out.println("输入源文件路径:");
+////		String srcPath = scanner.next();
+////		System.out.println("输入目标文件路径:");
+////		String targetPath = scanner.next();
+//
+//		String type = args[0];//类型(1-vision.txt转为vision.modeldata, 2-modeldata.txt转为tieta.dam)
+//		String srcPath = args[1];//源文件目录(需要提前源文件放到此目录中再调用方法)
+//		String targetPath = args[2];//目标文件路径(目录,转换后文件会放到此目录中,文件名固定为vision.modeldata或tieta.dam)
+//
+//		if(type.equals("1")){
+//			String srcFileName = "vision.txt";
+//			String targetFileName = "vision.modeldata";
+//			CreateObjUtil.convertTxtToVisionmodeldata(srcPath.concat(File.separator).concat(srcFileName),targetPath.concat(File.separator).concat(targetFileName));
+//		}
+//		if(type.equals("2")){
+//			String srcFileName = "modeldata.txt";
+//			String targetFileName = "tieta.dam";
+//			CreateObjUtil.convertTxtToDam(srcPath.concat(File.separator).concat(srcFileName),targetPath.concat(File.separator).concat(targetFileName));
+//		}
+//
+////		scanner.close();
+//	}
+//
+//	/**
+//	 * modeldata.txt 转 dam
+//	 * @param srcpath 源文件全路径,如D:\test\modeldata.txt
+//	 * @param despath 目标文件全路径,如D:\test\tieta.dam
+//	 * @throws Exception
+//	 */
+//	public static void convertTxtToDam(String srcpath,String despath)throws Exception{
+//		InputStream inputStream = null;
+//		InputStreamReader reader = null;
+//		ByteArrayInputStream stream = null;
+//		BufferedOutputStream bos = null;
+//		BufferedInputStream bis = null;
+//		try{
+//			BigSceneProto.binary_mesh.Builder builder = BigSceneProto.binary_mesh.newBuilder();
+//			inputStream = new FileInputStream(srcpath);
+//			reader = new InputStreamReader(inputStream, "ASCII");
+//			TextFormat.merge(reader, builder);
+//			byte[] buf = builder.build().toByteArray();
+//
+//			//把序列化后的数据写入本地磁盘
+//			stream = new ByteArrayInputStream(buf);
+//			bos = new BufferedOutputStream(new FileOutputStream(despath));//设置输出路径
+//			bis = new BufferedInputStream(stream);
+//			int b = -1;
+//			while ((b = bis.read()) != -1) {
+//				bos.write(b);
+//			}
+//		}catch (Exception e){
+//			log.error("txt转dam出错,srcpath:{}, despath:{}",srcpath, despath);
+//			throw e;
+//		}finally {
+//			if(inputStream != null){
+//				inputStream.close();
+//			}
+//			if(reader != null){
+//				reader.close();
+//			}
+//			if(stream != null){
+//				stream.close();
+//			}
+//			if(bos != null){
+//				bos.close();
+//			}
+//			if(bis != null){
+//				bis.close();
+//			}
+//		}
+//
+//	}
+//
+//	/**
+//	 * vision.txt 转 vision.modeldata
+//	 * @param srcpath 源文件全路径,如D:\test\vision.txt
+//	 * @param despath 目标文件全路径,如D:\test\vision.modeldata
+//	 * @throws Exception
+//	 */
+//	public static void convertTxtToVisionmodeldata(String srcpath,String despath)throws Exception {
+//
+//		Visionmodeldata.NavigationInfo.Builder builder = Visionmodeldata.NavigationInfo.newBuilder();
+//		String jsonFormat = transferVisionUuidToIndex(srcpath);
+//		JsonFormat.merge(jsonFormat, builder);
+//		byte[] buf= builder.build().toByteArray();
+//
+//		//把序列化后的数据写入本地磁盘
+//		try(ByteArrayInputStream stream = new ByteArrayInputStream(buf);
+//			BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(despath));//设置输出路径
+//			BufferedInputStream bis = new BufferedInputStream(stream)){
+//			int b = -1;
+//			while ((b = bis.read()) != -1) {
+//				bos.write(b);
+//			}
+//		}
+//	}
+//
+//	public static String readTxtFileToJson(String filePath){
+//		try {
+//			String encoding="UTF-8";
+//			File file=new File(filePath);
+//			if(file.isFile() && file.exists()){
+//				InputStreamReader read = new InputStreamReader(
+//						new FileInputStream(file),encoding);
+//				BufferedReader bufferedReader = new BufferedReader(read);
+//				String lineTxt = null;
+//				String result="";
+//				while((lineTxt = bufferedReader.readLine()) != null){
+//					result+=lineTxt;
+//					//log.info(lineTxt);
+//				}
+//				read.close();
+//				return result;
+//			}else{
+//				return null;
+//			}
+//		} catch (Exception e) {
+//			e.printStackTrace();
+//			return null;
+//		}
+//
+//	}
+//
+//	public static String transferVisionUuidToIndex(String srcPath){
+//		String visionJsonStr = readTxtFileToJson(srcPath);
+//		JSONObject visionJson = JSON.parseObject(visionJsonStr);
+//		JSONArray sweepLocationArr = visionJson.getJSONArray("sweepLocations");
+//		Map<String, Integer> uuidIndexMap = new HashMap<>();
+//		for (int i = 0; i < sweepLocationArr.size(); i++) {
+//			JSONObject sweepLocationObj = (JSONObject)sweepLocationArr.get(i);
+//			uuidIndexMap.put(sweepLocationObj.getString("uuid"), i);
+//		}
+//		for (Object o : sweepLocationArr) {
+//			JSONObject sweepLocationObj = (JSONObject)o;
+//			JSONArray visibles =  sweepLocationObj.getJSONArray("visibles");
+//			int[] visiblesArr = new int[visibles.size()];
+//			for(int i = 0; i < visibles.size(); i++){
+//				visiblesArr[i] = uuidIndexMap.get(visibles.get(i));
+//			}
+//			sweepLocationObj.put("visibles", visiblesArr);
+//		}
+//		return JSON.toJSONString(visionJson);
+//	}
+//
+//}

+ 122 - 157
src/main/java/com/fdkankan/project/tieta/utils/CutImgUtil.java

@@ -1,157 +1,122 @@
-package com.fdkankan.project.tieta.utils;
-
-import cn.hutool.core.collection.CollUtil;
-import cn.hutool.core.collection.ListUtil;
-import cn.hutool.core.io.FileUtil;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-
-import java.io.File;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class CutImgUtil {
-
-    public final static String callPath = "/mnt/cutImg/call/";//切图计算目录
-
-    public final static String scene_path = "/mnt/cutImg/scenes/%s/wwwroot/%s";//下载文件路径
-    public final static String numsTxt = "/mnt/cutImg/nums.txt";//场景码文件路径
-
-    public final static String panPath = "/mnt/cutImg/pan/";//虚化全景图路径
-
-    public static void main(String[] args) {
-
-        List<String> nums = FileUtil.readUtf8Lines(numsTxt);
-        for (String num : nums) {
-            System.out.println("切图开始,num:"+num);
-            try {
-                String path = callPath + num;
-                String target = path + "_images";
-                String targetImagesPath = target + "/extras/images/";
-                FileUtil.mkdir(targetImagesPath);
-
-                //复制全景图
-                FileUtil.copyContent(new File(panPath + num), new File(targetImagesPath), true);
-
-                //复制 vision.txt
-                FileUtil.copy(String.format(scene_path, num, "scene_view_data/" + num + "/images/vision.txt") , target + "/extras/vision.txt", true);
-
-                //生成data.json
-                createDataJson(target);
-
-                //调用算法
-                uploadPanoramaHandler(num, target);
-
-                //压缩
-                zip("/mnt/cutImg/scenes/" + num, "/mnt/cutImg/zip/" + num + ".zip");
-
-
-            }catch (Exception e){
-                FileUtil.appendUtf8Lines(ListUtil.toList(num), callPath + "fail.txt");
-            }
-
-            System.out.println("切图结束,num:"+num);
-        }
-    }
-
-    public static void zip(String source, String zipPath) throws Exception {
-        String cmd = "cd " + source + " && zip -r " + zipPath + " *";
-        CmdUtils.callLineSh(cmd);
-    }
-
-    public static void createDataJson(String target){
-        JSONObject floorplanJson = new JSONObject();
-        floorplanJson.put("has_source_images", true);
-        floorplanJson.put("has_vision_txt", true);
-
-        JSONObject dataJson = new JSONObject();
-        dataJson.put("extras", floorplanJson);
-        dataJson.put("split_type", "SPLIT_V8");
-        String skyboxType = "SKYBOX_V14";
-        dataJson.put("skybox_type", skyboxType);
-        FileUtil.writeUtf8String(dataJson.toJSONString(), target + File.separator+"data.json");
-    }
-
-    public static void build3dModel(String folderName, String isModel) throws Exception {
-        System.out.println("开始算法切图");
-        String command = "sudo bash /home/ubuntu/bin/Launcher.sh " + folderName;
-        CmdUtils.callLine(command);
-        System.out.println("算法切图完毕");
-
-    }
-
-    public static void uploadPanoramaHandler(String num, String target) throws Exception {
-
-        String imgViewPath = String.format("scene_view_data/%s/images/", num);
-
-        build3dModel(target , "1");
-
-        String uploadJsonPath= target + File.separator + "results" +File.separator+"upload.json";
-        Thread.sleep(2000);
-        String uploadData = FileUtil.readUtf8String(uploadJsonPath);
-        JSONObject uploadJson = null;
-        JSONArray array = null;
-        if(uploadData!=null) {
-            uploadJson = JSONObject.parseObject(uploadData);
-            array = uploadJson.getJSONArray("upload");
-        }
-        if(array == null){
-            throw new RuntimeException("计算失败,num:" + num);
-        }
-        Map<String, String> map = new HashMap<>();
-        JSONObject fileJson = null;
-        String fileName = "";
-        for(int i = 0, len = array.size(); i < len; i++) {
-            fileJson = array.getJSONObject(i);
-            fileName = fileJson.getString("file");
-            //文件不存在抛出异常
-            if (!new File(target + File.separator + "results" + File.separator + fileName)
-                    .exists()) {
-                throw new Exception(
-                        target + File.separator + "results" + File.separator + fileName + "文件不存在");
-            }
-
-            //high文件夹
-            if (fileJson.getIntValue("clazz") == 3) {
-                map.put(target + File.separator + "results" + File.separator + fileName,
-                        imgViewPath + "pan/high/" + fileName.replace("high/", ""));
-                continue;
-            }
-            //low文件夹
-            if (fileJson.getIntValue("clazz") == 4) {
-                map.put(target + File.separator + "results" + File.separator + fileName,
-                        imgViewPath + "pan/low/" + fileName.replace("low/", ""));
-                continue;
-            }
-
-            //tiles文件夹,亚马逊没有裁剪图片api,不需要上传4k图
-            if (fileJson.getIntValue("clazz") == 5) {
-                map.put(target + File.separator + "results" + File.separator + fileName,
-                        imgViewPath + fileName);
-                continue;
-            }
-
-            //tiles文件夹,亚马逊瓦片图
-            if (fileJson.getIntValue("clazz") == 7) {
-                map.put(target + File.separator + "results" + File.separator + fileName,
-                        imgViewPath + fileName);
-                continue;
-            }
-        }
-
-        if(CollUtil.isNotEmpty(map)) {
-
-            //先删除旧的tiles目录
-            FileUtil.del(String.format(scene_path, num, imgViewPath + "tiles"));
-
-            map.keySet().stream().forEach(v->{
-                FileUtil.copy(v, String.format(scene_path, num, map.get(v)), true);
-            });
-        }
-
-
-
-    }
-
-}
+//package com.fdkankan.project.tieta.utils;
+//
+//import cn.hutool.core.collection.CollUtil;
+//import cn.hutool.core.collection.ListUtil;
+//import cn.hutool.core.io.FileUtil;
+//import com.alibaba.fastjson.JSONArray;
+//import com.alibaba.fastjson.JSONObject;
+//
+//import java.io.File;
+//import java.util.HashMap;
+//import java.util.List;
+//import java.util.Map;
+//
+//public class CutImgUtil {
+//
+//    public final static String callPath = "/mnt/cutImg/call/";//切图计算目录
+//
+//    public final static String scene_path = "/mnt/cutImg/scenes/%s/wwwroot/%s";//下载文件路径
+//    public final static String numsTxt = "/mnt/cutImg/nums.txt";//场景码文件路径
+//
+//    public final static String panPath = "/mnt/cutImg/pan/";//虚化全景图路径
+//
+//    public static void zip(String source, String zipPath) throws Exception {
+//        String cmd = "cd " + source + " && zip -r " + zipPath + " *";
+//        CmdUtils.callLineSh(cmd);
+//    }
+//
+//    public static void createDataJson(String target){
+//        JSONObject floorplanJson = new JSONObject();
+//        floorplanJson.put("has_source_images", true);
+//        floorplanJson.put("has_vision_txt", true);
+//
+//        JSONObject dataJson = new JSONObject();
+//        dataJson.put("extras", floorplanJson);
+//        dataJson.put("split_type", "SPLIT_V8");
+//        String skyboxType = "SKYBOX_V14";
+//        dataJson.put("skybox_type", skyboxType);
+//        FileUtil.writeUtf8String(dataJson.toJSONString(), target + File.separator+"data.json");
+//    }
+//
+//    public static void build3dModel(String folderName, String isModel) throws Exception {
+//        System.out.println("开始算法切图");
+//        String command = "sudo bash /home/ubuntu/bin/Launcher.sh " + folderName;
+//        CmdUtils.callLine(command);
+//        System.out.println("算法切图完毕");
+//
+//    }
+//
+//    public static void uploadPanoramaHandler(String num, String target) throws Exception {
+//
+//        String imgViewPath = String.format("scene_view_data/%s/images/", num);
+//
+//        build3dModel(target , "1");
+//
+//        String uploadJsonPath= target + File.separator + "results" +File.separator+"upload.json";
+//        Thread.sleep(2000);
+//        String uploadData = FileUtil.readUtf8String(uploadJsonPath);
+//        JSONObject uploadJson = null;
+//        JSONArray array = null;
+//        if(uploadData!=null) {
+//            uploadJson = JSONObject.parseObject(uploadData);
+//            array = uploadJson.getJSONArray("upload");
+//        }
+//        if(array == null){
+//            throw new RuntimeException("计算失败,num:" + num);
+//        }
+//        Map<String, String> map = new HashMap<>();
+//        JSONObject fileJson = null;
+//        String fileName = "";
+//        for(int i = 0, len = array.size(); i < len; i++) {
+//            fileJson = array.getJSONObject(i);
+//            fileName = fileJson.getString("file");
+//            //文件不存在抛出异常
+//            if (!new File(target + File.separator + "results" + File.separator + fileName)
+//                    .exists()) {
+//                throw new Exception(
+//                        target + File.separator + "results" + File.separator + fileName + "文件不存在");
+//            }
+//
+//            //high文件夹
+//            if (fileJson.getIntValue("clazz") == 3) {
+//                map.put(target + File.separator + "results" + File.separator + fileName,
+//                        imgViewPath + "pan/high/" + fileName.replace("high/", ""));
+//                continue;
+//            }
+//            //low文件夹
+//            if (fileJson.getIntValue("clazz") == 4) {
+//                map.put(target + File.separator + "results" + File.separator + fileName,
+//                        imgViewPath + "pan/low/" + fileName.replace("low/", ""));
+//                continue;
+//            }
+//
+//            //tiles文件夹,亚马逊没有裁剪图片api,不需要上传4k图
+//            if (fileJson.getIntValue("clazz") == 5) {
+//                map.put(target + File.separator + "results" + File.separator + fileName,
+//                        imgViewPath + fileName);
+//                continue;
+//            }
+//
+//            //tiles文件夹,亚马逊瓦片图
+//            if (fileJson.getIntValue("clazz") == 7) {
+//                map.put(target + File.separator + "results" + File.separator + fileName,
+//                        imgViewPath + fileName);
+//                continue;
+//            }
+//        }
+//
+//        if(CollUtil.isNotEmpty(map)) {
+//
+//            //先删除旧的tiles目录
+//            FileUtil.del(String.format(scene_path, num, imgViewPath + "tiles"));
+//
+//            map.keySet().stream().forEach(v->{
+//                FileUtil.copy(v, String.format(scene_path, num, map.get(v)), true);
+//            });
+//        }
+//
+//
+//
+//    }
+//
+//}

+ 20 - 12
src/main/java/com/fdkankan/project/tieta/utils/FdfsUtil.java

@@ -18,6 +18,14 @@ import java.util.Map;
 @Slf4j
 public class FdfsUtil {
 
+    private static String timestamp_key = "timestamp";
+
+    private static String nonce_key = "nonce";
+
+    private static String sysCode_key = "sysCode";
+
+    private static String success_code = "000000";
+
     @Value("${fdfs.address}")
     private String address;
 
@@ -32,16 +40,16 @@ public class FdfsUtil {
 
     public String getSignature(String nonce, String timestamp){
         Map<String, String> headers = new HashMap<>();
-        headers.put("timestamp", timestamp);
-        headers.put("nonce", nonce);
-        headers.put("sysCode", sysCode);
+        headers.put(timestamp_key, timestamp);
+        headers.put(nonce_key, nonce);
+        headers.put(sysCode_key, sysCode);
         HttpRequest httpRequest = HttpRequest.post(address.concat(api_getSignature)).addHeaders(headers).timeout(5000);
         HttpResponse res = httpRequest.execute();
         String resBody = res.body();
         res.close();
         TietaResBean<String> tietaResBean = JSON.parseObject(resBody, TietaResBean.class);
         String code = tietaResBean.getCode();
-        if(!"000000".equals(code)){
+        if(!success_code.equals(code)){
             throw new RuntimeException("获取签名失败, code:" + code);
         }
         return tietaResBean.getData();
@@ -50,9 +58,9 @@ public class FdfsUtil {
     public Map<String, String> uploadFile(String nonce, String timestamp, String signature, String filePath){
 
         Map<String, String> headers = new HashMap<>();
-        headers.put("timestamp", timestamp);
-        headers.put("nonce", nonce);
-        headers.put("sysCode", sysCode);
+        headers.put(timestamp_key, timestamp);
+        headers.put(nonce_key, nonce);
+        headers.put(sysCode_key, sysCode);
         headers.put("signature", signature);
 
         Map<String, Object> test = new HashMap<>();
@@ -66,7 +74,7 @@ public class FdfsUtil {
         res.close();
         TietaResBean<Map<String, String>> tietaResBean = JSON.parseObject(resBody, TietaResBean.class);
         String code = tietaResBean.getCode();
-        if(!"000000".equals(code)){
+        if(!success_code.equals(code)){
             throw new RuntimeException("上传文件失败, code:" + code);
         }
         return tietaResBean.getData();
@@ -81,9 +89,9 @@ public class FdfsUtil {
 
     public static void main(String[] args) {
         Map<String, String> headers = new HashMap<>();
-        headers.put("timestamp", "1719389524320");
-        headers.put("nonce", "123123");
-        headers.put("sysCode", "CT00017");
+        headers.put(timestamp_key, "1719389524320");
+        headers.put(nonce_key, "123123");
+        headers.put(sysCode_key, "CT00017");
         headers.put("signature", "3044022062501c9896a919d81d00216379a84c7d89b2d7315a22f89aee2ce7c1185f656c02206d4694fb685247a289e1c0d11e7492311ef66354c64cd2234fa593e02a635074");
 
         Map<String, Object> test = new HashMap<>();
@@ -96,7 +104,7 @@ public class FdfsUtil {
         res.close();
         TietaResBean<Map<String, String>> tietaResBean = JSON.parseObject(resBody, TietaResBean.class);
         String code = tietaResBean.getCode();
-        if(!"000000".equals(code)){
+        if(!success_code.equals(code)){
             throw new RuntimeException("上传文件失败, code:" + code);
         }
         Map<String, String> data = tietaResBean.getData();

+ 5 - 7
src/main/java/com/fdkankan/rabbitmq/util/RabbitMqProducer.java

@@ -28,8 +28,7 @@ public class RabbitMqProducer {
 
     private Logger log = LoggerFactory.getLogger(this.getClass().getName());
 
-//    @Autowired
-//    ModelingQueueConfig modelingQueueConfig;
+    private static String log_format = "开始发送Mq消息,messageId:{},消息队列:{},消息内容:{}";
 
     @Autowired
     private RabbitTemplate rabbitTemplate;
@@ -41,7 +40,7 @@ public class RabbitMqProducer {
      */
     public void sendByWorkQueue(String queue, Object content){
         String messageId = UUID.randomUUID().toString();
-        log.info("开始发送Mq消息,messageId:{},消息队列:{},消息内容:{}",messageId, queue, new JSONObject(content).toString());
+        log.info(log_format, messageId, queue, new JSONObject(content).toString());
         rabbitTemplate.convertAndSend(queue, content, message -> {
             message.getMessageProperties().setMessageId(messageId);
             return message;
@@ -55,7 +54,7 @@ public class RabbitMqProducer {
      */
     public void sendByWorkQueue(String exchange,String queue, Object content){
         String messageId = UUID.randomUUID().toString();
-        log.info("开始发送Mq消息,messageId:{},消息队列:{},消息内容:{}",messageId, queue, new JSONObject(content).toString());
+        log.info(log_format, messageId, queue, new JSONObject(content).toString());
         rabbitTemplate.convertAndSend(exchange,queue, content, message -> {
             message.getMessageProperties().setMessageId(messageId);
             return message;
@@ -69,7 +68,7 @@ public class RabbitMqProducer {
      */
     public void sendByWorkQueue(String queue, Object content, Integer priority){
         String messageId = UUID.randomUUID().toString();
-        log.info("开始发送Mq消息,messageId:{},消息队列:{},消息内容:{}",messageId, queue, new JSONObject(content).toString());
+        log.info(log_format, messageId, queue, new JSONObject(content).toString());
         rabbitTemplate.convertAndSend(queue, content, message -> {
             message.getMessageProperties().setMessageId(messageId);
             message.getMessageProperties().setPriority(priority);
@@ -93,13 +92,12 @@ public class RabbitMqProducer {
 
     /**
      * 工作队列模式发送消息到多个队列
-     * @param queue 队列名
      * @param content 载荷
      */
     public void sendByWorkToQueues(Object content, String... queues){
         for (String queue : queues) {
             String messageId = UUID.randomUUID().toString();
-            log.info("开始发送Mq消息,messageId:{},消息队列:{},消息内容:{}",messageId, queue, new JSONObject(content).toString());
+            log.info(log_format, messageId, queue, new JSONObject(content).toString());
             rabbitTemplate.convertAndSend(queue, content, message -> {
                 message.getMessageProperties().setMessageId(messageId);
                 return message;

+ 7 - 5
src/main/java/com/fdkankan/redis/util/RedisClient.java

@@ -29,6 +29,8 @@ public class RedisClient {
 
     public final static String URL_REDISSON_UNLOCK = "/redis/redisson/unlock";
 
+    public final static String field_status = "status";
+
     @Value("${redis.host}")
     private String host;
 
@@ -48,7 +50,7 @@ public class RedisClient {
          params.put("key", this.genKey(key));
          params.put("value", value);
          JSONObject jsonObject = httpClient.postJson(url, params);
-         if(Objects.isNull(jsonObject) || !"0".equals(jsonObject.getString("status"))){
+         if(Objects.isNull(jsonObject) || !"0".equals(jsonObject.getString(field_status))){
              throw new RuntimeException("redis add string error");
          }
      }
@@ -58,7 +60,7 @@ public class RedisClient {
         Map<String, Object> params = new HashMap<>();
         params.put("key", this.genKey(key));
         JSONObject jsonObject = httpClient.postJson(url, params);
-        if(Objects.isNull(jsonObject) || !"0".equals(jsonObject.getString("status"))){
+        if(Objects.isNull(jsonObject) || !"0".equals(jsonObject.getString(field_status))){
             throw new RuntimeException("redis get string error");
         }
         return jsonObject.getString("data");
@@ -69,7 +71,7 @@ public class RedisClient {
         Map<String, Object> params = new HashMap<>();
         params.put("key", this.genKey(key));
         JSONObject jsonObject = httpClient.postJson(url, params);
-        if(Objects.isNull(jsonObject) || !"0".equals(jsonObject.getString("status"))){
+        if(Objects.isNull(jsonObject) || !"0".equals(jsonObject.getString(field_status))){
             throw new RuntimeException("redis del string error");
         }
         return jsonObject.getString("data");
@@ -84,7 +86,7 @@ public class RedisClient {
         params.put("leaseTime", expirTime);
         JSONObject jsonObject = httpClient.postJson(url, params);
         log.info("获取分布式锁,key:{}, result:{}", this.genKey(key), jsonObject);
-        if(Objects.nonNull(jsonObject) && "0".equals(jsonObject.getString("status"))){
+        if(Objects.nonNull(jsonObject) && "0".equals(jsonObject.getString(field_status))){
             result.put("lock", true);
             result.put("uniqueFlag", jsonObject.getString("data"));
         }
@@ -98,7 +100,7 @@ public class RedisClient {
         params.put("uniqueFlag", uniqueFlag);
         JSONObject jsonObject = httpClient.postJson(url, params);
         log.info("释放分布式锁,key:{},uniqueFlag:{}, result:{}", this.genKey(key), uniqueFlag, jsonObject);
-        if(Objects.nonNull(jsonObject) && "0".equals(jsonObject.getString("status"))){
+        if(Objects.nonNull(jsonObject) && "0".equals(jsonObject.getString(field_status))){
             return true;
         }
         return false;