package scripts.dict

import cn.lihongjie.coal.base.dto.CommonQuery
import cn.lihongjie.coal.base.dto.TreeDto
import cn.lihongjie.coal.coalInfo.controller.CoalInfoController
import org.springframework.context.ApplicationContext

ApplicationContext ioc = ioc

def controller = ioc.getBean(CoalInfoController.class)


def groupBy = controller.list(new CommonQuery()).content.groupBy { it -> it.getCoalTypeName() }

return groupBy.collect { key, value ->

    def treeDto = new TreeDto()
    treeDto.setName(key)
    treeDto.setId(key)
    treeDto.setChildren(value.collect { it ->

        def child = new TreeDto()
        child.setName(it.getName())
        child.setId(it.getId())
    })


}


