plant wise filter
This commit is contained in:
parent
bcdf15a034
commit
e68b24b557
@ -19,6 +19,7 @@ data class CommonFilters(
|
|||||||
val from: LocalDate = baseDate,
|
val from: LocalDate = baseDate,
|
||||||
val to: LocalDate = maxDate,
|
val to: LocalDate = maxDate,
|
||||||
val vendor: List<Long>? = null,
|
val vendor: List<Long>? = null,
|
||||||
|
val plant: List<Long>? = null,
|
||||||
val sortAsc: Boolean = true,
|
val sortAsc: Boolean = true,
|
||||||
val sortBy: String = IGNORE
|
val sortBy: String = IGNORE
|
||||||
)
|
)
|
||||||
@ -112,14 +113,18 @@ data class ReminderLogFilters(
|
|||||||
|
|
||||||
fun <T> applyVendorHelper(q: io.ebean.ExpressionList<T>, vids: List<Long>?) {
|
fun <T> applyVendorHelper(q: io.ebean.ExpressionList<T>, vids: List<Long>?) {
|
||||||
if (vids.isNullOrEmpty()) return
|
if (vids.isNullOrEmpty()) return
|
||||||
// q.apply {
|
|
||||||
// q.`in`("vendor", vids)
|
|
||||||
// }
|
|
||||||
// println(vids)
|
|
||||||
// println(vids[0])
|
|
||||||
q.eq("vendor_sys_pk", vids[0])
|
q.eq("vendor_sys_pk", vids[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun <T> applyPlantFilter(q: io.ebean.ExpressionList<T>, vids: List<Long>?) {
|
||||||
|
|
||||||
|
if (vids.isNullOrEmpty()) {
|
||||||
|
q.`in`("unloadingPlantId", Session.currentUserPlants().map { it.plantId })
|
||||||
|
} else {
|
||||||
|
q.`in`("unloadingPlantId", vids)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun <T> applySortHelper(q: io.ebean.ExpressionList<T>, sortBy: String, asc: Boolean) {
|
fun <T> applySortHelper(q: io.ebean.ExpressionList<T>, sortBy: String, asc: Boolean) {
|
||||||
if (sortBy == IGNORE) return;
|
if (sortBy == IGNORE) return;
|
||||||
val order = if (asc) "ASC" else "DESC"
|
val order = if (asc) "ASC" else "DESC"
|
||||||
@ -232,7 +237,7 @@ fun searchIncomingInventory(
|
|||||||
val q = database.find(IncomingInventory::class.java).where()
|
val q = database.find(IncomingInventory::class.java).where()
|
||||||
applyFromToHelper(q, commonFilters.from, commonFilters.to, "date")
|
applyFromToHelper(q, commonFilters.from, commonFilters.to, "date")
|
||||||
applyVendorHelper(q, commonFilters.vendor)
|
applyVendorHelper(q, commonFilters.vendor)
|
||||||
q.`in`("unloadingPlantId", Session.currentUserPlants().map { it.plantId })
|
applyPlantFilter(q, commonFilters.plant)
|
||||||
applySortHelper(q, commonFilters.sortBy, commonFilters.sortAsc)
|
applySortHelper(q, commonFilters.sortBy, commonFilters.sortAsc)
|
||||||
return q.findList()
|
return q.findList()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,7 +21,7 @@
|
|||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
<!-- SQL and bind values -->
|
<!-- SQL and bind values -->
|
||||||
<logger name="io.ebean.SQL" level="WARN"/>
|
<logger name="io.ebean.SQL" level="DEBUG"/>
|
||||||
<logger name="org.apache.http.client.protocol.ResponseProcessCookies" level="ERROR"/>
|
<logger name="org.apache.http.client.protocol.ResponseProcessCookies" level="ERROR"/>
|
||||||
|
|
||||||
<!-- Transaction Commit and Rollback events -->
|
<!-- Transaction Commit and Rollback events -->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user