Merge :remote-tracking branch 'origin/uat-temp-castle-250211-44248' into uat-temp-wj-chongqingdaqu-prod

uat-temp-wj-chongqingdaqu-prod
王杰 2 months ago
commit ea4076a106

@ -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 {

@ -5,6 +5,7 @@ import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack; import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.mes.bean.MesMediaFileCfg; import cn.estsh.i3plus.pojo.mes.bean.MesMediaFileCfg;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
/** /**
* @Description: * @Description:
@ -14,9 +15,19 @@ import org.springframework.stereotype.Service;
@Service @Service
@Slf4j @Slf4j
public class MesMediaFileCfgService extends BaseMesService<MesMediaFileCfg> implements IMesMediaFileCfgService { public class MesMediaFileCfgService extends BaseMesService<MesMediaFileCfg> implements IMesMediaFileCfgService {
@Autowired
private MesConfigService mesConfigService;
protected void setPackQueryBean(MesMediaFileCfg bean, DdlPackBean packBean) { protected void setPackQueryBean(MesMediaFileCfg bean, DdlPackBean packBean) {
DdlPreparedPack.getStringLikerPack(bean.getFileName(), "fileName", packBean); DdlPreparedPack.getStringLikerPack(bean.getFileName(), "fileName", packBean);
DdlPreparedPack.getNumEqualPack(bean.getFileType(), "fileType", packBean); DdlPreparedPack.getNumEqualPack(bean.getFileType(), "fileType", packBean);
} }
@Override
protected void onInsertBean(MesMediaFileCfg item) {
String localAddr = mesConfigService.getCfgValue(item.getOrganizeCode(), "LOCAL_PCN_PICTURE_ADDR");
String fileUrl = item.getFileUrl();
int index = fileUrl.lastIndexOf("/");
String fileName = fileUrl.substring(index + 1);
item.setLocalFileUrl(localAddr + fileName);
}
} }

Loading…
Cancel
Save