From dd0cf7f1b192532f65ff6bbf49792a76fc687967 Mon Sep 17 00:00:00 2001 From: "castle.zang" Date: Wed, 12 Feb 2025 17:56:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug=2044248=20https=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/base/MesWhiteController.java | 40 +++++++++++++++++++--- .../mes/pcn/apiservice/model/MesPictureModel.java | 10 ++++++ 2 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/model/MesPictureModel.java diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/base/MesWhiteController.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/base/MesWhiteController.java index c75ac3b..6957dcb 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/base/MesWhiteController.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/base/MesWhiteController.java @@ -1,20 +1,32 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.controller.base; +import cn.estsh.i3plus.ext.mes.pcn.apiservice.model.MesPictureModel; +import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi.MesConfigService; import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi.MesProduceSnExtService; import cn.estsh.impp.framework.boot.util.ResultBean; +import cn.hutool.json.JSONUtil; +import io.swagger.annotations.Api; +import jodd.util.Base64; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import java.io.*; +import java.nio.file.Files; @RestController @RequestMapping("/white") +@Api(tags = "白名单") +@Slf4j public class MesWhiteController { @Autowired private MesProduceSnExtService mesProduceSnExtService; + @Autowired + private MesConfigService mesConfigService; + @GetMapping("/mesPartSap/{productSn}/{organizeCode}") public ResultBean getPartNo(@PathVariable String productSn,@PathVariable String organizeCode){ @@ -27,4 +39,24 @@ public class MesWhiteController { return ResultBean.success("查询成功").setResultObject(partNo); } + + @PostMapping("/picture") + public ResultBean savePicture(@RequestBody MesPictureModel model){ + + String localUrl = mesConfigService.getCfgValue(model.getOrganizeCode(), "LOCAL_PICTURE_ABS_URL"); + File file = new File(localUrl+model.getFileName()); + byte[] decode = Base64.decode(model.getFile()); + OutputStream outputStream; + try { + outputStream = Files.newOutputStream(file.toPath()); + outputStream.write(decode); + outputStream.close(); + } catch (IOException e) { + log.error("保存图片出错:{}",e.getMessage()); + log.error("入参为:{}", model); + } + return ResultBean.success("查询成功"); + + } + } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/model/MesPictureModel.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/model/MesPictureModel.java new file mode 100644 index 0000000..64d3d49 --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/model/MesPictureModel.java @@ -0,0 +1,10 @@ +package cn.estsh.i3plus.ext.mes.pcn.apiservice.model; + +import lombok.Data; + +@Data +public class MesPictureModel { + private String file; + private String fileName; + private String organizeCode; +}