|
|
|
@@ -107,7 +107,10 @@ open fun getPoSummariesByIds(ids: List<Long>): List<PurchaseOrderSummary> { |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
open fun getPoList(args: MutableMap<String, Any>): List<PurchaseOrderDataClass> { |
|
|
|
/** |
|
|
|
* `select * from ( ... one row per PO ... ) r [where r.itemDetail ...]` — same as the legacy list query, without LIMIT. |
|
|
|
*/ |
|
|
|
private fun buildPoListUnpagedSelectSql(args: MutableMap<String, Any>): String { |
|
|
|
val sql = StringBuilder( |
|
|
|
"select * from ( " + |
|
|
|
"select " + |
|
|
|
@@ -211,9 +214,11 @@ open fun getPoSummariesByIds(ids: List<Long>): List<PurchaseOrderSummary> { |
|
|
|
if (args.containsKey("itemDetail")){ |
|
|
|
sql.append(" where r.itemDetail like :itemDetail "); |
|
|
|
} |
|
|
|
val list = jdbcDao.queryForList(sql.toString(), args); |
|
|
|
return sql.toString() |
|
|
|
} |
|
|
|
|
|
|
|
val mappedList = list.map { |
|
|
|
private fun mapRowsToPoListDataClass(list: List<Map<String, Any>>): List<PurchaseOrderDataClass> { |
|
|
|
return list.map { |
|
|
|
PurchaseOrderDataClass( |
|
|
|
id = (it["id"] as Int).toLong(), |
|
|
|
code = it["code"] as String, |
|
|
|
@@ -231,11 +236,32 @@ open fun getPoSummariesByIds(ids: List<Long>): List<PurchaseOrderSummary> { |
|
|
|
escalated = it["escalated"] == 1L, |
|
|
|
) |
|
|
|
} |
|
|
|
// println(value1) |
|
|
|
// println(value1 == 1L) |
|
|
|
// println(value2) |
|
|
|
// println(mappedList) |
|
|
|
return mappedList |
|
|
|
} |
|
|
|
|
|
|
|
open fun getPoListTotalCount(args: MutableMap<String, Any>): Int { |
|
|
|
val base = buildPoListUnpagedSelectSql(args) |
|
|
|
val countSql = "SELECT COUNT(1) AS cnt FROM ( $base ) po_list_count_wrap" |
|
|
|
val list = jdbcDao.queryForList(countSql, args) |
|
|
|
if (list.isEmpty()) { |
|
|
|
return 0 |
|
|
|
} |
|
|
|
return (list.first()["cnt"] as Number).toInt() |
|
|
|
} |
|
|
|
|
|
|
|
open fun getPoListPage( |
|
|
|
args: MutableMap<String, Any>, |
|
|
|
pageSize: Int, |
|
|
|
pageNum: Int, |
|
|
|
): List<PurchaseOrderDataClass> { |
|
|
|
val size = pageSize.coerceAtLeast(1) |
|
|
|
val page = pageNum.coerceAtLeast(1) |
|
|
|
val pagedArgs: MutableMap<String, Any> = HashMap(args) |
|
|
|
pagedArgs["limit"] = size |
|
|
|
pagedArgs["offset"] = (page - 1) * size |
|
|
|
val dataSql = buildPoListUnpagedSelectSql(args) + |
|
|
|
" ORDER BY r.orderDate DESC LIMIT :limit OFFSET :offset" |
|
|
|
val list = jdbcDao.queryForList(dataSql, pagedArgs) |
|
|
|
return mapRowsToPoListDataClass(list) |
|
|
|
} |
|
|
|
|
|
|
|
open fun allPurchaseOrder(): List<PurchaseOrder> { |
|
|
|
|