Bladeren bron

for easy locate lot qrcode

master
MSI\derek 3 weken geleden
bovenliggende
commit
3a8b77cdbe
4 gewijzigde bestanden met toevoegingen van 88 en 1 verwijderingen
  1. +1
    -0
      src/main/java/com/ffii/fpsms/modules/stock/entity/StockInLineRepository.kt
  2. +4
    -0
      src/main/java/com/ffii/fpsms/modules/stock/entity/projection/QrCodeInfo.kt
  3. +60
    -1
      src/main/java/com/ffii/fpsms/modules/stock/service/InventoryLotLineService.kt
  4. +23
    -0
      src/main/java/com/ffii/fpsms/modules/stock/web/InventoryLotLineController.kt

+ 1
- 0
src/main/java/com/ffii/fpsms/modules/stock/entity/StockInLineRepository.kt Bestand weergeven

@@ -17,4 +17,5 @@ interface StockInLineRepository : AbstractRepository<StockInLine, Long> {
fun findStockInLineInfoByIdAndStatusAndDeletedFalse(id: Long, status: String): Optional<StockInLineInfo>
fun findAllStockInLineInfoByPurchaseOrderIdAndStatusStartsWithAndDeletedFalse(purchaseOrderId: Long, status: String): List<Optional<StockInLineInfo>>
fun findAllByPurchaseOrderIdAndDeletedFalse(purchaseOrderId: Long): Optional<List<StockInLine>>
fun findStockInLineInfoByInventoryLotLineId(inventoryLotLineId: Long): Optional<StockInLineInfo>
}

+ 4
- 0
src/main/java/com/ffii/fpsms/modules/stock/entity/projection/QrCodeInfo.kt Bestand weergeven

@@ -27,3 +27,7 @@ interface QrCodeInfo { // stockInLine
val supplier: String?
// var qrCode: BufferedImage?
}

data class LotLineToQrcode (
val inventoryLotLineId: Long
)

+ 60
- 1
src/main/java/com/ffii/fpsms/modules/stock/service/InventoryLotLineService.kt Bestand weergeven

@@ -1,18 +1,32 @@
package com.ffii.fpsms.modules.stock.service

import com.ffii.core.response.RecordsRes
import com.ffii.core.utils.PdfUtils
import com.ffii.core.utils.QrCodeUtil
import com.ffii.fpsms.modules.master.entity.ItemUomRespository
import com.ffii.fpsms.modules.master.entity.WarehouseRepository
import com.ffii.fpsms.modules.stock.entity.InventoryLotLine
import com.ffii.fpsms.modules.stock.entity.InventoryLotLineRepository
import com.ffii.fpsms.modules.stock.entity.InventoryLotRepository
import com.ffii.fpsms.modules.stock.entity.StockInLineRepository
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.LotLineToQrcode
import com.ffii.fpsms.modules.stock.web.InventoryLotLineController
import com.ffii.fpsms.modules.stock.web.model.ExportQrCodeRequest
import com.ffii.fpsms.modules.stock.web.model.SaveInventoryLotLineRequest
import com.ffii.fpsms.modules.stock.web.model.SearchInventoryLotLineInfoRequest
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import net.sf.jasperreports.engine.JasperCompileManager
import org.springframework.core.io.ClassPathResource
import org.springframework.data.domain.PageRequest
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional
import java.io.FileNotFoundException
import java.io.IOException
import java.math.BigDecimal
import java.time.format.DateTimeFormatter
import java.util.Optional
import kotlin.jvm.optionals.getOrNull

