Procházet zdrojové kódy

update po

create_edit_user
MSI\derek před 2 měsíci
rodič
revize
89b8480d5b
6 změnil soubory, kde provedl 53 přidání a 18 odebrání
  1. +1
    -1
      src/main/java/com/ffii/fpsms/modules/purchaseOrder/enums/PurchaseOrderLineEnum.kt
  2. +26
    -8
      src/main/java/com/ffii/fpsms/modules/purchaseOrder/service/PurchaseOrderService.kt
  3. +4
    -0
      src/main/java/com/ffii/fpsms/modules/purchaseOrder/web/PurchaseOrderController.kt
  4. +2
    -0
      src/main/java/com/ffii/fpsms/modules/stock/entity/projection/StockInLineInfo.kt
  5. +19
    -8
      src/main/java/com/ffii/fpsms/modules/stock/service/StockInLineService.kt
  6. +1
    -1
      src/main/java/com/ffii/fpsms/modules/stock/web/model/SaveStockInRequest.kt

+ 1
- 1
src/main/java/com/ffii/fpsms/modules/purchaseOrder/enums/PurchaseOrderLineEnum.kt Zobrazit soubor

@@ -2,7 +2,7 @@ package com.ffii.fpsms.modules.purchaseOrder.enums

enum class PurchaseOrderLineStatus(val value: String) {
PENDING("pending"),
PICKING("picking"),
RECEIVING("receiving"),
COMPLETED("completed");
}


+ 26
- 8
src/main/java/com/ffii/fpsms/modules/purchaseOrder/service/PurchaseOrderService.kt Zobrazit soubor

