文件资源上传至管理平台接口

This commit is contained in:
1378012178@qq.com 2025-10-09 14:51:53 +08:00
parent 6417fb1810
commit b4b5c838cd
9 changed files with 1543 additions and 1474 deletions

View File

@ -37,4 +37,5 @@ public class SysBaseInfoApi {
result.put("url",deptInfo.getString("url")); result.put("url",deptInfo.getString("url"));
return Result.ok(result); return Result.ok(result);
} }
} }

View File

@ -0,0 +1,19 @@
package com.nu.entity;
import lombok.Data;
import java.io.Serializable;
/**
* @Description: 文件上传前置参数
* @Author: zmy
* @Date: 2025-10-9 09:26:22
* @Version: V1.0
*/
@Data
public class SysUploadPreEntity implements Serializable {
private String fileName;
private String fileSubfix;
private String fileSize;
}

View File

@ -57,7 +57,7 @@ public class ElderTagMQListener {
//增量处理数据 //增量处理数据
handleIncremental(dto); handleIncremental(dto);
//数据处理出错的话就不能继续处理标签资源了 所以方法放到这个位置 //数据处理出错的话就不能继续处理标签资源了 所以方法放到这个位置
handleCreateMedia(dto); // handleCreateMedia(dto);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
//返回错误日志 //返回错误日志
@ -110,32 +110,32 @@ public class ElderTagMQListener {
String baseUrl = dto.getApi(); String baseUrl = dto.getApi();
//处理长者标签图片 //处理长者标签图片
if (StringUtils.isNotBlank(dto.getPicMd5()) && !dto.getPicMd5().equals(currentElderTag.getPicMd5())) { // if (StringUtils.isNotBlank(dto.getPicMd5()) && !dto.getPicMd5().equals(currentElderTag.getPicMd5())) {
String pic = dto.getPic(); // String pic = dto.getPic();
if (StringUtils.isNotBlank(pic)) { // if (StringUtils.isNotBlank(pic)) {
String url = baseUrl + "/sys/common/open/static/" + URLEncoder.encode(pic, StandardCharsets.UTF_8).replace("%2F", "/") + "?name=" + SafetyUtil.getSecureKey(); // String url = baseUrl + "/sys/common/open/static/" + URLEncoder.encode(pic, StandardCharsets.UTF_8).replace("%2F", "/") + "?name=" + SafetyUtil.getSecureKey();
if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) { // if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) {
upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1); // upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1);
} // }
String filePath = pic.substring(0, pic.lastIndexOf("/")); // String filePath = pic.substring(0, pic.lastIndexOf("/"));
String fileName = pic.substring(pic.lastIndexOf("/") + 1); // String fileName = pic.substring(pic.lastIndexOf("/") + 1);
if (filePath.startsWith("/") || filePath.startsWith("\\")) { // if (filePath.startsWith("/") || filePath.startsWith("\\")) {
filePath = filePath.substring(1); // filePath = filePath.substring(1);
} // }
try { // try {
FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath, fileName); // FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath, fileName);
et.setPic(dto.getPic());//长者标签图片 et.setPic(dto.getPic());//长者标签图片
et.setPicMd5(dto.getPicMd5()); et.setPicMd5(dto.getPicMd5());
} catch (Exception e) { // } catch (Exception e) {
e.printStackTrace(); // e.printStackTrace();
MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog(); // MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
mediaAsyncErrorLog.setMediaid(pic); // mediaAsyncErrorLog.setMediaid(pic);
mediaAsyncErrorLog.setMsg(e.getMessage()); // mediaAsyncErrorLog.setMsg(e.getMessage());
mediaAsyncErrorLogService.save(mediaAsyncErrorLog); // mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
throw new RuntimeException("长者标签图片文件拉取错误,标签id" + currentElderTag.getId()); // throw new RuntimeException("长者标签图片文件拉取错误,标签id" + currentElderTag.getId());
} // }
} // }
} // }
elderTagService.updateById(et); elderTagService.updateById(et);
} }
}); });
@ -199,8 +199,8 @@ public class ElderTagMQListener {
for (ElderTag elderTag : allData) { for (ElderTag elderTag : allData) {
if (needAddIds.contains(elderTag.getId())) { if (needAddIds.contains(elderTag.getId())) {
//这里都是新增的标签 不存储标签资源字段 在标签资源mq中会存储这个值 //这里都是新增的标签 不存储标签资源字段 在标签资源mq中会存储这个值
elderTag.setPic(null); elderTag.setPic(elderTag.getPic());
elderTag.setPicMd5(null); elderTag.setPicMd5(elderTag.getPicMd5());
elderTag.setSort(0); elderTag.setSort(0);
elderTag.setPrice(new BigDecimal("0")); elderTag.setPrice(new BigDecimal("0"));
needAddETList.add(elderTag); needAddETList.add(elderTag);

View File

@ -172,6 +172,7 @@ public class EmployeesApplyServiceImpl extends ServiceImpl<EmployeesApplyMapper,
EmployeesApply eApply = new EmployeesApply(); EmployeesApply eApply = new EmployeesApply();
eApply.setId(employeesApply.getId()); eApply.setId(employeesApply.getId());
eApply.setModifyStatus("2"); eApply.setModifyStatus("2");
eApply.setStatus("2");
baseMapper.updateById(eApply); baseMapper.updateById(eApply);
//修改员工信息表此人的信息修改审核状态为通过 //修改员工信息表此人的信息修改审核状态为通过
BizEmployeesInfo eInfo = new BizEmployeesInfo(); BizEmployeesInfo eInfo = new BizEmployeesInfo();
@ -194,6 +195,7 @@ public class EmployeesApplyServiceImpl extends ServiceImpl<EmployeesApplyMapper,
BizEmployeesInfo eInfo = new BizEmployeesInfo(); BizEmployeesInfo eInfo = new BizEmployeesInfo();
eInfo.setId(employeesApply.getEmployeeId()); eInfo.setId(employeesApply.getEmployeeId());
eInfo.setModifyStatus("3"); eInfo.setModifyStatus("3");
eApply.setStatus("3");
employeesInfoService.updateById(eInfo); employeesInfoService.updateById(eInfo);
} }
//通知管理平台修改相关数据 //通知管理平台修改相关数据

View File

@ -269,7 +269,7 @@ public class ConfigServiceDirectiveController extends JeecgController<ConfigServ
//设置为未授权 //设置为未授权
configServiceDirective.setStatus("1"); configServiceDirective.setStatus("1");
//处理媒体资源放在保存方法之前 //处理媒体资源放在保存方法之前
configServiceDirectiveService.handleMediaFile(configServiceDirective); // configServiceDirectiveService.handleMediaFile(configServiceDirective);
configServiceDirectiveService.save(configServiceDirective); configServiceDirectiveService.save(configServiceDirective);
if (StringUtils.isNotBlank(configServiceDirective.getBodyTags())) { if (StringUtils.isNotBlank(configServiceDirective.getBodyTags())) {
configServiceDirectiveService.saveBodyTags(configServiceDirective); configServiceDirectiveService.saveBodyTags(configServiceDirective);

View File

@ -495,11 +495,11 @@ public class ConfigServiceDirectiveServiceImpl extends ServiceImpl<ConfigService
// record.setMp4FileMd5(null); // record.setMp4FileMd5(null);
// } // }
List<DirectiveBodyTag> bodyTagList = record.getBodyTagList(); // List<DirectiveBodyTag> bodyTagList = record.getBodyTagList();
record.setBodyTags(bodyTagList.stream().map(DirectiveBodyTag::getId).collect(Collectors.joining(","))); // record.setBodyTags(bodyTagList.stream().map(DirectiveBodyTag::getId).collect(Collectors.joining(",")));
//
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(",")));
}); });
} }
directiveMQDto.setDirectiveList(BeanUtil.copyToList(directives, DirectiveAsyncMQDto.class)); directiveMQDto.setDirectiveList(BeanUtil.copyToList(directives, DirectiveAsyncMQDto.class));
@ -541,35 +541,35 @@ public class ConfigServiceDirectiveServiceImpl extends ServiceImpl<ConfigService
} }
} }
//体型标签 //体型标签
{ // {
directiveMQDto.setBodyTagList(BeanUtil.copyToList(bodyTagService.selectAll(directiveIds, null), BodyTagMQDto.class)); // directiveMQDto.setBodyTagList(BeanUtil.copyToList(bodyTagService.selectAll(directiveIds, null), BodyTagMQDto.class));
} // }
//情绪标签 //情绪标签
{ // {
directiveMQDto.setEmotionTagList(BeanUtil.copyToList(emotionTagService.selectAll(directiveIds, null), EmotionTagMQDto.class)); // directiveMQDto.setEmotionTagList(BeanUtil.copyToList(emotionTagService.selectAll(directiveIds, null), EmotionTagMQDto.class));
} // }
directiveMQListener.handleIncremental2(directiveMQDto); directiveMQListener.handleIncremental2(directiveMQDto);
String apiAddress = ""; String apiAddress = "";
//查询源数据平台的接口api地址 //查询源数据平台的接口api地址
{ // {
//各平台api地址都存在管理系统中 管理系统api地址在系统参数配置中 ope_open_url // //各平台api地址都存在管理系统中 管理系统api地址在系统参数配置中 ope_open_url
JSONObject opeOpenUrl = sysConfigApi.getByKeyByDS("master", "ope_open_url"); // JSONObject opeOpenUrl = sysConfigApi.getByKeyByDS("master", "ope_open_url");
String opeApiAddress = opeOpenUrl.getString("configValue"); // String opeApiAddress = opeOpenUrl.getString("configValue");
if (opeApiAddress.endsWith("/")) { // if (opeApiAddress.endsWith("/")) {
opeApiAddress = opeApiAddress.substring(0, opeApiAddress.length() - 1); // opeApiAddress = opeApiAddress.substring(0, opeApiAddress.length() - 1);
} // }
String bizApiAddress = opeApiAddress + "/api/baseInfo/getOrgApiAddress?orgCode=" + sourceOrgCode; // String bizApiAddress = opeApiAddress + "/api/baseInfo/getOrgApiAddress?orgCode=" + sourceOrgCode;
//
try { // try {
String res = HttpRequestUtil.doGet(bizApiAddress, HttpRequestUtil.createDefaultHeaders()); // String res = HttpRequestUtil.doGet(bizApiAddress, HttpRequestUtil.createDefaultHeaders());
JSONObject jsonResponse = JSON.parseObject(res); // JSONObject jsonResponse = JSON.parseObject(res);
JSONObject result = jsonResponse.getJSONObject("result"); // JSONObject result = jsonResponse.getJSONObject("result");
apiAddress = result.getString("url"); // apiAddress = result.getString("url");
} catch (Exception e) { // } catch (Exception e) {
e.printStackTrace(); // e.printStackTrace();
} // }
} // }
directiveMQListener.handleCreateMedia2(directiveMQDto, apiAddress); directiveMQListener.handleCreateMedia2(directiveMQDto, apiAddress);
//给对应业务平台发送消息 //给对应业务平台发送消息

