|
|
@ -12,7 +12,6 @@ import cn.hutool.http.HttpRequest;
|
|
|
|
import cn.hutool.http.HttpResponse;
|
|
|
|
import cn.hutool.http.HttpResponse;
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
import jodd.io.FileUtil;
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
@ -20,10 +19,9 @@ 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.io.File;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @Description: 媒体文件维护
|
|
|
|
* @Description: 媒体文件维护
|
|
|
@ -59,10 +57,21 @@ public class MesMediaFileCfgController extends BaseMesController<MesMediaFileCfg
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void afterInsert(MesMediaFileCfg mesMediaFileCfg) {
|
|
|
|
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
|
|
|
|
//1.如果localFileUrl不为空,需要下发到本地url
|
|
|
|
if (!StringUtils.isBlank(mesMediaFileCfg.getLocalFileUrl())){
|
|
|
|
if (!StringUtils.isBlank(mesMediaFileCfg.getLocalFileUrl())){
|
|
|
|
String fileUrl = mesMediaFileCfg.getFileUrl();
|
|
|
|
String fileUrl = mesMediaFileCfg.getFileUrl();
|
|
|
|
HttpRequest httpRequest = HttpRequest.get(mesMediaFileCfg.getFileUrl()).timeout(60000);
|
|
|
|
HttpRequest httpRequest = HttpRequest.get(mesMediaFileCfg.getFileUrl()).timeout(10000);
|
|
|
|
byte[] bytes = httpRequest.execute().bodyBytes();
|
|
|
|
byte[] bytes = httpRequest.execute().bodyBytes();
|
|
|
|
|
|
|
|
|
|
|
|
int index = fileUrl.lastIndexOf("/");
|
|
|
|
int index = fileUrl.lastIndexOf("/");
|
|
|
@ -71,21 +80,21 @@ public class MesMediaFileCfgController extends BaseMesController<MesMediaFileCfg
|
|
|
|
String localUrl = mesConfigService.getCfgValue(mesMediaFileCfg.getOrganizeCode(), "LOCAL_PCN_URL");
|
|
|
|
String localUrl = mesConfigService.getCfgValue(mesMediaFileCfg.getOrganizeCode(), "LOCAL_PCN_URL");
|
|
|
|
String localUrlPort = mesConfigService.getCfgValue(mesMediaFileCfg.getOrganizeCode(), "LOCAL_PCN_URL_PORT");
|
|
|
|
String localUrlPort = mesConfigService.getCfgValue(mesMediaFileCfg.getOrganizeCode(), "LOCAL_PCN_URL_PORT");
|
|
|
|
String localPcnUrlInterface = mesConfigService.getCfgValue(mesMediaFileCfg.getOrganizeCode(), "LOCAL_PCN_URL_INTERFACE");
|
|
|
|
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)){
|
|
|
|
if (!StringUtils.isBlank(localUrl) && !StringUtils.isBlank(localUrlPort) && !StringUtils.isBlank(localPcnUrlInterface)){
|
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
|
params.put("file", Base64.encode(bytes));
|
|
|
|
params.put("file", Base64.encode(bytes));
|
|
|
|
params.put("fileName", fileName);
|
|
|
|
params.put("fileName", fileName);
|
|
|
|
params.put("organizeCode",mesMediaFileCfg.getOrganizeCode());
|
|
|
|
params.put("organizeCode",mesMediaFileCfg.getOrganizeCode());
|
|
|
|
HttpResponse response = HttpRequest.post(localUrl + ":" + localUrlPort + localPcnUrlInterface).body(JSONUtil.toJsonStr(params)).timeout(60000).execute();
|
|
|
|
params.put("remoteNginxUrl",remoteNginxUrl);
|
|
|
|
String body1 = response.body();
|
|
|
|
params.put("remoteUserName",remoteUserName);
|
|
|
|
System.out.println(body1);
|
|
|
|
params.put("remotePort",remotePort);
|
|
|
|
}
|
|
|
|
HttpResponse response = HttpRequest.post(localUrl + ":" + localUrlPort + localPcnUrlInterface).body(JSONUtil.toJsonStr(params)).timeout(10000).execute();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// });
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void afterUpdate(MesMediaFileCfg mesMediaFileCfg) {
|
|
|
|
|
|
|
|
//1.如果localFileUrl不为空,需要下发到本地url
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|