修复bug 44248 https图片问题

uat-temp-castle-250211-44248
臧学普 3 months ago
parent 907adc5cf7
commit eb5df895d2

@ -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);
}
}
}

@ -28,6 +28,6 @@ public class MesMediaFileCfgService extends BaseMesService<MesMediaFileCfg> impl
String fileUrl = item.getFileUrl();
int index = fileUrl.lastIndexOf("/");
String fileName = fileUrl.substring(index + 1);
item.setLocalFileUrl(localAddr + "/"+ fileName);
item.setLocalFileUrl(localAddr + fileName);
}
}

Loading…
Cancel
Save