Selaa lähdekoodia

[Inventory] Update Inventory

master
cyril.tsui 1 kuukausi sitten
vanhempi
commit
6d0beb5ebe
10 muutettua tiedostoa jossa 94 lisäystä ja 19 poistoa
  1. +5
    -0
      src/main/java/com/ffii/fpsms/modules/stock/entity/InventoryLotLineRepository.kt
  2. +4
    -0
      src/main/java/com/ffii/fpsms/modules/stock/entity/InventoryRepository.kt
  3. +5
    -1
      src/main/java/com/ffii/fpsms/modules/stock/entity/projection/InventoryInfo.kt
  4. +12
    -1
      src/main/java/com/ffii/fpsms/modules/stock/entity/projection/InventoryLotLineInfo.kt
  5. +13
    -2
      src/main/java/com/ffii/fpsms/modules/stock/service/InventoryLotLineService.kt
  6. +19
    -8
      src/main/java/com/ffii/fpsms/modules/stock/service/InventoryService.kt
  7. +8
    -0
      src/main/java/com/ffii/fpsms/modules/stock/web/InventoryController.kt
  8. +12
    -7
      src/main/java/com/ffii/fpsms/modules/stock/web/InventoryLotLineController.kt
  9. +7
    -0
      src/main/java/com/ffii/fpsms/modules/stock/web/model/SearchInventoryLotLineInfoRequest.kt
  10. +9
    -0
      src/main/java/com/ffii/fpsms/modules/stock/web/model/SearchInventoryRequest.kt

+ 5
- 0
src/main/java/com/ffii/fpsms/modules/stock/entity/InventoryLotLineRepository.kt Näytä tiedosto

