1、组件拆单反同步材质数据调整;2、组件创建排单实际板材同步数据调整;

This commit is contained in:
gaoqr
2026-08-05 16:45:19 +08:00
parent aeae9d6511
commit 2092a45a87
9 changed files with 153 additions and 33 deletions
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.cf.imes.framework.mybatis.core.dataobject.BaseDO;
import lombok.AllArgsConstructor;
import lombok.Builder;
@@ -14,13 +15,14 @@ import lombok.NoArgsConstructor;
import lombok.ToString;
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)
@@ -50,6 +52,14 @@ public class GoodsDO extends BaseDO {
* 商品 ID
*/
private String goodsId;
/**
* 组件生产系统材料 ID 列表。
*
* <p>多个对方 {@code materials[type=1].id} 可以映射并复用同一条订单板材。</p>
*/
@TableField(value = "source_material_ids", typeHandler = JacksonTypeHandler.class)
private List<String> sourceMaterialIds;
/**
* 排单 ID
*/
@@ -137,4 +147,4 @@ public class GoodsDO extends BaseDO {
*/
@TableField(exist = false)
private boolean exist;
}
}
@@ -614,6 +614,20 @@ public class ProducingOrderImportFactory {
}
));
// selectMaps 的聚合结果不会应用 JSON 类型处理器,再按选中的 order_goods.id
// 加载已有来源材料数组,确保重复导入及多来源材料映射时只追加、不覆盖。
if (MapUtil.isNotEmpty(materialMap)) {
Map<Long, List<String>> sourceMaterialIdsByGoodsId = goodsMapper.selectBatchIds(
materialMap.values().stream().map(GoodsDO::getId).toList())
.stream()
.collect(Collectors.toMap(GoodsDO::getId,
goods -> goods.getSourceMaterialIds() == null
? new ArrayList<>()
: new ArrayList<>(goods.getSourceMaterialIds())));
materialMap.values().forEach(goods -> goods.setSourceMaterialIds(
sourceMaterialIdsByGoodsId.getOrDefault(goods.getId(), new ArrayList<>())));
}
for (ProducingImportMaterial materialReqVO : materialReqVOS) {
String plateGoodsGoodsId = materialReqVO.getGoodsId();
@@ -629,6 +643,7 @@ public class ProducingOrderImportFactory {
.orderId(orderId)
.rawGoodsId(String.valueOf(rawGoodsId))
.goodsId(plateGoodsGoodsId)
.sourceMaterialIds(new ArrayList<>())
.goodsName(materialReqVO.getName())
.material(materialReqVO.getMaterial())
.texture(materialReqVO.getTexture())
@@ -657,14 +672,36 @@ public class ProducingOrderImportFactory {
// 缓存goodCode和orderGoodsId的对应关系
materialMap.put(plateGoodsGoodsId, goodsDO);
}
if (StringUtils.isNotEmpty(plateGoodsGoodsId)) {
GoodsDO orderGoods = materialMap.get(plateGoodsGoodsId);
mergeSourceMaterialId(orderGoods, materialReqVO.getSourceMaterialId());
if (StringUtils.isNotEmpty(materialReqVO.getSourceMaterialId())) {
externalMaterialMap.putIfAbsent(
plateGoodsGoodsId,
materialReqVO.getSourceMaterialId(),
toExternalBlockMaterial(materialReqVO));
}
}
}
/**
* 将本次对方板材 ID 去重追加到订单板材的来源材料数组。
*
* @param orderGoods 本次生成或复用的订单板材
* @param sourceMaterialId 对方 {@code materials[type=1].id}
*/
private void mergeSourceMaterialId(GoodsDO orderGoods, String sourceMaterialId) {
if (orderGoods == null || StringUtils.isEmpty(sourceMaterialId)) {
return;
}
List<String> sourceMaterialIds = orderGoods.getSourceMaterialIds();
if (sourceMaterialIds == null) {
sourceMaterialIds = new ArrayList<>();
orderGoods.setSourceMaterialIds(sourceMaterialIds);
}
if (!sourceMaterialIds.contains(sourceMaterialId)) {
sourceMaterialIds.add(sourceMaterialId);
}
}
/**
* 缓存加工组类型
*
@@ -2257,7 +2294,7 @@ public class ProducingOrderImportFactory {
private ProducingExternalMaterial toExternalBlockMaterial(
ProducingImportMaterial material) {
return ProducingExternalMaterial.builder()
.id(material.getId())
.id(material.getGoodsId())
.type(1)
.name(material.getName())
.remark(getEmpty(material.getRemark()))
@@ -3125,6 +3162,8 @@ public class ProducingOrderImportFactory {
.eq(GoodsDO::getOrganId, organId)
.eq(GoodsDO::getVersion, updateDo.getVersion())
.set(GoodsDO::getPlateNum, updateDo.getPlateNum())
.setSql("source_material_ids = {0}",
JsonUtils.toJsonString(updateDo.getSourceMaterialIds()))
.set(GoodsDO::getVersion, updateDo.getVersion() + 1));
if (updated == 0) {
throw new ServiceException(ErrorCodeConstants.WEBCAD_ORDER_IMPORT_GOODS_UPDATE_CONCURRENCY_ERROR, updateDo.getId());
@@ -32,9 +32,10 @@ public class ProducingOrderExtraSyncRequest {
private Map<String, String> parts = new LinkedHashMap<>();
/**
* iMES 物料标识到板材库/配件物料对象的映射。板材(type=1)使用
* {@code order_goods.goods_id} 作为 key,配件和封边条(type=2/3)使用对方
* {@code materials.id} 作为 key。
* 对方 {@code materials.id} 到 iMES 板材库/配件物料对象的映射。
*
* <p>type=1 对象的 {@code id} 使用 iMES 板材库商品编号;type=2/3 对象的
* {@code id} 使用本次生成或复用的 iMES 配件 ID。</p>
*/
@Builder.Default
private Map<String, ProducingExternalMaterial> externalMaterialMapping =
@@ -29,9 +29,10 @@ public class ProducingOrderItemSerialNoUpdateRequest {
private Map<String, String> parts = new LinkedHashMap<>();
/**
* iMES 物料标识到板材库/配件物料对象的映射。板材(type=1)使用
* {@code order_goods.goods_id} 作为 key,配件和封边条(type=2/3)使用对方
* {@code materials.id} 作为 key。
* 对方 {@code materials.id} 到 iMES 板材库/配件物料对象的映射。
*
* <p>type=1 对象的 {@code id} 使用 iMES 板材库商品编号;type=2/3 对象的
* {@code id} 使用本次生成或复用的 iMES 配件 ID。</p>
*/
private Map<String, ProducingExternalMaterial> externalMaterialMapping =
new LinkedHashMap<>();