|
@@ -16,6 +16,7 @@ import com.fdkankan.common.constant.*;
|
|
import com.fdkankan.common.util.*;
|
|
import com.fdkankan.common.util.*;
|
|
import com.fdkankan.platform.api.feign.PlatformClient;
|
|
import com.fdkankan.platform.api.feign.PlatformClient;
|
|
import com.fdkankan.redis.constant.RedisKey;
|
|
import com.fdkankan.redis.constant.RedisKey;
|
|
|
|
+import com.fdkankan.redis.constant.RedisLockKey;
|
|
import com.fdkankan.redis.util.RedisLockUtil;
|
|
import com.fdkankan.redis.util.RedisLockUtil;
|
|
import com.fdkankan.scene.entity.*;
|
|
import com.fdkankan.scene.entity.*;
|
|
import com.fdkankan.scene.mapper.ISceneProMapper;
|
|
import com.fdkankan.scene.mapper.ISceneProMapper;
|
|
@@ -27,6 +28,7 @@ import com.fdkankan.common.constant.ErrorCode;
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
import com.fdkankan.common.response.ResultData;
|
|
import com.fdkankan.common.response.ResultData;
|
|
import com.fdkankan.fyun.oss.UploadToOssUtil;
|
|
import com.fdkankan.fyun.oss.UploadToOssUtil;
|
|
|
|
+import com.fdkankan.scene.vo.UploadFileParamVO;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import net.coobird.thumbnailator.Thumbnails;
|
|
import net.coobird.thumbnailator.Thumbnails;
|
|
import org.joda.time.DateTime;
|
|
import org.joda.time.DateTime;
|
|
@@ -245,7 +247,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
@Override
|
|
@Override
|
|
public ResultData uploadFloorJson(SceneEditVO sceneEdit) throws Exception {
|
|
public ResultData uploadFloorJson(SceneEditVO sceneEdit) throws Exception {
|
|
|
|
|
|
- String lockKey = String.format(RedisKey.LOCK_UPLOAD_FLOORJSON_REBUILD, sceneEdit.getSceneNum());
|
|
|
|
|
|
+ String lockKey = String.format(RedisLockKey.LOCK_UPLOAD_FLOORJSON_REBUILD, sceneEdit.getSceneNum());
|
|
Boolean lock = redisLockUtil.lock(lockKey, RedisKey.EXPIRE_TIME_2_HOUR);
|
|
Boolean lock = redisLockUtil.lock(lockKey, RedisKey.EXPIRE_TIME_2_HOUR);
|
|
if(!lock){
|
|
if(!lock){
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5036);
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5036);
|
|
@@ -481,7 +483,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
@Override
|
|
@Override
|
|
public ResultData uploadFloorJsonAjk(String sceneNum, String ajkJson, String cameraJson, String floorPlanJson, MultipartFile[] file) throws Exception {
|
|
public ResultData uploadFloorJsonAjk(String sceneNum, String ajkJson, String cameraJson, String floorPlanJson, MultipartFile[] file) throws Exception {
|
|
|
|
|
|
- String lockKey = String.format(RedisKey.LOCK_UPLOAD_FLOORJSON_REBUILD, sceneNum);
|
|
|
|
|
|
+ String lockKey = String.format(RedisLockKey.LOCK_UPLOAD_FLOORJSON_REBUILD, sceneNum);
|
|
Boolean lock = redisLockUtil.lock(lockKey, RedisKey.EXPIRE_TIME_2_HOUR);
|
|
Boolean lock = redisLockUtil.lock(lockKey, RedisKey.EXPIRE_TIME_2_HOUR);
|
|
if(!lock){
|
|
if(!lock){
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5036);
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5036);
|
|
@@ -937,11 +939,9 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public ResultData uploadScreencapVoiceNew(String sceneNum, String type, String fileName, MultipartFile file, String length, String replace) throws Exception{
|
|
|
|
- if(StrUtil.isEmpty(sceneNum)){
|
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_3001);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ public ResultData uploadScreencapVoiceNew(UploadFileParamVO param, MultipartFile file) throws Exception{
|
|
|
|
+ String sceneNum = param.getSceneNum();
|
|
|
|
+ String fileName = param.getFileName();
|
|
ScenePro scenePro = findBySceneNum(sceneNum);
|
|
ScenePro scenePro = findBySceneNum(sceneNum);
|
|
if(scenePro == null){
|
|
if(scenePro == null){
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
@@ -968,7 +968,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
if(strsceneInfos!=null) {
|
|
if(strsceneInfos!=null) {
|
|
scenejson = JSONObject.parseObject(strsceneInfos);
|
|
scenejson = JSONObject.parseObject(strsceneInfos);
|
|
}
|
|
}
|
|
- if("soundsync".equals(type) && !"1".equals(replace)){
|
|
|
|
|
|
+ if("soundsync".equals(type) && !"1".equals(param.getReplace())){
|
|
synchronized(this){
|
|
synchronized(this){
|
|
if(scenejson.containsKey("screencapVoiceSoundsync") && !StrUtil.isEmpty(scenejson.getString("screencapVoiceSoundsync"))){
|
|
if(scenejson.containsKey("screencapVoiceSoundsync") && !StrUtil.isEmpty(scenejson.getString("screencapVoiceSoundsync"))){
|
|
String target = ConstantFilePath.SCENE_PATH + scenejson.getString("screencapVoiceSoundsync").substring(
|
|
String target = ConstantFilePath.SCENE_PATH + scenejson.getString("screencapVoiceSoundsync").substring(
|
|
@@ -987,7 +987,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
new File(target).renameTo(new File(path + File.separator + "oldSound201810.mp3"));
|
|
new File(target).renameTo(new File(path + File.separator + "oldSound201810.mp3"));
|
|
|
|
|
|
//判断音频时长,不够拼接空白音效
|
|
//判断音频时长,不够拼接空白音效
|
|
- double total = Double.parseDouble(length);
|
|
|
|
|
|
+ double total = param.getLength();
|
|
double now = (FileUtils.getAudioPlayTime(new File(path + File.separator + "oldSound201810.mp3")) +
|
|
double now = (FileUtils.getAudioPlayTime(new File(path + File.separator + "oldSound201810.mp3")) +
|
|
FileUtils.getAudioPlayTime(new File(path + File.separator + "newSound201810.mp3"))) / 1000.0;
|
|
FileUtils.getAudioPlayTime(new File(path + File.separator + "newSound201810.mp3"))) / 1000.0;
|
|
if(total - now > 0.5){
|
|
if(total - now > 0.5){
|
|
@@ -1027,7 +1027,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
file.transferTo(targetFile);
|
|
file.transferTo(targetFile);
|
|
//判断音频时长,不够拼接空白音效
|
|
//判断音频时长,不够拼接空白音效
|
|
FileUtils.changeVoiceToMp3(path + File.separator + soundFileName, path + File.separator + "newSound201810.mp3");
|
|
FileUtils.changeVoiceToMp3(path + File.separator + soundFileName, path + File.separator + "newSound201810.mp3");
|
|
- double total = Double.parseDouble(length);
|
|
|
|
|
|
+ double total = param.getLength();
|
|
double now = (FileUtils.getAudioPlayTime(new File(path + File.separator + "newSound201810.mp3"))) / 1000.0;
|
|
double now = (FileUtils.getAudioPlayTime(new File(path + File.separator + "newSound201810.mp3"))) / 1000.0;
|
|
log.info("前端传的时长:" + total);
|
|
log.info("前端传的时长:" + total);
|
|
log.info("获取文件的时长:" + now);
|
|
log.info("获取文件的时长:" + now);
|
|
@@ -1120,7 +1120,9 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public ResultData uploadScreencapVoiceNewV3(String sceneNum, String type, String fileName, MultipartFile file, String length, String replace, String times, String index) throws Exception{
|
|
|
|
|
|
+ public ResultData uploadScreencapVoiceNewV3(UploadFileParamVO param, MultipartFile file) throws Exception{
|
|
|
|
+ String sceneNum = param.getSceneNum();
|
|
|
|
+ String fileName = param.getFileName();
|
|
if(StrUtil.isEmpty(sceneNum)){
|
|
if(StrUtil.isEmpty(sceneNum)){
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_3001);
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_3001);
|
|
}
|
|
}
|
|
@@ -1147,7 +1149,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
if(strsceneInfos!=null) {
|
|
if(strsceneInfos!=null) {
|
|
scenejson = JSONObject.parseObject(strsceneInfos);
|
|
scenejson = JSONObject.parseObject(strsceneInfos);
|
|
}
|
|
}
|
|
- if("soundsync".equals(type) && !"1".equals(replace)){
|
|
|
|
|
|
+ if("soundsync".equals(type) && !"1".equals(param.getReplace())){
|
|
//判断分房间模块文件夹是否存在
|
|
//判断分房间模块文件夹是否存在
|
|
String partPath = path + File.separator + "part";
|
|
String partPath = path + File.separator + "part";
|
|
File partFile = new File(partPath);
|
|
File partFile = new File(partPath);
|
|
@@ -1165,7 +1167,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
}
|
|
}
|
|
|
|
|
|
//获取总音频多少段,每段时长
|
|
//获取总音频多少段,每段时长
|
|
- String[] time = times.split(",");
|
|
|
|
|
|
+ String[] time = param.getTimes().split(",");
|
|
//遍历判断音频是否存在,不存在生成空白音效
|
|
//遍历判断音频是否存在,不存在生成空白音效
|
|
for(int i = 0, len = time.length; i < len; i++){
|
|
for(int i = 0, len = time.length; i < len; i++){
|
|
if(!new File(partPath + File.separator + i + ".mp3").exists()){
|
|
if(!new File(partPath + File.separator + i + ".mp3").exists()){
|