文件资源上传至管理平台接口
This commit is contained in:
parent
6417fb1810
commit
b4b5c838cd
|
|
@ -37,4 +37,5 @@ public class SysBaseInfoApi {
|
|||
result.put("url",deptInfo.getString("url"));
|
||||
return Result.ok(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -57,7 +57,7 @@ public class ElderTagMQListener {
|
|||
//增量处理数据
|
||||
handleIncremental(dto);
|
||||
//数据处理出错的话就不能继续处理标签资源了 所以方法放到这个位置
|
||||
handleCreateMedia(dto);
|
||||
// handleCreateMedia(dto);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
//返回错误日志
|
||||
|
|
@ -110,32 +110,32 @@ public class ElderTagMQListener {
|
|||
String baseUrl = dto.getApi();
|
||||
|
||||
//处理长者标签图片
|
||||
if (StringUtils.isNotBlank(dto.getPicMd5()) && !dto.getPicMd5().equals(currentElderTag.getPicMd5())) {
|
||||
String pic = dto.getPic();
|
||||
if (StringUtils.isNotBlank(pic)) {
|
||||
String url = baseUrl + "/sys/common/open/static/" + URLEncoder.encode(pic, StandardCharsets.UTF_8).replace("%2F", "/") + "?name=" + SafetyUtil.getSecureKey();
|
||||
if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) {
|
||||
upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1);
|
||||
}
|
||||
String filePath = pic.substring(0, pic.lastIndexOf("/"));
|
||||
String fileName = pic.substring(pic.lastIndexOf("/") + 1);
|
||||
if (filePath.startsWith("/") || filePath.startsWith("\\")) {
|
||||
filePath = filePath.substring(1);
|
||||
}
|
||||
try {
|
||||
FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath, fileName);
|
||||
// if (StringUtils.isNotBlank(dto.getPicMd5()) && !dto.getPicMd5().equals(currentElderTag.getPicMd5())) {
|
||||
// String pic = dto.getPic();
|
||||
// if (StringUtils.isNotBlank(pic)) {
|
||||
// String url = baseUrl + "/sys/common/open/static/" + URLEncoder.encode(pic, StandardCharsets.UTF_8).replace("%2F", "/") + "?name=" + SafetyUtil.getSecureKey();
|
||||
// if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) {
|
||||
// upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1);
|
||||
// }
|
||||
// String filePath = pic.substring(0, pic.lastIndexOf("/"));
|
||||
// String fileName = pic.substring(pic.lastIndexOf("/") + 1);
|
||||
// if (filePath.startsWith("/") || filePath.startsWith("\\")) {
|
||||
// filePath = filePath.substring(1);
|
||||
// }
|
||||
// try {
|
||||
// FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath, fileName);
|
||||
et.setPic(dto.getPic());//长者标签图片
|
||||
et.setPicMd5(dto.getPicMd5());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
|
||||
mediaAsyncErrorLog.setMediaid(pic);
|
||||
mediaAsyncErrorLog.setMsg(e.getMessage());
|
||||
mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
|
||||
throw new RuntimeException("长者标签图片文件拉取错误,标签id" + currentElderTag.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
|
||||
// mediaAsyncErrorLog.setMediaid(pic);
|
||||
// mediaAsyncErrorLog.setMsg(e.getMessage());
|
||||
// mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
|
||||
// throw new RuntimeException("长者标签图片文件拉取错误,标签id" + currentElderTag.getId());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
elderTagService.updateById(et);
|
||||
}
|
||||
});
|
||||
|
|
@ -199,8 +199,8 @@ public class ElderTagMQListener {
|
|||
for (ElderTag elderTag : allData) {
|
||||
if (needAddIds.contains(elderTag.getId())) {
|
||||
//这里都是新增的标签 不存储标签资源字段 在标签资源mq中会存储这个值
|
||||
elderTag.setPic(null);
|
||||
elderTag.setPicMd5(null);
|
||||
elderTag.setPic(elderTag.getPic());
|
||||
elderTag.setPicMd5(elderTag.getPicMd5());
|
||||
elderTag.setSort(0);
|
||||
elderTag.setPrice(new BigDecimal("0"));
|
||||
needAddETList.add(elderTag);
|
||||
|
|
|
|||
|
|
@ -172,6 +172,7 @@ public class EmployeesApplyServiceImpl extends ServiceImpl<EmployeesApplyMapper,
|
|||
EmployeesApply eApply = new EmployeesApply();
|
||||
eApply.setId(employeesApply.getId());
|
||||
eApply.setModifyStatus("2");
|
||||
eApply.setStatus("2");
|
||||
baseMapper.updateById(eApply);
|
||||
//修改员工信息表此人的信息修改审核状态为通过
|
||||
BizEmployeesInfo eInfo = new BizEmployeesInfo();
|
||||
|
|
@ -194,6 +195,7 @@ public class EmployeesApplyServiceImpl extends ServiceImpl<EmployeesApplyMapper,
|
|||
BizEmployeesInfo eInfo = new BizEmployeesInfo();
|
||||
eInfo.setId(employeesApply.getEmployeeId());
|
||||
eInfo.setModifyStatus("3");
|
||||
eApply.setStatus("3");
|
||||
employeesInfoService.updateById(eInfo);
|
||||
}
|
||||
//通知管理平台修改相关数据
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -269,7 +269,7 @@ public class ConfigServiceDirectiveController extends JeecgController<ConfigServ
|
|||
//设置为“未授权”
|
||||
configServiceDirective.setStatus("1");
|
||||
//处理媒体资源(放在保存方法之前)
|
||||
configServiceDirectiveService.handleMediaFile(configServiceDirective);
|
||||
// configServiceDirectiveService.handleMediaFile(configServiceDirective);
|
||||
configServiceDirectiveService.save(configServiceDirective);
|
||||
if (StringUtils.isNotBlank(configServiceDirective.getBodyTags())) {
|
||||
configServiceDirectiveService.saveBodyTags(configServiceDirective);
|
||||
|
|
|
|||
|
|
@ -495,11 +495,11 @@ public class ConfigServiceDirectiveServiceImpl extends ServiceImpl<ConfigService
|
|||
// record.setMp4FileMd5(null);
|
||||
// }
|
||||
|
||||
List<DirectiveBodyTag> bodyTagList = record.getBodyTagList();
|
||||
record.setBodyTags(bodyTagList.stream().map(DirectiveBodyTag::getId).collect(Collectors.joining(",")));
|
||||
|
||||
List<DirectiveEmotionTag> emotionTagList = record.getEmotionTagList();
|
||||
record.setEmotionTags(emotionTagList.stream().map(DirectiveEmotionTag::getId).collect(Collectors.joining(",")));
|
||||
// List<DirectiveBodyTag> bodyTagList = record.getBodyTagList();
|
||||
// record.setBodyTags(bodyTagList.stream().map(DirectiveBodyTag::getId).collect(Collectors.joining(",")));
|
||||
//
|
||||
// List<DirectiveEmotionTag> emotionTagList = record.getEmotionTagList();
|
||||
// record.setEmotionTags(emotionTagList.stream().map(DirectiveEmotionTag::getId).collect(Collectors.joining(",")));
|
||||
});
|
||||
}
|
||||
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);
|
||||
|
||||
String apiAddress = "";
|
||||
//查询源数据平台的接口api地址
|
||||
{
|
||||
//各平台api地址都存在管理系统中 管理系统api地址在系统参数配置中 “ope_open_url”
|
||||
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/baseInfo/getOrgApiAddress?orgCode=" + sourceOrgCode;
|
||||
|
||||
try {
|
||||
String res = HttpRequestUtil.doGet(bizApiAddress, HttpRequestUtil.createDefaultHeaders());
|
||||
JSONObject jsonResponse = JSON.parseObject(res);
|
||||
JSONObject result = jsonResponse.getJSONObject("result");
|
||||
apiAddress = result.getString("url");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
// {
|
||||
// //各平台api地址都存在管理系统中 管理系统api地址在系统参数配置中 “ope_open_url”
|
||||
// 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/baseInfo/getOrgApiAddress?orgCode=" + sourceOrgCode;
|
||||
//
|
||||
// try {
|
||||
// String res = HttpRequestUtil.doGet(bizApiAddress, HttpRequestUtil.createDefaultHeaders());
|
||||
// JSONObject jsonResponse = JSON.parseObject(res);
|
||||
// JSONObject result = jsonResponse.getJSONObject("result");
|
||||
// apiAddress = result.getString("url");
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
|
||||
directiveMQListener.handleCreateMedia2(directiveMQDto, apiAddress);
|
||||
//给对应业务平台发送消息
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ public class DirectiveMQListener {
|
|||
//增量处理数据
|
||||
handleIncremental(dto);
|
||||
//数据处理出错的话就不能继续处理指令资源了 所以方法放到这个位置
|
||||
handleCreateMedia(dto);
|
||||
// handleCreateMedia(dto);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
//返回错误日志
|
||||
|
|
@ -137,165 +137,165 @@ public class DirectiveMQListener {
|
|||
|
||||
//拉取媒体资源至本地目录
|
||||
{
|
||||
//接口协议域名+上下文访问路径
|
||||
String baseUrl = dto.getApi();
|
||||
|
||||
//处理服务指令图片大图
|
||||
if (StringUtils.isNotBlank(dto.getPreviewFileMd5()) && !dto.getPreviewFileMd5().equals(currentDirective.getPreviewFileMd5())) {
|
||||
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);
|
||||
// //接口协议域名+上下文访问路径
|
||||
// String baseUrl = dto.getApi();
|
||||
//
|
||||
// //处理服务指令图片大图
|
||||
// if (StringUtils.isNotBlank(dto.getPreviewFileMd5()) && !dto.getPreviewFileMd5().equals(currentDirective.getPreviewFileMd5())) {
|
||||
// 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);
|
||||
configServiceDirective.setPreviewFile(dto.getPreviewFile());//服务指令图片大图
|
||||
configServiceDirective.setPreviewFileMd5(dto.getPreviewFileMd5());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
|
||||
mediaAsyncErrorLog.setMediaid(previewFile);
|
||||
mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
|
||||
throw new RuntimeException("服务指令图片大图文件拉取错误,指令id" + dto.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
|
||||
// mediaAsyncErrorLog.setMediaid(previewFile);
|
||||
// mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
|
||||
// throw new RuntimeException("服务指令图片大图文件拉取错误,指令id" + dto.getId());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//处理服务指令图片小图
|
||||
if (StringUtils.isNotBlank(dto.getPreviewFileSmallMd5()) && !dto.getPreviewFileSmallMd5().equals(currentDirective.getPreviewFileSmallMd5())) {
|
||||
String previewFileSmall = dto.getPreviewFileSmall();
|
||||
if (StringUtils.isNotBlank(previewFileSmall)) {
|
||||
String url = baseUrl + "/sys/common/open/static/" + URLEncoder.encode(previewFileSmall, StandardCharsets.UTF_8).replace("%2F", "/") + "?name=" + SafetyUtil.getSecureKey();
|
||||
if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) {
|
||||
upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1);
|
||||
}
|
||||
String filePath = previewFileSmall.substring(0, previewFileSmall.lastIndexOf("/"));
|
||||
String fileName = previewFileSmall.substring(previewFileSmall.lastIndexOf("/") + 1);
|
||||
if (filePath.startsWith("/") || filePath.startsWith("\\")) {
|
||||
filePath = filePath.substring(1);
|
||||
}
|
||||
try {
|
||||
FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath, fileName);
|
||||
// if (StringUtils.isNotBlank(dto.getPreviewFileSmallMd5()) && !dto.getPreviewFileSmallMd5().equals(currentDirective.getPreviewFileSmallMd5())) {
|
||||
// String previewFileSmall = dto.getPreviewFileSmall();
|
||||
// if (StringUtils.isNotBlank(previewFileSmall)) {
|
||||
// String url = baseUrl + "/sys/common/open/static/" + URLEncoder.encode(previewFileSmall, StandardCharsets.UTF_8).replace("%2F", "/") + "?name=" + SafetyUtil.getSecureKey();
|
||||
// if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) {
|
||||
// upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1);
|
||||
// }
|
||||
// String filePath = previewFileSmall.substring(0, previewFileSmall.lastIndexOf("/"));
|
||||
// String fileName = previewFileSmall.substring(previewFileSmall.lastIndexOf("/") + 1);
|
||||
// if (filePath.startsWith("/") || filePath.startsWith("\\")) {
|
||||
// filePath = filePath.substring(1);
|
||||
// }
|
||||
// try {
|
||||
// FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath, fileName);
|
||||
configServiceDirective.setPreviewFileSmall(dto.getPreviewFileSmall());//服务指令图片小图
|
||||
configServiceDirective.setPreviewFileSmallMd5(dto.getPreviewFileSmallMd5());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
|
||||
mediaAsyncErrorLog.setMediaid(previewFileSmall);
|
||||
mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
|
||||
throw new RuntimeException("服务指令图片小图文件拉取错误,指令id" + dto.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
|
||||
// mediaAsyncErrorLog.setMediaid(previewFileSmall);
|
||||
// mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
|
||||
// throw new RuntimeException("服务指令图片小图文件拉取错误,指令id" + dto.getId());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//处理即时指令图标
|
||||
if (StringUtils.isNotBlank(dto.getImmediateFileMd5()) && !dto.getImmediateFileMd5().equals(currentDirective.getImmediateFileMd5())) {
|
||||
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);
|
||||
// if (StringUtils.isNotBlank(dto.getImmediateFileMd5()) && !dto.getImmediateFileMd5().equals(currentDirective.getImmediateFileMd5())) {
|
||||
// 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);
|
||||
configServiceDirective.setImmediateFile(dto.getImmediateFile());//即时指令图标
|
||||
configServiceDirective.setImmediateFileMd5(dto.getImmediateFileMd5());
|
||||
} catch (Exception e) {
|
||||
MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
|
||||
mediaAsyncErrorLog.setMediaid(immediateFile);
|
||||
mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("即时指令图标文件拉取错误,指令id" + dto.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
// } catch (Exception e) {
|
||||
// MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
|
||||
// mediaAsyncErrorLog.setMediaid(immediateFile);
|
||||
// mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
|
||||
// e.printStackTrace();
|
||||
// throw new RuntimeException("即时指令图标文件拉取错误,指令id" + dto.getId());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//处理即时指令焦点图标
|
||||
if (StringUtils.isNotBlank(dto.getImmediateFileFocusMd5()) && !dto.getImmediateFileFocusMd5().equals(currentDirective.getImmediateFileFocusMd5())) {
|
||||
String immediateFileFocus = dto.getImmediateFileFocus();
|
||||
if (StringUtils.isNotBlank(immediateFileFocus)) {
|
||||
String url = baseUrl + "/sys/common/open/static/" + URLEncoder.encode(immediateFileFocus, StandardCharsets.UTF_8).replace("%2F", "/") + "?name=" + SafetyUtil.getSecureKey();
|
||||
if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) {
|
||||
upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1);
|
||||
}
|
||||
String filePath = immediateFileFocus.substring(0, immediateFileFocus.lastIndexOf("/"));
|
||||
String fileName = immediateFileFocus.substring(immediateFileFocus.lastIndexOf("/") + 1);
|
||||
if (filePath.startsWith("/") || filePath.startsWith("\\")) {
|
||||
filePath = filePath.substring(1);
|
||||
}
|
||||
try {
|
||||
FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath, fileName);
|
||||
// if (StringUtils.isNotBlank(dto.getImmediateFileFocusMd5()) && !dto.getImmediateFileFocusMd5().equals(currentDirective.getImmediateFileFocusMd5())) {
|
||||
// String immediateFileFocus = dto.getImmediateFileFocus();
|
||||
// if (StringUtils.isNotBlank(immediateFileFocus)) {
|
||||
// String url = baseUrl + "/sys/common/open/static/" + URLEncoder.encode(immediateFileFocus, StandardCharsets.UTF_8).replace("%2F", "/") + "?name=" + SafetyUtil.getSecureKey();
|
||||
// if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) {
|
||||
// upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1);
|
||||
// }
|
||||
// String filePath = immediateFileFocus.substring(0, immediateFileFocus.lastIndexOf("/"));
|
||||
// String fileName = immediateFileFocus.substring(immediateFileFocus.lastIndexOf("/") + 1);
|
||||
// if (filePath.startsWith("/") || filePath.startsWith("\\")) {
|
||||
// filePath = filePath.substring(1);
|
||||
// }
|
||||
// try {
|
||||
// FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath, fileName);
|
||||
configServiceDirective.setImmediateFileFocus(dto.getImmediateFileFocus());//即时指令图标
|
||||
configServiceDirective.setImmediateFileFocusMd5(dto.getImmediateFileFocusMd5());
|
||||
} catch (Exception e) {
|
||||
MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
|
||||
mediaAsyncErrorLog.setMediaid(immediateFileFocus);
|
||||
mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("即时指令焦点图标文件拉取错误,指令id" + dto.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
// } catch (Exception e) {
|
||||
// MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
|
||||
// mediaAsyncErrorLog.setMediaid(immediateFileFocus);
|
||||
// mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
|
||||
// e.printStackTrace();
|
||||
// throw new RuntimeException("即时指令焦点图标文件拉取错误,指令id" + dto.getId());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//处理指令音频文件
|
||||
if (StringUtils.isNotBlank(dto.getMp3FileMd5()) && !dto.getMp3FileMd5().equals(currentDirective.getMp3FileMd5())) {
|
||||
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);
|
||||
// if (StringUtils.isNotBlank(dto.getMp3FileMd5()) && !dto.getMp3FileMd5().equals(currentDirective.getMp3FileMd5())) {
|
||||
// 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);
|
||||
configServiceDirective.setMp3File(dto.getMp3File());//指令音频文件
|
||||
configServiceDirective.setMp3FileMd5(dto.getMp3FileMd5());
|
||||
} catch (Exception e) {
|
||||
MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
|
||||
mediaAsyncErrorLog.setMediaid(mp3File);
|
||||
mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("指令音频文件拉取错误,指令id" + dto.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
// } catch (Exception e) {
|
||||
// MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
|
||||
// mediaAsyncErrorLog.setMediaid(mp3File);
|
||||
// mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
|
||||
// e.printStackTrace();
|
||||
// throw new RuntimeException("指令音频文件拉取错误,指令id" + dto.getId());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//处理指令视频文件
|
||||
if (StringUtils.isNotBlank(dto.getMp4FileMd5()) && !dto.getMp4FileMd5().equals(currentDirective.getMp4FileMd5())) {
|
||||
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);
|
||||
// if (StringUtils.isNotBlank(dto.getMp4FileMd5()) && !dto.getMp4FileMd5().equals(currentDirective.getMp4FileMd5())) {
|
||||
// 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);
|
||||
configServiceDirective.setMp4File(dto.getMp4File());//指令视频文件
|
||||
configServiceDirective.setMp4FileMd5(dto.getMp4FileMd5());
|
||||
} catch (Exception e) {
|
||||
MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
|
||||
mediaAsyncErrorLog.setMediaid(mp4File);
|
||||
mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("指令视频文件拉取错误,指令id" + dto.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
// } catch (Exception e) {
|
||||
// MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
|
||||
// mediaAsyncErrorLog.setMediaid(mp4File);
|
||||
// mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
|
||||
// e.printStackTrace();
|
||||
// throw new RuntimeException("指令视频文件拉取错误,指令id" + dto.getId());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
directiveService.updateById(configServiceDirective);
|
||||
}
|
||||
});
|
||||
|
|
@ -596,19 +596,19 @@ public class DirectiveMQListener {
|
|||
for (ConfigServiceDirective directive : allData) {
|
||||
if (needAddIds.contains(directive.getId())) {
|
||||
//这里都是新增的指令 不存储指令资源字段 在指令资源mq中会存储这个值
|
||||
directive.setPreviewFile(null);
|
||||
directive.setPreviewFileSmall(null);
|
||||
directive.setImmediateFile(null);
|
||||
directive.setImmediateFileFocus(null);
|
||||
directive.setMp3File(null);
|
||||
directive.setMp4File(null);
|
||||
directive.setServiceContent(null);
|
||||
directive.setPreviewFileMd5(null);
|
||||
directive.setPreviewFileSmallMd5(null);
|
||||
directive.setImmediateFileMd5(null);
|
||||
directive.setImmediateFileFocusMd5(null);
|
||||
directive.setMp3FileMd5(null);
|
||||
directive.setMp4FileMd5(null);
|
||||
// directive.setPreviewFile(null);
|
||||
// directive.setPreviewFileSmall(null);
|
||||
// directive.setImmediateFile(null);
|
||||
// directive.setImmediateFileFocus(null);
|
||||
// directive.setMp3File(null);
|
||||
// directive.setMp4File(null);
|
||||
// directive.setServiceContent(null);
|
||||
// directive.setPreviewFileMd5(null);
|
||||
// directive.setPreviewFileSmallMd5(null);
|
||||
// directive.setImmediateFileMd5(null);
|
||||
// directive.setImmediateFileFocusMd5(null);
|
||||
// directive.setMp3FileMd5(null);
|
||||
// directive.setMp4FileMd5(null);
|
||||
needAddDirectiveList.add(directive);
|
||||
}
|
||||
}
|
||||
|
|
@ -618,87 +618,87 @@ public class DirectiveMQListener {
|
|||
}
|
||||
}
|
||||
//体型标签
|
||||
{
|
||||
//处理体型标签字典主表
|
||||
if (dto.getBodyTagList() != null) {
|
||||
//已经存在的体型标签id
|
||||
List<String> existedIds = Lists.newArrayList();
|
||||
//获取到已经存在的体型标签数据
|
||||
if (dto.isIzInc()) {
|
||||
List<DirectiveBodyTag> list = bodyTagService.list();
|
||||
existedIds = list.stream().map(DirectiveBodyTag::getId).collect(Collectors.toList());
|
||||
}
|
||||
//传过来的全部体型标签主表数据
|
||||
List<DirectiveBodyTag> allData = BeanUtil.copyToList(dto.getBodyTagList(), DirectiveBodyTag.class);
|
||||
//需要新增的体型标签字典表数据
|
||||
List<DirectiveBodyTag> needAddBodyList = new ArrayList<>();
|
||||
//获取到需要新增的体型标签字典表数据
|
||||
for (DirectiveBodyTag body : allData) {
|
||||
if (!existedIds.contains(body.getId())) {
|
||||
needAddBodyList.add(body);
|
||||
}
|
||||
}
|
||||
if (needAddBodyList != null && !needAddBodyList.isEmpty()) {
|
||||
bodyTagService.insertAll(needAddBodyList);
|
||||
}
|
||||
}
|
||||
//中间关系表
|
||||
{
|
||||
List<DirectiveBodyTagRelation> bodyRelations = Lists.newArrayList();//关系表
|
||||
needAddDirectiveList.stream().forEach(d -> {
|
||||
String bodyTags = d.getBodyTags();
|
||||
if (StringUtils.isNotBlank(bodyTags)) {
|
||||
Arrays.stream(bodyTags.split(",")).forEach(bi -> {
|
||||
DirectiveBodyTagRelation r = new DirectiveBodyTagRelation();
|
||||
r.setDirectiveId(d.getId());
|
||||
r.setTagId(bi);
|
||||
bodyRelations.add(r);
|
||||
});
|
||||
}
|
||||
});
|
||||
bodyTagService.insertAllRelation(bodyRelations);
|
||||
}
|
||||
}
|
||||
// {
|
||||
// //处理体型标签字典主表
|
||||
// if (dto.getBodyTagList() != null) {
|
||||
// //已经存在的体型标签id
|
||||
// List<String> existedIds = Lists.newArrayList();
|
||||
// //获取到已经存在的体型标签数据
|
||||
// if (dto.isIzInc()) {
|
||||
// List<DirectiveBodyTag> list = bodyTagService.list();
|
||||
// existedIds = list.stream().map(DirectiveBodyTag::getId).collect(Collectors.toList());
|
||||
// }
|
||||
// //传过来的全部体型标签主表数据
|
||||
// List<DirectiveBodyTag> allData = BeanUtil.copyToList(dto.getBodyTagList(), DirectiveBodyTag.class);
|
||||
// //需要新增的体型标签字典表数据
|
||||
// List<DirectiveBodyTag> needAddBodyList = new ArrayList<>();
|
||||
// //获取到需要新增的体型标签字典表数据
|
||||
// for (DirectiveBodyTag body : allData) {
|
||||
// if (!existedIds.contains(body.getId())) {
|
||||
// needAddBodyList.add(body);
|
||||
// }
|
||||
// }
|
||||
// if (needAddBodyList != null && !needAddBodyList.isEmpty()) {
|
||||
// bodyTagService.insertAll(needAddBodyList);
|
||||
// }
|
||||
// }
|
||||
// //中间关系表
|
||||
// {
|
||||
// List<DirectiveBodyTagRelation> bodyRelations = Lists.newArrayList();//关系表
|
||||
// needAddDirectiveList.stream().forEach(d -> {
|
||||
// String bodyTags = d.getBodyTags();
|
||||
// if (StringUtils.isNotBlank(bodyTags)) {
|
||||
// Arrays.stream(bodyTags.split(",")).forEach(bi -> {
|
||||
// DirectiveBodyTagRelation r = new DirectiveBodyTagRelation();
|
||||
// r.setDirectiveId(d.getId());
|
||||
// r.setTagId(bi);
|
||||
// bodyRelations.add(r);
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
// bodyTagService.insertAllRelation(bodyRelations);
|
||||
// }
|
||||
// }
|
||||
//情绪标签
|
||||
{
|
||||
if (dto.getEmotionTagList() != null) {
|
||||
//需要排除的情绪标签id
|
||||
List<String> existedIds = Lists.newArrayList();
|
||||
if (dto.isIzInc()) {
|
||||
List<DirectiveEmotionTag> list = emotionTagService.list();
|
||||
existedIds = list.stream().map(DirectiveEmotionTag::getId).collect(Collectors.toList());
|
||||
}
|
||||
//传来的所有数据
|
||||
List<DirectiveEmotionTag> allData = BeanUtil.copyToList(dto.getEmotionTagList(), DirectiveEmotionTag.class);
|
||||
|
||||
//需要新增的数据
|
||||
List<DirectiveEmotionTag> needAddData = new ArrayList<>();//字典表
|
||||
for (DirectiveEmotionTag emotion : allData) {
|
||||
if (!existedIds.contains(emotion.getId())) {
|
||||
needAddData.add(emotion); // 如果不在排除列表里,就加入结果
|
||||
}
|
||||
}
|
||||
if (needAddData != null && !needAddData.isEmpty()) {
|
||||
emotionTagService.insertAll(needAddData);
|
||||
}
|
||||
}
|
||||
//中间关系表
|
||||
{
|
||||
List<DirectiveEmotionTagRelation> emotionRelations = Lists.newArrayList();//关系表
|
||||
needAddDirectiveList.stream().forEach(d -> {
|
||||
String emotionTags = d.getEmotionTags();
|
||||
if (StringUtils.isNotBlank(emotionTags)) {
|
||||
Arrays.stream(emotionTags.split(",")).forEach(bi -> {
|
||||
DirectiveEmotionTagRelation r = new DirectiveEmotionTagRelation();
|
||||
r.setDirectiveId(d.getId());
|
||||
r.setTagId(bi);
|
||||
emotionRelations.add(r);
|
||||
});
|
||||
}
|
||||
});
|
||||
emotionTagService.insertAllRelation(emotionRelations);
|
||||
}
|
||||
}
|
||||
// {
|
||||
// if (dto.getEmotionTagList() != null) {
|
||||
// //需要排除的情绪标签id
|
||||
// List<String> existedIds = Lists.newArrayList();
|
||||
// if (dto.isIzInc()) {
|
||||
// List<DirectiveEmotionTag> list = emotionTagService.list();
|
||||
// existedIds = list.stream().map(DirectiveEmotionTag::getId).collect(Collectors.toList());
|
||||
// }
|
||||
// //传来的所有数据
|
||||
// List<DirectiveEmotionTag> allData = BeanUtil.copyToList(dto.getEmotionTagList(), DirectiveEmotionTag.class);
|
||||
//
|
||||
// //需要新增的数据
|
||||
// List<DirectiveEmotionTag> needAddData = new ArrayList<>();//字典表
|
||||
// for (DirectiveEmotionTag emotion : allData) {
|
||||
// if (!existedIds.contains(emotion.getId())) {
|
||||
// needAddData.add(emotion); // 如果不在排除列表里,就加入结果
|
||||
// }
|
||||
// }
|
||||
// if (needAddData != null && !needAddData.isEmpty()) {
|
||||
// emotionTagService.insertAll(needAddData);
|
||||
// }
|
||||
// }
|
||||
// //中间关系表
|
||||
// {
|
||||
// List<DirectiveEmotionTagRelation> emotionRelations = Lists.newArrayList();//关系表
|
||||
// needAddDirectiveList.stream().forEach(d -> {
|
||||
// String emotionTags = d.getEmotionTags();
|
||||
// if (StringUtils.isNotBlank(emotionTags)) {
|
||||
// Arrays.stream(emotionTags.split(",")).forEach(bi -> {
|
||||
// DirectiveEmotionTagRelation r = new DirectiveEmotionTagRelation();
|
||||
// r.setDirectiveId(d.getId());
|
||||
// r.setTagId(bi);
|
||||
// emotionRelations.add(r);
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
// emotionTagService.insertAllRelation(emotionRelations);
|
||||
// }
|
||||
// }
|
||||
//分类标签
|
||||
if (dto.getInstructionList() != null) {
|
||||
//需要排除的分类标签id
|
||||
|
|
@ -935,161 +935,161 @@ public class DirectiveMQListener {
|
|||
String baseUrl = apiAddress;
|
||||
|
||||
//处理服务指令图片大图
|
||||
if (StringUtils.isNotBlank(dto.getPreviewFileMd5()) && !dto.getPreviewFileMd5().equals(currentDirective.getPreviewFileMd5())) {
|
||||
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);
|
||||
// if (StringUtils.isNotBlank(dto.getPreviewFileMd5()) && !dto.getPreviewFileMd5().equals(currentDirective.getPreviewFileMd5())) {
|
||||
// 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);
|
||||
configServiceDirective.setPreviewFile(dto.getPreviewFile());//服务指令图片大图
|
||||
configServiceDirective.setPreviewFileMd5(dto.getPreviewFileMd5());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
|
||||
mediaAsyncErrorLog.setMediaid(previewFile);
|
||||
mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
|
||||
throw new RuntimeException("服务指令图片大图文件拉取错误,指令id" + dto.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
|
||||
// mediaAsyncErrorLog.setMediaid(previewFile);
|
||||
// mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
|
||||
// throw new RuntimeException("服务指令图片大图文件拉取错误,指令id" + dto.getId());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//处理服务指令图片小图
|
||||
if (StringUtils.isNotBlank(dto.getPreviewFileSmallMd5()) && !dto.getPreviewFileSmallMd5().equals(currentDirective.getPreviewFileSmallMd5())) {
|
||||
String previewFileSmall = dto.getPreviewFileSmall();
|
||||
if (StringUtils.isNotBlank(previewFileSmall)) {
|
||||
String url = baseUrl + "/sys/common/open/static/" + URLEncoder.encode(previewFileSmall, StandardCharsets.UTF_8).replace("%2F", "/") + "?name=" + SafetyUtil.getSecureKey();
|
||||
if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) {
|
||||
upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1);
|
||||
}
|
||||
String filePath = previewFileSmall.substring(0, previewFileSmall.lastIndexOf("/"));
|
||||
String fileName = previewFileSmall.substring(previewFileSmall.lastIndexOf("/") + 1);
|
||||
if (filePath.startsWith("/") || filePath.startsWith("\\")) {
|
||||
filePath = filePath.substring(1);
|
||||
}
|
||||
try {
|
||||
FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath, fileName);
|
||||
// if (StringUtils.isNotBlank(dto.getPreviewFileSmallMd5()) && !dto.getPreviewFileSmallMd5().equals(currentDirective.getPreviewFileSmallMd5())) {
|
||||
// String previewFileSmall = dto.getPreviewFileSmall();
|
||||
// if (StringUtils.isNotBlank(previewFileSmall)) {
|
||||
// String url = baseUrl + "/sys/common/open/static/" + URLEncoder.encode(previewFileSmall, StandardCharsets.UTF_8).replace("%2F", "/") + "?name=" + SafetyUtil.getSecureKey();
|
||||
// if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) {
|
||||
// upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1);
|
||||
// }
|
||||
// String filePath = previewFileSmall.substring(0, previewFileSmall.lastIndexOf("/"));
|
||||
// String fileName = previewFileSmall.substring(previewFileSmall.lastIndexOf("/") + 1);
|
||||
// if (filePath.startsWith("/") || filePath.startsWith("\\")) {
|
||||
// filePath = filePath.substring(1);
|
||||
// }
|
||||
// try {
|
||||
// FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath, fileName);
|
||||
configServiceDirective.setPreviewFileSmall(dto.getPreviewFileSmall());//服务指令图片小图
|
||||
configServiceDirective.setPreviewFileSmallMd5(dto.getPreviewFileSmallMd5());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
|
||||
mediaAsyncErrorLog.setMediaid(previewFileSmall);
|
||||
mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
|
||||
throw new RuntimeException("服务指令图片小图文件拉取错误,指令id" + dto.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
|
||||
// mediaAsyncErrorLog.setMediaid(previewFileSmall);
|
||||
// mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
|
||||
// throw new RuntimeException("服务指令图片小图文件拉取错误,指令id" + dto.getId());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//处理即时指令图标
|
||||
if (StringUtils.isNotBlank(dto.getImmediateFileMd5()) && !dto.getImmediateFileMd5().equals(currentDirective.getImmediateFileMd5())) {
|
||||
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);
|
||||
// if (StringUtils.isNotBlank(dto.getImmediateFileMd5()) && !dto.getImmediateFileMd5().equals(currentDirective.getImmediateFileMd5())) {
|
||||
// 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);
|
||||
configServiceDirective.setImmediateFile(dto.getImmediateFile());//即时指令图标
|
||||
configServiceDirective.setImmediateFileMd5(dto.getImmediateFileMd5());
|
||||
} catch (Exception e) {
|
||||
MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
|
||||
mediaAsyncErrorLog.setMediaid(immediateFile);
|
||||
mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("即时指令图标文件拉取错误,指令id" + dto.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
// } catch (Exception e) {
|
||||
// MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
|
||||
// mediaAsyncErrorLog.setMediaid(immediateFile);
|
||||
// mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
|
||||
// e.printStackTrace();
|
||||
// throw new RuntimeException("即时指令图标文件拉取错误,指令id" + dto.getId());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//处理即时指令焦点图标
|
||||
if (StringUtils.isNotBlank(dto.getImmediateFileFocusMd5()) && !dto.getImmediateFileFocusMd5().equals(currentDirective.getImmediateFileFocusMd5())) {
|
||||
String immediateFileFocus = dto.getImmediateFileFocus();
|
||||
if (StringUtils.isNotBlank(immediateFileFocus)) {
|
||||
String url = baseUrl + "/sys/common/open/static/" + URLEncoder.encode(immediateFileFocus, StandardCharsets.UTF_8).replace("%2F", "/") + "?name=" + SafetyUtil.getSecureKey();
|
||||
if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) {
|
||||
upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1);
|
||||
}
|
||||
String filePath = immediateFileFocus.substring(0, immediateFileFocus.lastIndexOf("/"));
|
||||
String fileName = immediateFileFocus.substring(immediateFileFocus.lastIndexOf("/") + 1);
|
||||
if (filePath.startsWith("/") || filePath.startsWith("\\")) {
|
||||
filePath = filePath.substring(1);
|
||||
}
|
||||
try {
|
||||
FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath, fileName);
|
||||
// if (StringUtils.isNotBlank(dto.getImmediateFileFocusMd5()) && !dto.getImmediateFileFocusMd5().equals(currentDirective.getImmediateFileFocusMd5())) {
|
||||
// String immediateFileFocus = dto.getImmediateFileFocus();
|
||||
// if (StringUtils.isNotBlank(immediateFileFocus)) {
|
||||
// String url = baseUrl + "/sys/common/open/static/" + URLEncoder.encode(immediateFileFocus, StandardCharsets.UTF_8).replace("%2F", "/") + "?name=" + SafetyUtil.getSecureKey();
|
||||
// if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) {
|
||||
// upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1);
|
||||
// }
|
||||
// String filePath = immediateFileFocus.substring(0, immediateFileFocus.lastIndexOf("/"));
|
||||
// String fileName = immediateFileFocus.substring(immediateFileFocus.lastIndexOf("/") + 1);
|
||||
// if (filePath.startsWith("/") || filePath.startsWith("\\")) {
|
||||
// filePath = filePath.substring(1);
|
||||
// }
|
||||
// try {
|
||||
// FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath, fileName);
|
||||
configServiceDirective.setImmediateFileFocus(dto.getImmediateFileFocus());//即时指令图标
|
||||
configServiceDirective.setImmediateFileFocusMd5(dto.getImmediateFileFocusMd5());
|
||||
} catch (Exception e) {
|
||||
MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
|
||||
mediaAsyncErrorLog.setMediaid(immediateFileFocus);
|
||||
mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("即时指令图标文件拉取错误,指令id" + dto.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
// } catch (Exception e) {
|
||||
// MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
|
||||
// mediaAsyncErrorLog.setMediaid(immediateFileFocus);
|
||||
// mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
|
||||
// e.printStackTrace();
|
||||
// throw new RuntimeException("即时指令图标文件拉取错误,指令id" + dto.getId());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//处理指令音频文件
|
||||
if (StringUtils.isNotBlank(dto.getMp3FileMd5()) && !dto.getMp3FileMd5().equals(currentDirective.getMp3FileMd5())) {
|
||||
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);
|
||||
// if (StringUtils.isNotBlank(dto.getMp3FileMd5()) && !dto.getMp3FileMd5().equals(currentDirective.getMp3FileMd5())) {
|
||||
// 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);
|
||||
configServiceDirective.setMp3File(dto.getMp3File());//指令音频文件
|
||||
configServiceDirective.setMp3FileMd5(dto.getMp3FileMd5());
|
||||
} catch (Exception e) {
|
||||
MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
|
||||
mediaAsyncErrorLog.setMediaid(mp3File);
|
||||
mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("指令音频文件拉取错误,指令id" + dto.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
// } catch (Exception e) {
|
||||
// MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
|
||||
// mediaAsyncErrorLog.setMediaid(mp3File);
|
||||
// mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
|
||||
// e.printStackTrace();
|
||||
// throw new RuntimeException("指令音频文件拉取错误,指令id" + dto.getId());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//处理指令视频文件
|
||||
if (StringUtils.isNotBlank(dto.getMp4FileMd5()) && !dto.getMp4FileMd5().equals(currentDirective.getMp4FileMd5())) {
|
||||
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);
|
||||
// if (StringUtils.isNotBlank(dto.getMp4FileMd5()) && !dto.getMp4FileMd5().equals(currentDirective.getMp4FileMd5())) {
|
||||
// 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);
|
||||
configServiceDirective.setMp4File(dto.getMp4File());//指令视频文件
|
||||
configServiceDirective.setMp4FileMd5(dto.getMp4FileMd5());
|
||||
} catch (Exception e) {
|
||||
MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
|
||||
mediaAsyncErrorLog.setMediaid(mp4File);
|
||||
mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("指令视频文件拉取错误,指令id" + dto.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
// } catch (Exception e) {
|
||||
// MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
|
||||
// mediaAsyncErrorLog.setMediaid(mp4File);
|
||||
// mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
|
||||
// e.printStackTrace();
|
||||
// throw new RuntimeException("指令视频文件拉取错误,指令id" + dto.getId());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
directiveService.updateById(configServiceDirective);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,17 +1,21 @@
|
|||
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 lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.constant.SymbolConstant;
|
||||
import org.jeecg.common.constant.enums.FileTypeEnum;
|
||||
import org.jeecg.common.exception.JeecgBootException;
|
||||
import org.jeecg.common.util.CommonUtils;
|
||||
import org.jeecg.common.util.filter.SsrfFileTypeFilter;
|
||||
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.context.annotation.Lazy;
|
||||
import org.springframework.util.AntPathMatcher;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
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.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
|
@ -50,6 +51,9 @@ public class CommonController {
|
|||
@Value(value = "${jeecg.uploadType}")
|
||||
private String uploadType;
|
||||
|
||||
@Autowired
|
||||
private ISysConfigApi sysConfigApi;
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @Author 政辉
|
||||
|
|
@ -427,4 +431,47 @@ public class CommonController {
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue