获取bom产品信息接口

master
zhouhy 1 year ago
parent ac4efe9b12
commit 580b7d3107

@ -22,6 +22,10 @@
<groupId>com.aucma</groupId> <groupId>com.aucma</groupId>
<artifactId>aucma-base</artifactId> <artifactId>aucma-base</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.aucma</groupId>
<artifactId>aucma-production</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>

@ -8,6 +8,7 @@ import com.aucma.base.domain.BaseMaterialInfo;
import com.aucma.base.domain.BaseOrderInfo; import com.aucma.base.domain.BaseOrderInfo;
import com.aucma.common.core.controller.BaseController; import com.aucma.common.core.controller.BaseController;
import com.aucma.common.core.domain.AjaxResult; import com.aucma.common.core.domain.AjaxResult;
import com.aucma.production.domain.BaseBomInfo;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
@ -80,7 +81,21 @@ public class SAPPortController extends BaseController {
List<BaseDeviceLedger> BaseDeviceLedgerVoList = sapPortService.getSapDeviceLedgers(sapPortDto); List<BaseDeviceLedger> BaseDeviceLedgerVoList = sapPortService.getSapDeviceLedgers(sapPortDto);
return AjaxResult.success(BaseDeviceLedgerVoList); 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<String,List<HashMap<String,String>>> werksMap = (HashMap<String,List<HashMap<String,String>>>)paramMap.get("WERKS");
WERKSDto werksDto = new WERKSDto();
werksDto.setItem(werksMap.get("item"));
sapPortDto.setFactoryCodes(werksDto);
List<BaseBomInfo> BaeeBomVoList = sapPortService.getSapBaseBomInfo(sapPortDto);
return AjaxResult.success(BaeeBomVoList);
}

@ -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<String, List<HashMap<String, String>>> 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<String, List<HashMap<String, String>>> getO_TAB() {
return O_TAB;
}
public void setO_TAB(HashMap<String, List<HashMap<String, String>>> 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 + '\'' +
'}';
}
}

@ -4,6 +4,7 @@ import com.aucma.api.domain.dto.SAPPortDto;
import com.aucma.base.domain.BaseDeviceLedger; import com.aucma.base.domain.BaseDeviceLedger;
import com.aucma.base.domain.BaseMaterialInfo; import com.aucma.base.domain.BaseMaterialInfo;
import com.aucma.base.domain.BaseOrderInfo; import com.aucma.base.domain.BaseOrderInfo;
import com.aucma.production.domain.BaseBomInfo;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
@ -25,6 +26,7 @@ public interface ISAPPortService {
List<BaseOrderInfo> getSapBaseOrderInfo(SAPPortDto sapPortDto); List<BaseOrderInfo> getSapBaseOrderInfo(SAPPortDto sapPortDto);
List<BaseDeviceLedger> getSapDeviceLedgers(SAPPortDto sapPortDto); List<BaseDeviceLedger> getSapDeviceLedgers(SAPPortDto sapPortDto);
List<BaseBomInfo> getSapBaseBomInfo(SAPPortDto sapPortDto);

@ -1,9 +1,11 @@
package com.aucma.api.service; package com.aucma.api.service;
import com.aucma.api.domain.vo.SAPResultBomVo;
import com.aucma.api.domain.vo.SAPResultVo; import com.aucma.api.domain.vo.SAPResultVo;
import com.aucma.base.domain.BaseDeviceLedger; import com.aucma.base.domain.BaseDeviceLedger;
import com.aucma.base.domain.BaseMaterialInfo; import com.aucma.base.domain.BaseMaterialInfo;
import com.aucma.base.domain.BaseOrderInfo; import com.aucma.base.domain.BaseOrderInfo;
import com.aucma.production.domain.BaseBomInfo;
import java.text.ParseException; import java.text.ParseException;
import java.util.ArrayList; import java.util.ArrayList;
@ -35,5 +37,10 @@ public interface ISAPPutStorageService {
*/ */
public ArrayList<BaseDeviceLedger> insertSAPDeviceLedger(SAPResultVo resultVo) throws ParseException; public ArrayList<BaseDeviceLedger> insertSAPDeviceLedger(SAPResultVo resultVo) throws ParseException;
/**
* bom
*
* */
public ArrayList<BaseBomInfo> insertSAPBaseBomInfo(SAPResultBomVo resultVo) throws ParseException;
} }

@ -3,6 +3,7 @@ package com.aucma.api.service.impl;
import com.aucma.api.domain.dto.SAPPortDto; import com.aucma.api.domain.dto.SAPPortDto;
import com.aucma.api.domain.dto.WERKSDto; 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.domain.vo.SAPResultVo;
import com.aucma.api.service.ISAPPortService; import com.aucma.api.service.ISAPPortService;
import com.aucma.api.service.ISAPPutStorageService; 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.exception.base.BaseException;
import com.aucma.common.utils.StringUtils; import com.aucma.common.utils.StringUtils;
import com.aucma.common.utils.http.HttpUtils; import com.aucma.common.utils.http.HttpUtils;
import com.aucma.production.domain.BaseBomInfo;
import com.aucma.system.utils.PortLogUtils; import com.aucma.system.utils.PortLogUtils;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired; 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 = 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\"}]}}"; // 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(); ObjectMapper resultMapper = new ObjectMapper();
// 将 JSON 字符串转换为 Java 对象 // 将 JSON 字符串转换为 Java 对象
SAPResultVo resultVo = resultMapper.readValue(result, SAPResultVo.class); SAPResultVo resultVo = resultMapper.readValue(result, SAPResultVo.class);
@ -166,5 +171,49 @@ public class SAPPortServiceImpl implements ISAPPortService {
return baseDeviceLedgersVos; return baseDeviceLedgersVos;
} }
@Override
public List<BaseBomInfo> 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<BaseBomInfo> 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;
}
} }

