package com.emato.cus.supervise.biz.acqGoodsSeat; import com.emato.cus.supervise.biz.DataConversion; import com.emato.cus.supervise.constant.Dict; import com.emato.cus.supervise.domain.WmsAcqGoodsOnSeat; import com.emato.cus.supervise.domainCus.CusAcqGoodsSeat06; import com.emato.cus.supervise.domainOms.OmsAcqInventoryInfo; import com.emato.cus.supervise.domainOms.OmsProductInfo; import com.google.common.collect.Lists; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; import java.time.LocalDateTime; import java.util.List; import java.util.Map; import java.util.stream.Collectors; /** * @author zengjunlin * @version 1.0 * 2018-02-03 16:55 */ @Component public class AcqGoodsOnSeatDataConversion implements DataConversion{ private final static Logger logger = LoggerFactory.getLogger(AcqGoodsOnSeatDataConversion.class); /** * 外部数据转换 * * @param params * @return */ @Override public List conversion(Map params) { logger.info("开始转换oms,wms 组装cus数据==========================="); List wmsList = (List) params.get("wmsList"); List omsList = (List) params.get("omsList"); final Map omsAcqInventoryInfoMap = omsList.stream().collect(Collectors.toMap(k->k.getMerchSn(), v->v)); List productInfoList = (List) params.get("productInfoList"); final Map omsProductInfoMap = productInfoList.stream().collect(Collectors.toMap(k->k.getSkuNo(), v->v)); List cusAcqGoodsSeat06List = Lists.newArrayList(); for (int i = 0; i < wmsList.size(); i++) { try{ WmsAcqGoodsOnSeat wmsAcqGoodsOnSeat = wmsList.get(i); OmsAcqInventoryInfo omsAcqInventoryInfo = omsAcqInventoryInfoMap.get(wmsAcqGoodsOnSeat.getMerchSn()); OmsProductInfo omsProductInfo = omsProductInfoMap.get(wmsAcqGoodsOnSeat.getSkuNo()); CusAcqGoodsSeat06 cusAcqGoodsSeat06 = new CusAcqGoodsSeat06(); cusAcqGoodsSeat06.setId(wmsAcqGoodsOnSeat.getId()); cusAcqGoodsSeat06.setSeatNo(wmsAcqGoodsOnSeat.getSeatNo()); cusAcqGoodsSeat06.setGoodsName(wmsAcqGoodsOnSeat.getGoodsName()); // cusAcqGoodsSeat06.setCodeTs(wmsAcqGoodsOnSeat.getCodeTs()); cusAcqGoodsSeat06.setFormNoDec(wmsAcqGoodsOnSeat.getFormNoDec()); cusAcqGoodsSeat06.setFormNo(wmsAcqGoodsOnSeat.getFormNo()); cusAcqGoodsSeat06.setSkuNo(wmsAcqGoodsOnSeat.getSkuNo()); cusAcqGoodsSeat06.setGoodsId(wmsAcqGoodsOnSeat.getGoodsId()); cusAcqGoodsSeat06.setgUnit(wmsAcqGoodsOnSeat.getgUnit()); cusAcqGoodsSeat06.setgQty(wmsAcqGoodsOnSeat.getgQty()); cusAcqGoodsSeat06.setLegalUnit(wmsAcqGoodsOnSeat.getLegalUnit()); cusAcqGoodsSeat06.setLegalQty(wmsAcqGoodsOnSeat.getLegalQty()); cusAcqGoodsSeat06.setGoodsModel(wmsAcqGoodsOnSeat.getGoodsModel()); cusAcqGoodsSeat06.setLocalEmsNo(Dict.localEmsNo); // TODO: 2018/5/8 此处存在问题:如wms的商户编号数据与oms的商户编号数据不统一,则会报空指针异常 cusAcqGoodsSeat06.setOwnerCode(omsAcqInventoryInfo.getOwnerCode()); cusAcqGoodsSeat06.setOwnerName(omsAcqInventoryInfo.getOwnerName()); cusAcqGoodsSeat06.setStoreCompanyName(Dict.storeCompanyName); cusAcqGoodsSeat06.setStoreUscCode(Dict.storeUscCode); cusAcqGoodsSeat06.setStoreCustomsCode(Dict.storeCustomsCode); cusAcqGoodsSeat06.setStoreCode(Dict.storeCode); cusAcqGoodsSeat06.setCreateTime(LocalDateTime.now()); cusAcqGoodsSeat06.setCreaterSn("1"); cusAcqGoodsSeat06.setModerSn("1"); cusAcqGoodsSeat06.setModTime(LocalDateTime.now()); cusAcqGoodsSeat06.setLegalQty(omsProductInfo.getLegalQyt()); cusAcqGoodsSeat06.setLegalUnit(omsProductInfo.getLegalUnit()); cusAcqGoodsSeat06.setGoodsModel(omsProductInfo.getGoodsModel()); cusAcqGoodsSeat06.setCodeTs(omsProductInfo.getCodeTs()); cusAcqGoodsSeat06List.add(cusAcqGoodsSeat06); }catch (Exception e){ logger.error("库位货物组装cus数据系统异常", e); }finally { continue; } } logger.info("转换oms,wms 组装cus数据结束==========================="); return cusAcqGoodsSeat06List; } }