|
@@ -15,6 +15,7 @@ import com.fdkk.sxz.constant.CodeConstant;
|
|
|
import com.fdkk.sxz.entity.SceneLightEntity;
|
|
|
import com.fdkk.sxz.entity.SceneStyleEntity;
|
|
|
import com.fdkk.sxz.other.mq.TopicRabbitConfig;
|
|
|
+import com.fdkk.sxz.util.*;
|
|
|
import com.fdkk.sxz.vo.response.ResponseRenovationBuildDetail;
|
|
|
import com.fdkk.sxz.vo.response.ResponseRenovationPartsDetail;
|
|
|
import com.fdkk.sxz.webApi.service.*;
|
|
@@ -33,9 +34,9 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
-import com.fdkk.sxz.util.*;
|
|
|
|
|
|
import java.io.File;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.net.URLDecoder;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
@@ -123,6 +124,15 @@ public class ImportDataController extends BaseController {
|
|
|
|
|
|
String vrNum = styleNum;
|
|
|
try {
|
|
|
+ String roamingPointUrl = "";
|
|
|
+ Boolean existRoamingPoint = uploadToOssUtil.existFileToOSS("data/data" + sceneNum + "/roamingPoint.json", "4dkankan");
|
|
|
+ if (existRoamingPoint) {
|
|
|
+ roamingPointUrl = "https://4dkk.4dage.com/data/data" + sceneNum + "/roamingPoint.json";
|
|
|
+
|
|
|
+ } else {
|
|
|
+ ImportDataController.log.info("roamingPoint,不存在");
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
if (StringUtils.isEmpty(styleNum)) {
|
|
|
Integer num = sceneStyleService.findLastNum(sceneNum);
|
|
@@ -138,6 +148,7 @@ public class ImportDataController extends BaseController {
|
|
|
sceneStyleEntity.setSceneNum(sceneNum);
|
|
|
sceneStyleEntity.setStyleName(styleName);
|
|
|
sceneStyleEntity.setStyleNum(vrNum);
|
|
|
+ sceneStyleEntity.setRoamingPointUrl(roamingPointUrl);
|
|
|
//新生成的换装风格,未渲染
|
|
|
sceneStyleEntity.setStatus(2);
|
|
|
sceneStyleService.save(sceneStyleEntity);
|
|
@@ -149,6 +160,7 @@ public class ImportDataController extends BaseController {
|
|
|
if (list != null && list.size() > 0) {
|
|
|
SceneStyleEntity sceneStyleEntity = list.get(0);
|
|
|
sceneStyleEntity.setStyleName(styleName);
|
|
|
+ sceneStyleEntity.setRoamingPointUrl(roamingPointUrl);
|
|
|
sceneStyleService.updateById(sceneStyleEntity);
|
|
|
}
|
|
|
}
|
|
@@ -171,15 +183,16 @@ public class ImportDataController extends BaseController {
|
|
|
"vision.modeldata", filePath);
|
|
|
|
|
|
if (!new File(filePath + "vision.modeldata").exists()) {
|
|
|
- log.info("vision.modeldata文件不存在");
|
|
|
+ ImportDataController.log.info("vision.modeldata文件不存在");
|
|
|
return Result.failure(CodeConstant.FAILURE_CODE_4001, CodeConstant.FAILURE_MSG_4001);
|
|
|
}
|
|
|
- log.info("下载vision.modeldata完成,开始转换vision.txt");
|
|
|
+ ImportDataController.log.info("下载vision.modeldata完成,开始转换vision.txt");
|
|
|
CreateObjUtil.convertVisionmodeldataToTxt(filePath + "vision.modeldata", filePath + "vision.txt");
|
|
|
|
|
|
+
|
|
|
//计算translationAverage,和puckAverage并重新赋予值
|
|
|
Map<String, Double> averageMap = ConvertCadKjl.getAverageValue(filePath + "vision.txt");
|
|
|
- setAverageValue(filePath + "vision.txt", averageMap.get("translationAverage"), averageMap.get("puckAverage"));
|
|
|
+ ImportDataController.setAverageValue(filePath + "vision.txt", averageMap.get("translationAverage"), averageMap.get("puckAverage"));
|
|
|
|
|
|
FileUtils.writeFile(filePath + "proLight.json", proLight);
|
|
|
|
|
@@ -224,7 +237,7 @@ public class ImportDataController extends BaseController {
|
|
|
FileUtils.writeFile(filePath + "house.json", kjlJson.toJSONString());
|
|
|
uploadToOssUtil.upload(filePath + "house.json", "data/data" + vrNum + "/house.json");
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
@@ -267,7 +280,7 @@ public class ImportDataController extends BaseController {
|
|
|
filePath = filePath + File.separator;
|
|
|
}
|
|
|
|
|
|
- log.info("保存的类型是:" + buildType + ";位置在:" + filePath);
|
|
|
+ ImportDataController.log.info("保存的类型是:" + buildType + ";位置在:" + filePath);
|
|
|
FileUtils.writeFile(filePath + "proLight.json", proLight);
|
|
|
|
|
|
//数据上传oss,让计算服务器下载资源
|
|
@@ -356,14 +369,14 @@ public class ImportDataController extends BaseController {
|
|
|
if (list != null && list.size() > 0) {
|
|
|
sceneStyleEntity = list.get(0);
|
|
|
if ("light".equals(buildType)) {
|
|
|
- log.info("灯光预览:" + styleNum);
|
|
|
+ ImportDataController.log.info("灯光预览:" + styleNum);
|
|
|
if (sceneStyleEntity.getLightStatus().intValue() == 0) {
|
|
|
return Result.failure(CodeConstant.FAILURE_CODE_4004, CodeConstant.FAILURE_MSG_4004);
|
|
|
}
|
|
|
sceneStyleEntity.setLightStatus(0);
|
|
|
}
|
|
|
if ("pano".equals(buildType)) {
|
|
|
- log.info("全景预览:" + styleNum);
|
|
|
+ ImportDataController.log.info("全景预览:" + styleNum);
|
|
|
if (sceneStyleEntity.getLightStatus().intValue() == 0) {
|
|
|
return Result.failure(CodeConstant.FAILURE_CODE_4016, CodeConstant.FAILURE_MSG_4016);
|
|
|
}
|
|
@@ -408,7 +421,7 @@ public class ImportDataController extends BaseController {
|
|
|
rabbitTemplate.convertAndSend(TopicRabbitConfig.TOPICE, TopicRabbitConfig.LIGHT,
|
|
|
styleNum + ":;" + sceneNum + ":;" + type + ":;" + dateType + ":;" +
|
|
|
ratio + ":;" + sceneLightEntity.getId().longValue() + ":;" +
|
|
|
- quality + ":;" + buildType+":;"+1);
|
|
|
+ quality + ":;" + buildType + ":;" + 1);
|
|
|
}
|
|
|
|
|
|
FileUtils.deleteDirectory(buildPath + "Output/" + styleNum);
|
|
@@ -464,7 +477,7 @@ public class ImportDataController extends BaseController {
|
|
|
|
|
|
try {
|
|
|
if (StringUtils.isEmpty(num)) {
|
|
|
- resultJson.put("msg","参数不能为空");
|
|
|
+ resultJson.put("msg", "参数不能为空");
|
|
|
return resultJson;
|
|
|
}
|
|
|
|
|
@@ -489,15 +502,32 @@ public class ImportDataController extends BaseController {
|
|
|
"vision.modeldata", basePath);
|
|
|
|
|
|
if (!new File(basePath + "/vision.modeldata").exists()) {
|
|
|
- log.info("vision.modeldata文件不存在");
|
|
|
+ ImportDataController.log.info("vision.modeldata文件不存在");
|
|
|
} else {
|
|
|
- log.info("下载vision.modeldata完成,开始转换vision.txt");
|
|
|
+ ImportDataController.log.info("下载vision.modeldata完成,开始转换vision.txt");
|
|
|
CreateObjUtil.convertVisionmodeldataToTxt(basePath + "/vision.modeldata", basePath + "/vision.txt");
|
|
|
|
|
|
JSONObject visionJson = JSON.parseObject(FileUtils.readFile(basePath + "/vision.txt"));
|
|
|
JSONArray sweepArray = visionJson.getJSONArray("sweepLocations");
|
|
|
if (sweepArray != null && sweepArray.size() > 0) {
|
|
|
entryJson.put("noSetting", sweepArray.getJSONObject(0));
|
|
|
+ //处理漫游点供前端使用
|
|
|
+ JSONArray roamingPoint = new JSONArray();
|
|
|
+ for (int i = 0; i < sweepArray.size(); i++) {
|
|
|
+ JSONObject objectJson = sweepArray.getJSONObject(i);
|
|
|
+ JSONObject newJson = new JSONObject();
|
|
|
+ newJson.put("uuid", objectJson.getString("uuid"));
|
|
|
+ JSONObject puck = objectJson.getJSONObject("puck");
|
|
|
+ puck.put("y", puck.getDoubleValue("y") * -1);
|
|
|
+ puck.remove("z");
|
|
|
+ newJson.put("puck", puck);
|
|
|
+ roamingPoint.add(newJson);
|
|
|
+ }
|
|
|
+ FileUtils.writeFile(basePath + File.separator + "roamingPoint.json", roamingPoint.toJSONString());
|
|
|
+
|
|
|
+ //数据上传oss,让计算服务器下载资源
|
|
|
+ uploadToOssUtil.upload(basePath + File.separator + "roamingPoint.json",
|
|
|
+ "data/data" + num + "/roamingPoint.json");
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
@@ -635,7 +665,7 @@ public class ImportDataController extends BaseController {
|
|
|
return resultJson;
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
- resultJson.put("msg","转换失败");
|
|
|
+ resultJson.put("msg", "转换失败");
|
|
|
return resultJson;
|
|
|
}
|
|
|
}
|
|
@@ -689,9 +719,9 @@ public class ImportDataController extends BaseController {
|
|
|
"vision.modeldata", path);
|
|
|
|
|
|
if (!new File(path + "/vision.modeldata").exists()) {
|
|
|
- log.info("vision.modeldata文件不存在");
|
|
|
+ ImportDataController.log.info("vision.modeldata文件不存在");
|
|
|
} else {
|
|
|
- log.info("下载vision.modeldata完成,开始转换vision.txt");
|
|
|
+ ImportDataController.log.info("下载vision.modeldata完成,开始转换vision.txt");
|
|
|
CreateObjUtil.convertVisionmodeldataToTxt(path + "/vision.modeldata", path + "/vision.txt");
|
|
|
}
|
|
|
|
|
@@ -1201,7 +1231,7 @@ public class ImportDataController extends BaseController {
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("obj", data);
|
|
|
String result = OkHttpUtils.httpPostJson(buildUrl + "getLightInfo", jsonObject.toJSONString());
|
|
|
- log.info("getLightInfo返回结果:" + result);
|
|
|
+ ImportDataController.log.info("getLightInfo返回结果:" + result);
|
|
|
JSONObject resultJson = JSON.parseObject(result);
|
|
|
if (resultJson.containsKey("state") && "done".equals(resultJson.getString("state"))) {
|
|
|
return Result.success(resultJson.getString("msg"));
|
|
@@ -1230,7 +1260,7 @@ public class ImportDataController extends BaseController {
|
|
|
}
|
|
|
|
|
|
String filePath = buildPath + "data/data" + styleNum + File.separator + fileName;
|
|
|
- log.info("保存文件路径-filePath{}:" + filePath);
|
|
|
+ ImportDataController.log.info("保存文件路径-filePath{}:" + filePath);
|
|
|
|
|
|
FileUtils.writeFile(filePath, jsonData);
|
|
|
|
|
@@ -1239,6 +1269,25 @@ public class ImportDataController extends BaseController {
|
|
|
return Result.success((Object) ("data/data" + styleNum + File.separator + fileName));
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation("测试保存Blob数据")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "data", value = "String", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "file", value = "文件流", dataType = "MultipartFile")})
|
|
|
+ @RequestMapping(value = "/testBlob", method = RequestMethod.POST)
|
|
|
+ @NoAuthentication
|
|
|
+ public Result testBlob(String fileString, @RequestParam("file") MultipartFile file) throws Exception {
|
|
|
+
|
|
|
+ Float size = Float.parseFloat(String.valueOf(file.getSize())) / 1024;
|
|
|
+ BigDecimal b = new BigDecimal(size);
|
|
|
+ // 2表示2位 ROUND_HALF_UP表明四舍五入,
|
|
|
+ size = b.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue();
|
|
|
+ ImportDataController.log.info("size{}m", size);
|
|
|
+
|
|
|
+ ImportDataController.log.info("length{}", fileString.length());
|
|
|
+ return Result.success("");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
public static void main(String[] args) {
|
|
|
try {
|
|
|
Map<String, Double> map = ConvertCadKjl.getAverageValue("G:\\javaProject\\changeing\\vision.txt");
|
|
@@ -1246,7 +1295,7 @@ public class ImportDataController extends BaseController {
|
|
|
System.out.println(map.get("translationAverage"));
|
|
|
System.out.println(map.get("puckAverage"));
|
|
|
|
|
|
- setAverageValue("G:\\javaProject\\changeing\\vision.txt", map.get("translationAverage"), map.get("puckAverage"));
|
|
|
+ ImportDataController.setAverageValue("G:\\javaProject\\changeing\\vision.txt", map.get("translationAverage"), map.get("puckAverage"));
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|