|
@@ -110,11 +110,14 @@ public class BomInfoServiceImpl extends ServiceImpl<BomInfoMapper, BomInfo> impl
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public BomInfoVo detail(Long id) {
|
|
|
- BomInfo BomInfo = this.getById(id);
|
|
|
- BomInfoVo result = BeanUtil.toBean(BomInfo, BomInfoVo.class);
|
|
|
-
|
|
|
- List<BomDetail> bomDetailList = bomDetailService.list(q -> q.eq(BomDetail::getBomInfoId, id));
|
|
|
+ public BomInfoVo detail(BomInfoDto dto) {
|
|
|
+ BomInfo bomInfo = this.getById(dto.getId());
|
|
|
+ BomInfoVo result = BeanUtil.toBean(bomInfo, BomInfoVo.class);
|
|
|
+
|
|
|
+ List<BomDetail> bomDetailList = bomDetailService.list(q -> q
|
|
|
+ .eq(BomDetail::getType, dto.getType())
|
|
|
+ .eq(BomDetail::getBomInfoId, dto.getId())
|
|
|
+ );
|
|
|
List<BomDetailVo> bomDetailVoList = BeanUtil.copyToList(bomDetailList, BomDetailVo.class);
|
|
|
|
|
|
productInfoService.attributeAssign(bomDetailVoList, BomDetailVo::getProductId, (item, productInfo) -> {
|
|
@@ -128,7 +131,7 @@ public class BomInfoServiceImpl extends ServiceImpl<BomInfoMapper, BomInfo> impl
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
+ @DSTransactional
|
|
|
@Override
|
|
|
public void add(BomInfoDto bomInfoDto) {
|
|
|
|
|
@@ -163,7 +166,10 @@ public class BomInfoServiceImpl extends ServiceImpl<BomInfoMapper, BomInfo> impl
|
|
|
public void edit(BomInfoDto bomInfoDto) {
|
|
|
Long bomInfoId = bomInfoDto.getId();
|
|
|
if (ObjectUtil.isEmpty(bomInfoId)) {
|
|
|
- throw new ServiceException("bomId不能为空");
|
|
|
+// throw new ServiceException("bomId不能为空");
|
|
|
+ //如果没传id就是新建
|
|
|
+ add(bomInfoDto);
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
bomInfoDto.setCurrentVersion(null);
|
|
@@ -173,21 +179,19 @@ public class BomInfoServiceImpl extends ServiceImpl<BomInfoMapper, BomInfo> impl
|
|
|
|
|
|
// 更新bom明细
|
|
|
List<BomDetail> bomDetailList = bomInfoDto.getBomDetailList();
|
|
|
- if (ObjectUtil.isNotEmpty(bomDetailList)) {
|
|
|
-
|
|
|
- List<Long> bomDetailIdList = bomDetailList.stream()
|
|
|
- .peek(item -> item.setBomInfoId(bomInfoId))
|
|
|
- .map(BaseIdPo::getId)
|
|
|
- .filter(Objects::nonNull)
|
|
|
- .collect(Collectors.toList());
|
|
|
|
|
|
- bomDetailService.remove(q -> q
|
|
|
- .eq(BomDetail::getBomInfoId, bomInfoId)
|
|
|
- .notIn(ObjectUtil.isNotEmpty(bomDetailIdList), BaseIdPo::getId, bomDetailIdList));
|
|
|
+ List<Long> bomDetailIdList = bomDetailList.stream()
|
|
|
+ .peek(item -> item.setBomInfoId(bomInfoId))
|
|
|
+ .map(BaseIdPo::getId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
|
- bomDetailService.saveOrUpdateBatch(bomDetailList);
|
|
|
- }
|
|
|
+ bomDetailService.remove(q -> q
|
|
|
+ .eq(BomDetail::getType, bomInfoDto.getType())
|
|
|
+ .eq(BomDetail::getBomInfoId, bomInfoId)
|
|
|
+ .notIn(ObjectUtil.isNotEmpty(bomDetailIdList), BaseIdPo::getId, bomDetailIdList));
|
|
|
|
|
|
+ bomDetailService.saveOrUpdateBatch(bomDetailList);
|
|
|
}
|
|
|
|
|
|
@Override
|