Merge branch 'feature/DM/nflg-bom' of http://112.74.186.154:3000/nflj/nflg_project into feature/DM/nflg-bom

# Conflicts:
#	nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomEdit.java
This commit is contained in:
jing's 2023-12-29 20:13:00 +08:00
commit 852ebe63b3
8 changed files with 64 additions and 17 deletions

View File

@ -320,6 +320,19 @@ public class EbomApi extends BaseApi {
}
@PostMapping("intiException")
@ApiOperation("初始化错误类型")
public ResultVO<Boolean> intiException(@RequestParam("bomRowId") Long bomRowId) throws ExecutionException, InterruptedException {
bomNewEbomParentService.checkAndSaveEBomException(bomRowId );
return ResultVO.success(true);
}
}

View File

@ -75,8 +75,7 @@ public class BomNewEbomChildVO extends BaseMaterialVO implements Serializable {
*/
@ApiModelProperty(value = "项目类别输入方式: 0-自动匹配 1-手工录入 3-来自物料主数据 4-来自历史统计")
private Integer projectTypeInputType;
@ApiModelProperty(value = "项目类别")
private String projectType;
/**
* 创建人工号
*/

View File

@ -345,8 +345,6 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
materialMainService.intiMaterialInfo(data);
productTypeInitDo(parent, data);
//更新异常信息
checkAndSaveEBomException(bomRowId);
}
}

View File

@ -0,0 +1,33 @@
package com.nflg.product.bomnew.service.domain.EBom;
import java.util.*;
/**
* 循环依赖检查
*/
public class DependencyChecker {
private Map<Integer, Boolean> visited; // 使用Integer类型的哈希码
private Set<String> nodes;
public DependencyChecker() {
visited = new HashMap<>();
nodes = new HashSet<>();
}
public void addDependency(String child, String parent) {
nodes.add(child);
nodes.add(parent);
}
public boolean hasCycle() {
for (String node : nodes) {
if (!visited.put(node.hashCode(), false) == false) {
// 当前节点已经被访问过存在循环依赖
return true;
}
}
return false;
}
}

View File

@ -249,7 +249,7 @@ public class EBomEdit {
// if(StrUtil.equals(ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_Q.getValue(),child.getProjectType())){
// child.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_9.getValue());
// }
//
// if(StrUtil.equals(ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_F.getValue(),child.getProjectType())){
// child.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_10.getValue());
// }

View File

@ -83,8 +83,8 @@ public abstract class VirtualPackageBase {
parent.setMaterialDesc(vMaterialDesc);
parent.setCurrentVersion(VersionUtil.getNextVersion(Objects.nonNull(oldParent)?oldParent.getCurrentVersion():""));
parent.setVirtualPackageIs(1);
parent.setProjectType("L");
parent.setProjectTypeInputType(ProjectTypeInputTypeEnum.AUTO_MATCH.getValue());
// parent.setProjectType("L");
// parent.setProjectTypeInputType(ProjectTypeInputTypeEnum.AUTO_MATCH.getValue());
parent.setShouldBomExist(1);
parent.setBomExist(1);
parent.setSourceRowId(0L);

View File

@ -296,7 +296,7 @@ public class OriginalBomToEBomConvert extends BaseConvert {
BeanUtil.copyProperties(parentEnt, eBomParent, "materialGetType");
eBomParent.setRowId(parentEnt.getEBomRowId() > 0 ? parentEnt.getEBomRowId() : IdWorker.getId());
eBomParent.setSource(EBomSourceEnum.FROM_BOM.getValue());
eBomParent.setCurrentVersion(Objects.isNull(ebom) ? "" : VersionUtil.getNextVersion(ebom.getCurrentVersion()));
eBomParent.setCurrentVersion(VersionUtil.getNextVersion(Objects.isNull(ebom) ? "" : VersionUtil.getNextVersion(ebom.getCurrentVersion()) ));
eBomParent.setConvertToEbomTime(LocalDateTime.now());
eBomParent.setSourceRowId(parentEnt.getBomRowId());
eBomParent.setLastVersionIs(1);

View File

@ -1,7 +1,8 @@
package com.nflg.product.bomnew.util;
import cn.hutool.core.collection.CollUtil;
import com.nflg.product.bomnew.service.domain.EBom.DependencyChecker;
import javax.validation.constraints.NotNull;
import java.util.*;
@ -127,22 +128,25 @@ public class TreeUtils {
* @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<>();
DependencyChecker checker = new DependencyChecker();
for (T data : list) {
String parent = getParentFun.apply(data);
String child = getChildFun.apply(data);
checker.addDependency(child, parent);
if (parents.contains(child)) {
result.add(getRowIdFun.apply(data));
}
parents.add(parent);
}
return result;
if (checker.hasCycle()) {
System.out.println("存在循环依赖");
} else {
System.out.println("不存在循环依赖");
}
return null;
}
}