@ -1,5 +1,6 @@
package com.aucma.api.service.impl; package com.aucma.api.service.impl;
import com.aucma.api.domain.vo.SAPResultBomVo;
import com.aucma.api.domain.vo.SAPResultVo; import com.aucma.api.domain.vo.SAPResultVo;
import com.aucma.api.service.ISAPPutStorageService; import com.aucma.api.service.ISAPPutStorageService;
import com.aucma.base.domain.BaseDeviceLedger; 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.IBaseDeviceLedgerService;
import com.aucma.base.service.IBaseMaterialInfoService; import com.aucma.base.service.IBaseMaterialInfoService;
import com.aucma.base.service.IBaseOrderInfoService; 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.beans.factory.annotation.Autowired;
import org.springframework.security.core.parameters.P;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
@ -34,6 +41,8 @@ public class SAPPutStorageServiceImpl implements ISAPPutStorageService {
@Autowired @Autowired
private IBaseOrderInfoService baseOrderInfoService; private IBaseOrderInfoService baseOrderInfoService;
@Autowired
private IBaseBomInfoService baseBomInfoService;
/** /**
* *
@ -66,41 +75,30 @@ public class SAPPutStorageServiceImpl implements ISAPPutStorageService {
List<HashMap<String, String>> itemList = resultVo.getO_TAB().get("item"); List<HashMap<String, String>> itemList = resultVo.getO_TAB().get("item");
for (HashMap<String, String> map : itemList) { for (HashMap<String, String> map : itemList) {
int item = 0; int item = 0;
List<BaseOrderInfo> baseOrderInfos = baseOrderInfoService.selectBaseOrderInfoList(null); String aufnr = map.get("AUFNR");
//查出值进行比对 如果数据库中已有该字段则忽略本次数据 BaseOrderInfo boInfo = new BaseOrderInfo();
//缺少工作中心 boInfo.setOrderCode(aufnr);
for (int i=0;i<baseOrderInfos.size();i++){ List<BaseOrderInfo> baseOrderInfos = baseOrderInfoService.selectBaseOrderInfoList(boInfo);
if (baseOrderInfos.get(i).getFactoryCode()!=null if (baseOrderInfos.isEmpty()){
&& baseOrderInfos.get(i).getFactoryCode().equals(map.get("WERKS")) BaseOrderInfo baseOrderInfo = new BaseOrderInfo();
&&baseOrderInfos.get(i).getOrderCode()!=null baseOrderInfo.setOrderCode(map.get("AUFNR"));
&&baseOrderInfos.get(i).getOrderCode().equals(map.get("AUFNR")) baseOrderInfo.setOrderStatus(map.get("STTXT"));
&&baseOrderInfos.get(i).getMaterialCode()!=null baseOrderInfo.setSaleOrderCode(map.get("KDAUF"));
&&baseOrderInfos.get(i).getMaterialCode().equals(map.get("MATNR")) baseOrderInfo.setMaterialCode(map.get("MATNR"));
){ baseOrderInfo.setMaterialName(map.get("MAKTX"));
//忽略标识 if (!map.get("GAMNG").equals(null)){
item = 1; 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.setDeviceType(map.get("EQTYP"));
deviceLedger.setDeviceCode(map.get("EQUNR"));// deviceLedger.setDeviceCode(map.get("EQUNR"));//
deviceLedger.setUsedDepartment(map.get("NAME1")); deviceLedger.setUsedDepartment(map.get("NAME1"));
deviceLedger.setCreatedTime(DateUtils.getNowDate());
baseDeviceLedgerService.insertBaseDeviceLedger(deviceLedger); baseDeviceLedgerService.insertBaseDeviceLedger(deviceLedger);
baseDeviceLedgerArrayList.add(deviceLedger); baseDeviceLedgerArrayList.add(deviceLedger);
} }
@ -149,5 +149,28 @@ public class SAPPutStorageServiceImpl implements ISAPPutStorageService {
return baseDeviceLedgerArrayList; return baseDeviceLedgerArrayList;
} }
@Override
public ArrayList<BaseBomInfo> insertSAPBaseBomInfo(SAPResultBomVo resultVo) throws ParseException {
ArrayList<BaseBomInfo> baseBomInfoList = new ArrayList<>();
List<HashMap<String, String>> itemList = resultVo.getO_TAB().get("item");
BaseBomInfo bbInfo = new BaseBomInfo();
for (HashMap<String, String> 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;
}
} }

@ -28,11 +28,8 @@ public class PlanCodeUtils {
LocalDate date = LocalDate.now(); LocalDate date = LocalDate.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyMMdd"); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyMMdd");
String format = date.format(formatter); String format = date.format(formatter);
Boolean flag=SpringUtils.getBean(RedisCache.class).hasKey(format);
System.out.println(flag);
//以当日日期作为key //以当日日期作为key
if (!flag) { if (!SpringUtils.getBean(RedisCache.class).hasKey(format)) {
SpringUtils.getBean(RedisCache.class).setCacheObject(format,1); SpringUtils.getBean(RedisCache.class).setCacheObject(format,1);
SpringUtils.getBean(RedisCache.class).expire(format,getSecondsNextEarlyMorning(), TimeUnit.SECONDS); SpringUtils.getBean(RedisCache.class).expire(format,getSecondsNextEarlyMorning(), TimeUnit.SECONDS);
} }

Loading…
Cancel
Save