zhang_nuo
6 天以前 f3d0cf42321bb6f0f3c03a66c3d33c260f5d593e
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) {