Merge branch 'dev'

This commit is contained in:
wangliwen 2022-12-10 15:02:45 +08:00
commit 1f549b5659
2 changed files with 84 additions and 26 deletions

View File

@ -11,7 +11,6 @@ import io.renren.common.utils.Result;
import io.renren.modules.activiti.dto.BatchCompleteDTO; import io.renren.modules.activiti.dto.BatchCompleteDTO;
import io.renren.modules.activiti.dto.TaskDTO; import io.renren.modules.activiti.dto.TaskDTO;
import io.renren.modules.activiti.service.ActTaskService; 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.SecurityUser;
import io.renren.modules.security.user.UserDetail; import io.renren.modules.security.user.UserDetail;
import io.renren.modules.sys.dto.SysUserDTO; 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.repository.ProcessDefinitionQuery;
import org.activiti.engine.task.TaskQuery; import org.activiti.engine.task.TaskQuery;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -36,7 +34,6 @@ import java.util.*;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.logging.Logger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -110,6 +107,10 @@ public class ActTaskController {
taskDTO.setAssigneeName(userDTO.getRealName()); taskDTO.setAssigneeName(userDTO.getRealName());
} }
} }
/**
* 当未指定流程类型时 补充一下会客厅的待办
*/
if (!(params.containsKey("processDefinitionKey") && org.apache.commons.lang3.StringUtils.isNotEmpty(params.get("processDefinitionKey").toString()))) { 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); int meetingroom_book = jdbcTemplate.queryForObject("SELECT COUNT(id) FROM t_meetingroom_book WHERE state = 1;", Integer.class);
page.setTotal(page.getTotal() + meetingroom_book); page.setTotal(page.getTotal() + meetingroom_book);

View File

@ -19,8 +19,6 @@ import io.renren.modules.notice.service.SysNoticeService;
import io.renren.modules.processForm.dto.TAbilityApplicationDTO; import io.renren.modules.processForm.dto.TAbilityApplicationDTO;
import io.renren.modules.processForm.service.TAbilityApplicationService; import io.renren.modules.processForm.service.TAbilityApplicationService;
import io.renren.modules.resource.dao.ResourceDao; 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.dto.ResourceDTO;
import io.renren.modules.resource.entity.ResourceEntity; import io.renren.modules.resource.entity.ResourceEntity;
import io.renren.modules.resource.service.ResourceService; 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.impl.task.TaskDefinition;
import org.activiti.engine.repository.ProcessDefinition; import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.engine.runtime.ProcessInstance; import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.NativeTaskQuery;
import org.activiti.engine.task.Task; import org.activiti.engine.task.Task;
import org.activiti.engine.task.TaskInfo; import org.activiti.engine.task.TaskInfo;
import org.activiti.engine.task.TaskQuery; import org.activiti.engine.task.TaskQuery;
@ -135,6 +134,10 @@ public class ActTaskService extends BaseServiceImpl {
* @return * @return
*/ */
public PageData<TaskDTO> page(Map<String, Object> params) { public PageData<TaskDTO> page(Map<String, Object> params) {
// TODO 同一审核组内成员
List<String> groupUserId = new ArrayList<String>() {{ // 测试
}};
String userId = (String) params.get("userId"); String userId = (String) params.get("userId");
Integer curPage = 1; Integer curPage = 1;
Integer limit = 10; Integer limit = 10;
@ -144,32 +147,86 @@ public class ActTaskService extends BaseServiceImpl {
if (params.get(Constant.LIMIT) != null) { if (params.get(Constant.LIMIT) != null) {
limit = Integer.parseInt((String) params.get(Constant.LIMIT)); 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)) { 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"))) { 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 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"))) { where.append(" AND RES.SUSPENSION_STATE_ = 1 ");
List<Long> listRoles = sysRoleUserService.getRoleIdList(SecurityUser.getUserId());
List<String> listStr = new ArrayList<>(); String order = " ORDER BY " +
for (Long role : listRoles) { " RES.CREATE_TIME_ DESC ";
listStr.add(role.toString()); 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);
} }
listStr.add(SecurityUser.getUserId().toString()); if (StringUtils.isNotEmpty((String) params.get("taskName"))) { // 任务名称
if (!listStr.isEmpty()) { nativeTaskQuery.parameter("taskName", params.get("taskName"));
taskQuery.taskCandidateGroupIn(listStr); nativeCountTaskQuery.parameter("taskName", params.get("taskName"));
} else {
return new PageData<>(new ArrayList<>(), 0);
} }
if (StringUtils.isNotEmpty((String) params.get("processDefinitionKey"))) { // 流程定义key
nativeTaskQuery.parameter("processDefinitionKey", params.get("processDefinitionKey"));
nativeCountTaskQuery.parameter("processDefinitionKey", params.get("processDefinitionKey"));
} }
taskQuery.orderByTaskCreateTime().desc(); List<Task> tasks = nativeTaskQuery.listPage((curPage - 1) * limit, limit);
List<Task> list = taskQuery.active().includeProcessVariables().listPage((curPage - 1) * limit, limit); long count = nativeCountTaskQuery.count();
return new PageData<>(tasks2TaskDtos(list), (int) taskQuery.count()); List<Task> 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<Long> listRoles = sysRoleUserService.getRoleIdList(SecurityUser.getUserId());
// List<String> 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<Task> list = taskQuery.active()
// .includeProcessVariables().listPage((curPage - 1) * limit, limit);
// return new PageData<>(tasks2TaskDtos(list), (int) taskQuery.count());
} }
/** /**