| | |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.tenant.annotation.NonDS; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.DateUtil; |
| | | import org.springblade.mdm.commons.vo.IdsVO; |
| | | import org.springblade.mdm.program.service.NcProgramApprovedService; |
| | | import org.springblade.mdm.program.service.NcProgramExportDNCService; |
| | | import org.springblade.mdm.program.service.NcProgramService; |
| | | import org.springblade.mdm.program.vo.NcNodeProgramQueryVO; |
| | | import org.springblade.mdm.program.vo.NcProgramExportDncPageVO; |
| | | import org.springblade.mdm.program.vo.NcProgramExportDncQueryVO; |
| | | import org.springblade.mdm.program.vo.NcProgramVO; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.io.IOException; |
| | | |
| | | /** |
| | | * 程序涉密网-工控网交换接口 |
| | |
| | | |
| | | private final NcProgramService ncProgramService; |
| | | private final NcProgramApprovedService ncProgramApprovedService; |
| | | private final NcProgramExportDNCService ncProgramExportDNCService; |
| | | @Operation(summary = "程序导出DNC分页查询", description = "分页查询,供用户选择数据") |
| | | @GetMapping("/export-dnc-page") |
| | | public R<IPage<NcProgramExportDncPageVO>> page(NcProgramExportDncQueryVO query) { |
| | | //IPage<NcProgramVO> pages = ncProgramService.pageQuery(query); |
| | | return R.data(ncProgramApprovedService.exportDncPageQuery(query)); |
| | | } |
| | | |
| | | @PostMapping("/export-dnc") |
| | | @Operation(summary = "数控程序导出dnc", description = "数控程序导出到工控网") |
| | | public void exportDnc(Long nodeId, HttpServletResponse response) { |
| | | public void exportDnc(@RequestBody @Parameter(description = "审批表id数组") IdsVO vo, HttpServletResponse response) { |
| | | 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); |
| | | } |
| | | |
| | | //return R.<Boolean>status(true); |
| | | } |
| | | |
| | | } |