mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
1、组件拆单反同步材质数据调整;2、组件创建排单实际板材同步数据调整;
This commit is contained in:
+8
@@ -86,6 +86,14 @@ public class SavePlanPlateList {
|
||||
@Schema(description = "纹理")
|
||||
private Boolean texture;
|
||||
|
||||
/**
|
||||
* 组件生产系统来源材料 ID 列表。
|
||||
*
|
||||
* <p>创建排单时由后端根据 {@code order_goods.id}重新加载,不信任前端传值。</p>
|
||||
*/
|
||||
@Schema(description = "组件生产系统materials[type=1].id列表", accessMode = Schema.AccessMode.READ_ONLY)
|
||||
private List<String> sourceMaterialIds;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+7
-1
@@ -1,17 +1,19 @@
|
||||
package com.cf.imes.module.executor.dal.dataobject.goods;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||
import com.cf.imes.framework.mybatis.core.dataobject.BaseDO;
|
||||
import lombok.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 订单商品 DO
|
||||
*
|
||||
* @author 晨丰科技
|
||||
*/
|
||||
@TableName("order_goods")
|
||||
@TableName(value = "order_goods", autoResultMap = true)
|
||||
@KeySequence("order_goods_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@@ -41,6 +43,10 @@ public class GoodsDO extends BaseDO {
|
||||
* 商品 ID
|
||||
*/
|
||||
private String goodsId;
|
||||
|
||||
/** 组件生产系统 {@code materials[type=1].id} 列表。 */
|
||||
@TableField(value = "source_material_ids", typeHandler = JacksonTypeHandler.class)
|
||||
private List<String> sourceMaterialIds;
|
||||
/**
|
||||
* 排单 ID
|
||||
*/
|
||||
|
||||
+69
-16
@@ -192,16 +192,20 @@ public class PlanServiceImpl implements PlanService {
|
||||
|
||||
SavePlanPlateList savePlanPlateList = Optional.ofNullable(createReqVO.getSavePlanPlateList()).orElseThrow(()-> new ServiceException(PLAN_PLATE_DATA_ERROR));
|
||||
|
||||
List<SavePlanPlateList.PlateItemList> plateItemList = Optional.ofNullable(
|
||||
savePlanPlateList.getPlateItemList()).orElseThrow(
|
||||
() -> new ServiceException(PLAN_PLATE_DATA_ERROR));
|
||||
List<SavePlanPlateList.GoodsItemList> goodsItemList = Optional.ofNullable(
|
||||
savePlanPlateList.getGoodsItemList()).orElseThrow(
|
||||
() -> new ServiceException(PLAN_PLATE_DATA_ERROR));
|
||||
loadSourceMaterialIds(goodsItemList);
|
||||
|
||||
|
||||
if (savePlanPlateList.getMixConfig() != null && Boolean.TRUE.equals(savePlanPlateList.getMixConfig().getIsMixed())) {
|
||||
|
||||
// 混单时走的逻辑
|
||||
Integer mixedType = Optional.ofNullable(savePlanPlateList.getMixConfig().getMixedType()).orElse(MixConfigTypeEnum.SAMEMATERIALANDTHICKNESS.getType());
|
||||
|
||||
List<SavePlanPlateList.PlateItemList> plateItemList = Optional.ofNullable(savePlanPlateList.getPlateItemList()).orElseThrow(()-> new ServiceException(PLAN_PLATE_DATA_ERROR));
|
||||
|
||||
List<SavePlanPlateList.GoodsItemList> goodsItemList = Optional.ofNullable(savePlanPlateList.getGoodsItemList()).orElseThrow(()-> new ServiceException(PLAN_PLATE_DATA_ERROR));
|
||||
|
||||
List<PlanActualGoodsList> planActualGoodsLists = Optional.ofNullable(createReqVO.getPlanActualGoodsListList()).orElse(new ArrayList<>());
|
||||
|
||||
// 混单时判断是否进行板材对应并创建排单
|
||||
@@ -212,9 +216,6 @@ public class PlanServiceImpl implements PlanService {
|
||||
} else {
|
||||
|
||||
// 非混单
|
||||
List<SavePlanPlateList.PlateItemList> plateItemList = Optional.ofNullable(savePlanPlateList.getPlateItemList()).orElseThrow(()-> new ServiceException(PLAN_PLATE_DATA_ERROR));
|
||||
|
||||
List<SavePlanPlateList.GoodsItemList> goodsItemList = Optional.ofNullable(savePlanPlateList.getGoodsItemList()).orElseThrow(()-> new ServiceException(PLAN_PLATE_DATA_ERROR));
|
||||
// 查找材质和厚度和颜色相同的大板
|
||||
Map<String, List<Long>> grouped = groupByMaterialAndThicknessAndColorAndBrand(goodsItemList);
|
||||
|
||||
@@ -1673,7 +1674,7 @@ public class PlanServiceImpl implements PlanService {
|
||||
if(CollUtil.isNotEmpty(planActualGoodsLists)) {
|
||||
|
||||
// 有选实际大板的小板加大板创建排单
|
||||
getCreatePlanMultipleGoodsList(planActualGoodsLists, plateItemList, planDOS,
|
||||
getCreatePlanMultipleGoodsList(planActualGoodsLists, plateItemList, goodsItemList, planDOS,
|
||||
producingMaterialGroupByPlanId, processId, processName, loginUser);
|
||||
|
||||
|
||||
@@ -1758,6 +1759,7 @@ public class PlanServiceImpl implements PlanService {
|
||||
|
||||
private void getCreatePlanMultipleGoodsList(List<PlanActualGoodsList> planActualGoodsLists,
|
||||
List<SavePlanPlateList.PlateItemList> plateItemList,
|
||||
List<SavePlanPlateList.GoodsItemList> goodsItemList,
|
||||
List<PlanDO> planDOS,
|
||||
Map<Long, ProducingPlanOrderMaterialGroup> producingMaterialGroupByPlanId,
|
||||
Long processId,
|
||||
@@ -1822,7 +1824,8 @@ public class PlanServiceImpl implements PlanService {
|
||||
|
||||
planDOS.add(planDO);
|
||||
producingMaterialGroupByPlanId.put(planId,
|
||||
toProducingMaterialGroup(planId, f.getPlanActualGoodsModelDO()));
|
||||
toProducingMaterialGroup(planId, f.getPlanActualGoodsModelDO(),
|
||||
collectSourceMaterialIds(goodsItemList, f.getIds())));
|
||||
}
|
||||
// 统计更新order_goods的数量和面积
|
||||
computePlatePlanAndComputeOrderGoodsInfo(allGoodsIds);
|
||||
@@ -1902,7 +1905,8 @@ public class PlanServiceImpl implements PlanService {
|
||||
.filter(goods -> value.contains(goods.getId()))
|
||||
.findFirst()
|
||||
.ifPresent(goods -> producingMaterialGroupByPlanId.put(planId,
|
||||
toProducingMaterialGroup(planId, goods)));
|
||||
toProducingMaterialGroup(planId, goods,
|
||||
collectSourceMaterialIds(goodsItemList, value))));
|
||||
}
|
||||
// 统计更新order_goods的数量和面积
|
||||
computePlatePlanAndComputeOrderGoodsInfo(allGoodsIds);
|
||||
@@ -2057,15 +2061,16 @@ public class PlanServiceImpl implements PlanService {
|
||||
* 根据普通排单使用的材质属性构建组件生产系统自定义材质分组。
|
||||
*/
|
||||
private ProducingPlanOrderMaterialGroup toProducingMaterialGroup(
|
||||
Long planId, SavePlanPlateList.GoodsItemList goods) {
|
||||
Long planId, SavePlanPlateList.GoodsItemList goods,
|
||||
List<String> sourceMaterialIds) {
|
||||
return ProducingPlanOrderMaterialGroup.builder()
|
||||
.id(goods.getGoodsId())
|
||||
.name(buildProducingMaterialGroupName(
|
||||
planId, null, goods.getMaterial(), goods.getColor(), goods.getThickness()))
|
||||
.type(1)
|
||||
.type(4)
|
||||
.thickness(goods.getThickness())
|
||||
.hasWave(goods.getTexture())
|
||||
.materialIds(Collections.emptyList())
|
||||
.materialIds(sourceMaterialIds)
|
||||
.brand(goods.getBrand())
|
||||
.material(goods.getMaterial())
|
||||
.color(goods.getColor())
|
||||
@@ -2076,21 +2081,69 @@ public class PlanServiceImpl implements PlanService {
|
||||
* 根据混单选择的实际大板属性构建组件生产系统自定义材质分组。
|
||||
*/
|
||||
private ProducingPlanOrderMaterialGroup toProducingMaterialGroup(
|
||||
Long planId, PlanActualGoodsModelDO goods) {
|
||||
Long planId, PlanActualGoodsModelDO goods,
|
||||
List<String> sourceMaterialIds) {
|
||||
return ProducingPlanOrderMaterialGroup.builder()
|
||||
.id(goods.getGoodsId())
|
||||
.name(buildProducingMaterialGroupName(
|
||||
planId, goods.getGoodsName(), goods.getMaterial(),
|
||||
goods.getColor(), goods.getThickness()))
|
||||
.type(1)
|
||||
.type(4)
|
||||
.thickness(goods.getThickness())
|
||||
.materialIds(Collections.emptyList())
|
||||
.materialIds(sourceMaterialIds)
|
||||
.brand(goods.getBrand())
|
||||
.material(goods.getMaterial())
|
||||
.color(goods.getColor())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据本次排单提交的订单商品 ID 一次性加载来源材料数组。
|
||||
*
|
||||
* <p>来源材料关系以数据库为准,避免前端遗漏或伪造对方材料 ID。</p>
|
||||
*/
|
||||
private void loadSourceMaterialIds(List<SavePlanPlateList.GoodsItemList> goodsItems) {
|
||||
if (CollUtil.isEmpty(goodsItems)) {
|
||||
return;
|
||||
}
|
||||
List<Long> goodsIds = goodsItems.stream()
|
||||
.map(SavePlanPlateList.GoodsItemList::getId)
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.toList();
|
||||
if (CollUtil.isEmpty(goodsIds)) {
|
||||
return;
|
||||
}
|
||||
Map<Long, List<String>> sourceMaterialIdsByGoodsId = goodsMapper.selectBatchIds(goodsIds)
|
||||
.stream()
|
||||
.collect(Collectors.toMap(GoodsDO::getId,
|
||||
goods -> Optional.ofNullable(goods.getSourceMaterialIds())
|
||||
.orElseGet(Collections::emptyList)));
|
||||
goodsItems.forEach(goods -> goods.setSourceMaterialIds(
|
||||
new ArrayList<>(sourceMaterialIdsByGoodsId.getOrDefault(
|
||||
goods.getId(), Collections.emptyList()))));
|
||||
}
|
||||
|
||||
/**
|
||||
* 汇总一个排单材质组内所有订单板材的对方材料 ID,并保持首次出现顺序。
|
||||
*/
|
||||
private List<String> collectSourceMaterialIds(
|
||||
List<SavePlanPlateList.GoodsItemList> goodsItems,
|
||||
Collection<Long> selectedGoodsIds) {
|
||||
if (CollUtil.isEmpty(goodsItems) || CollUtil.isEmpty(selectedGoodsIds)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
Set<Long> selected = new HashSet<>(selectedGoodsIds);
|
||||
return goodsItems.stream()
|
||||
.filter(goods -> selected.contains(goods.getId()))
|
||||
.map(SavePlanPlateList.GoodsItemList::getSourceMaterialIds)
|
||||
.filter(CollUtil::isNotEmpty)
|
||||
.flatMap(Collection::stream)
|
||||
.filter(StringUtils::isNotBlank)
|
||||
.distinct()
|
||||
.toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成对方接口必填的材质分组名称。
|
||||
*/
|
||||
|
||||
+2
-2
@@ -25,7 +25,7 @@ public class ProducingPlanOrderMaterialGroup {
|
||||
/** 物料名称。 */
|
||||
private String name;
|
||||
|
||||
/** 物料类型,1 表示板材。 */
|
||||
/** 自定义材质分组类型,组件生产排单固定传4。 */
|
||||
private Integer type;
|
||||
|
||||
/** 板材宽度。 */
|
||||
@@ -40,7 +40,7 @@ public class ProducingPlanOrderMaterialGroup {
|
||||
/** 是否有纹路。 */
|
||||
private Boolean hasWave;
|
||||
|
||||
/** 分组下的物料 ID 列表,当前按接口约定暂不填充。 */
|
||||
/** 分组所包含的对方 {@code materials[type=1].id} 去重列表。 */
|
||||
private List<String> materialIds;
|
||||
|
||||
/** 备注。 */
|
||||
|
||||
+5
-3
@@ -47,10 +47,10 @@ class ProducingPlanOrderClientTest {
|
||||
ProducingPlanOrderMaterialGroup.builder()
|
||||
.id("goods-1")
|
||||
.name("颗粒板-白色-18")
|
||||
.type(1)
|
||||
.type(4)
|
||||
.thickness(new java.math.BigDecimal("18"))
|
||||
.hasWave(true)
|
||||
.materialIds(List.of())
|
||||
.materialIds(List.of("source-material-2366", "source-material-2367"))
|
||||
.brand("测试品牌")
|
||||
.material("颗粒板")
|
||||
.color("白色")
|
||||
@@ -82,8 +82,10 @@ class ProducingPlanOrderClientTest {
|
||||
JsonNode materialBody = createBody.get("customMaterialGroupList").get(0);
|
||||
assertThat(materialBody.get("id").textValue()).isEqualTo("goods-1");
|
||||
assertThat(materialBody.get("name").textValue()).isEqualTo("颗粒板-白色-18");
|
||||
assertThat(materialBody.get("type").intValue()).isEqualTo(4);
|
||||
assertThat(materialBody.get("materialIds").isArray()).isTrue();
|
||||
assertThat(materialBody.get("materialIds").isEmpty()).isTrue();
|
||||
assertThat(materialBody.get("materialIds").toString())
|
||||
.isEqualTo("[\"source-material-2366\",\"source-material-2367\"]");
|
||||
assertThat(materialBody.get("material").textValue()).isEqualTo("颗粒板");
|
||||
assertThat(objectMapper.readTree(requests.get(1).body())
|
||||
.get("appendBlockIds").get(0).textValue()).isEqualTo("source-3");
|
||||
|
||||
Reference in New Issue
Block a user