package org.springblade.mdm.program.controller; import com.baomidou.mybatisplus.core.metadata.IPage; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.tenant.annotation.NonDS; import org.springblade.core.tool.api.R; import org.springblade.mdm.program.service.DNCSendBackService; import org.springblade.mdm.program.service.DncBackFileService; import org.springblade.mdm.program.vo.*; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import java.util.List; /** * 流程管理接口 * * @author Chill */ @NonDS @RestController @RequestMapping("/program/dncsendback/") @AllArgsConstructor @Tag(name = "DNC导入", description = "DNC导入接口") @Slf4j public class DncSendBackController { private final DNCSendBackService dncSendBackService; private final DncBackFileService dncBackFileService; /** * 上传DNC回传文件 * * @param file dnc程序打包文件 */ @PostMapping("upload") @ApiOperationSupport(order = 1) @Operation(summary = "DNC回传文件导入,上传文件", description = "上传DNC回传文件,并返回解析结果") public R> dncSendBackUpload(@RequestParam MultipartFile file) { try { return R.data(dncSendBackService.dncSendBackUpload(file)); }catch (Exception e){ log.error("导入错误",e); return R.fail(e.getMessage()); } } @GetMapping("/back-file-content") @Operation(summary = "获取回传文件内容", description = "查看工控网回传文件内容") public R fileContent(@Parameter(description = "文件的entryName") String entryName) { try { return R.data(dncSendBackService.getEntryFileContent(entryName)); }catch(Exception e) { log.error("删除文件失败",e); return R.fail(e.getMessage()); } } @PostMapping("accept") @ApiOperationSupport(order = 2) @Operation(summary = "DNC回传数据入库", description = "入库,同时启动固化流程,入参为上传是解析的数据列表") public R dncSendBackAccept(@RequestParam String ids) { try { dncSendBackService.dncFileAccept(ids); }catch (Exception e){ log.error("入库错误",e); return R.fail(e.getMessage()); } return R.success(); } @Operation(summary = "工控网回传记录分页查询", description = "工控网回传记录分页查询,查询回传历史") @GetMapping("/dnc-back-page") public R> page(DncBackFileQueryVO query) { return R.data(dncBackFileService.pageQuery(query)); } @Operation(summary = "回传取消", description = "工控网回传记录中取消未开始执行的流程") @PostMapping("/cancel-process") public R cancelProcess(@Parameter(description = "回传记录id")long id) { try{ dncBackFileService.cancelProcess(id); return R.success(); }catch (Exception e){ log.error("流程取消失败",e); return R.fail(e.getMessage()); } } @Operation(summary = "获取回传记录的文件列表", description = "获取回传记录的文件列表") @GetMapping("/files-by-id") public R> filesById(long id) { try { return R.data(dncBackFileService.filesById(id)); }catch (Exception e){ log.error("获取历史文件列表失败",e); return R.fail(e.getMessage()); } } @GetMapping("/history-file-content") @Operation(summary = "临时记录回传文件内容", description = "临时记录回传文件内容") public R historyContent(@Parameter(description = "历史记录id")long id,@Parameter(description = "文件的entryName") String entryName) { try { return R.data(dncBackFileService.getEntryFileContent(id,entryName)); }catch(Exception e) { log.error("获取历史文件内容失败",e); return R.fail(e.getMessage()); } } }