diff --git a/aucma-api/pom.xml b/aucma-api/pom.xml index 659ef3f..b1f935b 100644 --- a/aucma-api/pom.xml +++ b/aucma-api/pom.xml @@ -22,6 +22,10 @@ com.aucma aucma-base + + com.aucma + aucma-production + - \ No newline at end of file + 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 2e8ee3f..d26b2be 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 @@ -8,6 +8,7 @@ import com.aucma.base.domain.BaseMaterialInfo; import com.aucma.base.domain.BaseOrderInfo; import com.aucma.common.core.controller.BaseController; import com.aucma.common.core.domain.AjaxResult; +import com.aucma.production.domain.BaseBomInfo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -80,7 +81,21 @@ public class SAPPortController extends BaseController { List BaseDeviceLedgerVoList = sapPortService.getSapDeviceLedgers(sapPortDto); return AjaxResult.success(BaseDeviceLedgerVoList); } - + /** + * 获取产品bom信息 + * */ + @PostMapping("/getBaseBomInfo") + public AjaxResult getBaseBomInfo(@RequestBody Map paramMap) { + SAPPortDto sapPortDto = new SAPPortDto(); + sapPortDto.setStartDate(String.valueOf(paramMap.get("NDATE"))); + sapPortDto.setEndDate(String.valueOf(paramMap.get("EDATE"))); + HashMap>> werksMap = (HashMap>>)paramMap.get("WERKS"); + WERKSDto werksDto = new WERKSDto(); + werksDto.setItem(werksMap.get("item")); + sapPortDto.setFactoryCodes(werksDto); + List BaeeBomVoList = sapPortService.getSapBaseBomInfo(sapPortDto); + return AjaxResult.success(BaeeBomVoList); + } diff --git a/aucma-api/src/main/java/com/aucma/api/domain/vo/SAPResultBomVo.java b/aucma-api/src/main/java/com/aucma/api/domain/vo/SAPResultBomVo.java new file mode 100644 index 0000000..ab1533b --- /dev/null +++ b/aucma-api/src/main/java/com/aucma/api/domain/vo/SAPResultBomVo.java @@ -0,0 +1,91 @@ +package com.aucma.api.domain.vo; + +import com.aucma.api.domain.dto.WERKSDto; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.HashMap; +import java.util.List; + +/** + * @ClassName : SAPResultBomVo + * @Description : zhouhy + * @Author : + * @Date: 2023-10-08 10:05 + */ +public class SAPResultBomVo { + @JsonProperty(value = "O_TAB") + private HashMap>> O_TAB; + + @JsonProperty(value = "WERKS") + private WERKSDto WERKS; + + @JsonProperty(value = "O_RETURN") + private WERKSDto O_RETURN; + + @JsonProperty(value = "EDATE") + private String EDATE; + @JsonProperty(value = "NDATE") + private String NDATE; + @JsonProperty(value = "XTYPE") + private String XTYPE; + + public HashMap>> getO_TAB() { + return O_TAB; + } + + public void setO_TAB(HashMap>> o_TAB) { + O_TAB = o_TAB; + } + + public WERKSDto getWERKS() { + return WERKS; + } + + public void setWERKS(WERKSDto WERKS) { + this.WERKS = WERKS; + } + + public WERKSDto getO_RETURN() { + return O_RETURN; + } + + public void setO_RETURN(WERKSDto o_RETURN) { + O_RETURN = o_RETURN; + } + + public String getEDATE() { + return EDATE; + } + + public void setEDATE(String EDATE) { + this.EDATE = EDATE; + } + + public String getNDATE() { + return NDATE; + } + + public void setNDATE(String NDATE) { + this.NDATE = NDATE; + } + + public String getXTYPE() { + return XTYPE; + } + + public void setXTYPE(String XTYPE) { + this.XTYPE = XTYPE; + } + + @Override + public String toString() { + return "SAPResultBomVo{" + + "O_TAB=" + O_TAB + + ", WERKS=" + WERKS + + ", O_RETURN=" + O_RETURN + + ", EDATE='" + EDATE + '\'' + + ", NDATE='" + NDATE + '\'' + + ", XTYPE='" + XTYPE + '\'' + + '}'; + } +} 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 fc83ffd..922ad2e 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 @@ -4,6 +4,7 @@ import com.aucma.api.domain.dto.SAPPortDto; import com.aucma.base.domain.BaseDeviceLedger; import com.aucma.base.domain.BaseMaterialInfo; import com.aucma.base.domain.BaseOrderInfo; +import com.aucma.production.domain.BaseBomInfo; import org.springframework.stereotype.Service; import java.util.List; @@ -25,6 +26,7 @@ public interface ISAPPortService { List getSapBaseOrderInfo(SAPPortDto sapPortDto); List getSapDeviceLedgers(SAPPortDto sapPortDto); + List getSapBaseBomInfo(SAPPortDto sapPortDto); diff --git a/aucma-api/src/main/java/com/aucma/api/service/ISAPPutStorageService.java b/aucma-api/src/main/java/com/aucma/api/service/ISAPPutStorageService.java index 3deb66a..afe0236 100644 --- a/aucma-api/src/main/java/com/aucma/api/service/ISAPPutStorageService.java +++ b/aucma-api/src/main/java/com/aucma/api/service/ISAPPutStorageService.java @@ -1,9 +1,11 @@ package com.aucma.api.service; +import com.aucma.api.domain.vo.SAPResultBomVo; import com.aucma.api.domain.vo.SAPResultVo; import com.aucma.base.domain.BaseDeviceLedger; import com.aucma.base.domain.BaseMaterialInfo; import com.aucma.base.domain.BaseOrderInfo; +import com.aucma.production.domain.BaseBomInfo; import java.text.ParseException; import java.util.ArrayList; @@ -35,5 +37,10 @@ public interface ISAPPutStorageService { */ public ArrayList insertSAPDeviceLedger(SAPResultVo resultVo) throws ParseException; + /** + * 转换产品bom信息实体类 保存数据 + * + * */ + public ArrayList insertSAPBaseBomInfo(SAPResultBomVo resultVo) throws ParseException; } 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 abdc9e1..352336f 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 @@ -3,6 +3,7 @@ package com.aucma.api.service.impl; import com.aucma.api.domain.dto.SAPPortDto; import com.aucma.api.domain.dto.WERKSDto; +import com.aucma.api.domain.vo.SAPResultBomVo; import com.aucma.api.domain.vo.SAPResultVo; import com.aucma.api.service.ISAPPortService; import com.aucma.api.service.ISAPPutStorageService; @@ -13,6 +14,7 @@ import com.aucma.base.domain.BaseOrderInfo; import com.aucma.common.exception.base.BaseException; import com.aucma.common.utils.StringUtils; import com.aucma.common.utils.http.HttpUtils; +import com.aucma.production.domain.BaseBomInfo; import com.aucma.system.utils.PortLogUtils; import com.fasterxml.jackson.databind.ObjectMapper; import org.springframework.beans.factory.annotation.Autowired; @@ -147,6 +149,9 @@ public class SAPPortServiceImpl implements ISAPPortService { result = HttpUtils.sendHttpPost(SAPConstants.SAP_PREFIX_URL + SAPConstants.EQUIPMENT_URL, requestParam); // 处理接口返回消息 // result = "{\"O_TAB\":{\"item\":[{\"MAKTX\":\"压缩机,GP14TG,R134a,ACC\",\"WERKS\":\"2004\",\"MTART\":\"ROH\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-21\",\"MATNR\":\"000000003000000125\"},{\"MAKTX\":\"压缩机,GP14TG,R134a,ACC\",\"WERKS\":\"2006\",\"MTART\":\"ROH\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-21\",\"MATNR\":\"000000003000000125\"},{\"MAKTX\":\"压缩机,NL7CLX,R404a,丹佛斯\",\"WERKS\":\"2004\",\"MTART\":\"ROH\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-21\",\"MATNR\":\"000000003000000126\"},{\"MAKTX\":\"压缩机,NL7CLX,R404a,丹佛斯\",\"WERKS\":\"2006\",\"MTART\":\"ROH\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-21\",\"MATNR\":\"000000003000000126\"},{\"MAKTX\":\"压缩机,HVY57AA,R600a,奥地利ACC\",\"WERKS\":\"2004\",\"MTART\":\"ROH\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-21\",\"MATNR\":\"000000003000000127\"},{\"MAKTX\":\"压缩机,HVY57AA,R600a,奥地利ACC\",\"WERKS\":\"2006\",\"MTART\":\"ROH\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-21\",\"MATNR\":\"000000003000000127\"},{\"MAKTX\":\"压缩机,HVY67AA,R600a,奥地利ACC\",\"WERKS\":\"2004\",\"MTART\":\"ROH\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-21\",\"MATNR\":\"000000003000000128\"},{\"MAKTX\":\"压缩机,HVY67AA,R600a,奥地利ACC\",\"WERKS\":\"2006\",\"MTART\":\"ROH\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-21\",\"MATNR\":\"000000003000000128\"},{\"MAKTX\":\"压缩机,MR22FB,R404a,ACC\",\"WERKS\":\"2004\",\"MTART\":\"ROH\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-21\",\"MATNR\":\"000000003000000129\"},{\"MAKTX\":\"压缩机,MR22FB,R404a,ACC\",\"WERKS\":\"2006\",\"MTART\":\"ROH\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-21\",\"MATNR\":\"000000003000000129\"},{\"MAKTX\":\"盖后加固体,BC/BD-127FA\",\"WERKS\":\"2004\",\"MTART\":\"HALB\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-06\",\"MATNR\":\"000000008106000102\"},{\"MAKTX\":\"SC-246,YZXGWB乳品\",\"WERKS\":\"2006\",\"MTART\":\"FERT\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-22\",\"MATNR\":\"000000009002003478\"},{\"MAKTX\":\"SD-460,YZXGW蒙牛冰品\",\"WERKS\":\"2004\",\"MTART\":\"FERT\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-22\",\"MATNR\":\"000000009000004735\"},{\"MAKTX\":\"BC-100E,特需\",\"WERKS\":\"2006\",\"MTART\":\"FERT\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-02\",\"MATNR\":\"000000009001002406\"},{\"MAKTX\":\"BD(C)-310T,特需\",\"WERKS\":\"2004\",\"MTART\":\"FERT\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-20\",\"MATNR\":\"000000009000000225\"}]},\"WERKS\":null,\"O_RETURN\":{\"item\":[{\"MESSAGE\":\"查询成功1!\",\"ID\":\" 0\",\"TYPE\":\"S\"}]}}"; + System.out.println("========================================================"); + System.out.println(result); + System.out.println("========================================================"); ObjectMapper resultMapper = new ObjectMapper(); // 将 JSON 字符串转换为 Java 对象 SAPResultVo resultVo = resultMapper.readValue(result, SAPResultVo.class); @@ -166,5 +171,49 @@ public class SAPPortServiceImpl implements ISAPPortService { return baseDeviceLedgersVos; } + @Override + public List getSapBaseBomInfo(SAPPortDto sapPortDto) { + String startDate = sapPortDto.getStartDate(); + String endDate = sapPortDto.getEndDate(); + WERKSDto werks = sapPortDto.getFactoryCodes(); + String intervalDate = "(" + startDate + "——" + endDate + ")"; + if (StringUtils.isEmpty(startDate) || StringUtils.isEmpty(endDate) || StringUtils.isNull(werks)) { + return null; + } + ArrayList baseBomInfosVos = new ArrayList<>(); + String requestParam = null; + String result = null; + try { + // 创建ObjectMapper实例 对象转JSON字符串 + ObjectMapper objectMapper = new ObjectMapper(); + // 格式化输出 + // objectMapper.configure(SerializationFeature.INDENT_OUTPUT, true); + requestParam = objectMapper.writeValueAsString(sapPortDto); + result = HttpUtils.sendHttpPost(SAPConstants.SAP_PREFIX_URL + SAPConstants.PRODUCTS_BOM_URL, requestParam); + // 处理接口返回消息 + System.out.println("========================================================"); + System.out.println(result); + System.out.println("========================================================"); + + // result = "{\"O_TAB\":{\"item\":[{\"MAKTX\":\"压缩机,GP14TG,R134a,ACC\",\"WERKS\":\"2004\",\"MTART\":\"ROH\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-21\",\"MATNR\":\"000000003000000125\"},{\"MAKTX\":\"压缩机,GP14TG,R134a,ACC\",\"WERKS\":\"2006\",\"MTART\":\"ROH\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-21\",\"MATNR\":\"000000003000000125\"},{\"MAKTX\":\"压缩机,NL7CLX,R404a,丹佛斯\",\"WERKS\":\"2004\",\"MTART\":\"ROH\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-21\",\"MATNR\":\"000000003000000126\"},{\"MAKTX\":\"压缩机,NL7CLX,R404a,丹佛斯\",\"WERKS\":\"2006\",\"MTART\":\"ROH\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-21\",\"MATNR\":\"000000003000000126\"},{\"MAKTX\":\"压缩机,HVY57AA,R600a,奥地利ACC\",\"WERKS\":\"2004\",\"MTART\":\"ROH\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-21\",\"MATNR\":\"000000003000000127\"},{\"MAKTX\":\"压缩机,HVY57AA,R600a,奥地利ACC\",\"WERKS\":\"2006\",\"MTART\":\"ROH\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-21\",\"MATNR\":\"000000003000000127\"},{\"MAKTX\":\"压缩机,HVY67AA,R600a,奥地利ACC\",\"WERKS\":\"2004\",\"MTART\":\"ROH\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-21\",\"MATNR\":\"000000003000000128\"},{\"MAKTX\":\"压缩机,HVY67AA,R600a,奥地利ACC\",\"WERKS\":\"2006\",\"MTART\":\"ROH\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-21\",\"MATNR\":\"000000003000000128\"},{\"MAKTX\":\"压缩机,MR22FB,R404a,ACC\",\"WERKS\":\"2004\",\"MTART\":\"ROH\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-21\",\"MATNR\":\"000000003000000129\"},{\"MAKTX\":\"压缩机,MR22FB,R404a,ACC\",\"WERKS\":\"2006\",\"MTART\":\"ROH\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-21\",\"MATNR\":\"000000003000000129\"},{\"MAKTX\":\"盖后加固体,BC/BD-127FA\",\"WERKS\":\"2004\",\"MTART\":\"HALB\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-06\",\"MATNR\":\"000000008106000102\"},{\"MAKTX\":\"SC-246,YZXGWB乳品\",\"WERKS\":\"2006\",\"MTART\":\"FERT\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-22\",\"MATNR\":\"000000009002003478\"},{\"MAKTX\":\"SD-460,YZXGW蒙牛冰品\",\"WERKS\":\"2004\",\"MTART\":\"FERT\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-22\",\"MATNR\":\"000000009000004735\"},{\"MAKTX\":\"BC-100E,特需\",\"WERKS\":\"2006\",\"MTART\":\"FERT\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-02\",\"MATNR\":\"000000009001002406\"},{\"MAKTX\":\"BD(C)-310T,特需\",\"WERKS\":\"2004\",\"MTART\":\"FERT\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-20\",\"MATNR\":\"000000009000000225\"}]},\"WERKS\":null,\"O_RETURN\":{\"item\":[{\"MESSAGE\":\"查询成功1!\",\"ID\":\" 0\",\"TYPE\":\"S\"}]}}"; + ObjectMapper resultMapper = new ObjectMapper(); + // 将 JSON 字符串转换为 Java 对象 + SAPResultBomVo resultVo = resultMapper.readValue(result, SAPResultBomVo.class); + //判断返回数据是否正确 +// if (StringUtils.isNull(resultVo.getO_RETURN()) || !"0".equals(resultVo.getO_RETURN().get(0).get("ID"))){ +// throw new BaseException("处理接口返回消息错误!(ID不为0或O_RETURN为空)"); +// } + //转物料实体类 保存数据 + baseBomInfosVos = storageService.insertSAPBaseBomInfo(resultVo); + //保存接口日志 + PortLogUtils.savePortLog(werks.getItem().get(0).get("IWERK"), "获取SAP物料主数据" + intervalDate, "getSapBaseBomInfo", requestParam, result, null); + } catch (Exception e) { + //保存接口日志 + System.out.println(e.getMessage()); + PortLogUtils.savePortLog(werks.getItem().get(0).get("IWERK"), "获取SAP物料主数据" + intervalDate, "getSapBaseBomInfo", requestParam, result, e.toString()); + } + return baseBomInfosVos; + } + } 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 10a4fae..3810cd8 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 @@ -1,5 +1,6 @@ package com.aucma.api.service.impl; +import com.aucma.api.domain.vo.SAPResultBomVo; import com.aucma.api.domain.vo.SAPResultVo; import com.aucma.api.service.ISAPPutStorageService; import com.aucma.base.domain.BaseDeviceLedger; @@ -8,11 +9,17 @@ import com.aucma.base.domain.BaseOrderInfo; import com.aucma.base.service.IBaseDeviceLedgerService; import com.aucma.base.service.IBaseMaterialInfoService; import com.aucma.base.service.IBaseOrderInfoService; +import com.aucma.common.utils.DateUtils; +import com.aucma.common.utils.SecurityUtils; +import com.aucma.production.domain.BaseBomInfo; +import com.aucma.production.service.IBaseBomInfoService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.core.parameters.P; import org.springframework.stereotype.Service; import java.text.ParseException; import java.text.SimpleDateFormat; +import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; @@ -34,6 +41,8 @@ public class SAPPutStorageServiceImpl implements ISAPPutStorageService { @Autowired private IBaseOrderInfoService baseOrderInfoService; + @Autowired + private IBaseBomInfoService baseBomInfoService; /** * 转物料实体类 保存数据 @@ -66,41 +75,30 @@ public class SAPPutStorageServiceImpl implements ISAPPutStorageService { List> itemList = resultVo.getO_TAB().get("item"); for (HashMap map : itemList) { int item = 0; - List baseOrderInfos = baseOrderInfoService.selectBaseOrderInfoList(null); - //查出值进行比对 如果数据库中已有该字段则忽略本次数据 - //缺少工作中心 - for (int i=0;i baseOrderInfos = baseOrderInfoService.selectBaseOrderInfoList(boInfo); + if (baseOrderInfos.isEmpty()){ + BaseOrderInfo baseOrderInfo = new BaseOrderInfo(); + baseOrderInfo.setOrderCode(map.get("AUFNR")); + baseOrderInfo.setOrderStatus(map.get("STTXT")); + baseOrderInfo.setSaleOrderCode(map.get("KDAUF")); + baseOrderInfo.setMaterialCode(map.get("MATNR")); + baseOrderInfo.setMaterialName(map.get("MAKTX")); + if (!map.get("GAMNG").equals(null)){ + baseOrderInfo.setOrderAmount(Long.valueOf(map.get("GAMNG"))); + } + baseOrderInfo.setFactoryCode(map.get("WERKS")); + baseOrderInfo.setOrderType(map.get("AUART")); + baseOrderInfo.setBeginDate(new SimpleDateFormat("yyyy-MM-dd").parse(map.get("GLTRP"))); + baseOrderInfo.setEndDate(new SimpleDateFormat("yyyy-MM-dd").parse(map.get("GSTRP"))); + baseOrderInfo.setCreatedTime(DateUtils.getNowDate()); + baseOrderInfoService.insertBaseOrderInfo(baseOrderInfo); + + baseOrderInfoList.add(baseOrderInfo); + } - } - } - if (item==0){ - BaseOrderInfo baseOrderInfo = new BaseOrderInfo(); - baseOrderInfo.setOrderCode(map.get("AUFNR")); - baseOrderInfo.setOrderStatus(map.get("STTXT")); - baseOrderInfo.setSaleOrderCode(map.get("KDAUF")); - baseOrderInfo.setMaterialCode(map.get("MATNR")); - baseOrderInfo.setMaterialName(map.get("MAKTX")); - if (!map.get("GAMNG").equals(null)){ - baseOrderInfo.setOrderAmount(Long.valueOf(map.get("GAMNG"))); - } - baseOrderInfo.setFactoryCode(map.get("WERKS")); - baseOrderInfo.setOrderType(map.get("AUART")); - baseOrderInfo.setBeginDate(new SimpleDateFormat("yyyy-MM-dd").parse(map.get("GLTRP"))); - baseOrderInfo.setEndDate(new SimpleDateFormat("yyyy-MM-dd").parse(map.get("GSTRP"))); - - baseOrderInfoService.insertBaseOrderInfo(baseOrderInfo); - - baseOrderInfoList.add(baseOrderInfo); - } } @@ -142,6 +140,8 @@ public class SAPPutStorageServiceImpl implements ISAPPutStorageService { deviceLedger.setDeviceType(map.get("EQTYP")); deviceLedger.setDeviceCode(map.get("EQUNR"));// deviceLedger.setUsedDepartment(map.get("NAME1")); + deviceLedger.setCreatedTime(DateUtils.getNowDate()); + baseDeviceLedgerService.insertBaseDeviceLedger(deviceLedger); baseDeviceLedgerArrayList.add(deviceLedger); } @@ -149,5 +149,28 @@ public class SAPPutStorageServiceImpl implements ISAPPutStorageService { return baseDeviceLedgerArrayList; } + @Override + public ArrayList insertSAPBaseBomInfo(SAPResultBomVo resultVo) throws ParseException { + ArrayList baseBomInfoList = new ArrayList<>(); + List> itemList = resultVo.getO_TAB().get("item"); + BaseBomInfo bbInfo = new BaseBomInfo(); + for (HashMap map : itemList) { + BaseBomInfo baseBomInfo = new BaseBomInfo(); + baseBomInfo.setPlantCode(map.get("WERKS")); + baseBomInfo.setParentId(map.get("MATNR")); + baseBomInfo.setMaterialCode(map.get("IDNRK")); + if (!map.get("MENGE").isEmpty()){ + baseBomInfo.setStandardAmount(Long.parseLong(map.get("MENGE"))); + } + baseBomInfo.setCreatedTime(DateUtils.getNowDate()); +// baseBomInfo.setCreatedBy(SecurityUtils.getLoginUser().getUsername()); + baseBomInfoService.insertBaseBomInfo(baseBomInfo); + baseBomInfoList.add(baseBomInfo); + } + + + return baseBomInfoList; + } + } diff --git a/aucma-common/src/main/java/com/aucma/common/utils/uuid/PlanCodeUtils.java b/aucma-common/src/main/java/com/aucma/common/utils/uuid/PlanCodeUtils.java index 17a1d3f..8c03cd8 100644 --- a/aucma-common/src/main/java/com/aucma/common/utils/uuid/PlanCodeUtils.java +++ b/aucma-common/src/main/java/com/aucma/common/utils/uuid/PlanCodeUtils.java @@ -28,11 +28,8 @@ public class PlanCodeUtils { LocalDate date = LocalDate.now(); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyMMdd"); String format = date.format(formatter); - Boolean flag=SpringUtils.getBean(RedisCache.class).hasKey(format); - - System.out.println(flag); //以当日日期作为key - if (!flag) { + if (!SpringUtils.getBean(RedisCache.class).hasKey(format)) { SpringUtils.getBean(RedisCache.class).setCacheObject(format,1); SpringUtils.getBean(RedisCache.class).expire(format,getSecondsNextEarlyMorning(), TimeUnit.SECONDS); }