コミットを比較

...

1 コミット

作成者 SHA1 メッセージ 日付
  kelvin.yau 59757eeacf New PO Workbench, Improve loading speed. 1週間前
2個のファイルの変更42行の追加15行の削除
分割表示
  1. +34
    -8
      src/main/java/com/ffii/fpsms/modules/purchaseOrder/service/PurchaseOrderService.kt
  2. +8
    -7
      src/main/java/com/ffii/fpsms/modules/purchaseOrder/web/PurchaseOrderController.kt

+ 34
- 8
src/main/java/com/ffii/fpsms/modules/purchaseOrder/service/PurchaseOrderService.kt ファイルの表示

@@ -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> {


+ 8
- 7
src/main/java/com/ffii/fpsms/modules/purchaseOrder/web/PurchaseOrderController.kt ファイルの表示

@@ -3,7 +3,6 @@ package com.ffii.fpsms.modules.purchaseOrder.web
import com.ffii.core.response.RecordsRes
import com.ffii.core.support.JdbcDao
import com.ffii.core.utils.CriteriaArgsBuilder
import com.ffii.core.utils.PagingUtils
import com.ffii.core.utils.ZebraPrinterUtil
import com.ffii.fpsms.modules.master.entity.Items
import com.ffii.fpsms.modules.master.service.ItemsService
@@ -49,13 +48,15 @@ class PurchaseOrderController(
.addDate("estimatedArrivalDateTo")
.build()
// println(criteriaArgs)
val pageSize = request.getParameter("pageSize")?.toIntOrNull() ?: 10
val pageNum = request.getParameter("pageNum")?.toIntOrNull() ?: 1
val pageSize = request.getParameter("pageSize")?.toIntOrNull()?.coerceAtLeast(1) ?: 10
val pageNum = request.getParameter("pageNum")?.toIntOrNull()?.coerceAtLeast(1) ?: 1

val fullList = purchaseOrderService.getPoList(criteriaArgs)
val paginatedList = PagingUtils.getPaginatedList(fullList,pageSize, pageNum)

return RecordsRes(paginatedList, fullList.size)
val total = purchaseOrderService.getPoListTotalCount(criteriaArgs)
if (total == 0) {
return RecordsRes(emptyList<PurchaseOrderDataClass>(), 0)
}
val pageRows = purchaseOrderService.getPoListPage(criteriaArgs, pageSize, pageNum)
return RecordsRes(pageRows, total)
}
/** Class mapping is `/po`; path must be `/summary` → full path `/api/po/summary` (not `/po/po/summary`). */
@GetMapping("/summary")


読み込み中…
キャンセル
保存