| | |
| | | |
| | | package org.springblade.mdm.program.controller; |
| | | |
| | | 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 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.entity.NcProgram; |
| | | import org.springblade.mdm.program.service.NcProgramService; |
| | | import org.springblade.mdm.program.service.ProcessProgRefService; |
| | | import org.springblade.mdm.program.vo.NcNodeProgramQueryVO; |
| | | import org.springblade.mdm.program.vo.NcProgramUploadVO; |
| | | import org.springblade.mdm.program.vo.NcProgramVO; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 程序节点 |
| | |
| | | public class NcProgramController { |
| | | |
| | | private final NcProgramService ncProgramService; |
| | | |
| | | private final ProcessProgRefService ncProcessProgRefService; |
| | | @PostMapping("/upload") |
| | | @Operation(summary = "上传", description = "上传程序/附件文件") |
| | | public R<Boolean> upload(@RequestParam MultipartFile file,Long nodeId, |
| | | @RequestParam String category) { |
| | | ncProgramService.uploadNcFile(file,nodeId,category); |
| | | @Operation(summary = "上传文件", description = "上传程序/附件文件") |
| | | public R<Boolean> upload(NcProgramUploadVO uploadVO) { |
| | | //@Parameter(description="文件") @RequestPart("file") MultipartFile file, @Parameter(description="所属节点ID")@RequestParam Long nodeId, |
| | | // @Parameter(description="文件分类,使用字典(node_file_type)") @RequestParam String category |
| | | ncProgramService.uploadProgramFile(uploadVO); |
| | | return R.<Boolean>status(true); |
| | | } |
| | | |
| | | @PostMapping("/remove") |
| | | @Operation(summary = "删除程序文件", description = "") |
| | | public R<Boolean> removeFile(Long id) { |
| | | try { |
| | | ncProgramService.removeProgram(id); |
| | | return R.success(); |
| | | }catch(Exception e) { |
| | | log.error("删除文件失败",e); |
| | | return R.fail(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @GetMapping("/content") |
| | | @Operation(summary = "获取文件内容", description = "仅限文本格式的内容,二进制文件将返回空串") |
| | | public R<String> fileContent(Long id) { |
| | | try { |
| | | return R.data(ncProgramService.getFileContent(id)); |
| | | }catch(Exception e) { |
| | | log.error("删除文件失败",e); |
| | | return R.fail(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @GetMapping("/list-by-node") |
| | | @Operation(summary = "节点程序文件列表", description = "某节点内的程序列表,仅‘程序包’字典值60") |
| | | public R<List<NcProgramVO>> listByNode(@Parameter(description="所属节点ID")@RequestParam Long nodeId) { |
| | | return R.data(ncProgramService.listByNode(nodeId)); |
| | | } |
| | | |
| | | @PostMapping("/upgrade-process-edition") |
| | | @Operation(summary = "升版", description = "升级工序版次") |
| | | public R<Boolean> upgradeProcessEdition(Long id,String newProcessEdition ) { |
| | | ncProgramService.upgradeProcessEdition(id,newProcessEdition); |
| | | return R.<Boolean>status(true); |
| | | } |
| | | |
| | | @Operation(summary = "程序分页查询", description = "用于在编制节点选择流程对应的程序") |
| | | @GetMapping("/programpickpage") |
| | | public R<IPage<NcProgramVO>> page(NcNodeProgramQueryVO query) { |
| | | IPage<NcProgramVO> pages = ncProgramService.pageQuery(query); |
| | | return R.data(pages); |
| | | } |
| | | |
| | | @GetMapping("/list-by-process") |
| | | @Operation(summary = "流程已选程序文件列表", description = "流程已选程序列表") |
| | | public R<List<NcProgramVO>> listByProcess(@Parameter(description="所属节点ID")@RequestParam String processInstanceId) { |
| | | return R.data(ncProcessProgRefService.listByProcess(processInstanceId)); |
| | | } |
| | | } |