| @@ -0,0 +1,52 @@ | |||||
| package com.ffii.fpsms.modules.jobOrder.service | |||||
| import com.ffii.fpsms.modules.jobOrder.entity.JobOrderRepository | |||||
| import com.ffii.fpsms.modules.jobOrder.web.model.PrintRequest | |||||
| import com.ffii.fpsms.modules.jobOrder.web.model.LaserRequest | |||||
| import org.springframework.stereotype.Service | |||||
| import com.ffii.core.support.JdbcDao | |||||
| @Service | |||||
| open class PSService( | |||||
| private val jdbcDao: JdbcDao, | |||||
| ) { | |||||
| fun searchProductionSchedules(produceAt: String): List<Map<String, Any>> { | |||||
| val args = mapOf( | |||||
| "produceAt" to produceAt, | |||||
| ) | |||||
| val sql = """ | |||||
| SELECT | |||||
| ps.* | |||||
| FROM production_schedule ps | |||||
| WHERE 1 | |||||
| and ps.produceAt >= :produceAt | |||||
| ORDER BY produceAt | |||||
| """.trimIndent() | |||||
| return jdbcDao.queryForList(sql, args) | |||||
| } | |||||
| fun getProductionScheduleLines(psId: Int): List<Map<String, Any>> { | |||||
| val args = mapOf( | |||||
| "psId" to psId, | |||||
| ) | |||||
| val sql = """ | |||||
| SELECT | |||||
| (select group_concat(distinct code) from job_order where prodScheduleLineId = psl.id) as joCode, | |||||
| it.code as itemCode, | |||||
| it.name as itemName, | |||||
| psl.* | |||||
| FROM production_schedule_line psl | |||||
| left join items it on psl.itemId = it.id | |||||
| WHERE psl.prodScheduleId = :psId | |||||
| ORDER BY psl.itemPriority DESC, itemCode ASC | |||||
| """.trimIndent() | |||||
| return jdbcDao.queryForList(sql, args) | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,33 @@ | |||||
| 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) | |||||
| } | |||||
| } | |||||
| @@ -7,3 +7,4 @@ INSERT INTO `fpsmsdb`.`authority` (`authority`, `name`) VALUES ('ADMIN', '行政 | |||||
| INSERT INTO `fpsmsdb`.`authority` (`authority`, `name`) VALUES ('STOCK', '倉務'); | INSERT INTO `fpsmsdb`.`authority` (`authority`, `name`) VALUES ('STOCK', '倉務'); | ||||
| INSERT INTO `fpsmsdb`.`authority` (`authority`, `name`) VALUES ('Driver', '物流'); | INSERT INTO `fpsmsdb`.`authority` (`authority`, `name`) VALUES ('Driver', '物流'); | ||||
| INSERT INTO `fpsmsdb`.`authority` (`authority`, `name`) VALUES ('PACK', '包裝'); | INSERT INTO `fpsmsdb`.`authority` (`authority`, `name`) VALUES ('PACK', '包裝'); | ||||