diff --git a/src/main/java/com/ffii/fpsms/modules/stock/entity/InventoryLotLineRepository.kt b/src/main/java/com/ffii/fpsms/modules/stock/entity/InventoryLotLineRepository.kt index f94b494..91f8479 100644 --- a/src/main/java/com/ffii/fpsms/modules/stock/entity/InventoryLotLineRepository.kt +++ b/src/main/java/com/ffii/fpsms/modules/stock/entity/InventoryLotLineRepository.kt @@ -53,7 +53,6 @@ interface InventoryLotLineRepository : AbstractRepository -======= + // lotNo + itemId may not be unique (multiple warehouses/lines); pick one deterministically fun findFirstByInventoryLotLotNoAndInventoryLotItemIdAndDeletedFalseOrderByIdDesc( lotNo: String, itemId: Long ): InventoryLotLine? ->>>>>>> 9760717ed6a5c59383467921464fb2b89a7f85a8 + // InventoryLotLineRepository.kt 中添加 -@Query("SELECT ill FROM InventoryLotLine ill WHERE ill.warehouse.id IN :warehouseIds AND ill.deleted = false") -fun findAllByWarehouseIdInAndDeletedIsFalse(@Param("warehouseIds") warehouseIds: List): List + @Query("SELECT ill FROM InventoryLotLine ill WHERE ill.warehouse.id IN :warehouseIds AND ill.deleted = false") + fun findAllByWarehouseIdInAndDeletedIsFalse(@Param("warehouseIds") warehouseIds: List): List -@Query(""" + @Query(""" SELECT ill FROM InventoryLotLine ill WHERE ill.warehouse.code = :warehouseCode AND ill.deleted = false ORDER BY ill.inventoryLot.item.code, ill.inventoryLot.lotNo """) -fun findAllByWarehouseCodeAndDeletedIsFalse(@Param("warehouseCode") warehouseCode: String): List -@Query(""" + fun findAllByWarehouseCodeAndDeletedIsFalse(@Param("warehouseCode") warehouseCode: String): List + + @Query(""" SELECT COUNT(DISTINCT ill.inventoryLot.item.id) FROM InventoryLotLine ill WHERE ill.warehouse.id IN :warehouseIds AND ill.deleted = false """) -fun countDistinctItemsByWarehouseIds(@Param("warehouseIds") warehouseIds: List): Long + fun countDistinctItemsByWarehouseIds(@Param("warehouseIds") warehouseIds: List): Long -@Query(""" + @Query(""" SELECT COUNT(ill.id) FROM InventoryLotLine ill WHERE ill.warehouse.id IN :warehouseIds AND ill.deleted = false """) -fun countAllByWarehouseIds(@Param("warehouseIds") warehouseIds: List): Long + fun countAllByWarehouseIds(@Param("warehouseIds") warehouseIds: List): Long -@Query(""" + @Query(""" SELECT ill FROM InventoryLotLine ill JOIN ill.inventoryLot il WHERE il.expiryDate < :today @@ -103,7 +103,7 @@ fun countAllByWarehouseIds(@Param("warehouseIds") warehouseIds: List): Lon AND ill.deleted = false ORDER BY il.expiryDate ASC """) -fun findExpiredItems(@Param("today") today: LocalDate): List + fun findExpiredItems(@Param("today") today: LocalDate): List @Query(""" SELECT ill FROM InventoryLotLine ill @@ -131,7 +131,7 @@ fun findExpiredItems(@Param("today") today: LocalDate): List AND il.stockInLine IS NOT NULL ORDER BY w.store_id, il.item.code, il.lotNo """) -fun findAllByStoreIdsAndHasStockInLine( - @Param("storeIds") storeIds: List -): List + fun findAllByStoreIdsAndHasStockInLine( + @Param("storeIds") storeIds: List + ): List } \ No newline at end of file