1.初始化异常信息
This commit is contained in:
parent
8d75f3c249
commit
200864bb49
|
|
@ -135,6 +135,8 @@ public class OriginalBomApi extends BaseApi {
|
|||
|
||||
//跟新EBom 根节点
|
||||
ebomParentService.getBaseMapper().updateRootState();
|
||||
|
||||
|
||||
return ResultVO.success(true);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public enum EBomExceptionStatusEnum {
|
|||
EXCEPT_NO_6(6, "重复异常(当前层级包含了相同的物料信息)"),
|
||||
EXCEPT_NO_7(7, "物料主数据不存在(当前的物料信息在主数据平台不存在)"),
|
||||
EXCEPT_NO_8(8, "项目类别为空"),
|
||||
EXCEPT_NO_9(9, "项目赋值异常(父级物料的项目类型为Q时,子级中不能存在项目类别为Q的物料)"),
|
||||
EXCEPT_NO_9(9, "项目赋值异常(父级物料的项目类型为Q时,子级中物不能存在项目类别为Q的料)"),
|
||||
EXCEPT_NO_10(10, "项目赋值异常(当父级物料的项目类型为F时,子级中不能存在项目类型为F的物料)"),
|
||||
EXCEPT_NO_11(11, "未填写变更原因和技术通知单"),
|
||||
EXCEPT_NO_12(12, "数量需要用户确认"),
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
package com.nflg.product.bomnew.constant;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 物料状态
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum MateiralStateEnum implements ValueEnum<Integer> {
|
||||
|
||||
//物料状态 1:激活 2:禁止采购 3:售后专用 4:冻结 5:完全弃用
|
||||
ACTIVE(1, "激活"),
|
||||
DISABLE_PURCHASE(2, "禁止采购"),
|
||||
AFTER_SALE(3, "售后专用"),
|
||||
FREEZE(4, "冻结"),
|
||||
DELETED(5, "完全弃用");
|
||||
|
||||
private final Integer value;
|
||||
private final String description;
|
||||
|
||||
}
|
||||
|
|
@ -150,7 +150,7 @@ public class BomNewEbomParentVO extends BaseMaterialVO implements Serializable {
|
|||
/**
|
||||
* 异常状态:1=正常、2=冻结/完全弃用异常、3=递归异常、4=数据不完整异常、5=超级物料异常、6=重复异常
|
||||
*/
|
||||
@ApiModelProperty(value = "异常状态:1=正常、2=冻结/完全弃用异常、3=递归异常、4=数据不完整异常、5=超级物料异常、6=重复异常")
|
||||
@ApiModelProperty(value = "异常状态:1=正常、2=冻结/完全弃用异常、3=递归异常、4=数据不完整异常、5=超级物料异常、6=重复异常 7=物料主数据不存在 8=项目类别为空 9=项目赋值异常(父级物料的项目类型为Q时,子级中不能存在项目类别为Q的物料) 10=项目赋值异常(当父级物料的项目类型为F时,子级中不能存在项目类型为F的物料) 11=未填写变更原因和技术通知单 12=数量需要用户确认 13=项目类型需要用户确认")
|
||||
private Integer exceptionStatus;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -114,11 +114,6 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
} else {
|
||||
Page<BomNewEbomParentVO> result = this.getBaseMapper().getEBomListPage(new Page<>(query.getPage(), query.getPageSize()), query, userRoleService.getUserJob(), SessionUtil.getUserCode());
|
||||
returnResult = result;
|
||||
// materialMainService.intiMaterialInfo(result.getRecords());
|
||||
// Page<TreeNode<BomNewEbomParentVO>> resutlData = new Page<>();
|
||||
// BeanUtil.copyProperties(result, resutlData);
|
||||
// //resutlData.setRecords(handNodeToTree(result.getRecords()));
|
||||
// returnResult= resutlData;
|
||||
}
|
||||
return returnResult;
|
||||
}
|
||||
|
|
@ -145,15 +140,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
return resutlData;
|
||||
}
|
||||
|
||||
// private List<BomNewEbomParentVO> handNodeToTree(List<BomNewEbomParentVO> list){
|
||||
// List<TreeNode<BomNewEbomParentVO>> result=new ArrayList<>();
|
||||
// for (BomNewEbomParentVO vo : list) {
|
||||
// TreeNode<BomNewEbomParentVO> treeData= new TreeNode<>();
|
||||
// treeData.setData(vo);
|
||||
// result.add(treeData);
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -225,8 +212,8 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
List<BomNewEbomParentEntity> list = this.lambdaQuery().in(BomNewEbomParentEntity::getMaterialNo, materialNos).eq(BomNewEbomParentEntity::getLastVersionIs, 1).list();
|
||||
Map<String, BomNewEbomParentEntity> bomListMap = ListCommonUtil.listToMap(list, BomNewEbomParentEntity::getMaterialNo);
|
||||
for (BomNewEbomParentVO child : parentChild) {
|
||||
if (bomListMap.containsKey(child.getDrawingNo())) {
|
||||
BomNewEbomParentEntity parentEntity = bomListMap.get(child.getDrawingNo());
|
||||
if (bomListMap.containsKey(child.getMaterialNo())) {
|
||||
BomNewEbomParentEntity parentEntity = bomListMap.get(child.getMaterialNo());
|
||||
child.setCurrentVersion(parentEntity.getCurrentVersion());
|
||||
child.setStatus(parentEntity.getStatus());
|
||||
child.setDeviseName(parentEntity.getDeviseName());
|
||||
|
|
@ -277,7 +264,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
* @throws ExecutionException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
private List<BomNewEbomParentVO> getBomTree(Long rowId) throws ExecutionException, InterruptedException {
|
||||
public List<BomNewEbomParentVO> getBomTree(Long rowId) throws ExecutionException, InterruptedException {
|
||||
List<BomNewEbomParentVO> bomDetail = this.getBaseMapper().getParentChild(rowId);
|
||||
EBomDetailTask detailTask = new EBomDetailTask(bomDetail);
|
||||
ForkJoinTask<List<BomNewEbomParentVO>> submit = bomDetailPool.submit(detailTask);
|
||||
|
|
@ -302,8 +289,10 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
BomNewEbomParentVO parent = Convert.convert(BomNewEbomParentVO.class, this.getById(bomRowId));
|
||||
//初始化物料信息
|
||||
materialMainService.intiMaterialInfo(data);
|
||||
|
||||
productTypeInitDo(parent, data);
|
||||
|
||||
//更新异常信息
|
||||
checkAndSaveEBomException(bomRowId);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -339,6 +328,65 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化bom 异常信息
|
||||
* @param list
|
||||
*/
|
||||
public void initBomException (List<BomNewEbomParentVO> list){
|
||||
CheckEBomException checkEBomException=new CheckEBomException(list);
|
||||
checkEBomException.initException();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 初始化bom 异常信息
|
||||
* @param bomRowId bom行ID
|
||||
*/
|
||||
public void initBomException (Long bomRowId) throws ExecutionException, InterruptedException {
|
||||
CheckEBomException checkEBomException=new CheckEBomException(bomRowId);
|
||||
checkEBomException.initException();
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查 并保存异常信息
|
||||
*/
|
||||
public void checkAndSaveEBomException(Long bomRowId) throws ExecutionException, InterruptedException {
|
||||
CheckEBomException checkEBomException=new CheckEBomException(bomRowId);
|
||||
checkEBomException.initException();
|
||||
List<BomNewEbomParentVO> allBomDetail = checkEBomException.getAllBomDetail();
|
||||
//父级
|
||||
List<BomNewEbomParentVO> parents = allBomDetail.stream().filter(u -> u.getBomRowId() > 0).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(parents)) {
|
||||
List<BomNewEbomParentEntity> pentList=new ArrayList<>();
|
||||
parents.forEach(k->{
|
||||
BomNewEbomParentEntity pEnt=new BomNewEbomParentEntity();
|
||||
pEnt.setRowId(k.getBomRowId());
|
||||
pEnt.setExceptionStatus(k.getExceptionStatus());
|
||||
pentList.add(pEnt);
|
||||
});
|
||||
if(CollUtil.isNotEmpty(pentList)){
|
||||
this.updateBatchById(pentList);
|
||||
}
|
||||
}
|
||||
//子级
|
||||
List<BomNewEbomParentVO> child = allBomDetail.stream().filter(u -> u.getRowId() > 0).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(parents)) {
|
||||
List<BomNewEbomChildEntity> childList=new ArrayList<>();
|
||||
parents.forEach(k->{
|
||||
BomNewEbomChildEntity pEnt=new BomNewEbomChildEntity();
|
||||
pEnt.setRowId(k.getRowId());
|
||||
pEnt.setExceptionStatus(k.getExceptionStatus());
|
||||
childList.add(pEnt);
|
||||
});
|
||||
if(CollUtil.isNotEmpty(childList)){
|
||||
ebomChildService.updateBatchById(childList);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import com.nflg.product.bomnew.pojo.entity.BomOriginalCadParentEntity;
|
|||
import com.nflg.product.bomnew.pojo.query.OriginalBomQuery;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomOriginalListVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomOriginalPlmBomVO;
|
||||
import com.nflg.product.bomnew.service.domain.EBom.CheckEBomException;
|
||||
import com.nflg.product.bomnew.service.domain.OriginalBom.OriginalBomDetailTask;
|
||||
import com.nflg.product.bomnew.service.domain.OriginalBom.OriginalBomToEBomConvert;
|
||||
import com.nflg.product.bomnew.service.domain.OriginalBom.PlmBomToOriginalConvert;
|
||||
|
|
@ -339,6 +340,9 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
|
|||
|
||||
convertToEBomDo(parent);
|
||||
|
||||
//更新并保存异常信息
|
||||
ebomParentService.checkAndSaveEBomException(parent.getRowId());
|
||||
|
||||
}
|
||||
return true;
|
||||
|
||||
|
|
@ -357,6 +361,8 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
|
|||
|
||||
OriginalBomToEBomConvert convert = new OriginalBomToEBomConvert(parent, bomAllChildList);
|
||||
convert.convert();
|
||||
|
||||
|
||||
if (CollUtil.isNotEmpty(convert.getEBomParentResult())) {
|
||||
ebomParentService.saveOrUpdateBatch(convert.getEBomParentResult());
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,8 @@ public class MaterialService {
|
|||
|
||||
MaterialMainDTO materialMainDTO = new MaterialMainDTO();
|
||||
materialMainDTO.setMaterialName(materialName);
|
||||
// materialMainDTO.setDrawingNo(drawingNo);
|
||||
materialMainDTO.setDrawingNo(drawingNo);
|
||||
|
||||
|
||||
if (StrUtil.isEmpty(drawingNo)) {
|
||||
materialMainDTO.setMaterialDesc(materialName);
|
||||
|
|
@ -92,6 +93,35 @@ public class MaterialService {
|
|||
|
||||
}
|
||||
|
||||
public String addMaterial(String drawingNo, String materialName, String materialDesc , String materialCategoryCode) throws IOException {
|
||||
|
||||
List<MaterialMainEntity> oldMaterialList = SpringUtil.getBean(MaterialMainService.class).lambdaQuery()
|
||||
.eq(MaterialMainEntity::getMaterialName, materialName).list();
|
||||
if(CollUtil.isNotEmpty(oldMaterialList)){
|
||||
return oldMaterialList.get(0).getMaterialNo();
|
||||
}
|
||||
|
||||
MaterialMainDTO materialMainDTO = new MaterialMainDTO();
|
||||
materialMainDTO.setMaterialName(materialName);
|
||||
materialMainDTO.setDrawingNo(drawingNo);
|
||||
materialMainDTO.setMaterialDesc(materialDesc);
|
||||
|
||||
|
||||
materialMainDTO.setMaterialCategoryCode(materialCategoryCode);
|
||||
materialMainDTO.setOpEnum(1);
|
||||
materialMainDTO.setRowId(IdWorker.getId());
|
||||
HttpUtils httpUtils = new HttpUtils();
|
||||
String token = SessionUtil.getSessionKey();
|
||||
String s = httpUtils.doPost(NacosConfig.getNacosConfig().getAddMaterialUrl(), JSON.toJSONString(materialMainDTO), token);
|
||||
AddMaterialResultDTO result = JSON.parseObject(s, AddMaterialResultDTO.class);
|
||||
if (STATE.Success.getState().equals(result.getState())) {
|
||||
return result.getData().toString();
|
||||
}
|
||||
VUtils.isTure(true).throwMessage("申请物料失败" + result.getMsg());
|
||||
return s;
|
||||
|
||||
}
|
||||
|
||||
public String addMaterialPublish(String drawingNo, String materialName, String materialCategoryCode) throws IOException {
|
||||
MaterialMainDTO materialMainDTO = new MaterialMainDTO();
|
||||
materialMainDTO.setMaterialName(materialName);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,138 @@
|
|||
package com.nflg.product.bomnew.service.domain.EBom;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.nflg.product.bomnew.constant.EBomExceptionStatusEnum;
|
||||
import com.nflg.product.bomnew.constant.MaterialGetEnum;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
|
||||
import com.nflg.product.bomnew.service.BomNewEbomParentService;
|
||||
import com.nflg.product.bomnew.service.MaterialMainService;
|
||||
import com.nflg.product.bomnew.util.ListCommonUtil;
|
||||
import com.nflg.product.bomnew.util.TreeUtils;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 检查BOM 异常
|
||||
*/
|
||||
public class CheckEBomException {
|
||||
|
||||
@Getter
|
||||
List<BomNewEbomParentVO> allBomDetail ;
|
||||
|
||||
public CheckEBomException(Long bomRowId) throws ExecutionException, InterruptedException {
|
||||
allBomDetail = SpringUtil.getBean(BomNewEbomParentService.class).getBomTree(bomRowId);
|
||||
BomNewEbomParentEntity parent = SpringUtil.getBean(BomNewEbomParentService.class).getById(bomRowId);
|
||||
BomNewEbomParentVO convert = Convert.convert(BomNewEbomParentVO.class, parent);
|
||||
convert.setBomRowId(convert.getRowId());
|
||||
convert.setParentRowId(0L);
|
||||
allBomDetail.add(convert);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param allBom 整颗BOM树(包含跟节点)
|
||||
*/
|
||||
public CheckEBomException(List<BomNewEbomParentVO> allBom) {
|
||||
allBomDetail = allBom;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化异常
|
||||
*/
|
||||
public void initException() {
|
||||
//初始化物料信息
|
||||
SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(allBomDetail);
|
||||
|
||||
for (BomNewEbomParentVO vo : allBomDetail) {
|
||||
if(Objects.isNull(vo.getExceptionStatus())) {
|
||||
vo.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
|
||||
}
|
||||
if (StrUtil.isNotBlank(vo.getMaterialNo()) && (MaterialGetEnum.MaterialStateEnum.STATE_NO_4.equalsValue(vo.getMaterialState()) || MaterialGetEnum.MaterialStateEnum.STATE_NO_5.equalsValue(vo.getMaterialState()))) {
|
||||
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_2.getValue());
|
||||
} else if (StrUtil.isBlank(vo.getMaterialNo()) || Objects.isNull(vo.getNum()) || (Objects.nonNull(vo.getNum()) && BigDecimal.ZERO.compareTo(vo.getNum()) >= 0)) {
|
||||
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_4.getValue());
|
||||
} else if (StrUtil.isNotBlank(vo.getMaterialNo()) && Objects.isNull(vo.getMaterialState())) {
|
||||
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_7.getValue());
|
||||
} else if (StrUtil.isBlank(vo.getProjectType())) {
|
||||
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_8.getValue());
|
||||
}
|
||||
|
||||
}
|
||||
checkOther();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查 EXCEPT_NO_3 EXCEPT_NO_6, EXCEPT_NO_9, EXCEPT_NO_10
|
||||
*
|
||||
* @param
|
||||
*/
|
||||
private void checkOther() {
|
||||
List<CheckEBomExceptionDTO> checkEBomExceptionDTOS=new ArrayList<>();
|
||||
List<BomNewEbomParentVO> parents = allBomDetail.stream().filter(u -> u.getBomRowId() > 0).collect(Collectors.toList());
|
||||
for (BomNewEbomParentVO parent : parents) {
|
||||
List<BomNewEbomParentVO> child = allBomDetail.stream().filter(u -> u.getParentRowId().equals(parent.getBomRowId())).collect(Collectors.toList());
|
||||
if(CollUtil.isNotEmpty(child)){
|
||||
child.forEach(u->{
|
||||
CheckEBomExceptionDTO ent=new CheckEBomExceptionDTO();
|
||||
ent.setRowId(u.getRowId());
|
||||
ent.setParentMaterialNo(parent.getMaterialNo());
|
||||
ent.setChildMaterialNo(u.getMaterialNo());
|
||||
checkEBomExceptionDTOS.add(ent);
|
||||
});
|
||||
}
|
||||
//是否存在重复物料
|
||||
Map<String, List<BomNewEbomParentVO>> childMaterialMap = ListCommonUtil.listGroupMap(child, BomNewEbomParentVO::getMaterialNo);
|
||||
for (String key : childMaterialMap.keySet()) {
|
||||
List<BomNewEbomParentVO> materialGroupList = childMaterialMap.get(key);
|
||||
if (materialGroupList.size() > 1) {
|
||||
materialGroupList.forEach(u -> {
|
||||
u.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_6.getValue());
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
if ("Q".equals(parent.getProjectType())) {
|
||||
List<BomNewEbomParentVO> qList = child.stream().filter(u -> "Q".equals(u.getProjectType())).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(qList)) {
|
||||
parent.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_9.getValue());
|
||||
qList.forEach(u -> u.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_9.getValue()));
|
||||
}
|
||||
}
|
||||
if ("F".equals(parent.getProjectType())) {
|
||||
List<BomNewEbomParentVO> qList = child.stream().filter(u -> "F".equals(u.getProjectType())).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(qList)) {
|
||||
parent.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_10.getValue());
|
||||
qList.forEach(u -> u.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_10.getValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
checkCircularDependency(checkEBomExceptionDTOS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查循环依赖
|
||||
*/
|
||||
private void checkCircularDependency(List<CheckEBomExceptionDTO> list) {
|
||||
List<Long> result = TreeUtils.checkParentChildRelationship(list, CheckEBomExceptionDTO::getParentMaterialNo, CheckEBomExceptionDTO::getChildMaterialNo, CheckEBomExceptionDTO::getRowId);
|
||||
if(CollUtil.isNotEmpty(result)){
|
||||
List<BomNewEbomParentVO> collect = allBomDetail.stream().filter(u -> result.contains(u.getRowId())).collect(Collectors.toList());
|
||||
collect.forEach(u->{
|
||||
u.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_3.getValue());
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.nflg.product.bomnew.service.domain.EBom;
|
||||
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CheckEBomExceptionDTO {
|
||||
|
||||
@ApiModelProperty("标识行ID")
|
||||
private Long rowId;
|
||||
|
||||
@ApiModelProperty("父级物料号")
|
||||
private String parentMaterialNo;
|
||||
|
||||
@ApiModelProperty("子级物料号")
|
||||
private String childMaterialNo;
|
||||
}
|
||||
|
|
@ -65,7 +65,15 @@ public abstract class VirtualPackageBase {
|
|||
oldParent.setLastVersionIs(0);
|
||||
this.parentResult.add(oldParent);
|
||||
}
|
||||
String materialNo = SpringUtil.getBean(MaterialService.class).addMaterial(drawingNo, vMaterialName, virtualPackageType.getMaterialCategoryCode());
|
||||
if(!VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.equalsValue(virtualPackageType.getValue())){
|
||||
drawingNo="";
|
||||
}
|
||||
else {
|
||||
drawingNo= vDrawingNo;
|
||||
}
|
||||
String materialDesc= drawingNo+vMaterialName;
|
||||
|
||||
String materialNo = SpringUtil.getBean(MaterialService.class).addMaterial(drawingNo, vMaterialName,materialDesc, virtualPackageType.getMaterialCategoryCode());
|
||||
BomNewEbomParentEntity parent =new BomNewEbomParentEntity();
|
||||
parent.setRowId(IdWorker.getId());
|
||||
parent.setOrderNumber("001");
|
||||
|
|
|
|||
|
|
@ -119,5 +119,30 @@ public class TreeUtils {
|
|||
}
|
||||
return resultList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 判断是否循环依赖
|
||||
* @param list 要检查的对象
|
||||
* @return List<Long> 存在循环依赖的具体行-rowId
|
||||
*/
|
||||
public static <T> List<Long> checkParentChildRelationship(List<T> list ,Function<T,String> getParentFun, Function<T,String> getChildFun,Function<T,Long> getRowIdFun) {
|
||||
Set<String> parents = new HashSet<>();
|
||||
|
||||
List<Long> result=new ArrayList<>();
|
||||
|
||||
for (T data : list) {
|
||||
String parent = getParentFun.apply(data);
|
||||
String child = getChildFun.apply(data);
|
||||
|
||||
if (parents.contains(child)) {
|
||||
result.add(getRowIdFun.apply(data));
|
||||
}
|
||||
|
||||
parents.add(parent);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue