package com.ffii.fpsms.modules.bag.web

import com.ffii.core.response.RecordsRes
import com.ffii.fpsms.modules.bag.service.BagService
import jakarta.validation.Valid
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.ModelAttribute
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.RestController
import com.ffii.fpsms.modules.jobOrder.service.JoPickOrderService
import com.ffii.fpsms.modules.productProcess.service.ProductProcessService
import com.ffii.fpsms.modules.jobOrder.web.model.*
import com.ffii.fpsms.modules.jobOrder.web.model.ExportPickRecordRequest
import com.ffii.fpsms.modules.jobOrder.web.model.PrintPickRecordRequest
import com.ffii.fpsms.modules.jobOrder.web.model.SecondScanSubmitRequest
import com.ffii.fpsms.modules.jobOrder.web.model.SecondScanIssueRequest
import jakarta.servlet.http.HttpServletResponse
import net.sf.jasperreports.engine.JasperExportManager
import net.sf.jasperreports.engine.JasperPrint
import org.aspectj.weaver.tools.UnsupportedPointcutPrimitiveException
import org.springframework.context.NoSuchMessageException
import java.io.OutputStream
import java.io.UnsupportedEncodingException
import java.text.ParseException
import org.springframework.web.bind.annotation.*  
import org.springframework.web.bind.annotation.RequestParam 
import com.ffii.fpsms.modules.jobOrder.web.model.UpdateJoPickOrderHandledByRequest
import com.ffii.fpsms.modules.jobOrder.entity.projections.JobOrderInfo
import com.ffii.fpsms.modules.jobOrder.entity.projections.JobOrderInfoWithTypeName
import com.ffii.fpsms.modules.jobOrder.web.model.ExportFGStockInLabelRequest
import com.ffii.fpsms.modules.bag.web.model.*
import com.ffii.fpsms.modules.master.web.models.MessageResponse
@RestController
@RequestMapping("/bag")
class BagController(
    private val bagService: BagService
) {

    @GetMapping("/bagInfo")
    fun getBagInfo(): List<BagInfo> {
        return bagService.getAllBagInfo()
    }
    @PostMapping("/createJoBagConsumption")
    fun createJoBagConsumption(@RequestBody request: CreateJoBagConsumptionRequest): MessageResponse {
        return bagService.createJoBagConsumption(request)
    }
    @GetMapping("/bagUsageRecords")
    fun getBagUsageRecords(): List<BagUsageRecordResponse> {
        return bagService.getAllBagUsageRecords()
    }
    @GetMapping("/bags")
    fun getBags(): List<BagSummaryResponse> =
        bagService.getBagSummaries()

    @GetMapping("/bags/{bagId}/lot-lines")
    fun getBagLotLines(@PathVariable bagId: Long): List<BagLotLineResponse> =
        bagService.getBagLotLines(bagId)

    @GetMapping("/lot-lines/{bagLotLineId}/consumptions")
    fun getBagConsumptions(@PathVariable bagLotLineId: Long): List<BagConsumptionResponse> =
        bagService.getBagConsumptions(bagLotLineId)

    @PutMapping("/by-item/{itemId}/soft-delete")
    fun softDeleteBagByItemId(@PathVariable itemId: Long): MessageResponse =
        bagService.softDeleteBagByItemId(itemId)
}