MyTetra Share
Делитесь знаниями!
groupingBy
Время создания: 29.09.2020 09:38
Раздел: INFO - Development - JAVA - Collection - Stream
Запись: wwwlir/Tetra/master/base/16013435020ykw5ctp8n/text.html на raw.githubusercontent.com

def groupList = list.stream().collect(

Collectors.groupingBy({p->p.get("contragent_id")},

Collectors.groupingBy({p->p.get("re_id")})))



def contractAccrualGroup = accruals.stream().collect(

Collectors.groupingBy({p->p.getValue("documentNumber")},

Collectors.groupingBy({p->p.getValue("period")},

Collectors.mapping({p->p.getValue("contract_id")}, Collectors.toSet()))

)

)



//Группировка с обработкой

def accrualGroup = dataManager.loadValues('select a.contragent.id, a.documentNumber, count(distinct a.contractPosition.contract) from rtneo$Accrual a group by a.contragent.id, a.documentNumber having count(distinct a.contractPosition.contract)>1 order by a.documentNumber')

.properties("contragent_id", "documentNumber", "count_contract")

.firstResult(0)

.maxResults(10)

.list()


for(def item : accrualGroup){

def accruals = dataManager.loadValues('select a.documentNumber, a.period, a.contractPosition.contract.id from rtneo$Accrual a where a.contragent.id = :contragent_id order by a.documentNumber')

.properties("documentNumber", "period", "contract_id")

.parameter("contragent_id", item.getValue("contragent_id"))

.list()

def contractAccrualGroup = accruals.stream().collect(

Collectors.groupingBy({p->p.getValue("documentNumber")},

Collectors.groupingBy({p->p.getValue("period")},

Collectors.mapping({p->p.getValue("contract_id")}, Collectors.toSet()))

)

)

for(def i0 : contractAccrualGroup.entrySet()){

_(i0.getKey())

for(def i1 : i0.getValue().entrySet()){

_(i1.getKey())

for(def i2 : i1.getValue()){

_(i2)

}

}

}


}

 
MyTetra Share v.0.59
Яндекс индекс цитирования