deptToDoTaskPage接口优化
This commit is contained in:
parent
b843f76d0f
commit
df7e2a3824
|
@ -21,7 +21,6 @@ import io.renren.modules.resourceMountApply.dto.TResourceMountApplyDTO;
|
|||
import io.renren.modules.resourceMountApply.service.TResourceMountApplyService;
|
||||
import io.renren.modules.security.user.SecurityUser;
|
||||
import io.renren.modules.sys.dto.SysUserDTO;
|
||||
import io.renren.modules.sys.entity.SysUserEntity;
|
||||
import io.renren.modules.sys.service.SysRoleUserService;
|
||||
import io.renren.modules.sys.service.SysUserService;
|
||||
import org.activiti.engine.HistoryService;
|
||||
|
@ -55,6 +54,10 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
@ -67,6 +70,9 @@ public class ActTaskService extends BaseServiceImpl {
|
|||
private static final Logger logger = LoggerFactory.getLogger(ActTaskService.class);
|
||||
private static final ObjectMapper oMapper = new ObjectMapper();
|
||||
|
||||
private static Integer cpuNUm = Runtime.getRuntime().availableProcessors();
|
||||
private static final ExecutorService executor = Executors.newFixedThreadPool(cpuNUm);
|
||||
|
||||
public static String Task_HANDLE_STATE = "handleState"; //任务节点处理状态key
|
||||
public static String Task_HANDLE_STATE_AGREE = "agree"; //同意
|
||||
public static String Task_HANDLE_STATE_REJECTED = "rejected"; //驳回
|
||||
|
@ -160,17 +166,25 @@ public class ActTaskService extends BaseServiceImpl {
|
|||
limit = Integer.parseInt((String) params.get(Constant.LIMIT));
|
||||
}
|
||||
List<SysUserDTO> sysUserList = sysUserService.list(new HashMap());
|
||||
List<TaskDTO> taskDtoList = new ArrayList<>();
|
||||
for (SysUserDTO user : sysUserList) {
|
||||
String userId = user.getId().toString();
|
||||
List<TaskDTO> taskDtoList = new CopyOnWriteArrayList<>();
|
||||
Integer finalCurPage = curPage;
|
||||
Integer finalLimit = limit;
|
||||
List<Long> count = new CopyOnWriteArrayList<>();
|
||||
List<CompletableFuture> completableFutureList =
|
||||
sysUserList.stream().filter(index -> null != index.getId()).map(index -> {
|
||||
CompletableFuture completableFuture = CompletableFuture.runAsync(() -> {
|
||||
TaskQuery taskQuery = taskService.createTaskQuery();
|
||||
if (StringUtils.isNotEmpty(userId)) {
|
||||
taskQuery.taskAssignee(userId);
|
||||
}
|
||||
taskQuery.orderByTaskCreateTime().desc();
|
||||
List<Task> list = taskQuery.active().includeProcessVariables().list();
|
||||
List<Task> list = taskQuery.taskAssignee(index.getId().toString())
|
||||
.orderByTaskCreateTime().desc()
|
||||
.includeProcessVariables()
|
||||
.listPage((finalCurPage - 1) * finalLimit, finalCurPage * finalLimit);
|
||||
count.add(taskQuery.taskAssignee(index.getId().toString())
|
||||
.orderByTaskCreateTime().desc().count());
|
||||
taskDtoList.addAll(tasks2TaskDtos(list));
|
||||
}
|
||||
});
|
||||
return completableFuture;
|
||||
}).collect(Collectors.toList());
|
||||
CompletableFuture.allOf(completableFutureList.toArray(new CompletableFuture[completableFutureList.size()])).join();
|
||||
Page<TaskDTO> page = new Page(curPage, limit);
|
||||
int j = Math.min(curPage * limit, taskDtoList.size());
|
||||
if (taskDtoList.isEmpty()) {
|
||||
|
@ -180,7 +194,7 @@ public class ActTaskService extends BaseServiceImpl {
|
|||
ArrayList<TaskDTO> recordLists = new ArrayList<>();
|
||||
recordLists.addAll(taskDtoList.stream().distinct().skip((curPage - 1) * limit).limit(limit).collect(Collectors.toList()));
|
||||
page.setRecords(recordLists);
|
||||
page.setTotal(taskDtoList.stream().distinct().count());
|
||||
page.setTotal(count.stream().mapToLong(index -> index.longValue()).sum());
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import io.renren.modules.security.user.UserDetail;
|
|||
import io.renren.modules.sys.dao.SysDeptDao;
|
||||
import io.renren.modules.sys.dao.SysRegionDao;
|
||||
import io.renren.modules.sys.dao.SysUserDao;
|
||||
import io.renren.modules.sys.dto.SysRoleDTO;
|
||||
import io.renren.modules.sys.dto.SysUserDTO;
|
||||
import io.renren.modules.sys.entity.SysDeptEntity;
|
||||
import io.renren.modules.sys.entity.SysRegionEntity;
|
||||
|
@ -21,12 +22,9 @@ import io.renren.modules.sys.entity.SysUserEntity;
|
|||
import io.renren.modules.sys.enums.JhDeptEnum;
|
||||
import io.renren.modules.sys.enums.JhDeptsEnum;
|
||||
import io.renren.modules.sys.enums.SuperAdminEnum;
|
||||
import io.renren.modules.sys.service.SysDeptService;
|
||||
import io.renren.modules.sys.service.SysRoleUserService;
|
||||
import io.renren.modules.sys.service.SysUserPostService;
|
||||
import io.renren.modules.sys.service.SysUserService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import io.renren.modules.sys.service.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
@ -56,6 +54,11 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
|
|||
private SysUserDao sysUserDao;
|
||||
@Autowired
|
||||
private SysRegionDao regionDao;
|
||||
@Autowired
|
||||
private SysRoleService sysRoleService;
|
||||
|
||||
@Value("${big_date.assignee_role_name}")
|
||||
private String roleName; // 具备审批的角色名称
|
||||
|
||||
@Override
|
||||
public PageData<SysUserDTO> page(Map<String, Object> params) {
|
||||
|
@ -84,7 +87,10 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
|
|||
if (user.getSuperAdmin() == SuperAdminEnum.NO.value()) {
|
||||
params.put("deptIdList", sysDeptService.getSubDeptIdList(user.getDeptId()));
|
||||
}
|
||||
|
||||
SysRoleDTO roleDTO = sysRoleService.getByName(roleName);
|
||||
if (roleDTO != null) {
|
||||
params.put("role_id", roleDTO.getId());
|
||||
}
|
||||
List<SysUserEntity> entityList = baseDao.getList(params);
|
||||
|
||||
return ConvertUtils.sourceToTarget(entityList, SysUserDTO.class);
|
||||
|
@ -423,6 +429,7 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
|
|||
SysRegionEntity region = regionDao.selectOne(regionWrapper);
|
||||
return region;
|
||||
}
|
||||
|
||||
public long getDeptId(String deptName, String fatherDeptName) {
|
||||
QueryWrapper<SysDeptEntity> deptWrapper = new QueryWrapper<>();
|
||||
deptWrapper.eq("name", deptName);
|
||||
|
|
|
@ -28,6 +28,9 @@
|
|||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="role_id != null">
|
||||
AND EXISTS(SELECT 1 FROM sys_role_user WHERE sys_role_user.user_id = t1.id AND sys_role_user.role_id = #{role_id})
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getById" resultType="io.renren.modules.sys.entity.SysUserEntity">
|
||||
|
|
Loading…
Reference in New Issue