feat(sales): 优化 TOC 退货性能并添加结存价功能
- 使用 Map 优化性能,替换原有的循环查找逻辑 - 添加结存价和采购价初始化功能 - 根据店铺选择性地使用结存价或采购价计算退货金额 - 优化线程处理,提高数据插入效率 - 调整批量查询逻辑,减少数据库访问次数
This commit is contained in:
parent
428ddef112
commit
64ce827656
|
@ -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<Map> mapList = initAllBalancePricePurchasePrice();
|
||||
|
||||
|
||||
if (bdBusitypeEntity != null && summaryDimensionMap != null) {
|
||||
Iterator<Map.Entry<String, List<SonDetailsDto>>> iterator = summaryDimensionMap.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
|
|
|
@ -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<StockinOrderSearchResponse.StockinOrder> headerDetailsDtoList1 = new ArrayList<>();
|
||||
List<TocofsReturngoodsDetailedEntity> tocofsReturngoodsDetailedEntityList = new ArrayList<>();
|
||||
if (returnGoodHeaderDetailsDataDtoArrayList != null && returnGoodHeaderDetailsDataDtoArrayList.size() > 0) {
|
||||
List<List<StockinOrderSearchResponse.StockinOrder>> splitListByCount = SplitListByCountUtil.splitListByCount(returnGoodHeaderDetailsDataDtoArrayList, 100);
|
||||
List<List<StockinOrderSearchResponse.StockinOrder>> splitListByCount = SplitListByCountUtil.splitListByCount(returnGoodHeaderDetailsDataDtoArrayList, 800);
|
||||
for (int i = 0; i < splitListByCount.size(); i++) {
|
||||
List<StockinOrderSearchResponse.StockinOrder> 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<StockinOrderSearchResponse.StockinOrder.StockinB> 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<List<StockinOrderSearchResponse.StockinOrder.StockinH>> lists = SplitListByCountUtil.splitListByCount(headerDetailsDtoList1, 100);
|
||||
List<List<StockinOrderSearchResponse.StockinOrder.StockinH>> lists = SplitListByCountUtil.splitListByCount(headerDetailsDtoList1, 800);
|
||||
for (int i = 0; i < lists.size(); i++) {
|
||||
List<StockinOrderSearchResponse.StockinOrder.StockinH> stockinHS = lists.get(i);
|
||||
List<TocofsReturngoodsEntity> 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<TocofsReturngoodsEntity> 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<List<StockinOrderSearchResponse.StockinOrder.StockinB>> lists1 = SplitListByCountUtil.splitListByCount(headerDetailsDtoList2, 100);
|
||||
List<List<StockinOrderSearchResponse.StockinOrder.StockinB>> lists1 = SplitListByCountUtil.splitListByCount(headerDetailsDtoList2, 800);
|
||||
for (int i = 0; i < lists1.size(); i++) {
|
||||
List<StockinOrderSearchResponse.StockinOrder.StockinB> stockinBS = lists1.get(i);
|
||||
List<TocofsReturngoodsDetailedEntity> 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<Map> mapList = initAllBalancePricePurchasePrice();
|
||||
|
||||
if (bdBusitypeEntity != null && summaryDimensionMap != null) {
|
||||
Iterator<Map.Entry<String, List<GoodsRertunSonDetailsDto>>> iterator = summaryDimensionMap.entrySet().iterator();
|
||||
|
@ -628,8 +661,11 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
|
|||
List<SaleorderRequestChildrenDto> 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<String, List<GoodsRertunSonDetailsDto>> summaryDimensionMap = groupSummary(goodsRertunSonDetailsDtos);
|
||||
// 查询U8C业务流程
|
||||
BdBusitypeEntity bdBusitypeEntity = u8cOperationFlowV2();
|
||||
|
||||
//初始化所有存货管理档案对应的结存价+采购价
|
||||
List<Map> mapList = initAllBalancePricePurchasePrice();
|
||||
|
||||
if (bdBusitypeEntity != null && summaryDimensionMap != null) {
|
||||
Iterator<Map.Entry<String, List<GoodsRertunSonDetailsDto>>> iterator = summaryDimensionMap.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
|
@ -835,8 +873,11 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
|
|||
List<SaleorderRequestChildrenDto> 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<GoodsRertunSonDetailsDto> sonDetailsDtoList) throws Exception {
|
||||
private GoodsRertunSonDetailsDto groupMergeDetailedRows(List<GoodsRertunSonDetailsDto> sonDetailsDtoList, Boolean isCheckShopChoose, List<Map> 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<StockinOrderSearchResponse.StockinOrder> targetHeaderDetailsDtoList = new ArrayList<>();
|
||||
|
||||
if (returnGoodHeaderDetailsDataDtoArrayList != null && returnGoodHeaderDetailsDataDtoArrayList.size() > 0) {
|
||||
List<TocofsReturngoodsDetailedEntity> resultList = tocofsReturngoodsDetailedEntityList.stream().map(obj -> {
|
||||
if (obj.getNewstate3() == null) {
|
||||
obj.setNewstate3("");
|
||||
}
|
||||
return obj;
|
||||
}).collect(Collectors.toList());
|
||||
Map<String, String> 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<Map> initAllBalancePricePurchasePrice() throws Exception {
|
||||
List<Map> mapList = new ArrayList<>();
|
||||
Map<String, IaPeriodaccountEntity> stringIaPeriodaccountEntityMap = balanceUnitPriceUtil.initBalancePrice();
|
||||
Map<String, PoOrderBEntity> 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<Map> 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<String, IaPeriodaccountEntity> stringIaPeriodaccountEntityMap = (Map<String, IaPeriodaccountEntity>) 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<String, PoOrderBEntity> poOrderBEntityList = (Map<String, PoOrderBEntity>) 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;
|
||||
}
|
||||
}
|
|
@ -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<String, BdCubasdocEntity> stringBdCubasdocEntityMap = new HashMap<>();
|
||||
List<BdCubasdocEntity> allBdCumandocEntityList = new ArrayList<>();
|
||||
if (headerDtoList != null && headerDtoList.size() > 0) {
|
||||
List<List<StockinOrderSearchResponse.StockinOrder.StockinH>> lists = SplitListByCountUtil.splitListByCount(headerDtoList, 900);
|
||||
Set<String> stringSet = headerDtoList.stream().map(StockinOrderSearchResponse.StockinOrder.StockinH::getStoreCode).collect(Collectors.toSet());
|
||||
List<String> stringList = stringSet.stream().collect(Collectors.toList());
|
||||
List<List<String>> lists = SplitListByCountUtil.splitListByCount(stringList, 900);
|
||||
for (int i = 0; i < lists.size(); i++) {
|
||||
List<StockinOrderSearchResponse.StockinOrder.StockinH> 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<BdCubasdocEntity> bdCumandocEntityList = iBdCubasdocDao.query(bdCubasdocEntity);
|
||||
allBdCumandocEntityList.addAll(bdCumandocEntityList);
|
||||
List<String> 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<BdCubasdocEntity> bdCumandocEntityList = iBdCubasdocDao.query(bdCubasdocEntity);
|
||||
allBdCumandocEntityList.addAll(bdCumandocEntityList);
|
||||
}
|
||||
}
|
||||
// List<List<StockinOrderSearchResponse.StockinOrder.StockinH>> lists = SplitListByCountUtil.splitListByCount(headerDtoList, 900);
|
||||
// for (int i = 0; i < lists.size(); i++) {
|
||||
// List<StockinOrderSearchResponse.StockinOrder.StockinH> 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<BdCubasdocEntity> 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<BdCumandocEntity> allBdCumandocEntityList = new ArrayList<>();
|
||||
|
||||
if (headerDtoList != null && headerDtoList.size() > 0) {
|
||||
List<List<StockinOrderSearchResponse.StockinOrder.StockinH>> lists = SplitListByCountUtil.splitListByCount(headerDtoList, 500);
|
||||
for (int i = 0; i < lists.size(); i++) {
|
||||
List<StockinOrderSearchResponse.StockinOrder.StockinH> stockinHList = lists.get(i);
|
||||
String codesStr = stockinHList.stream().map(StockinOrderSearchResponse.StockinOrder.StockinH::getStoreCode).map(id -> "'" + id + "'").collect(Collectors.joining(","));
|
||||
Set<String> stringSet = headerDtoList.stream().map(StockinOrderSearchResponse.StockinOrder.StockinH::getStoreCode).collect(Collectors.toSet());
|
||||
List<String> stringList = stringSet.stream().collect(Collectors.toList());
|
||||
List<List<String>> lists = SplitListByCountUtil.splitListByCount(stringList, 900);
|
||||
|
||||
for (int i = 0; i < lists.size(); i++) {
|
||||
List<String> 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<BdCumandocEntity> bdCumandocEntityList = iBdCumandocDao.query(bdCumandocEntity);
|
||||
allBdCumandocEntityList.addAll(bdCumandocEntityList);
|
||||
}
|
||||
|
||||
// List<List<StockinOrderSearchResponse.StockinOrder.StockinH>> lists = SplitListByCountUtil.splitListByCount(headerDtoList, 500);
|
||||
// for (int i = 0; i < lists.size(); i++) {
|
||||
// List<StockinOrderSearchResponse.StockinOrder.StockinH> 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<BdCumandocEntity> 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<String, BdInvmandocEntity> stringBdInvmandocEntityMap = new HashMap<>();
|
||||
|
||||
if (detailsDtos != null && detailsDtos.size() > 0) {
|
||||
List<List<StockinOrderSearchResponse.StockinOrder.StockinB>> lists = SplitListByCountUtil.splitListByCount(detailsDtos, 500);
|
||||
Set<String> stringSet = detailsDtos.stream().map(StockinOrderSearchResponse.StockinOrder.StockinB::getSkuCode).collect(Collectors.toSet());
|
||||
List<String> stringList = stringSet.stream().collect(Collectors.toList());
|
||||
List<List<String>> lists = SplitListByCountUtil.splitListByCount(stringList, 900);
|
||||
for (int i = 0; i < lists.size(); i++) {
|
||||
List<StockinOrderSearchResponse.StockinOrder.StockinB> 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<BdInvmandocEntity> bdInvmandocEntity2 = iBdInvmandocDao.queryBdInvmandocByInvcodeList(bdInvmandocEntity);
|
||||
allBdInvmandocEntity.addAll(bdInvmandocEntity2);
|
||||
List<String> 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<BdInvmandocEntity> bdInvmandocEntity2 = iBdInvmandocDao.queryBdInvmandocByInvcodeList(bdInvmandocEntity);
|
||||
allBdInvmandocEntity.addAll(bdInvmandocEntity2);
|
||||
}
|
||||
}
|
||||
|
||||
// List<List<StockinOrderSearchResponse.StockinOrder.StockinB>> lists = SplitListByCountUtil.splitListByCount(detailsDtos, 500);
|
||||
// for (int i = 0; i < lists.size(); i++) {
|
||||
// List<StockinOrderSearchResponse.StockinOrder.StockinB> 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<BdInvmandocEntity> 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<String, BdInvbasdocEntity> initBasicInventoryFileV2(List<StockinOrderSearchResponse.StockinOrder.StockinB> detailsDtoList) throws Exception {
|
||||
List<BdInvbasdocEntity> allBdInvbasdocEntityList = new ArrayList<>();
|
||||
if (detailsDtoList != null && detailsDtoList.size() > 0) {
|
||||
List<List<StockinOrderSearchResponse.StockinOrder.StockinB>> lists = SplitListByCountUtil.splitListByCount(detailsDtoList, 500);
|
||||
Set<String> stringSet = detailsDtoList.stream().map(StockinOrderSearchResponse.StockinOrder.StockinB::getSkuCode).collect(Collectors.toSet());
|
||||
List<String> stringList = stringSet.stream().collect(Collectors.toList());
|
||||
List<List<String>> lists = SplitListByCountUtil.splitListByCount(stringList, 900);
|
||||
for (int i = 0; i < lists.size(); i++) {
|
||||
List<StockinOrderSearchResponse.StockinOrder.StockinB> 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<BdInvbasdocEntity> bdInvbasdocEntities = iBdInvbasdocDao.queryBdInvbasdocByPkInvmandocV3(bdInvbasdocEntity);
|
||||
allBdInvbasdocEntityList.addAll(bdInvbasdocEntities);
|
||||
List<String> 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<BdInvbasdocEntity> bdInvbasdocEntities = iBdInvbasdocDao.queryBdInvbasdocByPkInvmandocV3(bdInvbasdocEntity);
|
||||
allBdInvbasdocEntityList.addAll(bdInvbasdocEntities);
|
||||
}
|
||||
}
|
||||
// List<List<StockinOrderSearchResponse.StockinOrder.StockinB>> lists = SplitListByCountUtil.splitListByCount(detailsDtoList, 500);
|
||||
// for (int i = 0; i < lists.size(); i++) {
|
||||
// List<StockinOrderSearchResponse.StockinOrder.StockinB> 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<BdInvbasdocEntity> bdInvbasdocEntities = iBdInvbasdocDao.queryBdInvbasdocByPkInvmandocV3(bdInvbasdocEntity);
|
||||
// allBdInvbasdocEntityList.addAll(bdInvbasdocEntities);
|
||||
// }
|
||||
}
|
||||
Map<String, BdInvbasdocEntity> stringBdInvbasdocEntityMap = new HashMap<>();
|
||||
for (int i = 0; i < allBdInvbasdocEntityList.size(); i++) {
|
||||
|
@ -409,16 +464,29 @@ public class TocReturnBasicArchivesCacheUtil {
|
|||
List<BdTaxitemsEntity> allBdTaxitemsEntityList = new ArrayList<>();
|
||||
Map<String, BdTaxitemsEntity> stringBdTaxitemsEntityMap = new HashMap<>();
|
||||
if (detailsDtos != null && detailsDtos.size() > 0) {
|
||||
List<List<StockinOrderSearchResponse.StockinOrder.StockinB>> lists = SplitListByCountUtil.splitListByCount(detailsDtos, 500);
|
||||
Set<String> stringSet = detailsDtos.stream().map(StockinOrderSearchResponse.StockinOrder.StockinB::getSkuCode).collect(Collectors.toSet());
|
||||
List<String> stringList = stringSet.stream().collect(Collectors.toList());
|
||||
List<List<String>> lists = SplitListByCountUtil.splitListByCount(stringList, 900);
|
||||
for (int i = 0; i < lists.size(); i++) {
|
||||
List<StockinOrderSearchResponse.StockinOrder.StockinB> 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<BdTaxitemsEntity> bdTaxitemsEntityList = iBdTaxitemsDao.queryBdInvbasdocByInvcodeV2(bdTaxitemsEntity);
|
||||
allBdTaxitemsEntityList.addAll(bdTaxitemsEntityList);
|
||||
List<String> 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<BdTaxitemsEntity> bdTaxitemsEntityList = iBdTaxitemsDao.queryBdInvbasdocByInvcodeV2(bdTaxitemsEntity);
|
||||
allBdTaxitemsEntityList.addAll(bdTaxitemsEntityList);
|
||||
}
|
||||
}
|
||||
// List<List<StockinOrderSearchResponse.StockinOrder.StockinB>> lists = SplitListByCountUtil.splitListByCount(detailsDtos, 500);
|
||||
// for (int i = 0; i < lists.size(); i++) {
|
||||
// List<StockinOrderSearchResponse.StockinOrder.StockinB> 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<BdTaxitemsEntity> bdTaxitemsEntityList = iBdTaxitemsDao.queryBdInvbasdocByInvcodeV2(bdTaxitemsEntity);
|
||||
// allBdTaxitemsEntityList.addAll(bdTaxitemsEntityList);
|
||||
// }
|
||||
}
|
||||
if (allBdTaxitemsEntityList.size() > 0) {
|
||||
for (int i = 0; i < allBdTaxitemsEntityList.size(); i++) {
|
||||
|
|
Loading…
Reference in New Issue