Skip to content

Commit

Permalink
feat/● 概况-任务详情/task/detail, 修改为远程调用
Browse files Browse the repository at this point in the history
● 添加任务接口,添加日志地方,修改为远程调用
● 导入任务接口,修改为远程调用
  • Loading branch information
freestylefly committed Jun 25, 2024
1 parent dcb5284 commit 700db78
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public interface ProjectMemberMapper extends BaseMapper<ProjectMember> {

List<ProjectMemberResVO> searchMember(@Param("data") ProjectMemberReqVO projectMemberReqVO);

List<SysUser> selectUserById(@Param("userIdList") List<Long> userId);
List<SysUser> selectUserByUsername(@Param("usernameList") List<String> usernameList);
List<ProjectMemberResVO> queryExecutorList(@Param("projectId") String projectId);
List<ProjectMemberResVO> queryTaskUserList(@Param("taskId") String taskId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.laigeoffer.pmhub.api.system.UserFeignService;
import com.laigeoffer.pmhub.api.system.domain.dto.SysUserDTO;
import com.laigeoffer.pmhub.api.workflow.DeployFeignService;
import com.laigeoffer.pmhub.base.core.config.PmhubConfig;
import com.laigeoffer.pmhub.base.core.constant.SecurityConstants;
import com.laigeoffer.pmhub.base.core.core.domain.R;
import com.laigeoffer.pmhub.base.core.core.domain.dto.ApprovalSetDTO;
import com.laigeoffer.pmhub.base.core.core.domain.entity.SysUser;
import com.laigeoffer.pmhub.base.core.core.domain.vo.SysUserVO;
import com.laigeoffer.pmhub.base.core.enums.LogTypeEnum;
import com.laigeoffer.pmhub.base.core.enums.ProjectStatusEnum;
import com.laigeoffer.pmhub.base.core.enums.ProjectTaskPriorityEnum;
Expand Down Expand Up @@ -75,6 +78,10 @@ public class ProjectTaskServiceImpl extends ServiceImpl<ProjectTaskMapper, Proje
@Resource
private DeployFeignService wfDeployService;

// 远程调用用户服务
@Resource
private UserFeignService userFeignService;

@Override
public Long queryTodayTaskNum() {
LambdaQueryWrapper<ProjectTask> queryWrapper = new LambdaQueryWrapper<>();
Expand Down Expand Up @@ -220,14 +227,30 @@ public TaskResVO detail(TaskReqVO taskReqVO) {
detail.setStatusName(ProjectTaskStatusEnum.getStatusNameByStatus(detail.getStatus()));
detail.setExecuteStatusName(ProjectTaskStatusEnum.getStatusNameByStatus(detail.getExecuteStatus()));
if (detail.getUserId() != null) {
List<SysUser> sysUsers = projectMemberMapper.selectUserById(Collections.singletonList(detail.getUserId()));
// 查询用户信息
List<SysUser> sysUsers = getSysUserList(Collections.singletonList(detail.getUserId()));
detail.setExecutor(sysUsers.get(0).getNickName());
}
detail.setCreatedBy(projectMemberMapper.selectUserByUsername(Collections.singletonList(detail.getCreatedBy())).get(0).getNickName());
detail.setTaskPriorityName(ProjectTaskPriorityEnum.getStatusNameByStatus(detail.getTaskPriority()));
return detail;
}

private List<SysUser> getSysUserList(List<Long> userIds) {
// 查询用户信息
SysUserDTO sysUserDTO = new SysUserDTO();
sysUserDTO.setUserIds(userIds);
R<List<SysUserVO>> userResult = userFeignService.listOfInner(sysUserDTO, SecurityConstants.INNER);

if (Objects.isNull(userResult) || CollectionUtils.isEmpty(userResult.getData())) {
throw new ServiceException("远程调用查询用户列表:" + userIds + " 失败");
}
List<SysUserVO> userVOList = userResult.getData();
return userVOList.stream()
.map(userVO -> (SysUser) userVO)
.collect(Collectors.toList());
}

@Override
public List<ProjectMemberResVO> queryExecutorList(TaskReqVO taskReqVO) {
return projectMemberMapper.queryExecutorList(taskReqVO.getProjectId());
Expand Down Expand Up @@ -288,7 +311,7 @@ public String add(TaskReqVO taskReqVO) {
if (taskReqVO.getUserId() != null && !Objects.equals(taskReqVO.getUserId(), SecurityUtils.getUserId())) {
insertMember(projectTask.getId(), 0, taskReqVO.getUserId());
// 添加日志
saveLog("invitePartakeTask", projectTask.getId(), taskReqVO.getProjectId(), taskReqVO.getTaskName(), "邀请 " + projectMemberMapper.selectUserById(Collections.singletonList(taskReqVO.getUserId())).get(0).getNickName() + " 参与任务", taskReqVO.getUserId());
saveLog("invitePartakeTask", projectTask.getId(), taskReqVO.getProjectId(), taskReqVO.getTaskName(), "邀请 " + getSysUserList(Collections.singletonList(taskReqVO.getUserId())).get(0).getNickName() + " 参与任务", taskReqVO.getUserId());
}
// 4、任务指派消息提醒
extracted(taskReqVO.getTaskName(), taskReqVO.getUserId(), SecurityUtils.getUsername(), projectTask.getId());
Expand Down Expand Up @@ -416,8 +439,8 @@ public void edit(TaskReqVO taskReqVO) {
logContentVOList.forEach(logContentVO -> {
switch (logContentVO.getField()) {
case "userId":
logContentVO.setOldValue(projectMemberMapper.selectUserById(Collections.singletonList(Long.valueOf(logContentVO.getOldValue()))).get(0).getNickName());
logContentVO.setNewValue(projectMemberMapper.selectUserById(Collections.singletonList(Long.valueOf(logContentVO.getNewValue()))).get(0).getNickName());
logContentVO.setOldValue(getSysUserList(Collections.singletonList(Long.valueOf(logContentVO.getOldValue()))).get(0).getNickName());
logContentVO.setNewValue(getSysUserList(Collections.singletonList(Long.valueOf(logContentVO.getNewValue()))).get(0).getNickName());
break;
case "status":
case "executeStatus":
Expand Down Expand Up @@ -450,7 +473,7 @@ public List<TaskResVO> queryChildTask(TaskReqVO taskReqVO) {
detail.setStatusName(ProjectTaskStatusEnum.getStatusNameByStatus(detail.getStatus()));
detail.setExecuteStatusName(ProjectTaskStatusEnum.getStatusNameByStatus(detail.getExecuteStatus()));
if (detail.getUserId() != null) {
detail.setExecutor(projectMemberMapper.selectUserById(Collections.singletonList(detail.getUserId())).get(0).getNickName());
detail.setExecutor(getSysUserList(Collections.singletonList(detail.getUserId())).get(0).getNickName());
}
detail.setCreatedBy(projectMemberMapper.selectUserByUsername(Collections.singletonList(detail.getCreatedBy())).get(0).getNickName());
detail.setTaskPriorityName(ProjectTaskPriorityEnum.getStatusNameByStatus(detail.getTaskPriority()));
Expand Down Expand Up @@ -629,7 +652,7 @@ public void importTask(List<TaskExcelVO> taskList) {
insertMember(projectTask.getId(), 0, projectTask.getUserId());
// 添加日志
saveLog("invitePartakeTask", projectTask.getId(), projectTask.getProjectId(), projectTask.getTaskName()
,"邀请 " + projectMemberMapper.selectUserById(Collections.singletonList(projectTask.getUserId())).get(0).getNickName() + " 参与任务"
,"邀请 " + getSysUserList(Collections.singletonList(projectTask.getUserId())).get(0).getNickName() + " 参与任务"
, projectTask.getUserId());
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,7 @@
select pm.user_id, pm.joined_time from pmhub_project_member pm
where pm.pt_id = #{data.projectId}
</select>
<select id="selectUserById" parameterType="java.lang.Long" resultType="com.laigeoffer.pmhub.base.core.core.domain.entity.SysUser">
select * from sys_user su where
<if test="userIdList != null and userIdList.size() > 0">
su.user_id in
<foreach item="userId" index="index" collection="userIdList" open="(" separator="," close=")">
#{userId}
</foreach>
</if>
</select>

<select id="selectUserByUsername" parameterType="java.lang.String" resultType="com.laigeoffer.pmhub.base.core.core.domain.entity.SysUser">
select * from sys_user su where
<if test="usernameList != null and usernameList.size() > 0">
Expand Down

0 comments on commit 700db78

Please sign in to comment.