完成了项目任务进度统计与个人任务进度统计功能
parent
d9ccacb9c2
commit
f715834af7
|
@ -95,4 +95,13 @@ public class ProjectController {
|
||||||
projectService.updateProject(token, project);
|
projectService.updateProject(token, project);
|
||||||
return ResponseMap.ofSuccess("操作成功");
|
return ResponseMap.ofSuccess("操作成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
|
@GetMapping("/{projectId}/stats")
|
||||||
|
public ResponseMap getProjectProcess(
|
||||||
|
@RequestHeader("Token") String token,
|
||||||
|
@PathVariable Integer projectId
|
||||||
|
) {
|
||||||
|
return ResponseMap.ofSuccess("查询成功", projectService.getProjectProcess(token, projectId));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,11 @@ package cn.edu.hfut.rmdjzz.projectmanagement.controller;
|
||||||
|
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectGroup;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectGroup;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.vo.GroupPositionVo;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.vo.GroupPositionVo;
|
||||||
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.ForbiddenException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.ForbiddenException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectGroupService;
|
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectGroupService;
|
||||||
|
import cn.edu.hfut.rmdjzz.projectmanagement.service.ITaskService;
|
||||||
|
import cn.edu.hfut.rmdjzz.projectmanagement.utils.TokenUtils;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.ResponseList;
|
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.ResponseList;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.ResponseMap;
|
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.ResponseMap;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
@ -25,6 +28,9 @@ public class ProjectGroupController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private IProjectGroupService projectGroupService;
|
private IProjectGroupService projectGroupService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ITaskService taskService;
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public ResponseList<Integer> getGroupNumber(@PathVariable Integer projectId, @RequestHeader("Token") String token) {
|
public ResponseList<Integer> getGroupNumber(@PathVariable Integer projectId, @RequestHeader("Token") String token) {
|
||||||
|
@ -83,4 +89,17 @@ public class ProjectGroupController {
|
||||||
) {
|
) {
|
||||||
return ResponseMap.ofSuccess("统计成功", projectGroupService.collectStatsForGroupPositions(token, projectId));
|
return ResponseMap.ofSuccess("统计成功", projectGroupService.collectStatsForGroupPositions(token, projectId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
|
@GetMapping("/{staffId}/stats")
|
||||||
|
public ResponseList getProjectProcessOfStaff(
|
||||||
|
@RequestHeader("Token") String token,
|
||||||
|
@PathVariable Integer projectId,
|
||||||
|
@PathVariable Integer staffId
|
||||||
|
) {
|
||||||
|
if(TokenUtils.getStaffId(token) != staffId) {
|
||||||
|
throw new BadRequestException("错误请求");
|
||||||
|
}
|
||||||
|
return ResponseList.ofSuccess("查询成功", taskService.getProjectProcessOfStaff(token, projectId));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,12 @@ package cn.edu.hfut.rmdjzz.projectmanagement.mapper;
|
||||||
|
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Project;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Project;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectDto;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectDto;
|
||||||
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectProcessDto;
|
||||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||||
|
import io.swagger.v3.oas.models.security.SecurityScheme;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.apache.ibatis.annotations.Select;
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
|
@ -17,9 +19,11 @@ public interface ProjectMapper extends BaseMapper<Project> {
|
||||||
|
|
||||||
@Select("""
|
@Select("""
|
||||||
SELECT COUNT(*) FROM project WHERE project_id IN
|
SELECT COUNT(*) FROM project WHERE project_id IN
|
||||||
(SELECT DISTINCT project_id FROM project_group WHERE staff_id = #{id})
|
(SELECT DISTINCT project_id FROM project_group WHERE staff_id = #{staffId})
|
||||||
""")
|
""")
|
||||||
Long findProjectCount(@Param("id") Integer staffId);
|
Long findProjectCount(@Param("staffId") Integer staffId);
|
||||||
|
|
||||||
IPage<ProjectDto> findMyProject(IPage<ProjectDto> pg, @Param("id") Integer staff_id, @Param(Constants.WRAPPER) Wrapper<Project> wrapper);
|
ProjectProcessDto findProjectProcess(@Param("projectId") Integer projectId);
|
||||||
|
|
||||||
|
IPage<ProjectDto> findMyProject(IPage<ProjectDto> pg, @Param("staffId") Integer staff_id, @Param(Constants.WRAPPER) Wrapper<Project> wrapper);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package cn.edu.hfut.rmdjzz.projectmanagement.mapper;
|
||||||
|
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Task;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Task;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.TaskDto;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.TaskDto;
|
||||||
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.StaffProcessDto;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
@ -13,4 +14,6 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public interface TaskMapper extends BaseMapper<Task> {
|
public interface TaskMapper extends BaseMapper<Task> {
|
||||||
List<TaskDto> selectSubTaskList(@Param("projectId") Integer projectId, @Param("fatherId") Long fatherId);
|
List<TaskDto> selectSubTaskList(@Param("projectId") Integer projectId, @Param("fatherId") Long fatherId);
|
||||||
|
|
||||||
|
List<StaffProcessDto> selectProjectProcessOfStaff(@Param("projectId") Integer projectId, @Param("staffId") Integer staffId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,9 @@ package cn.edu.hfut.rmdjzz.projectmanagement.service;
|
||||||
|
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Project;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Project;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectDto;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectDto;
|
||||||
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectProcessDto;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
||||||
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.ForbiddenException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.RequestPage;
|
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.RequestPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
@ -17,6 +19,8 @@ public interface IProjectService extends IService<Project> {
|
||||||
|
|
||||||
Long getAllProjectOfStaff(String token);
|
Long getAllProjectOfStaff(String token);
|
||||||
|
|
||||||
|
ProjectProcessDto getProjectProcess(String token, Integer projectId) throws ForbiddenException;
|
||||||
|
|
||||||
Page<ProjectDto> getOnePageProject(String token, RequestPage page, Map<String, Object> params);
|
Page<ProjectDto> getOnePageProject(String token, RequestPage page, Map<String, Object> params);
|
||||||
|
|
||||||
Boolean setProjectCompleted(String token, Integer projectId) throws BadRequestException;
|
Boolean setProjectCompleted(String token, Integer projectId) throws BadRequestException;
|
||||||
|
|
|
@ -2,6 +2,7 @@ package cn.edu.hfut.rmdjzz.projectmanagement.service;
|
||||||
|
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Task;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Task;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.TaskDto;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.TaskDto;
|
||||||
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.StaffProcessDto;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.ForbiddenException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.ForbiddenException;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
@ -21,6 +22,8 @@ public interface ITaskService extends IService<Task> {
|
||||||
|
|
||||||
Boolean closeTaskAndSubTask(String token, Integer projectId, Long taskId) throws BadRequestException;
|
Boolean closeTaskAndSubTask(String token, Integer projectId, Long taskId) throws BadRequestException;
|
||||||
|
|
||||||
|
List<StaffProcessDto> getProjectProcessOfStaff(String token, Integer projectId) throws BadRequestException, ForbiddenException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return 1:all rights 2:father holder 3:current holder 0:no right
|
* @return 1:all rights 2:father holder 3:current holder 0:no right
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -2,7 +2,9 @@ package cn.edu.hfut.rmdjzz.projectmanagement.service.impl;
|
||||||
|
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Project;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Project;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectDto;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectDto;
|
||||||
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectProcessDto;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
||||||
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.ForbiddenException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.mapper.ProjectMapper;
|
import cn.edu.hfut.rmdjzz.projectmanagement.mapper.ProjectMapper;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectGroupService;
|
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectGroupService;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectService;
|
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectService;
|
||||||
|
@ -36,6 +38,14 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
||||||
return baseMapper.findProjectCount(staffId);
|
return baseMapper.findProjectCount(staffId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ProjectProcessDto getProjectProcess(String token, Integer projectId) throws ForbiddenException {
|
||||||
|
if(projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
|
||||||
|
throw new ForbiddenException("无查看权限");
|
||||||
|
}
|
||||||
|
return baseMapper.findProjectProcess(projectId);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<ProjectDto> getOnePageProject(
|
public Page<ProjectDto> getOnePageProject(
|
||||||
String token,
|
String token,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package cn.edu.hfut.rmdjzz.projectmanagement.service.impl;
|
package cn.edu.hfut.rmdjzz.projectmanagement.service.impl;
|
||||||
|
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Task;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Task;
|
||||||
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.StaffProcessDto;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.TaskDto;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.TaskDto;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.ForbiddenException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.ForbiddenException;
|
||||||
|
@ -112,6 +113,15 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<StaffProcessDto> getProjectProcessOfStaff(String token, Integer projectId) throws BadRequestException, ForbiddenException {
|
||||||
|
Integer staffId = TokenUtils.getStaffId(token);
|
||||||
|
if(projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
|
||||||
|
throw new ForbiddenException("无查看权限");
|
||||||
|
}
|
||||||
|
return baseMapper.selectProjectProcessOfStaff(projectId, staffId);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer getHolderLevel(Integer staffId, Long taskId) {
|
public Integer getHolderLevel(Integer staffId, Long taskId) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -18,11 +18,33 @@
|
||||||
pt2.project_class_name AS project_subclass_name,
|
pt2.project_class_name AS project_subclass_name,
|
||||||
is_completed,
|
is_completed,
|
||||||
is_deleted,
|
is_deleted,
|
||||||
project_closed_date
|
project_closed_date,
|
||||||
|
IF(complete_num IS NULL, 0, complete_num) AS complete_num,
|
||||||
|
IF(total_num IS NULL, 0, total_num) AS total_num
|
||||||
FROM project
|
FROM project
|
||||||
JOIN project_type pt1 ON project.project_class_id = pt1.project_class_id
|
JOIN project_type pt1 ON project.project_class_id = pt1.project_class_id
|
||||||
JOIN project_type pt2 ON project.project_subclass_id = pt2.project_class_id
|
JOIN project_type pt2 ON project.project_subclass_id = pt2.project_class_id
|
||||||
WHERE project_id IN (SELECT DISTINCT project_id FROM project_group WHERE staff_id = #{id})) AS T
|
LEFT JOIN (SELECT task_project_id,
|
||||||
|
SUM(IF(task_status = '已完成' OR task_status = '关闭', 1, 0)) AS complete_num,
|
||||||
|
COUNT(task_status) AS total_num
|
||||||
|
FROM task
|
||||||
|
WHERE is_deleted = false
|
||||||
|
AND task_project_id != 0
|
||||||
|
GROUP BY task_project_id) AS t
|
||||||
|
ON project.project_id = t.task_project_id
|
||||||
|
WHERE project_id IN (SELECT DISTINCT project_id FROM project_group WHERE staff_id = #{staffId})
|
||||||
|
AND is_deleted = false) AS T
|
||||||
${ew.customSqlSegment}
|
${ew.customSqlSegment}
|
||||||
</select>
|
</select>
|
||||||
|
<select id="findProjectProcess" resultType="cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectProcessDto">
|
||||||
|
SELECT #{projectId} AS project_id,
|
||||||
|
IF(complete_num IS NULL, 0, complete_num) AS complete_num,
|
||||||
|
total_num
|
||||||
|
FROM (SELECT SUM(IF(task_status = '已完成' OR task_status = '关闭', 1, 0)) AS complete_num,
|
||||||
|
COUNT(task_status) AS total_num
|
||||||
|
FROM task
|
||||||
|
WHERE is_deleted = false
|
||||||
|
AND task_project_id != 0
|
||||||
|
AND task_project_id = #{projectId}) AS T;
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -25,4 +25,21 @@
|
||||||
AND task_project_id = #{projectId}
|
AND task_project_id = #{projectId}
|
||||||
AND t.task_father_id = #{fatherId}
|
AND t.task_father_id = #{fatherId}
|
||||||
</select>
|
</select>
|
||||||
|
<select id="selectProjectProcessOfStaff" resultType="cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.StaffProcessDto">
|
||||||
|
SELECT t2.task_type,
|
||||||
|
IF(complete_num IS NULL, 0, complete_num) AS complete_num,
|
||||||
|
IF(total_num IS NULL, 0, total_num) AS total_num
|
||||||
|
FROM (SELECT task_type,
|
||||||
|
SUM(IF(task_status = '已完成' OR task_status = '关闭', 1, 0)) AS complete_num,
|
||||||
|
COUNT(task_status) AS total_num
|
||||||
|
FROM task
|
||||||
|
WHERE is_deleted = false
|
||||||
|
AND task_project_id != 0
|
||||||
|
AND task_project_id = #{projectId}
|
||||||
|
<if test="staffId != null">AND task_holder_id = #{staffId}</if>
|
||||||
|
GROUP BY task_type) AS t1
|
||||||
|
RIGHT JOIN (SELECT DISTINCT task_type FROM task) AS t2
|
||||||
|
ON t1.task_type = t2.task_type
|
||||||
|
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
Loading…
Reference in New Issue