| @@ -3,6 +3,8 @@ package com.ffii.fpsms.modules.stock.entity | |||||
| import com.ffii.core.support.AbstractRepository | import com.ffii.core.support.AbstractRepository | ||||
| import com.ffii.fpsms.modules.stock.entity.projection.CurrentInventoryItemInfo | import com.ffii.fpsms.modules.stock.entity.projection.CurrentInventoryItemInfo | ||||
| import com.ffii.fpsms.modules.stock.entity.projection.InventoryLotLineInfo | 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.data.jpa.repository.Query | ||||
| import org.springframework.stereotype.Repository | import org.springframework.stereotype.Repository | ||||
| import java.io.Serializable | import java.io.Serializable | ||||
| @@ -11,6 +13,9 @@ import java.io.Serializable | |||||
| interface InventoryLotLineRepository : AbstractRepository<InventoryLotLine, Long> { | interface InventoryLotLineRepository : AbstractRepository<InventoryLotLine, Long> { | ||||
| fun findInventoryLotLineInfoByInventoryLotItemIdIn(ids: List<Serializable>): List<InventoryLotLineInfo> | 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(""" | @Query(""" | ||||
| select | select | ||||
| i.id as id, | i.id as id, | ||||
| @@ -3,6 +3,8 @@ package com.ffii.fpsms.modules.stock.entity | |||||
| import com.ffii.core.support.AbstractRepository | import com.ffii.core.support.AbstractRepository | ||||
| import com.ffii.fpsms.modules.master.entity.Items | import com.ffii.fpsms.modules.master.entity.Items | ||||
| import com.ffii.fpsms.modules.stock.entity.projection.InventoryInfo | 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 org.springframework.stereotype.Repository | ||||
| import java.io.Serializable | import java.io.Serializable | ||||
| import java.util.Optional | import java.util.Optional | ||||
| @@ -11,6 +13,8 @@ import java.util.Optional | |||||
| interface InventoryRepository: AbstractRepository<Inventory, Long> { | interface InventoryRepository: AbstractRepository<Inventory, Long> { | ||||
| fun findInventoryInfoByDeletedIsFalse(): List<InventoryInfo> | fun findInventoryInfoByDeletedIsFalse(): List<InventoryInfo> | ||||
| fun findInventoryInfoByItemCodeContainsAndItemNameContainsAndItemTypeContainsAndDeletedIsFalse(code: String, name: String, type: String, 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> | ||||
| @@ -26,8 +26,12 @@ interface InventoryInfo{ | |||||
| val uomCode: String? | val uomCode: String? | ||||
| @get:Value("#{target.item.itemUoms.^[purchaseUnit == true && deleted == false]?.uom.udfudesc}") | @get:Value("#{target.item.itemUoms.^[purchaseUnit == true && deleted == false]?.uom.udfudesc}") | ||||
| val uomUdfudesc: String? | val uomUdfudesc: String? | ||||
| // @get:Value("#{target.qty * target.uom.gramPerSmallestUnit}") | |||||
| // @get:Value("#{target.qty * target.uom.gramPerSmallestUnit}") | |||||
| // val germPerSmallestUnit: BigDecimal? | // 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 " + | // @get:Value("#{target.qty * (target.uom.unit4 != '' ? target.uom.unit4Qty " + | ||||
| // ": target.uom.unit3 != '' ? target.uom.unit3Qty " + | // ": target.uom.unit3 != '' ? target.uom.unit3Qty " + | ||||
| // ": target.uom.unit2 != '' ? target.uom.unit2Qty " + | // ": target.uom.unit2 != '' ? target.uom.unit2Qty " + | ||||
| @@ -8,6 +8,7 @@ interface InventoryLotLineItemInfo { | |||||
| val id: Long | val id: Long | ||||
| val code: String | val code: String | ||||
| val name: String | val name: String | ||||
| val type: String | |||||
| } | } | ||||
| interface InventoryLotLineWarehouseInfo { | interface InventoryLotLineWarehouseInfo { | ||||
| @@ -20,13 +21,23 @@ interface InventoryLotLineWarehouseInfo { | |||||
| interface InventoryLotLineInfo { | interface InventoryLotLineInfo { | ||||
| val id: Long? | val id: Long? | ||||
| @get:Value("#{target.inventoryLot.lotNo}") | |||||
| val lotNo: String? | |||||
| @get:Value("#{target.inventoryLot.item}") | @get:Value("#{target.inventoryLot.item}") | ||||
| val item: InventoryLotLineItemInfo? | val item: InventoryLotLineItemInfo? | ||||
| val warehouse: InventoryLotLineWarehouseInfo? | 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? | 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? | 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? | 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}") | @get:Value("#{target.status.value}") | ||||
| val status: String? | val status: String? | ||||
| @@ -1,5 +1,6 @@ | |||||
| package com.ffii.fpsms.modules.stock.service | 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.ItemUomRespository | ||||
| import com.ffii.fpsms.modules.master.entity.WarehouseRepository | import com.ffii.fpsms.modules.master.entity.WarehouseRepository | ||||
| import com.ffii.fpsms.modules.stock.entity.InventoryLotLine | 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.enum.InventoryLotLineStatus | ||||
| import com.ffii.fpsms.modules.stock.entity.projection.InventoryLotLineInfo | 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.SaveInventoryLotLineRequest | ||||
| import com.ffii.fpsms.modules.stock.web.model.SearchInventoryLotLineInfoRequest | |||||
| import org.springframework.data.domain.PageRequest | |||||
| import org.springframework.stereotype.Service | import org.springframework.stereotype.Service | ||||
| import org.springframework.transaction.annotation.Propagation | |||||
| import org.springframework.transaction.annotation.Transactional | |||||
| import java.math.BigDecimal | import java.math.BigDecimal | ||||
| import java.util.Optional | import java.util.Optional | ||||
| import kotlin.jvm.optionals.getOrNull | import kotlin.jvm.optionals.getOrNull | ||||
| @@ -30,6 +31,16 @@ open class InventoryLotLineService( | |||||
| return inventoryLotLineRepository.findInventoryLotLineInfoByInventoryLotItemIdIn(itemIds) | 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 { | open fun saveInventoryLotLine(request: SaveInventoryLotLineRequest): InventoryLotLine { | ||||
| val inventoryLotLine = | val inventoryLotLine = | ||||
| request.id?.let { inventoryLotLineRepository.findById(it).getOrNull() } ?: InventoryLotLine() | request.id?.let { inventoryLotLineRepository.findById(it).getOrNull() } ?: InventoryLotLine() | ||||
| @@ -1,24 +1,19 @@ | |||||
| package com.ffii.fpsms.modules.stock.service | package com.ffii.fpsms.modules.stock.service | ||||
| import com.ffii.core.response.RecordsRes | |||||
| import com.ffii.core.support.AbstractBaseEntityService | import com.ffii.core.support.AbstractBaseEntityService | ||||
| import com.ffii.core.support.JdbcDao | 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.Items | ||||
| import com.ffii.fpsms.modules.master.entity.ItemsRepository | import com.ffii.fpsms.modules.master.entity.ItemsRepository | ||||
| import com.ffii.fpsms.modules.master.entity.UomConversionRepository | import com.ffii.fpsms.modules.master.entity.UomConversionRepository | ||||
| import com.ffii.fpsms.modules.master.service.ItemUomService | import com.ffii.fpsms.modules.master.service.ItemUomService | ||||
| import com.ffii.fpsms.modules.master.service.UomConversionService | 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.Inventory | ||||
| import com.ffii.fpsms.modules.stock.entity.InventoryRepository | import com.ffii.fpsms.modules.stock.entity.InventoryRepository | ||||
| import com.ffii.fpsms.modules.stock.entity.projection.InventoryInfo | 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 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 | @Service | ||||
| open class InventoryService( | open class InventoryService( | ||||
| @@ -39,6 +34,22 @@ open class InventoryService( | |||||
| return inventoryRepository.findInventoryInfoByDeletedIsFalse(); | 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>{ | open fun allInventoriesByItems(items: List<Items>): List<InventoryInfo>{ | ||||
| return inventoryRepository.findInventoryInfoByItemInAndDeletedIsFalse(items); | return inventoryRepository.findInventoryInfoByItemInAndDeletedIsFalse(items); | ||||
| } | } | ||||
| @@ -1,8 +1,11 @@ | |||||
| package com.ffii.fpsms.modules.stock.web | 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.entity.projection.InventoryInfo | ||||
| import com.ffii.fpsms.modules.stock.service.InventoryService | 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.GetMapping | ||||
| import org.springframework.web.bind.annotation.ModelAttribute | |||||
| import org.springframework.web.bind.annotation.RequestMapping | import org.springframework.web.bind.annotation.RequestMapping | ||||
| import org.springframework.web.bind.annotation.RestController | import org.springframework.web.bind.annotation.RestController | ||||
| @@ -15,4 +18,9 @@ class InventoryController( | |||||
| fun allInventories(): List<InventoryInfo> { | fun allInventories(): List<InventoryInfo> { | ||||
| return inventoryService.allInventories() | return inventoryService.allInventories() | ||||
| } | } | ||||
| @GetMapping("/getRecordByPage") | |||||
| fun allInventoriesByPage(@ModelAttribute request: SearchInventoryRequest): RecordsRes<InventoryInfo> { | |||||
| return inventoryService.allInventoriesByPage(request); | |||||
| } | |||||
| } | } | ||||
| @@ -1,23 +1,22 @@ | |||||
| package com.ffii.fpsms.modules.stock.web | 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.pickOrder.web.models.ConsoPickOrderRequest | ||||
| import com.ffii.fpsms.modules.stock.entity.InventoryLotLineRepository | import com.ffii.fpsms.modules.stock.entity.InventoryLotLineRepository | ||||
| import com.ffii.fpsms.modules.stock.entity.StockInLineRepository | 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.LotLineInfo | ||||
| import com.ffii.fpsms.modules.stock.web.model.SearchInventoryLotLineInfoRequest | |||||
| import jakarta.validation.Valid | 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 | import java.math.BigDecimal | ||||
| @RequestMapping("/inventoryLotLine") | @RequestMapping("/inventoryLotLine") | ||||
| @RestController | @RestController | ||||
| class InventoryLotLineController ( | class InventoryLotLineController ( | ||||
| private val inventoryLotLineRepository: InventoryLotLineRepository, | private val inventoryLotLineRepository: InventoryLotLineRepository, | ||||
| private val inventoryLotLineService: InventoryLotLineService, | |||||
| private val stockInLineRepository: StockInLineRepository, | private val stockInLineRepository: StockInLineRepository, | ||||
| ){ | ){ | ||||
| @@ -30,6 +29,12 @@ class InventoryLotLineController ( | |||||
| return inventoryLotLineRepository.findCurrentInventoryByItems(request.ids) | 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}") | @GetMapping("/lot-detail/{stockInLineId}") | ||||
| fun getLotDetail(@Valid @PathVariable stockInLineId: Long): LotLineInfo { | fun getLotDetail(@Valid @PathVariable stockInLineId: Long): LotLineInfo { | ||||
| val stockInLine = stockInLineRepository.findById(stockInLineId).orElseThrow() | val stockInLine = stockInLineRepository.findById(stockInLineId).orElseThrow() | ||||
| @@ -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? | |||||
| ) | |||||
| @@ -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? | |||||
| ) | |||||