|
@@ -6,20 +6,22 @@ import cn.hutool.core.exceptions.ExceptionUtil;
|
|
import cn.hutool.core.io.FileUtil;
|
|
import cn.hutool.core.io.FileUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.ZipUtil;
|
|
import cn.hutool.core.util.ZipUtil;
|
|
|
|
+import cn.hutool.crypto.SecureUtil;
|
|
|
|
+import cn.hutool.crypto.symmetric.AES;
|
|
import cn.hutool.http.HttpStatus;
|
|
import cn.hutool.http.HttpStatus;
|
|
import cn.hutool.http.HttpUtil;
|
|
import cn.hutool.http.HttpUtil;
|
|
|
|
+import cn.hutool.jwt.signers.AlgorithmUtil;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.fdkankan.common.constant.CommonSuccessStatus;
|
|
import com.fdkankan.common.constant.CommonSuccessStatus;
|
|
import com.fdkankan.common.constant.ErrorCode;
|
|
import com.fdkankan.common.constant.ErrorCode;
|
|
-import com.fdkankan.common.constant.ServerCode;
|
|
|
|
|
|
+import com.fdkankan.common.constant.SceneStatus;
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
|
|
+import com.fdkankan.common.util.AesUtil;
|
|
import com.fdkankan.common.util.DateExtUtil;
|
|
import com.fdkankan.common.util.DateExtUtil;
|
|
-import com.fdkankan.extend.TowerSceneBean;
|
|
|
|
-import com.fdkankan.extend.callback.ErrorCallback;
|
|
|
|
-import com.fdkankan.extend.callback.SuccessCallback;
|
|
|
|
|
|
+import com.fdkankan.extend.bean.TowerSceneBean;
|
|
import com.fdkankan.extend.entity.Camera;
|
|
import com.fdkankan.extend.entity.Camera;
|
|
import com.fdkankan.extend.entity.CameraDetail;
|
|
import com.fdkankan.extend.entity.CameraDetail;
|
|
import com.fdkankan.extend.entity.ScenePlus;
|
|
import com.fdkankan.extend.entity.ScenePlus;
|
|
@@ -29,24 +31,25 @@ import com.fdkankan.extend.util.RsaCryptTools;
|
|
import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
import com.fdkankan.model.constants.UploadFilePath;
|
|
import com.fdkankan.model.constants.UploadFilePath;
|
|
import com.fdkankan.model.utils.SceneUtil;
|
|
import com.fdkankan.model.utils.SceneUtil;
|
|
|
|
+import com.fdkankan.rabbitmq.util.RabbitMqProducer;
|
|
import com.fdkankan.redis.constant.RedisKey;
|
|
import com.fdkankan.redis.constant.RedisKey;
|
|
import com.fdkankan.redis.util.RedisUtil;
|
|
import com.fdkankan.redis.util.RedisUtil;
|
|
import com.fdkankan.web.response.ResultData;
|
|
import com.fdkankan.web.response.ResultData;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
-import netscape.javascript.JSObject;
|
|
|
|
|
|
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
-import org.springframework.cloud.context.config.annotation.RefreshScope;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
+import javax.crypto.KeyGenerator;
|
|
|
|
+import javax.crypto.SecretKey;
|
|
import java.io.File;
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
-@RefreshScope
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
@Service
|
|
@Service
|
|
public class TowerServiceImpl implements ITowerService {
|
|
public class TowerServiceImpl implements ITowerService {
|
|
@@ -61,6 +64,14 @@ public class TowerServiceImpl implements ITowerService {
|
|
|
|
|
|
private static String pushLogPath = parentPath.concat("log.txt");
|
|
private static String pushLogPath = parentPath.concat("log.txt");
|
|
|
|
|
|
|
|
+ public static final String TIE_TA_SCENE_PUSH_CALLBACK_QUEUE = "tie_ta_scene_push_callback_queue";
|
|
|
|
+
|
|
|
|
+ /** 场景推送回调交换机*/
|
|
|
|
+ public static final String TIE_TA_SCENE_PUSH_CALLBACK_EXCHANGE = "tie_ta_scene_push_callback_exchange";
|
|
|
|
+
|
|
|
|
+ /** 场景推送回调交换机路由*/
|
|
|
|
+ public static final String TIE_TA_SCENE_PUSH_CALLBACK_ROUTING = "tie_ta_scene_push_callback_routing";
|
|
|
|
+
|
|
@Value("${tower.manufact}")
|
|
@Value("${tower.manufact}")
|
|
private String manufact;
|
|
private String manufact;
|
|
|
|
|
|
@@ -70,9 +81,6 @@ public class TowerServiceImpl implements ITowerService {
|
|
@Value("${tower.url}")
|
|
@Value("${tower.url}")
|
|
private String url;
|
|
private String url;
|
|
|
|
|
|
- @Value("fyun.bucket")
|
|
|
|
- private String bucket;
|
|
|
|
-
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private FYunFileServiceInterface fYunFileService;
|
|
private FYunFileServiceInterface fYunFileService;
|
|
@Autowired
|
|
@Autowired
|
|
@@ -92,6 +100,12 @@ public class TowerServiceImpl implements ITowerService {
|
|
@Resource
|
|
@Resource
|
|
private HttpClient httpClient;
|
|
private HttpClient httpClient;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private RabbitMqProducer rabbitMqProducer;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private RabbitTemplate rabbitTemplate;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public String packSceneDataHandler(String num, String title, String logId) throws Exception {
|
|
public String packSceneDataHandler(String num, String title, String logId) throws Exception {
|
|
|
|
|
|
@@ -179,7 +193,7 @@ public class TowerServiceImpl implements ITowerService {
|
|
log.info("结束下载,开始推送:{}", num);
|
|
log.info("结束下载,开始推送:{}", num);
|
|
|
|
|
|
try {
|
|
try {
|
|
- this.dataPush(num, title, towerSceneBean.getSceneId(), towerSceneBean.getRoomId(), zipPath, logId);
|
|
|
|
|
|
+ this.dataPush(num, towerSceneBean.getSceneId(), towerSceneBean.getRoomId(), zipPath);
|
|
}finally {
|
|
}finally {
|
|
FileUtil.del(scenePath);
|
|
FileUtil.del(scenePath);
|
|
}
|
|
}
|
|
@@ -293,7 +307,9 @@ public class TowerServiceImpl implements ITowerService {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void dataPush(String num, String title, String sceneId, String roomId, String zipPath, String logId) throws Exception {
|
|
|
|
|
|
+ public JSONObject dataPush(String num, String sceneId, String roomId, String zipPath) throws Exception {
|
|
|
|
+
|
|
|
|
+ JSONObject jsonObject = null;
|
|
|
|
|
|
log.info("开始组装参数");
|
|
log.info("开始组装参数");
|
|
|
|
|
|
@@ -314,63 +330,19 @@ public class TowerServiceImpl implements ITowerService {
|
|
log.info("encrypt:{}", encrypt);
|
|
log.info("encrypt:{}", encrypt);
|
|
log.info("开始推送");
|
|
log.info("开始推送");
|
|
try {
|
|
try {
|
|
- String post = HttpUtil.post(url, params);
|
|
|
|
- JSONObject jsonObject = JSON.parseObject(post);
|
|
|
|
- this.dataPushLog(num, title, jsonObject.getString("resultCode"), jsonObject.getString("resultMsg"), logId);
|
|
|
|
|
|
+ String post = HttpUtil.post(url, params, 60*60*1000);
|
|
|
|
+ jsonObject = JSON.parseObject(post);
|
|
|
|
+ if(!jsonObject.containsKey("resultCode")){
|
|
|
|
+ throw new RuntimeException("铁塔接口出参错误");
|
|
|
|
+ }
|
|
|
|
+ return jsonObject;
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
- log.error("推送失败", e);
|
|
|
|
- this.dataPushLog(num, title, String.valueOf(HttpStatus.HTTP_BAD_GATEWAY), "请求失败", logId);
|
|
|
|
|
|
+ log.error("调用铁塔接口出错,场景:{}", num, e);
|
|
|
|
+ jsonObject = new JSONObject();
|
|
|
|
+ jsonObject.put("resultCode", -2);
|
|
|
|
+ jsonObject.put("resultMsg", "调用铁塔接口出错");
|
|
|
|
+ return jsonObject;
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public static void main(String[] args) {
|
|
|
|
-// Map<String, Object> params = new HashMap<>();
|
|
|
|
-// params.put("stationCode", "410192010000001484");
|
|
|
|
-// params.put("roomEntityID", "000102050000000003085104");
|
|
|
|
-// params.put("file", FileUtil.file("D:\\test\\410192010000001484_000102050000000003085104.zip"));
|
|
|
|
-// params.put("manufact", "3");
|
|
|
|
-// params.put("upUserAcct", "111");
|
|
|
|
-// params.put("encrypt", "oNFZonGRrum3hldhU9AcMwP0JsXoxZocaTSTgj1h1Ag9pJzro9us0udinPr058y9KcwSPtkO58TKVE4csnasTZT00jghJQqsk0ATiNzX8QZh+F1iH33j6I3NHZu3vzjAV4lVHSo23WcEMo4s9G5dxymagYl8FKd7ua0/CYNysrs=");
|
|
|
|
-// String post = HttpUtil.post("http://120.52.136.13:2808/fileManager/uploadRsaFileZipView", params);
|
|
|
|
-// JSONObject jsonObject = JSON.parseObject(post);
|
|
|
|
-// System.out.println(jsonObject.toJSONString());
|
|
|
|
-
|
|
|
|
-// String sceneStr = fYunFileService.getFileContent(ossScenePoolFilePath);
|
|
|
|
-// String sceneStr = FileUtil.readUtf8String("D:\\四维时代\\中国铁塔\\郑州-天津.js");
|
|
|
|
-// List<TowerSceneBean> towerSceneBeans = JSON.parseArray(sceneStr, TowerSceneBean.class);
|
|
|
|
-// System.out.println(JSON.toJSONString(towerSceneBeans));
|
|
|
|
-
|
|
|
|
-// String visionStr = FileUtil.readUtf8String("C:\\Users\\dsx\\Desktop\\vision.txt");
|
|
|
|
-// JSONObject visionObj = JSON.parseObject(visionStr);
|
|
|
|
-// JSONArray array = visionObj.getJSONArray("sweepLocations");
|
|
|
|
-// Map<Integer, String> uuidMap = new HashMap<>();
|
|
|
|
-// for(int i = 0; i < array.size(); i++){
|
|
|
|
-// JSONObject o = (JSONObject)array.get(i);
|
|
|
|
-// uuidMap.put(i, o.getString("uuid"));
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// for(int i = 0; i < array.size(); i++){
|
|
|
|
-// JSONObject o = (JSONObject)array.get(i);
|
|
|
|
-// JSONArray visibles = o.getJSONArray("visibles");
|
|
|
|
-// int size = visibles.size();
|
|
|
|
-// String[] visibleArr = new String[size];
|
|
|
|
-// for(int j = 0; j < size; j++){
|
|
|
|
-// System.out.println(visibles.get(j));
|
|
|
|
-// int index = (Integer)visibles.get(j);
|
|
|
|
-// String uuid = uuidMap.get(index);
|
|
|
|
-// visibleArr[j] = uuid;
|
|
|
|
-// }
|
|
|
|
-// o.put("visibles", visibleArr);
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// FileUtil.writeUtf8String(JSON.toJSONString(visionObj), "C:\\Users\\dsx\\Desktop\\vision2.txt");
|
|
|
|
-
|
|
|
|
- String test = "123123/sdfsdf.jpg";
|
|
|
|
- System.out.println(test.substring(test.lastIndexOf("/")));
|
|
|
|
-
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
private void dataPushLog(String num, String title, String resultCode, String resultMsg, String logId){
|
|
private void dataPushLog(String num, String title, String resultCode, String resultMsg, String logId){
|
|
@@ -383,6 +355,10 @@ public class TowerServiceImpl implements ITowerService {
|
|
FileUtil.appendUtf8String(content, parentPath.concat("download").concat("-").concat(logId).concat(".log"));
|
|
FileUtil.appendUtf8String(content, parentPath.concat("download").concat("-").concat(logId).concat(".log"));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public static void main(String[] args) {
|
|
|
|
+// System.out.println(AlgorithmUtil.getId("AES"));
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public ResultData sceneBatchMove(MultipartFile file, String origSnCode, String snCode) throws IOException {
|
|
public ResultData sceneBatchMove(MultipartFile file, String origSnCode, String snCode) throws IOException {
|
|
if(file.isEmpty()){
|
|
if(file.isEmpty()){
|
|
@@ -440,4 +416,98 @@ public class TowerServiceImpl implements ITowerService {
|
|
}
|
|
}
|
|
return ResultData.ok(result);
|
|
return ResultData.ok(result);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void pushScene(TowerSceneBean towerSceneBean) throws Exception {
|
|
|
|
+
|
|
|
|
+ JSONObject pushResult = null;
|
|
|
|
+ String num = towerSceneBean.getNum();
|
|
|
|
+ Map<String, Object> noticeContent = new HashMap<>();
|
|
|
|
+ noticeContent.put("num", num);
|
|
|
|
+ String scenePath = parentPath.concat(num).concat("/");
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+
|
|
|
|
+ //场景本地数据父目录
|
|
|
|
+ String sceneSourcePath = scenePath.concat(towerSceneBean.getSceneId()).concat("_").concat(towerSceneBean.getRoomId());
|
|
|
|
+ String zipPath = sceneSourcePath.concat(".zip");
|
|
|
|
+
|
|
|
|
+ log.info("开始下载:{}", num);
|
|
|
|
+
|
|
|
|
+ ScenePlus scenePlus = scenePlusService.getByNum(num);
|
|
|
|
+ if(Objects.isNull(scenePlus)){
|
|
|
|
+ throw new RuntimeException("查询不到此场景");
|
|
|
|
+ }
|
|
|
|
+ if(scenePlus.getSceneStatus() != SceneStatus.SUCCESS.code() && scenePlus.getSceneStatus() != SceneStatus.NO_DISPLAY.code()){
|
|
|
|
+ throw new RuntimeException("场景计算中");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //data数据下载
|
|
|
|
+ String dataPath = sceneSourcePath + "/data/";
|
|
|
|
+ String ossDataPath = String.format(UploadFilePath.DATA_VIEW_PATH, num);
|
|
|
|
+ //下载floorplan.json
|
|
|
|
+ fYunFileService.downloadFile(ossDataPath.concat("floorplan.json"), dataPath.concat("floorplan.json"));
|
|
|
|
+
|
|
|
|
+// //下载scene.json
|
|
|
|
+ String sceneJsonPath = dataPath.concat("scene.json");
|
|
|
|
+ String sceneJson = fYunFileService.getFileContent(ossDataPath.concat("scene.json"));
|
|
|
|
+ JSONObject sceneJsonObj = JSON.parseObject(sceneJson);
|
|
|
|
+ sceneJsonObj.put("sceneKind", "pano");
|
|
|
|
+ FileUtil.writeUtf8String(sceneJsonObj.toJSONString(), sceneJsonPath);
|
|
|
|
+
|
|
|
|
+ //下载mesh
|
|
|
|
+ FileUtil.mkdir(dataPath.concat("mesh/"));
|
|
|
|
+ List<String> meshList = fYunFileService.listRemoteFiles(ossDataPath.concat("mesh"));
|
|
|
|
+ meshList.parallelStream().forEach(key -> fYunFileService.downloadFile(key, dataPath.concat("mesh/")));
|
|
|
|
+
|
|
|
|
+ //images数据下载
|
|
|
|
+ String imagesPath = sceneSourcePath + "/images/";
|
|
|
|
+ String ossImagesPath = String.format(UploadFilePath.IMG_VIEW_PATH, num);
|
|
|
|
+ //下载high图
|
|
|
|
+ List<String> highList = fYunFileService.listRemoteFiles(ossImagesPath.concat("pan/high/"));
|
|
|
|
+ FileUtil.mkdir(imagesPath.concat("4k/"));
|
|
|
|
+ highList.parallelStream().forEach(key -> fYunFileService.downloadFile(key, imagesPath.concat("4k/")));
|
|
|
|
+ //下载low图
|
|
|
|
+ FileUtil.mkdir(imagesPath.concat("512/"));
|
|
|
|
+ List<String> lowList = fYunFileService.listRemoteFiles(ossImagesPath.concat("pan/low/"));
|
|
|
|
+ lowList.parallelStream().forEach(key -> fYunFileService.downloadFile(key, imagesPath.concat("512/")));
|
|
|
|
+ //下载vision.txt
|
|
|
|
+ fYunFileService.downloadFile(ossImagesPath.concat("vision.txt"), imagesPath.concat("vision.txt"));
|
|
|
|
+
|
|
|
|
+ //下载caches/images
|
|
|
|
+ List<String> panoramaImageList = SceneUtil.getPanoramaImageList(imagesPath.concat("vision.txt"));
|
|
|
|
+ log.info(JSON.toJSONString(panoramaImageList));
|
|
|
|
+ List<String> imageList = fYunFileService.listRemoteFiles(String.format(UploadFilePath.scene_result_data_path, num).concat("caches/images/"));
|
|
|
|
+ if(CollUtil.isNotEmpty(imageList)){
|
|
|
|
+ imageList.stream().forEach(key->{
|
|
|
|
+ if(panoramaImageList.contains(key.substring(key.lastIndexOf("/") + 1))){
|
|
|
|
+ if(!FileUtil.exist(imagesPath.concat("8K"))){
|
|
|
|
+ FileUtil.mkdir(imagesPath.concat("8K"));
|
|
|
|
+ }
|
|
|
|
+ fYunFileService.downloadFile(key, imagesPath.concat("8K"));
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.convertVisable(imagesPath.concat("vision.txt"));
|
|
|
|
+
|
|
|
|
+ //打包
|
|
|
|
+ ZipUtil.zip(sceneSourcePath, zipPath, true);
|
|
|
|
+
|
|
|
|
+ log.info("打包成功,开始推送:{}", num);
|
|
|
|
+
|
|
|
|
+ pushResult = this.dataPush(num, towerSceneBean.getSceneId(), towerSceneBean.getRoomId(), zipPath);
|
|
|
|
+
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ log.error("场景推送出错,未知异常", e);
|
|
|
|
+ pushResult = new JSONObject();
|
|
|
|
+ pushResult.put("resultCode", -3);
|
|
|
|
+ pushResult.put("resultMsg", e.getMessage());
|
|
|
|
+ } finally {
|
|
|
|
+ noticeContent.put("result", pushResult);
|
|
|
|
+ rabbitMqProducer.sendByWorkQueue(TIE_TA_SCENE_PUSH_CALLBACK_QUEUE, noticeContent);
|
|
|
|
+// rabbitTemplate.convertAndSend(TIE_TA_SCENE_PUSH_CALLBACK_EXCHANGE , TIE_TA_SCENE_PUSH_CALLBACK_ROUTING , noticeContent);
|
|
|
|
+ FileUtil.del(scenePath);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|