This commit is contained in:
parent
ee7e9fa01a
commit
feaaabc4bb
|
|
@ -983,51 +983,25 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
VUtils.isTure(!parentEntity.getCreatedBy().equals(SessionUtil.getUserCode())).throwMessage("该节点不属于你,你无权删除");
|
||||
}
|
||||
|
||||
List<BomNewEbomParentVO> bomTree = getBomTree(bomRowId);
|
||||
List<BomNewEbomParentVO> 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<BomNewEbomParentVO> 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<Long> 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<Long> rowIds = obomList.stream().map(BomNewEbomParentVO::getSourceRowId).collect(Collectors.toList());
|
||||
SpringUtil.getBean(BomNewOriginalParentService.class).revertBom(rowIds);
|
||||
if (CollectionUtil.isNotEmpty(eBomDel.getRevertOBom())) {
|
||||
List<Long> 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;
|
||||
|
|
|
|||
|
|
@ -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<BomNewEbomParentVO> bomTreeAll;
|
||||
@Getter
|
||||
List<BomNewEbomParentVO> delEBom;
|
||||
@Getter
|
||||
List<BomNewEbomParentVO> revertOBom;
|
||||
|
||||
public EBomDel(Long bomRowId) throws ExecutionException, InterruptedException {
|
||||
bomTreeAll = SpringUtil.getBean(BomNewEbomParentService.class).buildBomTreeContainSelf(bomRowId);
|
||||
}
|
||||
|
||||
public EBomDel( List<BomNewEbomParentVO> allBom){
|
||||
bomTreeAll.addAll(allBom);
|
||||
}
|
||||
|
||||
public void classifyBom(){
|
||||
|
||||
List<String> 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<Long> delParentRowId = new ArrayList<>();
|
||||
// for (BomNewEbomParentVO bom : delBom) {
|
||||
// delParentRowId.add(bom.getBomRowId());
|
||||
// }
|
||||
// delParentRowId.add(bomRowId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue