From 07bb9d1ed93b7afe5d4b337c201bd4883523de56 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Sat, 10 Dec 2022 15:00:28 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BD=BF=E7=94=A8activiti=20NativeTaskQuer?= =?UTF-8?q?y=E6=9F=A5=E8=AF=A2=E5=BE=85=E5=8A=9E=E5=88=86=E9=A1=B5?= =?UTF-8?q?=EF=BC=8C=E4=B8=BA=E5=AE=A1=E6=A0=B8=E7=BB=84=E4=BA=92=E5=8A=A9?= =?UTF-8?q?=E5=AE=A1=E6=A0=B8=E5=81=9A=E6=9F=A5=E8=AF=A2=E5=9F=BA=E7=A1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ActTaskController.java | 11 ++- .../activiti/service/ActTaskService.java | 99 +++++++++++++++---- 2 files changed, 84 insertions(+), 26 deletions(-) diff --git a/renren-admin/src/main/java/io/renren/modules/activiti/controller/ActTaskController.java b/renren-admin/src/main/java/io/renren/modules/activiti/controller/ActTaskController.java index ab02b0f7..76c6a52d 100644 --- a/renren-admin/src/main/java/io/renren/modules/activiti/controller/ActTaskController.java +++ b/renren-admin/src/main/java/io/renren/modules/activiti/controller/ActTaskController.java @@ -11,7 +11,6 @@ import io.renren.common.utils.Result; import io.renren.modules.activiti.dto.BatchCompleteDTO; import io.renren.modules.activiti.dto.TaskDTO; import io.renren.modules.activiti.service.ActTaskService; -import io.renren.modules.device.dto.TbDeviceApplyDTO; import io.renren.modules.security.user.SecurityUser; import io.renren.modules.security.user.UserDetail; import io.renren.modules.sys.dto.SysUserDTO; @@ -26,7 +25,6 @@ import org.activiti.engine.repository.ProcessDefinition; import org.activiti.engine.repository.ProcessDefinitionQuery; import org.activiti.engine.task.TaskQuery; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.dao.DataAccessException; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.*; @@ -36,7 +34,6 @@ import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import java.util.logging.Logger; import java.util.stream.Collectors; /** @@ -110,6 +107,10 @@ public class ActTaskController { taskDTO.setAssigneeName(userDTO.getRealName()); } } + + /** + * 当未指定流程类型时 补充一下会客厅的待办 + */ if (!(params.containsKey("processDefinitionKey") && org.apache.commons.lang3.StringUtils.isNotEmpty(params.get("processDefinitionKey").toString()))) { int meetingroom_book = jdbcTemplate.queryForObject("SELECT COUNT(id) FROM t_meetingroom_book WHERE state = 1;", Integer.class); page.setTotal(page.getTotal() + meetingroom_book); @@ -507,7 +508,7 @@ public class ActTaskController { @ApiOperation("根据政务云资源申请业务ID查询详情") @LogOperation("根据政务云资源申请业务ID查询详情") @ApiImplicitParams({ - @ApiImplicitParam(name = "id", value = "业务ID", paramType = "query",required = true, dataType = "String") + @ApiImplicitParam(name = "id", value = "业务ID", paramType = "query", required = true, dataType = "String") }) public Result getZwyBusinessInfoById(String id) { JdbcTemplate jdbcTemplate = getJDBCTemplate(); @@ -578,7 +579,7 @@ public class ActTaskController { @ApiOperation("根据政务云视频申请业务ID查询详情") @LogOperation("根据政务云视频申请业务ID查询详情") @ApiImplicitParams({ - @ApiImplicitParam(name = "id", value = "业务ID", paramType = "query",required = true, dataType = "String") + @ApiImplicitParam(name = "id", value = "业务ID", paramType = "query", required = true, dataType = "String") }) public Result getZwyVideoInfoById(String id) { JdbcTemplate jdbcTemplate = getJDBCTemplate(); diff --git a/renren-admin/src/main/java/io/renren/modules/activiti/service/ActTaskService.java b/renren-admin/src/main/java/io/renren/modules/activiti/service/ActTaskService.java index b468dd47..05d95254 100644 --- a/renren-admin/src/main/java/io/renren/modules/activiti/service/ActTaskService.java +++ b/renren-admin/src/main/java/io/renren/modules/activiti/service/ActTaskService.java @@ -19,8 +19,6 @@ import io.renren.modules.notice.service.SysNoticeService; import io.renren.modules.processForm.dto.TAbilityApplicationDTO; import io.renren.modules.processForm.service.TAbilityApplicationService; import io.renren.modules.resource.dao.ResourceDao; -import io.renren.modules.resource.dataResource.domain.TsingtaoDataResourceService; -import io.renren.modules.resource.dto.GetDataResourceListDto; import io.renren.modules.resource.dto.ResourceDTO; import io.renren.modules.resource.entity.ResourceEntity; import io.renren.modules.resource.service.ResourceService; @@ -53,6 +51,7 @@ import org.activiti.engine.impl.pvm.process.TransitionImpl; import org.activiti.engine.impl.task.TaskDefinition; import org.activiti.engine.repository.ProcessDefinition; import org.activiti.engine.runtime.ProcessInstance; +import org.activiti.engine.task.NativeTaskQuery; import org.activiti.engine.task.Task; import org.activiti.engine.task.TaskInfo; import org.activiti.engine.task.TaskQuery; @@ -135,6 +134,10 @@ public class ActTaskService extends BaseServiceImpl { * @return */ public PageData page(Map params) { + // TODO 同一审核组内成员 + List groupUserId = new ArrayList() {{ // 测试 + + }}; String userId = (String) params.get("userId"); Integer curPage = 1; Integer limit = 10; @@ -144,32 +147,86 @@ public class ActTaskService extends BaseServiceImpl { if (params.get(Constant.LIMIT) != null) { limit = Integer.parseInt((String) params.get(Constant.LIMIT)); } - TaskQuery taskQuery = taskService.createTaskQuery(); + String taskSql = "SELECT " + + " RES.* " + + "FROM " + + " ACT_RU_TASK RES " + + " INNER JOIN ACT_RE_PROCDEF D ON RES.PROC_DEF_ID_ = D.ID_ "; + String countSql = "SELECT " + + " COUNT(RES.ID_) " + + "FROM " + + " ACT_RU_TASK RES " + + " INNER JOIN ACT_RE_PROCDEF D ON RES.PROC_DEF_ID_ = D.ID_ "; + StringBuffer where = new StringBuffer(" WHERE 1 =1 "); if (StringUtils.isNotEmpty(userId)) { - taskQuery.taskAssignee(userId); + where.append("AND ( RES.ASSIGNEE_ = #{userId} "); + // 处理同一工作组内 + groupUserId.stream().forEach(index -> { + where.append(String.format(" OR RES.ASSIGNEE_ = '%s' ", index)); + }); + where.append(")"); } + if (StringUtils.isNotEmpty((String) params.get("taskName"))) { - taskQuery.taskNameLike("%" + params.get("taskName") + "%"); + where.append(" AND RES.NAME_ = #{taskName}"); } if (StringUtils.isNotEmpty((String) params.get("processDefinitionKey"))) { // 流程定义key - taskQuery.processDefinitionKey((String) params.get("processDefinitionKey")); + where.append(" AND D.KEY_ = #{processDefinitionKey} "); } - if (StringUtils.isNotEmpty((String) params.get("isRoleGroup")) && "1".equals(params.get("isRoleGroup"))) { - List listRoles = sysRoleUserService.getRoleIdList(SecurityUser.getUserId()); - List listStr = new ArrayList<>(); - for (Long role : listRoles) { - listStr.add(role.toString()); - } - listStr.add(SecurityUser.getUserId().toString()); - if (!listStr.isEmpty()) { - taskQuery.taskCandidateGroupIn(listStr); - } else { - return new PageData<>(new ArrayList<>(), 0); - } + where.append(" AND RES.SUSPENSION_STATE_ = 1 "); + + String order = " ORDER BY " + + " RES.CREATE_TIME_ DESC "; + NativeTaskQuery nativeTaskQuery = taskService.createNativeTaskQuery().sql(taskSql + where + order); + NativeTaskQuery nativeCountTaskQuery = taskService.createNativeTaskQuery().sql(countSql + where + order); + if (StringUtils.isNotEmpty(userId)) { // 分配审核员 + nativeTaskQuery.parameter("userId", userId); + nativeCountTaskQuery.parameter("userId", userId); } - taskQuery.orderByTaskCreateTime().desc(); - List list = taskQuery.active().includeProcessVariables().listPage((curPage - 1) * limit, limit); - return new PageData<>(tasks2TaskDtos(list), (int) taskQuery.count()); + if (StringUtils.isNotEmpty((String) params.get("taskName"))) { // 任务名称 + nativeTaskQuery.parameter("taskName", params.get("taskName")); + nativeCountTaskQuery.parameter("taskName", params.get("taskName")); + } + if (StringUtils.isNotEmpty((String) params.get("processDefinitionKey"))) { // 流程定义key + nativeTaskQuery.parameter("processDefinitionKey", params.get("processDefinitionKey")); + nativeCountTaskQuery.parameter("processDefinitionKey", params.get("processDefinitionKey")); + } + List tasks = nativeTaskQuery.listPage((curPage - 1) * limit, limit); + long count = nativeCountTaskQuery.count(); + List list_ = tasks.stream().map(index -> { + TaskQuery taskQuery = taskService.createTaskQuery(); + Task temp = taskQuery.taskId(index.getId()).includeProcessVariables().singleResult(); + return temp; + }).collect(Collectors.toList()); + return new PageData<>(tasks2TaskDtos(list_), (int) count); +// 以下注释为原实现方案 +// TaskQuery taskQuery = taskService.createTaskQuery(); +// if (StringUtils.isNotEmpty(userId)) { +// taskQuery.taskAssignee(userId); +// } +// if (StringUtils.isNotEmpty((String) params.get("taskName"))) { +// taskQuery.taskNameLike("%" + params.get("taskName") + "%"); +// } +// if (StringUtils.isNotEmpty((String) params.get("processDefinitionKey"))) { // 流程定义key +// taskQuery.processDefinitionKey((String) params.get("processDefinitionKey")); +// } +// if (StringUtils.isNotEmpty((String) params.get("isRoleGroup")) && "1".equals(params.get("isRoleGroup"))) { +// List listRoles = sysRoleUserService.getRoleIdList(SecurityUser.getUserId()); +// List listStr = new ArrayList<>(); +// for (Long role : listRoles) { +// listStr.add(role.toString()); +// } +// listStr.add(SecurityUser.getUserId().toString()); +// if (!listStr.isEmpty()) { +// taskQuery.taskCandidateGroupIn(listStr); +// } else { +// return new PageData<>(new ArrayList<>(), 0); +// } +// } +// taskQuery.orderByTaskCreateTime().desc(); +// List list = taskQuery.active() +// .includeProcessVariables().listPage((curPage - 1) * limit, limit); +// return new PageData<>(tasks2TaskDtos(list), (int) taskQuery.count()); } /** From 07c73216dd5db78e1a46e79c742df31ac4c16aa1 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Sat, 10 Dec 2022 15:00:43 +0800 Subject: [PATCH 2/2] ... --- .../java/io/renren/modules/activiti/service/ActTaskService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/renren-admin/src/main/java/io/renren/modules/activiti/service/ActTaskService.java b/renren-admin/src/main/java/io/renren/modules/activiti/service/ActTaskService.java index 05d95254..b562bd0b 100644 --- a/renren-admin/src/main/java/io/renren/modules/activiti/service/ActTaskService.java +++ b/renren-admin/src/main/java/io/renren/modules/activiti/service/ActTaskService.java @@ -136,7 +136,7 @@ public class ActTaskService extends BaseServiceImpl { public PageData page(Map params) { // TODO 同一审核组内成员 List groupUserId = new ArrayList() {{ // 测试 - + }}; String userId = (String) params.get("userId"); Integer curPage = 1;