|
@@ -166,10 +166,13 @@ public class TechnologyServiceImpl extends ServiceImpl<TechnologyMapper, Technol
|
|
|
if (ObjectUtil.isNotEmpty(technologyProcessLines)) {
|
|
|
technologyProcessLineService.saveBatch(technologyProcessLines);
|
|
|
|
|
|
- processRoute = technologyProcessLines.stream()
|
|
|
- .map(TechnologyProcessLine::getTargetProcessesId)
|
|
|
- .map(Objects::toString)
|
|
|
- .filter(item -> !Objects.equals(item, "99")).collect(Collectors.joining(","));
|
|
|
+// processRoute = technologyProcessLines.stream()
|
|
|
+// .map(TechnologyProcessLine::getTargetProcessesId)
|
|
|
+// .map(Objects::toString)
|
|
|
+// .filter(item -> !Objects.equals(item, "99")).collect(Collectors.joining(","));
|
|
|
+
|
|
|
+ List<Long> processLineIds = recursionTechnologyProcessLine(technologyProcessLines, Collections.singletonList(1L));
|
|
|
+ processRoute = processLineIds.stream().map(Objects::toString).collect(Collectors.joining(","));
|
|
|
} else {
|
|
|
processRoute = null;
|
|
|
}
|
|
@@ -197,10 +200,13 @@ public class TechnologyServiceImpl extends ServiceImpl<TechnologyMapper, Technol
|
|
|
if (ObjectUtil.isNotEmpty(technologyProcessLines)) {
|
|
|
technologyProcessLineService.saveBatch(technologyProcessLines);
|
|
|
|
|
|
- processRoute = technologyProcessLines.stream()
|
|
|
- .map(TechnologyProcessLine::getTargetProcessesId)
|
|
|
- .map(Objects::toString)
|
|
|
- .filter(item -> !Objects.equals(item, "99")).collect(Collectors.joining(","));
|
|
|
+// processRoute = technologyProcessLines.stream()
|
|
|
+// .map(TechnologyProcessLine::getTargetProcessesId)
|
|
|
+// .map(Objects::toString)
|
|
|
+// .filter(item -> !Objects.equals(item, "99")).collect(Collectors.joining(","));
|
|
|
+
|
|
|
+ List<Long> processLineIds = recursionTechnologyProcessLine(technologyProcessLines, Collections.singletonList(1L));
|
|
|
+ processRoute = processLineIds.stream().map(Objects::toString).collect(Collectors.joining(","));
|
|
|
} else {
|
|
|
processRoute = null;
|
|
|
}
|
|
@@ -208,6 +214,35 @@ public class TechnologyServiceImpl extends ServiceImpl<TechnologyMapper, Technol
|
|
|
this.update(q->q.eq(Technology::getId,technologyDto.getId()).set(Technology::getProcessRoute,processRoute));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 遍历工艺线路
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<Long> recursionTechnologyProcessLine(List<TechnologyProcessLine> technologyProcessLines, List<Long> sourceProcessesIds){
|
|
|
+ List<Long> processIds = new ArrayList<>();
|
|
|
+
|
|
|
+ List<Long> targetProcessesIds = technologyProcessLines.stream()
|
|
|
+ .filter(item -> sourceProcessesIds.contains(item.getSourceProcessesId()))
|
|
|
+ .map(TechnologyProcessLine::getTargetProcessesId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ if(ObjectUtil.isNotEmpty(targetProcessesIds)){
|
|
|
+ //过滤掉结束节点
|
|
|
+ List<Long> collect = targetProcessesIds.stream().filter(item -> !Objects.equals(item, 99L)).collect(Collectors.toList());
|
|
|
+ if(ObjectUtil.isNotEmpty(collect)){
|
|
|
+ processIds.addAll(collect);
|
|
|
+ }
|
|
|
+ //不包含结束节点才递归(防止死循环)
|
|
|
+ if(!targetProcessesIds.contains(99L)) {
|
|
|
+ processIds.addAll(recursionTechnologyProcessLine(technologyProcessLines, targetProcessesIds));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //去重
|
|
|
+ processIds = processIds.stream().distinct().collect(Collectors.toList());
|
|
|
+ return processIds;
|
|
|
+ }
|
|
|
+
|
|
|
@DSTransactional
|
|
|
@Override
|
|
|
public void delete(Long id) {
|