混单创建排单逻辑修复

This commit is contained in:
gaoqr
2026-06-10 11:09:18 +08:00
parent e27d47f3b2
commit 1fbb66e9a2
@@ -1479,43 +1479,6 @@ public class PlanServiceImpl implements PlanService {
computeOrderInfo(orderIds);
}
public static Map<String, List<Long>> groupByMaterialAndThickness(List<SavePlanPlateList.GoodsItemList> items) {
Map<String, List<Long>> groupedItems = new HashMap<>();
for (SavePlanPlateList.GoodsItemList item : items) {
// 将 material 和 thickness 组合成键
String key = item.getMaterial() + "|" + item.getThickness();
// 如果键不存在,初始化一个新的列表
groupedItems.putIfAbsent(key, new ArrayList<>());
// 添加当前项的 id 到对应的分组
groupedItems.get(key).add(item.getId());
}
return groupedItems;
}
public static Map<String, List<Long>> groupByThickness(List<SavePlanPlateList.GoodsItemList> items) {
Map<String, List<Long>> groupedItems = new HashMap<>();
for (SavePlanPlateList.GoodsItemList item : items) {
// 将 material 和 thickness 组合成键
String key = item.getThickness().toString();
// 如果键不存在,初始化一个新的列表
groupedItems.putIfAbsent(key, new ArrayList<>());
// 添加当前项的 id 到对应的分组
groupedItems.get(key).add(item.getId());
}
return groupedItems;
}
public static Map<String, List<Long>> groupByMaterialAndThicknessFilterLessThanOne(List<SavePlanPlateList.GoodsItemList> items) {
Map<String, List<Long>> groupedItems = new HashMap<>();
@@ -1559,35 +1522,18 @@ public class PlanServiceImpl implements PlanService {
}
public static Map<String, List<Long>> groupByMaterialAndThicknessEqualToOne(List<SavePlanPlateList.GoodsItemList> items) {
/**
* 混单情况下不用混单的材质按goodsCode商品编码分组
*
* @param items
* @return
*/
public static Map<String, List<Long>> groupByGoodsCodeEqualToOne(List<SavePlanPlateList.GoodsItemList> items) {
Map<String, List<Long>> groupedItems = new HashMap<>();
for (SavePlanPlateList.GoodsItemList item : items) {
// 将 material 和 thickness 组合成键
// String key = item.getMaterial() + "|" + item.getThickness();
// 如果键不存在,初始化一个新的列表
groupedItems.putIfAbsent(item.getId().toString(), new ArrayList<>() {{
add(item.getId());
}});
// 添加当前项的 id 到对应的分组
// groupedItems.get(key).add(item.getId());
}
// 只留混单的材质
// groupedItems.entrySet().removeIf(entry -> entry.getValue().size() > 1);
return groupedItems;
}
public static Map<String, List<Long>> groupByThicknessEqualToOne(List<SavePlanPlateList.GoodsItemList> items) {
Map<String, List<Long>> groupedItems = new HashMap<>();
for (SavePlanPlateList.GoodsItemList item : items) {
// 将 material 和 thickness 组合成键
String key = item.getThickness().toString();
String key = item.getGoodsId();
// 如果键不存在,初始化一个新的列表
groupedItems.putIfAbsent(key, new ArrayList<>());
@@ -1596,15 +1542,9 @@ public class PlanServiceImpl implements PlanService {
groupedItems.get(key).add(item.getId());
}
// 只留混单的材质
groupedItems.entrySet().removeIf(entry -> entry.getValue().size() > 1);
return groupedItems;
}
public static Map<String, List<Long>> groupByMaterialAndThicknessAndColorAndBrand(List<SavePlanPlateList.GoodsItemList> items) {
Map<String, List<Long>> groupedItems = new HashMap<>();
@@ -1643,37 +1583,23 @@ public class PlanServiceImpl implements PlanService {
// 有选实际大板的小板加大板创建排单
getCreatePlanMultipleGoodsList(planActualGoodsLists, plateItemList, planDOS, processId, processName, loginUser);
// 没有选择实际大板的创建排单
if(MixConfigTypeEnum.SAMEMATERIALANDTHICKNESS.equals(mixedType)){
// 筛选出材质和厚度相同的大板
grouped = groupByMaterialAndThicknessEqualToOne(goodsItemList);
}else {
// 不用混单的材质按goodsCode商品编码分组
grouped = groupByGoodsCodeEqualToOne(goodsItemList);
grouped = groupByThicknessEqualToOne(goodsItemList);
}
if(CollUtil.isNotEmpty(grouped)) {
if (CollUtil.isNotEmpty(grouped)) {
createPlanAndPlateDataList(grouped, plateItemList, planDOS, processId, processName, loginUser, PlanTypeEnum.ORDERPLAN.getType());
}
}else {
if(MixConfigTypeEnum.SAMEMATERIALANDTHICKNESS.equals(mixedType)){
// 筛选出材质和厚度相同的大板
grouped = groupByMaterialAndThickness(goodsItemList);
}else {
// 筛选出厚度相同的大板
grouped = groupByThickness(goodsItemList);
} else {
// 不用混单的材质按goodsCode商品编码分组
grouped = groupByGoodsCodeEqualToOne(goodsItemList);
if (CollUtil.isNotEmpty(grouped)) {
createPlanAndPlateDataList(grouped, plateItemList, planDOS, processId, processName, loginUser, PlanTypeEnum.ORDERPLAN.getType());
}
createPlanAndPlateDataList(grouped, plateItemList, planDOS, processId, processName, loginUser, PlanTypeEnum.ORDERPLAN.getType());
}
planDOS.forEach(f->f.setFilter(f.getType().equals(PlanTypeEnum.MIXEDORDERPLAN.getType()) ? mixedType : 0));