@@ -8,6 +8,7 @@ import org.springframework.data.domain.Pageable | |||||
import org.springframework.data.jpa.repository.Query | import org.springframework.data.jpa.repository.Query | ||||
import org.springframework.data.repository.query.Param | import org.springframework.data.repository.query.Param | ||||
import org.springframework.stereotype.Repository | import org.springframework.stereotype.Repository | ||||
import java.io.Serializable | |||||
import java.time.LocalDateTime | import java.time.LocalDateTime | ||||
@Repository | @Repository | ||||
@@ -22,10 +23,10 @@ interface PickOrderRepository : AbstractRepository<PickOrder, Long> { | |||||
and (:targetDateTo is null or po.targetDate <= :targetDateTo) | and (:targetDateTo is null or po.targetDate <= :targetDateTo) | ||||
and (lower(:type) = 'all' or lower(po.type) like concat('%',lower(:type),'%')) | and (lower(:type) = 'all' or lower(po.type) like concat('%',lower(:type),'%')) | ||||
and (lower(:status) = 'all' or lower(po.status) like concat('%',lower(:status),'%')) | and (lower(:status) = 'all' or lower(po.status) like concat('%',lower(:status),'%')) | ||||
and (lower(:items) = 'all' or exists ( | |||||
and (lower(:itemName) = 'all' or exists ( | |||||
select 1 from PickOrderLine pol | select 1 from PickOrderLine pol | ||||
where pol.pickOrder = po | where pol.pickOrder = po | ||||
and (lower(:items) = 'all' or lower(pol.item.name) like concat('%',lower(:items),'%')) | |||||
and (lower(:itemName) = 'all' or lower(pol.item.name) like concat('%',lower(:itemName),'%')) | |||||
) | ) | ||||
) | ) | ||||
and po.deleted = false | and po.deleted = false | ||||
@@ -37,7 +38,13 @@ interface PickOrderRepository : AbstractRepository<PickOrder, Long> { | |||||
targetDateTo: LocalDateTime?, | targetDateTo: LocalDateTime?, | ||||
type: String, | type: String, | ||||
status: String, | status: String, | ||||
items: String, | |||||
itemName: String, | |||||
pageable: Pageable, | pageable: Pageable, | ||||
): Page<PickOrderInfo> | ): Page<PickOrderInfo> | ||||
@Query(""" | |||||
select po.consoCode from PickOrder po where po.consoCode like :prefix% order by po.consoCode desc limit 1 | |||||
""") | |||||
fun findLatestConsoCodeByPrefix(prefix: String): String? | |||||
fun findAllByIdIn(id: List<Serializable>): List<PickOrder> | |||||
} | } |
@@ -6,6 +6,7 @@ import com.ffii.fpsms.modules.pickOrder.entity.projection.PickOrderInfo | |||||
import com.ffii.fpsms.modules.pickOrder.web.models.SearchPickOrderRequest | import com.ffii.fpsms.modules.pickOrder.web.models.SearchPickOrderRequest | ||||
import org.springframework.data.domain.PageRequest | import org.springframework.data.domain.PageRequest | ||||
import org.springframework.stereotype.Service | import org.springframework.stereotype.Service | ||||
import java.time.LocalDate | |||||
import java.time.LocalDateTime | import java.time.LocalDateTime | ||||
import java.time.format.DateTimeFormatter | import java.time.format.DateTimeFormatter | ||||
@@ -35,7 +36,7 @@ open class PickOrderService( | |||||
targetDateTo = LocalDateTimeParse(request.targetDateTo), | targetDateTo = LocalDateTimeParse(request.targetDateTo), | ||||
type = request.type ?: "all", | type = request.type ?: "all", | ||||
status = request.status ?: "all", | status = request.status ?: "all", | ||||
items = request.items ?: "all", | |||||
itemName = request.itemName ?: "all", | |||||
pageable = pageable | pageable = pageable | ||||
) | ) | ||||
@@ -45,6 +46,28 @@ open class PickOrderService( | |||||
} | } | ||||
// Consolidating Pick Orders | // Consolidating Pick Orders | ||||
open fun assignConsoCode(): String { | |||||
val suffixFormat = "%03d" | |||||
val pattern = "YYYYMMDD" | |||||
val formatter = DateTimeFormatter.ofPattern(pattern) | |||||
val prefix = "PICK" | |||||
val midfix = LocalDate.now().format(formatter) | |||||
val suffix = String.format(suffixFormat, 1) | |||||
val latestConsoCode = pickOrderRepository.findLatestConsoCodeByPrefix("${prefix}-${midfix}") | |||||
if (latestConsoCode != null) { | |||||
val splitLatestConsoCode = latestConsoCode.split("-") | |||||
if (splitLatestConsoCode.size > 2) { | |||||
val latestNo = splitLatestConsoCode[2].toInt() | |||||
return listOf<String>(prefix, midfix, String.format(suffixFormat, latestNo + 1)).joinToString("-") | |||||
} | |||||
} | |||||
return listOf<String>(prefix, midfix, suffix).joinToString("-") | |||||
} | |||||
open fun consoPickOrders() { | open fun consoPickOrders() { | ||||
} | } |
@@ -0,0 +1,5 @@ | |||||
package com.ffii.fpsms.modules.pickOrder.web.models | |||||
data class ConsoPickOrderRequest ( | |||||
val ids: List<Long> | |||||
) |
@@ -8,7 +8,7 @@ data class SearchPickOrderRequest ( | |||||
val targetDateTo: String?, | val targetDateTo: String?, | ||||
val type: String?, | val type: String?, | ||||
val status: String?, | val status: String?, | ||||
val items: String?, | |||||
val itemName: String?, | |||||
val pageSize: Int?, | val pageSize: Int?, | ||||
val pageNum: Int?, | val pageNum: Int?, | ||||
) | ) |