Compare commits
2 Commits
1c2c70d077
...
dafe6f3c88
Author | SHA1 | Date |
---|---|---|
|
dafe6f3c88 | |
|
2e03763f87 |
|
@ -38,7 +38,7 @@ import java.util.stream.Collectors;
|
|||
*/
|
||||
@Api(tags = "服务指令")
|
||||
@RestController
|
||||
@RequestMapping("/services/serviceDirective/configServiceDirective")
|
||||
@RequestMapping("/services/serviceDirective")
|
||||
@Slf4j
|
||||
public class ConfigServiceDirectiveController extends JeecgController<ConfigServiceDirective, IConfigServiceDirectiveService> {
|
||||
@Autowired
|
||||
|
@ -78,18 +78,18 @@ public class ConfigServiceDirectiveController extends JeecgController<ConfigServ
|
|||
directiveIds = configServiceDirectiveService.queryDirectiveIdByBodyTagIds(configServiceDirective.getBodyTags());
|
||||
if (directiveIds != null && !directiveIds.isEmpty()) {
|
||||
queryWrapper.in("id", directiveIds.stream().map(ConfigServiceDirective::getId).collect(Collectors.toList()));
|
||||
}else{
|
||||
} else {
|
||||
//体重标签下没有数据
|
||||
queryWrapper.eq("id","null");
|
||||
queryWrapper.eq("id", "null");
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotBlank(configServiceDirective.getEmotionTags())) {
|
||||
directiveIds = configServiceDirectiveService.queryDirectiveIdByEmotionTagIds(configServiceDirective.getEmotionTags());
|
||||
if (directiveIds != null && !directiveIds.isEmpty() && StringUtils.isNotBlank(configServiceDirective.getEmotionTags())) {
|
||||
queryWrapper.in("id", directiveIds.stream().map(ConfigServiceDirective::getId).collect(Collectors.toList()));
|
||||
}else{
|
||||
} else {
|
||||
//情绪标签下没有数据
|
||||
queryWrapper.eq("id","null");
|
||||
queryWrapper.eq("id", "null");
|
||||
}
|
||||
}
|
||||
Page<ConfigServiceDirective> page = new Page<ConfigServiceDirective>(pageNo, pageSize);
|
||||
|
@ -109,8 +109,9 @@ public class ConfigServiceDirectiveController extends JeecgController<ConfigServ
|
|||
@ApiOperation(value = "服务指令-添加", notes = "服务指令-添加")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody ConfigServiceDirective configServiceDirective) {
|
||||
//处理媒体资源
|
||||
configServiceDirectiveService.handleMedia(configServiceDirective);
|
||||
//处理媒体资源(放在保存方法之前)
|
||||
configServiceDirectiveService.handleMediaFile(configServiceDirective);
|
||||
log.info("服务指令保存时,pre:{},immedia:{},mp3:{},mp4:{}",configServiceDirective.getPreviewFile(),configServiceDirective.getImmediateFile(),configServiceDirective.getMp3File(),configServiceDirective.getMp4File());
|
||||
configServiceDirectiveService.save(configServiceDirective);
|
||||
if (StringUtils.isNotBlank(configServiceDirective.getBodyTags())) {
|
||||
configServiceDirectiveService.saveBodyTags(configServiceDirective);
|
||||
|
@ -123,7 +124,6 @@ public class ConfigServiceDirectiveController extends JeecgController<ConfigServ
|
|||
} else {
|
||||
configServiceDirectiveService.removeEmotionTags(configServiceDirective);
|
||||
}
|
||||
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
|
@ -137,8 +137,9 @@ public class ConfigServiceDirectiveController extends JeecgController<ConfigServ
|
|||
@ApiOperation(value = "服务指令-编辑", notes = "服务指令-编辑")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody ConfigServiceDirective configServiceDirective) {
|
||||
//处理媒体资源
|
||||
configServiceDirectiveService.handleMedia(configServiceDirective);
|
||||
//处理媒体资源(放在保存方法之前)
|
||||
configServiceDirectiveService.handleMediaFile(configServiceDirective);
|
||||
log.info("服务指令保存时,pre:{},immedia:{},mp3:{},mp4:{}",configServiceDirective.getPreviewFile(),configServiceDirective.getImmediateFile(),configServiceDirective.getMp3File(),configServiceDirective.getMp4File());
|
||||
configServiceDirectiveService.updateById(configServiceDirective);
|
||||
if (StringUtils.isNotBlank(configServiceDirective.getBodyTags())) {
|
||||
configServiceDirectiveService.saveBodyTags(configServiceDirective);
|
||||
|
|
|
@ -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,42 +122,30 @@ 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;
|
||||
//语音文件路径
|
||||
@TableField(exist = false)
|
||||
private java.lang.String mp3FileMedia;
|
||||
/**视频文件*/
|
||||
@ApiModelProperty(value = "视频文件")
|
||||
/**指令视频文件*/
|
||||
@ApiModelProperty(value = "指令视频文件")
|
||||
private java.lang.String mp4File;
|
||||
//视频文件是否变更
|
||||
@TableField(exist = false)
|
||||
private boolean mp4FileChanged;
|
||||
//视频文件路径
|
||||
@TableField(exist = false)
|
||||
private java.lang.String mp4FileMedia;
|
||||
/**预览图片*/
|
||||
@ApiModelProperty(value = "预览图片")
|
||||
/**服务指令图片*/
|
||||
@ApiModelProperty(value = "服务指令图片")
|
||||
private java.lang.String previewFile;
|
||||
//预览图片是否变更
|
||||
//服务指令图片是否变更
|
||||
@TableField(exist = false)
|
||||
private boolean previewFileChanged;
|
||||
//预览图片路径
|
||||
@TableField(exist = false)
|
||||
private java.lang.String previewFileMedia;
|
||||
/**即时指令图片*/
|
||||
@ApiModelProperty(value = "即时指令图片")
|
||||
/**即时指令图标*/
|
||||
@ApiModelProperty(value = "即时指令图标")
|
||||
private java.lang.String immediateFile;
|
||||
//即时指令图片是否变更
|
||||
//即时指令图标是否变更
|
||||
@TableField(exist = false)
|
||||
private boolean immediateFileChanged;
|
||||
//即时指令图片路径
|
||||
@TableField(exist = false)
|
||||
private java.lang.String immediateFileMedia;
|
||||
|
||||
//合并单元格用:类别合并的行数
|
||||
@TableField(exist = false)
|
||||
|
@ -174,12 +162,6 @@ public class ConfigServiceDirective implements Serializable {
|
|||
//情绪标签id,id,id
|
||||
@TableField(exist = false)
|
||||
private String emotionTags;
|
||||
@TableField(exist = false)
|
||||
//服务类别名称
|
||||
private String categoryName;
|
||||
//服务类型名称
|
||||
@TableField(exist = false)
|
||||
private String typeName;
|
||||
|
||||
|
||||
//体型标签
|
||||
|
@ -195,4 +177,20 @@ public class ConfigServiceDirective implements Serializable {
|
|||
//情绪标签字符串
|
||||
@TableField(exist = false)
|
||||
private String emotionTagsName;
|
||||
|
||||
//分类标签中文名称
|
||||
@TableField(exist = false)
|
||||
private String instructionName;
|
||||
//服务类别中文名称
|
||||
@TableField(exist = false)
|
||||
private String categoryName;
|
||||
//服务类型中文名称
|
||||
@TableField(exist = false)
|
||||
private String typeName;
|
||||
//周期类型中文名称
|
||||
@TableField(exist = false)
|
||||
private String cycleTypeName;
|
||||
//媒体资源存储路径名
|
||||
@TableField(exist = false)
|
||||
private String mediaFileSavePath;
|
||||
}
|
||||
|
|
|
@ -10,35 +10,39 @@ import java.util.List;
|
|||
/**
|
||||
* @Description: 服务指令
|
||||
* @Author: 张明远
|
||||
* @Date: 2025-03-13
|
||||
* @Date: 2025-03-13
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface IConfigServiceDirectiveService extends IService<ConfigServiceDirective> {
|
||||
|
||||
void merge(List<ConfigServiceDirective> records);
|
||||
|
||||
List<ConfigServiceDirective> pageList(ConfigServiceDirective configServiceDirective,IPage<ConfigServiceDirective> list);
|
||||
List<ConfigServiceDirective> pageList(ConfigServiceDirective configServiceDirective, IPage<ConfigServiceDirective> list);
|
||||
|
||||
/**
|
||||
* 存储体型标签数据
|
||||
*
|
||||
* @param configServiceDirective
|
||||
*/
|
||||
void saveBodyTags(ConfigServiceDirective configServiceDirective);
|
||||
|
||||
/**
|
||||
* 存储情绪标签数据
|
||||
*
|
||||
* @param configServiceDirective
|
||||
*/
|
||||
void saveEmotionTags(ConfigServiceDirective configServiceDirective);
|
||||
|
||||
/**
|
||||
* 移除改服务指令下体型标签
|
||||
*
|
||||
* @param configServiceDirective
|
||||
*/
|
||||
void removeBodyTags(ConfigServiceDirective configServiceDirective);
|
||||
|
||||
/**
|
||||
* 移除改服务指令下情绪标签
|
||||
*
|
||||
* @param configServiceDirective
|
||||
*/
|
||||
void removeEmotionTags(ConfigServiceDirective configServiceDirective);
|
||||
|
@ -53,7 +57,5 @@ public interface IConfigServiceDirectiveService extends IService<ConfigServiceDi
|
|||
|
||||
void insertAllDirectives(List<ConfigServiceDirective> directives);
|
||||
|
||||
void handleMedia(ConfigServiceDirective configServiceDirective);
|
||||
|
||||
// List<JSONObject> selectMediaList(String dataSourceCode, List<String> idList);
|
||||
void handleMediaFile(ConfigServiceDirective configServiceDirective);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.nu.modules.servicedirective.service.impl;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
|
@ -12,16 +11,16 @@ 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 org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* @Description: 服务指令
|
||||
|
@ -32,8 +31,9 @@ import java.util.stream.Stream;
|
|||
@Service
|
||||
public class ConfigServiceDirectiveServiceImpl extends ServiceImpl<ConfigServiceDirectiveMapper, ConfigServiceDirective> implements IConfigServiceDirectiveService {
|
||||
|
||||
// @Autowired
|
||||
// private IMediaManageApi mediaManageApi;
|
||||
@Value(value = "${jeecg.path.upload}")
|
||||
private String uploadpath;
|
||||
|
||||
@Autowired
|
||||
private ISysConfigApi sysConfigApi;
|
||||
@Autowired
|
||||
|
@ -56,23 +56,6 @@ public class ConfigServiceDirectiveServiceImpl extends ServiceImpl<ConfigService
|
|||
List<DirectiveEmotionTag> emotionTagList = record.getEmotionTagList();
|
||||
record.setEmotionTags(emotionTagList.stream().map(DirectiveEmotionTag::getId).collect(Collectors.joining(",")));
|
||||
});
|
||||
//处理媒体资源转换
|
||||
{
|
||||
List<String> meidsIds = list.stream().flatMap(directive -> Stream.of(directive.getMp3File(), directive.getMp4File(), directive.getPreviewFile(), directive.getImmediateFile())).filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
||||
|
||||
// if (!CollectionUtils.isEmpty(meidsIds)) {
|
||||
// List<JSONObject> mediaObjs = mediaManageApi.queryByIds(meidsIds);
|
||||
//
|
||||
// Map<String, String> idToFilePathMap = mediaObjs.stream().collect(Collectors.toMap(media -> media.getStr("id"), media -> media.getStr("filePath")));
|
||||
//
|
||||
// list.stream().forEach(record -> {
|
||||
// record.setPreviewFileMedia(idToFilePathMap.get(record.getPreviewFile()));
|
||||
// record.setImmediateFileMedia(idToFilePathMap.get(record.getImmediateFile()));
|
||||
// record.setMp3FileMedia(idToFilePathMap.get(record.getMp3File()));
|
||||
// record.setMp4FileMedia(idToFilePathMap.get(record.getMp4File()));
|
||||
// });
|
||||
// }
|
||||
}
|
||||
}
|
||||
//处理单元格合并所需数据
|
||||
merge(list);
|
||||
|
@ -242,35 +225,101 @@ public class ConfigServiceDirectiveServiceImpl extends ServiceImpl<ConfigService
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理资源文件
|
||||
* 1、检测各资源文件的存储路径是否跟路径字段的值一致
|
||||
* 2、如果不一致1)检测缺少的路径新建目录 2)然后把资源挪到新路径中 3)修改媒体资源对应字段的值的路径名
|
||||
*
|
||||
* @param configServiceDirective
|
||||
*/
|
||||
@Override
|
||||
public void handleMedia(ConfigServiceDirective configServiceDirective) {
|
||||
// Map<String, String> params = Maps.newHashMap();
|
||||
// params.put("sysFunc", "directive");
|
||||
// if (configServiceDirective.isImmediateFileChanged()) {
|
||||
// params.put("fileName", configServiceDirective.getDirectiveName() + "预览图片");
|
||||
// params.put("descr", "服务指令用户上传图片:" + configServiceDirective.getDirectiveName() + "预览图片");
|
||||
// configServiceDirective.setImmediateFile((mediaManageApi.saveByPath(configServiceDirective.getImmediateFileMedia(), params)));
|
||||
// }
|
||||
// if (configServiceDirective.isPreviewFileChanged()) {
|
||||
// params.put("fileName", configServiceDirective.getDirectiveName() + "即时指令图片");
|
||||
// params.put("descr", "服务指令用户上传图片:" + configServiceDirective.getDirectiveName() + "即时指令图片");
|
||||
// configServiceDirective.setPreviewFile(mediaManageApi.saveByPath(configServiceDirective.getPreviewFileMedia(), params));
|
||||
// }
|
||||
// if (configServiceDirective.isMp3FileChanged()) {
|
||||
// params.put("fileName", configServiceDirective.getDirectiveName() + "音频文件");
|
||||
// params.put("descr", "服务指令用户上传音频:" + configServiceDirective.getDirectiveName() + "音频文件");
|
||||
// configServiceDirective.setMp3File(mediaManageApi.saveByPath(configServiceDirective.getMp3FileMedia(), params));
|
||||
// }
|
||||
// if (configServiceDirective.isMp4FileChanged()) {
|
||||
// params.put("fileName", configServiceDirective.getDirectiveName() + "视频文件");
|
||||
// params.put("descr", "服务指令用户上传视频:" + configServiceDirective.getDirectiveName() + "视频文件");
|
||||
// configServiceDirective.setMp4File(mediaManageApi.saveByPath(configServiceDirective.getMp4FileMedia(), params));
|
||||
// }
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public List<JSONObject> selectMediaList(String dataSourceCode, List<String> idList) {
|
||||
// return mediaManageApi.selectByDirectiveIds(dataSourceCode, idList);
|
||||
// }
|
||||
/**
|
||||
* 处理单个文件,检查路径是否需要迁移
|
||||
* @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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -254,13 +254,10 @@ jeecg:
|
|||
pc: http://localhost:3100
|
||||
app: http://localhost:8051
|
||||
path:
|
||||
#服务指令上传目录
|
||||
directivepath: /cache/nu/opt/upFiles/directive
|
||||
#文件上传根目录 设置
|
||||
upload: /cache/ope/opt/upFiles
|
||||
#webapp文件路径
|
||||
webapp: /cache/ope/opt/webapp
|
||||
webapp1: /abc
|
||||
shiro:
|
||||
excludeUrls: /test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/bigscreen/category/**,/bigscreen/visual/**,/bigscreen/map/**,/jmreport/bigscreen2/**
|
||||
#阿里云oss存储和大鱼短信秘钥配置
|
||||
|
|
|
@ -253,8 +253,6 @@ jeecg:
|
|||
pc: http://localhost:3100
|
||||
app: http://localhost:8051
|
||||
path:
|
||||
#服务指令上传目录
|
||||
directivepath: /opt/upFiles/directive
|
||||
#文件上传根目录 设置
|
||||
upload: /opt/ope/upFiles
|
||||
#webapp文件路径
|
||||
|
|
Loading…
Reference in New Issue