|
|
|
@@ -13,6 +13,7 @@ import java.io.Serializable |
|
|
|
import com.ffii.fpsms.modules.stock.entity.enum.InventoryLotLineStatus |
|
|
|
import org.springframework.data.repository.query.Param |
|
|
|
import java.time.LocalDate |
|
|
|
import org.springframework.data.jpa.repository.EntityGraph |
|
|
|
@Repository |
|
|
|
interface InventoryLotLineRepository : AbstractRepository<InventoryLotLine, Long> { |
|
|
|
|
|
|
|
@@ -69,11 +70,31 @@ interface InventoryLotLineRepository : AbstractRepository<InventoryLotLine, Long |
|
|
|
itemId: Long |
|
|
|
): InventoryLotLine? |
|
|
|
|
|
|
|
// InventoryLotLineRepository.kt 中添加 |
|
|
|
@EntityGraph( |
|
|
|
type = EntityGraph.EntityGraphType.FETCH, |
|
|
|
attributePaths = [ |
|
|
|
"inventoryLot", |
|
|
|
"inventoryLot.item", // important: two levels deep |
|
|
|
"warehouse", |
|
|
|
"stockUom", |
|
|
|
"stockUom.uom" // if uom is a relation inside ItemUom |
|
|
|
] |
|
|
|
) |
|
|
|
@Query("SELECT ill FROM InventoryLotLine ill WHERE ill.warehouse.id IN :warehouseIds AND ill.deleted = false") |
|
|
|
fun findAllByWarehouseIdInAndDeletedIsFalse(@Param("warehouseIds") warehouseIds: List<Long>): List<InventoryLotLine> |
|
|
|
|
|
|
|
@Query("SELECT ill FROM InventoryLotLine ill WHERE ill.warehouse.id IN :warehouseIds AND ill.deleted = false AND ill.status = 'available'") |
|
|
|
|
|
|
|
// You can also add another one for the status filter if needed |
|
|
|
@EntityGraph( |
|
|
|
type = EntityGraph.EntityGraphType.FETCH, |
|
|
|
attributePaths = ["inventoryLot", "inventoryLot.item", "warehouse", "stockUom", "stockUom.uom"] |
|
|
|
) |
|
|
|
@Query(""" |
|
|
|
SELECT ill |
|
|
|
FROM InventoryLotLine ill |
|
|
|
WHERE ill.warehouse.id IN :warehouseIds |
|
|
|
AND ill.deleted = false |
|
|
|
AND ill.status = 'available' |
|
|
|
""") |
|
|
|
fun findAllByWarehouseIdInAndDeletedIsFalseAndStatusIsAvailable(@Param("warehouseIds") warehouseIds: List<Long>): List<InventoryLotLine> |
|
|
|
|
|
|
|
@Query(""" |
|
|
|
@@ -95,6 +116,7 @@ interface InventoryLotLineRepository : AbstractRepository<InventoryLotLine, Long |
|
|
|
""") |
|
|
|
fun findAllByWarehouseCodeAndDeletedIsFalse(@Param("warehouseCode") warehouseCode: String): List<InventoryLotLine> |
|
|
|
|
|
|
|
|
|
|
|
@Query(""" |
|
|
|
SELECT COUNT(DISTINCT ill.inventoryLot.item.id) |
|
|
|
FROM InventoryLotLine ill |
|
|
|
|