| | |
| | | import org.springblade.mdm.program.vo.NcProgramExportDncPageVO; |
| | | import org.springblade.mdm.program.vo.NcProgramExportDncQueryVO; |
| | | import org.springblade.mdm.program.vo.NcProgramVO; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.server.ResponseStatusException; |
| | | |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.IOException; |
| | | import java.io.PrintWriter; |
| | | |
| | | /** |
| | | * 程序涉密网-工控网交换接口 |
| | |
| | | @RestController |
| | | @RequestMapping("/program/exchange") |
| | | @AllArgsConstructor |
| | | @Tag(name = "导出DNC", description = "涉密网程序导出DNC") |
| | | @Tag(name = "导出工控网", description = "涉密网程序导出给工控网") |
| | | @Slf4j |
| | | public class NcProgramExportDNCController { |
| | | |
| | |
| | | |
| | | @PostMapping("/export-dnc") |
| | | @Operation(summary = "数控程序导出dnc", description = "数控程序导出到工控网") |
| | | public void exportDnc(@RequestBody @Parameter(description = "审批表id数组") IdsVO vo, HttpServletResponse response) { |
| | | public void exportDnc(@RequestBody @Parameter(description = "审批表id数组") IdsVO vo, HttpServletResponse response) throws IOException { |
| | | if(vo.getIds() == null || vo.getIds().length == 0) { |
| | | throw new ServiceException("未选择文件导出"); |
| | | } |
| | | try { |
| | | String filename = "todncexp-"+ DateUtil.format(DateUtil.now(), "yyyyMMddHHmm")+".zip"; |
| | | response.setHeader("Content-Disposition", "attachment; filename="+filename); |
| | | response.setContentType("application/octet-stream"); |
| | | ncProgramExportDNCService.exportDnc(vo.getIds(),response.getOutputStream()); |
| | | } catch (IOException e) { |
| | | log.error("导出DNC异常", e); |
| | | throw new RuntimeException(e); |
| | | } |
| | | //try { |
| | | String filename = "programexp-"+ DateUtil.format(DateUtil.now(), "yyyyMMddHHmm")+".zip"; |
| | | response.setHeader("Content-Disposition", "attachment; filename="+filename); |
| | | response.setContentType("application/octet-stream"); |
| | | |
| | | ByteArrayOutputStream bos = new ByteArrayOutputStream(); |
| | | ncProgramExportDNCService.exportDnc(vo.getIds(),bos); |
| | | response.getOutputStream().write(bos.toByteArray()); |
| | | |
| | | |
| | | //} catch (Exception e) { |
| | | //log.error("导出DNC异常", e); |
| | | /* |
| | | |
| | | throw new ResponseStatusException( |
| | | HttpStatus.NO_CONTENT, |
| | | "参数只能包含字母", |
| | | new IllegalArgumentException("无效参数格式") |
| | | );*/ |
| | | //} |
| | | |
| | | } |
| | | |