项目人员模块代码更新
This commit is contained in:
parent
386561125e
commit
b45766d377
|
@ -0,0 +1,60 @@
|
|||
package com.dite.znpt.domain.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* @author wangna
|
||||
* @date 2025/08/05
|
||||
* @Description: 团队成员请求类(用于创建和更新)
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value="TeamMemberReq对象", description="团队成员请求类")
|
||||
public class TeamMemberReq implements Serializable {
|
||||
|
||||
@NotBlank(message = "项目ID不能为空")
|
||||
@ApiModelProperty("项目ID")
|
||||
private String projectId;
|
||||
|
||||
@ApiModelProperty("机组ID(可选)")
|
||||
private String turbineId;
|
||||
|
||||
@ApiModelProperty("任务组ID(可选)")
|
||||
private String taskGroupId;
|
||||
|
||||
@ApiModelProperty("任务ID(可选)")
|
||||
private String taskId;
|
||||
|
||||
@NotBlank(message = "用户ID不能为空")
|
||||
@ApiModelProperty("用户ID")
|
||||
private String userId;
|
||||
|
||||
@NotBlank(message = "角色类型不能为空")
|
||||
@ApiModelProperty("项目角色类型:PROJECT_MANAGER-项目经理,SAFETY_OFFICER-安全员,QUALITY_OFFICER-质量员,CONSTRUCTOR-施工人员,TEAM_LEADER-施工组长")
|
||||
private String roleType;
|
||||
|
||||
@ApiModelProperty("具体岗位代码(如:GROUND_SERVICE-地勤,DRIVER-司机,ASCENDING-登高等)")
|
||||
private String jobCode;
|
||||
|
||||
@ApiModelProperty("岗位描述")
|
||||
private String jobDesc;
|
||||
|
||||
@NotNull(message = "加入时间不能为空")
|
||||
@ApiModelProperty("加入时间")
|
||||
private LocalDate joinDate;
|
||||
|
||||
@ApiModelProperty("离开时间")
|
||||
private LocalDate leaveDate;
|
||||
|
||||
@ApiModelProperty("状态:ACTIVE-在职,INACTIVE-离职,PENDING-待入职")
|
||||
private String status = "ACTIVE";
|
||||
|
||||
@ApiModelProperty("备注")
|
||||
private String remark;
|
||||
}
|
|
@ -17,6 +17,21 @@ public interface ProjectMemberService extends IService<ProjectMemberEntity> {
|
|||
*/
|
||||
PageResult<ProjectMemberResp> getProjectTeamMembers(TeamMemberQuery query);
|
||||
|
||||
/**
|
||||
* 创建团队成员
|
||||
*/
|
||||
ProjectMemberResp createTeamMember(TeamMemberReq req);
|
||||
|
||||
/**
|
||||
* 更新团队成员信息
|
||||
*/
|
||||
ProjectMemberResp updateTeamMember(String memberId, TeamMemberReq req);
|
||||
|
||||
/**
|
||||
* 删除团队成员(支持单个或批量删除)
|
||||
*/
|
||||
boolean deleteTeamMembers(String... memberIds);
|
||||
|
||||
// ========================== 项目看板相关方法 ==========================
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,11 +7,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||
import com.dite.znpt.constant.Message;
|
||||
import com.dite.znpt.domain.PageResult;
|
||||
import com.dite.znpt.domain.entity.*;
|
||||
import com.dite.znpt.domain.vo.ProjectDetailResp;
|
||||
import com.dite.znpt.domain.vo.ProjectKanbanDataResp;
|
||||
import com.dite.znpt.domain.vo.ProjectKanbanStatsResp;
|
||||
import com.dite.znpt.domain.vo.ProjectMemberResp;
|
||||
import com.dite.znpt.domain.vo.TeamMemberQuery;
|
||||
import com.dite.znpt.domain.vo.*;
|
||||
import com.dite.znpt.enums.ProjectStatusEnum;
|
||||
import com.dite.znpt.enums.ProjectTaskStateEnum;
|
||||
import com.dite.znpt.exception.ServiceException;
|
||||
|
@ -42,6 +38,7 @@ public class ProjectMemberServiceImpl extends ServiceImpl<ProjectMemberMapper, P
|
|||
private final ProjectService projectService;
|
||||
private final TurbineService turbineService;
|
||||
private final ProjectTaskService projectTaskService;
|
||||
private final ProjectTaskGroupService projectTaskGroupService;
|
||||
private final ProjectBudgetInfoService projectBudgetInfoService;
|
||||
private final ProjectDailyReportService projectDailyReportService;
|
||||
|
||||
|
@ -132,6 +129,144 @@ public class ProjectMemberServiceImpl extends ServiceImpl<ProjectMemberMapper, P
|
|||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProjectMemberResp createTeamMember(TeamMemberReq req) {
|
||||
// 验证项目是否存在
|
||||
ProjectEntity project = projectService.getById(req.getProjectId());
|
||||
if (project == null) {
|
||||
throw new ServiceException(Message.PROJECT_ID_IS_NOT_EXIST);
|
||||
}
|
||||
|
||||
// 验证用户是否存在
|
||||
UserEntity user = userService.getById(req.getUserId());
|
||||
if (user == null) {
|
||||
throw new ServiceException("用户不存在");
|
||||
}
|
||||
|
||||
// 验证机组是否存在(如果指定了机组)
|
||||
if (StrUtil.isNotBlank(req.getTurbineId())) {
|
||||
TurbineEntity turbine = turbineService.getById(req.getTurbineId());
|
||||
if (turbine == null) {
|
||||
throw new ServiceException("机组不存在");
|
||||
}
|
||||
}
|
||||
|
||||
// 验证任务组是否存在(如果指定了任务组)
|
||||
if (StrUtil.isNotBlank(req.getTaskGroupId())) {
|
||||
ProjectTaskGroupEntity taskGroup = projectTaskGroupService.getById(req.getTaskGroupId());
|
||||
if (taskGroup == null) {
|
||||
throw new ServiceException("任务组不存在");
|
||||
}
|
||||
}
|
||||
|
||||
// 验证任务是否存在(如果指定了任务)
|
||||
if (StrUtil.isNotBlank(req.getTaskId())) {
|
||||
ProjectTaskEntity task = projectTaskService.getById(req.getTaskId());
|
||||
if (task == null) {
|
||||
throw new ServiceException("任务不存在");
|
||||
}
|
||||
}
|
||||
|
||||
// 创建项目成员实体
|
||||
ProjectMemberEntity entity = new ProjectMemberEntity();
|
||||
BeanUtil.copyProperties(req, entity);
|
||||
|
||||
// 保存到数据库
|
||||
this.save(entity);
|
||||
|
||||
// 返回创建后的成员信息
|
||||
return getTeamMemberById(entity.getMemberId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProjectMemberResp updateTeamMember(String memberId, TeamMemberReq req) {
|
||||
// 验证成员是否存在
|
||||
ProjectMemberEntity existingMember = this.getById(memberId);
|
||||
if (existingMember == null) {
|
||||
throw new ServiceException("项目成员不存在");
|
||||
}
|
||||
|
||||
// 验证项目是否存在
|
||||
ProjectEntity project = projectService.getById(req.getProjectId());
|
||||
if (project == null) {
|
||||
throw new ServiceException(Message.PROJECT_ID_IS_NOT_EXIST);
|
||||
}
|
||||
|
||||
// 验证用户是否存在
|
||||
UserEntity user = userService.getById(req.getUserId());
|
||||
if (user == null) {
|
||||
throw new ServiceException("用户不存在");
|
||||
}
|
||||
|
||||
// 验证机组是否存在(如果指定了机组)
|
||||
if (StrUtil.isNotBlank(req.getTurbineId())) {
|
||||
TurbineEntity turbine = turbineService.getById(req.getTurbineId());
|
||||
if (turbine == null) {
|
||||
throw new ServiceException("机组不存在");
|
||||
}
|
||||
}
|
||||
|
||||
// 验证任务组是否存在(如果指定了任务组)
|
||||
if (StrUtil.isNotBlank(req.getTaskGroupId())) {
|
||||
ProjectTaskGroupEntity taskGroup = projectTaskGroupService.getById(req.getTaskGroupId());
|
||||
if (taskGroup == null) {
|
||||
throw new ServiceException("任务组不存在");
|
||||
}
|
||||
}
|
||||
|
||||
// 验证任务是否存在(如果指定了任务)
|
||||
if (StrUtil.isNotBlank(req.getTaskId())) {
|
||||
ProjectTaskEntity task = projectTaskService.getById(req.getTaskId());
|
||||
if (task == null) {
|
||||
throw new ServiceException("任务不存在");
|
||||
}
|
||||
}
|
||||
|
||||
// 更新成员信息
|
||||
BeanUtil.copyProperties(req, existingMember);
|
||||
this.updateById(existingMember);
|
||||
|
||||
// 返回更新后的成员信息
|
||||
return getTeamMemberById(memberId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteTeamMembers(String... memberIds) {
|
||||
if (memberIds == null || memberIds.length == 0) {
|
||||
throw new ServiceException("请选择要删除的成员");
|
||||
}
|
||||
|
||||
// 验证所有成员是否存在
|
||||
List<ProjectMemberEntity> members = this.listByIds(CollUtil.toList(memberIds));
|
||||
if (members.size() != memberIds.length) {
|
||||
throw new ServiceException("部分成员不存在");
|
||||
}
|
||||
|
||||
// 批量删除
|
||||
return this.removeByIds(CollUtil.toList(memberIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据成员ID获取成员信息
|
||||
*/
|
||||
private ProjectMemberResp getTeamMemberById(String memberId) {
|
||||
ProjectMemberEntity entity = this.getById(memberId);
|
||||
if (entity == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 构建查询条件
|
||||
TeamMemberQuery query = new TeamMemberQuery();
|
||||
query.setProjectId(entity.getProjectId());
|
||||
|
||||
// 查询并返回单个成员信息
|
||||
List<ProjectMemberResp> list = this.baseMapper.queryTeamMembers(query);
|
||||
return list.stream()
|
||||
.filter(member -> member.getMemberId().equals(memberId))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
// ========================== 项目看板相关方法实现 ==========================
|
||||
|
||||
@Override
|
||||
|
@ -340,7 +475,10 @@ public class ProjectMemberServiceImpl extends ServiceImpl<ProjectMemberMapper, P
|
|||
List<ProjectKanbanDataResp.ProjectKanbanItem.TeamMemberResp> teamMembers = members.stream()
|
||||
.map(member -> {
|
||||
ProjectKanbanDataResp.ProjectKanbanItem.TeamMemberResp teamMember = new ProjectKanbanDataResp.ProjectKanbanItem.TeamMemberResp();
|
||||
// 先复制所有同名字段
|
||||
BeanUtil.copyProperties(member, teamMember);
|
||||
// 手动处理字段名不一致的字段
|
||||
teamMember.setUserName(member.getName()); // name -> userName
|
||||
return teamMember;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
|
|
@ -2,20 +2,15 @@ package com.dite.znpt.web.controller;
|
|||
|
||||
import com.dite.znpt.domain.PageResult;
|
||||
import com.dite.znpt.domain.Result;
|
||||
import com.dite.znpt.domain.vo.ProjectDetailResp;
|
||||
import com.dite.znpt.domain.vo.ProjectKanbanDataResp;
|
||||
import com.dite.znpt.domain.vo.ProjectKanbanStatsResp;
|
||||
import com.dite.znpt.domain.vo.ProjectMemberResp;
|
||||
import com.dite.znpt.domain.vo.TeamMemberQuery;
|
||||
import com.dite.znpt.domain.vo.*;
|
||||
import com.dite.znpt.service.ProjectMemberService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wangna
|
||||
|
@ -40,6 +35,26 @@ public class ProjectMemberController {
|
|||
return projectMemberService.getProjectTeamMembers(query);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "创建团队成员", httpMethod = "POST")
|
||||
@PostMapping("/team-member")
|
||||
public Result<ProjectMemberResp> createTeamMember(@Valid @RequestBody TeamMemberReq req) {
|
||||
return Result.ok(projectMemberService.createTeamMember(req));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "更新团队成员信息", httpMethod = "PUT")
|
||||
@PutMapping("/team-member/{memberId}")
|
||||
public Result<ProjectMemberResp> updateTeamMember(
|
||||
@PathVariable String memberId,
|
||||
@Valid @RequestBody TeamMemberReq req) {
|
||||
return Result.ok(projectMemberService.updateTeamMember(memberId, req));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除团队成员(支持单个或批量删除)", httpMethod = "DELETE")
|
||||
@DeleteMapping("/team-member/batch")
|
||||
public Result<Boolean> deleteTeamMembers(@RequestBody List<String> ids) {
|
||||
return Result.ok(projectMemberService.deleteTeamMembers(ids.toArray(new String[0])));
|
||||
}
|
||||
|
||||
// ========================== 项目看板相关接口 ==========================
|
||||
|
||||
@ApiOperation(value = "获取项目看板统计数据", httpMethod = "GET")
|
||||
|
|
Loading…
Reference in New Issue