AcqGoodsOnSeatDataConversion.java 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. package com.emato.cus.supervise.biz.acqGoodsSeat;
  2. import com.emato.cus.supervise.biz.DataConversion;
  3. import com.emato.cus.supervise.constant.Dict;
  4. import com.emato.cus.supervise.domain.WmsAcqGoodsOnSeat;
  5. import com.emato.cus.supervise.domainCus.CusAcqGoodsSeat06;
  6. import com.emato.cus.supervise.domainOms.OmsAcqInventoryInfo;
  7. import com.emato.cus.supervise.domainOms.OmsProductInfo;
  8. import com.google.common.collect.Lists;
  9. import org.apache.commons.lang3.StringUtils;
  10. import org.slf4j.Logger;
  11. import org.slf4j.LoggerFactory;
  12. import org.springframework.stereotype.Component;
  13. import java.time.LocalDateTime;
  14. import java.util.List;
  15. import java.util.Map;
  16. import java.util.stream.Collectors;
  17. /**
  18. * @author zengjunlin
  19. * @version 1.0
  20. * 2018-02-03 16:55
  21. */
  22. @Component
  23. public class AcqGoodsOnSeatDataConversion implements DataConversion{
  24. private final static Logger logger = LoggerFactory.getLogger(AcqGoodsOnSeatDataConversion.class);
  25. /**
  26. * 库位货物
  27. *
  28. * @param params
  29. * @return
  30. */
  31. @Override
  32. public List conversion(Map params) {
  33. logger.info("库位货物开始转换oms,wms 组装cus数据===========================");
  34. List<WmsAcqGoodsOnSeat> wmsList = (List<WmsAcqGoodsOnSeat>) params.get("wmsList");
  35. List<OmsAcqInventoryInfo> omsList = (List<OmsAcqInventoryInfo>) params.get("omsList");
  36. final Map<String,OmsAcqInventoryInfo> omsAcqInventoryInfoMap = omsList.stream().collect(Collectors.toMap(k->k.getMerchSn(), v->v));
  37. List<OmsProductInfo> productInfoList = (List<OmsProductInfo>) params.get("productInfoList");
  38. final Map<String,OmsProductInfo> omsProductInfoMap = productInfoList.stream().collect(Collectors.toMap(k->k.getSkuNo(), v->v));
  39. List<CusAcqGoodsSeat06> cusAcqGoodsSeat06List = Lists.newArrayList();
  40. for (int i = 0; i < wmsList.size(); i++) {
  41. try{
  42. WmsAcqGoodsOnSeat wmsAcqGoodsOnSeat = wmsList.get(i);
  43. OmsAcqInventoryInfo omsAcqInventoryInfo = omsAcqInventoryInfoMap.get(wmsAcqGoodsOnSeat.getMerchSn());
  44. OmsProductInfo omsProductInfo = omsProductInfoMap.get(wmsAcqGoodsOnSeat.getSkuNo());
  45. String osku = omsProductInfo.getSkuNo();
  46. if (StringUtils.isBlank(osku)) {
  47. logger.error("当前转换的sku为: {}, 对应的产品备案数据异常", osku);
  48. continue;
  49. }
  50. logger.debug("当前转换的sku为: {}", omsProductInfo.getSkuNo());
  51. CusAcqGoodsSeat06 cusAcqGoodsSeat06 = new CusAcqGoodsSeat06();
  52. cusAcqGoodsSeat06.setId(wmsAcqGoodsOnSeat.getId());
  53. cusAcqGoodsSeat06.setSeatNo(wmsAcqGoodsOnSeat.getSeatNo());
  54. cusAcqGoodsSeat06.setGoodsName(wmsAcqGoodsOnSeat.getGoodsName());
  55. // cusAcqGoodsSeat06.setCodeTs(wmsAcqGoodsOnSeat.getCodeTs());
  56. cusAcqGoodsSeat06.setFormNoDec(wmsAcqGoodsOnSeat.getFormNoDec());
  57. cusAcqGoodsSeat06.setFormNo(wmsAcqGoodsOnSeat.getFormNo());
  58. cusAcqGoodsSeat06.setSkuNo(wmsAcqGoodsOnSeat.getSkuNo());
  59. cusAcqGoodsSeat06.setGoodsId(wmsAcqGoodsOnSeat.getGoodsId());
  60. cusAcqGoodsSeat06.setgUnit(wmsAcqGoodsOnSeat.getgUnit());
  61. cusAcqGoodsSeat06.setgQty(wmsAcqGoodsOnSeat.getgQty());
  62. cusAcqGoodsSeat06.setLegalUnit(wmsAcqGoodsOnSeat.getLegalUnit());
  63. cusAcqGoodsSeat06.setLegalQty(wmsAcqGoodsOnSeat.getLegalQty());
  64. cusAcqGoodsSeat06.setGoodsModel(wmsAcqGoodsOnSeat.getGoodsModel());
  65. cusAcqGoodsSeat06.setLocalEmsNo(omsAcqInventoryInfo.getLocalEmsNo());
  66. // TODO: 2018/5/8 此处存在问题:如wms的商户编号数据与oms的商户编号数据不统一,则会报空指针异常
  67. cusAcqGoodsSeat06.setOwnerCode(omsAcqInventoryInfo.getOwnerCode());
  68. cusAcqGoodsSeat06.setOwnerName(omsAcqInventoryInfo.getOwnerName());
  69. cusAcqGoodsSeat06.setStoreCompanyName(Dict.storeCompanyName);
  70. cusAcqGoodsSeat06.setStoreUscCode(Dict.storeUscCode);
  71. cusAcqGoodsSeat06.setStoreCustomsCode(Dict.storeCustomsCode);
  72. cusAcqGoodsSeat06.setStoreCode(Dict.storeCode);
  73. cusAcqGoodsSeat06.setCreateTime(LocalDateTime.now());
  74. cusAcqGoodsSeat06.setCreaterSn("1");
  75. cusAcqGoodsSeat06.setModerSn("1");
  76. cusAcqGoodsSeat06.setModTime(LocalDateTime.now());
  77. cusAcqGoodsSeat06.setLegalQty(omsProductInfo.getLegalQyt());
  78. cusAcqGoodsSeat06.setLegalUnit(omsProductInfo.getLegalUnit());
  79. cusAcqGoodsSeat06.setGoodsModel(omsProductInfo.getGoodsModel());
  80. cusAcqGoodsSeat06.setCodeTs(omsProductInfo.getCodeTs());
  81. cusAcqGoodsSeat06List.add(cusAcqGoodsSeat06);
  82. }catch (Exception e){
  83. logger.error("库位货物组装cus数据系统异常", e);
  84. }finally {
  85. continue;
  86. }
  87. }
  88. logger.info("库位货物组装转换oms,wms 组装cus数据结束===========================");
  89. return cusAcqGoodsSeat06List;
  90. }
  91. }