From 11b76893603a27a5e7d725643c7dcb0b53f97df4 Mon Sep 17 00:00:00 2001 From: yinq Date: Tue, 2 Apr 2024 10:52:06 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20=E8=8E=B7=E5=8F=96=E7=94=9F?= =?UTF-8?q?=E4=BA=A7=E5=B7=A5=E5=8D=95=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/controller/SAPPortController.java | 11 ++++++++ .../aucma/api/service/ISAPPortService.java | 9 +++++++ .../api/service/impl/SAPPortServiceImpl.java | 27 +++++++++++++++++++ .../impl/SAPPutStorageServiceImpl.java | 2 +- 4 files changed, 48 insertions(+), 1 deletion(-) diff --git a/aucma-api/src/main/java/com/aucma/api/controller/SAPPortController.java b/aucma-api/src/main/java/com/aucma/api/controller/SAPPortController.java index d3bf5c9..0c45dac 100644 --- a/aucma-api/src/main/java/com/aucma/api/controller/SAPPortController.java +++ b/aucma-api/src/main/java/com/aucma/api/controller/SAPPortController.java @@ -73,6 +73,17 @@ public class SAPPortController extends BaseController { return AjaxResult.success(BaseOrderInfoVoList); } + /** + * 获取生产工单测试 + * @param params + * @return + */ + @PostMapping ("/getProduceWorkTest") + public AjaxResult getProduceWorkTest(@RequestBody String params){ + List BaseOrderInfoVoList = sapPortService.getProduceWorkTest(params); + return AjaxResult.success(BaseOrderInfoVoList); + } + /** * 获取设备台账 * @param paramMap diff --git a/aucma-api/src/main/java/com/aucma/api/service/ISAPPortService.java b/aucma-api/src/main/java/com/aucma/api/service/ISAPPortService.java index 143a2c2..9c12011 100644 --- a/aucma-api/src/main/java/com/aucma/api/service/ISAPPortService.java +++ b/aucma-api/src/main/java/com/aucma/api/service/ISAPPortService.java @@ -8,8 +8,10 @@ import com.aucma.base.domain.BaseOrderInfo; import com.aucma.base.domain.OrderBomInfo; import com.aucma.production.domain.BaseBomInfo; import com.aucma.production.domain.CalendarInfo; +import com.fasterxml.jackson.core.JsonProcessingException; import org.springframework.stereotype.Service; +import java.text.ParseException; import java.util.List; /** @@ -55,4 +57,11 @@ public interface ISAPPortService { * @return 结果 */ public int addSAPCalendar(CalendarInfo calendarInfo); + + /** + * 获取生产工单测试 + * @param params + * @return + */ + List getProduceWorkTest(String params); } diff --git a/aucma-api/src/main/java/com/aucma/api/service/impl/SAPPortServiceImpl.java b/aucma-api/src/main/java/com/aucma/api/service/impl/SAPPortServiceImpl.java index aa963cf..3512342 100644 --- a/aucma-api/src/main/java/com/aucma/api/service/impl/SAPPortServiceImpl.java +++ b/aucma-api/src/main/java/com/aucma/api/service/impl/SAPPortServiceImpl.java @@ -25,6 +25,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.text.ParseException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -239,4 +240,30 @@ public class SAPPortServiceImpl implements ISAPPortService { this.getSapBaseOrderInfo(sapPortDto); return 1; } + + /** + * 获取生产工单测试 + * @param params + * @return + */ + @Override + public List getProduceWorkTest(String params) { + // 处理接口返回消息 + ArrayList baseOrderInfoVos = null; + try { + ObjectMapper resultMapper = new ObjectMapper(); + // 将 JSON 字符串转换为 Java 对象 + SAPResultOrderInfoVo resultVo = resultMapper.readValue(params, SAPResultOrderInfoVo.class); + + //判断返回数据是否正确 + if (StringUtils.isNull(resultVo.getO_RETURN()) || !resultVo.getO_RETURN().getItem().get(0).get("ID").contains("0")){ + throw new BaseException("处理接口返回消息错误!(ID不为0或O_RETURN为空)"); + } + //转工单实体类 保存数据 + baseOrderInfoVos = storageService.insertSAPBaseOrderInfo(resultVo); + } catch (JsonProcessingException | BaseException | ParseException e) { + e.printStackTrace(); + } + return baseOrderInfoVos; + } } diff --git a/aucma-api/src/main/java/com/aucma/api/service/impl/SAPPutStorageServiceImpl.java b/aucma-api/src/main/java/com/aucma/api/service/impl/SAPPutStorageServiceImpl.java index 6f33a07..c5ed7cd 100644 --- a/aucma-api/src/main/java/com/aucma/api/service/impl/SAPPutStorageServiceImpl.java +++ b/aucma-api/src/main/java/com/aucma/api/service/impl/SAPPutStorageServiceImpl.java @@ -170,7 +170,7 @@ public class SAPPutStorageServiceImpl implements ISAPPutStorageService { List> itemList = resultVo.getO_TAB().get("item"); for (HashMap map : itemList) { if (StringUtils.isEmpty(map.get("WERKS")) || !map.get("WERKS").equals(SAPConstants.FACTORY_CODE) - || !map.get("MATNR").startsWith("90")) { + || StringUtils.isEmpty(map.get("MATNR")) || !map.get("MATNR").startsWith("90")) { continue; } BaseOrderInfo boInfo = new BaseOrderInfo();