服务指令同步
This commit is contained in:
parent
53fbd4c39e
commit
05c000f53d
|
|
@ -7,63 +7,131 @@ import java.io.Serializable;
|
|||
/**
|
||||
* @Description: 服务指令审核
|
||||
* @Author: 张明远
|
||||
* @Date: 2025-07-14
|
||||
* @Date: 2025-07-14
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
public class DirectiveAsyncMQDto implements Serializable {
|
||||
/**id*/
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private String id;
|
||||
/**服务类别id*/
|
||||
/**
|
||||
* 服务类别id
|
||||
*/
|
||||
private String categoryId;
|
||||
/**服务类型id*/
|
||||
/**
|
||||
* 服务类型id
|
||||
*/
|
||||
private String typeId;
|
||||
/**分类标签*/
|
||||
/**
|
||||
* 分类标签
|
||||
*/
|
||||
private String instructionTagId;
|
||||
/**服务指令名称*/
|
||||
/**
|
||||
* 服务指令名称
|
||||
*/
|
||||
private String directiveName;
|
||||
/**收费价格*/
|
||||
/**
|
||||
* 收费价格
|
||||
*/
|
||||
private java.math.BigDecimal tollPrice;
|
||||
/**提成价格*/
|
||||
/**
|
||||
* 提成价格
|
||||
*/
|
||||
private java.math.BigDecimal comPrice;
|
||||
/**是否参与医保报销 0不报销 1报销*/
|
||||
/**
|
||||
* 是否参与医保报销 0不报销 1报销
|
||||
*/
|
||||
private String izReimbursement;
|
||||
/**是否参与机构优惠 0不参与 1参与*/
|
||||
/**
|
||||
* 是否参与机构优惠 0不参与 1参与
|
||||
*/
|
||||
private String izPreferential;
|
||||
/**收费频次 1按次收费 2按天收费*/
|
||||
/**
|
||||
* 收费频次 1按次收费 2按天收费
|
||||
*/
|
||||
private String chargingFrequency;
|
||||
/**周期类型 1日常护理 2周期护理 3即时护理*/
|
||||
/**
|
||||
* 周期类型 1日常护理 2周期护理 3即时护理
|
||||
*/
|
||||
private String cycleType;
|
||||
/**排序*/
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
/**服务描述*/
|
||||
/**
|
||||
* 服务描述
|
||||
*/
|
||||
private String serviceContent;
|
||||
/**服务时长(分钟)*/
|
||||
/**
|
||||
* 服务时长(分钟)
|
||||
*/
|
||||
private String serviceDuration;
|
||||
/**指令状态*/
|
||||
/**
|
||||
* 指令状态
|
||||
*/
|
||||
private String status;
|
||||
/**是否启用 0启用 1未启用*/
|
||||
/**
|
||||
* 是否启用 0启用 1未启用
|
||||
*/
|
||||
private String izEnabled;
|
||||
/**是否删除*/
|
||||
/**
|
||||
* 是否删除
|
||||
*/
|
||||
private String delFlag;
|
||||
/**创建人*/
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
/**创建日期*/
|
||||
/**
|
||||
* 创建日期
|
||||
*/
|
||||
private java.util.Date createTime;
|
||||
/**更新人*/
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
/**更新日期*/
|
||||
/**
|
||||
* 更新日期
|
||||
*/
|
||||
private java.util.Date updateTime;
|
||||
/**所属部门*/
|
||||
/**
|
||||
* 所属部门
|
||||
*/
|
||||
private String sysOrgCode;
|
||||
/**指令音频文件*/
|
||||
/**
|
||||
* 指令音频文件
|
||||
*/
|
||||
private String mp3File;
|
||||
/**指令视频文件*/
|
||||
/**
|
||||
* 指令视频文件
|
||||
*/
|
||||
private String mp4File;
|
||||
/**服务指令图片*/
|
||||
/**
|
||||
* 服务指令图片
|
||||
*/
|
||||
private String previewFile;
|
||||
/**即时指令图标*/
|
||||
/**
|
||||
* 即时指令图标
|
||||
*/
|
||||
private String immediateFile;
|
||||
/**
|
||||
* 指令音频文件md5
|
||||
*/
|
||||
private java.lang.String mp3FileMd5;
|
||||
/**
|
||||
* 指令视频文件md5
|
||||
*/
|
||||
private java.lang.String mp4FileMd5;
|
||||
/**
|
||||
* 服务指令图片md5
|
||||
*/
|
||||
private java.lang.String previewFileMd5;
|
||||
/**
|
||||
* 即时指令图标md5
|
||||
*/
|
||||
private java.lang.String immediateFileMd5;
|
||||
|
||||
|
||||
//分类标签中文名称
|
||||
|
|
|
|||
|
|
@ -127,8 +127,8 @@ public class ConfigServiceDirectiveController extends JeecgController<ConfigServ
|
|||
configServiceDirective.setSysOrgCode(deptInfo.getString("code"));
|
||||
//设置为“未授权”
|
||||
configServiceDirective.setStatus("1");
|
||||
//业务平台添加时无媒体资源 处理媒体资源(放在保存方法之前)
|
||||
// configServiceDirectiveService.handleMediaFile(configServiceDirective);
|
||||
//处理媒体资源(放在保存方法之前)
|
||||
configServiceDirectiveService.handleMediaFile(configServiceDirective);
|
||||
configServiceDirectiveService.save(configServiceDirective);
|
||||
if (StringUtils.isNotBlank(configServiceDirective.getBodyTags())) {
|
||||
configServiceDirectiveService.saveBodyTags(configServiceDirective);
|
||||
|
|
@ -162,8 +162,8 @@ 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.handleMediaFile(configServiceDirective);
|
||||
//处理媒体资源(放在保存方法之前)
|
||||
configServiceDirectiveService.handleMediaFile(configServiceDirective);
|
||||
configServiceDirectiveService.updateById(configServiceDirective);
|
||||
if (StringUtils.isNotBlank(configServiceDirective.getBodyTags())) {
|
||||
configServiceDirectiveService.saveBodyTags(configServiceDirective);
|
||||
|
|
|
|||
|
|
@ -148,6 +148,20 @@ public class ConfigServiceDirective implements Serializable {
|
|||
/**即时指令图标*/
|
||||
@ApiModelProperty(value = "即时指令图标")
|
||||
private java.lang.String immediateFile;
|
||||
/**指令音频文件md5*/
|
||||
@ApiModelProperty(value = "指令音频文件md5")
|
||||
private java.lang.String mp3FileMd5;
|
||||
/**指令视频文件md5*/
|
||||
@ApiModelProperty(value = "指令视频文件md5")
|
||||
private java.lang.String mp4FileMd5;
|
||||
/**服务指令图片md5*/
|
||||
@ApiModelProperty(value = "服务指令图片md5")
|
||||
private java.lang.String previewFileMd5;
|
||||
/**即时指令图标md5*/
|
||||
@ApiModelProperty(value = "即时指令图标md5")
|
||||
private java.lang.String immediateFileMd5;
|
||||
|
||||
|
||||
//即时指令图标是否变更
|
||||
@TableField(exist = false)
|
||||
private boolean immediateFileChanged;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,9 @@ import org.springframework.context.annotation.Lazy;
|
|||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
|
@ -267,7 +269,7 @@ public class ConfigServiceDirectiveServiceImpl extends ServiceImpl<ConfigService
|
|||
//上传根路径
|
||||
String path = uploadpath;
|
||||
//需要存储的路径
|
||||
String mediaFileSavePath = configServiceDirective.getMediaFileSavePath();
|
||||
String mediaFileSavePath = configServiceDirective.getMediaFileSavePath() + configServiceDirective.getId();
|
||||
//服务指令图片
|
||||
String previewFile = configServiceDirective.getPreviewFile();
|
||||
//即时指令图标
|
||||
|
|
@ -278,23 +280,27 @@ public class ConfigServiceDirectiveServiceImpl extends ServiceImpl<ConfigService
|
|||
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);
|
||||
Map<String, String> newPreviewFileMap = processFile(path, mediaFileSavePath, previewFile);
|
||||
Map<String, String> newImmediateFileMap = processFile(path, mediaFileSavePath, immediateFile);
|
||||
Map<String, String> newMp3FileMap = processFile(path, mediaFileSavePath, mp3File);
|
||||
Map<String, String> newMp4FileMap = processFile(path, mediaFileSavePath, mp4File);
|
||||
|
||||
// 如果有变化,更新ConfigServiceDirective对象
|
||||
if (newPreviewFile != null) {
|
||||
configServiceDirective.setPreviewFile(newPreviewFile);
|
||||
if (newPreviewFileMap != null) {
|
||||
configServiceDirective.setPreviewFile(newPreviewFileMap.get("path"));
|
||||
configServiceDirective.setPreviewFileMd5(newPreviewFileMap.get("md5"));
|
||||
}
|
||||
if (newImmediateFile != null) {
|
||||
configServiceDirective.setImmediateFile(newImmediateFile);
|
||||
if (newImmediateFileMap != null) {
|
||||
configServiceDirective.setImmediateFile(newImmediateFileMap.get("path"));
|
||||
configServiceDirective.setImmediateFileMd5(newImmediateFileMap.get("md5"));
|
||||
}
|
||||
if (newMp3File != null) {
|
||||
configServiceDirective.setMp3File(newMp3File);
|
||||
if (newMp3FileMap != null) {
|
||||
configServiceDirective.setMp3File(newMp3FileMap.get("path"));
|
||||
configServiceDirective.setMp3FileMd5(newMp3FileMap.get("md5"));
|
||||
}
|
||||
if (newMp4File != null) {
|
||||
configServiceDirective.setMp4File(newMp4File);
|
||||
if (newMp4FileMap != null) {
|
||||
configServiceDirective.setMp4File(newMp4FileMap.get("path"));
|
||||
configServiceDirective.setMp4FileMd5(newMp4FileMap.get("md5"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -306,7 +312,7 @@ public class ConfigServiceDirectiveServiceImpl extends ServiceImpl<ConfigService
|
|||
* @param filePath 文件路径
|
||||
* @return 如果路径有变化返回新路径,否则返回null
|
||||
*/
|
||||
private String processFile(String basePath, String targetDir, String filePath) {
|
||||
private Map<String, String> processFile(String basePath, String targetDir, String filePath) {
|
||||
if (StringUtils.isBlank(filePath)) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -331,6 +337,9 @@ public class ConfigServiceDirectiveServiceImpl extends ServiceImpl<ConfigService
|
|||
// 移动文件
|
||||
File oldFile = new File(oldFullPath);
|
||||
if (oldFile.exists()) {
|
||||
// 计算原文件的MD5
|
||||
String md5 = calculateMD5(oldFile);
|
||||
|
||||
File newFile = new File(newFullPath);
|
||||
|
||||
// 如果目标文件已存在,先删除
|
||||
|
|
@ -341,8 +350,11 @@ public class ConfigServiceDirectiveServiceImpl extends ServiceImpl<ConfigService
|
|||
// 移动文件
|
||||
Files.move(oldFile.toPath(), newFile.toPath());
|
||||
|
||||
// 返回新的相对路径
|
||||
return newRelativePath;
|
||||
// 返回包含新路径和MD5的Map
|
||||
Map<String, String> result = new HashMap<>();
|
||||
result.put("path", newRelativePath);
|
||||
result.put("md5", md5);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
|
@ -353,6 +365,23 @@ public class ConfigServiceDirectiveServiceImpl extends ServiceImpl<ConfigService
|
|||
return null;
|
||||
}
|
||||
|
||||
private String calculateMD5(File file) throws Exception {
|
||||
try (InputStream is = Files.newInputStream(file.toPath())) {
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
byte[] buffer = new byte[8192];
|
||||
int read;
|
||||
while ((read = is.read(buffer)) != -1) {
|
||||
md.update(buffer, 0, read);
|
||||
}
|
||||
byte[] md5 = md.digest();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (byte b : md5) {
|
||||
sb.append(String.format("%02x", b));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void auditPass(DirectiveAsyncMQDto dto) {
|
||||
//将相应字典项改为已授权
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.nu.mq.directive.listener;
|
|||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.nu.dto.*;
|
||||
import com.nu.modules.directivetag.body.entity.DirectiveBodyTag;
|
||||
|
|
@ -12,6 +13,7 @@ import com.nu.modules.directivetag.emotion.entity.DirectiveEmotionTagRelation;
|
|||
import com.nu.modules.directivetag.emotion.service.IDirectiveEmotionTagService;
|
||||
import com.nu.modules.instructiontag.entity.InstructionTag;
|
||||
import com.nu.modules.instructiontag.service.IInstructionTagService;
|
||||
import com.nu.modules.mediaasyncerrorlog.entity.MediaAsyncErrorLog;
|
||||
import com.nu.modules.mediaasyncerrorlog.service.IMediaAsyncErrorLogService;
|
||||
import com.nu.modules.servicecategory.entity.ConfigServiceCategory;
|
||||
import com.nu.modules.servicecategory.service.IConfigServiceCategoryService;
|
||||
|
|
@ -19,7 +21,10 @@ import com.nu.modules.servicedirective.entity.ConfigServiceDirective;
|
|||
import com.nu.modules.servicedirective.service.IConfigServiceDirectiveService;
|
||||
import com.nu.modules.servicetype.entity.ConfigServiceType;
|
||||
import com.nu.modules.servicetype.service.IConfigServiceTypeService;
|
||||
import com.nu.modules.sysconfig.entity.SysConfig;
|
||||
import com.nu.modules.sysconfig.service.ISysConfigService;
|
||||
import com.nu.utils.FileDownloader;
|
||||
import com.nu.utils.SafetyUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.compress.utils.Lists;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
|
@ -32,6 +37,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
|
@ -97,127 +105,127 @@ public class DirectiveMQListener {
|
|||
// directiveService.updateById(configServiceDirective);
|
||||
// }
|
||||
//
|
||||
// @RabbitListener(
|
||||
// bindings = @QueueBinding(
|
||||
// value = @Queue(name = "#{directiveAsyncDQNP.getCreateMediaQueueName()}"),
|
||||
// exchange = @Exchange(name = "hldy.directive", type = ExchangeTypes.DIRECT),
|
||||
// key = "#{directiveAsyncDQNP.getCreateMediaKeyName()}"
|
||||
// ),
|
||||
// errorHandler = "directiveMQErrorHandler"
|
||||
// )
|
||||
// public void handleCreateMedia(DirectiveAsyncMQDto dto) {
|
||||
// //更新服务指令媒体资源字段
|
||||
// ConfigServiceDirective configServiceDirective = new ConfigServiceDirective();
|
||||
// configServiceDirective.setId(dto.getId());
|
||||
// configServiceDirective.setPreviewFile(dto.getPreviewFile());//服务指令图片
|
||||
// configServiceDirective.setServiceContent(dto.getServiceContent());//服务指令说明
|
||||
// configServiceDirective.setImmediateFile(dto.getImmediateFile());//即时指令图标
|
||||
// configServiceDirective.setMp3File(dto.getMp3File());//指令音频文件
|
||||
// configServiceDirective.setMp4File(dto.getMp4File());//指令视频文件
|
||||
// directiveService.updateById(configServiceDirective);
|
||||
//
|
||||
// //拉取媒体资源至本地目录
|
||||
// {
|
||||
// LambdaQueryWrapper<SysConfig> qw = new LambdaQueryWrapper<>();
|
||||
// qw.eq(SysConfig::getDelFlag, "0");
|
||||
// qw.eq(SysConfig::getConfigKey, "ope_open_url");
|
||||
// SysConfig urlObj = sysConfigService.getOne(qw);
|
||||
// //试验田协议+域名(/ip+端口)
|
||||
// String baseUrl = urlObj.getConfigValue();
|
||||
// if (baseUrl.endsWith("/")) {
|
||||
// baseUrl = baseUrl.substring(0, baseUrl.length() - 1); // 移除末尾斜杠
|
||||
// }
|
||||
//
|
||||
// //处理服务指令图片
|
||||
// String previewFile = dto.getPreviewFile();
|
||||
// if (StringUtils.isNotBlank(previewFile)) {
|
||||
// String url = baseUrl + "/sys/common/open/static/" + URLEncoder.encode(previewFile, StandardCharsets.UTF_8).replace("%2F", "/") + "?name=" + SafetyUtil.getSecureKey();
|
||||
// if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) {
|
||||
// upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1);
|
||||
// }
|
||||
// String filePath = previewFile.substring(0, previewFile.lastIndexOf("/"));
|
||||
// String fileName = previewFile.substring(previewFile.lastIndexOf("/") + 1);
|
||||
// if (filePath.startsWith("/") || filePath.startsWith("\\")) {
|
||||
// filePath = filePath.substring(1);
|
||||
// }
|
||||
// try {
|
||||
// FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath, fileName);
|
||||
// } catch (Exception e) {
|
||||
// MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
|
||||
// mediaAsyncErrorLog.setMediaid(previewFile);
|
||||
// mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
|
||||
// e.printStackTrace();
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// }
|
||||
// //处理即时指令图标
|
||||
// String immediateFile = dto.getImmediateFile();
|
||||
// if (StringUtils.isNotBlank(immediateFile)) {
|
||||
// String url = baseUrl + "/sys/common/open/static/" + URLEncoder.encode(immediateFile, StandardCharsets.UTF_8).replace("%2F", "/") + "?name=" + SafetyUtil.getSecureKey();
|
||||
// if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) {
|
||||
// upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1);
|
||||
// }
|
||||
// String filePath = immediateFile.substring(0, immediateFile.lastIndexOf("/"));
|
||||
// String fileName = immediateFile.substring(immediateFile.lastIndexOf("/") + 1);
|
||||
// if (filePath.startsWith("/") || filePath.startsWith("\\")) {
|
||||
// filePath = filePath.substring(1);
|
||||
// }
|
||||
// try {
|
||||
// FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath, fileName);
|
||||
// } catch (Exception e) {
|
||||
// MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
|
||||
// mediaAsyncErrorLog.setMediaid(immediateFile);
|
||||
// mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
|
||||
// e.printStackTrace();
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// }
|
||||
// //处理指令音频文件
|
||||
// String mp3File = dto.getMp3File();
|
||||
// if (StringUtils.isNotBlank(mp3File)) {
|
||||
// String url = baseUrl + "/sys/common/open/static/" + URLEncoder.encode(mp3File, StandardCharsets.UTF_8).replace("%2F", "/") + "?name=" + SafetyUtil.getSecureKey();
|
||||
// if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) {
|
||||
// upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1);
|
||||
// }
|
||||
// String filePath = mp3File.substring(0, mp3File.lastIndexOf("/"));
|
||||
// String fileName = mp3File.substring(mp3File.lastIndexOf("/") + 1);
|
||||
// if (filePath.startsWith("/") || filePath.startsWith("\\")) {
|
||||
// filePath = filePath.substring(1);
|
||||
// }
|
||||
// try {
|
||||
// FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath, fileName);
|
||||
// } catch (Exception e) {
|
||||
// MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
|
||||
// mediaAsyncErrorLog.setMediaid(mp3File);
|
||||
// mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
|
||||
// e.printStackTrace();
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// }
|
||||
// //处理指令视频文件
|
||||
// String mp4File = dto.getMp4File();
|
||||
// if (StringUtils.isNotBlank(mp4File)) {
|
||||
// String url = baseUrl + "/sys/common/open/static/" + URLEncoder.encode(mp4File, StandardCharsets.UTF_8).replace("%2F", "/") + "?name=" + SafetyUtil.getSecureKey();
|
||||
// if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) {
|
||||
// upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1);
|
||||
// }
|
||||
// String filePath = mp4File.substring(0, mp4File.lastIndexOf("/"));
|
||||
// String fileName = mp4File.substring(mp4File.lastIndexOf("/") + 1);
|
||||
// if (filePath.startsWith("/") || filePath.startsWith("\\")) {
|
||||
// filePath = filePath.substring(1);
|
||||
// }
|
||||
// try {
|
||||
// FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath, fileName);
|
||||
// } catch (Exception e) {
|
||||
// MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
|
||||
// mediaAsyncErrorLog.setMediaid(mp4File);
|
||||
// mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
|
||||
// e.printStackTrace();
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@RabbitListener(
|
||||
bindings = @QueueBinding(
|
||||
value = @Queue(name = "#{directiveAsyncDQNP.getCreateMediaQueueName()}"),
|
||||
exchange = @Exchange(name = "hldy.directive", type = ExchangeTypes.DIRECT),
|
||||
key = "#{directiveAsyncDQNP.getCreateMediaKeyName()}"
|
||||
),
|
||||
errorHandler = "directiveMQErrorHandler"
|
||||
)
|
||||
public void handleCreateMedia(DirectiveAsyncMQDto dto) {
|
||||
//更新服务指令媒体资源字段
|
||||
ConfigServiceDirective configServiceDirective = new ConfigServiceDirective();
|
||||
configServiceDirective.setId(dto.getId());
|
||||
configServiceDirective.setPreviewFile(dto.getPreviewFile());//服务指令图片
|
||||
configServiceDirective.setServiceContent(dto.getServiceContent());//服务指令说明
|
||||
configServiceDirective.setImmediateFile(dto.getImmediateFile());//即时指令图标
|
||||
configServiceDirective.setMp3File(dto.getMp3File());//指令音频文件
|
||||
configServiceDirective.setMp4File(dto.getMp4File());//指令视频文件
|
||||
directiveService.updateById(configServiceDirective);
|
||||
|
||||
//拉取媒体资源至本地目录
|
||||
{
|
||||
LambdaQueryWrapper<SysConfig> qw = new LambdaQueryWrapper<>();
|
||||
qw.eq(SysConfig::getDelFlag, "0");
|
||||
qw.eq(SysConfig::getConfigKey, "ope_open_url");
|
||||
SysConfig urlObj = sysConfigService.getOne(qw);
|
||||
//试验田协议+域名(/ip+端口)
|
||||
String baseUrl = urlObj.getConfigValue();
|
||||
if (baseUrl.endsWith("/")) {
|
||||
baseUrl = baseUrl.substring(0, baseUrl.length() - 1); // 移除末尾斜杠
|
||||
}
|
||||
|
||||
//处理服务指令图片
|
||||
String previewFile = dto.getPreviewFile();
|
||||
if (StringUtils.isNotBlank(previewFile)) {
|
||||
String url = baseUrl + "/sys/common/open/static/" + URLEncoder.encode(previewFile, StandardCharsets.UTF_8).replace("%2F", "/") + "?name=" + SafetyUtil.getSecureKey();
|
||||
if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) {
|
||||
upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1);
|
||||
}
|
||||
String filePath = previewFile.substring(0, previewFile.lastIndexOf("/"));
|
||||
String fileName = previewFile.substring(previewFile.lastIndexOf("/") + 1);
|
||||
if (filePath.startsWith("/") || filePath.startsWith("\\")) {
|
||||
filePath = filePath.substring(1);
|
||||
}
|
||||
try {
|
||||
FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath, fileName);
|
||||
} catch (Exception e) {
|
||||
MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
|
||||
mediaAsyncErrorLog.setMediaid(previewFile);
|
||||
mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
//处理即时指令图标
|
||||
String immediateFile = dto.getImmediateFile();
|
||||
if (StringUtils.isNotBlank(immediateFile)) {
|
||||
String url = baseUrl + "/sys/common/open/static/" + URLEncoder.encode(immediateFile, StandardCharsets.UTF_8).replace("%2F", "/") + "?name=" + SafetyUtil.getSecureKey();
|
||||
if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) {
|
||||
upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1);
|
||||
}
|
||||
String filePath = immediateFile.substring(0, immediateFile.lastIndexOf("/"));
|
||||
String fileName = immediateFile.substring(immediateFile.lastIndexOf("/") + 1);
|
||||
if (filePath.startsWith("/") || filePath.startsWith("\\")) {
|
||||
filePath = filePath.substring(1);
|
||||
}
|
||||
try {
|
||||
FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath, fileName);
|
||||
} catch (Exception e) {
|
||||
MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
|
||||
mediaAsyncErrorLog.setMediaid(immediateFile);
|
||||
mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
//处理指令音频文件
|
||||
String mp3File = dto.getMp3File();
|
||||
if (StringUtils.isNotBlank(mp3File)) {
|
||||
String url = baseUrl + "/sys/common/open/static/" + URLEncoder.encode(mp3File, StandardCharsets.UTF_8).replace("%2F", "/") + "?name=" + SafetyUtil.getSecureKey();
|
||||
if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) {
|
||||
upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1);
|
||||
}
|
||||
String filePath = mp3File.substring(0, mp3File.lastIndexOf("/"));
|
||||
String fileName = mp3File.substring(mp3File.lastIndexOf("/") + 1);
|
||||
if (filePath.startsWith("/") || filePath.startsWith("\\")) {
|
||||
filePath = filePath.substring(1);
|
||||
}
|
||||
try {
|
||||
FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath, fileName);
|
||||
} catch (Exception e) {
|
||||
MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
|
||||
mediaAsyncErrorLog.setMediaid(mp3File);
|
||||
mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
//处理指令视频文件
|
||||
String mp4File = dto.getMp4File();
|
||||
if (StringUtils.isNotBlank(mp4File)) {
|
||||
String url = baseUrl + "/sys/common/open/static/" + URLEncoder.encode(mp4File, StandardCharsets.UTF_8).replace("%2F", "/") + "?name=" + SafetyUtil.getSecureKey();
|
||||
if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) {
|
||||
upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1);
|
||||
}
|
||||
String filePath = mp4File.substring(0, mp4File.lastIndexOf("/"));
|
||||
String fileName = mp4File.substring(mp4File.lastIndexOf("/") + 1);
|
||||
if (filePath.startsWith("/") || filePath.startsWith("\\")) {
|
||||
filePath = filePath.substring(1);
|
||||
}
|
||||
try {
|
||||
FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath, fileName);
|
||||
} catch (Exception e) {
|
||||
MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
|
||||
mediaAsyncErrorLog.setMediaid(mp4File);
|
||||
mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// /**
|
||||
// * if 未到运营开始时间时 全量变更
|
||||
|
|
|
|||
Loading…
Reference in New Issue