From 47eef9d27baef401b3cc686519a092fe4074ba89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E7=B1=B3?= <470431449@qq.com> Date: Sat, 25 Nov 2023 20:02:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=9F=E5=A7=8BBOM=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bomnew/api/user/OriginalBomApi.java | 18 +++-------- .../service/BomNewOriginalParentService.java | 32 ++++++++++++++++--- .../master/BomNewOriginalParentMapper.xml | 2 ++ 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/OriginalBomApi.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/OriginalBomApi.java index cff3876e..4d819818 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/OriginalBomApi.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/OriginalBomApi.java @@ -74,25 +74,17 @@ public class OriginalBomApi extends BaseApi { originalParentService.pullFromPlm(SessionUtil.getUserCode()); - //计算树的层级数 - CompletableFuture.runAsync(()->{ - try { - originalParentService.compucteLevelNum(); - originalParentService.getBaseMapper().updateRootState(); - } catch (ExecutionException e) { - throw new RuntimeException(e); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - }); + originalParentService.computeLevelNumAndRootState(); return ResultVO.success(true); } @GetMapping("del") @ApiOperation("删除BOM") - public ResultVO del(@RequestParam("parentRowId") Long parentRowId) throws ExecutionException, InterruptedException { - return ResultVO.success(originalParentService.del(parentRowId)); + public ResultVO del(@RequestParam("bomRowId") Long bomRowId) throws ExecutionException, InterruptedException { + originalParentService.del(bomRowId); + originalParentService.computeLevelNumAndRootState(); + return ResultVO.success(true); } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewOriginalParentService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewOriginalParentService.java index e9598a50..ca71131c 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewOriginalParentService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewOriginalParentService.java @@ -31,6 +31,8 @@ import java.sql.Struct; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Objects; +import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.concurrent.ForkJoinPool; import java.util.concurrent.ForkJoinTask; @@ -240,20 +242,40 @@ public class BomNewOriginalParentService extends ServiceImpl{ + try { + this.compucteLevelNum(); + this.getBaseMapper().updateRootState(); + } catch (ExecutionException e) { + throw new RuntimeException(e); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + }); + } + /** * 删除BOM * - * @param parentRowId + * @param bomRowId */ - public Boolean del(Long parentRowId) throws ExecutionException, InterruptedException { + public Boolean del(Long bomRowId) throws ExecutionException, InterruptedException { + + BomNewOriginalParentEntity parentEntity = this.getBaseMapper().selectById(bomRowId); + VUtils.isTure(Objects.isNull(parentEntity) ).throwMessage("该节点不存在,请检查参数是否正确"); + VUtils.isTure(!parentEntity.getCreatedBy().equals(SessionUtil.getUserCode())).throwMessage("该节点不属于你,你无权删除"); + List bomTree = getBomTree(bomRowId); - List bomTree = getBomTree(parentRowId); - List parentDel = new ArrayList<>(); List delParentRowId = bomTree.stream().filter(u -> u.getCreatedBy().equals(SessionUtil.getUserCode()) && OriginalStatusEnum.UN_CONVERT.equalsValue(u.getStatus())).map(u -> u.getParentRowId()).collect(Collectors.toList()); - + delParentRowId.add(bomRowId); if (CollUtil.isNotEmpty(delParentRowId)) { this.getBaseMapper().delBatch(delParentRowId); } diff --git a/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewOriginalParentMapper.xml b/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewOriginalParentMapper.xml index 1633b7ee..f2baa35a 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewOriginalParentMapper.xml +++ b/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewOriginalParentMapper.xml @@ -112,6 +112,8 @@ + + update t_bom_new_original_parent set root_is=0,user_root_is=0 where last_version_is=1; update t_bom_new_original_parent a join ( select a.row_id from t_bom_new_original_parent a left join t_bom_new_original_child b