|
|
|
@ -8,6 +8,7 @@ import cn.hutool.json.JSONUtil;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import jodd.util.Base64;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
@ -42,9 +43,10 @@ public class MesWhiteController {
|
|
|
|
|
|
|
|
|
|
@PostMapping("/picture")
|
|
|
|
|
public ResultBean savePicture(@RequestBody MesPictureModel model){
|
|
|
|
|
|
|
|
|
|
log.info("castle-保存图片开始");
|
|
|
|
|
String localUrl = mesConfigService.getCfgValue(model.getOrganizeCode(), "LOCAL_PICTURE_ABS_URL");
|
|
|
|
|
File file = new File(localUrl+model.getFileName());
|
|
|
|
|
String fileName = localUrl+model.getFileName();
|
|
|
|
|
File file = new File(fileName);
|
|
|
|
|
byte[] decode = Base64.decode(model.getFile());
|
|
|
|
|
OutputStream outputStream;
|
|
|
|
|
try {
|
|
|
|
@ -55,6 +57,17 @@ public class MesWhiteController {
|
|
|
|
|
log.error("保存图片出错:{}",e.getMessage());
|
|
|
|
|
log.error("入参为:{}", model);
|
|
|
|
|
}
|
|
|
|
|
if (!StringUtils.isBlank(model.getRemoteUserName()) && !StringUtils.isBlank(model.getRemoteNginxUrl()) ){
|
|
|
|
|
// 构建scp命令
|
|
|
|
|
log.info("castle-保存图片开始-scp命令");
|
|
|
|
|
String scpCommand = String.format("scp -P %d -i %s %s@%s:%s", model.getRemotePort() ,fileName, model.getRemoteUserName(), model.getRemoteNginxUrl(), localUrl);
|
|
|
|
|
try {
|
|
|
|
|
Runtime.getRuntime().exec(scpCommand);
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
log.error("调用scp命令失败,请手动同步图片:{}",fileName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ResultBean.success("查询成功");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|