package com.ffii.fpsms.modules.jobOrder.web

import com.ffii.fpsms.modules.jobOrder.service.PlasticBagPrinterService
import com.ffii.fpsms.modules.jobOrder.service.PSService
import com.ffii.fpsms.modules.jobOrder.web.model.PrintRequest
import com.ffii.fpsms.modules.jobOrder.web.model.LaserRequest
import jakarta.servlet.http.HttpServletResponse
import org.springframework.http.HttpHeaders
import org.springframework.web.bind.annotation.*
import java.time.LocalDate
import org.springframework.http.ResponseEntity

@RestController
@RequestMapping("/ps")
class PSController(
    private val psService: PSService,
) {
    @GetMapping("/search-ps")
    fun searchPs(@RequestParam produceAt: String): ResponseEntity<List<Map<String, Any>>> {
        // Returns fields: id, produceAt, totalEstProdCount, totalFGType
        val results = psService.searchProductionSchedules(produceAt)
        return ResponseEntity.ok(results)
    }

    @GetMapping("/search-ps-line")
    fun searchPsLine(@RequestParam psId: Int): ResponseEntity<List<Map<String, Any>>> {
        // Returns fields: id, itemCode, itemName, avgQtyLastMonth, stockQty, daysLeft, batchNeed, prodQty, itemPriority
        val results = psService.getProductionScheduleLines(psId)
        return ResponseEntity.ok(results)
    }
    

}