View File

@ -83,7 +83,7 @@ public class DirectiveMQListener {
//增量处理数据 //增量处理数据
handleIncremental(dto); handleIncremental(dto);
//数据处理出错的话就不能继续处理指令资源了 所以方法放到这个位置 //数据处理出错的话就不能继续处理指令资源了 所以方法放到这个位置
handleCreateMedia(dto); // handleCreateMedia(dto);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
//返回错误日志 //返回错误日志
@ -137,165 +137,165 @@ public class DirectiveMQListener {
//拉取媒体资源至本地目录 //拉取媒体资源至本地目录
{ {
//接口协议域名+上下文访问路径 // //接口协议域名+上下文访问路径
String baseUrl = dto.getApi(); // String baseUrl = dto.getApi();
//
//处理服务指令图片大图 // //处理服务指令图片大图
if (StringUtils.isNotBlank(dto.getPreviewFileMd5()) && !dto.getPreviewFileMd5().equals(currentDirective.getPreviewFileMd5())) { // if (StringUtils.isNotBlank(dto.getPreviewFileMd5()) && !dto.getPreviewFileMd5().equals(currentDirective.getPreviewFileMd5())) {
String previewFile = dto.getPreviewFile(); // String previewFile = dto.getPreviewFile();
if (StringUtils.isNotBlank(previewFile)) { // if (StringUtils.isNotBlank(previewFile)) {
String url = baseUrl + "/sys/common/open/static/" + URLEncoder.encode(previewFile, StandardCharsets.UTF_8).replace("%2F", "/") + "?name=" + SafetyUtil.getSecureKey(); // String url = baseUrl + "/sys/common/open/static/" + URLEncoder.encode(previewFile, StandardCharsets.UTF_8).replace("%2F", "/") + "?name=" + SafetyUtil.getSecureKey();
if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) { // if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) {
upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1); // upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1);
} // }
String filePath = previewFile.substring(0, previewFile.lastIndexOf("/")); // String filePath = previewFile.substring(0, previewFile.lastIndexOf("/"));
String fileName = previewFile.substring(previewFile.lastIndexOf("/") + 1); // String fileName = previewFile.substring(previewFile.lastIndexOf("/") + 1);
if (filePath.startsWith("/") || filePath.startsWith("\\")) { // if (filePath.startsWith("/") || filePath.startsWith("\\")) {
filePath = filePath.substring(1); // filePath = filePath.substring(1);
} // }
try { // try {
FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath, fileName); // FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath, fileName);
configServiceDirective.setPreviewFile(dto.getPreviewFile());//服务指令图片大图 configServiceDirective.setPreviewFile(dto.getPreviewFile());//服务指令图片大图
configServiceDirective.setPreviewFileMd5(dto.getPreviewFileMd5()); configServiceDirective.setPreviewFileMd5(dto.getPreviewFileMd5());
} catch (Exception e) { // } catch (Exception e) {
e.printStackTrace(); // e.printStackTrace();
MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog(); // MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
mediaAsyncErrorLog.setMediaid(previewFile); // mediaAsyncErrorLog.setMediaid(previewFile);
mediaAsyncErrorLogService.save(mediaAsyncErrorLog); // mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
throw new RuntimeException("服务指令图片大图文件拉取错误,指令id" + dto.getId()); // throw new RuntimeException("服务指令图片大图文件拉取错误,指令id" + dto.getId());
} // }
} // }
} // }
//处理服务指令图片小图 //处理服务指令图片小图
if (StringUtils.isNotBlank(dto.getPreviewFileSmallMd5()) && !dto.getPreviewFileSmallMd5().equals(currentDirective.getPreviewFileSmallMd5())) { // if (StringUtils.isNotBlank(dto.getPreviewFileSmallMd5()) && !dto.getPreviewFileSmallMd5().equals(currentDirective.getPreviewFileSmallMd5())) {
String previewFileSmall = dto.getPreviewFileSmall(); // String previewFileSmall = dto.getPreviewFileSmall();
if (StringUtils.isNotBlank(previewFileSmall)) { // if (StringUtils.isNotBlank(previewFileSmall)) {
String url = baseUrl + "/sys/common/open/static/" + URLEncoder.encode(previewFileSmall, StandardCharsets.UTF_8).replace("%2F", "/") + "?name=" + SafetyUtil.getSecureKey(); // String url = baseUrl + "/sys/common/open/static/" + URLEncoder.encode(previewFileSmall, StandardCharsets.UTF_8).replace("%2F", "/") + "?name=" + SafetyUtil.getSecureKey();
if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) { // if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) {
upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1); // upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1);
} // }
String filePath = previewFileSmall.substring(0, previewFileSmall.lastIndexOf("/")); // String filePath = previewFileSmall.substring(0, previewFileSmall.lastIndexOf("/"));
String fileName = previewFileSmall.substring(previewFileSmall.lastIndexOf("/") + 1); // String fileName = previewFileSmall.substring(previewFileSmall.lastIndexOf("/") + 1);
if (filePath.startsWith("/") || filePath.startsWith("\\")) { // if (filePath.startsWith("/") || filePath.startsWith("\\")) {
filePath = filePath.substring(1); // filePath = filePath.substring(1);
} // }
try { // try {
FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath, fileName); // FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath, fileName);
configServiceDirective.setPreviewFileSmall(dto.getPreviewFileSmall());//服务指令图片小图 configServiceDirective.setPreviewFileSmall(dto.getPreviewFileSmall());//服务指令图片小图
configServiceDirective.setPreviewFileSmallMd5(dto.getPreviewFileSmallMd5()); configServiceDirective.setPreviewFileSmallMd5(dto.getPreviewFileSmallMd5());
} catch (Exception e) { // } catch (Exception e) {
e.printStackTrace(); // e.printStackTrace();
MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog(); // MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
mediaAsyncErrorLog.setMediaid(previewFileSmall); // mediaAsyncErrorLog.setMediaid(previewFileSmall);
mediaAsyncErrorLogService.save(mediaAsyncErrorLog); // mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
throw new RuntimeException("服务指令图片小图文件拉取错误,指令id" + dto.getId()); // throw new RuntimeException("服务指令图片小图文件拉取错误,指令id" + dto.getId());
} // }
} // }
} // }
//处理即时指令图标 //处理即时指令图标
if (StringUtils.isNotBlank(dto.getImmediateFileMd5()) && !dto.getImmediateFileMd5().equals(currentDirective.getImmediateFileMd5())) { // if (StringUtils.isNotBlank(dto.getImmediateFileMd5()) && !dto.getImmediateFileMd5().equals(currentDirective.getImmediateFileMd5())) {
String immediateFile = dto.getImmediateFile(); // String immediateFile = dto.getImmediateFile();
if (StringUtils.isNotBlank(immediateFile)) { // if (StringUtils.isNotBlank(immediateFile)) {
String url = baseUrl + "/sys/common/open/static/" + URLEncoder.encode(immediateFile, StandardCharsets.UTF_8).replace("%2F", "/") + "?name=" + SafetyUtil.getSecureKey(); // String url = baseUrl + "/sys/common/open/static/" + URLEncoder.encode(immediateFile, StandardCharsets.UTF_8).replace("%2F", "/") + "?name=" + SafetyUtil.getSecureKey();
if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) { // if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) {
upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1); // upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1);
} // }
String filePath = immediateFile.substring(0, immediateFile.lastIndexOf("/")); // String filePath = immediateFile.substring(0, immediateFile.lastIndexOf("/"));
String fileName = immediateFile.substring(immediateFile.lastIndexOf("/") + 1); // String fileName = immediateFile.substring(immediateFile.lastIndexOf("/") + 1);
if (filePath.startsWith("/") || filePath.startsWith("\\")) { // if (filePath.startsWith("/") || filePath.startsWith("\\")) {
filePath = filePath.substring(1); // filePath = filePath.substring(1);
} // }
try { // try {
FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath, fileName); // FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath, fileName);
configServiceDirective.setImmediateFile(dto.getImmediateFile());//即时指令图标 configServiceDirective.setImmediateFile(dto.getImmediateFile());//即时指令图标
configServiceDirective.setImmediateFileMd5(dto.getImmediateFileMd5()); configServiceDirective.setImmediateFileMd5(dto.getImmediateFileMd5());
} catch (Exception e) { // } catch (Exception e) {
MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog(); // MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
mediaAsyncErrorLog.setMediaid(immediateFile); // mediaAsyncErrorLog.setMediaid(immediateFile);
mediaAsyncErrorLogService.save(mediaAsyncErrorLog); // mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
e.printStackTrace(); // e.printStackTrace();
throw new RuntimeException("即时指令图标文件拉取错误,指令id" + dto.getId()); // throw new RuntimeException("即时指令图标文件拉取错误,指令id" + dto.getId());
} // }
} // }
} // }
//处理即时指令焦点图标 //处理即时指令焦点图标
if (StringUtils.isNotBlank(dto.getImmediateFileFocusMd5()) && !dto.getImmediateFileFocusMd5().equals(currentDirective.getImmediateFileFocusMd5())) { // if (StringUtils.isNotBlank(dto.getImmediateFileFocusMd5()) && !dto.getImmediateFileFocusMd5().equals(currentDirective.getImmediateFileFocusMd5())) {
String immediateFileFocus = dto.getImmediateFileFocus(); // String immediateFileFocus = dto.getImmediateFileFocus();
if (StringUtils.isNotBlank(immediateFileFocus)) { // if (StringUtils.isNotBlank(immediateFileFocus)) {
String url = baseUrl + "/sys/common/open/static/" + URLEncoder.encode(immediateFileFocus, StandardCharsets.UTF_8).replace("%2F", "/") + "?name=" + SafetyUtil.getSecureKey(); // String url = baseUrl + "/sys/common/open/static/" + URLEncoder.encode(immediateFileFocus, StandardCharsets.UTF_8).replace("%2F", "/") + "?name=" + SafetyUtil.getSecureKey();
if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) { // if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) {
upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1); // upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1);
} // }
String filePath = immediateFileFocus.substring(0, immediateFileFocus.lastIndexOf("/")); // String filePath = immediateFileFocus.substring(0, immediateFileFocus.lastIndexOf("/"));
String fileName = immediateFileFocus.substring(immediateFileFocus.lastIndexOf("/") + 1); // String fileName = immediateFileFocus.substring(immediateFileFocus.lastIndexOf("/") + 1);
if (filePath.startsWith("/") || filePath.startsWith("\\")) { // if (filePath.startsWith("/") || filePath.startsWith("\\")) {
filePath = filePath.substring(1); // filePath = filePath.substring(1);
} // }
try { // try {
FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath, fileName); // FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath, fileName);
configServiceDirective.setImmediateFileFocus(dto.getImmediateFileFocus());//即时指令图标 configServiceDirective.setImmediateFileFocus(dto.getImmediateFileFocus());//即时指令图标
configServiceDirective.setImmediateFileFocusMd5(dto.getImmediateFileFocusMd5()); configServiceDirective.setImmediateFileFocusMd5(dto.getImmediateFileFocusMd5());
} catch (Exception e) { // } catch (Exception e) {
MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog(); // MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
mediaAsyncErrorLog.setMediaid(immediateFileFocus); // mediaAsyncErrorLog.setMediaid(immediateFileFocus);
mediaAsyncErrorLogService.save(mediaAsyncErrorLog); // mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
e.printStackTrace(); // e.printStackTrace();
throw new RuntimeException("即时指令焦点图标文件拉取错误,指令id" + dto.getId()); // throw new RuntimeException("即时指令焦点图标文件拉取错误,指令id" + dto.getId());
} // }
} // }
} // }
//处理指令音频文件 //处理指令音频文件
if (StringUtils.isNotBlank(dto.getMp3FileMd5()) && !dto.getMp3FileMd5().equals(currentDirective.getMp3FileMd5())) { // if (StringUtils.isNotBlank(dto.getMp3FileMd5()) && !dto.getMp3FileMd5().equals(currentDirective.getMp3FileMd5())) {
String mp3File = dto.getMp3File(); // String mp3File = dto.getMp3File();
if (StringUtils.isNotBlank(mp3File)) { // if (StringUtils.isNotBlank(mp3File)) {
String url = baseUrl + "/sys/common/open/static/" + URLEncoder.encode(mp3File, StandardCharsets.UTF_8).replace("%2F", "/") + "?name=" + SafetyUtil.getSecureKey(); // String url = baseUrl + "/sys/common/open/static/" + URLEncoder.encode(mp3File, StandardCharsets.UTF_8).replace("%2F", "/") + "?name=" + SafetyUtil.getSecureKey();
if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) { // if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) {
upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1); // upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1);
} // }
String filePath = mp3File.substring(0, mp3File.lastIndexOf("/")); // String filePath = mp3File.substring(0, mp3File.lastIndexOf("/"));
String fileName = mp3File.substring(mp3File.lastIndexOf("/") + 1); // String fileName = mp3File.substring(mp3File.lastIndexOf("/") + 1);
if (filePath.startsWith("/") || filePath.startsWith("\\")) { // if (filePath.startsWith("/") || filePath.startsWith("\\")) {
filePath = filePath.substring(1); // filePath = filePath.substring(1);
} // }
try { // try {
FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath, fileName); // FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath, fileName);
configServiceDirective.setMp3File(dto.getMp3File());//指令音频文件 configServiceDirective.setMp3File(dto.getMp3File());//指令音频文件
configServiceDirective.setMp3FileMd5(dto.getMp3FileMd5()); configServiceDirective.setMp3FileMd5(dto.getMp3FileMd5());
} catch (Exception e) { // } catch (Exception e) {
MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog(); // MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
mediaAsyncErrorLog.setMediaid(mp3File); // mediaAsyncErrorLog.setMediaid(mp3File);
mediaAsyncErrorLogService.save(mediaAsyncErrorLog); // mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
e.printStackTrace(); // e.printStackTrace();
throw new RuntimeException("指令音频文件拉取错误,指令id" + dto.getId()); // throw new RuntimeException("指令音频文件拉取错误,指令id" + dto.getId());
} // }
} // }
} // }
//处理指令视频文件 //处理指令视频文件
if (StringUtils.isNotBlank(dto.getMp4FileMd5()) && !dto.getMp4FileMd5().equals(currentDirective.getMp4FileMd5())) { // if (StringUtils.isNotBlank(dto.getMp4FileMd5()) && !dto.getMp4FileMd5().equals(currentDirective.getMp4FileMd5())) {
String mp4File = dto.getMp4File(); // String mp4File = dto.getMp4File();
if (StringUtils.isNotBlank(mp4File)) { // if (StringUtils.isNotBlank(mp4File)) {
String url = baseUrl + "/sys/common/open/static/" + URLEncoder.encode(mp4File, StandardCharsets.UTF_8).replace("%2F", "/") + "?name=" + SafetyUtil.getSecureKey(); // String url = baseUrl + "/sys/common/open/static/" + URLEncoder.encode(mp4File, StandardCharsets.UTF_8).replace("%2F", "/") + "?name=" + SafetyUtil.getSecureKey();
if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) { // if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) {
upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1); // upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1);
} // }
String filePath = mp4File.substring(0, mp4File.lastIndexOf("/")); // String filePath = mp4File.substring(0, mp4File.lastIndexOf("/"));
String fileName = mp4File.substring(mp4File.lastIndexOf("/") + 1); // String fileName = mp4File.substring(mp4File.lastIndexOf("/") + 1);
if (filePath.startsWith("/") || filePath.startsWith("\\")) { // if (filePath.startsWith("/") || filePath.startsWith("\\")) {
filePath = filePath.substring(1); // filePath = filePath.substring(1);
} // }
try { // try {
FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath, fileName); // FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath, fileName);
configServiceDirective.setMp4File(dto.getMp4File());//指令视频文件 configServiceDirective.setMp4File(dto.getMp4File());//指令视频文件
configServiceDirective.setMp4FileMd5(dto.getMp4FileMd5()); configServiceDirective.setMp4FileMd5(dto.getMp4FileMd5());
} catch (Exception e) { // } catch (Exception e) {
MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog(); // MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
mediaAsyncErrorLog.setMediaid(mp4File); // mediaAsyncErrorLog.setMediaid(mp4File);
mediaAsyncErrorLogService.save(mediaAsyncErrorLog); // mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
e.printStackTrace(); // e.printStackTrace();
throw new RuntimeException("指令视频文件拉取错误,指令id" + dto.getId()); // throw new RuntimeException("指令视频文件拉取错误,指令id" + dto.getId());
} // }
} // }
} // }
directiveService.updateById(configServiceDirective); directiveService.updateById(configServiceDirective);
} }
}); });
@ -596,19 +596,19 @@ public class DirectiveMQListener {
for (ConfigServiceDirective directive : allData) { for (ConfigServiceDirective directive : allData) {
if (needAddIds.contains(directive.getId())) { if (needAddIds.contains(directive.getId())) {
//这里都是新增的指令 不存储指令资源字段 在指令资源mq中会存储这个值 //这里都是新增的指令 不存储指令资源字段 在指令资源mq中会存储这个值
directive.setPreviewFile(null); // directive.setPreviewFile(null);
directive.setPreviewFileSmall(null); // directive.setPreviewFileSmall(null);
directive.setImmediateFile(null); // directive.setImmediateFile(null);
directive.setImmediateFileFocus(null); // directive.setImmediateFileFocus(null);
directive.setMp3File(null); // directive.setMp3File(null);
directive.setMp4File(null); // directive.setMp4File(null);
directive.setServiceContent(null); // directive.setServiceContent(null);
directive.setPreviewFileMd5(null); // directive.setPreviewFileMd5(null);
directive.setPreviewFileSmallMd5(null); // directive.setPreviewFileSmallMd5(null);
directive.setImmediateFileMd5(null); // directive.setImmediateFileMd5(null);
directive.setImmediateFileFocusMd5(null); // directive.setImmediateFileFocusMd5(null);
directive.setMp3FileMd5(null); // directive.setMp3FileMd5(null);
directive.setMp4FileMd5(null); // directive.setMp4FileMd5(null);
needAddDirectiveList.add(directive); needAddDirectiveList.add(directive);
} }
} }
@ -618,87 +618,87 @@ public class DirectiveMQListener {
} }
} }
//体型标签 //体型标签
{ // {
//处理体型标签字典主表 // //处理体型标签字典主表
if (dto.getBodyTagList() != null) { // if (dto.getBodyTagList() != null) {
//已经存在的体型标签id // //已经存在的体型标签id
List<String> existedIds = Lists.newArrayList(); // List<String> existedIds = Lists.newArrayList();
//获取到已经存在的体型标签数据 // //获取到已经存在的体型标签数据
if (dto.isIzInc()) { // if (dto.isIzInc()) {
List<DirectiveBodyTag> list = bodyTagService.list(); // List<DirectiveBodyTag> list = bodyTagService.list();
existedIds = list.stream().map(DirectiveBodyTag::getId).collect(Collectors.toList()); // existedIds = list.stream().map(DirectiveBodyTag::getId).collect(Collectors.toList());
} // }
//传过来的全部体型标签主表数据 // //传过来的全部体型标签主表数据
List<DirectiveBodyTag> allData = BeanUtil.copyToList(dto.getBodyTagList(), DirectiveBodyTag.class); // List<DirectiveBodyTag> allData = BeanUtil.copyToList(dto.getBodyTagList(), DirectiveBodyTag.class);
//需要新增的体型标签字典表数据 // //需要新增的体型标签字典表数据
List<DirectiveBodyTag> needAddBodyList = new ArrayList<>(); // List<DirectiveBodyTag> needAddBodyList = new ArrayList<>();
//获取到需要新增的体型标签字典表数据 // //获取到需要新增的体型标签字典表数据
for (DirectiveBodyTag body : allData) { // for (DirectiveBodyTag body : allData) {
if (!existedIds.contains(body.getId())) { // if (!existedIds.contains(body.getId())) {
needAddBodyList.add(body); // needAddBodyList.add(body);
} // }
} // }
if (needAddBodyList != null && !needAddBodyList.isEmpty()) { // if (needAddBodyList != null && !needAddBodyList.isEmpty()) {
bodyTagService.insertAll(needAddBodyList); // bodyTagService.insertAll(needAddBodyList);
} // }
} // }
//中间关系表 // //中间关系表
{ // {
List<DirectiveBodyTagRelation> bodyRelations = Lists.newArrayList();//关系表 // List<DirectiveBodyTagRelation> bodyRelations = Lists.newArrayList();//关系表
needAddDirectiveList.stream().forEach(d -> { // needAddDirectiveList.stream().forEach(d -> {
String bodyTags = d.getBodyTags(); // String bodyTags = d.getBodyTags();
if (StringUtils.isNotBlank(bodyTags)) { // if (StringUtils.isNotBlank(bodyTags)) {
Arrays.stream(bodyTags.split(",")).forEach(bi -> { // Arrays.stream(bodyTags.split(",")).forEach(bi -> {
DirectiveBodyTagRelation r = new DirectiveBodyTagRelation(); // DirectiveBodyTagRelation r = new DirectiveBodyTagRelation();
r.setDirectiveId(d.getId()); // r.setDirectiveId(d.getId());
r.setTagId(bi); // r.setTagId(bi);
bodyRelations.add(r); // bodyRelations.add(r);
}); // });
} // }
}); // });
bodyTagService.insertAllRelation(bodyRelations); // bodyTagService.insertAllRelation(bodyRelations);
} // }
} // }
//情绪标签 //情绪标签
{ // {
if (dto.getEmotionTagList() != null) { // if (dto.getEmotionTagList() != null) {
//需要排除的情绪标签id // //需要排除的情绪标签id
List<String> existedIds = Lists.newArrayList(); // List<String> existedIds = Lists.newArrayList();
if (dto.isIzInc()) { // if (dto.isIzInc()) {
List<DirectiveEmotionTag> list = emotionTagService.list(); // List<DirectiveEmotionTag> list = emotionTagService.list();
existedIds = list.stream().map(DirectiveEmotionTag::getId).collect(Collectors.toList()); // existedIds = list.stream().map(DirectiveEmotionTag::getId).collect(Collectors.toList());
} // }
//传来的所有数据 // //传来的所有数据
List<DirectiveEmotionTag> allData = BeanUtil.copyToList(dto.getEmotionTagList(), DirectiveEmotionTag.class); // List<DirectiveEmotionTag> allData = BeanUtil.copyToList(dto.getEmotionTagList(), DirectiveEmotionTag.class);
//
//需要新增的数据 // //需要新增的数据
List<DirectiveEmotionTag> needAddData = new ArrayList<>();//字典表 // List<DirectiveEmotionTag> needAddData = new ArrayList<>();//字典表
for (DirectiveEmotionTag emotion : allData) { // for (DirectiveEmotionTag emotion : allData) {
if (!existedIds.contains(emotion.getId())) { // if (!existedIds.contains(emotion.getId())) {
needAddData.add(emotion); // 如果不在排除列表里就加入结果 // needAddData.add(emotion); // 如果不在排除列表里就加入结果
} // }
} // }
if (needAddData != null && !needAddData.isEmpty()) { // if (needAddData != null && !needAddData.isEmpty()) {
emotionTagService.insertAll(needAddData); // emotionTagService.insertAll(needAddData);
} // }
} // }
//中间关系表 // //中间关系表
{ // {
List<DirectiveEmotionTagRelation> emotionRelations = Lists.newArrayList();//关系表 // List<DirectiveEmotionTagRelation> emotionRelations = Lists.newArrayList();//关系表
needAddDirectiveList.stream().forEach(d -> { // needAddDirectiveList.stream().forEach(d -> {
String emotionTags = d.getEmotionTags(); // String emotionTags = d.getEmotionTags();
if (StringUtils.isNotBlank(emotionTags)) { // if (StringUtils.isNotBlank(emotionTags)) {
Arrays.stream(emotionTags.split(",")).forEach(bi -> { // Arrays.stream(emotionTags.split(",")).forEach(bi -> {
DirectiveEmotionTagRelation r = new DirectiveEmotionTagRelation(); // DirectiveEmotionTagRelation r = new DirectiveEmotionTagRelation();
r.setDirectiveId(d.getId()); // r.setDirectiveId(d.getId());
r.setTagId(bi); // r.setTagId(bi);
emotionRelations.add(r); // emotionRelations.add(r);
}); // });
} // }
}); // });
emotionTagService.insertAllRelation(emotionRelations); // emotionTagService.insertAllRelation(emotionRelations);
} // }
} // }
//分类标签 //分类标签
if (dto.getInstructionList() != null) { if (dto.getInstructionList() != null) {
//需要排除的分类标签id //需要排除的分类标签id
@ -935,161 +935,161 @@ public class DirectiveMQListener {
String baseUrl = apiAddress; String baseUrl = apiAddress;
//处理服务指令图片大图 //处理服务指令图片大图
if (StringUtils.isNotBlank(dto.getPreviewFileMd5()) && !dto.getPreviewFileMd5().equals(currentDirective.getPreviewFileMd5())) { // if (StringUtils.isNotBlank(dto.getPreviewFileMd5()) && !dto.getPreviewFileMd5().equals(currentDirective.getPreviewFileMd5())) {
String previewFile = dto.getPreviewFile(); // String previewFile = dto.getPreviewFile();
if (StringUtils.isNotBlank(previewFile)) { // if (StringUtils.isNotBlank(previewFile)) {
String url = baseUrl + "/sys/common/open/static/" + URLEncoder.encode(previewFile, StandardCharsets.UTF_8).replace("%2F", "/") + "?name=" + SafetyUtil.getSecureKey(); // String url = baseUrl + "/sys/common/open/static/" + URLEncoder.encode(previewFile, StandardCharsets.UTF_8).replace("%2F", "/") + "?name=" + SafetyUtil.getSecureKey();
if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) { // if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) {
upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1); // upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1);
} // }
String filePath = previewFile.substring(0, previewFile.lastIndexOf("/")); // String filePath = previewFile.substring(0, previewFile.lastIndexOf("/"));
String fileName = previewFile.substring(previewFile.lastIndexOf("/") + 1); // String fileName = previewFile.substring(previewFile.lastIndexOf("/") + 1);
if (filePath.startsWith("/") || filePath.startsWith("\\")) { // if (filePath.startsWith("/") || filePath.startsWith("\\")) {
filePath = filePath.substring(1); // filePath = filePath.substring(1);
} // }
try { // try {
FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath, fileName); // FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath, fileName);
configServiceDirective.setPreviewFile(dto.getPreviewFile());//服务指令图片大图 configServiceDirective.setPreviewFile(dto.getPreviewFile());//服务指令图片大图
configServiceDirective.setPreviewFileMd5(dto.getPreviewFileMd5()); configServiceDirective.setPreviewFileMd5(dto.getPreviewFileMd5());
} catch (Exception e) { // } catch (Exception e) {
e.printStackTrace(); // e.printStackTrace();
MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog(); // MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
mediaAsyncErrorLog.setMediaid(previewFile); // mediaAsyncErrorLog.setMediaid(previewFile);
mediaAsyncErrorLogService.save(mediaAsyncErrorLog); // mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
throw new RuntimeException("服务指令图片大图文件拉取错误,指令id" + dto.getId()); // throw new RuntimeException("服务指令图片大图文件拉取错误,指令id" + dto.getId());
} // }
} // }
} // }
//处理服务指令图片小图 //处理服务指令图片小图
if (StringUtils.isNotBlank(dto.getPreviewFileSmallMd5()) && !dto.getPreviewFileSmallMd5().equals(currentDirective.getPreviewFileSmallMd5())) { // if (StringUtils.isNotBlank(dto.getPreviewFileSmallMd5()) && !dto.getPreviewFileSmallMd5().equals(currentDirective.getPreviewFileSmallMd5())) {
String previewFileSmall = dto.getPreviewFileSmall(); // String previewFileSmall = dto.getPreviewFileSmall();
if (StringUtils.isNotBlank(previewFileSmall)) { // if (StringUtils.isNotBlank(previewFileSmall)) {
String url = baseUrl + "/sys/common/open/static/" + URLEncoder.encode(previewFileSmall, StandardCharsets.UTF_8).replace("%2F", "/") + "?name=" + SafetyUtil.getSecureKey(); // String url = baseUrl + "/sys/common/open/static/" + URLEncoder.encode(previewFileSmall, StandardCharsets.UTF_8).replace("%2F", "/") + "?name=" + SafetyUtil.getSecureKey();
if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) { // if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) {
upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1); // upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1);
} // }
String filePath = previewFileSmall.substring(0, previewFileSmall.lastIndexOf("/")); // String filePath = previewFileSmall.substring(0, previewFileSmall.lastIndexOf("/"));
String fileName = previewFileSmall.substring(previewFileSmall.lastIndexOf("/") + 1); // String fileName = previewFileSmall.substring(previewFileSmall.lastIndexOf("/") + 1);
if (filePath.startsWith("/") || filePath.startsWith("\\")) { // if (filePath.startsWith("/") || filePath.startsWith("\\")) {
filePath = filePath.substring(1); // filePath = filePath.substring(1);
} // }
try { // try {
FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath, fileName); // FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath, fileName);
configServiceDirective.setPreviewFileSmall(dto.getPreviewFileSmall());//服务指令图片小图 configServiceDirective.setPreviewFileSmall(dto.getPreviewFileSmall());//服务指令图片小图
configServiceDirective.setPreviewFileSmallMd5(dto.getPreviewFileSmallMd5()); configServiceDirective.setPreviewFileSmallMd5(dto.getPreviewFileSmallMd5());
} catch (Exception e) { // } catch (Exception e) {
e.printStackTrace(); // e.printStackTrace();
MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog(); // MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
mediaAsyncErrorLog.setMediaid(previewFileSmall); // mediaAsyncErrorLog.setMediaid(previewFileSmall);
mediaAsyncErrorLogService.save(mediaAsyncErrorLog); // mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
throw new RuntimeException("服务指令图片小图文件拉取错误,指令id" + dto.getId()); // throw new RuntimeException("服务指令图片小图文件拉取错误,指令id" + dto.getId());
} // }
} // }
} // }
//处理即时指令图标 //处理即时指令图标
if (StringUtils.isNotBlank(dto.getImmediateFileMd5()) && !dto.getImmediateFileMd5().equals(currentDirective.getImmediateFileMd5())) { // if (StringUtils.isNotBlank(dto.getImmediateFileMd5()) && !dto.getImmediateFileMd5().equals(currentDirective.getImmediateFileMd5())) {
String immediateFile = dto.getImmediateFile(); // String immediateFile = dto.getImmediateFile();
if (StringUtils.isNotBlank(immediateFile)) { // if (StringUtils.isNotBlank(immediateFile)) {
String url = baseUrl + "/sys/common/open/static/" + URLEncoder.encode(immediateFile, StandardCharsets.UTF_8).replace("%2F", "/") + "?name=" + SafetyUtil.getSecureKey(); // String url = baseUrl + "/sys/common/open/static/" + URLEncoder.encode(immediateFile, StandardCharsets.UTF_8).replace("%2F", "/") + "?name=" + SafetyUtil.getSecureKey();
if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) { // if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) {
upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1); // upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1);
} // }
String filePath = immediateFile.substring(0, immediateFile.lastIndexOf("/")); // String filePath = immediateFile.substring(0, immediateFile.lastIndexOf("/"));
String fileName = immediateFile.substring(immediateFile.lastIndexOf("/") + 1); // String fileName = immediateFile.substring(immediateFile.lastIndexOf("/") + 1);
if (filePath.startsWith("/") || filePath.startsWith("\\")) { // if (filePath.startsWith("/") || filePath.startsWith("\\")) {
filePath = filePath.substring(1); // filePath = filePath.substring(1);
} // }
try { // try {
FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath, fileName); // FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath, fileName);
configServiceDirective.setImmediateFile(dto.getImmediateFile());//即时指令图标 configServiceDirective.setImmediateFile(dto.getImmediateFile());//即时指令图标
configServiceDirective.setImmediateFileMd5(dto.getImmediateFileMd5()); configServiceDirective.setImmediateFileMd5(dto.getImmediateFileMd5());
} catch (Exception e) { // } catch (Exception e) {
MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog(); // MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
mediaAsyncErrorLog.setMediaid(immediateFile); // mediaAsyncErrorLog.setMediaid(immediateFile);
mediaAsyncErrorLogService.save(mediaAsyncErrorLog); // mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
e.printStackTrace(); // e.printStackTrace();
throw new RuntimeException("即时指令图标文件拉取错误,指令id" + dto.getId()); // throw new RuntimeException("即时指令图标文件拉取错误,指令id" + dto.getId());
} // }
} // }
} // }
//处理即时指令焦点图标 //处理即时指令焦点图标
if (StringUtils.isNotBlank(dto.getImmediateFileFocusMd5()) && !dto.getImmediateFileFocusMd5().equals(currentDirective.getImmediateFileFocusMd5())) { // if (StringUtils.isNotBlank(dto.getImmediateFileFocusMd5()) && !dto.getImmediateFileFocusMd5().equals(currentDirective.getImmediateFileFocusMd5())) {
String immediateFileFocus = dto.getImmediateFileFocus(); // String immediateFileFocus = dto.getImmediateFileFocus();
if (StringUtils.isNotBlank(immediateFileFocus)) { // if (StringUtils.isNotBlank(immediateFileFocus)) {
String url = baseUrl + "/sys/common/open/static/" + URLEncoder.encode(immediateFileFocus, StandardCharsets.UTF_8).replace("%2F", "/") + "?name=" + SafetyUtil.getSecureKey(); // String url = baseUrl + "/sys/common/open/static/" + URLEncoder.encode(immediateFileFocus, StandardCharsets.UTF_8).replace("%2F", "/") + "?name=" + SafetyUtil.getSecureKey();
if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) { // if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) {
upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1); // upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1);
} // }
String filePath = immediateFileFocus.substring(0, immediateFileFocus.lastIndexOf("/")); // String filePath = immediateFileFocus.substring(0, immediateFileFocus.lastIndexOf("/"));
String fileName = immediateFileFocus.substring(immediateFileFocus.lastIndexOf("/") + 1); // String fileName = immediateFileFocus.substring(immediateFileFocus.lastIndexOf("/") + 1);
if (filePath.startsWith("/") || filePath.startsWith("\\")) { // if (filePath.startsWith("/") || filePath.startsWith("\\")) {
filePath = filePath.substring(1); // filePath = filePath.substring(1);
} // }
try { // try {
FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath, fileName); // FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath, fileName);
configServiceDirective.setImmediateFileFocus(dto.getImmediateFileFocus());//即时指令图标 configServiceDirective.setImmediateFileFocus(dto.getImmediateFileFocus());//即时指令图标
configServiceDirective.setImmediateFileFocusMd5(dto.getImmediateFileFocusMd5()); configServiceDirective.setImmediateFileFocusMd5(dto.getImmediateFileFocusMd5());
} catch (Exception e) { // } catch (Exception e) {
MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog(); // MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
mediaAsyncErrorLog.setMediaid(immediateFileFocus); // mediaAsyncErrorLog.setMediaid(immediateFileFocus);
mediaAsyncErrorLogService.save(mediaAsyncErrorLog); // mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
e.printStackTrace(); // e.printStackTrace();
throw new RuntimeException("即时指令图标文件拉取错误,指令id" + dto.getId()); // throw new RuntimeException("即时指令图标文件拉取错误,指令id" + dto.getId());
} // }
} // }
} // }
//处理指令音频文件 //处理指令音频文件
if (StringUtils.isNotBlank(dto.getMp3FileMd5()) && !dto.getMp3FileMd5().equals(currentDirective.getMp3FileMd5())) { // if (StringUtils.isNotBlank(dto.getMp3FileMd5()) && !dto.getMp3FileMd5().equals(currentDirective.getMp3FileMd5())) {
String mp3File = dto.getMp3File(); // String mp3File = dto.getMp3File();
if (StringUtils.isNotBlank(mp3File)) { // if (StringUtils.isNotBlank(mp3File)) {
String url = baseUrl + "/sys/common/open/static/" + URLEncoder.encode(mp3File, StandardCharsets.UTF_8).replace("%2F", "/") + "?name=" + SafetyUtil.getSecureKey(); // String url = baseUrl + "/sys/common/open/static/" + URLEncoder.encode(mp3File, StandardCharsets.UTF_8).replace("%2F", "/") + "?name=" + SafetyUtil.getSecureKey();
if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) { // if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) {
upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1); // upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1);
} // }
String filePath = mp3File.substring(0, mp3File.lastIndexOf("/")); // String filePath = mp3File.substring(0, mp3File.lastIndexOf("/"));
String fileName = mp3File.substring(mp3File.lastIndexOf("/") + 1); // String fileName = mp3File.substring(mp3File.lastIndexOf("/") + 1);
if (filePath.startsWith("/") || filePath.startsWith("\\")) { // if (filePath.startsWith("/") || filePath.startsWith("\\")) {
filePath = filePath.substring(1); // filePath = filePath.substring(1);
} // }
try { // try {
FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath, fileName); // FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath, fileName);
configServiceDirective.setMp3File(dto.getMp3File());//指令音频文件 configServiceDirective.setMp3File(dto.getMp3File());//指令音频文件
configServiceDirective.setMp3FileMd5(dto.getMp3FileMd5()); configServiceDirective.setMp3FileMd5(dto.getMp3FileMd5());
} catch (Exception e) { // } catch (Exception e) {
MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog(); // MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
mediaAsyncErrorLog.setMediaid(mp3File); // mediaAsyncErrorLog.setMediaid(mp3File);
mediaAsyncErrorLogService.save(mediaAsyncErrorLog); // mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
e.printStackTrace(); // e.printStackTrace();
throw new RuntimeException("指令音频文件拉取错误,指令id" + dto.getId()); // throw new RuntimeException("指令音频文件拉取错误,指令id" + dto.getId());
} // }
} // }
} // }
//处理指令视频文件 //处理指令视频文件
if (StringUtils.isNotBlank(dto.getMp4FileMd5()) && !dto.getMp4FileMd5().equals(currentDirective.getMp4FileMd5())) { // if (StringUtils.isNotBlank(dto.getMp4FileMd5()) && !dto.getMp4FileMd5().equals(currentDirective.getMp4FileMd5())) {
String mp4File = dto.getMp4File(); // String mp4File = dto.getMp4File();
if (StringUtils.isNotBlank(mp4File)) { // if (StringUtils.isNotBlank(mp4File)) {
String url = baseUrl + "/sys/common/open/static/" + URLEncoder.encode(mp4File, StandardCharsets.UTF_8).replace("%2F", "/") + "?name=" + SafetyUtil.getSecureKey(); // String url = baseUrl + "/sys/common/open/static/" + URLEncoder.encode(mp4File, StandardCharsets.UTF_8).replace("%2F", "/") + "?name=" + SafetyUtil.getSecureKey();
if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) { // if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) {
upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1); // upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1);
} // }
String filePath = mp4File.substring(0, mp4File.lastIndexOf("/")); // String filePath = mp4File.substring(0, mp4File.lastIndexOf("/"));
String fileName = mp4File.substring(mp4File.lastIndexOf("/") + 1); // String fileName = mp4File.substring(mp4File.lastIndexOf("/") + 1);
if (filePath.startsWith("/") || filePath.startsWith("\\")) { // if (filePath.startsWith("/") || filePath.startsWith("\\")) {
filePath = filePath.substring(1); // filePath = filePath.substring(1);
} // }
try { // try {
FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath, fileName); // FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath, fileName);
configServiceDirective.setMp4File(dto.getMp4File());//指令视频文件 configServiceDirective.setMp4File(dto.getMp4File());//指令视频文件
configServiceDirective.setMp4FileMd5(dto.getMp4FileMd5()); configServiceDirective.setMp4FileMd5(dto.getMp4FileMd5());
} catch (Exception e) { // } catch (Exception e) {
MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog(); // MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
mediaAsyncErrorLog.setMediaid(mp4File); // mediaAsyncErrorLog.setMediaid(mp4File);
mediaAsyncErrorLogService.save(mediaAsyncErrorLog); // mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
e.printStackTrace(); // e.printStackTrace();
throw new RuntimeException("指令视频文件拉取错误,指令id" + dto.getId()); // throw new RuntimeException("指令视频文件拉取错误,指令id" + dto.getId());
} // }
} // }
} // }
directiveService.updateById(configServiceDirective); directiveService.updateById(configServiceDirective);
} }
}); });

