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 45b4a318..aaecc1b7 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 @@ -983,51 +983,25 @@ public class BomNewEbomParentService extends ServiceImpl bomTree = getBomTree(bomRowId); - List delBom = null; + EBomDel eBomDel=new EBomDel(bomRowId); + eBomDel.classifyBom(); - //设计 工艺,删录入 excel导入 - delBom = bomTree.stream().filter(u -> u.getBomRowId() > 0 - && (u.getSource().equals(EBomSourceEnum.FROM_MDM.getValue()) - ||u.getSource().equals(EBomSourceEnum.FROM_EXCE.getValue()))) - .collect(Collectors.toList()); - - //借用件不能删除,原始bom转换只能自己 - List obomList = null; - if (userRoleService.designer()) { - obomList = bomTree.stream().filter(u -> u.getBomRowId() > 0 - && (u.getSource().equals(EBomSourceEnum.FROM_BOM.getValue()) - && u.getCreatedBy().equals(SessionUtil.getUserCode()) - )) - .collect(Collectors.toList()); - - if (CollectionUtil.isNotEmpty(obomList)) { - delBom.addAll(obomList); + if (CollectionUtil.isNotEmpty(eBomDel.getDelEBom())) { + this.getBaseMapper().delBatch(eBomDel.getDelEBom().stream().map(BomNewEbomParentVO::getRowId).collect(Collectors.toList())); } - } - - if (CollUtil.isNotEmpty(delBom)) { - - List delParentRowId = new ArrayList<>(); - for (BomNewEbomParentVO bom : delBom) { - delParentRowId.add(bom.getBomRowId()); - } - delParentRowId.add(bomRowId); - if (CollUtil.isNotEmpty(delParentRowId)) { - this.getBaseMapper().delBatch(delParentRowId); - } - - - - ThreadUtil.execAsync(() -> computeLevelNumAndRootState()); - - } //恢复原始bom状态 - if (CollectionUtil.isNotEmpty(obomList)) { - List rowIds = obomList.stream().map(BomNewEbomParentVO::getSourceRowId).collect(Collectors.toList()); - SpringUtil.getBean(BomNewOriginalParentService.class).revertBom(rowIds); + if (CollectionUtil.isNotEmpty(eBomDel.getRevertOBom())) { + List rowIds = eBomDel.getRevertOBom().stream().map(BomNewEbomParentVO::getSourceRowId).collect(Collectors.toList()); + SpringUtil.getBean(BomNewOriginalParentService.class).revertBom(rowIds); + + + } + if (CollectionUtil.isNotEmpty(eBomDel.getDelEBom())) { + + ThreadUtil.execAsync(() -> computeLevelNumAndRootState()); + } return true; 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 new file mode 100644 index 00000000..9e7dea90 --- /dev/null +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomDel.java @@ -0,0 +1,94 @@ +package com.nflg.product.bomnew.service.domain.EBom; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.extra.spring.SpringUtil; +import com.nflg.product.base.core.conmon.util.SessionUtil; +import com.nflg.product.bomnew.constant.EBomConstant; +import com.nflg.product.bomnew.constant.EBomSourceEnum; +import com.nflg.product.bomnew.constant.UserJobEnum; +import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO; +import com.nflg.product.bomnew.service.BomNewEbomParentService; +import com.nflg.product.bomnew.service.UserRoleService; +import lombok.Getter; +import org.apache.tomcat.jni.User; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; +import java.util.stream.Collectors; + +public class EBomDel { + @Getter + List bomTreeAll; + @Getter + List delEBom; + @Getter + List revertOBom; + + public EBomDel(Long bomRowId) throws ExecutionException, InterruptedException { + bomTreeAll = SpringUtil.getBean(BomNewEbomParentService.class).buildBomTreeContainSelf(bomRowId); + } + + public EBomDel( List allBom){ + bomTreeAll.addAll(allBom); + } + + public void classifyBom(){ + + List roleList= SpringUtil.getBean(UserRoleService.class).getUserPost(); + + + + + //设计人员 自己创建的直接删除 + + //工艺岗位角色的时候,只能删除自己在EBOM中创建的数据 + //设计人员在Ebom中创建的数据 工艺人员可以删除? + // 原始bom导入过来的只能 设计人员自己删,工艺不能删 + + if(roleList.contains(EBomConstant.DESIGNER)){ + delEBom = bomTreeAll.stream().filter(u -> u.getBomRowId() > 0 + && u.getCreatedBy().equals(SessionUtil.getUserCode()) + && (u.getSource().equals(EBomSourceEnum.FROM_MDM.getValue()) ||u.getSource().equals(EBomSourceEnum.FROM_EXCE.getValue()))) + .collect(Collectors.toList()); + } + + //工艺 删除自己和设计人员的 + if(roleList.contains(EBomConstant.TECHNICIAN)){ + delEBom = bomTreeAll.stream().filter(u -> u.getBomRowId() > 0 + &&( u.getCreatedJob().equals(UserJobEnum.DESIGNER.getValue())||u.getCreatedBy().equals(SessionUtil.getUserCode())) + && (u.getSource().equals(EBomSourceEnum.FROM_MDM.getValue()) ||u.getSource().equals(EBomSourceEnum.FROM_EXCE.getValue()))) + .collect(Collectors.toList()); + } + + + //借用件不能删除,原始bom转换只能自己 + if(roleList.contains(EBomConstant.DESIGNER)){ + revertOBom = bomTreeAll.stream().filter(u -> u.getBomRowId() > 0 + && (u.getSource().equals(EBomSourceEnum.FROM_BOM.getValue()) + && u.getCreatedBy().equals(SessionUtil.getUserCode()) + )) + .collect(Collectors.toList()); + + if (CollectionUtil.isNotEmpty(revertOBom)) { + delEBom.addAll(revertOBom); + } + } + + + + +// if (CollUtil.isNotEmpty(delBom)) { +// +// List delParentRowId = new ArrayList<>(); +// for (BomNewEbomParentVO bom : delBom) { +// delParentRowId.add(bom.getBomRowId()); +// } +// delParentRowId.add(bomRowId); + } + + + + +}