| @@ -1,13 +1,33 @@ | |||||
| package com.ffii.fpsms.modules.master.entity | package com.ffii.fpsms.modules.master.entity | ||||
| import com.ffii.core.support.AbstractRepository | import com.ffii.core.support.AbstractRepository | ||||
| import org.springframework.data.jpa.repository.Query | |||||
| import org.springframework.data.repository.query.Param | |||||
| import org.springframework.stereotype.Repository | import org.springframework.stereotype.Repository | ||||
| import java.util.Optional | import java.util.Optional | ||||
| interface BomDurationAggregate { | |||||
| val bomId: Long | |||||
| val totalMinutes: Long | |||||
| } | |||||
| @Repository | @Repository | ||||
| interface BomProcessRepository : AbstractRepository<BomProcess, Long> { | interface BomProcessRepository : AbstractRepository<BomProcess, Long> { | ||||
| fun findBySeqNoAndBomIdAndDeletedIsFalse(seqNo: Int, bomId: Long): BomProcess? | fun findBySeqNoAndBomIdAndDeletedIsFalse(seqNo: Int, bomId: Long): BomProcess? | ||||
| fun findByBomIdOrderBySeqNo(bomId: Long): List<BomProcess> | fun findByBomIdOrderBySeqNo(bomId: Long): List<BomProcess> | ||||
| fun findByBomId(bomId: Long): List<BomProcess> | fun findByBomId(bomId: Long): List<BomProcess> | ||||
| fun findAllByBomIdAndDeletedFalse(bomId: Long): List<BomProcess> | fun findAllByBomIdAndDeletedFalse(bomId: Long): List<BomProcess> | ||||
| @Query( | |||||
| """ | |||||
| SELECT | |||||
| bp.bom.id AS bomId, | |||||
| COALESCE(SUM(COALESCE(bp.durationInMinute, 0)), 0) AS totalMinutes | |||||
| FROM BomProcess bp | |||||
| WHERE bp.deleted = false | |||||
| AND bp.bom.id IN :bomIds | |||||
| GROUP BY bp.bom.id | |||||
| """ | |||||
| ) | |||||
| fun sumDurationByBomIds(@Param("bomIds") bomIds: Collection<Long>): List<BomDurationAggregate> | |||||
| } | } | ||||
| @@ -32,6 +32,7 @@ interface ItemUomRespository : AbstractRepository<ItemUom, Long> { | |||||
| fun findByItemIdAndUomIdAndStockUnitAndDeletedIsFalse(itemId: Long, uomId: Long, stockUnit: Boolean): ItemUom? | fun findByItemIdAndUomIdAndStockUnitAndDeletedIsFalse(itemId: Long, uomId: Long, stockUnit: Boolean): ItemUom? | ||||
| fun findFirstByItemIdAndStockUnitIsTrueAndDeletedIsFalseOrderByIdAsc(itemId: Long): ItemUom? | fun findFirstByItemIdAndStockUnitIsTrueAndDeletedIsFalseOrderByIdAsc(itemId: Long): ItemUom? | ||||
| fun findAllByItemIdInAndStockUnitIsTrueAndDeletedIsFalse(itemIds: Collection<Long>): List<ItemUom> | |||||
| @Query( | @Query( | ||||
| """ | """ | ||||
| @@ -13,6 +13,7 @@ interface UomConversionRepository : AbstractRepository<UomConversion, Long> { | |||||
| fun findByCodeAndDeletedFalse(code: String): UomConversion?; | fun findByCodeAndDeletedFalse(code: String): UomConversion?; | ||||
| fun findByM18IdAndDeletedFalse(m18Id: Long): UomConversion?; | fun findByM18IdAndDeletedFalse(m18Id: Long): UomConversion?; | ||||
| fun findAllByIdInAndDeletedFalse(ids: Collection<Long>): List<UomConversion> | |||||
| fun findByLastModifyDateAndM18IdAndDeletedFalse(lastModifyDate: LocalDateTime, m18Id: Long): UomConversion?; | fun findByLastModifyDateAndM18IdAndDeletedFalse(lastModifyDate: LocalDateTime, m18Id: Long): UomConversion?; | ||||
| fun findByUdfudescAndDeletedFalse(udfudesc: String): UomConversion?; | fun findByUdfudescAndDeletedFalse(udfudesc: String): UomConversion?; | ||||
| @@ -93,6 +93,7 @@ interface PickOrderRepository : AbstractRepository<PickOrder, Long> { | |||||
| fun findAllByStatusAndAssignToIsNullAndDeletedFalse(status: PickOrderStatus): List<PickOrder> | fun findAllByStatusAndAssignToIsNullAndDeletedFalse(status: PickOrderStatus): List<PickOrder> | ||||
| //fun findAllByJoid(jobOrderId: Long): List<PickOrder> | //fun findAllByJoid(jobOrderId: Long): List<PickOrder> | ||||
| fun findAllByJobOrder_Id(jobOrderId: Long): List<PickOrder> | fun findAllByJobOrder_Id(jobOrderId: Long): List<PickOrder> | ||||
| fun findAllByJobOrder_IdInAndDeletedFalseOrderByJobOrder_IdAscCreatedDesc(jobOrderIds: Collection<Long>): List<PickOrder> | |||||
| fun findTopByJobOrder_IdOrderByCreatedDesc(jobOrderId: Long): PickOrder? | fun findTopByJobOrder_IdOrderByCreatedDesc(jobOrderId: Long): PickOrder? | ||||
| fun findAllByStatusIn(statuses: List<PickOrderStatus>): List<PickOrder> | fun findAllByStatusIn(statuses: List<PickOrderStatus>): List<PickOrder> | ||||