|
@@ -44,8 +44,7 @@ import java.util.*;
|
|
|
* <p>
|
|
* <p>
|
|
|
* TODO
|
|
* TODO
|
|
|
* </p>
|
|
* </p>
|
|
|
- *
|
|
|
|
|
- * @author dengsixing
|
|
|
|
|
|
|
+ * 场景转换监听器
|
|
|
* @since 2022/4/19
|
|
* @since 2022/4/19
|
|
|
**/
|
|
**/
|
|
|
@Slf4j
|
|
@Slf4j
|
|
@@ -70,58 +69,6 @@ public class ConvertListener{
|
|
|
@Resource
|
|
@Resource
|
|
|
private RedisClient redisClient;
|
|
private RedisClient redisClient;
|
|
|
|
|
|
|
|
-// @RabbitListener(
|
|
|
|
|
-// queuesToDeclare = @Queue(Constant.QUEUE_SCENE_CONVERT),
|
|
|
|
|
-// concurrency = "1"
|
|
|
|
|
-// )
|
|
|
|
|
-// public void buildObjScenePreHandler(Channel channel, Message message) throws Exception {
|
|
|
|
|
-// String roomId = null;
|
|
|
|
|
-// try {
|
|
|
|
|
-// String msg = new String(message.getBody(), StandardCharsets.UTF_8);
|
|
|
|
|
-// log.info("msg:{}", msg);
|
|
|
|
|
-// JSONObject jsonObject = JSON.parseObject(msg);
|
|
|
|
|
-// //roomId
|
|
|
|
|
-// roomId = jsonObject.getString("roomId");
|
|
|
|
|
-// String zipUrl = jsonObject.getString("zipUrl");
|
|
|
|
|
-// String zipName = FileUtil.getName(zipUrl);
|
|
|
|
|
-// String dirName = FileUtil.getPrefix(zipName);
|
|
|
|
|
-// log.info("zipUrl:{}", zipUrl);
|
|
|
|
|
-// //下载压缩包
|
|
|
|
|
-// String baseZipPath = "/mnt/scene/convert/";
|
|
|
|
|
-// FileUtil.mkdir(baseZipPath);
|
|
|
|
|
-// HttpUtil.downloadFile(zipUrl, baseZipPath);
|
|
|
|
|
-//// FileUtil.copy(zipUrl, baseZipPath, true);
|
|
|
|
|
-//
|
|
|
|
|
-// String localZipPath = baseZipPath + zipName;
|
|
|
|
|
-// ZipUtil.unzip(localZipPath, baseZipPath);
|
|
|
|
|
-//
|
|
|
|
|
-// String targetPath = "/oss/4dkankan/scene_view_data/" + roomId + "/";
|
|
|
|
|
-// String dataSource = baseZipPath + dirName + "/";
|
|
|
|
|
-// Map<String, String> uploadFileMap = convertUtil.convert(dataSource, roomId);
|
|
|
|
|
-// String finalRoomId = roomId;
|
|
|
|
|
-// uploadFileMap.keySet().stream().forEach(key->{
|
|
|
|
|
-//
|
|
|
|
|
-// SceneFileMapping sceneFileMapping = sceneFileMappingService.getByNumAndKey(finalRoomId, key);
|
|
|
|
|
-// if(Objects.isNull(sceneFileMapping)){
|
|
|
|
|
-// sceneFileMapping = new SceneFileMapping();
|
|
|
|
|
-// }
|
|
|
|
|
-// Map<String, String> mapping = fdfsUtil.uploadFile(uploadFileMap.get(key));
|
|
|
|
|
-// sceneFileMapping.setNum(finalRoomId);
|
|
|
|
|
-// sceneFileMapping.setFileid(mapping.get("file_id"));
|
|
|
|
|
-// sceneFileMapping.setUrl(mapping.get("http_url"));
|
|
|
|
|
-// sceneFileMapping.setKey(key);
|
|
|
|
|
-// sceneFileMappingService.saveOrUpdate(sceneFileMapping);
|
|
|
|
|
-// });
|
|
|
|
|
-//
|
|
|
|
|
-// }catch (Exception e){
|
|
|
|
|
-// log.error("convert fail, roomId:{}", roomId, e);
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
|
|
|
|
-//
|
|
|
|
|
-//
|
|
|
|
|
-// }
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* 场景转换监听器
|
|
* 场景转换监听器
|
|
|
* @throws Exception
|
|
* @throws Exception
|
|
@@ -131,13 +78,13 @@ public class ConvertListener{
|
|
|
concurrency = "1"
|
|
concurrency = "1"
|
|
|
)
|
|
)
|
|
|
public void buildObjScenePreHandler(Channel channel, Message message) throws Exception {
|
|
public void buildObjScenePreHandler(Channel channel, Message message) throws Exception {
|
|
|
- //开始计时
|
|
|
|
|
|
|
+ // 开始计时
|
|
|
TimeInterval timeInterval = new TimeInterval();
|
|
TimeInterval timeInterval = new TimeInterval();
|
|
|
timeInterval.start();
|
|
timeInterval.start();
|
|
|
|
|
|
|
|
- //获取消息id
|
|
|
|
|
|
|
+ // 获取消息id
|
|
|
String messageId = message.getMessageProperties().getMessageId();
|
|
String messageId = message.getMessageProperties().getMessageId();
|
|
|
- //消息开始消费,立即ack,防止二次消费
|
|
|
|
|
|
|
+ // 消息开始消费,立即ack,防止二次消费
|
|
|
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
|
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
|
|
|
|
|
|
|
String stationCode = null;
|
|
String stationCode = null;
|
|
@@ -162,17 +109,17 @@ public class ConvertListener{
|
|
|
convertType = "standar";
|
|
convertType = "standar";
|
|
|
}
|
|
}
|
|
|
if(StrUtil.isNotEmpty(upTimeStr)){
|
|
if(StrUtil.isNotEmpty(upTimeStr)){
|
|
|
- //将字符串转为时间格式
|
|
|
|
|
|
|
+ // 将字符串转为时间格式
|
|
|
upTime = DateUtil.parse(upTimeStr, DatePattern.NORM_DATETIME_PATTERN);
|
|
upTime = DateUtil.parse(upTimeStr, DatePattern.NORM_DATETIME_PATTERN);
|
|
|
- //将字符串转为YYYYMMDDHHMMSS格式
|
|
|
|
|
|
|
+ // 将字符串转为YYYYMMDDHHMMSS格式
|
|
|
upTimeKey = upTimeStr.replace("-", "").replace(" ", "").replace(":", "");
|
|
upTimeKey = upTimeStr.replace("-", "").replace(" ", "").replace(":", "");
|
|
|
}
|
|
}
|
|
|
fileList = jsonObject.getJSONArray("fileList");
|
|
fileList = jsonObject.getJSONArray("fileList");
|
|
|
convertIngKey = String.format(Constant.REDIS_SCENE_CONVERT_ING, messageId);
|
|
convertIngKey = String.format(Constant.REDIS_SCENE_CONVERT_ING, messageId);
|
|
|
String convert = redisClient.get(convertIngKey);
|
|
String convert = redisClient.get(convertIngKey);
|
|
|
log.info("-----------------convert:{}-----------------", convert);
|
|
log.info("-----------------convert:{}-----------------", convert);
|
|
|
- //铁塔的rabbitmq有问题,简单队列不能负载均衡,所以这里用redis做了一个锁,方式重复消费
|
|
|
|
|
- if(StrUtil.isNotEmpty(convert)){//正在转换,直接丢弃
|
|
|
|
|
|
|
+ // 铁塔的rabbitmq有问题,简单队列不能负载均衡,所以这里用redis做了一个锁,方式重复消费
|
|
|
|
|
+ if(StrUtil.isNotEmpty(convert)){// 正在转换,直接丢弃
|
|
|
log.warn("场景正在转换,此消息丢弃, stationCode:{}, entityId:{}", stationCode, entityId);
|
|
log.warn("场景正在转换,此消息丢弃, stationCode:{}, entityId:{}", stationCode, entityId);
|
|
|
convertIngKey = null;
|
|
convertIngKey = null;
|
|
|
return;
|
|
return;
|
|
@@ -184,7 +131,7 @@ public class ConvertListener{
|
|
|
sceneConvertLog.setCreateTime(new Date());
|
|
sceneConvertLog.setCreateTime(new Date());
|
|
|
sceneConvertLog.setConverttype(convertType);
|
|
sceneConvertLog.setConverttype(convertType);
|
|
|
|
|
|
|
|
- //只更新上传时间
|
|
|
|
|
|
|
+ // 只更新上传时间
|
|
|
if(convertType.equals("upTime")){
|
|
if(convertType.equals("upTime")){
|
|
|
|
|
|
|
|
List<Scene> list = sceneService.list(new LambdaQueryWrapper<Scene>().eq(Scene::getNum, entityId).eq(Scene::getStationcode, stationCode));
|
|
List<Scene> list = sceneService.list(new LambdaQueryWrapper<Scene>().eq(Scene::getNum, entityId).eq(Scene::getStationcode, stationCode));
|
|
@@ -197,7 +144,7 @@ public class ConvertListener{
|
|
|
});
|
|
});
|
|
|
sceneService.updateBatchById(list);
|
|
sceneService.updateBatchById(list);
|
|
|
|
|
|
|
|
- //有中高低点位的场景的公有visiontxt文件
|
|
|
|
|
|
|
+ // 有中高低点位的场景的公有visiontxt文件
|
|
|
List<SceneFileMapping> visionTxt = sceneFileMappingService.getByNumAndKey(list.get(0).getNum(), -1, "scene_view_data/" + list.get(0).getNum() + "/images/vision.txt");
|
|
List<SceneFileMapping> visionTxt = sceneFileMappingService.getByNumAndKey(list.get(0).getNum(), -1, "scene_view_data/" + list.get(0).getNum() + "/images/vision.txt");
|
|
|
if(CollUtil.isNotEmpty(visionTxt)){
|
|
if(CollUtil.isNotEmpty(visionTxt)){
|
|
|
visionTxt.stream().forEach(v -> v.setUpTime(finalUpTimeKey));
|
|
visionTxt.stream().forEach(v -> v.setUpTime(finalUpTimeKey));
|
|
@@ -214,7 +161,7 @@ public class ConvertListener{
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}else{
|
|
}else{
|
|
|
- //校验文件是否齐全
|
|
|
|
|
|
|
+ // 校验文件是否齐全
|
|
|
boolean exists512 = fileList.stream().anyMatch(v -> {
|
|
boolean exists512 = fileList.stream().anyMatch(v -> {
|
|
|
JSONObject obj = (JSONObject) v;
|
|
JSONObject obj = (JSONObject) v;
|
|
|
return "1".equals(obj.getString(file_type_key));
|
|
return "1".equals(obj.getString(file_type_key));
|
|
@@ -230,7 +177,6 @@ public class ConvertListener{
|
|
|
return "3".equals(obj.getString(file_type_key));
|
|
return "3".equals(obj.getString(file_type_key));
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
-
|
|
|
|
|
dataSource = baseZipPath + stationCode + "_" + entityId + "_" + DateUtil.format(upTime, DatePattern.PURE_DATETIME_PATTERN) + "/";
|
|
dataSource = baseZipPath + stationCode + "_" + entityId + "_" + DateUtil.format(upTime, DatePattern.PURE_DATETIME_PATTERN) + "/";
|
|
|
String imagePath = dataSource + "images/";
|
|
String imagePath = dataSource + "images/";
|
|
|
String dataPath = dataSource + "data/";
|
|
String dataPath = dataSource + "data/";
|
|
@@ -246,19 +192,19 @@ public class ConvertListener{
|
|
|
String fileName = obj.getString("fileName");
|
|
String fileName = obj.getString("fileName");
|
|
|
String fileType = obj.getString(file_type_key);
|
|
String fileType = obj.getString(file_type_key);
|
|
|
String fileUrl = obj.getString("fileUrl");
|
|
String fileUrl = obj.getString("fileUrl");
|
|
|
- if("7".equals(fileType)){//vision.txt
|
|
|
|
|
|
|
+ if("7".equals(fileType)){// vision.txt
|
|
|
HttpUtilExt.downloadFileAndCheck(fileUrl, imagePath + fileName, 300000);
|
|
HttpUtilExt.downloadFileAndCheck(fileUrl, imagePath + fileName, 300000);
|
|
|
}
|
|
}
|
|
|
- if("1".equals(fileType)){//512图
|
|
|
|
|
|
|
+ if("1".equals(fileType)){// 512图
|
|
|
HttpUtilExt.downloadFileAndCheck(fileUrl, image512Path + fileName, 300000);
|
|
HttpUtilExt.downloadFileAndCheck(fileUrl, image512Path + fileName, 300000);
|
|
|
}
|
|
}
|
|
|
- if("2".equals(fileType)){//4k图
|
|
|
|
|
|
|
+ if("2".equals(fileType)){// 4k图
|
|
|
HttpUtilExt.downloadFileAndCheck(fileUrl, image4kPath + fileName, 300000);
|
|
HttpUtilExt.downloadFileAndCheck(fileUrl, image4kPath + fileName, 300000);
|
|
|
if(!exists512){
|
|
if(!exists512){
|
|
|
ImgUtil.scale(new File(image4kPath + fileName), new File(image512Path + fileName), 0.125f);
|
|
ImgUtil.scale(new File(image4kPath + fileName), new File(image512Path + fileName), 0.125f);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- if(!exists4k){//如果资源中没有4k,需要用8k图做一下像素压缩
|
|
|
|
|
|
|
+ if(!exists4k){// 如果资源中没有4k,需要用8k图做一下像素压缩
|
|
|
if("3".equals(fileType)){
|
|
if("3".equals(fileType)){
|
|
|
HttpUtilExt.downloadFileAndCheck(fileUrl, image8kPath + fileName, 30000);
|
|
HttpUtilExt.downloadFileAndCheck(fileUrl, image8kPath + fileName, 30000);
|
|
|
ImgUtil.scale(new File(image8kPath + fileName),new File(image4kPath + fileName), 0.5f);
|
|
ImgUtil.scale(new File(image8kPath + fileName),new File(image4kPath + fileName), 0.5f);
|
|
@@ -267,18 +213,18 @@ public class ConvertListener{
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- if("11".equals(fileType)){//mesh.obj
|
|
|
|
|
|
|
+ if("11".equals(fileType)){// mesh.obj
|
|
|
HttpUtilExt.downloadFileAndCheck(fileUrl, meshPath + fileName, 300000);
|
|
HttpUtilExt.downloadFileAndCheck(fileUrl, meshPath + fileName, 300000);
|
|
|
}
|
|
}
|
|
|
- if("5".equals(fileType)){//floorplan.json
|
|
|
|
|
|
|
+ if("5".equals(fileType)){// floorplan.json
|
|
|
HttpUtilExt.downloadFileAndCheck(fileUrl, dataPath + fileName, 300000);
|
|
HttpUtilExt.downloadFileAndCheck(fileUrl, dataPath + fileName, 300000);
|
|
|
}
|
|
}
|
|
|
- if("12".equals(fileType)){//scene.json
|
|
|
|
|
|
|
+ if("12".equals(fileType)){// scene.json
|
|
|
HttpUtilExt.downloadFileAndCheck(fileUrl, dataPath + fileName, 300000);
|
|
HttpUtilExt.downloadFileAndCheck(fileUrl, dataPath + fileName, 300000);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- //转换并上传文件
|
|
|
|
|
|
|
+ // 转换并上传文件
|
|
|
convertUtil.convert(dataSource, entityId, stationCode, upTime, convertType, upTimeKey);
|
|
convertUtil.convert(dataSource, entityId, stationCode, upTime, convertType, upTimeKey);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -302,15 +248,5 @@ public class ConvertListener{
|
|
|
redisClient.del(convertIngKey);
|
|
redisClient.del(convertIngKey);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-// channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
|
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-// public boolean checkNead8kPic(JSONArray array){
|
|
|
|
|
-// array.stream().findFirst().stream().anyMatch()
|
|
|
|
|
-//
|
|
|
|
|
-//
|
|
|
|
|
-//
|
|
|
|
|
-// }
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|