2 次代码提交

作者 SHA1 备注 提交日期
  kelvin.yau ad48036eff Merge branch 'master' of https://git.2fi-solutions.com/derek/FPSMS-backend 4 天前
  kelvin.yau e58fed5dc0 inventory search page, search by lotNo by scanning QR code 4 天前
共有 4 个文件被更改,包括 46 次插入6 次删除
  1. +10
    -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

+ 10
- 0
src/main/java/com/ffii/fpsms/modules/stock/entity/InventoryLotLineRepository.kt 查看文件

@@ -53,11 +53,21 @@ interface InventoryLotLineRepository : AbstractRepository<InventoryLotLine, Long
""")
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
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<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?
)

正在加载...
取消
保存