add supervision approval log related for dashboardmaster
| @@ -18,6 +18,7 @@ interface ItemUomRespository : AbstractRepository<ItemUom, Long> { | |||||
| fun findByItemIdAndPurchaseUnitIsTrueAndDeletedIsFalse(itemId: Serializable): ItemUom? | fun findByItemIdAndPurchaseUnitIsTrueAndDeletedIsFalse(itemId: Serializable): ItemUom? | ||||
| fun findByItemIdAndSalesUnitIsTrueAndDeletedIsFalse(itemId: Serializable): ItemUom? | fun findByItemIdAndSalesUnitIsTrueAndDeletedIsFalse(itemId: Serializable): ItemUom? | ||||
| fun findByItemIdAndStockUnitIsTrueAndDeletedIsFalse(itemId: Serializable): ItemUom? | |||||
| fun findByItemM18IdAndPurchaseUnitIsTrueAndDeletedIsFalse(itemM18Id: Long): ItemUom? | fun findByItemM18IdAndPurchaseUnitIsTrueAndDeletedIsFalse(itemM18Id: Long): ItemUom? | ||||
| fun findBaseUnitByItemIdAndStockUnitIsTrueAndDeletedIsFalse(itemId: Long): ItemUom? | fun findBaseUnitByItemIdAndStockUnitIsTrueAndDeletedIsFalse(itemId: Long): ItemUom? | ||||
| @@ -34,6 +34,9 @@ open class ItemUomService( | |||||
| open fun findSalesUnitByItemId(itemId: Long): ItemUom? { | open fun findSalesUnitByItemId(itemId: Long): ItemUom? { | ||||
| return itemUomRespository.findByItemIdAndSalesUnitIsTrueAndDeletedIsFalse(itemId) | return itemUomRespository.findByItemIdAndSalesUnitIsTrueAndDeletedIsFalse(itemId) | ||||
| } | } | ||||
| open fun findStockUnitByItemId(itemId: Long): ItemUom? { | |||||
| return itemUomRespository.findByItemIdAndStockUnitIsTrueAndDeletedIsFalse(itemId) | |||||
| } | |||||
| open fun findPurchaseUnitByM18ItemId(m18ItemId: Long): ItemUom? { | open fun findPurchaseUnitByM18ItemId(m18ItemId: Long): ItemUom? { | ||||
| return itemUomRespository.findByItemM18IdAndPurchaseUnitIsTrueAndDeletedIsFalse(m18ItemId) | return itemUomRespository.findByItemM18IdAndPurchaseUnitIsTrueAndDeletedIsFalse(m18ItemId) | ||||
| @@ -8,9 +8,9 @@ import java.util.Optional | |||||
| @Repository | @Repository | ||||
| interface StockInLineRepository : AbstractRepository<StockInLine, Long> { | interface StockInLineRepository : AbstractRepository<StockInLine, Long> { | ||||
| fun findAllByStockInIdAndDeletedFalse(stockInId: Long): List<StockInLine> | |||||
| fun findAllStockInLineInfoByStockInIdAndDeletedFalse(stockInId: Long): List<StockInLineInfo> | fun findAllStockInLineInfoByStockInIdAndDeletedFalse(stockInId: Long): List<StockInLineInfo> | ||||
| fun findStockInLineInfoByIdAndDeletedFalse(id: Long): StockInLineInfo | fun findStockInLineInfoByIdAndDeletedFalse(id: Long): StockInLineInfo | ||||
| fun findAllByStockInIdAndDeletedFalse(stockInId: Long): List<StockInLine> | |||||
| fun findStockInLineInfoByIdInAndDeletedFalse(id: List<Long>): List<StockInLineInfo> | fun findStockInLineInfoByIdInAndDeletedFalse(id: List<Long>): List<StockInLineInfo> | ||||
| fun findStockInLineInfoByPurchaseOrderLineIdAndStatusNotAndDeletedFalse(purchaseOrderLineId: Long, status: String): List<StockInLineInfo> | fun findStockInLineInfoByPurchaseOrderLineIdAndStatusNotAndDeletedFalse(purchaseOrderLineId: Long, status: String): List<StockInLineInfo> | ||||
| fun findStockInLineInfoByPurchaseOrderLineIdAndDeletedFalse(purchaseOrderLineId: Long): List<StockInLineInfo> | fun findStockInLineInfoByPurchaseOrderLineIdAndDeletedFalse(purchaseOrderLineId: Long): List<StockInLineInfo> | ||||
| @@ -0,0 +1,20 @@ | |||||
| package com.ffii.fpsms.modules.stock.entity | |||||
| import org.springframework.beans.factory.annotation.Value | |||||
| interface SupervisionApprovalLogInfo { | |||||
| val id: Long | |||||
| @get:Value("#{target.stockInLine?.stockIn.purchaseOrder.id}") | |||||
| val poId: Long | |||||
| @get:Value("#{target.stockInLine?.purchaseOrderLine.id}") | |||||
| val polId: Long | |||||
| @get:Value("#{target.stockInLine?.stockIn.code}") | |||||
| val poCode: String | |||||
| @get:Value("#{target.stockInLine?.id}") | |||||
| val stockInLineId: Long | |||||
| @get:Value("#{target.stockInLine?.item.name}") | |||||
| val itemName: String | |||||
| @get:Value("#{target.type}") | |||||
| val escalationLevel: String | |||||
| val reason: String | |||||
| } | |||||
| @@ -1,8 +1,11 @@ | |||||
| package com.ffii.fpsms.modules.stock.entity | package com.ffii.fpsms.modules.stock.entity | ||||
| import com.ffii.core.support.AbstractRepository | import com.ffii.core.support.AbstractRepository | ||||
| import com.ffii.fpsms.modules.user.entity.User | |||||
| import org.springframework.stereotype.Repository | import org.springframework.stereotype.Repository | ||||
| @Repository | @Repository | ||||
| interface SupervisionApprovalLogRepository : AbstractRepository<SupervisionApprovalLog, Long> { | |||||
| interface SupervisionApprovalLogRepository: AbstractRepository<SupervisionApprovalLog, Long> { | |||||
| // fun findAllByPersonInCharge(personInCharge: Long): List<SupervisionApprovalLog> | |||||
| fun findAllInfoByDeletedFalse(): List<SupervisionApprovalLogInfo> | |||||
| } | } | ||||
| @@ -243,13 +243,15 @@ open class InventoryService( | |||||
| ) | ) | ||||
| requestList.add(request) | requestList.add(request) | ||||
| val item = itemsRepository.findByCodeAndDeletedFalse(request.itemCode) | val item = itemsRepository.findByCodeAndDeletedFalse(request.itemCode) | ||||
| val salesUnit = itemUomService.findSalesUnitByItemId(itemId = item!!.id!!)!!.uom | val salesUnit = itemUomService.findSalesUnitByItemId(itemId = item!!.id!!)!!.uom | ||||
| val stockUnit = itemUomService.findStockUnitByItemId(itemId = item.id!!)!!.uom | |||||
| // purchase order line | // purchase order line | ||||
| val purchaseOrderLine = PurchaseOrderLine() | val purchaseOrderLine = PurchaseOrderLine() | ||||
| .apply { | .apply { | ||||
| this.item = item | this.item = item | ||||
| this.itemNo = item.code | this.itemNo = item.code | ||||
| this.uom = salesUnit | |||||
| this.uom = stockUnit | |||||
| this.purchaseOrder = po | this.purchaseOrder = po | ||||
| this.price = BigDecimal.ZERO | this.price = BigDecimal.ZERO | ||||
| this.status = PurchaseOrderLineStatus.COMPLETED | this.status = PurchaseOrderLineStatus.COMPLETED | ||||
| @@ -301,13 +303,19 @@ open class InventoryService( | |||||
| val inventoryLotLineEntries = requestList.mapIndexed { index, request -> | val inventoryLotLineEntries = requestList.mapIndexed { index, request -> | ||||
| val inventoryLot = savedInventoryLotEntries[index] | val inventoryLot = savedInventoryLotEntries[index] | ||||
| val warehouse = warehouseRepository.findAll().find { it.code == request.warehouseCode }!! | val warehouse = warehouseRepository.findAll().find { it.code == request.warehouseCode }!! | ||||
| val salesUnit = itemUomService.findSalesUnitByItemId(itemId = inventoryLot.item!!.id!!) | |||||
| // val salesUnit = itemUomService.findSalesUnitByItemId(itemId = inventoryLot.item!!.id!!) | |||||
| val stockUnit = itemUomService.findStockUnitByItemId(itemId = inventoryLot.item!!.id!!) | |||||
| // val zero = BigDecimal.ZERO | |||||
| // val one = BigDecimal.ONE | |||||
| // val ratio = (salesUnit?.ratioN ?: zero).divide(salesUnit?.ratioD ?: one) | |||||
| InventoryLotLine().apply { | InventoryLotLine().apply { | ||||
| this.inventoryLot = inventoryLot | this.inventoryLot = inventoryLot | ||||
| this.warehouse = warehouse | this.warehouse = warehouse | ||||
| this.inQty = request.qty | this.inQty = request.qty | ||||
| this.status = InventoryLotLineStatus.AVAILABLE | this.status = InventoryLotLineStatus.AVAILABLE | ||||
| this.stockUom = salesUnit | |||||
| this.stockUom = stockUnit | |||||
| // this.stockUom = salesUnit | |||||
| } | } | ||||
| } | } | ||||
| val savedInventoryLotLine = inventoryLotLineRepository.saveAllAndFlush(inventoryLotLineEntries) | val savedInventoryLotLine = inventoryLotLineRepository.saveAllAndFlush(inventoryLotLineEntries) | ||||
| @@ -0,0 +1,38 @@ | |||||
| package com.ffii.fpsms.modules.stock.service | |||||
| import com.ffii.core.support.AbstractBaseEntityService | |||||
| import com.ffii.core.support.JdbcDao | |||||
| import com.ffii.fpsms.modules.common.SecurityUtils | |||||
| import com.ffii.fpsms.modules.stock.entity.SupervisionApprovalLog | |||||
| import com.ffii.fpsms.modules.stock.entity.SupervisionApprovalLogInfo | |||||
| import com.ffii.fpsms.modules.stock.entity.SupervisionApprovalLogRepository | |||||
| import org.springframework.stereotype.Service | |||||
| @Service | |||||
| open class SupervisionApprovalLogService( | |||||
| private val jdbcDao: JdbcDao, | |||||
| private val supervisionApprovalLogRepository: SupervisionApprovalLogRepository | |||||
| ): AbstractBaseEntityService<SupervisionApprovalLog, Long, SupervisionApprovalLogRepository>(jdbcDao, supervisionApprovalLogRepository) { | |||||
| open fun getAllLogs(): List<SupervisionApprovalLog> { | |||||
| return supervisionApprovalLogRepository.findAll() | |||||
| } | |||||
| open fun getStockInLog(): List<SupervisionApprovalLog> { | |||||
| val stockInLog = getAllLogs().filter { | |||||
| it.stockInLine != null | |||||
| } | |||||
| return stockInLog | |||||
| } | |||||
| open fun getLogByUser(): List<SupervisionApprovalLogInfo> { | |||||
| val user = SecurityUtils.getUser().orElseThrow() | |||||
| val filterLog = supervisionApprovalLogRepository | |||||
| .findAllInfoByDeletedFalse() | |||||
| // .findAll() | |||||
| // .findAllByPersonInCharge(user.id!!).filter { | |||||
| // it.stockInLine != null | |||||
| // } | |||||
| println("filterLog") | |||||
| println(filterLog) | |||||
| return filterLog | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,19 @@ | |||||
| package com.ffii.fpsms.modules.stock.web | |||||
| import com.ffii.fpsms.modules.stock.entity.SupervisionApprovalLog | |||||
| import com.ffii.fpsms.modules.stock.entity.SupervisionApprovalLogInfo | |||||
| import com.ffii.fpsms.modules.stock.service.SupervisionApprovalLogService | |||||
| import org.springframework.web.bind.annotation.GetMapping | |||||
| import org.springframework.web.bind.annotation.RequestMapping | |||||
| import org.springframework.web.bind.annotation.RestController | |||||
| @RestController | |||||
| @RequestMapping("/supervisionApprovalLog") | |||||
| class SupervisionApprovalLogController( | |||||
| private val supervisionApprovalLogService: SupervisionApprovalLogService | |||||
| ) { | |||||
| @GetMapping("/stock-in") | |||||
| fun getStockInQcLog(): List<SupervisionApprovalLogInfo> { | |||||
| return supervisionApprovalLogService.getLogByUser() | |||||
| } | |||||
| } | |||||