diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java index 027281c8..a5be783d 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java @@ -256,7 +256,7 @@ public class BomNewEbomParentService extends ServiceImpl waitList = bomNewEbomParentEntityList.stream().filter(item -> item.getStatus().equals(EBomStatusEnum.WAIT_CHECK.getValue())).collect(Collectors.toList()); // List revertList = bomNewEbomParentEntityList.stream().filter(item -> item.getStatus().equals(EBomStatusEnum.RETURNED.getValue())).collect(Collectors.toList()); - List pbomList = bomTreeList.stream().filter(item -> item.getStatus().equals(EBomStatusEnum.PUBLISHED.getValue())).collect(Collectors.toList()); + List pbomList = bomTreeList.stream().filter(item -> EBomStatusEnum.PUBLISHED.getValue().equals(item.getStatus())).collect(Collectors.toList()); // if (CollUtil.isNotEmpty(waitList)) { // List materialNoList = waitList.stream().map(BomNewEbomParentEntity::getMaterialNo).collect(Collectors.toList()); // @@ -776,7 +776,7 @@ public class BomNewEbomParentService extends ServiceImpl 0) { + if (CollectionUtil.isNotEmpty(pbomList) ) { List materialNoList = pbomList.stream().map(BomNewEbomParentVO::getMaterialNo).collect(Collectors.toList()); throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("物料编号 {} 状态为已发布PBOM,无法退回设计", StrUtil.join(",", materialNoList))); @@ -790,20 +790,44 @@ public class BomNewEbomParentService extends ServiceImpl updateList = new ArrayList<>(); - for (Long rowId : revertList) { - BomNewEbomParentEntity entity = new BomNewEbomParentEntity(); - entity.setRowId(rowId); - entity.setEditStatus(EBomStatusEnum.RETURNED.getValue()); - entity.setRevertTime(LocalDateTime.now()); - entity.setRevertUserName(dto.getRevertUserName()); - updateList.add(entity); + + if(CollectionUtil.isNotEmpty(revertList)) { + UpdateWrapper updateWrapper = new UpdateWrapper<>(); + updateWrapper.lambda() + .set(BomNewEbomParentEntity::getAuditTime, LocalDateTime.now()) + .set(BomNewEbomParentEntity::getAuditUserName, SessionUtil.getUserName()) + .set(BomNewEbomParentEntity::getStatus, EBomStatusEnum.RETURNED.getValue()) + .set(BomNewEbomParentEntity::getEditStatus, EbomEditStatusEnum.HANDLER_CREATED.getValue()) + .in(BomNewEbomParentEntity::getRowId, revertList); + + UpdateWrapper childWrapper = new UpdateWrapper<>(); + childWrapper.lambda() + .set(BomNewEbomChildEntity::getModifyTime, LocalDateTime.now()) + + .set(BomNewEbomChildEntity::getEditStatus, EbomEditStatusEnum.HANDLER_CREATED.getValue()) + .in(BomNewEbomChildEntity ::getParentRowId, revertList); + + if (!this.update(updateWrapper)) { + throw new NflgBusinessException(STATE.Error, "退回设计失败"); + } + ebomChildService.update(childWrapper); } - if (!this.updateBatchById(updateList)) { - throw new NflgBusinessException(STATE.Error, "退回设计失败"); - } + //重新创建保存list 避免污染 +// List updateList = new ArrayList<>(); +// for (Long rowId : revertList) { +// BomNewEbomParentEntity entity = new BomNewEbomParentEntity(); +// entity.setRowId(rowId); +// entity.setStatus(EBomStatusEnum.RETURNED.getValue()); +// entity.setEditStatus(EbomEditStatusEnum.HANDLER_CREATED.getValue()); +// entity.setRevertTime(LocalDateTime.now()); +// entity.setRevertUserName(dto.getRevertUserName()); +// updateList.add(entity); +// } +// +// if (!this.updateBatchById(updateList)) { +// throw new NflgBusinessException(STATE.Error, "退回设计失败"); +// } } @@ -865,19 +889,42 @@ public class BomNewEbomParentService extends ServiceImpl updateReviewList = new ArrayList<>(); - for (Long id : updateReviewIdList) { - BomNewEbomParentEntity entity = new BomNewEbomParentEntity(); - entity.setRowId(id); - entity.setAuditTime(LocalDateTime.now()); - entity.setAuditUserName(dto.getRevertUserName()); - entity.setStatus(EBomStatusEnum.CHECKED.getValue()); - updateReviewList.add(entity); - } + if(CollectionUtil.isNotEmpty(updateReviewIdList)){ + UpdateWrapper updateWrapper=new UpdateWrapper<>(); + updateWrapper.lambda() + .set(BomNewEbomParentEntity::getAuditTime,LocalDateTime.now()) + .set(BomNewEbomParentEntity::getAuditUserName,SessionUtil.getUserName()) + .set(BomNewEbomParentEntity::getStatus,EBomStatusEnum.CHECKED.getValue()) + .set(BomNewEbomParentEntity::getEditStatus,EbomEditStatusEnum.HANDLER_FINISHED.getValue()) + .in(BomNewEbomParentEntity::getRowId,updateReviewIdList); + + UpdateWrapper childWrapper = new UpdateWrapper<>(); + childWrapper.lambda() + .set(BomNewEbomChildEntity::getModifyTime, LocalDateTime.now()) + + .set(BomNewEbomChildEntity::getEditStatus, EbomEditStatusEnum.HANDLER_FINISHED.getValue()) + .in(BomNewEbomChildEntity ::getParentRowId, updateReviewIdList); + + if (! this.update(updateWrapper)) { + throw new NflgBusinessException(STATE.Error, "复核失败"); + } + ebomChildService.update(childWrapper); - if (!this.updateBatchById(updateReviewList)) { - throw new NflgBusinessException(STATE.Error, "复核失败"); } +// List updateReviewList = new ArrayList<>(); +// for (Long id : updateReviewIdList) { +// BomNewEbomParentEntity entity = new BomNewEbomParentEntity(); +// entity.setRowId(id); +// entity.setAuditTime(LocalDateTime.now()); +// entity.setAuditUserName(dto.getRevertUserName()); +// entity.setStatus(EBomStatusEnum.CHECKED.getValue()); +// entity.setEditStatus(EbomEditStatusEnum.HANDLER_FINISHED.getValue()); +// updateReviewList.add(entity); +// } +// +// if (!this.updateBatchById(updateReviewList)) { +// throw new NflgBusinessException(STATE.Error, "复核失败"); +// } return true; } @@ -1021,8 +1068,8 @@ public class BomNewEbomParentService extends ServiceImpl computeLevelNumAndRootState()); - computeLevelNumAndRootState(); + ThreadUtil.execAsync(() -> computeLevelNumAndRootState()); + // computeLevelNumAndRootState(); } return true;