fix(ebom): 调整删除规则,导入的数据可以删除;但是31码下的虚拟包不能删除

This commit is contained in:
曹鹏飞 2024-05-26 17:23:49 +08:00
parent 30ca4cb0b4
commit 02c7ec9ac3
2 changed files with 17 additions and 14 deletions

View File

@ -377,7 +377,7 @@ public class EbomApi extends BaseApi {
public ResultVO<BomNewEbomParentVO> temporary(@RequestBody BomNewEBomParentEditDTO dto) throws ExecutionException, InterruptedException {
checkDeleteRule(dto);
bomNewEbomParentService.deleteBomChild(dto.getDelDatas());
bomNewEbomParentService.deleteBomChild(dto.getDelDatas(), dto.getParent());
BomNewEbomParentVO temporary = bomNewEbomParentService.temporary(dto);
return ResultVO.success(temporary);
@ -388,7 +388,7 @@ public class EbomApi extends BaseApi {
@LogRecord(success = "Ebom-暂存添加,物料编码:{{#dto.parent.materialNo}}-版本:{{#dto.parent.currentVersion}},操作结果:{{#_ret.state}} {{#_ret.msg}}", bizNo = "{{#dto.parent.rowId}}", type = "Ebom-暂存添加")
public ResultVO<BomNewEbomParentVO> temporaryAdd(@RequestBody BomNewEBomParentEditDTO dto) throws ExecutionException, InterruptedException {
checkDeleteRule(dto);
bomNewEbomParentService.deleteBomChild(dto.getDelDatas());
bomNewEbomParentService.deleteBomChild(dto.getDelDatas(), dto.getParent());
BomNewEbomParentVO temporary = bomNewEbomParentService.temporary(dto);
// bomNewEbomParentService.getBaseMapper().updateRootForWaitReview();
return ResultVO.success(temporary);
@ -399,7 +399,7 @@ public class EbomApi extends BaseApi {
@LogRecord(success = "Ebom-提交添加,物料编码:{{#dto.parent.materialNo}}-版本:{{#dto.parent.currentVersion}},操作结果:{{#_ret.state}} {{#_ret.msg}}", bizNo = "{{#dto.parent.rowId}}", type = "Ebom-提交添加")
public ResultVO<Boolean> submitAdd(@RequestBody BomNewEBomParentEditDTO dto) throws ExecutionException, InterruptedException {
checkDeleteRule(dto);
bomNewEbomParentService.deleteBomChild(dto.getDelDatas());
bomNewEbomParentService.deleteBomChild(dto.getDelDatas(), dto.getParent());
return ResultVO.success(bomNewEbomParentService.submit(dto));
}
@ -409,7 +409,7 @@ public class EbomApi extends BaseApi {
@LogRecord(success = "Ebom-提交,物料编码:{{#dto.parent.materialNo}}-版本:{{#dto.parent.currentVersion}},操作结果:{{#_ret.state}} {{#_ret.msg}}", bizNo = "{{#dto.parent.rowId}}", type = "Ebom-提交")
public ResultVO<Boolean> submit(@RequestBody BomNewEBomParentEditDTO dto) throws ExecutionException, InterruptedException {
checkDeleteRule(dto);
bomNewEbomParentService.deleteBomChild(dto.getDelDatas());
bomNewEbomParentService.deleteBomChild(dto.getDelDatas(), dto.getParent());
return ResultVO.success(bomNewEbomParentService.submit(dto));
}
@ -464,7 +464,7 @@ public class EbomApi extends BaseApi {
*/
@PostMapping("queryMaterials")
@ApiOperation("批量查询物料信息")
public ResultVO<List<BaseMaterialVO>> queryMaterials(@Valid @RequestBody @NotEmpty List<QueryMaterialsQuery> query) {
public ResultVO<List<QueryMaterialsVO>> queryMaterials(@Valid @RequestBody @NotEmpty List<QueryMaterialsQuery> query) {
return ResultVO.success(bomNewEbomParentService.queryMaterials(query));
}

View File

@ -1980,7 +1980,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
* 从原始Bom导入的数据数据没有异常的情况下用户不可以删除
* 用户可以直接删除用户单击暂存或是提交时才会保存至数据库
*/
public void deleteBomChild(List<BomNewEbomParentVO> delList) {
public void deleteBomChild(List<BomNewEbomParentVO> delList, BomNewEbomParentVO parent) {
if (CollUtil.isEmpty(delList)) {
return;
}
@ -1993,12 +1993,15 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
List<BomNewEbomChildEntity> delTagList = new ArrayList<>();
//检查原始bom里过来数据是否包含正常数据
List<BomNewEbomChildEntity> check1List = delChildList.stream().filter(u -> Objects.equals(EBomSourceEnum.FROM_BOM.getValue(), u.getSource())
&& Objects.equals(u.getExceptionStatus(), EBomExceptionStatusEnum.OK.getValue())).collect(Collectors.toList());
if (CollUtil.isNotEmpty(check1List)) {
throw new NflgBusinessException(STATE.Error, StrUtil.format("从原始Bom导入的数据数据没有异常的情况下{} 不可以删除 ", StrUtil.join(",", check1List.stream().map(BomNewEbomChildEntity::getMaterialNo).collect(Collectors.toList()))));
}
// List<BomNewEbomChildEntity> check1List = delChildList.stream().filter(u -> Objects.equals(EBomSourceEnum.FROM_BOM.getValue(), u.getSource())
// && Objects.equals(u.getExceptionStatus(), EBomExceptionStatusEnum.OK.getValue())).collect(Collectors.toList());
//
// if (CollUtil.isNotEmpty(check1List)) {
// throw new NflgBusinessException(STATE.Error, StrUtil.format("从原始Bom导入的数据数据没有异常的情况下{} 不可以删除 ", StrUtil.join(",", check1List.stream().map(BomNewEbomChildEntity::getMaterialNo).collect(Collectors.toList()))));
// }
VUtils.isTure(parent.getMaterialNo().startsWith("31")
&& delChildList.stream().anyMatch(d -> !Objects.equals(d.getVirtualPartType(), VirtualPackageTypeEnum.UN_VIRTUAL_PACKAGE.getValue())))
.throwMessage("不能删除31码下的虚拟包");
//检查有bom数据关系是否可以删
// List<BomNewEbomParentVO> check2List = delList.stream().filter(u -> Objects.equals(EBomSourceEnum.FROM_BOM.getValue(), u.getSource())
@ -2364,7 +2367,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
return null;
}
public List<BaseMaterialVO> queryMaterials(List<QueryMaterialsQuery> query) {
public List<QueryMaterialsVO> queryMaterials(List<QueryMaterialsQuery> query) {
List<BaseMaterialVO> datas = new ArrayList<>();
List<String> keys = query.stream().map(QueryMaterialsQuery::getMaterialNo)
.filter(StrUtil::isNotBlank)
@ -2381,7 +2384,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
if (CollUtil.isNotEmpty(keys)) {
datas.addAll(SpringUtil.getBean(MaterialMainMapper.class).getMaterialByDrawingNo(keys));
}
return datas;
return Convert.toList(QueryMaterialsVO.class, datas);
}
public Integer getSapErrorNum() {