@@ -21,7 +35,8 @@ open class InventoryLotLineService(
private val inventoryLotLineRepository: InventoryLotLineRepository,
private val inventoryLotRepository: InventoryLotRepository,
private val warehouseRepository: WarehouseRepository,
private val itemUomRespository: ItemUomRespository
private val itemUomRespository: ItemUomRespository,
private val stockInLineRepository: StockInLineRepository
) {
open fun findById(id: Long): Optional<InventoryLotLine> {
return inventoryLotLineRepository.findById(id)
@@ -72,4 +87,48 @@ open class InventoryLotLineService(

return inventoryLotLineRepository.save(inventoryLotLine)
}

@Throws(IOException::class)
@Transactional
open fun exportStockInLineQrcode(request: LotLineToQrcode): Map<String, Any> {
val QRCODE_PDF = "qrCodeLabel/poItemPDF.jrxml"
val resource = ClassPathResource(QRCODE_PDF)
if (!resource.exists()) {
println("here")
throw FileNotFoundException("Report file not found: $QRCODE_PDF")
}
val inputStream = resource.inputStream
val poLabel = JasperCompileManager.compileReport(inputStream)
val qrContent = stockInLineRepository.findStockInLineInfoByInventoryLotLineId(request.inventoryLotLineId).orElseThrow()
val qrCodeInfo = listOf(qrContent)
// val qrCodeInfo = stockInLineRepository.findStockInLineInfoByIdInAndDeletedFalse(request.stockInLineIds).toMutableList()
val fields = mutableListOf<MutableMap<String ,Any>>()

for (info in qrCodeInfo) {
val field = mutableMapOf<String, Any>()
val qrContent = QrContent(itemId = info.itemId, stockInLineId = info.id)
val qrCodeContent = (Json.encodeToString(qrContent))
// field["itemId"] = info.itemId
field["itemName"] = info.itemName!!
field["itemNo"] = info.itemNo
field["poCode"] = info.poCode
field["itemType"] = info.itemType
field["acceptedQty"] = info.acceptedQty.toString()
field["uom"] = info.uom.code.toString()
field["productionDate"] = info.productionDate?.format(DateTimeFormatter.ISO_LOCAL_DATE) ?: ""
field["expiryDate"] = info.expiryDate?.format(DateTimeFormatter.ISO_LOCAL_DATE) ?: ""
field["lotNo"] = info.lotNo!!
field["supplier"] = info.supplier!!
val image = QrCodeUtil.generateQRCodeImage(qrCodeContent)
field["qrCode"] = image
fields.add(field)
}
val params: MutableMap<String, Any> = mutableMapOf(
"poCode" to qrCodeInfo[0].poCode
)
return mapOf(
"report" to PdfUtils.fillReport(poLabel,fields, params),
"fileName" to qrCodeInfo[0].poCode
);
}
}

+ 23
- 0
src/main/java/com/ffii/fpsms/modules/stock/web/InventoryLotLineController.kt Bestand weergeven

@@ -5,12 +5,22 @@ 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.entity.projection.LotLineToQrcode
import com.ffii.fpsms.modules.stock.service.InventoryLotLineService
import com.ffii.fpsms.modules.stock.service.StockInLineService
import com.ffii.fpsms.modules.stock.web.model.ExportQrCodeRequest
import com.ffii.fpsms.modules.stock.web.model.LotLineInfo
import com.ffii.fpsms.modules.stock.web.model.SearchInventoryLotLineInfoRequest
import jakarta.servlet.http.HttpServletResponse
import jakarta.validation.Valid
import net.sf.jasperreports.engine.JasperExportManager
import net.sf.jasperreports.engine.JasperPrint
import org.springframework.context.NoSuchMessageException
import org.springframework.web.bind.annotation.*
import java.io.OutputStream
import java.io.UnsupportedEncodingException
import java.math.BigDecimal
import java.text.ParseException

@RequestMapping("/inventoryLotLine")
@RestController
@@ -18,6 +28,7 @@ class InventoryLotLineController (
private val inventoryLotLineRepository: InventoryLotLineRepository,
private val inventoryLotLineService: InventoryLotLineService,
private val stockInLineRepository: StockInLineRepository,
private val stockInLineService: StockInLineService,

){
// @PostMapping("/test")
@@ -52,4 +63,16 @@ class InventoryLotLineController (
uom = inventoryLotLine.stockUom!!.uom!!.udfudesc!!
)
}

@PostMapping("/print-label")
@Throws(UnsupportedEncodingException::class, NoSuchMessageException::class, ParseException::class, Exception::class)
fun printLabel(@Valid @RequestBody request: LotLineToQrcode, response: HttpServletResponse) {
response.characterEncoding = "utf-8";
response.contentType = "application/pdf";
val out: OutputStream = response.outputStream
val pdf = inventoryLotLineService.exportStockInLineQrcode(request)
val jasperPrint = pdf["report"] as JasperPrint
response.addHeader("filename", "${pdf["fileName"]}.pdf")
out.write(JasperExportManager.exportReportToPdf(jasperPrint));
}
}

Laden…
Annuleren
Opslaan