From 7845437d5b80f01c725319b6930852765b74bc86 Mon Sep 17 00:00:00 2001 From: jing's Date: Mon, 25 Mar 2024 18:27:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=93=8D=E4=BD=9C=E6=9D=83=E9=99=90=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nflg/product/bomnew/api/user/EbomApi.java | 9 +- .../product/bomnew/constant/EBomConstant.java | 19 ++ .../bomnew/pojo/dto/BomNewEbomImportDTO.java | 5 +- .../service/BomNewEbomParentService.java | 249 ++++++++++-------- .../domain/EBom/CheckEBomException.java | 2 +- .../bomnew/service/domain/EBom/EBomDel.java | 11 +- .../bomnew/service/domain/EBom/EBomEdit.java | 41 ++- 7 files changed, 213 insertions(+), 123 deletions(-) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java index 42995f0f..f43d8f93 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java @@ -231,8 +231,8 @@ public class EbomApi extends BaseApi { return ResultVO.error("清除原数据或追加行数据错误"); } - bomNewEbomParentService.createBomImport(dto,file.getInputStream()); - return ResultVO.success(true); + return bomNewEbomParentService.createBomImport(dto,file.getInputStream()); + } // @PostMapping("createBom") @@ -355,6 +355,9 @@ public class EbomApi extends BaseApi { @ApiOperation("暂存") @LogRecord(success = "Ebom-暂存,物料编码:{{#dto.parent.materialNo}}-版本:{{#dto.parent.currentVersion}},操作结果:{{#_ret}}", bizNo = "{{#dto.parent.rowId}}",type = "Ebom-暂存") public ResultVO temporary(@RequestBody BomNewEBomParentEditDTO dto) throws ExecutionException, InterruptedException { + + + bomNewEbomParentService.deleteBomChild(dto.getDelDatas()); return ResultVO.success(bomNewEbomParentService.temporary(dto)); } @@ -377,7 +380,7 @@ public class EbomApi extends BaseApi { @ApiOperation("提交") @LogRecord(success = "Ebom-提交,物料编码:{{#dto.parent.materialNo}}-版本:{{#dto.parent.currentVersion}},操作结果:{{#_ret}}", bizNo = "{{#dto.parent.rowId}}",type = "Ebom-提交") public ResultVO submit(@RequestBody BomNewEBomParentEditDTO dto) throws ExecutionException, InterruptedException { - + bomNewEbomParentService.deleteBomChild(dto.getDelDatas()); return ResultVO.success(bomNewEbomParentService.submit(dto)); } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/EBomConstant.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/EBomConstant.java index 1c1f28fc..3a28f62f 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/EBomConstant.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/EBomConstant.java @@ -1,5 +1,8 @@ package com.nflg.product.bomnew.constant; +import lombok.AllArgsConstructor; +import lombok.Getter; + /** * @author 大米 * @date 2023/11/11 20:09 @@ -24,4 +27,20 @@ public class EBomConstant { public static final String XIAN_TAO_FACTORY_CODE_1020="1020"; public static final String XIAN_TAO_FACTORY_Name_1020="仙桃"; + + + @AllArgsConstructor + @Getter + public enum EBomExcelImportEnum implements ValueEnum { + + // 1- 删除 2-追加 + IMPORT_TYPE_DEL(1, "删除"), + IMPORT_TYPE_APPEND(2, "追加"); + + private final Integer value; + private final String description; + } + + + } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/dto/BomNewEbomImportDTO.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/dto/BomNewEbomImportDTO.java index 53f30874..49c3dc71 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/dto/BomNewEbomImportDTO.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/dto/BomNewEbomImportDTO.java @@ -1,5 +1,6 @@ package com.nflg.product.bomnew.pojo.dto; +import com.nflg.product.bomnew.constant.EBomConstant; import com.nflg.product.bomnew.constant.EBomSourceEnum; import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO; import io.swagger.annotations.ApiModelProperty; @@ -29,7 +30,7 @@ public class BomNewEbomImportDTO { public boolean isDel(){ if (Objects.nonNull(opType)){ - if(opType==1){ + if(opType.equals(EBomConstant.EBomExcelImportEnum.IMPORT_TYPE_DEL.getValue())){ return true; } } @@ -37,7 +38,7 @@ public class BomNewEbomImportDTO { } public boolean isAppend(){ if (Objects.nonNull(opType)){ - if(opType==2){ + if(opType.equals(EBomConstant.EBomExcelImportEnum.IMPORT_TYPE_APPEND.getValue())){ return true; } } 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 52d7e5d4..e84f49a6 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 @@ -8,6 +8,7 @@ import cn.hutool.core.lang.TypeReference; import cn.hutool.core.thread.ThreadUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.extra.spring.SpringUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -32,6 +33,7 @@ import com.nflg.product.bomnew.service.domain.EBom.*; import com.nflg.product.bomnew.util.*; import lombok.extern.slf4j.Slf4j; import nflg.product.common.constant.STATE; +import nflg.product.common.vo.ResultVO; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Service; @@ -915,7 +917,7 @@ public class BomNewEbomParentService extends ServiceImpl createBomImport(BomNewEbomImportDTO dto, InputStream inputStream) throws IOException, ExecutionException, InterruptedException { List result = EecExcelUtil.getExcelContext(inputStream, BomNewEBomImportExcelDTO.class); @@ -941,6 +943,12 @@ public class BomNewEbomParentService extends ServiceImpl delWrapper=new QueryWrapper<>(); + delWrapper.lambda().eq(BomNewEbomChildEntity::getParentRowId,dto.getRowId()); + SpringUtil.getBean(BomNewEbomChildService.class).getBaseMapper().delete(delWrapper); + } } else { //最后一个序列号 @@ -994,13 +1007,35 @@ public class BomNewEbomParentService extends ServiceImpl sameList=null; if (CollectionUtil.isNotEmpty(eBomEdit.childEntities)) { + + QueryWrapper queryWrapper=new QueryWrapper<>(); + queryWrapper.lambda().eq(BomNewEbomChildEntity::getParentRowId,dto.getRowId()); + List oldChildList= SpringUtil.getBean(BomNewEbomChildService.class).list(queryWrapper); + ebomChildService.saveOrUpdateBatch(eBomEdit.childEntities); + + if(CollUtil.isNotEmpty(oldChildList)) { + //追加里包含相同 + List appendList = eBomEdit.childEntities.stream().map(BomNewEbomChildEntity::getMaterialNo).collect(Collectors.toList()); + List oldList = oldChildList.stream().map(BomNewEbomChildEntity::getMaterialNo).collect(Collectors.toList()); + sameList = appendList.stream() + .filter(oldList::contains) + .collect(Collectors.toList()); + + } + } //不要异步 computeLevelNumAndRootState(); -// ThreadUtil.execAsync(() -> computeLevelNumAndRootState()); + if(CollUtil.isEmpty(sameList)){ + return ResultVO.success(); + }else{ + return ResultVO.error(StrUtil.format("包含相同物料 {}",StrUtil.join(",",sameList))); + } } @@ -1068,31 +1103,23 @@ public class BomNewEbomParentService extends ServiceImpl rowIds = dto.getRowIdList(); - - - // List bomNewEbomParentEntityList = this.getBaseMapper().selectBatchIds(rowIds); - - List bomNewEbomParentEntityList = this.lambdaQuery().in(BomNewEbomParentEntity::getRowId, rowIds).eq(BomNewEbomParentEntity::getRootIs, 1).list(); - if (CollUtil.isEmpty(bomNewEbomParentEntityList)) { - // throw new NflgBusinessException(STATE.BusinessError, "下级BOM无法进行退回"); - VUtils.isTure(true).throwMessage("下级BOM无法进行退回"); + VUtils.isTure(true).throwMessage("下级BOM无法进行退回,请选择顶层"); } Set materialNoAndVersion = bomNewEbomParentEntityList.stream().map(u -> StrUtil.join("-", u.getMaterialNo(), u.getCurrentVersion())).collect(Collectors.toSet()); LogRecordContext.putVariable("log", materialNoAndVersion); if (rowIds.size() != bomNewEbomParentEntityList.size()) { - - VUtils.isTure(true).throwMessage("选择数据中包含有下级BOM无法进行退回"); } @@ -1100,40 +1127,25 @@ public class BomNewEbomParentService extends ServiceImpl revertList = new ArrayList<>(); for (Long bomRowId : rowIds) { - List bomTreeList = buildBomTreeContainSelf(bomRowId); -// -// -// -// List 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 -> EBomStatusEnum.PUBLISHED.getValue().equals(item.getStatus())).collect(Collectors.toList()); -// if (CollUtil.isNotEmpty(waitList)) { -// List materialNoList = waitList.stream().map(BomNewEbomParentEntity::getMaterialNo).collect(Collectors.toList()); -// -// throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("物料编号 {} 状态为待复核,无法退回设计", StrUtil.join(",", materialNoList))); -// } -// if (CollUtil.isNotEmpty(revertList)) { -// List materialNoList = revertList.stream().map(BomNewEbomParentEntity::getMaterialNo).collect(Collectors.toList()); -// -// throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("物料编号 {} 状态为已退回,不需要退回设计", StrUtil.join(",", materialNoList))); -// } + 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))); } - //忽略叶子节点 和 工艺人员 + //忽略叶子节点 和 工艺人员 revertList.addAll(bomTreeList.stream() .filter(u -> u.getBomRowId() > 0 && !Objects.equals(UserJobEnum.ENGINEER.getValue(),u.getCreatedJob())) .map(BomNewEbomParentVO::getBomRowId).collect(Collectors.toList())); - } if (CollectionUtil.isNotEmpty(revertList)) { + //parent表状态 UpdateWrapper updateWrapper = new UpdateWrapper<>(); updateWrapper.lambda() .set(BomNewEbomParentEntity::getRevertTime, LocalDateTime.now()) @@ -1142,41 +1154,31 @@ public class BomNewEbomParentService extends ServiceImpl 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)) { + this.update(updateWrapper ); + if (!ebomChildService.update(childWrapper)) { throw new NflgBusinessException(STATE.Error, "退回设计失败"); } - ebomChildService.update(childWrapper); + + } else { VUtils.isTure(true).throwMessage("没有需要退回设计的物料"); } - //重新创建保存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, "退回设计失败"); -// } + } /** * 设计复核 + *设计人员只可以复核自己的物料,如果存在引用其他用户创建的物料时,不可以改变被引用物料的审核状态。 + * 异常检查: * 1. 是否存在空物料编号、空数量的数据信息; * 2. 是否存在在主数据平台的物料信息没有的数据; * 3. 同一层级是否存在相同的物料编码数据; @@ -1184,7 +1186,7 @@ public class BomNewEbomParentService extends ServiceImpl rowIds = dto.getRowIdList(); @@ -1192,10 +1194,18 @@ public class BomNewEbomParentService extends ServiceImpl bomNewEbomParentEntityList = this.lambdaQuery().in(BomNewEbomParentEntity::getRowId, rowIds).eq(BomNewEbomParentEntity::getRootIs, 1).list(); if (CollUtil.isEmpty(bomNewEbomParentEntityList)) { - // return ResultVO.error("下级BOM无法进行复核"); - VUtils.isTure(true).throwMessage("下级BOM无法进行复核"); + VUtils.isTure(true).throwMessage("下级BOM无法进行复核,请选择顶层"); } + + //检查顶级bom是否是设计自己 + List checkList=bomNewEbomParentEntityList.stream().filter(u->!u.getCreatedBy().equals(SessionUtil.getUserCode())).collect(Collectors.toList()); + if(CollUtil.isNotEmpty(checkList)) { + String checkListMaterialNo=StrUtil.join(",",checkList.stream().map(BomNewEbomParentEntity::getMaterialNo).collect(Collectors.toList())); + VUtils.isTure(true).throwMessage(StrUtil.format("{} 该节点不属于你,你无权复核",checkListMaterialNo)); + } + + Set materialNoAndVersion = bomNewEbomParentEntityList.stream().map(u -> StrUtil.join("-", u.getMaterialNo(), u.getCurrentVersion())).collect(Collectors.toSet()); LogRecordContext.putVariable("log", materialNoAndVersion); @@ -1204,6 +1214,7 @@ public class BomNewEbomParentService extends ServiceImpl checkStatus = CollectionUtil.toList(new Integer[]{ EBomExceptionStatusEnum.EXCEPT_NO_2.getValue(), EBomExceptionStatusEnum.EXCEPT_NO_3.getValue(), @@ -1224,7 +1235,7 @@ public class BomNewEbomParentService extends ServiceImpl0 说明有bom,更新只到parent这层,无bom不需要更新 + //筛选bomRowId()>0 说明有bom,更新到parent这层,无bom不需要更新 //设计人员只可以复核自己的物料,如果存在引用其他用户创建的物料时,不可以改变被引用物料的审核状态。 updateReviewIdList.addAll(checkEBomException.getAllBomDetail().stream() .filter(u -> u.getBomRowId() > 0 @@ -1234,8 +1245,8 @@ public class BomNewEbomParentService extends ServiceImpl updateWrapper = new UpdateWrapper<>(); updateWrapper.lambda() .set(BomNewEbomParentEntity::getAuditTime, LocalDateTime.now()) @@ -1244,33 +1255,19 @@ public class BomNewEbomParentService extends ServiceImpl 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)) { + + this.update(updateWrapper); + if (!ebomChildService.update(childWrapper)) { throw new NflgBusinessException(STATE.Error, "复核失败"); } - ebomChildService.update(childWrapper); - } -// 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; } @@ -1283,9 +1280,13 @@ public class BomNewEbomParentService extends ServiceImpl rowIdList = dto.getRowIdList().stream().map(BomNewEbomProjectTypeDTO.BomNewEbomChangeProjectType::getRowId).collect(Collectors.toList()); List bomRowIdList = dto.getRowIdList().stream().filter(u -> u.getBomRowId() > 0).map(BomNewEbomProjectTypeDTO.BomNewEbomChangeProjectType::getBomRowId).collect(Collectors.toList()); + + + // if (CollectionUtil.isNotEmpty(bomRowIdList)) { // UpdateWrapper parentUpdate = new UpdateWrapper<>(); // parentUpdate.lambda() @@ -1473,15 +1474,22 @@ public class BomNewEbomParentService extends ServiceImpl queryWrapper=new QueryWrapper<>(); + + queryWrapper.lambda() .eq(BomNewEbomParentEntity::getRowId, bomRowId) + .eq(BomNewEbomParentEntity::getRootIs, 1); + + BomNewEbomParentEntity parentEntity = this.getBaseMapper().selectOne(queryWrapper); + LogRecordContext.putVariable("bom", parentEntity); VUtils.isTure(Objects.isNull(parentEntity)).throwMessage("该节点不存在,请检查参数是否正确"); //设计人员只能删自己 - if (userRoleService.designer()) { - VUtils.isTure(!parentEntity.getCreatedBy().equals(SessionUtil.getUserCode())).throwMessage("该节点不属于你,你无权删除"); - } + checkUserRoleAuth(parentEntity.getCreatedBy()); +// if (userRoleService.designer()) { +// VUtils.isTure(!parentEntity.getCreatedBy().equals(SessionUtil.getUserCode())).throwMessage("该节点不属于你,你无权删除"); +// } EBomDel eBomDel = new EBomDel(bomRowId); eBomDel.classifyBom(); @@ -1538,6 +1546,18 @@ public class BomNewEbomParentService extends ServiceImpl @@ -1548,9 +1568,9 @@ public class BomNewEbomParentService extends ServiceImpl delList) { + public void deleteBomChild(List delList) { - if (CollectionUtil.isEmpty(delList)) { - return; - } - List delTagList = new ArrayList<>(); + QueryWrapper queryChildWrapper=new QueryWrapper<>(); + queryChildWrapper.lambda().in(BomNewEbomChildEntity::getRowId,delList.stream().map(BomNewEbomParentVO::getRowId)); + List delChildList=SpringUtil.getBean(BomNewEbomChildService.class).list(queryChildWrapper); - List okList = delList.stream().filter(u -> Objects.equals(EBomSourceEnum.FROM_BOM.getValue(), u.getSource()) + + + List delTagList = new ArrayList<>(); + + //检查原始bom里过来数据是否包含正常数据 + List 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(okList)) { - throw new NflgBusinessException(STATE.Error, "从原始Bom导入的数据,数据没有异常的情况下,不可以删除"); + if (CollUtil.isNotEmpty(check1List)) { + throw new NflgBusinessException(STATE.Error,StrUtil.format("从原始Bom导入的数据,数据没有异常的情况下,{} 不可以删除 ",StrUtil.join(",", check1List.stream().map(BomNewEbomChildEntity::getMaterialNo).collect(Collectors.toList()) ))); } + //检查有bom数据关系是否可以删? +// List check2List = delList.stream().filter(u -> Objects.equals(EBomSourceEnum.FROM_BOM.getValue(), u.getSource()) +// && u.getBomRowId()>0).collect(Collectors.toList()); +// +// if (CollUtil.isNotEmpty(check2List)) { +// throw new NflgBusinessException(STATE.Error,StrUtil.format("原始Bom导入有Bom,{} 不可以删除,请退回重新处理 ",String.join(",", check2List.stream().map(BomNewEbomParentVO::getMaterialNo).collect(Collectors.toList()) ))); +// } + + //原始bom不正常 - List s1List = delList.stream().filter(u -> Objects.equals(EBomSourceEnum.FROM_BOM.getValue(), u.getSource()) + List s1List = delChildList.stream().filter(u -> Objects.equals(EBomSourceEnum.FROM_BOM.getValue(), u.getSource()) && !Objects.equals(u.getExceptionStatus(), EBomExceptionStatusEnum.OK.getValue())).collect(Collectors.toList()); if (CollectionUtil.isNotEmpty(s1List)) { delTagList.addAll(s1List); } //手动创建 - List s2List = delList.stream().filter(u -> Objects.equals(EBomSourceEnum.FROM_EXCE.getValue(), u.getSource()) + List s2List = delChildList.stream().filter(u -> Objects.equals(EBomSourceEnum.FROM_EXCE.getValue(), u.getSource()) || Objects.equals(EBomSourceEnum.FROM_MDM.getValue(), u.getSource())).collect(Collectors.toList()); + //工艺岗可以删自己的和设计岗(手动、excel), + // 设计自己删除自己 + //工艺岗用户1 可以删工艺岗用户2 的数据? if (CollectionUtil.isNotEmpty(s2List)) { - delTagList.addAll(s2List); - } - - if (CollectionUtil.isNotEmpty(delTagList)) { - List rowIdList = delTagList.stream().filter(u -> u.getRowId() != null || u.getRowId().longValue() > 0).map(BomNewEbomParentVO::getRowId).collect(Collectors.toList()); - if (CollectionUtil.isNotEmpty(rowIdList)) { - ebomChildService.removeByIds(rowIdList); + for (BomNewEbomChildEntity vo: + s2List) { + if( userRoleService.technician() ){ //工艺岗可删 + delTagList.add(vo); + }else if ( userRoleService.designer() && vo.getCreatedBy().equals(SessionUtil.getUserCode())){ //自己的数据可删 + delTagList.add(vo); + }else{ + throw new NflgBusinessException(STATE.Error,StrUtil.format("{}数据不是你的,无权删除",vo.getMaterialNo())); + } } } - + if (CollectionUtil.isNotEmpty(delTagList)) { + List rowIdList = delTagList.stream().filter(u -> u.getRowId() != null || u.getRowId().longValue() > 0).map(BomNewEbomChildEntity::getRowId).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(rowIdList)) { + ebomChildService.removeByIds(rowIdList); + } + } } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/CheckEBomException.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/CheckEBomException.java index d0763a32..7fd2be00 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/CheckEBomException.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/CheckEBomException.java @@ -235,7 +235,7 @@ public class CheckEBomException { allBomDetail) { //并集 寻找相同 List list = CollectionUtil.intersection(codeList, ImmutableList.of(item.getExceptionStatus())).stream().collect(Collectors.toList()); - ; + if (CollUtil.isNotEmpty(list)) { diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomDel.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomDel.java index f359d7f7..32b276f5 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomDel.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomDel.java @@ -41,11 +41,10 @@ public class EBomDel { - //设计人员 自己创建的直接删除 - - //工艺岗位角色的时候,只能删除自己在EBOM中创建的数据 - //设计人员在Ebom中创建的数据 工艺人员可以删除? + //设计人员: 自己创建的直接删除 + //工艺岗位,只能删除自己在EBOM中创建的数据 // 原始bom导入过来的只能 设计人员自己删,工艺不能删 + //设计人员在Ebom中创建的数据 工艺人员可以删除? if(roleList.contains(EBomConstant.DESIGNER)){ delEBom = bomTreeAll.stream().filter(u -> u.getBomRowId() > 0 && u.getCreatedBy().equals(SessionUtil.getUserCode()) @@ -53,7 +52,7 @@ public class EBomDel { .collect(Collectors.toList()); } - //工艺 删除自己和设计人员的 + //工艺 删除自己和设计人员的数据只能是excel和手动录入 if(roleList.contains(EBomConstant.TECHNICIAN)){ delEBom = bomTreeAll.stream().filter(u -> u.getBomRowId() > 0 &&( u.getCreatedJob().equals(UserJobEnum.DESIGNER.getValue())||u.getCreatedBy().equals(SessionUtil.getUserCode())) @@ -62,7 +61,7 @@ public class EBomDel { } - //借用件不能删除,原始bom转换只能自己 + //借用件不能删除,原始bom转换只能删自己 if(roleList.contains(EBomConstant.DESIGNER)){ revertOBom = bomTreeAll.stream().filter(u -> u.getBomRowId() > 0 && (u.getSource().equals(EBomSourceEnum.FROM_BOM.getValue()) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomEdit.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomEdit.java index 3729aeaf..81365e9b 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomEdit.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomEdit.java @@ -1,11 +1,11 @@ package com.nflg.product.bomnew.service.domain.EBom; -import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.convert.Convert; import cn.hutool.core.lang.TypeReference; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.extra.spring.SpringUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -19,14 +19,14 @@ import com.nflg.product.bomnew.pojo.entity.BomNewEbomChildEntity; import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity; import com.nflg.product.bomnew.pojo.vo.BaseMaterialVO; import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO; +import com.nflg.product.bomnew.service.BomNewEbomChildService; import com.nflg.product.bomnew.service.BomNewEbomParentService; import com.nflg.product.bomnew.service.MaterialMainService; import com.nflg.product.bomnew.service.UserRoleService; -import com.nflg.product.bomnew.util.MaterialshouldBomExistUtil; +import com.nflg.product.bomnew.util.ListCommonUtil; import com.nflg.product.bomnew.util.VUtils; import lombok.Getter; import nflg.product.common.constant.STATE; -import org.ttzero.excel.reader.Col; import java.math.BigDecimal; import java.time.LocalDateTime; @@ -68,7 +68,7 @@ public class EBomEdit { parent.setCurrentVersion("A00"); parent.setDeviseName(SessionUtil.getRealName()); parent.setDeptName(SessionUtil.getDepartName()); - parent.setSourceRowId(0l); + parent.setSourceRowId(0L); parent.setSource(source); parent.setStatus(EBomStatusEnum.WAIT_CHECK.getValue()); parent.setNum(new BigDecimal(1)); @@ -178,7 +178,7 @@ public class EBomEdit { child.setSource(source); child.setCreatedTime(LocalDateTime.now()); child.setCreatedBy(SessionUtil.getUserCode()); - child.setSourceRowId(0l); + child.setSourceRowId(0L); child.setParentRowId(parentEntity.getRowId()); if(StrUtil.isEmpty(child.getOrderNumber())){ child.setOrderNumber("00"); @@ -237,6 +237,37 @@ public class EBomEdit { Set difference = Sets.difference(new HashSet<>(materialNos), new HashSet<>(effectiveMaterialNos)); VUtils.isTure(CollUtil.isNotEmpty(difference)).throwMessage(StrUtil.join(",", difference) + "在物料主数据中不存在"); + + //检查数据是否可修改 + List notNullRowIdList= dto.getDatas().stream().filter(u->u.getRowId()!=null && u.getRowId()>0).collect(Collectors.toList()); + Map mapList= ListCommonUtil.listToMap(notNullRowIdList,BomNewEbomParentVO::getRowId); + + + QueryWrapper queryChildWrapper=new QueryWrapper<>(); + List rowIds=notNullRowIdList.stream().map(BomNewEbomParentVO::getRowId).collect(Collectors.toList()); + queryChildWrapper.lambda().in(BomNewEbomChildEntity::getRowId,rowIds); + List childList=SpringUtil.getBean(BomNewEbomChildService.class).list(queryChildWrapper); + + // 数据不存在异常的情况下,数据是不能被修改 + List check1List = childList.stream().filter(u -> Objects.equals(EBomSourceEnum.FROM_BOM.getValue(), u.getSource()) + && Objects.equals(u.getExceptionStatus(), EBomExceptionStatusEnum.OK.getValue())).collect(Collectors.toList()); + + for (BomNewEbomChildEntity childEntity: + check1List ) { + if(mapList.get(childEntity.getRowId()) ==null){ + continue; + } + //忽略物料编码空的 + if(ObjectUtil.isNull(childEntity.getMaterialNo())){ + continue; + } + + //检查物料id是否被修改,根据情况还可加入其他条件 + if(!mapList.get(childEntity.getRowId()).getMaterialNo().equals(childEntity.getMaterialNo())){ + throw new NflgBusinessException(STATE.Error,StrUtil.format("从原始Bom导入的数据,数据没有异常的情况下,{} 不可以修改 ", childEntity.getMaterialNo())); + } + } + }