| Autore | SHA1 | Messaggio | Data |
|---|---|---|---|
|
|
ad48036eff |
Merge branch 'master' of https://git.2fi-solutions.com/derek/FPSMS-backend
# Conflicts: # src/main/java/com/ffii/fpsms/modules/stock/entity/InventoryLotLineRepository.kt |
1 settimana fa |
|
|
e58fed5dc0 | inventory search page, search by lotNo by scanning QR code | 1 settimana fa |
| @@ -53,11 +53,21 @@ interface InventoryLotLineRepository : AbstractRepository<InventoryLotLine, Long | |||||
| """) | """) | ||||
| fun findByLotNoAndItemId(lotNo: String, itemId: Long): InventoryLotLine? | fun findByLotNoAndItemId(lotNo: String, itemId: Long): InventoryLotLine? | ||||
| <<<<<<< HEAD | |||||
| @Query(""" | |||||
| SELECT DISTINCT ill.inventoryLot.item.id | |||||
| FROM InventoryLotLine ill | |||||
| WHERE ill.deleted = false | |||||
| AND ill.inventoryLot.lotNo = :lotNo | |||||
| """) | |||||
| 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") | @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> | fun findAllByWarehouseIdInAndDeletedIsFalse(@Param("warehouseIds") warehouseIds: List<Long>): List<InventoryLotLine> | ||||
| @@ -21,6 +21,20 @@ interface InventoryRepository: AbstractRepository<Inventory, Long> { | |||||
| "AND i.deleted = false") | "AND i.deleted = false") | ||||
| fun findInventoryInfoByItemCodeContainsAndItemNameContainsAndItemTypeAndDeletedIsFalse(code: String, name: String, type: String, pageable: Pageable): Page<InventoryInfo> | fun findInventoryInfoByItemCodeContainsAndItemNameContainsAndItemTypeAndDeletedIsFalse(code: String, name: String, type: String, pageable: Pageable): Page<InventoryInfo> | ||||
| @Query("SELECT i FROM Inventory i " + | |||||
| "WHERE (:code IS NULL OR i.item.code LIKE CONCAT('%', :code, '%')) " + | |||||
| "AND (:name IS NULL OR i.item.name LIKE CONCAT('%', :name, '%')) " + | |||||
| "AND (:type IS NULL OR :type = '' OR i.item.type = :type) " + | |||||
| "AND i.item.id IN :itemIds " + | |||||
| "AND i.deleted = false") | |||||
| fun findInventoryInfoByItemCodeContainsAndItemNameContainsAndItemTypeAndItemIdInAndDeletedIsFalse( | |||||
| code: String, | |||||
| name: String, | |||||
| type: String, | |||||
| itemIds: List<Long>, | |||||
| pageable: Pageable | |||||
| ): Page<InventoryInfo> | |||||
| fun findInventoryInfoByItemIdInAndDeletedIsFalse(itemIds: List<Serializable>): List<InventoryInfo> | fun findInventoryInfoByItemIdInAndDeletedIsFalse(itemIds: List<Serializable>): List<InventoryInfo> | ||||
| fun findInventoryInfoByItemInAndDeletedIsFalse(items: List<Items>): List<InventoryInfo> | fun findInventoryInfoByItemInAndDeletedIsFalse(items: List<Items>): List<InventoryInfo> | ||||
| @@ -59,13 +59,28 @@ open class InventoryService( | |||||
| open fun allInventoriesByPage(request: SearchInventoryRequest): RecordsRes<InventoryInfo>{ | open fun allInventoriesByPage(request: SearchInventoryRequest): RecordsRes<InventoryInfo>{ | ||||
| val pageable = PageRequest.of(request.pageNum ?: 0, request.pageSize ?: 10) | val pageable = PageRequest.of(request.pageNum ?: 0, request.pageSize ?: 10) | ||||
| val lotNo = request.lotNo?.trim()?.takeIf { it.isNotEmpty() } | |||||
| val response = inventoryRepository.findInventoryInfoByItemCodeContainsAndItemNameContainsAndItemTypeAndDeletedIsFalse( | |||||
| code = request.code, | |||||
| name = request.name, | |||||
| type = request.type, | |||||
| pageable = pageable | |||||
| ) | |||||
| val response = if (lotNo != null) { | |||||
| val itemIds = inventoryLotLineRepository.findDistinctItemIdsByLotNo(lotNo) | |||||
| if (itemIds.isEmpty()) { | |||||
| return RecordsRes(emptyList(), 0) | |||||
| } | |||||
| inventoryRepository.findInventoryInfoByItemCodeContainsAndItemNameContainsAndItemTypeAndItemIdInAndDeletedIsFalse( | |||||
| code = request.code, | |||||
| name = request.name, | |||||
| type = request.type, | |||||
| itemIds = itemIds, | |||||
| pageable = pageable | |||||
| ) | |||||
| } else { | |||||
| inventoryRepository.findInventoryInfoByItemCodeContainsAndItemNameContainsAndItemTypeAndDeletedIsFalse( | |||||
| code = request.code, | |||||
| name = request.name, | |||||
| type = request.type, | |||||
| pageable = pageable | |||||
| ) | |||||
| } | |||||
| val records = response.content | val records = response.content | ||||
| val total = response.totalElements | val total = response.totalElements | ||||
| @@ -4,6 +4,7 @@ data class SearchInventoryRequest( | |||||
| val code: String, | val code: String, | ||||
| val name: String, | val name: String, | ||||
| val type: String, | val type: String, | ||||
| val lotNo: String? = null, | |||||
| val pageNum: Int?, | val pageNum: Int?, | ||||
| val pageSize: Int? | val pageSize: Int? | ||||
| ) | ) | ||||