buhuazhen
2026-04-25 6039d8cd64e73970d196094bd66836944f508c59
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
@@ -34,8 +39,17 @@
    }
    @PostMapping("/export/{id}")
    public R  export(@PathVariable Long id){
        productionPrintOrderService.exportPrintExcelByWordId(id);
        return R.ok();
    @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();
    }
}