服务指令字段、功能调整
This commit is contained in:
parent
2e03763f87
commit
dafe6f3c88
|
@ -85,9 +85,9 @@ public class ConfigServiceDirective implements Serializable {
|
|||
@Excel(name = "排序", width = 15)
|
||||
@ApiModelProperty(value = "排序")
|
||||
private java.lang.Integer sort;
|
||||
/**服务说明*/
|
||||
@Excel(name = "服务说明", width = 15)
|
||||
@ApiModelProperty(value = "服务说明")
|
||||
/**服务描述*/
|
||||
@Excel(name = "服务描述", width = 15)
|
||||
@ApiModelProperty(value = "服务描述")
|
||||
private java.lang.String serviceContent;
|
||||
/**服务时长(分钟)*/
|
||||
@Excel(name = "服务时长(分钟)", width = 15)
|
||||
|
@ -122,28 +122,28 @@ public class ConfigServiceDirective implements Serializable {
|
|||
/**所属部门*/
|
||||
@ApiModelProperty(value = "所属部门")
|
||||
private java.lang.String sysOrgCode;
|
||||
/**语音文件*/
|
||||
@ApiModelProperty(value = "语音文件")
|
||||
/**指令音频文件*/
|
||||
@ApiModelProperty(value = "指令音频文件")
|
||||
private java.lang.String mp3File;
|
||||
//语音文件是否变更
|
||||
@TableField(exist = false)
|
||||
private boolean mp3FileChanged;
|
||||
/**视频文件*/
|
||||
@ApiModelProperty(value = "视频文件")
|
||||
/**指令视频文件*/
|
||||
@ApiModelProperty(value = "指令视频文件")
|
||||
private java.lang.String mp4File;
|
||||
//视频文件是否变更
|
||||
@TableField(exist = false)
|
||||
private boolean mp4FileChanged;
|
||||
/**预览图片*/
|
||||
@ApiModelProperty(value = "预览图片")
|
||||
/**服务指令图片*/
|
||||
@ApiModelProperty(value = "服务指令图片")
|
||||
private java.lang.String previewFile;
|
||||
//预览图片是否变更
|
||||
//服务指令图片是否变更
|
||||
@TableField(exist = false)
|
||||
private boolean previewFileChanged;
|
||||
/**即时指令图片*/
|
||||
@ApiModelProperty(value = "即时指令图片")
|
||||
/**即时指令图标*/
|
||||
@ApiModelProperty(value = "即时指令图标")
|
||||
private java.lang.String immediateFile;
|
||||
//即时指令图片是否变更
|
||||
//即时指令图标是否变更
|
||||
@TableField(exist = false)
|
||||
private boolean immediateFileChanged;
|
||||
|
||||
|
|
|
@ -11,10 +11,14 @@ import com.nu.modules.servicedirective.mapper.ConfigServiceDirectiveMapper;
|
|||
import com.nu.modules.servicedirective.service.IConfigServiceDirectiveService;
|
||||
import com.nu.modules.sysconfig.ISysConfigApi;
|
||||
import com.nu.utils.RabbitMQUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.jeecg.common.system.api.ISysBaseAPI;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -27,6 +31,9 @@ import java.util.stream.Collectors;
|
|||
@Service
|
||||
public class ConfigServiceDirectiveServiceImpl extends ServiceImpl<ConfigServiceDirectiveMapper, ConfigServiceDirective> implements IConfigServiceDirectiveService {
|
||||
|
||||
@Value(value = "${jeecg.path.upload}")
|
||||
private String uploadpath;
|
||||
|
||||
@Autowired
|
||||
private ISysConfigApi sysConfigApi;
|
||||
@Autowired
|
||||
|
@ -227,7 +234,92 @@ public class ConfigServiceDirectiveServiceImpl extends ServiceImpl<ConfigService
|
|||
*/
|
||||
@Override
|
||||
public void handleMediaFile(ConfigServiceDirective configServiceDirective) {
|
||||
//上传根路径
|
||||
String path = uploadpath;
|
||||
//需要存储的路径
|
||||
String mediaFileSavePath = configServiceDirective.getMediaFileSavePath();
|
||||
//服务指令图片
|
||||
String previewFile = configServiceDirective.getPreviewFile();
|
||||
//即时指令图标
|
||||
String immediateFile = configServiceDirective.getImmediateFile();
|
||||
//指令音频文件
|
||||
String mp3File = configServiceDirective.getMp3File();
|
||||
//指令视频文件
|
||||
String mp4File = configServiceDirective.getMp4File();
|
||||
|
||||
// 处理每个文件并获取更新后的路径
|
||||
String newPreviewFile = processFile(path, mediaFileSavePath, previewFile);
|
||||
String newImmediateFile = processFile(path, mediaFileSavePath, immediateFile);
|
||||
String newMp3File = processFile(path, mediaFileSavePath, mp3File);
|
||||
String newMp4File = processFile(path, mediaFileSavePath, mp4File);
|
||||
|
||||
// 如果有变化,更新ConfigServiceDirective对象
|
||||
if (newPreviewFile != null) {
|
||||
configServiceDirective.setPreviewFile(newPreviewFile);
|
||||
}
|
||||
if (newImmediateFile != null) {
|
||||
configServiceDirective.setImmediateFile(newImmediateFile);
|
||||
}
|
||||
if (newMp3File != null) {
|
||||
configServiceDirective.setMp3File(newMp3File);
|
||||
}
|
||||
if (newMp4File != null) {
|
||||
configServiceDirective.setMp4File(newMp4File);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理单个文件,检查路径是否需要迁移
|
||||
* @param basePath 基础路径
|
||||
* @param targetDir 目标目录
|
||||
* @param filePath 文件路径
|
||||
* @return 如果路径有变化返回新路径,否则返回null
|
||||
*/
|
||||
private String processFile(String basePath, String targetDir, String filePath) {
|
||||
if (StringUtils.isBlank(filePath)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
// 检查文件路径是否以目标目录开头
|
||||
if (!filePath.startsWith(targetDir + "/")) {
|
||||
// 获取文件名(路径的最后一部分)
|
||||
String fileName = filePath.substring(filePath.lastIndexOf('/') + 1);
|
||||
|
||||
// 构建新的完整路径
|
||||
String newRelativePath = targetDir + "/" + fileName;
|
||||
String oldFullPath = basePath + "/" + filePath;
|
||||
String newFullPath = basePath + "/" + newRelativePath;
|
||||
|
||||
// 创建目标目录(如果不存在)
|
||||
File targetDirectory = new File(basePath + "/" + targetDir);
|
||||
if (!targetDirectory.exists()) {
|
||||
targetDirectory.mkdirs();
|
||||
}
|
||||
|
||||
// 移动文件
|
||||
File oldFile = new File(oldFullPath);
|
||||
if (oldFile.exists()) {
|
||||
File newFile = new File(newFullPath);
|
||||
|
||||
// 如果目标文件已存在,先删除
|
||||
if (newFile.exists()) {
|
||||
newFile.delete();
|
||||
}
|
||||
|
||||
// 移动文件
|
||||
Files.move(oldFile.toPath(), newFile.toPath());
|
||||
|
||||
// 返回新的相对路径
|
||||
return newRelativePath;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 处理异常,可以根据实际需求记录日志或抛出
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -205,7 +205,7 @@ spring:
|
|||
password:
|
||||
#rabbitmq 配置
|
||||
rabbitmq:
|
||||
host: 192.168.2.1991
|
||||
host: 192.168.2.199
|
||||
prot: 5672
|
||||
username: hldy
|
||||
password: hldy
|
||||
|
|
Loading…
Reference in New Issue