| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.oss.OssTemplate; |
| | | import org.springblade.core.tenant.annotation.NonDS; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.mdm.flow.entity.FlowProgramFile; |
| | | import org.springblade.mdm.flow.service.FlowProgramFileService; |
| | | import org.springblade.mdm.flow.service.TaskDispatchService; |
| | | import org.springblade.mdm.program.entity.NcNode; |
| | |
| | | import org.springblade.mdm.program.vo.NcNodeQueryVO; |
| | | import org.springblade.mdm.program.vo.NcNodeVO; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.io.IOException; |
| | |
| | | @Tag(name = "程序节点", description = "程序节点") |
| | | @Slf4j |
| | | public class NcNodeHisController { |
| | | private final NcNodeService ncNodeService; |
| | | private final OssTemplate ossTemplate; |
| | | private final NcNodeHisService nodeHisService; |
| | | private final FlowProgramFileService flowProgramFileService; |
| | | |
| | |
| | | return R.fail(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @GetMapping("/link-by-nodeid") |
| | | @Operation(summary = "根据节点获取文件内容", description = "仅限文本格式的内容,二进制文件将返回空串") |
| | | public R<String> fileLinkByNodeId(@Parameter(description = "节点id") Long nodeId) { |
| | | try { |
| | | NcNodeHis node = this.nodeHisService.getById(nodeId); |
| | | FlowProgramFile flowFile = this.flowProgramFileService.getById(node.getFlowProgramFileId()); |
| | | |
| | | if(node.getFlowProgramFileId() != null || flowFile == null) { |
| | | return R.data(this.ossTemplate.fileLink(flowFile.getOssName())); |
| | | }else{ |
| | | return R.data(""); |
| | | } |
| | | }catch(Exception e) { |
| | | log.error("获取文件内容失败",e); |
| | | return R.fail(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @GetMapping("/download-by-nodeid") |
| | | @Operation(summary = "下载节点对应的文件", description = "下载节点对应的文件") |
| | | public void downloadByNodeId(@Parameter(description = "节点id") Long nodeId, HttpServletResponse response) throws IOException { |
| | | |
| | | NcNodeHis node = nodeHisService.getById(nodeId); |
| | | if(node.getFlowProgramFileId() != null) { |
| | | flowProgramFileService.download(node.getFlowProgramFileId(),response); |
| | | }else{ |
| | | log.error("非文件节点"); |
| | | throw new ServiceException("节点无文件id"); |
| | | } |
| | | |
| | | } |
| | | } |