fix -- 修改流程定义模块,主页面显示最新版本的流程部署,添加“版本管理”页面。优化查询方法。
This commit is contained in:
@@ -1,13 +1,16 @@
|
||||
package com.ruoyi.web.controller.workflow;
|
||||
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.workflow.domain.dto.FlowProcDefDto;
|
||||
import com.ruoyi.workflow.domain.dto.FlowSaveXmlVo;
|
||||
import com.ruoyi.workflow.service.IFlowDefinitionService;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.system.service.ISysRoleService;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
import com.ruoyi.workflow.domain.dto.FlowSaveXmlVo;
|
||||
import com.ruoyi.workflow.domain.vo.FlowDefinitionVo;
|
||||
import com.ruoyi.workflow.service.IFlowDefinitionService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
@@ -32,14 +35,14 @@ import java.util.Map;
|
||||
* 工作流程定义
|
||||
* </p>
|
||||
*
|
||||
* @author XuanXuan
|
||||
* @date 2021-04-03
|
||||
* @author KonBAI
|
||||
* @date 2022-01-17
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags = "流程定义")
|
||||
@RestController
|
||||
@RequestMapping("/workflow/definition")
|
||||
public class FlowDefinitionController {
|
||||
public class FlowDefinitionController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private IFlowDefinitionService flowDefinitionService;
|
||||
@@ -52,45 +55,57 @@ public class FlowDefinitionController {
|
||||
|
||||
|
||||
@GetMapping(value = "/list")
|
||||
@ApiOperation(value = "流程定义列表", response = FlowProcDefDto.class)
|
||||
public R list(@ApiParam(value = "当前页码", required = true) @RequestParam Integer pageNum,
|
||||
@ApiParam(value = "每页条数", required = true) @RequestParam Integer pageSize) {
|
||||
return R.success(flowDefinitionService.list(pageNum, pageSize));
|
||||
@ApiOperation(value = "流程定义列表", response = FlowDefinitionVo.class)
|
||||
public TableDataInfo<FlowDefinitionVo> list(PageQuery pageQuery) {
|
||||
return flowDefinitionService.list(pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列出指定流程的发布版本列表
|
||||
* @param processKey 流程定义Key
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/publishList")
|
||||
@ApiOperation(value = "流程定义列表", response = FlowDefinitionVo.class)
|
||||
public TableDataInfo<FlowDefinitionVo> publishList(@ApiParam(value = "流程定义Key", required = true) @RequestParam String processKey,
|
||||
PageQuery pageQuery) {
|
||||
return flowDefinitionService.publishList(processKey, pageQuery);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "导入流程文件", notes = "上传bpmn20的xml文件")
|
||||
@PostMapping("/import")
|
||||
public R importFile(@RequestParam(required = false) String name,
|
||||
@RequestParam(required = false) String category,
|
||||
MultipartFile file) {
|
||||
public R<Void> importFile(@RequestParam(required = false) String name,
|
||||
@RequestParam(required = false) String category,
|
||||
MultipartFile file) {
|
||||
try (InputStream in = file.getInputStream()) {
|
||||
flowDefinitionService.importFile(name, category, in);
|
||||
} catch (Exception e) {
|
||||
log.error("导入失败:", e);
|
||||
return R.success(e.getMessage());
|
||||
return error(e.getMessage());
|
||||
}
|
||||
|
||||
return R.success("导入成功");
|
||||
return success("导入成功");
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "读取xml文件")
|
||||
@GetMapping("/readXml/{deployId}")
|
||||
public R readXml(@ApiParam(value = "流程定义id") @PathVariable(value = "deployId") String deployId) {
|
||||
@GetMapping("/readXml/{definitionId}")
|
||||
public R<String> readXml(@ApiParam(value = "流程定义ID") @PathVariable(value = "definitionId") String definitionId) {
|
||||
try {
|
||||
return flowDefinitionService.readXml(deployId);
|
||||
return R.success(null, flowDefinitionService.readXml(definitionId));
|
||||
} catch (Exception e) {
|
||||
return R.error("加载xml文件异常");
|
||||
return R.error("加载xml文件异常", null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ApiOperation(value = "读取图片文件")
|
||||
@GetMapping("/readImage/{deployId}")
|
||||
public void readImage(@ApiParam(value = "流程定义id") @PathVariable(value = "deployId") String deployId, HttpServletResponse response) {
|
||||
@GetMapping("/readImage/{definitionId}")
|
||||
public void readImage(@ApiParam(value = "流程定义id") @PathVariable(value = "definitionId") String definitionId,
|
||||
HttpServletResponse response) {
|
||||
try (OutputStream os = response.getOutputStream()) {
|
||||
BufferedImage image = ImageIO.read(flowDefinitionService.readImage(deployId));
|
||||
BufferedImage image = ImageIO.read(flowDefinitionService.readImage(definitionId));
|
||||
response.setContentType("image/png");
|
||||
if (image != null) {
|
||||
ImageIO.write(image, "png", os);
|
||||
@@ -103,51 +118,52 @@ public class FlowDefinitionController {
|
||||
|
||||
@ApiOperation(value = "保存流程设计器内的xml文件")
|
||||
@PostMapping("/save")
|
||||
public R save(@RequestBody FlowSaveXmlVo vo) {
|
||||
public R<Void> save(@RequestBody FlowSaveXmlVo vo) {
|
||||
try (InputStream in = new ByteArrayInputStream(vo.getXml().getBytes(StandardCharsets.UTF_8))) {
|
||||
flowDefinitionService.importFile(vo.getName(), vo.getCategory(), in);
|
||||
} catch (Exception e) {
|
||||
log.error("导入失败:", e);
|
||||
return R.success(e.getMessage());
|
||||
return success(e.getMessage());
|
||||
}
|
||||
|
||||
return R.success("导入成功");
|
||||
return success("导入成功");
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "根据流程定义id启动流程实例")
|
||||
@PostMapping("/start/{procDefId}")
|
||||
public R start(@ApiParam(value = "流程定义id") @PathVariable(value = "procDefId") String procDefId,
|
||||
@ApiParam(value = "变量集合,json对象") @RequestBody Map<String, Object> variables) {
|
||||
return flowDefinitionService.startProcessInstanceById(procDefId, variables);
|
||||
public R<Void> start(@ApiParam(value = "流程定义id") @PathVariable(value = "procDefId") String procDefId,
|
||||
@ApiParam(value = "变量集合,json对象") @RequestBody Map<String, Object> variables) {
|
||||
flowDefinitionService.startProcessInstanceById(procDefId, variables);
|
||||
return success("流程启动成功");
|
||||
|
||||
}
|
||||
|
||||
@ApiOperation(value = "激活或挂起流程定义")
|
||||
@PutMapping(value = "/updateState")
|
||||
public R updateState(@ApiParam(value = "1:激活,2:挂起", required = true) @RequestParam Integer state,
|
||||
@ApiParam(value = "流程部署ID", required = true) @RequestParam String deployId) {
|
||||
flowDefinitionService.updateState(state, deployId);
|
||||
return R.success();
|
||||
public R<Void> updateState(@ApiParam(value = "ture:挂起,false:激活", required = true) @RequestParam Boolean suspended,
|
||||
@ApiParam(value = "流程定义ID", required = true) @RequestParam String definitionId) {
|
||||
flowDefinitionService.updateState(suspended, definitionId);
|
||||
return success();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除流程")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public R delete(@ApiParam(value = "流程部署ID", required = true) @RequestParam String deployId) {
|
||||
public R<Void> delete(@ApiParam(value = "流程部署ID", required = true) @RequestParam String deployId) {
|
||||
flowDefinitionService.delete(deployId);
|
||||
return R.success();
|
||||
return success();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "指定流程办理人员列表")
|
||||
@GetMapping("/userList")
|
||||
public R userList(SysUser user) {
|
||||
public R<List<SysUser>> userList(SysUser user) {
|
||||
List<SysUser> list = userService.selectUserList(user);
|
||||
return R.success(list);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "指定流程办理组列表")
|
||||
@GetMapping("/roleList")
|
||||
public R roleList(SysRole role) {
|
||||
public R<List<SysRole>> roleList(SysRole role) {
|
||||
List<SysRole> list = sysRoleService.selectRoleList(role);
|
||||
return R.success(list);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user