| | |
| | | @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); |
| | | } |
| | | |
| | |
| | | |
| | | return R.data(approveRecordService.listByNcProgramId(ncProgramId)); |
| | | } |
| | | /* |
| | | @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()); |
| | | } |
| | | } |
| | | } |