Sergio C.
11/30/2021, 6:23 PMvar qtdTotal = 0.0f
val partition = response?.partition { it.uidCaracteristica != 0 }
val uidGroup = partition?.first?.groupBy { it.produto }?.toMutableMap() ?: mutableMapOf()
uidGroup[0] = partition?.second ?: listOf()
uidGroup.forEach { (key, uidsList) ->
if (key == 0) {
uidsList.forEach { stk ->
addRow(
stk.description ?: "", "", "", "",
extraInfo = listOf(
stk.produto.toString(),
stk.description ?: "",
stk.codbarras ?: "",
stk.referencia ?: ""
)
)
qtdTotal += stk.stock ?: 0.0f
}
} else {
val caracteristicas = uidsList.map {
ReportsDataset.Row(
it.caracteristica ?: "",
it.stkmin?.toString() ?: "",
it.stkmax?.toString() ?: "",
it.stock?.toString() ?: "",
extraInfo = listOf(it.uidCaracteristica?.toString() ?: "")
)
}
val stk = uidsList.first()
addRow(
stk.description ?: "", "", "", "",
extraRows = caracteristicas,
extraInfo = listOf(
stk.produto.toString(),
stk.description ?: "",
stk.codbarras ?: "",
stk.referencia ?: ""
)
)
qtdTotal += stk.stock ?: 0.0f
}
}
Richard Gomez
12/02/2021, 2:35 PMSergio C.
12/02/2021, 6:42 PMresponse
is a list of products, each product with uidCaracteristica != 0
must be organised under the same Row
other products uidCaracteristica == 0
must be a single Row
jimn
12/02/2021, 7:21 PMhttps://i.imgur.com/cvsYT4t.png▾
Sergio C.
12/03/2021, 9:15 AM