| | |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.flowable.engine.task.Comment; |
| | | import org.flowable.task.api.history.HistoricTaskInstance; |
| | | import org.springblade.core.tenant.annotation.NonDS; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.mdm.flow.service.ApproveRecordService; |
| | | import org.springblade.mdm.flow.vo.ApproveRecordVO; |
| | | import org.springblade.mdm.flow.vo.TaskTraceVO; |
| | | 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.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | |
| | | private final NcProgramService ncProgramService; |
| | | private final ProcessProgRefService ncProcessProgRefService; |
| | | |
| | | private final ApproveRecordService approveRecordService; |
| | | |
| | | @PostMapping("/upload") |
| | | @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); |
| | | try { |
| | | boolean existOther = ncProgramService.programExistsUnderOtherNode(uploadVO.getNodeId(), uploadVO.getFile().getOriginalFilename()); |
| | | if (existOther) { |
| | | //程序存在,则返回提示信息 |
| | | return R.fail("程序其他节点已存在"); |
| | | } |
| | | if (uploadVO.getConfirm() == null || uploadVO.getConfirm() != 1) { |
| | | //默认情况,需要检查程序是否存在 |
| | | boolean exists = ncProgramService.programExistsUnderNode(uploadVO.getNodeId(), uploadVO.getFile().getOriginalFilename()); |
| | | if (exists) { |
| | | //程序存在,则返回提示信息 |
| | | return R.fail(2, "存在重复程序名"); |
| | | } else { |
| | | ncProgramService.uploadProgramFileNew(uploadVO); |
| | | } |
| | | } else { |
| | | //同名文件用户确认上传了() |
| | | ncProgramService.uploadProgramFileNew(uploadVO); |
| | | } |
| | | }catch(Exception e) { |
| | | log.error("程序上传执行错误",e); |
| | | return R.fail("上传失败:" + e.getMessage()); |
| | | } |
| | | return R.success(); |
| | | } |
| | | |
| | | @PostMapping("/remove") |
| | |
| | | |
| | | @GetMapping("/content") |
| | | @Operation(summary = "获取文件内容", description = "仅限文本格式的内容,二进制文件将返回空串") |
| | | public R<String> fileContent(Long id) { |
| | | public R<String> fileContent(@Parameter(description = "程序文件id") Long id) { |
| | | try { |
| | | return R.data(ncProgramService.getFileContent(id)); |
| | | }catch(Exception e) { |
| | | log.error("删除文件失败",e); |
| | | return R.fail(e.getMessage()); |
| | | } |
| | | } |
| | | @GetMapping("/content-by-nodeid") |
| | | @Operation(summary = "根据节点获取文件内容", description = "仅限文本格式的内容,二进制文件将返回空串") |
| | | public R<String> fileContentByNodeId(@Parameter(description = "节点id") Long nodeId) { |
| | | try { |
| | | return R.data(ncProgramService.getFileContentByNodeId(nodeId)); |
| | | }catch(Exception e) { |
| | | log.error("删除文件失败",e); |
| | | return R.fail(e.getMessage()); |
| | |
| | | |
| | | @PostMapping("/upgrade-process-edition") |
| | | @Operation(summary = "升版", description = "升级工序版次") |
| | | public R<Boolean> upgradeProcessEdition(Long id,String newProcessEdition ) { |
| | | ncProgramService.upgradeProcessEdition(id,newProcessEdition); |
| | | public R<Boolean> upgradeProcessEdition(Long bindNcNodeId,String newProcessEdition ) { |
| | | ncProgramService.upgradeProcessEdition(bindNcNodeId,newProcessEdition); |
| | | return R.<Boolean>status(true); |
| | | } |
| | | |
| | |
| | | public R<List<NcProgramVO>> listByProcess(@Parameter(description="所属节点ID")@RequestParam String processInstanceId) { |
| | | return R.data(ncProcessProgRefService.listByProcess(processInstanceId)); |
| | | } |
| | | |
| | | @Operation(summary = "操作日志", description = "程序操作日志,即审批记录,在主页点击某一个程序后的下方标签显示") |
| | | @GetMapping("approve-records") |
| | | public R<List<ApproveRecordVO>> processTrace1(@Parameter(description = "程序id") Long ncProgramId){ |
| | | List<TaskTraceVO> result = new ArrayList<>(); |
| | | |
| | | return R.data(approveRecordService.listByNcProgramId(ncProgramId)); |
| | | } |
| | | |
| | | @GetMapping("/history-by-bindnodeid") |
| | | @Operation(summary = "根据绑定节点id获取历史列表", description = "程序历史列表,仅‘程序包’字典值70的数据。用于显示程序的‘历史版本’") |
| | | public R<List<NcProgramVO>> historyByBindNodeId(@Parameter(description="节点ID(nodeType=70的节点id)")@RequestParam Long bindNodeId) { |
| | | return R.data(ncProgramService.historyByBindNode(bindNodeId)); |
| | | } |
| | | /* |
| | | @PostMapping("/send") |
| | | @Operation(summary = "程序下发", description = "工控网数控程序下发(发送到机床配置的下发目录),根据id") |
| | | public R<List<NcProgramVO>> send(@Parameter(description="所属节点ID")@RequestParam Long id) { |
| | | return null;//R.data(ncProcessProgRefService.listByProcess(processInstanceId)); |
| | | }*/ |
| | | |
| | | @PostMapping("/send-to-machine-by-nodeid") |
| | | @Operation(summary = "程序下发", description = "下发给机床设定的目录") |
| | | public R<Void> sendToMachineByNodeId(@Parameter(description = "节点id") Long nodeId) { |
| | | try { |
| | | ncProgramService.sendByBindNodeId(nodeId); |
| | | return R.success(); |
| | | }catch(Exception e) { |
| | | log.error("删除文件失败",e); |
| | | return R.fail(e.getMessage()); |
| | | } |
| | | } |
| | | } |