修改 code review
parent
e969dbe8b7
commit
91c0c423c0
|
@ -1,8 +1,7 @@
|
|||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow;
|
||||
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.*;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.workflow.TaskService;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.workflow.BpmTaskService;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
|
||||
|
@ -25,40 +24,40 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|||
public class TaskController {
|
||||
|
||||
@Resource
|
||||
private TaskService taskService;
|
||||
private BpmTaskService bpmTaskService;
|
||||
|
||||
@GetMapping("/todo/page")
|
||||
@ApiOperation("获取待办任务分页")
|
||||
public CommonResult<PageResult<TodoTaskRespVO>> getTodoTaskPage(@Valid TodoTaskPageReqVO pageVO) {
|
||||
return success(taskService.getTodoTaskPage(pageVO));
|
||||
return success(bpmTaskService.getTodoTaskPage(pageVO));
|
||||
}
|
||||
|
||||
@GetMapping("/claim")
|
||||
@ApiOperation("签收任务")
|
||||
public CommonResult<Boolean> claimTask(@RequestParam("id") String taskId) {
|
||||
taskService.claimTask(taskId);
|
||||
bpmTaskService.claimTask(taskId);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PostMapping("/task-steps")
|
||||
public CommonResult<TaskHandleVO> getTaskSteps(@RequestBody TaskQueryReqVO taskQuery) {
|
||||
return success(taskService.getTaskSteps(taskQuery));
|
||||
return success(bpmTaskService.getTaskSteps(taskQuery));
|
||||
}
|
||||
|
||||
@PostMapping("/formKey")
|
||||
public CommonResult<TodoTaskRespVO> getTaskFormKey(@RequestBody TaskQueryReqVO taskQuery) {
|
||||
return success(taskService.getTaskFormKey(taskQuery));
|
||||
return success(bpmTaskService.getTaskFormKey(taskQuery));
|
||||
}
|
||||
|
||||
@PostMapping("/complete")
|
||||
public CommonResult<Boolean> complete(@RequestBody TaskReqVO taskReq) {
|
||||
taskService.completeTask(taskReq);
|
||||
bpmTaskService.completeTask(taskReq);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/process/history-steps")
|
||||
public CommonResult<List<TaskStepVO>> getHistorySteps(@RequestParam("id") String processInstanceId) {
|
||||
return success(taskService.getHistorySteps(processInstanceId));
|
||||
return success(bpmTaskService.getHistorySteps(processInstanceId));
|
||||
}
|
||||
|
||||
// TODO @Li: 项目里,暂时不使用 path 路径参数,监控等麻烦
|
||||
|
@ -68,7 +67,7 @@ public class TaskController {
|
|||
*/
|
||||
@GetMapping("/process/highlight-img/{id}")
|
||||
public void getHighlightImg(@PathVariable("id") String processInstanceId, HttpServletResponse response) throws IOException {
|
||||
FileResp fileResp = taskService.getHighlightImg(processInstanceId);
|
||||
FileResp fileResp = bpmTaskService.getHighlightImg(processInstanceId);
|
||||
ServletUtils.writeAttachment(response, fileResp.getFileName(), fileResp.getFileByte());
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,10 @@ public interface TaskConvert {
|
|||
})
|
||||
TodoTaskRespVO convert(Task task, ProcessDefinition definition);
|
||||
|
||||
@Mappings(value = {
|
||||
@Mapping(source = "assignee", target = "status",qualifiedByName = "convertAssigneeToStatus")
|
||||
})
|
||||
TodoTaskRespVO convert(Task task);
|
||||
|
||||
@Named("convertAssigneeToStatus")
|
||||
default Integer convertAssigneeToStatus(String assignee) {
|
||||
|
|
|
@ -1,26 +1,28 @@
|
|||
package cn.iocoder.yudao.adminserver.modules.bpm.enums.oa;
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.enums;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.exception.ErrorCode;
|
||||
|
||||
// TODO @jason:错误码整理下,和其它模块保持一致。包括前缀
|
||||
/**
|
||||
* activiti 系统 错误码枚举类
|
||||
* 工作流 错误码枚举类
|
||||
*
|
||||
* 003 activiti
|
||||
* 001 oa
|
||||
* activiti 系统,使用 1-003-000-000 段
|
||||
* 工作流系统,使用 1-003-000-000 段
|
||||
*/
|
||||
public interface OAErrorCodeConstants {
|
||||
public interface BpmErrorCodeConstants {
|
||||
|
||||
// ========== 通用流程处理 模块 1-003-000-000 ==========
|
||||
ErrorCode PROCESS_INSTANCE_NOT_EXISTS = new ErrorCode(1003000001, "流程实例不存在");
|
||||
ErrorCode HIGHLIGHT_IMG_ERROR = new ErrorCode(1003000002, "获取高亮流程图异常");
|
||||
|
||||
|
||||
// ========== OA 流程模块 1-003-001-000 ==========
|
||||
ErrorCode LEAVE_NOT_EXISTS = new ErrorCode(1003001001, "请假申请不存在");
|
||||
ErrorCode PM_POST_NOT_EXISTS = new ErrorCode(1003001002, "项目经理岗位未设置");
|
||||
ErrorCode DEPART_PM_POST_NOT_EXISTS = new ErrorCode(1003001003, "部门的项目经理不存在");
|
||||
ErrorCode BM_POST_NOT_EXISTS = new ErrorCode(1003001004, "部门经理岗位未设置");
|
||||
ErrorCode DEPART_BM_POST_NOT_EXISTS = new ErrorCode(1003001005, "部门的部门经理不存在");
|
||||
ErrorCode HR_POST_NOT_EXISTS = new ErrorCode(1003001006, "HR岗位未设置");
|
||||
ErrorCode DAY_LEAVE_ERROR = new ErrorCode(1003001007, "请假天数必须大于0");
|
||||
ErrorCode DAY_LEAVE_ERROR = new ErrorCode(1003001007, "请假天数必须>=1");
|
||||
|
||||
|
||||
ErrorCode PROCESS_INSTANCE_NOT_EXISTS = new ErrorCode(1003001008, "流程实例不存在");
|
||||
ErrorCode HIGHLIGHT_IMG_ERROR = new ErrorCode(1003001009, "获取高亮流程图异常");
|
||||
|
||||
}
|
|
@ -28,7 +28,7 @@ import org.springframework.validation.annotation.Validated;
|
|||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
import static cn.iocoder.yudao.adminserver.modules.bpm.enums.oa.OAErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
/**
|
||||
|
@ -164,12 +164,7 @@ public class OALeaveServiceImpl implements OALeaveService {
|
|||
throw ServiceExceptionUtil.exception(PM_POST_NOT_EXISTS);
|
||||
}
|
||||
SysUserDO userDO = sysUserMapper.selectById(id);
|
||||
Set<Long> postIds = new HashSet<>(8);
|
||||
postIds.add( pmPostDO.getId());
|
||||
SysUserBaseVO baseVO = new SysUserBaseVO();
|
||||
baseVO.setDeptId(userDO.getDeptId())
|
||||
.setPostIds(postIds);
|
||||
final List<SysUserDO> pmUsers = sysUserMapper.selectListByBaseVO(baseVO);
|
||||
final List<SysUserDO> pmUsers = sysUserMapper.selectListByDepartIdAndPostId(userDO.getDeptId(), pmPostDO.getId());
|
||||
if (CollUtil.isEmpty(pmUsers)) {
|
||||
throw ServiceExceptionUtil.exception(DEPART_PM_POST_NOT_EXISTS);
|
||||
}
|
||||
|
@ -179,13 +174,8 @@ public class OALeaveServiceImpl implements OALeaveService {
|
|||
if (Objects.isNull(bmPostDO)) {
|
||||
throw ServiceExceptionUtil.exception(BM_POST_NOT_EXISTS);
|
||||
}
|
||||
userDO = sysUserMapper.selectById(id);
|
||||
postIds = new HashSet<>(8);
|
||||
postIds.add( bmPostDO.getId());
|
||||
baseVO = new SysUserBaseVO();
|
||||
baseVO.setDeptId(userDO.getDeptId())
|
||||
.setPostIds(postIds);
|
||||
final List<SysUserDO> bmUsers = sysUserMapper.selectListByBaseVO(baseVO);
|
||||
|
||||
final List<SysUserDO> bmUsers = sysUserMapper.selectListByDepartIdAndPostId(userDO.getDeptId(), bmPostDO.getId());
|
||||
if (CollUtil.isEmpty(bmUsers)) {
|
||||
throw ServiceExceptionUtil.exception(DEPART_BM_POST_NOT_EXISTS);
|
||||
}
|
||||
|
@ -194,13 +184,7 @@ public class OALeaveServiceImpl implements OALeaveService {
|
|||
if (Objects.isNull(hrPostDO)) {
|
||||
throw ServiceExceptionUtil.exception(HR_POST_NOT_EXISTS);
|
||||
}
|
||||
userDO = sysUserMapper.selectById(id);
|
||||
postIds = new HashSet<>(8);
|
||||
postIds.add( hrPostDO.getId());
|
||||
baseVO = new SysUserBaseVO();
|
||||
baseVO.setDeptId(userDO.getDeptId())
|
||||
.setPostIds(postIds);
|
||||
final List<SysUserDO> hrUsers = sysUserMapper.selectListByBaseVO(baseVO);
|
||||
final List<SysUserDO> hrUsers = sysUserMapper.selectListByDepartIdAndPostId(userDO.getDeptId(), hrPostDO.getId());
|
||||
if (CollUtil.isEmpty(hrUsers)) {
|
||||
throw ServiceExceptionUtil.exception(DEPART_BM_POST_NOT_EXISTS);
|
||||
}
|
||||
|
|
|
@ -6,11 +6,10 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
// TODO @jason:前缀
|
||||
/**
|
||||
* 用户任务服务接口
|
||||
* 工作流用户任务服务接口
|
||||
*/
|
||||
public interface TaskService {
|
||||
public interface BpmTaskService {
|
||||
|
||||
|
||||
/**
|
||||
|
@ -25,10 +24,11 @@ public interface TaskService {
|
|||
*/
|
||||
void claimTask(String taskId);
|
||||
|
||||
// TODO @jason:可以把实现方法的注释,统一写到接口里
|
||||
|
||||
/**
|
||||
* 办理完成用户任务
|
||||
* @param taskReq 任务参数, 包含任务的参数,和 评论
|
||||
* 工作流,完成 userTask, 完成用户任务 一般传入参数 1。是否同意(variables). 2. 评论(comment)
|
||||
* variables 变量名 和 评论 由前台传入
|
||||
* @param taskReq 任务参数
|
||||
*/
|
||||
void completeTask(TaskReqVO taskReq);
|
||||
|
|
@ -4,7 +4,7 @@ import cn.hutool.core.collection.CollUtil;
|
|||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.*;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.convert.workflow.TaskConvert;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.workflow.TaskService;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.workflow.BpmTaskService;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||
|
@ -41,13 +41,13 @@ import java.util.Map;
|
|||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.adminserver.modules.bpm.enums.oa.OAErrorCodeConstants.HIGHLIGHT_IMG_ERROR;
|
||||
import static cn.iocoder.yudao.adminserver.modules.bpm.enums.oa.OAErrorCodeConstants.PROCESS_INSTANCE_NOT_EXISTS;
|
||||
import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.HIGHLIGHT_IMG_ERROR;
|
||||
import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.PROCESS_INSTANCE_NOT_EXISTS;
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class TaskServiceImpl implements TaskService {
|
||||
public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
|
||||
@Resource
|
||||
private TaskRuntime taskRuntime;
|
||||
|
@ -76,7 +76,6 @@ public class TaskServiceImpl implements TaskService {
|
|||
List<Task> tasks = pageTasks.getContent();
|
||||
final List<TodoTaskRespVO> respVOList = tasks.stream().map(task -> {
|
||||
ProcessDefinition definition = repositoryService.getProcessDefinition(task.getProcessDefinitionId());
|
||||
definition.getId();
|
||||
return TaskConvert.INSTANCE.convert(task, definition);
|
||||
}).collect(Collectors.toList());
|
||||
return new PageResult<>(respVOList, (long)totalItems);
|
||||
|
@ -92,11 +91,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* 工作流,完成 userTask, 完成用户任务 一般传入参数 1。是否同意(variables). 2. 评论(comment)
|
||||
* variables 变量名 和 评论 由前台传入
|
||||
* @param taskReq 任务参数
|
||||
*/
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void completeTask(TaskReqVO taskReq) {
|
||||
|
@ -166,13 +161,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
@Override
|
||||
public TodoTaskRespVO getTaskFormKey(TaskQueryReqVO taskQuery) {
|
||||
final Task task = taskRuntime.task(taskQuery.getTaskId());
|
||||
// 转换结果 TODO @jason:放到 convert 类里
|
||||
TodoTaskRespVO respVO = new TodoTaskRespVO();
|
||||
respVO.setFormKey(task.getFormKey());
|
||||
respVO.setBusinessKey(task.getBusinessKey());
|
||||
respVO.setId(task.getId());
|
||||
respVO.setProcessInstanceId(task.getProcessInstanceId());
|
||||
return respVO;
|
||||
return TaskConvert.INSTANCE.convert(task);
|
||||
}
|
||||
|
||||
@Override
|
|
@ -15,6 +15,7 @@ import org.apache.logging.log4j.util.Strings;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
@Mapper
|
||||
public interface SysUserMapper extends BaseMapperX<SysUserDO> {
|
||||
|
@ -56,13 +57,12 @@ public interface SysUserMapper extends BaseMapperX<SysUserDO> {
|
|||
return selectList(new QueryWrapperX<SysUserDO>().like("username", username));
|
||||
}
|
||||
|
||||
// TODO jason:变量平铺比较好
|
||||
default List<SysUserDO> selectListByBaseVO(SysUserBaseVO reqVO) {
|
||||
return selectList(new QueryWrapperX<SysUserDO>().likeIfPresent("username", reqVO.getUsername())
|
||||
.likeIfPresent("nickname", reqVO.getNickname())
|
||||
|
||||
default List<SysUserDO> selectListByDepartIdAndPostId(Long departId, Long postId) {
|
||||
return selectList(new QueryWrapperX<SysUserDO>()
|
||||
.eq("status", CommonStatusEnum.ENABLE.getStatus())
|
||||
.eq("dept_id", reqVO.getDeptId())
|
||||
.likeIfPresent("post_ids", Optional.ofNullable(reqVO.getPostIds()).map(t -> Strings.join(t, ',')).orElse("")));
|
||||
.eq("dept_id", departId)
|
||||
.likeIfPresent("post_ids", Optional.ofNullable(postId).map(t -> String.valueOf(postId)).orElse("")));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -73,5 +73,6 @@ yudao:
|
|||
constants-class-list:
|
||||
- cn.iocoder.yudao.adminserver.modules.infra.enums.InfErrorCodeConstants
|
||||
- cn.iocoder.yudao.adminserver.modules.system.enums.SysErrorCodeConstants
|
||||
- cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants
|
||||
|
||||
debug: false
|
||||
|
|
Loading…
Reference in New Issue