Преглед на файлове

inventory search page, search by lotNo by scanning QR code

master
kelvin.yau преди 4 дни
родител
ревизия
e58fed5dc0
променени са 4 файла, в които са добавени 44 реда и са изтрити 6 реда
  1. +8
    -0
      src/main/java/com/ffii/fpsms/modules/stock/entity/InventoryLotLineRepository.kt
  2. +14
    -0
      src/main/java/com/ffii/fpsms/modules/stock/entity/InventoryRepository.kt
  3. +21
    -6
      src/main/java/com/ffii/fpsms/modules/stock/service/InventoryService.kt
  4. +1
    -0
      src/main/java/com/ffii/fpsms/modules/stock/web/model/SearchInventoryRequest.kt

+ 8
- 0
src/main/java/com/ffii/fpsms/modules/stock/entity/InventoryLotLineRepository.kt Целия файл

@@ -52,6 +52,14 @@ interface InventoryLotLineRepository : AbstractRepository<InventoryLotLine, Long
AND ill.deleted = false
""")
fun findByLotNoAndItemId(lotNo: String, itemId: Long): InventoryLotLine?

@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>
// 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>


+ 14
- 0
src/main/java/com/ffii/fpsms/modules/stock/entity/InventoryRepository.kt Целия файл

@@ -21,6 +21,20 @@ interface InventoryRepository: AbstractRepository<Inventory, Long> {
"AND i.deleted = false")
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 findInventoryInfoByItemInAndDeletedIsFalse(items: List<Items>): List<InventoryInfo>


+ 21
- 6
src/main/java/com/ffii/fpsms/modules/stock/service/InventoryService.kt Целия файл

@@ -59,13 +59,28 @@ open class InventoryService(

open fun allInventoriesByPage(request: SearchInventoryRequest): RecordsRes<InventoryInfo>{
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 total = response.totalElements


+ 1
- 0
src/main/java/com/ffii/fpsms/modules/stock/web/model/SearchInventoryRequest.kt Целия файл

@@ -4,6 +4,7 @@ data class SearchInventoryRequest(
val code: String,
val name: String,
val type: String,
val lotNo: String? = null,
val pageNum: Int?,
val pageSize: Int?
)

Зареждане…
Отказ
Запис