11-3-获取待办事项不分页版
This commit is contained in:
@ -1,10 +1,32 @@
|
|||||||
package org.dromara.bigscreen.controller;
|
package org.dromara.bigscreen.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.convert.Convert;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import org.dromara.common.core.domain.R;
|
||||||
|
import org.dromara.common.core.domain.dto.UserDTO;
|
||||||
|
import org.dromara.common.core.enums.BusinessStatusEnum;
|
||||||
|
import org.dromara.common.core.utils.StreamUtils;
|
||||||
|
import org.dromara.common.satoken.utils.LoginHelper;
|
||||||
import org.dromara.common.web.core.BaseController;
|
import org.dromara.common.web.core.BaseController;
|
||||||
|
import org.dromara.system.service.impl.SysUserServiceImpl;
|
||||||
|
import org.dromara.warm.flow.core.FlowEngine;
|
||||||
|
import org.dromara.warm.flow.core.entity.User;
|
||||||
|
import org.dromara.warm.flow.core.enums.NodeType;
|
||||||
|
import org.dromara.warm.flow.orm.entity.FlowDefinition;
|
||||||
|
import org.dromara.warm.flow.orm.mapper.FlowDefinitionMapper;
|
||||||
|
import org.dromara.workflow.domain.bo.FlowTaskBo;
|
||||||
|
import org.dromara.workflow.domain.vo.FlowTaskVo;
|
||||||
|
import org.dromara.workflow.mapper.FlwTaskMapper;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 个人首页接口
|
* 个人首页接口
|
||||||
*/
|
*/
|
||||||
@ -12,4 +34,67 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/personalHome")
|
@RequestMapping("/personalHome")
|
||||||
public class PersonalHomeController extends BaseController {
|
public class PersonalHomeController extends BaseController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private FlwTaskMapper flwTaskMapper;
|
||||||
|
@Autowired
|
||||||
|
private FlowDefinitionMapper flowDefinitionMapper;
|
||||||
|
@Autowired
|
||||||
|
private SysUserServiceImpl userService;
|
||||||
|
|
||||||
|
@GetMapping("/getTaskList")
|
||||||
|
public R<List<FlowTaskVo>> getTaskList(FlowTaskBo flowTaskBo) {
|
||||||
|
QueryWrapper<FlowTaskBo> queryWrapper = new QueryWrapper<>();
|
||||||
|
List<Long> definitionIds = new ArrayList<>();
|
||||||
|
if (!"0".equals(flowTaskBo.getProjectId())){
|
||||||
|
List<FlowDefinition> flowDefinitions = flowDefinitionMapper.selectList(new LambdaQueryWrapper<FlowDefinition>()
|
||||||
|
.select(FlowDefinition::getId)
|
||||||
|
.like(FlowDefinition::getFlowCode, flowTaskBo.getProjectId()));
|
||||||
|
if (flowDefinitions != null && !flowDefinitions.isEmpty()) {
|
||||||
|
flowDefinitions.forEach(flowDefinition -> {
|
||||||
|
definitionIds.add(flowDefinition.getId());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (definitionIds.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
queryWrapper.eq("t.node_type", NodeType.BETWEEN.getKey());
|
||||||
|
queryWrapper.in("t.processed_by", LoginHelper.getUserIdStr());
|
||||||
|
queryWrapper.in("t.flow_status", BusinessStatusEnum.WAITING.getStatus());
|
||||||
|
List<FlowTaskVo> page = this.getFlowTaskDefinitionIdsVoPage(definitionIds, queryWrapper);
|
||||||
|
return R.ok(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<FlowTaskVo> getFlowTaskDefinitionIdsVoPage(List<Long> definitionIds, QueryWrapper<FlowTaskBo> queryWrapper) {
|
||||||
|
List<FlowTaskVo> records = flwTaskMapper.getListRunTaskDefinitionInfo(definitionIds, queryWrapper);
|
||||||
|
if (CollUtil.isNotEmpty(records)) {
|
||||||
|
List<Long> taskIds = StreamUtils.toList(records, FlowTaskVo::getId);
|
||||||
|
Map<Long, List<UserDTO>> listMap = currentTaskAllUser(taskIds);
|
||||||
|
records.forEach(t -> {
|
||||||
|
List<UserDTO> userList = listMap.getOrDefault(t.getId(), Collections.emptyList());
|
||||||
|
if (CollUtil.isNotEmpty(userList)) {
|
||||||
|
t.setAssigneeIds(StreamUtils.join(userList, e -> String.valueOf(e.getUserId())));
|
||||||
|
t.setAssigneeNames(StreamUtils.join(userList, UserDTO::getNickName));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return records;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<Long, List<UserDTO>> currentTaskAllUser(List<Long> taskIdList) {
|
||||||
|
Map<Long, List<UserDTO>> map = new HashMap<>();
|
||||||
|
// 获取与当前任务关联的用户列表
|
||||||
|
List<User> associatedUsers = FlowEngine.userService().getByAssociateds(taskIdList);
|
||||||
|
Map<Long, List<User>> listMap = StreamUtils.groupByKey(associatedUsers, User::getAssociated);
|
||||||
|
for (Map.Entry<Long, List<User>> entry : listMap.entrySet()) {
|
||||||
|
List<User> value = entry.getValue();
|
||||||
|
if (CollUtil.isNotEmpty(value)) {
|
||||||
|
List<UserDTO> userDtoList = userService.selectListByIds(StreamUtils.toList(value, e -> Convert.toLong(e.getProcessedBy())));
|
||||||
|
map.put(entry.getKey(), userDtoList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,6 +30,14 @@ public interface FlwTaskMapper {
|
|||||||
Page<FlowTaskVo> getListRunTask(@Param("page") Page<FlowTaskVo> page, @Param(Constants.WRAPPER) Wrapper<FlowTaskBo> queryWrapper);
|
Page<FlowTaskVo> getListRunTask(@Param("page") Page<FlowTaskVo> page, @Param(Constants.WRAPPER) Wrapper<FlowTaskBo> queryWrapper);
|
||||||
Page<FlowTaskVo> getListRunTaskDefinitionIds(@Param("page") Page<FlowTaskVo> page, @Param("definitionIds") List<Long> definitionIds, @Param(Constants.WRAPPER) Wrapper<FlowTaskBo> queryWrapper);
|
Page<FlowTaskVo> getListRunTaskDefinitionIds(@Param("page") Page<FlowTaskVo> page, @Param("definitionIds") List<Long> definitionIds, @Param(Constants.WRAPPER) Wrapper<FlowTaskBo> queryWrapper);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不分页版
|
||||||
|
* @param definitionIds
|
||||||
|
* @param queryWrapper
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<FlowTaskVo> getListRunTaskDefinitionInfo(@Param("definitionIds") List<Long> definitionIds, @Param(Constants.WRAPPER) Wrapper<FlowTaskBo> queryWrapper);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取待办信息
|
* 获取待办信息
|
||||||
*
|
*
|
||||||
|
|||||||
@ -42,6 +42,51 @@
|
|||||||
) t
|
) t
|
||||||
${ew.getCustomSqlSegment}
|
${ew.getCustomSqlSegment}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<!-- 不分页版-->
|
||||||
|
<select id="getListRunTaskDefinitionInfo" resultMap="FlowTaskResult">
|
||||||
|
select * from (
|
||||||
|
select distinct
|
||||||
|
t.id,
|
||||||
|
t.node_code,
|
||||||
|
t.node_name,
|
||||||
|
t.node_type,
|
||||||
|
t.definition_id,
|
||||||
|
t.instance_id,
|
||||||
|
t.create_time,
|
||||||
|
t.update_time,
|
||||||
|
t.tenant_id,
|
||||||
|
i.business_id,
|
||||||
|
i.flow_status,
|
||||||
|
i.create_by,
|
||||||
|
d.flow_name,
|
||||||
|
d.flow_code,
|
||||||
|
d.form_custom,
|
||||||
|
d.category,
|
||||||
|
COALESCE(t.form_path, d.form_path) as form_path,
|
||||||
|
d.version,
|
||||||
|
uu.processed_by,
|
||||||
|
uu.type,
|
||||||
|
bp.project_name
|
||||||
|
from flow_task t
|
||||||
|
left join flow_user uu on uu.associated = t.id
|
||||||
|
left join flow_definition d on t.definition_id = d.id
|
||||||
|
left join flow_instance i on t.instance_id = i.id
|
||||||
|
LEFT JOIN bus_project bp ON bp.id = SUBSTRING_INDEX( d.flow_code, '_', 1 )
|
||||||
|
where t.node_type = 1
|
||||||
|
and t.del_flag = '0'
|
||||||
|
and uu.del_flag = '0'
|
||||||
|
and uu.type in ('1','2','3')
|
||||||
|
<if test="definitionIds != null and definitionIds.size()>0">
|
||||||
|
AND t.definition_id in
|
||||||
|
<foreach collection="definitionIds" item="definitionId" separator="," open="(" close=")">
|
||||||
|
#{definitionId}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
) t
|
||||||
|
${ew.getCustomSqlSegment}
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="getListRunTaskDefinitionIds" resultMap="FlowTaskResult">
|
<select id="getListRunTaskDefinitionIds" resultMap="FlowTaskResult">
|
||||||
select * from (
|
select * from (
|
||||||
select distinct
|
select distinct
|
||||||
|
|||||||
Reference in New Issue
Block a user