diff --git a/len-activiti/src/main/java/com/len/actlistener/ActNodeListener.java b/len-activiti/src/main/java/com/len/actlistener/ActNodeListener.java
index 0fdb201..7419cd7 100644
--- a/len-activiti/src/main/java/com/len/actlistener/ActNodeListener.java
+++ b/len-activiti/src/main/java/com/len/actlistener/ActNodeListener.java
@@ -5,7 +5,9 @@ import com.len.service.ActAssigneeService;
import com.len.service.impl.ActAssigneeServiceImpl;
import com.len.util.AssigneeType;
import com.len.util.SpringUtil;
+
import java.util.List;
+
import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.TaskListener;
@@ -13,25 +15,26 @@ import org.activiti.engine.delegate.TaskListener;
* @author zhuxiaomeng
* @date 2018/1/20.
* @email 154040976@qq.com
- *
+ *
* 流程监听器 动态注入节点办理人
*/
-public class ActNodeListener implements TaskListener{
+public class ActNodeListener implements TaskListener {
- @Override
- public void notify(DelegateTask delegateTask) {
- String nodeId=delegateTask.getTaskDefinitionKey();//key
- ActAssigneeService actAssigneeService= SpringUtil.getBean(ActAssigneeServiceImpl.class);
- List assigneeList=actAssigneeService.selectListByPage(new ActAssignee(nodeId));
- for(ActAssignee assignee:assigneeList){
- switch (assignee.getAssigneeType()){
- case AssigneeType.GROUP_TYPE:
- delegateTask.addCandidateGroup(assignee.getRoleId());
- break;
- case AssigneeType.USER_TYPE:
- delegateTask.addCandidateUser(assignee.getAssignee());
- break;
+ @Override
+ public void notify(DelegateTask delegateTask) {
+ //KEY
+ String nodeId = delegateTask.getTaskDefinitionKey();
+ ActAssigneeService actAssigneeService = SpringUtil.getBean(ActAssigneeServiceImpl.class);
+ List assigneeList = actAssigneeService.selectListByPage(new ActAssignee(nodeId));
+ for (ActAssignee assignee : assigneeList) {
+ switch (assignee.getAssigneeType()) {
+ case AssigneeType.GROUP_TYPE:
+ delegateTask.addCandidateGroup(assignee.getRoleId());
+ break;
+ case AssigneeType.USER_TYPE:
+ delegateTask.addCandidateUser(assignee.getAssignee());
+ break;
+ }
+ }
}
- }
- }
}
diff --git a/len-activiti/src/main/java/com/len/actlistener/LeaveListenerImpl.java b/len-activiti/src/main/java/com/len/actlistener/LeaveListenerImpl.java
index 87756c8..e90ff28 100644
--- a/len-activiti/src/main/java/com/len/actlistener/LeaveListenerImpl.java
+++ b/len-activiti/src/main/java/com/len/actlistener/LeaveListenerImpl.java
@@ -1,26 +1,26 @@
package com.len.actlistener;
import com.len.entity.UserLeave;
+
import java.util.Map;
+
import org.activiti.engine.delegate.DelegateTask;
/**
* @author zhuxiaomeng
* @date 2018/1/25.
* @email 154040976@qq.com
- *
+ *
* 自定义请假流程 监听器
*/
public class LeaveListenerImpl extends ActNodeListener {
- @Override
- public void notify(DelegateTask delegateTask) {
- super.notify(delegateTask);
- String taskId=delegateTask.getId();
- System.out.println(taskId);
- Map map =delegateTask.getVariables();
- UserLeave userLeave= (UserLeave) map.get("userLeave");
- delegateTask.addCandidateUser(userLeave.getUserId());
- System.out.println(userLeave);
- }
+ @Override
+ public void notify(DelegateTask delegateTask) {
+ super.notify(delegateTask);
+ String taskId = delegateTask.getId();
+ Map map = delegateTask.getVariables();
+ UserLeave userLeave = (UserLeave) map.get("userLeave");
+ delegateTask.addCandidateUser(userLeave.getUserId());
+ }
}
diff --git a/len-activiti/src/main/java/com/len/actlistener/ListenUserRole.java b/len-activiti/src/main/java/com/len/actlistener/ListenUserRole.java
index e89910c..3149bd3 100644
--- a/len-activiti/src/main/java/com/len/actlistener/ListenUserRole.java
+++ b/len-activiti/src/main/java/com/len/actlistener/ListenUserRole.java
@@ -6,9 +6,11 @@ import com.len.entity.SysUser;
import com.len.service.ActAssigneeService;
import com.len.service.SysUserService;
import com.len.util.JsonUtil;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+
import org.activiti.engine.IdentityService;
import org.activiti.engine.identity.Group;
import org.activiti.engine.identity.User;
@@ -26,157 +28,153 @@ import org.springframework.stereotype.Component;
* @author zhuxiaomeng
* @date 2018/1/25.
* @email 154040976@qq.com
- *
+ *
* 切入实现系统用户 角色 用户-角色 同步到 activiti 用户 组 用户组 同步到工作流,模块化 无侵入
- *
- *
*/
@Aspect
@Component
public class ListenUserRole {
- @Autowired
- IdentityService identityService;
+ @Autowired
+ IdentityService identityService;
- @Autowired
- SysUserService userService;
+ @Autowired
+ SysUserService userService;
- /**********************用户处理begin***************************/
- /**
- * 明确切入方法的参数
- * @param joinPoint
- */
- @Around("execution(com.len.util.JsonUtil com.len.controller.UserController.updateUser(*,String[]))")
- public Object listenerUserUpdate(ProceedingJoinPoint joinPoint) throws Throwable{
- Object o=new Object();
- //更新前拿到用户-角色数据
- SysRoleUser sysRoleUser =new SysRoleUser();
- Object[] args = joinPoint.getArgs();
- sysRoleUser.setUserId(((SysUser)args[0]).getId());
- List keyList=userService.selectByCondition(sysRoleUser);
- List strings=new ArrayList<>();
- keyList.forEach(sysRoleUser1 -> strings.add(sysRoleUser1.getRoleId()));
- o = joinPoint.proceed(joinPoint.getArgs());
- JsonUtil jsonUtil= (JsonUtil) o;
- if(jsonUtil.isFlag()){
- changeUser(args,strings);
- }
- return o;
- }
-
- /**
- * 新增用户监听 同步工作流用户表 环绕注解能得到 插入用户id 啊哈哈
- * @param joinPoint
- */
- @Around("execution(com.len.util.JsonUtil com.len.controller.UserController.addUser(*,String[]))")
- public Object listenerUserInsert(ProceedingJoinPoint joinPoint) throws Throwable{
- Object o=new Object();
- o = joinPoint.proceed(joinPoint.getArgs());
- Object[] args = joinPoint.getArgs();
- if(args.length==2){
- JsonUtil jsonUtil= (JsonUtil) o;
- if(jsonUtil.isFlag()){
- changeUser(args, Arrays.asList((String[]) args[1]));
- }
- }
- return o;
- }
-
- @Around("execution(com.len.util.JsonUtil com.len.controller.UserController.del(..))")
- public Object listenDelUser(ProceedingJoinPoint point) throws Throwable{
- Object o=new Object();
- o = point.proceed(point.getArgs());
- JsonUtil util= (JsonUtil) o;
- if(util.isFlag()){
- Object[] args = point.getArgs();
- identityService.deleteUser((String) args[0]);
- }
- return o;
- }
-
-
- /**
- * 保存进 activiti 用户 角色 用户角色中间表
- * @param obj
- */
- private void changeUser(Object[] obj,List strings){
- SysUser user= (SysUser) obj[0];
- identityService.deleteUser(user.getId());
- User au =new UserEntity();
- au.setId(user.getId());
- au.setFirstName(user.getRealName());
- au.setEmail(user.getEmail());
- identityService.saveUser(au);
-
- //删除用户-组关联
- for(String roleId:strings){
- identityService.deleteMembership(user.getId(),roleId);
- }
- //再次关联
- if(!strings.isEmpty()){
- for(String roleId:strings){
- identityService.createMembership(user.getId(),roleId);
- }
- }
- }
-
- /**********************用户处理end***************************/
-
-
-
- /**********************角色处理begin***************************/
- @Around("execution(com.len.util.JsonUtil com.len.controller.RoleController.addRole(*,String[]))")
- public Object listenRoleInsert(ProceedingJoinPoint joinPoint)throws Throwable{
- Object o=null;
- o=joinPoint.proceed(joinPoint.getArgs());
- JsonUtil j=(JsonUtil)o;
- if(j.isFlag()){
+ /**********************用户处理begin***************************/
+ /**
+ * 明确切入方法的参数
+ *
+ * @param joinPoint
+ */
+ @Around("execution(com.len.util.JsonUtil com.len.controller.UserController.updateUser(*,String[]))")
+ public Object listenerUserUpdate(ProceedingJoinPoint joinPoint) throws Throwable {
+ Object o = new Object();
+ //更新前拿到用户-角色数据
+ SysRoleUser sysRoleUser = new SysRoleUser();
Object[] args = joinPoint.getArgs();
- if(args.length==2){
- changeRole(args);
+ sysRoleUser.setUserId(((SysUser) args[0]).getId());
+ List keyList = userService.selectByCondition(sysRoleUser);
+ List strings = new ArrayList<>();
+ keyList.forEach(sysRoleUser1 -> strings.add(sysRoleUser1.getRoleId()));
+ o = joinPoint.proceed(joinPoint.getArgs());
+ JsonUtil jsonUtil = (JsonUtil) o;
+ if (jsonUtil.isFlag()) {
+ changeUser(args, strings);
}
- }
- return o;
- }
+ return o;
+ }
- @Around("execution(com.len.util.JsonUtil com.len.controller.RoleController.updateUser(*,String[]))")
- public Object listenRoleUpdate(ProceedingJoinPoint joinPoint) throws Throwable{
- Object o=null;
- o=joinPoint.proceed(joinPoint.getArgs());
- Object[] args = joinPoint.getArgs();
- if(args.length==2){
- if(((JsonUtil)o).isFlag()){
- changeRole(args);
+ /**
+ * 新增用户监听 同步工作流用户表 环绕注解能得到 插入用户id 啊哈哈
+ *
+ * @param joinPoint
+ */
+ @Around("execution(com.len.util.JsonUtil com.len.controller.UserController.addUser(*,String[]))")
+ public Object listenerUserInsert(ProceedingJoinPoint joinPoint) throws Throwable {
+ Object o = joinPoint.proceed(joinPoint.getArgs());
+ Object[] args = joinPoint.getArgs();
+ if (args.length == 2) {
+ JsonUtil jsonUtil = (JsonUtil) o;
+ if (jsonUtil.isFlag()) {
+ changeUser(args, Arrays.asList((String[]) args[1]));
+ }
}
- }
+ return o;
+ }
- return o;
- }
+ @Around("execution(com.len.util.JsonUtil com.len.controller.UserController.del(..))")
+ public Object listenDelUser(ProceedingJoinPoint point) throws Throwable {
+ Object o = point.proceed(point.getArgs());
+ JsonUtil util = (JsonUtil) o;
+ if (util.isFlag()) {
+ Object[] args = point.getArgs();
+ identityService.deleteUser((String) args[0]);
+ }
+ return o;
+ }
- @Around("execution(com.len.util.JsonUtil com.len.controller.RoleController.del(..))")
- public Object listenDelRole(ProceedingJoinPoint point) throws Throwable{
- Object o=new Object();
- o = point.proceed(point.getArgs());
- JsonUtil util= (JsonUtil) o;
- if(util.isFlag()){
- Object[] args = point.getArgs();
- identityService.deleteGroup((String) args[0]);
- }
- return o;
- }
- /**
- * 更新进组
- * @param obj
- */
- public void changeRole(Object[] obj){
- SysRole role = (SysRole) obj[0];
- identityService.deleteGroup(role.getId());
- Group group=new GroupEntity();
- group.setId(role.getId());
- group.setName(role.getRoleName());
- identityService.saveGroup(group);
- }
+ /**
+ * 保存进 activiti 用户 角色 用户角色中间表
+ *
+ * @param obj
+ */
+ private void changeUser(Object[] obj, List strings) {
+ SysUser user = (SysUser) obj[0];
+ identityService.deleteUser(user.getId());
+ User au = new UserEntity();
+ au.setId(user.getId());
+ au.setFirstName(user.getRealName());
+ au.setEmail(user.getEmail());
+ identityService.saveUser(au);
- /**********************角色处理end***************************/
+ //删除用户-组关联
+ for (String roleId : strings) {
+ identityService.deleteMembership(user.getId(), roleId);
+ }
+ //再次关联
+ if (!strings.isEmpty()) {
+ for (String roleId : strings) {
+ identityService.createMembership(user.getId(), roleId);
+ }
+ }
+ }
+
+ /**********************用户处理end***************************/
+
+
+ /**********************角色处理begin***************************/
+ @Around("execution(com.len.util.JsonUtil com.len.controller.RoleController.addRole(*,String[]))")
+ public Object listenRoleInsert(ProceedingJoinPoint joinPoint) throws Throwable {
+ Object o = joinPoint.proceed(joinPoint.getArgs());
+ JsonUtil j = (JsonUtil) o;
+ if (j.isFlag()) {
+ Object[] args = joinPoint.getArgs();
+ if (args.length == 2) {
+ changeRole(args);
+ }
+ }
+ return o;
+ }
+
+ @Around("execution(com.len.util.JsonUtil com.len.controller.RoleController.updateUser(*,String[]))")
+ public Object listenRoleUpdate(ProceedingJoinPoint joinPoint) throws Throwable {
+ Object o = joinPoint.proceed(joinPoint.getArgs());
+ Object[] args = joinPoint.getArgs();
+ if (args.length == 2) {
+ if (((JsonUtil) o).isFlag()) {
+ changeRole(args);
+ }
+ }
+
+ return o;
+ }
+
+ @Around("execution(com.len.util.JsonUtil com.len.controller.RoleController.del(..))")
+ public Object listenDelRole(ProceedingJoinPoint point) throws Throwable {
+ Object o = point.proceed(point.getArgs());
+ JsonUtil util = (JsonUtil) o;
+ if (util.isFlag()) {
+ Object[] args = point.getArgs();
+ identityService.deleteGroup((String) args[0]);
+ }
+ return o;
+ }
+
+ /**
+ * 更新进组
+ *
+ * @param obj
+ */
+ public void changeRole(Object[] obj) {
+ SysRole role = (SysRole) obj[0];
+ identityService.deleteGroup(role.getId());
+ Group group = new GroupEntity();
+ group.setId(role.getId());
+ group.setName(role.getRoleName());
+ identityService.saveGroup(group);
+ }
+
+ /**********************角色处理end***************************/
}
diff --git a/len-activiti/src/main/java/com/len/config/ActivitiConfig.java b/len-activiti/src/main/java/com/len/config/ActivitiConfig.java
index 48d12b1..ad94547 100644
--- a/len-activiti/src/main/java/com/len/config/ActivitiConfig.java
+++ b/len-activiti/src/main/java/com/len/config/ActivitiConfig.java
@@ -1,7 +1,9 @@
package com.len.config;
import com.fasterxml.jackson.databind.ObjectMapper;
+
import javax.sql.DataSource;
+
import org.activiti.engine.DynamicBpmnService;
import org.activiti.engine.FormService;
import org.activiti.engine.HistoryService;
@@ -28,9 +30,11 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
@Configuration
public class ActivitiConfig {
- /**spring 集成 activiti*/
+ /**
+ * spring 集成 activiti
+ */
@Bean
- public ProcessEngineConfiguration processEngineConfiguration(DataSource dataSource, PlatformTransactionManager transactionManager){
+ public ProcessEngineConfiguration processEngineConfiguration(DataSource dataSource, PlatformTransactionManager transactionManager) {
SpringProcessEngineConfiguration processEngineConfiguration = new SpringProcessEngineConfiguration();
processEngineConfiguration.setDataSource(dataSource);
//表不存在创建表
@@ -50,54 +54,54 @@ public class ActivitiConfig {
//流程引擎,与spring整合使用factoryBean
@Bean
- public ProcessEngineFactoryBean processEngine(ProcessEngineConfiguration processEngineConfiguration){
+ public ProcessEngineFactoryBean processEngine(ProcessEngineConfiguration processEngineConfiguration) {
ProcessEngineFactoryBean processEngineFactoryBean = new ProcessEngineFactoryBean();
processEngineFactoryBean.setProcessEngineConfiguration((ProcessEngineConfigurationImpl) processEngineConfiguration);
return processEngineFactoryBean;
}
@Bean
- public RepositoryService repositoryService(ProcessEngine processEngine){
+ public RepositoryService repositoryService(ProcessEngine processEngine) {
return processEngine.getRepositoryService();
}
@Bean
- public RuntimeService runtimeService(ProcessEngine processEngine){
+ public RuntimeService runtimeService(ProcessEngine processEngine) {
return processEngine.getRuntimeService();
}
@Bean
- public TaskService taskService(ProcessEngine processEngine){
+ public TaskService taskService(ProcessEngine processEngine) {
return processEngine.getTaskService();
}
@Bean
- public HistoryService historyService(ProcessEngine processEngine){
+ public HistoryService historyService(ProcessEngine processEngine) {
return processEngine.getHistoryService();
}
@Bean
- public FormService formService(ProcessEngine processEngine){
+ public FormService formService(ProcessEngine processEngine) {
return processEngine.getFormService();
}
@Bean
- public IdentityService identityService(ProcessEngine processEngine){
+ public IdentityService identityService(ProcessEngine processEngine) {
return processEngine.getIdentityService();
}
@Bean
- public ManagementService managementService(ProcessEngine processEngine){
+ public ManagementService managementService(ProcessEngine processEngine) {
return processEngine.getManagementService();
}
@Bean
- public DynamicBpmnService dynamicBpmnService(ProcessEngine processEngine){
+ public DynamicBpmnService dynamicBpmnService(ProcessEngine processEngine) {
return processEngine.getDynamicBpmnService();
}
@Bean
- public ObjectMapper objectMapper(){
+ public ObjectMapper objectMapper() {
return new ObjectMapper();
}
}
diff --git a/len-activiti/src/main/java/com/len/controller/ActivitiController.java b/len-activiti/src/main/java/com/len/controller/ActivitiController.java
index 6c86d64..a4501ff 100644
--- a/len-activiti/src/main/java/com/len/controller/ActivitiController.java
+++ b/len-activiti/src/main/java/com/len/controller/ActivitiController.java
@@ -21,6 +21,7 @@ import com.len.service.SysUserService;
import com.len.util.Checkbox;
import com.len.util.JsonUtil;
import com.len.util.ReType;
+
import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -33,6 +34,7 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
import javax.servlet.http.HttpServletRequest;
+
import org.activiti.bpmn.converter.BpmnXMLConverter;
import org.activiti.bpmn.model.BpmnModel;
import org.activiti.editor.constants.ModelDataJsonConstants;
@@ -67,375 +69,380 @@ import org.springframework.web.bind.annotation.ResponseBody;
* @author zhuxiaomeng
* @date 2018/1/13.
* @email 154040976@qq.com
- *
+ *
* 流程管理 流程创建、发布 流程节点绑定角色/用户(绑定用户 开始ing)
*/
@Controller
@RequestMapping(value = "/act")
public class ActivitiController extends BaseController {
- @Autowired
- RepositoryService repositoryService;
+ @Autowired
+ RepositoryService repositoryService;
- @Autowired
- ObjectMapper objectMapper;
+ @Autowired
+ ObjectMapper objectMapper;
- @Autowired
- RuntimeService runtimeService;
+ @Autowired
+ RuntimeService runtimeService;
- @Autowired
- IdentityService identityService;
+ @Autowired
+ IdentityService identityService;
- @Autowired
- SysUserService userService;
+ @Autowired
+ SysUserService userService;
- @Autowired
- RoleService roleService;
+ @Autowired
+ RoleService roleService;
- @Autowired
- RoleUserService roleUserService;
+ @Autowired
+ RoleUserService roleUserService;
- @Autowired
- ActAssigneeService actAssigneeService;
+ @Autowired
+ ActAssigneeService actAssigneeService;
- /**
- * 同步用户 角色 用户角色到activiti表中
- */
- @PostMapping(value = "syncdata")
- @ResponseBody
- public JsonUtil syncdata() {
- JsonUtil j = new JsonUtil();
- try {
- List userList = userService.selectListByPage(new SysUser());
- User au = null;
- for (SysUser user : userList) {
- au = new UserEntity();
- au.setId(user.getId());
- au.setFirstName(user.getRealName());
- au.setEmail(user.getEmail());
- identityService.deleteUser(au.getId());
- identityService.saveUser(au);
- }
- List sysRoleList = roleService.selectListByPage(new SysRole());
- Group group = null;
- for (SysRole role : sysRoleList) {
- group = new GroupEntity();
- group.setId(role.getId());
- group.setName(role.getRoleName());
- identityService.deleteGroup(group.getId());
- identityService.saveGroup(group);
- }
- List roleUserList = roleUserService.selectByCondition(new SysRoleUser());
+ /**
+ * 同步用户 角色 用户角色到activiti表中
+ */
+ @PostMapping(value = "syncdata")
+ @ResponseBody
+ public JsonUtil syncdata() {
+ JsonUtil j = new JsonUtil();
+ try {
+ List userList = userService.selectListByPage(new SysUser());
+ User au = null;
+ for (SysUser user : userList) {
+ au = new UserEntity();
+ au.setId(user.getId());
+ au.setFirstName(user.getRealName());
+ au.setEmail(user.getEmail());
+ identityService.deleteUser(au.getId());
+ identityService.saveUser(au);
+ }
+ List sysRoleList = roleService.selectListByPage(new SysRole());
+ Group group = null;
+ for (SysRole role : sysRoleList) {
+ group = new GroupEntity();
+ group.setId(role.getId());
+ group.setName(role.getRoleName());
+ identityService.deleteGroup(group.getId());
+ identityService.saveGroup(group);
+ }
+ List roleUserList = roleUserService.selectByCondition(new SysRoleUser());
- for (SysRoleUser sysRoleUser : roleUserList) {
- identityService.deleteMembership(sysRoleUser.getUserId(), sysRoleUser.getRoleId());
- identityService.createMembership(sysRoleUser.getUserId(), sysRoleUser.getRoleId());
- }
- j.setMsg("同步成功");
- } catch (MyException e) {
- j.setFlag(false);
- j.setMsg("同步失败");
- e.printStackTrace();
- }
- return j;
- }
- /**方法此有所参考 感谢我参考原作者:liuruijie
- *
- */
- @GetMapping(value = "goActiviti")
- public String goActiviti() throws UnsupportedEncodingException {
- Model model = repositoryService.newModel();
-
- String name = "新建流程";
- String description = "";
- int revision = 1;
- String key = "processKey";
-
- ObjectNode modelNode = objectMapper.createObjectNode();
- modelNode.put(ModelDataJsonConstants.MODEL_NAME, name);
- modelNode.put(ModelDataJsonConstants.MODEL_DESCRIPTION, description);
- modelNode.put(ModelDataJsonConstants.MODEL_REVISION, revision);
-
- model.setName(name);
- model.setKey(key);
- model.setMetaInfo(modelNode.toString());
-
- repositoryService.saveModel(model);
- String id = model.getId();
-
- //完善ModelEditorSource
- ObjectNode editorNode = objectMapper.createObjectNode();
- editorNode.put("id", "canvas");
- editorNode.put("resourceId", "canvas");
- ObjectNode stencilSetNode = objectMapper.createObjectNode();
- stencilSetNode.put("namespace",
- "http://b3mn.org/stencilset/bpmn2.0#");
- editorNode.put("stencilset", stencilSetNode);
- repositoryService.addModelEditorSource(id, editorNode.toString().getBytes("utf-8"));
- return "redirect:/static/modeler.html?modelId=" + id;
- }
-
- @GetMapping("actUpdate/{id}")
- public String actUpdate(@PathVariable String id){
- return "redirect:/static/modeler.html?modelId=" + id;
- }
-
- @GetMapping(value = "goAct")
- public String goAct(org.springframework.ui.Model model) {
- return "/actList";
- }
-
- /**
- * 部署列表
- */
- @GetMapping(value = "showAct")
- @ResponseBody
- public String showAct(org.springframework.ui.Model model, ProcessDefinition definition,
- String page, String limit) {
- ProcessDefinitionQuery processDefinitionQuery = repositoryService
- .createProcessDefinitionQuery();
- List processDefinitionList=null;
- if(definition!=null){
- if(!StringUtils.isEmpty(definition.getDeploymentId())){
- processDefinitionQuery.deploymentId(definition.getDeploymentId());
- }
- if(!StringUtils.isEmpty(definition.getName())){
- processDefinitionQuery.processDefinitionNameLike("%"+definition.getName()+"%");
-
- }
- }
- processDefinitionList = processDefinitionQuery.listPage(Integer.valueOf(limit) * (Integer.valueOf(page) - 1), Integer.valueOf(limit));
- long count = repositoryService.createDeploymentQuery().count();
- List list = new ArrayList<>();
- processDefinitionList
- .forEach(processDefinition -> list.add(new ProcessDefinition(processDefinition)));
- ReType reType = new ReType(count, list);
- return JSON.toJSONString(reType);
- }
-
-
- @GetMapping(value = "goActModel")
- public String goActModel(org.springframework.ui.Model model) {
- return "/actModelList";
- }
-
- /**
- * 模型列表
- */
- @GetMapping(value = "showAm")
- @ResponseBody
- public String showModel(org.springframework.ui.Model model, ActModel actModel, String page,
- String limit) {
- ModelQuery modelQuery = repositoryService.createModelQuery();
- if(actModel!=null){
- if(!StringUtils.isEmpty(actModel.getKey())){
- modelQuery.modelKey(actModel.getKey());
- }
- if(!StringUtils.isEmpty(actModel.getName())){
- modelQuery.modelNameLike("%"+actModel.getName()+"%");
- }
- }
- List models = modelQuery
- .listPage(Integer.valueOf(limit) * (Integer.valueOf(page) - 1), Integer.valueOf(limit));
- long count = repositoryService.createModelQuery().count();
- List list = new ArrayList<>();
- models.forEach(mo -> list.add(new ActModel(mo)));
- ReType reType = new ReType(count, list);
- return JSON.toJSONString(reType);
- }
-
- /**
- * 发布流程
- */
- @PostMapping(value = "open")
- @ResponseBody
- public JsonUtil open(String id) {
- String msg = "发布成功";
- JsonUtil j = new JsonUtil();
- try {
- Model modelData = repositoryService.getModel(id);
- byte[] bytes = repositoryService.getModelEditorSource(modelData.getId());
-
- if (bytes == null) {
- return JsonUtil.error("模型为空");
- }
- JsonNode modelNode = null;
- modelNode = new ObjectMapper().readTree(bytes);
- BpmnModel model = new BpmnJsonConverter().convertToBpmnModel(modelNode);
- if (model.getProcesses().size() == 0) {
- return JsonUtil.error("数据不符合要求");
- }
- byte[] bpmnBytes = new BpmnXMLConverter().convertToXML(model);
- //发布流程
- String processName = modelData.getName() + ".bpmn20.xml";
- String convertToXML = new String(bpmnBytes);
-
- System.out.println(convertToXML);
- Deployment deployment = repositoryService.createDeployment()
- .name(modelData.getName())
- .addString(processName, new String(bpmnBytes, "UTF-8"))
- .deploy();
- modelData.setDeploymentId(deployment.getId());
- repositoryService.saveModel(modelData);
- } catch (MyException e) {
- msg = "发布数失败";
- j.setFlag(false);
- } catch (IOException e) {
- e.printStackTrace();
- }
- j.setMsg(msg);
- return j;
- }
-
- public List getActivityList(String deploymentId){
- org.activiti.engine.repository.ProcessDefinition processDefinition = repositoryService
- .createProcessDefinitionQuery().deploymentId(deploymentId).singleResult();
- ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService)
- .getDeployedProcessDefinition(processDefinition.getId());
- return processDefinitionEntity.getActivities();
-
- }
-
- /**
- * 根据流程部署id获取节点并且传到前端
- * @param deploymentId 部署id
- * @param model
- * @return
- */
- @GetMapping("goAssignee/{id}")
- public String goAssignee(@PathVariable("id") String deploymentId,
- org.springframework.ui.Model model) {
-
- /**根据流程实例id查询出所有流程节点*/
- List activityList=getActivityList(deploymentId);
-
- /**角色和节点关系封装成list*/
- List roleList = roleService.selectListByPage(new SysRole());
- List checkboxes=new ArrayList<>();
- Checkbox checkbox = null;
- Map map = null;
- List