liyong
2026-05-21 8e89f95b9db4039f0cb8b4b8dc7974c247366c4c
src/main/java/com/ruoyi/production/controller/ProductionPrintOrderController.java
@@ -6,7 +6,12 @@
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
@@ -22,15 +27,29 @@
    private final ProductionPrintOrderService productionPrintOrderService;
    @PostMapping("/save")
    public R save(@RequestBody SaveProductionPrintOrderDto dto){
    public R save(@RequestBody SaveProductionPrintOrderDto dto) {
        productionPrintOrderService.save(dto);
        return R.ok();
    }
    @PostMapping("/getByProductWordId/{id}")
    public ProductionPrintOrder getByProductWordId(@PathVariable Long 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();
    }
}