| | |
| | | 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 |
| | |
| | | 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(); |
| | | } |
| | | } |