|
|
@ -1,18 +1,28 @@
|
|
|
|
package cn.estsh.i3plus.ext.mes.apiservice.controller.base;
|
|
|
|
package cn.estsh.i3plus.ext.mes.apiservice.controller.base;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.api.base.IMesMediaFileCfgService;
|
|
|
|
import cn.estsh.i3plus.ext.mes.api.base.IMesMediaFileCfgService;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.apiservice.serviceimpl.base.MesConfigService;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pojo.constant.MesCommonConstant;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pojo.constant.MesCommonConstant;
|
|
|
|
import cn.estsh.i3plus.icloud.core.sdk.ICoreSysFileCloud;
|
|
|
|
import cn.estsh.i3plus.icloud.core.sdk.ICoreSysFileCloud;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesMediaFileCfg;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesMediaFileCfg;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.MesMediaFileCfgRepository;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.MesMediaFileCfgRepository;
|
|
|
|
import cn.estsh.impp.framework.boot.fileservice.ImppFileService;
|
|
|
|
import cn.estsh.impp.framework.boot.fileservice.ImppFileService;
|
|
|
|
|
|
|
|
import cn.hutool.core.codec.Base64;
|
|
|
|
|
|
|
|
import cn.hutool.http.HttpRequest;
|
|
|
|
|
|
|
|
import cn.hutool.http.HttpResponse;
|
|
|
|
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @Description: 媒体文件维护
|
|
|
|
* @Description: 媒体文件维护
|
|
|
|
* @CreateDate 2024/6/6
|
|
|
|
* @CreateDate 2024/6/6
|
|
|
@ -34,6 +44,9 @@ public class MesMediaFileCfgController extends BaseMesController<MesMediaFileCfg
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private IMesMediaFileCfgService mediaFileCfgService;
|
|
|
|
private IMesMediaFileCfgService mediaFileCfgService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private MesConfigService mesConfigService;
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* fastDfs客户端
|
|
|
|
* fastDfs客户端
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -42,7 +55,51 @@ public class MesMediaFileCfgController extends BaseMesController<MesMediaFileCfg
|
|
|
|
//默认大小
|
|
|
|
//默认大小
|
|
|
|
private static final long FILE_SIZE = 1024 * 1024;
|
|
|
|
private static final long FILE_SIZE = 1024 * 1024;
|
|
|
|
|
|
|
|
|
|
|
|
// @PostMapping(value = "/obs/upload")
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void afterInsert(MesMediaFileCfg mesMediaFileCfg) {
|
|
|
|
|
|
|
|
uploadPng(mesMediaFileCfg);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void afterUpdate(MesMediaFileCfg mesMediaFileCfg) {
|
|
|
|
|
|
|
|
//1.如果localFileUrl不为空,需要下发到本地url
|
|
|
|
|
|
|
|
uploadPng(mesMediaFileCfg);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void uploadPng(MesMediaFileCfg mesMediaFileCfg){
|
|
|
|
|
|
|
|
// CompletableFuture.runAsync(()->{
|
|
|
|
|
|
|
|
//1.如果localFileUrl不为空,需要下发到本地url
|
|
|
|
|
|
|
|
if (!StringUtils.isBlank(mesMediaFileCfg.getLocalFileUrl())){
|
|
|
|
|
|
|
|
String fileUrl = mesMediaFileCfg.getFileUrl();
|
|
|
|
|
|
|
|
HttpRequest httpRequest = HttpRequest.get(mesMediaFileCfg.getFileUrl()).timeout(10000);
|
|
|
|
|
|
|
|
byte[] bytes = httpRequest.execute().bodyBytes();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int index = fileUrl.lastIndexOf("/");
|
|
|
|
|
|
|
|
String fileName = fileUrl.substring(index + 1);
|
|
|
|
|
|
|
|
//获取pcn的地址
|
|
|
|
|
|
|
|
String localUrl = mesConfigService.getCfgValue(mesMediaFileCfg.getOrganizeCode(), "LOCAL_PCN_URL");
|
|
|
|
|
|
|
|
String localUrlPort = mesConfigService.getCfgValue(mesMediaFileCfg.getOrganizeCode(), "LOCAL_PCN_URL_PORT");
|
|
|
|
|
|
|
|
String localPcnUrlInterface = mesConfigService.getCfgValue(mesMediaFileCfg.getOrganizeCode(), "LOCAL_PCN_URL_INTERFACE");
|
|
|
|
|
|
|
|
String remoteNginxUrl = mesConfigService.getCfgValue(mesMediaFileCfg.getOrganizeCode(), "REMOTE_NGINX_URL");
|
|
|
|
|
|
|
|
String remoteUserName = mesConfigService.getCfgValue(mesMediaFileCfg.getOrganizeCode(), "REMOTE_USER_NAME");
|
|
|
|
|
|
|
|
String remotePort = mesConfigService.getCfgValue(mesMediaFileCfg.getOrganizeCode(), "REMOTE_PORT");
|
|
|
|
|
|
|
|
if (!StringUtils.isBlank(localUrl) && !StringUtils.isBlank(localUrlPort) && !StringUtils.isBlank(localPcnUrlInterface)){
|
|
|
|
|
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
|
|
|
|
|
params.put("file", Base64.encode(bytes));
|
|
|
|
|
|
|
|
params.put("fileName", fileName);
|
|
|
|
|
|
|
|
params.put("organizeCode",mesMediaFileCfg.getOrganizeCode());
|
|
|
|
|
|
|
|
params.put("remoteNginxUrl",remoteNginxUrl);
|
|
|
|
|
|
|
|
params.put("remoteUserName",remoteUserName);
|
|
|
|
|
|
|
|
params.put("remotePort",remotePort);
|
|
|
|
|
|
|
|
HttpResponse response = HttpRequest.post(localUrl + ":" + localUrlPort + localPcnUrlInterface).body(JSONUtil.toJsonStr(params)).timeout(10000).execute();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// @PostMapping(value = "/obs/upload")
|
|
|
|
// @ApiOperation(value = "上传媒体文件")
|
|
|
|
// @ApiOperation(value = "上传媒体文件")
|
|
|
|
// public ResultBean obsUploadFile(@RequestParam("file") MultipartFile file, MesMediaFileCfg mesMediaFileCfg) {
|
|
|
|
// public ResultBean obsUploadFile(@RequestParam("file") MultipartFile file, MesMediaFileCfg mesMediaFileCfg) {
|
|
|
|
// try {
|
|
|
|
// try {
|
|
|
|