Merge remote-tracking branch 'refs/remotes/惠信/dev_zhangke' into rakor

This commit is contained in:
曹鹏飞 2025-09-24 16:38:05 +08:00
commit eaa57a56f4
1 changed files with 40 additions and 34 deletions

View File

@ -58,13 +58,19 @@ public class BomControllerService {
@Transactional
public void add(@Valid BomMaterialDTO dto) {
VUtil.trueThrowBusinessError(StrUtil.isBlank(dto.getMaterialNo())).throwMessage("物料编号不能为空");
VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(dto.getChildren())).throwMessage("子级物料不可以为空!");
BigDecimal totalWight = dto.getChildren().stream()
.map(child -> child.getMaterialWeight() != null ? child.getMaterialWeight() : new BigDecimal(0))
.reduce(BigDecimal.ZERO, BigDecimal::add);
WmsBom parent = new WmsBom()
.setParentId(0L)
.setNo(dto.getMaterialNo())
.setDescribe(dto.getMaterialDesc())
.setDrawingNo(dto.getDrawingNo())
.setWeight(dto.getMaterialWeight())
.setNum(dto.getNum())
.setWeight(totalWight)
.setNum(new BigDecimal(1))
.setCreateBy(UserUtil.getUserName())
.setCreateTime(LocalDateTime.now());
bomService.add(parent, dto.getChildren().stream().map(it -> new WmsBom()