AcqGoodsOnSeatDataConversion.java 4.7 KB

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