Compare commits

..

No commits in common. "dafe6f3c88abb1756661ae2a1811516f5bf2607a" and "1c2c70d07791b702b9819b7ff9a0d9ad984b2cef" have entirely different histories.

6 changed files with 102 additions and 147 deletions

View File

@ -38,7 +38,7 @@ import java.util.stream.Collectors;
*/ */
@Api(tags = "服务指令") @Api(tags = "服务指令")
@RestController @RestController
@RequestMapping("/services/serviceDirective") @RequestMapping("/services/serviceDirective/configServiceDirective")
@Slf4j @Slf4j
public class ConfigServiceDirectiveController extends JeecgController<ConfigServiceDirective, IConfigServiceDirectiveService> { public class ConfigServiceDirectiveController extends JeecgController<ConfigServiceDirective, IConfigServiceDirectiveService> {
@Autowired @Autowired
@ -78,18 +78,18 @@ public class ConfigServiceDirectiveController extends JeecgController<ConfigServ
directiveIds = configServiceDirectiveService.queryDirectiveIdByBodyTagIds(configServiceDirective.getBodyTags()); directiveIds = configServiceDirectiveService.queryDirectiveIdByBodyTagIds(configServiceDirective.getBodyTags());
if (directiveIds != null && !directiveIds.isEmpty()) { if (directiveIds != null && !directiveIds.isEmpty()) {
queryWrapper.in("id", directiveIds.stream().map(ConfigServiceDirective::getId).collect(Collectors.toList())); 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())) { if (StringUtils.isNotBlank(configServiceDirective.getEmotionTags())) {
directiveIds = configServiceDirectiveService.queryDirectiveIdByEmotionTagIds(configServiceDirective.getEmotionTags()); directiveIds = configServiceDirectiveService.queryDirectiveIdByEmotionTagIds(configServiceDirective.getEmotionTags());
if (directiveIds != null && !directiveIds.isEmpty() && StringUtils.isNotBlank(configServiceDirective.getEmotionTags())) { if (directiveIds != null && !directiveIds.isEmpty() && StringUtils.isNotBlank(configServiceDirective.getEmotionTags())) {
queryWrapper.in("id", directiveIds.stream().map(ConfigServiceDirective::getId).collect(Collectors.toList())); 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); Page<ConfigServiceDirective> page = new Page<ConfigServiceDirective>(pageNo, pageSize);
@ -109,9 +109,8 @@ public class ConfigServiceDirectiveController extends JeecgController<ConfigServ
@ApiOperation(value = "服务指令-添加", notes = "服务指令-添加") @ApiOperation(value = "服务指令-添加", notes = "服务指令-添加")
@PostMapping(value = "/add") @PostMapping(value = "/add")
public Result<String> add(@RequestBody ConfigServiceDirective configServiceDirective) { public Result<String> add(@RequestBody ConfigServiceDirective configServiceDirective) {
//处理媒体资源放在保存方法之前 //处理媒体资源
configServiceDirectiveService.handleMediaFile(configServiceDirective); configServiceDirectiveService.handleMedia(configServiceDirective);
log.info("服务指令保存时pre:{},immedia:{},mp3:{},mp4:{}",configServiceDirective.getPreviewFile(),configServiceDirective.getImmediateFile(),configServiceDirective.getMp3File(),configServiceDirective.getMp4File());
configServiceDirectiveService.save(configServiceDirective); configServiceDirectiveService.save(configServiceDirective);
if (StringUtils.isNotBlank(configServiceDirective.getBodyTags())) { if (StringUtils.isNotBlank(configServiceDirective.getBodyTags())) {
configServiceDirectiveService.saveBodyTags(configServiceDirective); configServiceDirectiveService.saveBodyTags(configServiceDirective);
@ -124,6 +123,7 @@ public class ConfigServiceDirectiveController extends JeecgController<ConfigServ
} else { } else {
configServiceDirectiveService.removeEmotionTags(configServiceDirective); configServiceDirectiveService.removeEmotionTags(configServiceDirective);
} }
return Result.OK("添加成功!"); return Result.OK("添加成功!");
} }
@ -137,9 +137,8 @@ public class ConfigServiceDirectiveController extends JeecgController<ConfigServ
@ApiOperation(value = "服务指令-编辑", notes = "服务指令-编辑") @ApiOperation(value = "服务指令-编辑", notes = "服务指令-编辑")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST}) @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
public Result<String> edit(@RequestBody ConfigServiceDirective configServiceDirective) { public Result<String> edit(@RequestBody ConfigServiceDirective configServiceDirective) {
//处理媒体资源放在保存方法之前 //处理媒体资源
configServiceDirectiveService.handleMediaFile(configServiceDirective); configServiceDirectiveService.handleMedia(configServiceDirective);
log.info("服务指令保存时pre:{},immedia:{},mp3:{},mp4:{}",configServiceDirective.getPreviewFile(),configServiceDirective.getImmediateFile(),configServiceDirective.getMp3File(),configServiceDirective.getMp4File());
configServiceDirectiveService.updateById(configServiceDirective); configServiceDirectiveService.updateById(configServiceDirective);
if (StringUtils.isNotBlank(configServiceDirective.getBodyTags())) { if (StringUtils.isNotBlank(configServiceDirective.getBodyTags())) {
configServiceDirectiveService.saveBodyTags(configServiceDirective); configServiceDirectiveService.saveBodyTags(configServiceDirective);

View File

@ -85,9 +85,9 @@ public class ConfigServiceDirective implements Serializable {
@Excel(name = "排序", width = 15) @Excel(name = "排序", width = 15)
@ApiModelProperty(value = "排序") @ApiModelProperty(value = "排序")
private java.lang.Integer sort; private java.lang.Integer sort;
/**服务描述*/ /**服务说明*/
@Excel(name = "服务描述", width = 15) @Excel(name = "服务说明", width = 15)
@ApiModelProperty(value = "服务描述") @ApiModelProperty(value = "服务说明")
private java.lang.String serviceContent; private java.lang.String serviceContent;
/**服务时长(分钟)*/ /**服务时长(分钟)*/
@Excel(name = "服务时长(分钟)", width = 15) @Excel(name = "服务时长(分钟)", width = 15)
@ -122,30 +122,42 @@ public class ConfigServiceDirective implements Serializable {
/**所属部门*/ /**所属部门*/
@ApiModelProperty(value = "所属部门") @ApiModelProperty(value = "所属部门")
private java.lang.String sysOrgCode; private java.lang.String sysOrgCode;
/**指令音频文件*/ /**语音文件*/
@ApiModelProperty(value = "指令音频文件") @ApiModelProperty(value = "语音文件")
private java.lang.String mp3File; private java.lang.String mp3File;
//语音文件是否变更 //语音文件是否变更
@TableField(exist = false) @TableField(exist = false)
private boolean mp3FileChanged; private boolean mp3FileChanged;
/**指令视频文件*/ //语音文件路径
@ApiModelProperty(value = "指令视频文件") @TableField(exist = false)
private java.lang.String mp3FileMedia;
/**视频文件*/
@ApiModelProperty(value = "视频文件")
private java.lang.String mp4File; private java.lang.String mp4File;
//视频文件是否变更 //视频文件是否变更
@TableField(exist = false) @TableField(exist = false)
private boolean mp4FileChanged; private boolean mp4FileChanged;
/**服务指令图片*/ //视频文件路径
@ApiModelProperty(value = "服务指令图片") @TableField(exist = false)
private java.lang.String mp4FileMedia;
/**预览图片*/
@ApiModelProperty(value = "预览图片")
private java.lang.String previewFile; private java.lang.String previewFile;
//服务指令图片是否变更 //预览图片是否变更
@TableField(exist = false) @TableField(exist = false)
private boolean previewFileChanged; private boolean previewFileChanged;
/**即时指令图标*/ //预览图片路径
@ApiModelProperty(value = "即时指令图标") @TableField(exist = false)
private java.lang.String previewFileMedia;
/**即时指令图片*/
@ApiModelProperty(value = "即时指令图片")
private java.lang.String immediateFile; private java.lang.String immediateFile;
//即时指令图标是否变更 //即时指令图是否变更
@TableField(exist = false) @TableField(exist = false)
private boolean immediateFileChanged; private boolean immediateFileChanged;
//即时指令图片路径
@TableField(exist = false)
private java.lang.String immediateFileMedia;
//合并单元格用类别合并的行数 //合并单元格用类别合并的行数
@TableField(exist = false) @TableField(exist = false)
@ -162,6 +174,12 @@ public class ConfigServiceDirective implements Serializable {
//情绪标签id,id,id //情绪标签id,id,id
@TableField(exist = false) @TableField(exist = false)
private String emotionTags; private String emotionTags;
@TableField(exist = false)
//服务类别名称
private String categoryName;
//服务类型名称
@TableField(exist = false)
private String typeName;
//体型标签 //体型标签
@ -177,20 +195,4 @@ public class ConfigServiceDirective implements Serializable {
//情绪标签字符串 //情绪标签字符串
@TableField(exist = false) @TableField(exist = false)
private String emotionTagsName; 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;
} }

View File

@ -10,39 +10,35 @@ import java.util.List;
/** /**
* @Description: 服务指令 * @Description: 服务指令
* @Author: 张明远 * @Author: 张明远
* @Date: 2025-03-13 * @Date: 2025-03-13
* @Version: V1.0 * @Version: V1.0
*/ */
public interface IConfigServiceDirectiveService extends IService<ConfigServiceDirective> { public interface IConfigServiceDirectiveService extends IService<ConfigServiceDirective> {
void merge(List<ConfigServiceDirective> records); void merge(List<ConfigServiceDirective> records);
List<ConfigServiceDirective> pageList(ConfigServiceDirective configServiceDirective, IPage<ConfigServiceDirective> list); List<ConfigServiceDirective> pageList(ConfigServiceDirective configServiceDirective,IPage<ConfigServiceDirective> list);
/** /**
* 存储体型标签数据 * 存储体型标签数据
*
* @param configServiceDirective * @param configServiceDirective
*/ */
void saveBodyTags(ConfigServiceDirective configServiceDirective); void saveBodyTags(ConfigServiceDirective configServiceDirective);
/** /**
* 存储情绪标签数据 * 存储情绪标签数据
*
* @param configServiceDirective * @param configServiceDirective
*/ */
void saveEmotionTags(ConfigServiceDirective configServiceDirective); void saveEmotionTags(ConfigServiceDirective configServiceDirective);
/** /**
* 移除改服务指令下体型标签 * 移除改服务指令下体型标签
*
* @param configServiceDirective * @param configServiceDirective
*/ */
void removeBodyTags(ConfigServiceDirective configServiceDirective); void removeBodyTags(ConfigServiceDirective configServiceDirective);
/** /**
* 移除改服务指令下情绪标签 * 移除改服务指令下情绪标签
*
* @param configServiceDirective * @param configServiceDirective
*/ */
void removeEmotionTags(ConfigServiceDirective configServiceDirective); void removeEmotionTags(ConfigServiceDirective configServiceDirective);
@ -57,5 +53,7 @@ public interface IConfigServiceDirectiveService extends IService<ConfigServiceDi
void insertAllDirectives(List<ConfigServiceDirective> directives); void insertAllDirectives(List<ConfigServiceDirective> directives);
void handleMediaFile(ConfigServiceDirective configServiceDirective); void handleMedia(ConfigServiceDirective configServiceDirective);
// List<JSONObject> selectMediaList(String dataSourceCode, List<String> idList);
} }

View File

@ -1,5 +1,6 @@
package com.nu.modules.servicedirective.service.impl; package com.nu.modules.servicedirective.service.impl;
import cn.hutool.json.JSONObject;
import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
@ -11,16 +12,16 @@ import com.nu.modules.servicedirective.mapper.ConfigServiceDirectiveMapper;
import com.nu.modules.servicedirective.service.IConfigServiceDirectiveService; import com.nu.modules.servicedirective.service.IConfigServiceDirectiveService;
import com.nu.modules.sysconfig.ISysConfigApi; import com.nu.modules.sysconfig.ISysConfigApi;
import com.nu.utils.RabbitMQUtil; import com.nu.utils.RabbitMQUtil;
import org.apache.commons.lang.StringUtils;
import org.jeecg.common.system.api.ISysBaseAPI; import org.jeecg.common.system.api.ISysBaseAPI;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; 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.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
/** /**
* @Description: 服务指令 * @Description: 服务指令
@ -31,9 +32,8 @@ import java.util.stream.Collectors;
@Service @Service
public class ConfigServiceDirectiveServiceImpl extends ServiceImpl<ConfigServiceDirectiveMapper, ConfigServiceDirective> implements IConfigServiceDirectiveService { public class ConfigServiceDirectiveServiceImpl extends ServiceImpl<ConfigServiceDirectiveMapper, ConfigServiceDirective> implements IConfigServiceDirectiveService {
@Value(value = "${jeecg.path.upload}") // @Autowired
private String uploadpath; // private IMediaManageApi mediaManageApi;
@Autowired @Autowired
private ISysConfigApi sysConfigApi; private ISysConfigApi sysConfigApi;
@Autowired @Autowired
@ -56,6 +56,23 @@ public class ConfigServiceDirectiveServiceImpl extends ServiceImpl<ConfigService
List<DirectiveEmotionTag> emotionTagList = record.getEmotionTagList(); List<DirectiveEmotionTag> emotionTagList = record.getEmotionTagList();
record.setEmotionTags(emotionTagList.stream().map(DirectiveEmotionTag::getId).collect(Collectors.joining(","))); 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); merge(list);
@ -225,101 +242,35 @@ public class ConfigServiceDirectiveServiceImpl extends ServiceImpl<ConfigService
}); });
} }
/**
* 处理资源文件
* 1检测各资源文件的存储路径是否跟路径字段的值一致
* 2如果不一致1检测缺少的路径新建目录 2然后把资源挪到新路径中 3修改媒体资源对应字段的值的路径名
*
* @param configServiceDirective
*/
@Override @Override
public void handleMediaFile(ConfigServiceDirective configServiceDirective) { public void handleMedia(ConfigServiceDirective configServiceDirective) {
//上传根路径 // Map<String, String> params = Maps.newHashMap();
String path = uploadpath; // params.put("sysFunc", "directive");
//需要存储的路径 // if (configServiceDirective.isImmediateFileChanged()) {
String mediaFileSavePath = configServiceDirective.getMediaFileSavePath(); // params.put("fileName", configServiceDirective.getDirectiveName() + "预览图片");
//服务指令图片 // params.put("descr", "服务指令用户上传图片:" + configServiceDirective.getDirectiveName() + "预览图片");
String previewFile = configServiceDirective.getPreviewFile(); // configServiceDirective.setImmediateFile((mediaManageApi.saveByPath(configServiceDirective.getImmediateFileMedia(), params)));
//即时指令图标 // }
String immediateFile = configServiceDirective.getImmediateFile(); // if (configServiceDirective.isPreviewFileChanged()) {
//指令音频文件 // params.put("fileName", configServiceDirective.getDirectiveName() + "即时指令图片");
String mp3File = configServiceDirective.getMp3File(); // params.put("descr", "服务指令用户上传图片:" + configServiceDirective.getDirectiveName() + "即时指令图片");
//指令视频文件 // configServiceDirective.setPreviewFile(mediaManageApi.saveByPath(configServiceDirective.getPreviewFileMedia(), params));
String mp4File = configServiceDirective.getMp4File(); // }
// if (configServiceDirective.isMp3FileChanged()) {
// 处理每个文件并获取更新后的路径 // params.put("fileName", configServiceDirective.getDirectiveName() + "音频文件");
String newPreviewFile = processFile(path, mediaFileSavePath, previewFile); // params.put("descr", "服务指令用户上传音频:" + configServiceDirective.getDirectiveName() + "音频文件");
String newImmediateFile = processFile(path, mediaFileSavePath, immediateFile); // configServiceDirective.setMp3File(mediaManageApi.saveByPath(configServiceDirective.getMp3FileMedia(), params));
String newMp3File = processFile(path, mediaFileSavePath, mp3File); // }
String newMp4File = processFile(path, mediaFileSavePath, mp4File); // if (configServiceDirective.isMp4FileChanged()) {
// params.put("fileName", configServiceDirective.getDirectiveName() + "视频文件");
// 如果有变化更新ConfigServiceDirective对象 // params.put("descr", "服务指令用户上传视频:" + configServiceDirective.getDirectiveName() + "视频文件");
if (newPreviewFile != null) { // configServiceDirective.setMp4File(mediaManageApi.saveByPath(configServiceDirective.getMp4FileMedia(), params));
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) {
* @param basePath 基础路径 // return mediaManageApi.selectByDirectiveIds(dataSourceCode, idList);
* @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;
}
} }

View File

@ -254,10 +254,13 @@ jeecg:
pc: http://localhost:3100 pc: http://localhost:3100
app: http://localhost:8051 app: http://localhost:8051
path: path:
#服务指令上传目录
directivepath: /cache/nu/opt/upFiles/directive
#文件上传根目录 设置 #文件上传根目录 设置
upload: /cache/ope/opt/upFiles upload: /cache/ope/opt/upFiles
#webapp文件路径 #webapp文件路径
webapp: /cache/ope/opt/webapp webapp: /cache/ope/opt/webapp
webapp1: /abc
shiro: shiro:
excludeUrls: /test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/bigscreen/category/**,/bigscreen/visual/**,/bigscreen/map/**,/jmreport/bigscreen2/** excludeUrls: /test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/bigscreen/category/**,/bigscreen/visual/**,/bigscreen/map/**,/jmreport/bigscreen2/**
#阿里云oss存储和大鱼短信秘钥配置 #阿里云oss存储和大鱼短信秘钥配置

View File

@ -253,6 +253,8 @@ jeecg:
pc: http://localhost:3100 pc: http://localhost:3100
app: http://localhost:8051 app: http://localhost:8051
path: path:
#服务指令上传目录
directivepath: /opt/upFiles/directive
#文件上传根目录 设置 #文件上传根目录 设置
upload: /opt/ope/upFiles upload: /opt/ope/upFiles
#webapp文件路径 #webapp文件路径