diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToC.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToC.java index 8186d457..66d207f7 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToC.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToC.java @@ -493,10 +493,9 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { //进一步优化性能,使用Map newstate = no2NameMap.get(detailsDto.getId()); - if (newstate != null && (succeseeY.equals(newstate) || succeseeH.equals(newstate))) { + if (newstate != null && !"".equals(newstate) && (succeseeY.equals(newstate) || succeseeH.equals(newstate))) { isSuccess = true; } - if (!isSuccess) { detailsDto.setNewState(newstate); targetDetails.add(detailsDto); @@ -751,7 +750,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { // BdRdclEntity bdRdclEntity = rdclUtil.queryRdClObject("202"); //初始化所有存货管理档案对应的结存价+采购价 List mapList = initAllBalancePricePurchasePrice(); - + if (bdBusitypeEntity != null && summaryDimensionMap != null) { Iterator>> iterator = summaryDimensionMap.entrySet().iterator(); while (iterator.hasNext()) { diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToC.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToC.java index cc079086..aa9edd66 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToC.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToC.java @@ -65,6 +65,9 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { private static final String PROD_FILED = "prod"; + @Autowired + private BalanceUnitPriceUtil balanceUnitPriceUtil; + @Autowired private QueryU8CEntityUtil queryU8CEntityUtil; @@ -360,7 +363,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { // List headerDetailsDtoList1 = new ArrayList<>(); List tocofsReturngoodsDetailedEntityList = new ArrayList<>(); if (returnGoodHeaderDetailsDataDtoArrayList != null && returnGoodHeaderDetailsDataDtoArrayList.size() > 0) { - List> splitListByCount = SplitListByCountUtil.splitListByCount(returnGoodHeaderDetailsDataDtoArrayList, 100); + List> splitListByCount = SplitListByCountUtil.splitListByCount(returnGoodHeaderDetailsDataDtoArrayList, 800); for (int i = 0; i < splitListByCount.size(); i++) { List stockinOrderList = splitListByCount.get(i); String idStr = commaConcatenatedPrimaryKeyStock(stockinOrderList); @@ -447,39 +450,67 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { for (StockinOrderSearchResponse.StockinOrder index : returnGoodHeaderDetailsDataDtoArrayList) { StockinOrderSearchResponse.StockinOrder.StockinH header = index.getHeader();// 主表 List details = index.getDetails();//明细表 - for (int i = 0; i < details.size(); i++) { StockinOrderSearchResponse.StockinOrder.StockinB stockinB = details.get(i); stockinB.setReturnGoodSearchHeaderDto(header); } - headerDetailsDtoList1.add(header); headerDetailsDtoList2.addAll(details); } //每250作为一个批次插入主表,根据主键(id)判断是否重复,如果重复的,则不进行插入 - List> lists = SplitListByCountUtil.splitListByCount(headerDetailsDtoList1, 100); + List> lists = SplitListByCountUtil.splitListByCount(headerDetailsDtoList1, 800); for (int i = 0; i < lists.size(); i++) { List stockinHS = lists.get(i); - List tocofsReturngoodsEntities = copyHeaderDto(stockinHS); - if (tocofsReturngoodsEntities.size() > 0) { - logger.info("插入底表{}个对象(表头)", tocofsReturngoodsEntities.size()); - iTocofsReturngoodsDao.entityInsertOrUpdateBatch(tocofsReturngoodsEntities); - } else { - logger.info("tocofsReturngoodsEntities:没有对象被插入表头底表"); + Thread thread = new Thread(new Runnable() { + @Override + public void run() { + try { + List tocofsReturngoodsEntities = copyHeaderDto(stockinHS); + if (tocofsReturngoodsEntities.size() > 0) { + logger.info("插入底表{}个对象(表头)", tocofsReturngoodsEntities.size()); + iTocofsReturngoodsDao.entityInsertOrUpdateBatch(tocofsReturngoodsEntities); + } else { + logger.info("tocofsReturngoodsEntities:没有对象被插入表头底表"); + } + } catch (Exception e) { + logger.error("线程保存TOC退货主表抛出异常", e); + } + } + }); + thread.start(); + try { + thread.join(); + } catch (Exception e) { + logger.error("线程保存TOC退货主表抛出异常", e); } } //插入明细表 - List> lists1 = SplitListByCountUtil.splitListByCount(headerDetailsDtoList2, 100); + List> lists1 = SplitListByCountUtil.splitListByCount(headerDetailsDtoList2, 800); for (int i = 0; i < lists1.size(); i++) { List stockinBS = lists1.get(i); List tocofsReturngoodsDetailedEntities = copyDetailsDto(stockinBS); - if (tocofsReturngoodsDetailedEntities.size() > 0) { - logger.info("插入底表{}个对象(表体)", tocofsReturngoodsDetailedEntities.size()); - iTocofsReturngoodsDetailedDao.entityInsertOrUpdateBatch(tocofsReturngoodsDetailedEntities); - } else { - logger.info("tocofsReturngoodsDetailedEntities:没有对象被插入表头底表"); + Thread thread = new Thread(new Runnable() { + @Override + public void run() { + try { + if (tocofsReturngoodsDetailedEntities.size() > 0) { + logger.info("插入底表{}个对象(表体)", tocofsReturngoodsDetailedEntities.size()); + iTocofsReturngoodsDetailedDao.entityInsertOrUpdateBatch(tocofsReturngoodsDetailedEntities); + } else { + logger.info("tocofsReturngoodsDetailedEntities:没有对象被插入表头底表"); + } + } catch (Exception e) { + logger.error("线程保存TOC退货明细抛出异常", e); + } + } + }); + thread.start(); + try { + thread.join(); + } catch (Exception e) { + logger.error("线程保存TOC退货明细抛出异常", e); } } } @@ -558,6 +589,8 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { BdBusitypeEntity bdBusitypeEntity = u8cOperationFlow(); // 查询销售收发类别 // BdRdclEntity bdRdclEntity = rdclUtil.queryRdClObject("202"); + //初始化所有存货管理档案对应的结存价+采购价 + List mapList = initAllBalancePricePurchasePrice(); if (bdBusitypeEntity != null && summaryDimensionMap != null) { Iterator>> iterator = summaryDimensionMap.entrySet().iterator(); @@ -628,8 +661,11 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { List saleorderRequestChildrenDtoList = new ArrayList<>(); saleorderRequestDto.setChildrenvo(saleorderRequestChildrenDtoList); + //验证是否为指定的店铺,如果为true,则取结存价 + Boolean isCheckShopChoose = balanceUnitPriceUtil.checkOfsShop(header.getStoreCode()); + //把汇总好的出库单明细行合并成一行 - GoodsRertunSonDetailsDto goodsRertunSonDetailsDto = groupMergeDetailedRows(oldValue); + GoodsRertunSonDetailsDto goodsRertunSonDetailsDto = groupMergeDetailedRows(oldValue, isCheckShopChoose, mapList); //存货管理档案:取发货公司的存货管理档案 BdInvmandocEntity bdInvmandocEntity = oldValue.get(0).getBdInvmandocEntity(); //存货基础档案 @@ -765,7 +801,9 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { Map> summaryDimensionMap = groupSummary(goodsRertunSonDetailsDtos); // 查询U8C业务流程 BdBusitypeEntity bdBusitypeEntity = u8cOperationFlowV2(); - + //初始化所有存货管理档案对应的结存价+采购价 + List mapList = initAllBalancePricePurchasePrice(); + if (bdBusitypeEntity != null && summaryDimensionMap != null) { Iterator>> iterator = summaryDimensionMap.entrySet().iterator(); while (iterator.hasNext()) { @@ -835,8 +873,11 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { List saleorderRequestChildrenDtoList = new ArrayList<>(); saleorderRequestDto.setChildrenvo(saleorderRequestChildrenDtoList); + //验证是否为指定的店铺,如果为true,则取结存价 + Boolean isCheckShopChoose = balanceUnitPriceUtil.checkOfsShop(header.getStoreCode()); //把汇总好的出库单明细行合并成一行 - GoodsRertunSonDetailsDto goodsRertunSonDetailsDto = groupMergeDetailedRows(oldValue); + GoodsRertunSonDetailsDto goodsRertunSonDetailsDto = groupMergeDetailedRows(oldValue, isCheckShopChoose, mapList); + //存货管理档案:取发货公司的存货管理档案 BdInvmandocEntity bdInvmandocEntity = oldValue.get(0).getBdInvmandocEntity(); //存货基础档案 @@ -1404,23 +1445,35 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { * @param sonDetailsDtoList 汇总过后的售后入库单明细 * @author liuyang */ - private GoodsRertunSonDetailsDto groupMergeDetailedRows(List sonDetailsDtoList) throws Exception { + private GoodsRertunSonDetailsDto groupMergeDetailedRows(List sonDetailsDtoList, Boolean isCheckShopChoose, List mapList) throws Exception { + Assert.notNull(sonDetailsDtoList, "sonDetailsDtoList不能为空"); + Assert.notNull(isCheckShopChoose, "isCheckShopChoose不能为空"); + Assert.notNull(mapList, "mapLists不能为空"); + if (sonDetailsDtoList != null && sonDetailsDtoList.size() > 0) { BigDecimal groupTotalPayAmount = new BigDecimal("0"); BigDecimal groupShipQty = new BigDecimal("0"); for (int i = 0; i < sonDetailsDtoList.size(); i++) { GoodsRertunSonDetailsDto goodsRertunSonDetailsDto = sonDetailsDtoList.get(i); - StockinOrderSearchResponse.StockinOrder.StockinH header = goodsRertunSonDetailsDto.getHeader(); - RerturnGoodsOrderSearchData rerturnGoodsOrderSearchData = header.getRerturnGoodsOrderSearchData(); + StockinOrderSearchResponse.StockinOrder.StockinH header = goodsRertunSonDetailsDto.getHeader();//O售后入库单表头 + RerturnGoodsOrderSearchData rerturnGoodsOrderSearchData = header.getRerturnGoodsOrderSearchData();//OFS售后订单 + + //存货管理档案 + BdInvmandocEntity bdInvmandocEntity = goodsRertunSonDetailsDto.getBdInvmandocEntity(); //取对应的售后订单明细,主要是取这个价格 - RerturnGoodsOrderSearchDetails afterSalesOrder = findAfterSalesOrderV2(goodsRertunSonDetailsDto, rerturnGoodsOrderSearchData); + String totalAmount = getFloorPrice(isCheckShopChoose, bdInvmandocEntity, header, goodsRertunSonDetailsDto, mapList); + if (totalAmount == null) { + //取O实退金额 + RerturnGoodsOrderSearchDetails afterSalesOrder = findAfterSalesOrderV2(goodsRertunSonDetailsDto, rerturnGoodsOrderSearchData); + totalAmount = afterSalesOrder.getTotalAmount(); + } //实付金额/实发数量 - Assert.notNull(afterSalesOrder.getTotalAmount(), "退货入库单总金额不能为空 明细行对象:{}", JSON.toJSONString(goodsRertunSonDetailsDto)); + Assert.notNull(totalAmount, "退货入库单总金额不能为空 明细行对象:{}", JSON.toJSONString(goodsRertunSonDetailsDto)); Assert.notNull(goodsRertunSonDetailsDto.getReceivedQty(), "实收数量不能为空 明细行对象:{}", JSON.toJSONString(goodsRertunSonDetailsDto)); - BigDecimal totalPayAmountBigDecimal = new BigDecimal(afterSalesOrder.getTotalAmount()); + BigDecimal totalPayAmountBigDecimal = new BigDecimal(totalAmount); BigDecimal shipQtyBigDecimal = new BigDecimal(goodsRertunSonDetailsDto.getReceivedQty()); groupTotalPayAmount = groupTotalPayAmount.add(totalPayAmountBigDecimal); @@ -1976,6 +2029,14 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { List targetHeaderDetailsDtoList = new ArrayList<>(); if (returnGoodHeaderDetailsDataDtoArrayList != null && returnGoodHeaderDetailsDataDtoArrayList.size() > 0) { + List resultList = tocofsReturngoodsDetailedEntityList.stream().map(obj -> { + if (obj.getNewstate3() == null) { + obj.setNewstate3(""); + } + return obj; + }).collect(Collectors.toList()); + Map no2NameMap = resultList.stream().collect(Collectors.toMap(TocofsReturngoodsDetailedEntity::getId, TocofsReturngoodsDetailedEntity::getNewstate3)); + //字段Y(成功)或者为H(待处理)可以视为成功,完成了小段业务闭环的数据行 String succeseeY = "Y"; String succeseeH = "H"; @@ -1989,16 +2050,20 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { StockinOrderSearchResponse.StockinOrder.StockinB stockinB = details.get(j); Boolean isSuccess = false; String newstate = null; - if (tocofsReturngoodsDetailedEntityList != null && tocofsReturngoodsDetailedEntityList.size() > 0) { - for (int k = 0; k < tocofsReturngoodsDetailedEntityList.size(); k++) { - TocofsReturngoodsDetailedEntity tocofsReturngoodsDetailedEntity = tocofsReturngoodsDetailedEntityList.get(k); - if (tocofsReturngoodsDetailedEntity.getId().equals(stockinB.getId())) { - newstate = tocofsReturngoodsDetailedEntity.getNewstate3(); - if (succeseeY.equals(newstate) || succeseeH.equals(newstate)) { - isSuccess = true; - } - } - } +// if (tocofsReturngoodsDetailedEntityList != null && tocofsReturngoodsDetailedEntityList.size() > 0) { +// for (int k = 0; k < tocofsReturngoodsDetailedEntityList.size(); k++) { +// TocofsReturngoodsDetailedEntity tocofsReturngoodsDetailedEntity = tocofsReturngoodsDetailedEntityList.get(k); +// if (tocofsReturngoodsDetailedEntity.getId().equals(stockinB.getId())) { +// newstate = tocofsReturngoodsDetailedEntity.getNewstate3(); +// if (succeseeY.equals(newstate) || succeseeH.equals(newstate)) { +// isSuccess = true; +// } +// } +// } +// } + newstate = no2NameMap.get(stockinB.getId()); + if (newstate != null && !"".equals(newstate) && (succeseeY.equals(newstate) || succeseeH.equals(newstate))) { + isSuccess = true; } if (!isSuccess) { stockinB.setNewstate3(newstate); @@ -2282,4 +2347,94 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { Assert.state(false, "根据OFS售后入库单明细行,无法查找OFS售后订单明细行 来源明细行主键:{} 来源单据主键:{}", goodsRertunSonDetailsDto.getRefOrderDetailId(), goodsRertunSonDetailsDto.getRefOrderId()); return null; } + + /** + * 初始化所有存货管理档案对应的结存价、采购价 + * + * @author liuyang + */ + private List initAllBalancePricePurchasePrice() throws Exception { + List mapList = new ArrayList<>(); + Map stringIaPeriodaccountEntityMap = balanceUnitPriceUtil.initBalancePrice(); + Map stringPoOrderBEntityMap = balanceUnitPriceUtil.initPurchasePrice(); + mapList.add(stringIaPeriodaccountEntityMap); + mapList.add(stringPoOrderBEntityMap); + return mapList; + } + + /** + * 获取结存金额或者采购金额 + * + * @param isCheckShopChoose true取OFS实付金额、false取结存金额或者采购价 + * @param bdInvmandocEntity 存货基本档案 + * @param header 对应的销售入库单表头 + * @param sonDetailsDto 对应的销售入库单明细行对象 + * @param mapList 索引为0结存价为1采购价 + * @author liuyang + */ + private String getFloorPrice(Boolean isCheckShopChoose, BdInvmandocEntity bdInvmandocEntity, StockinOrderSearchResponse.StockinOrder.StockinH header, GoodsRertunSonDetailsDto sonDetailsDto, List mapList) throws Exception { + Assert.notNull(isCheckShopChoose, "isCheckShopChoose不能为空"); + Assert.notNull(bdInvmandocEntity, "bdInvmandocEntity不能为空"); + Assert.notNull(header, "header不能为空"); + Assert.notNull(sonDetailsDto, "detailsDto不能为空"); + Assert.notNull(mapList, "mapList不能为空"); + + String totalPayAmount = null; + if (isCheckShopChoose) { + IaPeriodaccountEntity iaPeriodaccountEntity1 = null; + if (mapList != null && mapList.size() > 0) { + Map stringIaPeriodaccountEntityMap = (Map) mapList.get(0); + iaPeriodaccountEntity1 = stringIaPeriodaccountEntityMap.get(bdInvmandocEntity.getPkInvmandoc()); + } + if (iaPeriodaccountEntity1 != null) { + //取结存价 + logger.info("店铺:{} 取O结存价", header.getStoreCode()); + + //结存金额 + String nabmny = iaPeriodaccountEntity1.getNabmny(); + if (nabmny == null || "".equals(nabmny)) { + nabmny = "0"; + } + BigDecimal nabmnyBigDecimal = new BigDecimal(nabmny); + + //结存数量 + String nabnum = iaPeriodaccountEntity1.getNabnum(); + if (nabnum == null || "".equals(nabnum)) { + nabnum = "0"; + } + BigDecimal nabnumBigDecimal = new BigDecimal(nabnum); + + if (!"0".equals(nabmnyBigDecimal.stripTrailingZeros().toPlainString()) && !"0".equals(nabnumBigDecimal.stripTrailingZeros().toPlainString())) { + //得到结存单价 + BigDecimal bigDecimal = nabmnyBigDecimal.divide(nabnumBigDecimal, 20, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP); + totalPayAmount = bigDecimal.stripTrailingZeros().toPlainString(); + } else { + //如果结存金额为或者数量为0,则设置为0 + totalPayAmount = "0"; + } + } else { + //取采购价 + logger.info("店铺:{} 取O采购价", header.getStoreCode()); + PoOrderBEntity poOrderBEntity = null; + if (mapList != null && mapList.size() > 0) { + Map poOrderBEntityList = (Map) mapList.get(1); + if (poOrderBEntityList != null && poOrderBEntityList.size() > 0) { + poOrderBEntity = poOrderBEntityList.get(bdInvmandocEntity.getPkInvmandoc()); + } + } + if (poOrderBEntity != null) { + String norgtaxprice = poOrderBEntity.getNorgtaxprice(); + if ("0".equals(new BigDecimal(norgtaxprice).stripTrailingZeros().toPlainString())) { + //如果采购单价都为0,那么金额也为0 + totalPayAmount = "0"; + } else { + totalPayAmount = norgtaxprice; + } + } else { + Assert.state(false, "店铺:{} 存货管理档案主键:{} 既没有结存价、也没有采购价!", header.getStoreCode(), bdInvmandocEntity.getPkInvmandoc()); + } + } + } + return totalPayAmount; + } } \ No newline at end of file diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/TocReturnBasicArchivesCacheUtil.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/TocReturnBasicArchivesCacheUtil.java index 7eb733bb..ebc0f4af 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/TocReturnBasicArchivesCacheUtil.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/TocReturnBasicArchivesCacheUtil.java @@ -12,10 +12,7 @@ import com.hzya.frame.ttxofs.dto.stock.StockinOrderSearchResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; /** @@ -213,18 +210,33 @@ public class TocReturnBasicArchivesCacheUtil { Map stringBdCubasdocEntityMap = new HashMap<>(); List allBdCumandocEntityList = new ArrayList<>(); if (headerDtoList != null && headerDtoList.size() > 0) { - List> lists = SplitListByCountUtil.splitListByCount(headerDtoList, 900); + Set stringSet = headerDtoList.stream().map(StockinOrderSearchResponse.StockinOrder.StockinH::getStoreCode).collect(Collectors.toSet()); + List stringList = stringSet.stream().collect(Collectors.toList()); + List> lists = SplitListByCountUtil.splitListByCount(stringList, 900); for (int i = 0; i < lists.size(); i++) { - List stockinHList = lists.get(i); - String codesStr = stockinHList.stream().map(StockinOrderSearchResponse.StockinOrder.StockinH::getStoreCode).map(id -> "'" + id + "'").collect(Collectors.joining(",")); - - BdCubasdocEntity bdCubasdocEntity = new BdCubasdocEntity(); - bdCubasdocEntity.setDataSourceCode("lets_u8c"); - bdCubasdocEntity.setDr(0L); - bdCubasdocEntity.setDef1s(codesStr); - List bdCumandocEntityList = iBdCubasdocDao.query(bdCubasdocEntity); - allBdCumandocEntityList.addAll(bdCumandocEntityList); + List strings = lists.get(i); + String codesStr = strings.stream().map(s -> "'" + s.trim() + "'").collect(Collectors.joining(",")); + if (codesStr != null && codesStr.length() > 0) { + BdCubasdocEntity bdCubasdocEntity = new BdCubasdocEntity(); + bdCubasdocEntity.setDataSourceCode("lets_u8c"); + bdCubasdocEntity.setDr(0L); + bdCubasdocEntity.setDef1s(codesStr); + List bdCumandocEntityList = iBdCubasdocDao.query(bdCubasdocEntity); + allBdCumandocEntityList.addAll(bdCumandocEntityList); + } } +// List> lists = SplitListByCountUtil.splitListByCount(headerDtoList, 900); +// for (int i = 0; i < lists.size(); i++) { +// List stockinHList = lists.get(i); +// String codesStr = stockinHList.stream().map(StockinOrderSearchResponse.StockinOrder.StockinH::getStoreCode).map(id -> "'" + id + "'").collect(Collectors.joining(",")); +// +// BdCubasdocEntity bdCubasdocEntity = new BdCubasdocEntity(); +// bdCubasdocEntity.setDataSourceCode("lets_u8c"); +// bdCubasdocEntity.setDr(0L); +// bdCubasdocEntity.setDef1s(codesStr); +// List bdCumandocEntityList = iBdCubasdocDao.query(bdCubasdocEntity); +// allBdCumandocEntityList.addAll(bdCumandocEntityList); +// } } if (allBdCumandocEntityList.size() > 0) { for (int i = 0; i < allBdCumandocEntityList.size(); i++) { @@ -270,11 +282,14 @@ public class TocReturnBasicArchivesCacheUtil { List allBdCumandocEntityList = new ArrayList<>(); if (headerDtoList != null && headerDtoList.size() > 0) { - List> lists = SplitListByCountUtil.splitListByCount(headerDtoList, 500); - for (int i = 0; i < lists.size(); i++) { - List stockinHList = lists.get(i); - String codesStr = stockinHList.stream().map(StockinOrderSearchResponse.StockinOrder.StockinH::getStoreCode).map(id -> "'" + id + "'").collect(Collectors.joining(",")); + Set stringSet = headerDtoList.stream().map(StockinOrderSearchResponse.StockinOrder.StockinH::getStoreCode).collect(Collectors.toSet()); + List stringList = stringSet.stream().collect(Collectors.toList()); + List> lists = SplitListByCountUtil.splitListByCount(stringList, 900); + for (int i = 0; i < lists.size(); i++) { + List strings = lists.get(i); + + String codesStr = strings.stream().map(s -> "'" + s.trim() + "'").collect(Collectors.joining(",")); BdCumandocEntity bdCumandocEntity = new BdCumandocEntity(); bdCumandocEntity.setDataSourceCode("lets_u8c"); bdCumandocEntity.setDr(0L); @@ -282,6 +297,19 @@ public class TocReturnBasicArchivesCacheUtil { List bdCumandocEntityList = iBdCumandocDao.query(bdCumandocEntity); allBdCumandocEntityList.addAll(bdCumandocEntityList); } + +// List> lists = SplitListByCountUtil.splitListByCount(headerDtoList, 500); +// for (int i = 0; i < lists.size(); i++) { +// List stockinHList = lists.get(i); +// String codesStr = stockinHList.stream().map(StockinOrderSearchResponse.StockinOrder.StockinH::getStoreCode).map(id -> "'" + id + "'").collect(Collectors.joining(",")); +// +// BdCumandocEntity bdCumandocEntity = new BdCumandocEntity(); +// bdCumandocEntity.setDataSourceCode("lets_u8c"); +// bdCumandocEntity.setDr(0L); +// bdCumandocEntity.setDef1s(codesStr); +// List bdCumandocEntityList = iBdCumandocDao.query(bdCumandocEntity); +// allBdCumandocEntityList.addAll(bdCumandocEntityList); +// } } if (allBdCumandocEntityList.size() > 0) { for (int i = 0; i < allBdCumandocEntityList.size(); i++) { @@ -317,16 +345,30 @@ public class TocReturnBasicArchivesCacheUtil { Map stringBdInvmandocEntityMap = new HashMap<>(); if (detailsDtos != null && detailsDtos.size() > 0) { - List> lists = SplitListByCountUtil.splitListByCount(detailsDtos, 500); + Set stringSet = detailsDtos.stream().map(StockinOrderSearchResponse.StockinOrder.StockinB::getSkuCode).collect(Collectors.toSet()); + List stringList = stringSet.stream().collect(Collectors.toList()); + List> lists = SplitListByCountUtil.splitListByCount(stringList, 900); for (int i = 0; i < lists.size(); i++) { - List stockinBList = lists.get(i); - String idsStr = stockinBList.stream().map(StockinOrderSearchResponse.StockinOrder.StockinB::getSkuCode).map(id -> "'" + id + "'").collect(Collectors.joining(",")); - - BdInvmandocEntity bdInvmandocEntity = new BdInvmandocEntity(); - bdInvmandocEntity.setInvcodes(idsStr); - List bdInvmandocEntity2 = iBdInvmandocDao.queryBdInvmandocByInvcodeList(bdInvmandocEntity); - allBdInvmandocEntity.addAll(bdInvmandocEntity2); + List strings = lists.get(i); + String codesStr = strings.stream().map(s -> "'" + s.trim() + "'").collect(Collectors.joining(",")); + if (codesStr != null && codesStr.length() > 0) { + BdInvmandocEntity bdInvmandocEntity = new BdInvmandocEntity(); + bdInvmandocEntity.setInvcodes(codesStr); + List bdInvmandocEntity2 = iBdInvmandocDao.queryBdInvmandocByInvcodeList(bdInvmandocEntity); + allBdInvmandocEntity.addAll(bdInvmandocEntity2); + } } + +// List> lists = SplitListByCountUtil.splitListByCount(detailsDtos, 500); +// for (int i = 0; i < lists.size(); i++) { +// List stockinBList = lists.get(i); +// String idsStr = stockinBList.stream().map(StockinOrderSearchResponse.StockinOrder.StockinB::getSkuCode).map(id -> "'" + id + "'").collect(Collectors.joining(",")); +// +// BdInvmandocEntity bdInvmandocEntity = new BdInvmandocEntity(); +// bdInvmandocEntity.setInvcodes(idsStr); +// List bdInvmandocEntity2 = iBdInvmandocDao.queryBdInvmandocByInvcodeList(bdInvmandocEntity); +// allBdInvmandocEntity.addAll(bdInvmandocEntity2); +// } } if (allBdInvmandocEntity.size() > 0) { for (int i = 0; i < allBdInvmandocEntity.size(); i++) { @@ -366,16 +408,29 @@ public class TocReturnBasicArchivesCacheUtil { private Map initBasicInventoryFileV2(List detailsDtoList) throws Exception { List allBdInvbasdocEntityList = new ArrayList<>(); if (detailsDtoList != null && detailsDtoList.size() > 0) { - List> lists = SplitListByCountUtil.splitListByCount(detailsDtoList, 500); + Set stringSet = detailsDtoList.stream().map(StockinOrderSearchResponse.StockinOrder.StockinB::getSkuCode).collect(Collectors.toSet()); + List stringList = stringSet.stream().collect(Collectors.toList()); + List> lists = SplitListByCountUtil.splitListByCount(stringList, 900); for (int i = 0; i < lists.size(); i++) { - List stockinBList = lists.get(i); - String idsStr = stockinBList.stream().map(StockinOrderSearchResponse.StockinOrder.StockinB::getSkuCode).map(id -> "'" + id + "'").collect(Collectors.joining(",")); - - BdInvbasdocEntity bdInvbasdocEntity = new BdInvbasdocEntity(); - bdInvbasdocEntity.setInvcodes(idsStr); - List bdInvbasdocEntities = iBdInvbasdocDao.queryBdInvbasdocByPkInvmandocV3(bdInvbasdocEntity); - allBdInvbasdocEntityList.addAll(bdInvbasdocEntities); + List strings = lists.get(i); + String codesStr = strings.stream().map(s -> "'" + s.trim() + "'").collect(Collectors.joining(",")); + if (codesStr != null && codesStr.length() > 0) { + BdInvbasdocEntity bdInvbasdocEntity = new BdInvbasdocEntity(); + bdInvbasdocEntity.setInvcodes(codesStr); + List bdInvbasdocEntities = iBdInvbasdocDao.queryBdInvbasdocByPkInvmandocV3(bdInvbasdocEntity); + allBdInvbasdocEntityList.addAll(bdInvbasdocEntities); + } } +// List> lists = SplitListByCountUtil.splitListByCount(detailsDtoList, 500); +// for (int i = 0; i < lists.size(); i++) { +// List stockinBList = lists.get(i); +// String idsStr = stockinBList.stream().map(StockinOrderSearchResponse.StockinOrder.StockinB::getSkuCode).map(id -> "'" + id + "'").collect(Collectors.joining(",")); +// +// BdInvbasdocEntity bdInvbasdocEntity = new BdInvbasdocEntity(); +// bdInvbasdocEntity.setInvcodes(idsStr); +// List bdInvbasdocEntities = iBdInvbasdocDao.queryBdInvbasdocByPkInvmandocV3(bdInvbasdocEntity); +// allBdInvbasdocEntityList.addAll(bdInvbasdocEntities); +// } } Map stringBdInvbasdocEntityMap = new HashMap<>(); for (int i = 0; i < allBdInvbasdocEntityList.size(); i++) { @@ -409,16 +464,29 @@ public class TocReturnBasicArchivesCacheUtil { List allBdTaxitemsEntityList = new ArrayList<>(); Map stringBdTaxitemsEntityMap = new HashMap<>(); if (detailsDtos != null && detailsDtos.size() > 0) { - List> lists = SplitListByCountUtil.splitListByCount(detailsDtos, 500); + Set stringSet = detailsDtos.stream().map(StockinOrderSearchResponse.StockinOrder.StockinB::getSkuCode).collect(Collectors.toSet()); + List stringList = stringSet.stream().collect(Collectors.toList()); + List> lists = SplitListByCountUtil.splitListByCount(stringList, 900); for (int i = 0; i < lists.size(); i++) { - List stockinBList = lists.get(i); - String codesStr = stockinBList.stream().map(StockinOrderSearchResponse.StockinOrder.StockinB::getSkuCode).map(id -> "'" + id + "'").collect(Collectors.joining(",")); - - BdTaxitemsEntity bdTaxitemsEntity = new BdTaxitemsEntity(); - bdTaxitemsEntity.setInvcodes(codesStr); - List bdTaxitemsEntityList = iBdTaxitemsDao.queryBdInvbasdocByInvcodeV2(bdTaxitemsEntity); - allBdTaxitemsEntityList.addAll(bdTaxitemsEntityList); + List strings = lists.get(i); + String result = strings.stream().map(s -> "'" + s.trim() + "'").collect(Collectors.joining(",")); + if (result != null && result.length() > 0) { + BdTaxitemsEntity bdTaxitemsEntity = new BdTaxitemsEntity(); + bdTaxitemsEntity.setInvcodes(result); + List bdTaxitemsEntityList = iBdTaxitemsDao.queryBdInvbasdocByInvcodeV2(bdTaxitemsEntity); + allBdTaxitemsEntityList.addAll(bdTaxitemsEntityList); + } } +// List> lists = SplitListByCountUtil.splitListByCount(detailsDtos, 500); +// for (int i = 0; i < lists.size(); i++) { +// List stockinBList = lists.get(i); +// String codesStr = stockinBList.stream().map(StockinOrderSearchResponse.StockinOrder.StockinB::getSkuCode).map(id -> "'" + id + "'").collect(Collectors.joining(",")); +// +// BdTaxitemsEntity bdTaxitemsEntity = new BdTaxitemsEntity(); +// bdTaxitemsEntity.setInvcodes(codesStr); +// List bdTaxitemsEntityList = iBdTaxitemsDao.queryBdInvbasdocByInvcodeV2(bdTaxitemsEntity); +// allBdTaxitemsEntityList.addAll(bdTaxitemsEntityList); +// } } if (allBdTaxitemsEntityList.size() > 0) { for (int i = 0; i < allBdTaxitemsEntityList.size(); i++) {