|
|
|
@ -7,8 +7,10 @@ import cn.estsh.i3plus.icloud.core.sdk.ICoreSysFileCloud;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesMediaFileCfg;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.MesMediaFileCfgRepository;
|
|
|
|
|
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 jodd.io.FileUtil;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
@ -59,14 +61,24 @@ public class MesMediaFileCfgController extends BaseMesController<MesMediaFileCfg
|
|
|
|
|
public void afterInsert(MesMediaFileCfg mesMediaFileCfg) {
|
|
|
|
|
//1.如果localFileUrl不为空,需要下发到本地url
|
|
|
|
|
if (!StringUtils.isBlank(mesMediaFileCfg.getLocalFileUrl())){
|
|
|
|
|
File file = new File(mesMediaFileCfg.getFileUrl());
|
|
|
|
|
HttpRequest httpRequest = HttpRequest.get(mesMediaFileCfg.getFileUrl());
|
|
|
|
|
String fileUrl = mesMediaFileCfg.getFileUrl();
|
|
|
|
|
HttpRequest httpRequest = HttpRequest.get(mesMediaFileCfg.getFileUrl()).timeout(60000);
|
|
|
|
|
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");
|
|
|
|
|
if (!StringUtils.isBlank(localUrl) && !StringUtils.isBlank(localUrlPort) && !StringUtils.isBlank(localPcnUrlInterface)){
|
|
|
|
|
HttpResponse response = HttpRequest.post(localUrl + ":" + localUrlPort + localPcnUrlInterface).form("file", file).execute();
|
|
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
|
|
params.put("file", Base64.encode(bytes));
|
|
|
|
|
params.put("fileName", fileName);
|
|
|
|
|
params.put("organizeCode",mesMediaFileCfg.getOrganizeCode());
|
|
|
|
|
HttpResponse response = HttpRequest.post(localUrl + ":" + localUrlPort + localPcnUrlInterface).body(JSONUtil.toJsonStr(params)).timeout(60000).execute();
|
|
|
|
|
String body1 = response.body();
|
|
|
|
|
System.out.println(body1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|