package com.ruoyi.production.controller; import com.ruoyi.framework.web.domain.R; import com.ruoyi.production.dto.SaveProductionPrintOrderDto; import com.ruoyi.production.pojo.ProductionPrintOrder; import com.ruoyi.production.service.ProductionPrintOrderService; import io.swagger.annotations.Api; import lombok.RequiredArgsConstructor; import lombok.SneakyThrows; import org.springframework.web.bind.annotation.*; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; import java.net.URLEncoder; /** * @author buhuazhen * @date 2026/4/23 * @email 3038525872@qq.com */ @RequestMapping("/productionProductInput") @RestController @Api(value = "印刷单") @RequiredArgsConstructor public class ProductionPrintOrderController { private final ProductionPrintOrderService productionPrintOrderService; @PostMapping("/save") public R save(@RequestBody SaveProductionPrintOrderDto dto) { productionPrintOrderService.save(dto); return R.ok(); } @PostMapping("/getByProductWordId/{id}") public ProductionPrintOrder getByProductWordId(@PathVariable Long id) { return productionPrintOrderService.getByProductWordId(id); } @PostMapping("/export/{id}") @SneakyThrows public void export(@PathVariable Long id, HttpServletResponse response) { byte[] bytes = productionPrintOrderService.exportPrintExcelByWordId(id); String fileName = "印刷定印单.xlsx"; response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setCharacterEncoding("utf-8"); // 解决中文文件名乱码 response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8")); ServletOutputStream out = response.getOutputStream(); out.write(bytes); out.flush(); } }