perf(sales): 优化销售出库和退货性能
-调整销售出库和退货的批量处理数量,从 800 增加到 1000 - 优化退货处理逻辑,使用 Map 结构提高查询效率 - 移除不必要的注释代码,提高代码可读性 - 更新测试用例,使用更早的订单号进行测试
This commit is contained in:
parent
873355c87c
commit
48e7bc9900
|
@ -566,7 +566,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
|
|||
// List<com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.HeaderDetailsDto> headerDetailsDtoList1 = new ArrayList<>();
|
||||
List<TocofsSaleoutDetailedEntity> allTocofsSaleoutDetailedEntityList = new ArrayList<>();
|
||||
if (headerDetailsDtoList != null && headerDetailsDtoList.size() > 0) {
|
||||
List<List<HeaderDetailsDto>> splitListByCount = SplitListByCountUtil.splitListByCount(headerDetailsDtoList, 800);
|
||||
List<List<HeaderDetailsDto>> splitListByCount = SplitListByCountUtil.splitListByCount(headerDetailsDtoList, 1000);
|
||||
for (int i = 0; i < splitListByCount.size(); i++) {
|
||||
List<HeaderDetailsDto> headerDetailsDtoList2 = splitListByCount.get(i);
|
||||
String idStr = commaConcatenatedPrimaryKeyStock(headerDetailsDtoList2);
|
||||
|
@ -4082,7 +4082,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
|
|||
}
|
||||
|
||||
//通过「O销售出库单表头」匹配「底表O销售出库单明细行」
|
||||
List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntitiesAll = new ArrayList<>();
|
||||
// List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntitiesAll = new ArrayList<>();
|
||||
if (allTocofsSaleoutEntityList.size() > 0) {
|
||||
Map<String, List<TocofsSaleoutDetailedEntity>> stringListMap = convertToMap(tocofsSaleoutDetailedEntityList);
|
||||
|
||||
|
@ -4096,7 +4096,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
|
|||
// }
|
||||
// }
|
||||
List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntities = stringListMap.get(tocofsSaleoutEntity.getId());
|
||||
tocofsSaleoutDetailedEntitiesAll.addAll(tocofsSaleoutDetailedEntities);
|
||||
// tocofsSaleoutDetailedEntitiesAll.addAll(tocofsSaleoutDetailedEntities);
|
||||
tocofsSaleoutEntity.setTocofsSaleoutDetailedEntityList(tocofsSaleoutDetailedEntities);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import cn.hutool.core.util.StrUtil;
|
|||
import cn.hutool.http.HttpRequest;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.hzya.frame.base.PluginBaseEntity;
|
||||
import com.hzya.frame.beanutil.BeanUtil;
|
||||
import com.hzya.frame.plugin.lets.constant.OverallConstant;
|
||||
|
@ -471,7 +472,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, 800);
|
||||
List<List<StockinOrderSearchResponse.StockinOrder>> splitListByCount = SplitListByCountUtil.splitListByCount(returnGoodHeaderDetailsDataDtoArrayList, 1000);
|
||||
for (int i = 0; i < splitListByCount.size(); i++) {
|
||||
List<StockinOrderSearchResponse.StockinOrder> stockinOrderList = splitListByCount.get(i);
|
||||
String idStr = commaConcatenatedPrimaryKeyStock(stockinOrderList);
|
||||
|
@ -3114,13 +3115,16 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
|
|||
List<TocofsReturngoodsEntity> allTocofsReturngoodsEntityList = new ArrayList<>();
|
||||
//底表O售后入库单明细行
|
||||
List<TocofsReturngoodsDetailedEntity> tocofsReturngoodsDetailedEntityList = iTocofsReturngoodsDetailedDao.query(tocofsReturngoodsDetailedEntity);
|
||||
|
||||
if (tocofsReturngoodsDetailedEntityList != null && tocofsReturngoodsDetailedEntityList.size() > 0) {
|
||||
List<List<TocofsReturngoodsDetailedEntity>> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsReturngoodsDetailedEntityList, 1000);
|
||||
Set<String> mainTableIdSet = tocofsReturngoodsDetailedEntityList.stream().map(TocofsReturngoodsDetailedEntity::getMaintableid).collect(Collectors.toSet());
|
||||
List<String> mainTableIdList = Lists.newArrayList(mainTableIdSet);
|
||||
|
||||
List<List<String>> splitListByCount = SplitListByCountUtil.splitListByCount(mainTableIdList, 1000);
|
||||
// List<List<TocofsReturngoodsDetailedEntity>> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsReturngoodsDetailedEntityList, 1000);
|
||||
for (int i = 0; i < splitListByCount.size(); i++) {
|
||||
List<TocofsReturngoodsDetailedEntity> tocofsReturngoodsDetailedEntityList1 = splitListByCount.get(i);
|
||||
Set<String> mainTableIdSet = tocofsReturngoodsDetailedEntityList1.stream().map(TocofsReturngoodsDetailedEntity::getMaintableid).collect(Collectors.toSet());
|
||||
String mainTableIds = mainTableIdSet.stream().map(id -> "'" + id + "'").collect(Collectors.joining(","));
|
||||
List<String> strings = splitListByCount.get(i);
|
||||
// Set<String> mainTableIdSet = tocofsReturngoodsDetailedEntityList1.stream().map(TocofsReturngoodsDetailedEntity::getMaintableid).collect(Collectors.toSet());
|
||||
String mainTableIds = strings.stream().map(id -> "'" + id + "'").collect(Collectors.joining(","));
|
||||
//查询对应的O售后入库单表头
|
||||
TocofsReturngoodsEntity tocofsReturngoodsEntity = new TocofsReturngoodsEntity();
|
||||
tocofsReturngoodsEntity.setIds(mainTableIds);
|
||||
|
@ -3131,16 +3135,20 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
|
|||
|
||||
//通过「O售后入库单表头」匹配「O售后入库单明细」
|
||||
if (allTocofsReturngoodsEntityList.size() > 0) {
|
||||
Map<String, List<TocofsReturngoodsDetailedEntity>> stringListMap = convertToMap(tocofsReturngoodsDetailedEntityList);
|
||||
for (int i = 0; i < allTocofsReturngoodsEntityList.size(); i++) {
|
||||
TocofsReturngoodsEntity tocofsReturngoodsEntity = allTocofsReturngoodsEntityList.get(i);
|
||||
List<TocofsReturngoodsDetailedEntity> tocofsReturngoodsDetailedEntityList1 = new ArrayList<>();
|
||||
for (int j = 0; j < tocofsReturngoodsDetailedEntityList.size(); j++) {
|
||||
TocofsReturngoodsDetailedEntity tocofsReturngoodsDetailedEntity1 = tocofsReturngoodsDetailedEntityList.get(j);
|
||||
if (tocofsReturngoodsDetailedEntity1.getMaintableid().equals(tocofsReturngoodsEntity.getId())) {
|
||||
tocofsReturngoodsDetailedEntityList1.add(tocofsReturngoodsDetailedEntity1);
|
||||
}
|
||||
}
|
||||
tocofsReturngoodsEntity.setTocofsReturngoodsDetailedEntityList(tocofsReturngoodsDetailedEntityList1);
|
||||
//性能太差了,使用Map搜索
|
||||
// List<TocofsReturngoodsDetailedEntity> tocofsReturngoodsDetailedEntityList1 = new ArrayList<>();
|
||||
// for (int j = 0; j < tocofsReturngoodsDetailedEntityList.size(); j++) {
|
||||
// TocofsReturngoodsDetailedEntity tocofsReturngoodsDetailedEntity1 = tocofsReturngoodsDetailedEntityList.get(j);
|
||||
// if (tocofsReturngoodsDetailedEntity1.getMaintableid().equals(tocofsReturngoodsEntity.getId())) {
|
||||
// tocofsReturngoodsDetailedEntityList1.add(tocofsReturngoodsDetailedEntity1);
|
||||
// }
|
||||
// }
|
||||
// tocofsReturngoodsEntity.setTocofsReturngoodsDetailedEntityList(tocofsReturngoodsDetailedEntityList1);
|
||||
List<TocofsReturngoodsDetailedEntity> tocofsReturngoodsDetailedEntities = stringListMap.get(tocofsReturngoodsEntity.getId());
|
||||
tocofsReturngoodsEntity.setTocofsReturngoodsDetailedEntityList(tocofsReturngoodsDetailedEntities);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3175,4 +3183,18 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
|
|||
}
|
||||
return returnGoodHeaderDetailsDataDtoArrayList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 存在相同Maintableid汇总在一起
|
||||
*
|
||||
* @author liuyang
|
||||
*/
|
||||
public static Map<String, List<TocofsReturngoodsDetailedEntity>> convertToMap(List<TocofsReturngoodsDetailedEntity> tocofsReturngoodsDetailedEntityList) {
|
||||
Map<String, List<TocofsReturngoodsDetailedEntity>> map = new HashMap<>();
|
||||
for (TocofsReturngoodsDetailedEntity entity : tocofsReturngoodsDetailedEntityList) {
|
||||
String maintableid = entity.getMaintableid();
|
||||
map.computeIfAbsent(maintableid, k -> new ArrayList<>()).add(entity);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
|
@ -89,7 +89,7 @@ public class SoSaleOutPluginInitializerToBTest {
|
|||
|
||||
// soSaleOutPluginInitializerToB.startImplementByStockTime("2024-10-31 14:48:41", "2024-10-31 14:48:41");
|
||||
|
||||
soSaleOutPluginInitializerToB.startImplementByCode("LETS-SH2025011400029405", "stock");
|
||||
soSaleOutPluginInitializerToB.startImplementByCode("LETS-SH2024122000040612", "stock");
|
||||
|
||||
|
||||
// soSaleOutPluginInitializerToB.startImplementByStockTime("2024-11-08 19:18:02", "2024-11-08 19:18:02");
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.hzya.frame.plugin.lets.plugin.sales;
|
||||
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.lang.UUID;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
@ -133,7 +134,7 @@ class SoSaleOutPluginInitializerToCTest {
|
|||
// soSaleOutPluginInitializerToC.sendU8CTOCOrder("123446");
|
||||
|
||||
try {
|
||||
soSaleOutPluginInitializerToC.startImplementStockByCode("LETS-SH2025011400029405", "stock");
|
||||
// soSaleOutPluginInitializerToC.startImplementStockByCode("LETS-SH2025011400029405", "stock");
|
||||
// soSaleOutPluginInitializerToC.startImplementStockByCode("LETS-SH2025011300024220", "tran");
|
||||
|
||||
// soSaleOutPluginInitializerToC.startImplementStockByCode("LETS-SH2025012300026949", "tran");
|
||||
|
@ -144,5 +145,30 @@ class SoSaleOutPluginInitializerToCTest {
|
|||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Thread thread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Thread currentThread = Thread.currentThread();
|
||||
try {
|
||||
while (true) {
|
||||
Thread.currentThread().sleep(1000);
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
currentThread.setName("线程名称:" + UUID.fastUUID());
|
||||
long end = System.currentTimeMillis();
|
||||
System.out.println("耗时:" + (end - start));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}, "线程1");
|
||||
thread.start();
|
||||
|
||||
while (true) {
|
||||
Thread.currentThread().sleep(1000);
|
||||
System.out.println(thread.getName());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue