gongchunyi
9 小时以前 10570a9fa5e87231210a449eddc732c7d0599349
src/main/java/com/ruoyi/production/service/impl/ProductionBomStructureServiceImpl.java
@@ -822,14 +822,22 @@
        if (bomStructure == null) {
            return null;
        }
        // The root node is the first output node; other rows use their direct parent as the current operation output.
        if (bomStructure.getParentId() == null) {
        if (bomStructure.getParentId() == null || hasChildren(bomStructure, structureById)) {
            return bomStructure;
        }
        ProductionBomStructure parent = structureById.get(bomStructure.getParentId());
        return parent != null ? parent : bomStructure;
    }
    private boolean hasChildren(ProductionBomStructure bomStructure,
                                Map<Long, ProductionBomStructure> structureById) {
        if (bomStructure == null || bomStructure.getId() == null || structureById == null) {
            return false;
        }
        return structureById.values().stream()
                .anyMatch(child -> child != null && Objects.equals(child.getParentId(), bomStructure.getId()));
    }
    private Long resolveOutputProductModelId(ProductionBomStructure outputNode,
                                             Long rootProductModelId) {
        if (outputNode == null) {