View File

@ -1,17 +1,21 @@
package org.jeecg.modules.system.controller; package org.jeecg.modules.system.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.nu.modules.sysconfig.ISysConfigApi;
import com.nu.utils.HttpRequestUtil;
import com.nu.utils.SafetyUtil; import com.nu.utils.SafetyUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result; import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.CommonConstant; import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.constant.SymbolConstant; import org.jeecg.common.constant.SymbolConstant;
import org.jeecg.common.constant.enums.FileTypeEnum;
import org.jeecg.common.exception.JeecgBootException; import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.util.CommonUtils; import org.jeecg.common.util.CommonUtils;
import org.jeecg.common.util.filter.SsrfFileTypeFilter; import org.jeecg.common.util.filter.SsrfFileTypeFilter;
import org.jeecg.common.util.oConvertUtils; import org.jeecg.common.util.oConvertUtils;
import com.nu.entity.SysUploadPreEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.util.AntPathMatcher; import org.springframework.util.AntPathMatcher;
import org.springframework.util.FileCopyUtils; import org.springframework.util.FileCopyUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -23,10 +27,7 @@ import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.*; import java.io.*;
import java.security.MessageDigest; import java.util.Map;
import java.security.NoSuchAlgorithmException;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
/** /**
* <p> * <p>
@ -50,6 +51,9 @@ public class CommonController {
@Value(value = "${jeecg.uploadType}") @Value(value = "${jeecg.uploadType}")
private String uploadType; private String uploadType;
@Autowired
private ISysConfigApi sysConfigApi;
/** /**
* @return * @return
* @Author 政辉 * @Author 政辉
@ -427,4 +431,47 @@ public class CommonController {
return new AntPathMatcher().extractPathWithinPattern(bestMatchPattern, path); return new AntPathMatcher().extractPathWithinPattern(bestMatchPattern, path);
} }
/**
* 需要上传至管理平台调用的前置接口
*
* @param dto
* @return
*/
@PostMapping("/upload/pre")
public Result<?> uploadPre(@RequestBody SysUploadPreEntity dto) {
try {
// 1. 获取管理平台 API 地址
JSONObject opeOpenUrl = sysConfigApi.getByKeyByDS("master", "ope_open_url");
String opeApiAddress = opeOpenUrl.getString("configValue");
if (opeApiAddress.endsWith("/")) {
opeApiAddress = opeApiAddress.substring(0, opeApiAddress.length() - 1);
}
String bizApiAddress = opeApiAddress + "/api/common/saveFileType";
// 2. 构造请求头使用你工具类提供的默认头
Map<String, String> headers = HttpRequestUtil.createDefaultHeaders();
// 3. dto 对象转为 JSON 字符串假设你项目中有 fastjson / jackson
// 这里以 fastjson 为例Jeecg 默认用 fastjson
String body = JSON.toJSONString(dto);
// 4. 发送 POST 请求
String response = HttpRequestUtil.doPost(bizApiAddress, headers, body);
// 5. 可选解析响应确认是否成功
// 解析 JSON
JSONObject jsonResponse = JSON.parseObject(response);
// 判断 result 是否为 200
Object resultObj = jsonResponse.get("result");
if (resultObj != null && "200".equals(resultObj.toString())) {
return Result.ok(SafetyUtil.getSecureKey());
} else {
return Result.ok(500);
}
} catch (Exception e) {
return Result.ok(500);
}
}
} }