From 1ffef190ef1fe5dbb80daa1fcf3b8ca00011244c Mon Sep 17 00:00:00 2001 From: liuy <37787198+LiuyCodes@users.noreply.github.com> Date: Sat, 8 Feb 2025 23:36:54 +0800 Subject: [PATCH] =?UTF-8?q?refactor(sales):=20=E4=BC=98=E5=8C=96=E9=94=80?= =?UTF-8?q?=E5=94=AE=E5=87=BA=E5=BA=93=E5=8D=95=E6=95=B0=E6=8D=AE=E5=A4=84?= =?UTF-8?q?=E7=90=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增代码注释和调试信息,便于排查问题 - 优化数据查询和处理逻辑,提高效率 - 使用 Set 和 List转换,避免重复数据 - 重构部分代码结构,提高可读性 --- .../sales/SoSaleOutPluginInitializerToC.java | 33 +++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) 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 200c60b4..ea1deba7 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 @@ -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; @@ -39,6 +40,7 @@ import com.hzya.frame.u8c.ax.entity.Ass; import com.hzya.frame.web.entity.BaseResult; import com.hzya.frame.web.entity.JsonResultEntity; import com.hzya.frame.web.exception.BaseSystemException; +import org.apache.commons.collections.ListUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -572,6 +574,12 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { allTocofsSaleoutDetailedEntityList.addAll(tocofsSaleoutDetailedEntityList); } } + // 判断重启的key +// allTocofsSaleoutDetailedEntityList.stream().collect(Collectors.groupingBy(s -> s, Collectors.counting())).forEach((key, count) -> { +// if (count > 1) { +// System.out.println("重复的键: " + key + ", 出现次数: " + count); +// } +// }); return filterDataRowsAsPushOrFailedStock(allTocofsSaleoutDetailedEntityList, headerDetailsDtoList); } @@ -657,6 +665,14 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { } return obj; }).collect(Collectors.toList()); + + //排查代码 +// resultList.stream().collect(Collectors.groupingBy(s -> s, Collectors.counting())).forEach((key, count) -> { +// if (count > 1) { +// System.out.println("重复的键: " + key + ", 出现次数: " + count); +// } +// }); + Map no2NameMap = resultList.stream().collect(Collectors.toMap(TocofsSaleoutDetailedEntity::getId, TocofsSaleoutDetailedEntity::getNewstate)); //字段Y(成功)或者为H(手工处理)可以视为成功,完成了小段业务闭环的数据行 @@ -4044,16 +4060,19 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { // tocofsSaleoutDetailedEntity.setBusinessDateEnd(); // tocofsSaleoutDetailedEntity.setBusinesstype("TOC_ORDER"); - //底表O销售出库单表头对象 + //底表O销售出库单表头对象 34479 List allTocofsSaleoutEntityList = new ArrayList<>(); - //底表O销售出库单明细行 + //底表O销售出库单明细行 71874 List tocofsSaleoutDetailedEntityList = iTocofsSaleoutDetailedDao.query(tocofsSaleoutDetailedEntity); if (tocofsSaleoutDetailedEntityList != null && tocofsSaleoutDetailedEntityList.size() > 0) { - List> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsSaleoutDetailedEntityList, 1000); + Set mainTableIdSet = tocofsSaleoutDetailedEntityList.stream().map(TocofsSaleoutDetailedEntity::getMaintableid).collect(Collectors.toSet()); + List mainTableIdList = Lists.newArrayList(mainTableIdSet); + + List> splitListByCount = SplitListByCountUtil.splitListByCount(mainTableIdList, 1000); for (int i = 0; i < splitListByCount.size(); i++) { - List tocofsSaleoutDetailedEntityList1 = splitListByCount.get(i); - Set mainTableIdSet = tocofsSaleoutDetailedEntityList1.stream().map(TocofsSaleoutDetailedEntity::getMaintableid).collect(Collectors.toSet()); - String mainTableIds = mainTableIdSet.stream().map(id -> "'" + id + "'").collect(Collectors.joining(",")); + List tocofsSaleoutDetailedEntityList1 = splitListByCount.get(i); +// Set mainTableIdSet = tocofsSaleoutDetailedEntityList1.stream().map(TocofsSaleoutDetailedEntity::getMaintableid).collect(Collectors.toSet()); + String mainTableIds = tocofsSaleoutDetailedEntityList1.stream().map(id -> "'" + id + "'").collect(Collectors.joining(",")); //查询对应的O销售出库单表头 TocofsSaleoutEntity tocofsSaleoutEntity = new TocofsSaleoutEntity(); tocofsSaleoutEntity.setIds(mainTableIds); @@ -4063,6 +4082,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { } //通过「O销售出库单表头」匹配「底表O销售出库单明细行」 + List tocofsSaleoutDetailedEntitiesAll = new ArrayList<>(); if (allTocofsSaleoutEntityList.size() > 0) { Map> stringListMap = convertToMap(tocofsSaleoutDetailedEntityList); @@ -4076,6 +4096,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { // } // } List tocofsSaleoutDetailedEntities = stringListMap.get(tocofsSaleoutEntity.getId()); + tocofsSaleoutDetailedEntitiesAll.addAll(tocofsSaleoutDetailedEntities); tocofsSaleoutEntity.setTocofsSaleoutDetailedEntityList(tocofsSaleoutDetailedEntities); } }