123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- 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.apache.commons.lang3.StringUtils;
- 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<WmsAcqGoodsOnSeat> wmsList = (List<WmsAcqGoodsOnSeat>) params.get("wmsList");
- List<OmsAcqInventoryInfo> omsList = (List<OmsAcqInventoryInfo>) params.get("omsList");
- final Map<String,OmsAcqInventoryInfo> omsAcqInventoryInfoMap = omsList.stream().collect(Collectors.toMap(k->k.getMerchSn(), v->v));
- List<OmsProductInfo> productInfoList = (List<OmsProductInfo>) params.get("productInfoList");
- final Map<String,OmsProductInfo> omsProductInfoMap = productInfoList.stream().collect(Collectors.toMap(k->k.getSkuNo(), v->v));
- List<CusAcqGoodsSeat06> 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());
- String osku = omsProductInfo.getSkuNo();
- if (StringUtils.isBlank(osku)) {
- logger.error("当前转换的sku为: {}, 对应的产品备案数据异常", osku);
- continue;
- }
- logger.debug("当前转换的sku为: {}", omsProductInfo.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(omsAcqInventoryInfo.getLocalEmsNo());
- // 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;
- }
- }
|