| @@ -53,7 +53,6 @@ interface InventoryLotLineRepository : AbstractRepository<InventoryLotLine, Long | |||||
| """) | """) | ||||
| fun findByLotNoAndItemId(lotNo: String, itemId: Long): InventoryLotLine? | fun findByLotNoAndItemId(lotNo: String, itemId: Long): InventoryLotLine? | ||||
| <<<<<<< HEAD | |||||
| @Query(""" | @Query(""" | ||||
| SELECT DISTINCT ill.inventoryLot.item.id | SELECT DISTINCT ill.inventoryLot.item.id | ||||
| FROM InventoryLotLine ill | FROM InventoryLotLine ill | ||||
| @@ -61,41 +60,42 @@ interface InventoryLotLineRepository : AbstractRepository<InventoryLotLine, Long | |||||
| AND ill.inventoryLot.lotNo = :lotNo | AND ill.inventoryLot.lotNo = :lotNo | ||||
| """) | """) | ||||
| fun findDistinctItemIdsByLotNo(@Param("lotNo") lotNo: String): List<Long> | fun findDistinctItemIdsByLotNo(@Param("lotNo") lotNo: String): List<Long> | ||||
| ======= | |||||
| // lotNo + itemId may not be unique (multiple warehouses/lines); pick one deterministically | // lotNo + itemId may not be unique (multiple warehouses/lines); pick one deterministically | ||||
| fun findFirstByInventoryLotLotNoAndInventoryLotItemIdAndDeletedFalseOrderByIdDesc( | fun findFirstByInventoryLotLotNoAndInventoryLotItemIdAndDeletedFalseOrderByIdDesc( | ||||
| lotNo: String, | lotNo: String, | ||||
| itemId: Long | itemId: Long | ||||
| ): InventoryLotLine? | ): InventoryLotLine? | ||||
| >>>>>>> 9760717ed6a5c59383467921464fb2b89a7f85a8 | |||||
| // InventoryLotLineRepository.kt 中添加 | // InventoryLotLineRepository.kt 中添加 | ||||
| @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") | |||||
| fun findAllByWarehouseIdInAndDeletedIsFalse(@Param("warehouseIds") warehouseIds: List<Long>): List<InventoryLotLine> | |||||
| @Query(""" | |||||
| @Query(""" | |||||
| SELECT ill FROM InventoryLotLine ill | SELECT ill FROM InventoryLotLine ill | ||||
| WHERE ill.warehouse.code = :warehouseCode | WHERE ill.warehouse.code = :warehouseCode | ||||
| AND ill.deleted = false | AND ill.deleted = false | ||||
| ORDER BY ill.inventoryLot.item.code, ill.inventoryLot.lotNo | ORDER BY ill.inventoryLot.item.code, ill.inventoryLot.lotNo | ||||
| """) | """) | ||||
| fun findAllByWarehouseCodeAndDeletedIsFalse(@Param("warehouseCode") warehouseCode: String): List<InventoryLotLine> | |||||
| @Query(""" | |||||
| fun findAllByWarehouseCodeAndDeletedIsFalse(@Param("warehouseCode") warehouseCode: String): List<InventoryLotLine> | |||||
| @Query(""" | |||||
| SELECT COUNT(DISTINCT ill.inventoryLot.item.id) | SELECT COUNT(DISTINCT ill.inventoryLot.item.id) | ||||
| FROM InventoryLotLine ill | FROM InventoryLotLine ill | ||||
| WHERE ill.warehouse.id IN :warehouseIds | WHERE ill.warehouse.id IN :warehouseIds | ||||
| AND ill.deleted = false | AND ill.deleted = false | ||||
| """) | """) | ||||
| fun countDistinctItemsByWarehouseIds(@Param("warehouseIds") warehouseIds: List<Long>): Long | |||||
| fun countDistinctItemsByWarehouseIds(@Param("warehouseIds") warehouseIds: List<Long>): Long | |||||
| @Query(""" | |||||
| @Query(""" | |||||
| SELECT COUNT(ill.id) | SELECT COUNT(ill.id) | ||||
| FROM InventoryLotLine ill | FROM InventoryLotLine ill | ||||
| WHERE ill.warehouse.id IN :warehouseIds | WHERE ill.warehouse.id IN :warehouseIds | ||||
| AND ill.deleted = false | AND ill.deleted = false | ||||
| """) | """) | ||||
| fun countAllByWarehouseIds(@Param("warehouseIds") warehouseIds: List<Long>): Long | |||||
| fun countAllByWarehouseIds(@Param("warehouseIds") warehouseIds: List<Long>): Long | |||||
| @Query(""" | |||||
| @Query(""" | |||||
| SELECT ill FROM InventoryLotLine ill | SELECT ill FROM InventoryLotLine ill | ||||
| JOIN ill.inventoryLot il | JOIN ill.inventoryLot il | ||||
| WHERE il.expiryDate < :today | WHERE il.expiryDate < :today | ||||
| @@ -103,7 +103,7 @@ fun countAllByWarehouseIds(@Param("warehouseIds") warehouseIds: List<Long>): Lon | |||||
| AND ill.deleted = false | AND ill.deleted = false | ||||
| ORDER BY il.expiryDate ASC | ORDER BY il.expiryDate ASC | ||||
| """) | """) | ||||
| fun findExpiredItems(@Param("today") today: LocalDate): List<InventoryLotLine> | |||||
| fun findExpiredItems(@Param("today") today: LocalDate): List<InventoryLotLine> | |||||
| @Query(""" | @Query(""" | ||||
| SELECT ill FROM InventoryLotLine ill | SELECT ill FROM InventoryLotLine ill | ||||
| @@ -131,7 +131,7 @@ fun findExpiredItems(@Param("today") today: LocalDate): List<InventoryLotLine> | |||||
| AND il.stockInLine IS NOT NULL | AND il.stockInLine IS NOT NULL | ||||
| ORDER BY w.store_id, il.item.code, il.lotNo | ORDER BY w.store_id, il.item.code, il.lotNo | ||||
| """) | """) | ||||
| fun findAllByStoreIdsAndHasStockInLine( | |||||
| @Param("storeIds") storeIds: List<String> | |||||
| ): List<InventoryLotLine> | |||||
| fun findAllByStoreIdsAndHasStockInLine( | |||||
| @Param("storeIds") storeIds: List<String> | |||||
| ): List<InventoryLotLine> | |||||
| } | } | ||||