refactor(sales): 优化销售出库单匹配逻辑
-将原有的双重循环匹配改为使用 Map 进行优化 - 新增 convertToMap 方法,用于将明细行数据转换为 Map 形式 - 修改测试代码,增加业务类型查询相关代码
This commit is contained in:
parent
4271e8e891
commit
f522db520c
|
@ -4064,16 +4064,19 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
|
||||||
|
|
||||||
//通过「O销售出库单表头」匹配「底表O销售出库单明细行」
|
//通过「O销售出库单表头」匹配「底表O销售出库单明细行」
|
||||||
if (allTocofsSaleoutEntityList.size() > 0) {
|
if (allTocofsSaleoutEntityList.size() > 0) {
|
||||||
|
Map<String, List<TocofsSaleoutDetailedEntity>> stringListMap = convertToMap(tocofsSaleoutDetailedEntityList);
|
||||||
|
|
||||||
for (int i = 0; i < allTocofsSaleoutEntityList.size(); i++) {
|
for (int i = 0; i < allTocofsSaleoutEntityList.size(); i++) {
|
||||||
TocofsSaleoutEntity tocofsSaleoutEntity = allTocofsSaleoutEntityList.get(i);
|
TocofsSaleoutEntity tocofsSaleoutEntity = allTocofsSaleoutEntityList.get(i);
|
||||||
List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntityList1 = new ArrayList<>();
|
// List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntityList1 = new ArrayList<>();
|
||||||
for (int j = 0; j < tocofsSaleoutDetailedEntityList.size(); j++) {
|
// for (int j = 0; j < tocofsSaleoutDetailedEntityList.size(); j++) {
|
||||||
TocofsSaleoutDetailedEntity tocofsSaleoutDetailedEntity1 = tocofsSaleoutDetailedEntityList.get(j);
|
// TocofsSaleoutDetailedEntity tocofsSaleoutDetailedEntity1 = tocofsSaleoutDetailedEntityList.get(j);
|
||||||
if (tocofsSaleoutDetailedEntity1.getMaintableid().equals(tocofsSaleoutEntity.getId())) {
|
// if (tocofsSaleoutDetailedEntity1.getMaintableid().equals(tocofsSaleoutEntity.getId())) {
|
||||||
tocofsSaleoutDetailedEntityList1.add(tocofsSaleoutDetailedEntity1);
|
// tocofsSaleoutDetailedEntityList1.add(tocofsSaleoutDetailedEntity1);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
tocofsSaleoutEntity.setTocofsSaleoutDetailedEntityList(tocofsSaleoutDetailedEntityList1);
|
List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntities = stringListMap.get(tocofsSaleoutEntity.getId());
|
||||||
|
tocofsSaleoutEntity.setTocofsSaleoutDetailedEntityList(tocofsSaleoutDetailedEntities);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4107,6 +4110,15 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
|
||||||
return headerDetailsDtoList;
|
return headerDetailsDtoList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Map<String, List<TocofsSaleoutDetailedEntity>> convertToMap(List<TocofsSaleoutDetailedEntity> list) {
|
||||||
|
Map<String, List<TocofsSaleoutDetailedEntity>> map = new HashMap<>();
|
||||||
|
for (TocofsSaleoutDetailedEntity entity : list) {
|
||||||
|
String maintableid = entity.getMaintableid();
|
||||||
|
map.computeIfAbsent(maintableid, k -> new ArrayList<>()).add(entity);
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 过滤掉没有交易成功时间的明细行数据
|
* 过滤掉没有交易成功时间的明细行数据
|
||||||
*
|
*
|
||||||
|
|
|
@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||||
import com.hzya.frame.WebappApplication;
|
import com.hzya.frame.WebappApplication;
|
||||||
import com.hzya.frame.plugin.lets.constant.OverallConstant;
|
import com.hzya.frame.plugin.lets.constant.OverallConstant;
|
||||||
import com.hzya.frame.plugin.lets.dao.ISoSaleinvoiceDao;
|
import com.hzya.frame.plugin.lets.dao.ISoSaleinvoiceDao;
|
||||||
|
import com.hzya.frame.plugin.lets.entity.BdBusitypeEntity;
|
||||||
import com.hzya.frame.plugin.lets.entity.SoSaleinvoiceEntity;
|
import com.hzya.frame.plugin.lets.entity.SoSaleinvoiceEntity;
|
||||||
import com.hzya.frame.plugin.lets.ofs.dao.ITocofsSaleoutDetailedDao;
|
import com.hzya.frame.plugin.lets.ofs.dao.ITocofsSaleoutDetailedDao;
|
||||||
import com.hzya.frame.plugin.lets.ofs.entity.TocofsSaleoutDetailedEntity;
|
import com.hzya.frame.plugin.lets.ofs.entity.TocofsSaleoutDetailedEntity;
|
||||||
|
@ -15,6 +16,7 @@ import com.hzya.frame.plugin.lets.u8cdto.ErrorHeaderDetailsDtoDto;
|
||||||
import com.hzya.frame.plugin.lets.u8cdto.ReusltStrDto;
|
import com.hzya.frame.plugin.lets.u8cdto.ReusltStrDto;
|
||||||
import com.hzya.frame.plugin.lets.u8cdto.SoSaleResultRootDto;
|
import com.hzya.frame.plugin.lets.u8cdto.SoSaleResultRootDto;
|
||||||
import com.hzya.frame.plugin.lets.util.OfsStandardUtil;
|
import com.hzya.frame.plugin.lets.util.OfsStandardUtil;
|
||||||
|
import com.hzya.frame.plugin.lets.util.QueryBdBusitypeUtil;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -47,6 +49,9 @@ class SoSaleOutPluginInitializerToCTest {
|
||||||
@Autowired
|
@Autowired
|
||||||
private OfsStandardUtil ofsStandardUtil;
|
private OfsStandardUtil ofsStandardUtil;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private QueryBdBusitypeUtil queryBdBusitypeUtil;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void startImplement() throws Exception {
|
void startImplement() throws Exception {
|
||||||
// soSaleOutPluginInitializerToC.startImplement(null, null);
|
// soSaleOutPluginInitializerToC.startImplement(null, null);
|
||||||
|
@ -109,7 +114,7 @@ class SoSaleOutPluginInitializerToCTest {
|
||||||
// String code = "LETS-SH2024052100015139";
|
// String code = "LETS-SH2024052100015139";
|
||||||
// soSaleOutPluginInitializerToC.startImplementStockByCode(code, "tran");
|
// soSaleOutPluginInitializerToC.startImplementStockByCode(code, "tran");
|
||||||
|
|
||||||
// soSaleOutPluginInitializerToC.startImplementStockByTimeAndTran("2024-10-22 00:00:00", "2024-10-22 23:59:59");
|
soSaleOutPluginInitializerToC.startImplementStockByTime("2025-01-01 22:25:21", "2025-01-01 22:25:21","1");
|
||||||
|
|
||||||
// JSONObject jsonObject = new JSONObject();
|
// JSONObject jsonObject = new JSONObject();
|
||||||
// soSaleOutPluginInitializerToC.executeBusiness(jsonObject);
|
// soSaleOutPluginInitializerToC.executeBusiness(jsonObject);
|
||||||
|
@ -120,7 +125,7 @@ class SoSaleOutPluginInitializerToCTest {
|
||||||
// String aaa = "LETS-SH2024102800021196";
|
// String aaa = "LETS-SH2024102800021196";
|
||||||
// soSaleOutPluginInitializerToC.startImplementTranByTime("2025-01-04 15:48:02", "2025-01-04 15:48:02", "0");
|
// soSaleOutPluginInitializerToC.startImplementTranByTime("2025-01-04 15:48:02", "2025-01-04 15:48:02", "0");
|
||||||
|
|
||||||
soSaleOutPluginInitializerToC.startImplementTranByTime("2025-01-04 15:48:02", "2025-01-04 15:48:02", "2");
|
// soSaleOutPluginInitializerToC.startImplementTranByTime("2025-01-04 15:48:02", "2025-01-04 15:48:02", "2");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -132,6 +137,10 @@ class SoSaleOutPluginInitializerToCTest {
|
||||||
// soSaleOutPluginInitializerToC.startImplementStockByCode("LETS-SH2025011300024220", "tran");
|
// soSaleOutPluginInitializerToC.startImplementStockByCode("LETS-SH2025011300024220", "tran");
|
||||||
|
|
||||||
// soSaleOutPluginInitializerToC.startImplementStockByCode("LETS-SH2025012300026949", "tran");
|
// soSaleOutPluginInitializerToC.startImplementStockByCode("LETS-SH2025012300026949", "tran");
|
||||||
|
|
||||||
|
// String processName = "TOC确认收入";
|
||||||
|
// BdBusitypeEntity bdBusitypeEntity = queryBdBusitypeUtil.queryBdBusitype(processName);
|
||||||
|
// System.out.println(bdBusitypeEntity.getPkBusitype());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue