|
@@ -244,19 +244,32 @@ public class SysMusicScoreServiceImpl extends BaseServiceImpl<Integer, SysMusicS
|
|
}
|
|
}
|
|
//
|
|
//
|
|
String old = JSONObject.toJSONString(obj);
|
|
String old = JSONObject.toJSONString(obj);
|
|
-
|
|
|
|
- if (StringUtils.isNotEmpty(obj.getUrl())) {
|
|
|
|
- obj.setUrl(doTranscod(obj.getUrl()));
|
|
|
|
|
|
+ boolean flag = false;
|
|
|
|
+ String url = doTranscod(obj.getUrl());
|
|
|
|
+ if (StringUtils.isNotEmpty(url)) {
|
|
|
|
+ obj.setUrl(url);
|
|
|
|
+ flag = true;
|
|
|
|
+ }
|
|
|
|
+ String metronomeUrl = doTranscod(obj.getMetronomeUrl());
|
|
|
|
+ if (StringUtils.isNotEmpty(metronomeUrl)) {
|
|
|
|
+ obj.setMetronomeUrl(metronomeUrl);
|
|
|
|
+ flag = true;
|
|
}
|
|
}
|
|
- if (StringUtils.isNotEmpty(obj.getMetronomeUrl())) {
|
|
|
|
- obj.setMetronomeUrl(doTranscod(obj.getMetronomeUrl()));
|
|
|
|
|
|
+ String mp3Url = doTranscod(obj.getMp3Url());
|
|
|
|
+ if (StringUtils.isNotEmpty(mp3Url)) {
|
|
|
|
+ obj.setMp3Url(mp3Url);
|
|
|
|
+ flag = true;
|
|
}
|
|
}
|
|
- if (StringUtils.isNotEmpty(obj.getMp3Url())) {
|
|
|
|
- obj.setMp3Url(doTranscod(obj.getMp3Url()));
|
|
|
|
|
|
+ String metronomeMp3Url = doTranscod(obj.getMetronomeMp3Url());
|
|
|
|
+ if (StringUtils.isNotEmpty(metronomeMp3Url)) {
|
|
|
|
+ obj.setMetronomeMp3Url(metronomeMp3Url);
|
|
|
|
+ flag = true;
|
|
}
|
|
}
|
|
- if (StringUtils.isNotEmpty(obj.getMetronomeMp3Url())) {
|
|
|
|
- obj.setMetronomeMp3Url(doTranscod(obj.getMetronomeMp3Url()));
|
|
|
|
|
|
+
|
|
|
|
+ if(!flag){
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
|
|
+
|
|
String now = JSONObject.toJSONString(obj);
|
|
String now = JSONObject.toJSONString(obj);
|
|
|
|
|
|
//更新obj
|
|
//更新obj
|
|
@@ -286,8 +299,11 @@ public class SysMusicScoreServiceImpl extends BaseServiceImpl<Integer, SysMusicS
|
|
* @param fileUrl
|
|
* @param fileUrl
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- private String doTranscod(String fileUrl){
|
|
|
|
|
|
+ private String doTranscod(String fileUrl) {
|
|
String transcodUrl = "";
|
|
String transcodUrl = "";
|
|
|
|
+ if (StringUtils.isEmpty(fileUrl)) {
|
|
|
|
+ return transcodUrl;
|
|
|
|
+ }
|
|
//文件扩展名
|
|
//文件扩展名
|
|
String expand = FileUtil.getFileExpandByPath(fileUrl);
|
|
String expand = FileUtil.getFileExpandByPath(fileUrl);
|
|
//将远程文件写入本地临时文件路径
|
|
//将远程文件写入本地临时文件路径
|
|
@@ -313,17 +329,17 @@ public class SysMusicScoreServiceImpl extends BaseServiceImpl<Integer, SysMusicS
|
|
UploadReturnBean uploadReturnBean = uploadFileService.uploadFile(inputStream, expand);
|
|
UploadReturnBean uploadReturnBean = uploadFileService.uploadFile(inputStream, expand);
|
|
transcodUrl = uploadReturnBean.getUrl();
|
|
transcodUrl = uploadReturnBean.getUrl();
|
|
}
|
|
}
|
|
- }catch (Exception e){
|
|
|
|
|
|
+ } catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
- }finally {
|
|
|
|
|
|
+ } finally {
|
|
//删除服务器中的文件
|
|
//删除服务器中的文件
|
|
- /*if(tempFile.exists()){
|
|
|
|
|
|
+ if(tempFile.exists()){
|
|
tempFile.delete();
|
|
tempFile.delete();
|
|
}
|
|
}
|
|
File tempTranscodFile = new File(tempTranscodFileName);
|
|
File tempTranscodFile = new File(tempTranscodFileName);
|
|
if(tempTranscodFile.exists()){
|
|
if(tempTranscodFile.exists()){
|
|
tempTranscodFile.delete();
|
|
tempTranscodFile.delete();
|
|
- }*/
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|
|
return transcodUrl;
|
|
return transcodUrl;
|
|
}
|
|
}
|
|
@@ -339,7 +355,7 @@ public class SysMusicScoreServiceImpl extends BaseServiceImpl<Integer, SysMusicS
|
|
private String getTempFileName(String expand) {
|
|
private String getTempFileName(String expand) {
|
|
//没有目录则创建
|
|
//没有目录则创建
|
|
File file = new File(tempPath);
|
|
File file = new File(tempPath);
|
|
- if (file.exists()) {
|
|
|
|
|
|
+ if (!file.exists()) {
|
|
file.mkdirs();
|
|
file.mkdirs();
|
|
}
|
|
}
|
|
//.mp3
|
|
//.mp3
|