|
|
@@ -38,6 +38,7 @@ import java.util.HashMap |
|
|
import java.util.Objects |
|
|
import java.util.Objects |
|
|
import kotlin.jvm.optionals.getOrDefault |
|
|
import kotlin.jvm.optionals.getOrDefault |
|
|
import kotlin.jvm.optionals.getOrNull |
|
|
import kotlin.jvm.optionals.getOrNull |
|
|
|
|
|
import com.ffii.fpsms.modules.purchaseOrder.web.model.PurchaseOrderSummary |
|
|
|
|
|
|
|
|
@Service |
|
|
@Service |
|
|
open class PurchaseOrderService( |
|
|
open class PurchaseOrderService( |
|
|
@@ -64,6 +65,48 @@ open class PurchaseOrderService( |
|
|
// sql.append(" AND i.name like :name "); |
|
|
// sql.append(" AND i.name like :name "); |
|
|
// } |
|
|
// } |
|
|
// } |
|
|
// } |
|
|
|
|
|
open fun getPoSummariesByIds(ids: List<Long>): List<PurchaseOrderSummary> { |
|
|
|
|
|
if (ids.isEmpty()) return emptyList() |
|
|
|
|
|
|
|
|
|
|
|
val sql = """ |
|
|
|
|
|
select |
|
|
|
|
|
po.id, |
|
|
|
|
|
po.code, |
|
|
|
|
|
po.status, |
|
|
|
|
|
po.orderDate, |
|
|
|
|
|
po.estimatedArrivalDate, |
|
|
|
|
|
s.name as supplierName, |
|
|
|
|
|
exists( |
|
|
|
|
|
select 1 from stock_in_line sil |
|
|
|
|
|
where sil.purchaseOrderId = po.id |
|
|
|
|
|
and sil.status like 'determine%' |
|
|
|
|
|
and sil.deleted = false |
|
|
|
|
|
) as escalated |
|
|
|
|
|
from purchase_order po |
|
|
|
|
|
left join shop s on s.id = po.supplierId |
|
|
|
|
|
where po.deleted = false |
|
|
|
|
|
and po.id in (:ids) |
|
|
|
|
|
order by po.orderDate desc |
|
|
|
|
|
""".trimIndent() |
|
|
|
|
|
|
|
|
|
|
|
val args = mutableMapOf<String, Any>( |
|
|
|
|
|
"ids" to ids |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
val list = jdbcDao.queryForList(sql, args) |
|
|
|
|
|
|
|
|
|
|
|
return list.map { |
|
|
|
|
|
PurchaseOrderSummary( |
|
|
|
|
|
id = (it["id"] as Number).toLong(), |
|
|
|
|
|
code = it["code"] as String, |
|
|
|
|
|
status = it["status"] as String?, |
|
|
|
|
|
orderDate = it["orderDate"] as LocalDateTime?, |
|
|
|
|
|
estimatedArrivalDate = it["estimatedArrivalDate"] as LocalDateTime?, |
|
|
|
|
|
supplierName = it["supplierName"] as String?, |
|
|
|
|
|
escalated = (it["escalated"] as Boolean?) ?: false, |
|
|
|
|
|
) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
open fun getPoList(args: MutableMap<String, Any>): List<PurchaseOrderDataClass> { |
|
|
open fun getPoList(args: MutableMap<String, Any>): List<PurchaseOrderDataClass> { |
|
|
val sql = StringBuilder( |
|
|
val sql = StringBuilder( |
|
|
"select * from ( " + |
|
|
"select * from ( " + |
|
|
|