liyong
2026-04-25 0d9b0dab20eae44c817944e98c967dfd8832f580
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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();
    }
}