@@ -3,6 +3,8 @@ package com.ffii.fpsms.modules.stock.entity
import com.ffii.core.support.AbstractRepository
import com.ffii.fpsms.modules.stock.entity.projection.CurrentInventoryItemInfo
import com.ffii.fpsms.modules.stock.entity.projection.InventoryLotLineInfo
import org.springframework.data.domain.Page
import org.springframework.data.domain.Pageable
import org.springframework.data.jpa.repository.Query
import org.springframework.stereotype.Repository
import java.io.Serializable
@@ -11,6 +13,9 @@ import java.io.Serializable
interface InventoryLotLineRepository : AbstractRepository<InventoryLotLine, Long> {
fun findInventoryLotLineInfoByInventoryLotItemIdIn(ids: List<Serializable>): List<InventoryLotLineInfo>

@Query("select ill from InventoryLotLine ill where :id is null or ill.inventoryLot.item.id = :id")
fun findInventoryLotLineInfoByItemId(id: Long?, pageable: Pageable): Page<InventoryLotLineInfo>

@Query("""
select
i.id as id,


+ 4
- 0
src/main/java/com/ffii/fpsms/modules/stock/entity/InventoryRepository.kt Näytä tiedosto

@@ -3,6 +3,8 @@ package com.ffii.fpsms.modules.stock.entity
import com.ffii.core.support.AbstractRepository
import com.ffii.fpsms.modules.master.entity.Items
import com.ffii.fpsms.modules.stock.entity.projection.InventoryInfo
import org.springframework.data.domain.Page
import org.springframework.data.domain.Pageable
import org.springframework.stereotype.Repository
import java.io.Serializable
import java.util.Optional
@@ -11,6 +13,8 @@ import java.util.Optional
interface InventoryRepository: AbstractRepository<Inventory, Long> {
fun findInventoryInfoByDeletedIsFalse(): List<InventoryInfo>

fun findInventoryInfoByItemCodeContainsAndItemNameContainsAndItemTypeContainsAndDeletedIsFalse(code: String, name: String, type: String, pageable: Pageable): Page<InventoryInfo>

fun findInventoryInfoByItemIdInAndDeletedIsFalse(itemIds: List<Serializable>): List<InventoryInfo>

fun findInventoryInfoByItemInAndDeletedIsFalse(items: List<Items>): List<InventoryInfo>


+ 5
- 1
src/main/java/com/ffii/fpsms/modules/stock/entity/projection/InventoryInfo.kt Näytä tiedosto

@@ -26,8 +26,12 @@ interface InventoryInfo{
val uomCode: String?
@get:Value("#{target.item.itemUoms.^[purchaseUnit == true && deleted == false]?.uom.udfudesc}")
val uomUdfudesc: String?
// @get:Value("#{target.qty * target.uom.gramPerSmallestUnit}")
// @get:Value("#{target.qty * target.uom.gramPerSmallestUnit}")
// val germPerSmallestUnit: BigDecimal?
@get:Value("#{(target.onHandQty - target.onHoldQty - target.unavailableQty)}")
val qtyPerSmallestUnit: BigDecimal?
@get:Value("#{target.item.itemUoms.^[baseUnit == true && deleted == false]?.uom.udfudesc}")
val baseUom: String?
// @get:Value("#{target.qty * (target.uom.unit4 != '' ? target.uom.unit4Qty " +
// ": target.uom.unit3 != '' ? target.uom.unit3Qty " +
// ": target.uom.unit2 != '' ? target.uom.unit2Qty " +


+ 12
- 1
src/main/java/com/ffii/fpsms/modules/stock/entity/projection/InventoryLotLineInfo.kt Näytä tiedosto

@@ -8,6 +8,7 @@ interface InventoryLotLineItemInfo {
val id: Long
val code: String
val name: String
val type: String
}

interface InventoryLotLineWarehouseInfo {
@@ -20,13 +21,23 @@ interface InventoryLotLineWarehouseInfo {

interface InventoryLotLineInfo {
val id: Long?

@get:Value("#{target.inventoryLot.lotNo}")
val lotNo: String?
@get:Value("#{target.inventoryLot.item}")
val item: InventoryLotLineItemInfo?
val warehouse: InventoryLotLineWarehouseInfo?
@get:Value("#{((target.inQty ?: 0) - (target.outQty ?: 0) - (target.holdQty ?: 0)) / (target.inventoryLot.item.itemUoms.^[salesUnit == true && deleted == false]?.ratioN / target.inventoryLot.item.itemUoms.^[salesUnit == true && deleted == false]?.ratioD)}")
var availableQty: BigDecimal?
@get:Value("#{(target.inQty ?: 0)/ (target.inventoryLot.item.itemUoms.^[salesUnit == true && deleted == false]?.ratioN / target.inventoryLot.item.itemUoms.^[salesUnit == true && deleted == false]?.ratioD)}")
var inQty: BigDecimal?
@get:Value("#{(target.outQty ?: 0)/ (target.inventoryLot.item.itemUoms.^[salesUnit == true && deleted == false]?.ratioN / target.inventoryLot.item.itemUoms.^[salesUnit == true && deleted == false]?.ratioD)}")
var outQty: BigDecimal?
@get:Value("#{(target.holdQty ?: 0)/ (target.inventoryLot.item.itemUoms.^[salesUnit == true && deleted == false]?.ratioN / target.inventoryLot.item.itemUoms.^[salesUnit == true && deleted == false]?.ratioD)}")
var holdQty: BigDecimal?
@get:Value("#{(target.inQty ?: 0) - (target.outQty ?: 0) - (target.holdQty ?: 0)}")
val qtyPerSmallestUnit: BigDecimal?
@get:Value("#{target.inventoryLot.item.itemUoms.^[baseUnit == true && deleted == false]?.uom.udfudesc}")
val baseUom: String?

@get:Value("#{target.status.value}")
val status: String?


+ 13
- 2
src/main/java/com/ffii/fpsms/modules/stock/service/InventoryLotLineService.kt Näytä tiedosto

@@ -1,5 +1,6 @@
package com.ffii.fpsms.modules.stock.service

import com.ffii.core.response.RecordsRes
import com.ffii.fpsms.modules.master.entity.ItemUomRespository
import com.ffii.fpsms.modules.master.entity.WarehouseRepository
import com.ffii.fpsms.modules.stock.entity.InventoryLotLine
@@ -8,9 +9,9 @@ import com.ffii.fpsms.modules.stock.entity.InventoryLotRepository
import com.ffii.fpsms.modules.stock.entity.enum.InventoryLotLineStatus
import com.ffii.fpsms.modules.stock.entity.projection.InventoryLotLineInfo
import com.ffii.fpsms.modules.stock.web.model.SaveInventoryLotLineRequest
import com.ffii.fpsms.modules.stock.web.model.SearchInventoryLotLineInfoRequest
import org.springframework.data.domain.PageRequest
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Propagation
import org.springframework.transaction.annotation.Transactional
import java.math.BigDecimal
import java.util.Optional
import kotlin.jvm.optionals.getOrNull
@@ -30,6 +31,16 @@ open class InventoryLotLineService(
return inventoryLotLineRepository.findInventoryLotLineInfoByInventoryLotItemIdIn(itemIds)
}

open fun allInventoryLotLinesByPage(request: SearchInventoryLotLineInfoRequest): RecordsRes<InventoryLotLineInfo> {
val pageable = PageRequest.of(request.pageNum ?: 0, request.pageSize ?: 10);

val response = inventoryLotLineRepository.findInventoryLotLineInfoByItemId(request.itemId, pageable)

val records = response.content
val total = response.totalElements
return RecordsRes<InventoryLotLineInfo>(records, total.toInt());
}

open fun saveInventoryLotLine(request: SaveInventoryLotLineRequest): InventoryLotLine {
val inventoryLotLine =
request.id?.let { inventoryLotLineRepository.findById(it).getOrNull() } ?: InventoryLotLine()


+ 19
- 8
src/main/java/com/ffii/fpsms/modules/stock/service/InventoryService.kt Näytä tiedosto

@@ -1,24 +1,19 @@
package com.ffii.fpsms.modules.stock.service

import com.ffii.core.response.RecordsRes
import com.ffii.core.support.AbstractBaseEntityService
import com.ffii.core.support.JdbcDao
import com.ffii.fpsms.modules.common.CodeGenerator
import com.ffii.fpsms.modules.master.entity.Items
import com.ffii.fpsms.modules.master.entity.ItemsRepository
import com.ffii.fpsms.modules.master.entity.UomConversionRepository
import com.ffii.fpsms.modules.master.service.ItemUomService
import com.ffii.fpsms.modules.master.service.UomConversionService
import com.ffii.fpsms.modules.master.web.models.MessageResponse
import com.ffii.fpsms.modules.stock.entity.Inventory
import com.ffii.fpsms.modules.stock.entity.InventoryRepository
import com.ffii.fpsms.modules.stock.entity.projection.InventoryInfo
import com.ffii.fpsms.modules.stock.web.model.SaveInventoryRequest
import com.ffii.fpsms.modules.stock.web.model.SearchInventoryRequest
import org.springframework.data.domain.PageRequest
import org.springframework.stereotype.Service
import java.io.IOException
import java.math.BigDecimal
import java.time.LocalDate
import java.time.format.DateTimeFormatter
import kotlin.jvm.optionals.getOrNull

@Service
open class InventoryService(
@@ -39,6 +34,22 @@ open class InventoryService(
return inventoryRepository.findInventoryInfoByDeletedIsFalse();
}

open fun allInventoriesByPage(request: SearchInventoryRequest): RecordsRes<InventoryInfo>{
val pageable = PageRequest.of(request.pageNum ?: 0, request.pageSize ?: 10)

val response = inventoryRepository.findInventoryInfoByItemCodeContainsAndItemNameContainsAndItemTypeContainsAndDeletedIsFalse(
code = request.code,
name = request.name,
type = request.type,
pageable = pageable
)

val records = response.content
val total = response.totalElements

return RecordsRes<InventoryInfo>(records, total.toInt());
}

open fun allInventoriesByItems(items: List<Items>): List<InventoryInfo>{
return inventoryRepository.findInventoryInfoByItemInAndDeletedIsFalse(items);
}


+ 8
- 0
src/main/java/com/ffii/fpsms/modules/stock/web/InventoryController.kt Näytä tiedosto

@@ -1,8 +1,11 @@
package com.ffii.fpsms.modules.stock.web

import com.ffii.core.response.RecordsRes
import com.ffii.fpsms.modules.stock.entity.projection.InventoryInfo
import com.ffii.fpsms.modules.stock.service.InventoryService
import com.ffii.fpsms.modules.stock.web.model.SearchInventoryRequest
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.ModelAttribute
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@@ -15,4 +18,9 @@ class InventoryController(
fun allInventories(): List<InventoryInfo> {
return inventoryService.allInventories()
}

@GetMapping("/getRecordByPage")
fun allInventoriesByPage(@ModelAttribute request: SearchInventoryRequest): RecordsRes<InventoryInfo> {
return inventoryService.allInventoriesByPage(request);
}
}

+ 12
- 7
src/main/java/com/ffii/fpsms/modules/stock/web/InventoryLotLineController.kt Näytä tiedosto

@@ -1,23 +1,22 @@
package com.ffii.fpsms.modules.stock.web

import com.ffii.core.response.RecordsRes
import com.ffii.fpsms.modules.pickOrder.web.models.ConsoPickOrderRequest
import com.ffii.fpsms.modules.stock.entity.InventoryLotLineRepository
import com.ffii.fpsms.modules.stock.entity.StockInLineRepository
import com.ffii.fpsms.modules.stock.entity.projection.InventoryLotLineInfo
import com.ffii.fpsms.modules.stock.service.InventoryLotLineService
import com.ffii.fpsms.modules.stock.web.model.LotLineInfo
import com.ffii.fpsms.modules.stock.web.model.SearchInventoryLotLineInfoRequest
import jakarta.validation.Valid
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController
import org.springframework.web.bind.annotation.*
import java.math.BigDecimal

@RequestMapping("/inventoryLotLine")
@RestController
class InventoryLotLineController (
private val inventoryLotLineRepository: InventoryLotLineRepository,
private val inventoryLotLineService: InventoryLotLineService,
private val stockInLineRepository: StockInLineRepository,

){
@@ -30,6 +29,12 @@ class InventoryLotLineController (
return inventoryLotLineRepository.findCurrentInventoryByItems(request.ids)
}

@GetMapping("/getRecordByPage")
fun allInventoryLotLinesByPage(@ModelAttribute request: SearchInventoryLotLineInfoRequest): RecordsRes<InventoryLotLineInfo> {
println(request.itemId)
return inventoryLotLineService.allInventoryLotLinesByPage(request);
}

@GetMapping("/lot-detail/{stockInLineId}")
fun getLotDetail(@Valid @PathVariable stockInLineId: Long): LotLineInfo {
val stockInLine = stockInLineRepository.findById(stockInLineId).orElseThrow()


+ 7
- 0
src/main/java/com/ffii/fpsms/modules/stock/web/model/SearchInventoryLotLineInfoRequest.kt Näytä tiedosto

@@ -0,0 +1,7 @@
package com.ffii.fpsms.modules.stock.web.model

data class SearchInventoryLotLineInfoRequest(
val itemId: Long? = null,
val pageSize: Int?,
val pageNum: Int?
)

+ 9
- 0
src/main/java/com/ffii/fpsms/modules/stock/web/model/SearchInventoryRequest.kt Näytä tiedosto

@@ -0,0 +1,9 @@
package com.ffii.fpsms.modules.stock.web.model

data class SearchInventoryRequest(
val code: String,
val name: String,
val type: String,
val pageNum: Int?,
val pageSize: Int?
)

Ladataan…
Peruuta
Tallenna