@@ -22,6 +22,8 @@ import com.ffii.fpsms.modules.stock.entity.StockInLineRepository
import com.ffii.fpsms.modules.stock.entity.StockInRepository
import com.ffii.fpsms.modules.stock.web.model.StockInLineStatus
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional
import java.io.IOException
import java.util.HashMap
import java.util.Objects
import kotlin.jvm.optionals.getOrDefault
@@ -31,7 +33,6 @@ import kotlin.jvm.optionals.getOrNull
open class PurchaseOrderService(
private val jdbcDao: JdbcDao,
private val purchaseOrderRepository: PurchaseOrderRepository,
private val purchaseOrderLineRepository: PurchaseOrderLineRepository,
private val polRepository: PurchaseOrderLineRepository,
private val shopRepository: ShopRepository,
private val m18DataLogRepository: M18DataLogRepository,
@@ -89,6 +90,8 @@ open class PurchaseOrderService(
return purchaseOrderRepository.findTopByM18DataLogIdAndDeletedIsFalseOrderByModifiedDesc(m18DataLogId)
}

@Throws(IOException::class)
@Transactional
open fun savePurchaseOrder(request: SavePurchaseOrderRequest): SavePurchaseOrderResponse {
val purchaseOrder =
request.id?.let { purchaseOrderRepository.findById(it).getOrDefault(PurchaseOrder()) } ?: PurchaseOrder()
@@ -132,13 +135,28 @@ open class PurchaseOrderService(

return savedPurchaseOrder
}

fun checkPolAndCompletePo(id: Long): MessageResponse {
val unfinishedLines = purchaseOrderLineRepository
.findAllByPurchaseOrderIdAndStatusNotAndDeletedIsFalse(
purchaseOrderId = id,
status = PurchaseOrderLineStatus.COMPLETED
)
@Throws(IOException::class)
@Transactional
open fun startPo(id: Long): MessageResponse {
val po = purchaseOrderRepository.findById(id).orElseThrow()
po.apply {
status = PurchaseOrderStatus.RECEIVING
}
val savedPo = purchaseOrderRepository.saveAndFlush(po)
return MessageResponse(
id = savedPo.id,
name = savedPo.code,
code = savedPo.code,
type = PurchaseOrderStatus.RECEIVING.value,
message = "Update Success",
errorPosition = null,
entity = savedPo,
)
}
@Throws(IOException::class)
@Transactional
open fun checkPolAndCompletePo(id: Long): MessageResponse {
val unfinishedLines = polRepository.findAllByPurchaseOrderIdAndStatusNotAndDeletedIsFalse(purchaseOrderId = id, status = PurchaseOrderLineStatus.COMPLETED)
val po = purchaseOrderRepository.findById(id).orElseThrow()
if (unfinishedLines.isEmpty()) {
po.apply {


+ 4
- 0
src/main/java/com/ffii/fpsms/modules/purchaseOrder/web/PurchaseOrderController.kt Zobrazit soubor

@@ -23,6 +23,10 @@ class PurchaseOrderController(
return purchaseOrderService.getDetailedPo(id)
}

@PostMapping("/start/{id}") // purchaseOrderId
fun startPo(@PathVariable id: Long): MessageResponse {
return purchaseOrderService.startPo(id)
}
@PostMapping("/check/{id}") // purchaseOrderId
fun checkPolAndCompletePo(@PathVariable id: Long): MessageResponse {
return purchaseOrderService.checkPolAndCompletePo(id)


+ 2
- 0
src/main/java/com/ffii/fpsms/modules/stock/entity/projection/StockInLineInfo.kt Zobrazit soubor

@@ -23,6 +23,8 @@ interface StockInLineInfo {
val acceptedQty: BigDecimal
val price: BigDecimal?
val priceUnit: BigDecimal?
@get:Value("#{target.item?.shelfLife}")
val shelfLife: Double?
val receiptDate: LocalDateTime?
val productionDate: LocalDateTime?
val expiryDate: LocalDate?


+ 19
- 8
src/main/java/com/ffii/fpsms/modules/stock/service/StockInLineService.kt Zobrazit soubor

@@ -64,8 +64,20 @@ open class StockInLineService(
val stockInLine = StockInLine()
val item = itemRepository.findById(request.itemId).orElseThrow()
val purchaseOrderLine = polRepository.findById(request.purchaseOrderLineId).orElseThrow()
val stockIn = stockInRepository.findByPurchaseOrderIdAndDeletedFalse(request.purchaseOrderId)
?: stockInService.create(SaveStockInRequest(purchaseOrderId = request.purchaseOrderId)).entity as StockIn
var stockIn = stockInRepository.findByPurchaseOrderIdAndDeletedFalse(request.purchaseOrderId)
purchaseOrderLine.apply {
status = PurchaseOrderLineStatus.RECEIVING
}
polRepository.saveAndFlush(purchaseOrderLine)
if (stockIn == null) {
stockIn = stockInService.create(SaveStockInRequest(purchaseOrderId = request.purchaseOrderId)).entity as StockIn
// update po status to receiving
val po = purchaseOrderRepository.findById(request.purchaseOrderId).orElseThrow()
po.apply {
status = PurchaseOrderStatus.RECEIVING
}
purchaseOrderRepository.save(po)
}
stockInLine.apply {
this.item = item
itemNo = item.code
@@ -112,6 +124,7 @@ open class StockInLineService(
@Transactional
fun saveInventoryLotLineWhenStockIn(request: SaveStockInLineRequest, stockInLine: StockInLine): InventoryLotLine {
val inventoryLotLine = InventoryLotLine()
println(request.warehouseId!!)
val warehouse = warehouseRepository.findById(request.warehouseId!!).orElseThrow()
inventoryLotLine.apply {
this.inventoryLot = stockInLine.inventoryLot
@@ -148,10 +161,8 @@ open class StockInLineService(
@Transactional
fun updatePurchaseOrderStatus(request: SaveStockInLineRequest) {
if (request.status == StockInLineStatus.COMPLETE.status) {
val unfinishedLines = polRepository.findAllByPurchaseOrderIdAndStatusNotAndDeletedIsFalse(
purchaseOrderId = request.purchaseOrderId,
status = PurchaseOrderLineStatus.COMPLETED
)
val unfinishedLines = polRepository
.findAllByPurchaseOrderIdAndStatusNotAndDeletedIsFalse(purchaseOrderId = request.purchaseOrderId, status = PurchaseOrderLineStatus.COMPLETED)
if (unfinishedLines.isEmpty()) {
val po = purchaseOrderRepository.findById(request.purchaseOrderId).orElseThrow()
po.apply {
@@ -223,7 +234,7 @@ open class StockInLineService(
val savedStockInLine = saveAndFlush(stockInLine)
// check if all line completed
updatePurchaseOrderLineStatus(request)
updatePurchaseOrderStatus(request)
// updatePurchaseOrderStatus(request)
// val allLineByStockInId = find
val lineInfo = stockInLineRepository.findStockInLineInfoByIdAndDeletedFalse(savedStockInLine.id!!)
// println("checkpoint2")
@@ -297,7 +308,7 @@ open class StockInLineService(
val lineInfoList = stockInLineRepository.findStockInLineInfoByIdInAndDeletedFalse(ids)
// check if all line completed
updatePurchaseOrderLineStatus(request)
updatePurchaseOrderStatus(request)
// updatePurchaseOrderStatus(request)

return MessageResponse(
id = stockInLine.id,


+ 1
- 1
src/main/java/com/ffii/fpsms/modules/stock/web/model/SaveStockInRequest.kt Zobrazit soubor

@@ -29,7 +29,7 @@ data class SaveStockInRequest(
val orderDate: Long? = null,
val estimatedCompleteDate: LocalDateTime? = null,
val completeDate: LocalDateTime? = null,
val status: LocalDateTime? = null,
val status: String? = null,
val stockOutId: Long? = null,
// val m18
)


Načítá se…
Zrušit
Uložit