增加了统计整个项目与个人完成情况
parent
ff47276365
commit
9bc59be2a0
|
@ -131,20 +131,6 @@ public class ProjectGroupController {
|
||||||
return ResponseMap.ofSuccess(projectGroupService.collectStatsForGroupPositions(token, projectId));
|
return ResponseMap.ofSuccess(projectGroupService.collectStatsForGroupPositions(token, projectId));
|
||||||
}
|
}
|
||||||
|
|
||||||
//FIXME: DELETE
|
|
||||||
@SneakyThrows
|
|
||||||
@GetMapping("/{staffId}/stats")
|
|
||||||
public ResponseList<StaffProcessDTO> getProjectProcessOfStaff(
|
|
||||||
@RequestHeader(TokenUtils.HEADER_TOKEN) String token,
|
|
||||||
@PathVariable Integer projectId,
|
|
||||||
@PathVariable Integer staffId
|
|
||||||
) {
|
|
||||||
if (!Objects.equals(TokenUtils.getStaffId(token), staffId)) {
|
|
||||||
throw new BadRequestException(BadRequestException.WRONG_PARAMETERS);
|
|
||||||
}
|
|
||||||
return ResponseList.ofSuccess(taskService.getProjectProcessOfStaff(token, projectId));
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO: TEST
|
//TODO: TEST
|
||||||
@Operation(description = "请求体是一个key为taskId,value为staffId的map")
|
@Operation(description = "请求体是一个key为taskId,value为staffId的map")
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
|
|
|
@ -3,6 +3,7 @@ package cn.edu.hfut.rmdjzz.projectmanagement.controller;
|
||||||
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.exception.BadRequestException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
||||||
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.ForbiddenException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectService;
|
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectService;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.service.ITaskService;
|
import cn.edu.hfut.rmdjzz.projectmanagement.service.ITaskService;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.utils.TokenUtils;
|
import cn.edu.hfut.rmdjzz.projectmanagement.utils.TokenUtils;
|
||||||
|
@ -110,14 +111,30 @@ public class TaskController {
|
||||||
return ResponseMap.ofSuccess("查询成功", taskService.getProjectTaskTrend(token, projectId));
|
return ResponseMap.ofSuccess("查询成功", taskService.getProjectTaskTrend(token, projectId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
|
@GetMapping("/stats/group")
|
||||||
|
public ResponseMap getTaskNumOfEveryone(
|
||||||
|
@RequestHeader(TokenUtils.HEADER_TOKEN) String token,
|
||||||
|
@PathVariable Integer projectId
|
||||||
|
) {
|
||||||
|
if(!projectService.checkOpenStatus(projectId)) {
|
||||||
|
throw new BadRequestException(IProjectService.PROJECT_UNOPENED);
|
||||||
|
}
|
||||||
|
return ResponseMap.ofSuccess("查询成功", taskService.getProjectProcessOfEveryone(token, projectId));
|
||||||
|
}
|
||||||
|
|
||||||
//TODO:
|
//TODO:
|
||||||
|
@SneakyThrows
|
||||||
@GetMapping({"/stats", "/stats/{staffId}"})
|
@GetMapping({"/stats", "/stats/{staffId}"})
|
||||||
public ResponseMap getProjectStatistics(
|
public ResponseList getProjectStatistics(
|
||||||
@RequestHeader(TokenUtils.HEADER_TOKEN) String token,
|
@RequestHeader(TokenUtils.HEADER_TOKEN) String token,
|
||||||
@PathVariable Integer projectId,
|
@PathVariable Integer projectId,
|
||||||
@PathVariable(required = false) Integer staffId
|
@PathVariable(required = false) Integer staffId
|
||||||
) {
|
) {
|
||||||
return ResponseMap.ofSuccess();
|
if(!projectService.checkOpenStatus(projectId)) {
|
||||||
|
throw new BadRequestException(IProjectService.PROJECT_UNOPENED);
|
||||||
|
}
|
||||||
|
return ResponseList.ofSuccess("查询成功", taskService.getProjectStatistics(token, projectId, staffId));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
package cn.edu.hfut.rmdjzz.projectmanagement.entity.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 阳勇权
|
||||||
|
* @since 2022/7/12 14:36
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class TaskNumOfEveryoneDTO {
|
||||||
|
String staffFullname;
|
||||||
|
Long completedNum;
|
||||||
|
}
|
|
@ -3,6 +3,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.StaffProcessDTO;
|
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.entity.dto.TaskNumOfEveryoneDTO;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.TaskTrendDTO;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.TaskTrendDTO;
|
||||||
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;
|
||||||
|
@ -17,10 +18,12 @@ 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);
|
List<StaffProcessDTO> selectProjectProcess(@Param("projectId") Integer projectId, @Param("staffId") Integer staffId);
|
||||||
|
|
||||||
List<TaskTrendDTO> selectClosedTaskTrendBeforeDate(@Param("projectId") Integer projectId, @Param("startDate") LocalDate startDate);
|
List<TaskTrendDTO> selectClosedTaskTrendBeforeDate(@Param("projectId") Integer projectId, @Param("startDate") LocalDate startDate);
|
||||||
|
|
||||||
|
List<TaskNumOfEveryoneDTO> selectProjectProcessOfEveryone(@Param("projectId") Integer projectId);
|
||||||
|
|
||||||
TaskTrendDTO selectUnclosedTaskTrendBeforeDate(@Param("projectId") Integer projectId, @Param("startDate") LocalDate startDate);
|
TaskTrendDTO selectUnclosedTaskTrendBeforeDate(@Param("projectId") Integer projectId, @Param("startDate") LocalDate startDate);
|
||||||
|
|
||||||
List<TaskTrendDTO> selectTaskClosedNum(@Param("projectId") Integer projectId, @Param("startDate") LocalDate startDate, @Param("endDate") LocalDate endDate);
|
List<TaskTrendDTO> selectTaskClosedNum(@Param("projectId") Integer projectId, @Param("startDate") LocalDate startDate, @Param("endDate") LocalDate endDate);
|
||||||
|
|
|
@ -24,7 +24,7 @@ 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;
|
List<StaffProcessDTO> getProjectStatistics(String token, Integer projectId, Integer staffId) 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
|
||||||
|
@ -51,4 +51,6 @@ public interface ITaskService extends IService<Task> {
|
||||||
Boolean transferStaffTasks(String token, Integer projectId, Integer transferredStaffId, Map<Long, Integer> transferMap) throws ForbiddenException, BadRequestException;
|
Boolean transferStaffTasks(String token, Integer projectId, Integer transferredStaffId, Map<Long, Integer> transferMap) throws ForbiddenException, BadRequestException;
|
||||||
|
|
||||||
Boolean transferTasksToSingleStaff(String token, Integer projectId, Integer transferredStaffId, Integer targetStaffId) throws ForbiddenException, BadRequestException;
|
Boolean transferTasksToSingleStaff(String token, Integer projectId, Integer transferredStaffId, Integer targetStaffId) throws ForbiddenException, BadRequestException;
|
||||||
|
|
||||||
|
Map<String, Long> getProjectProcessOfEveryone(String token, Integer projectId) throws ForbiddenException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ 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.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.entity.dto.TaskNumOfEveryoneDTO;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.TaskTrendDTO;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.TaskTrendDTO;
|
||||||
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;
|
||||||
|
@ -130,12 +131,14 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<StaffProcessDTO> getProjectProcessOfStaff(String token, Integer projectId) throws ForbiddenException {
|
public List<StaffProcessDTO> getProjectStatistics(String token, Integer projectId, Integer staffId) throws ForbiddenException {
|
||||||
Integer staffId = TokenUtils.getStaffId(token);
|
if(staffId != null && !TokenUtils.getStaffId(token).equals(staffId)) {
|
||||||
|
throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
|
||||||
|
}
|
||||||
if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
|
if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
|
||||||
throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
|
throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
|
||||||
}
|
}
|
||||||
List<StaffProcessDTO> resList = baseMapper.selectProjectProcessOfStaff(projectId, staffId);
|
List<StaffProcessDTO> resList = baseMapper.selectProjectProcess(projectId, staffId);
|
||||||
addResultProjectProcess(resList, Task.TYPE_ASSIGNMENT);
|
addResultProjectProcess(resList, Task.TYPE_ASSIGNMENT);
|
||||||
addResultProjectProcess(resList, Task.TYPE_DEFECT);
|
addResultProjectProcess(resList, Task.TYPE_DEFECT);
|
||||||
addResultProjectProcess(resList, Task.TYPE_DEMAND);
|
addResultProjectProcess(resList, Task.TYPE_DEMAND);
|
||||||
|
@ -511,4 +514,17 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
|
||||||
return transferredTaskCount.intValue() == updatedTaskCount;
|
return transferredTaskCount.intValue() == updatedTaskCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Long> getProjectProcessOfEveryone(String token, Integer projectId) throws ForbiddenException{
|
||||||
|
if(projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
|
||||||
|
throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
|
||||||
|
}
|
||||||
|
Map<String, Long> resMap = new HashMap<>();
|
||||||
|
List<TaskNumOfEveryoneDTO> resList = baseMapper.selectProjectProcessOfEveryone(projectId);
|
||||||
|
for(TaskNumOfEveryoneDTO taskNumOfEveryoneDTO: resList) {
|
||||||
|
resMap.put(taskNumOfEveryoneDTO.getStaffFullname(), taskNumOfEveryoneDTO.getCompletedNum());
|
||||||
|
}
|
||||||
|
return resMap;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
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"
|
<select id="selectProjectProcess"
|
||||||
resultType="cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.StaffProcessDTO">
|
resultType="cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.StaffProcessDTO">
|
||||||
SELECT task_type,
|
SELECT task_type,
|
||||||
SUM(IF(task_status = '已完成' OR task_status = '关闭', 1, 0)) AS complete_num,
|
SUM(IF(task_status = '已完成' OR task_status = '关闭', 1, 0)) AS complete_num,
|
||||||
|
@ -43,6 +43,16 @@
|
||||||
</if>
|
</if>
|
||||||
GROUP BY task_type
|
GROUP BY task_type
|
||||||
</select>
|
</select>
|
||||||
|
<select id="selectProjectProcessOfEveryone" resultType="cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.TaskNumOfEveryoneDTO">
|
||||||
|
SELECT staff_fullname, completed_num
|
||||||
|
FROM (SELECT task_holder_id, SUM(IF(task_closed_time IS NULL, 0, 1)) AS completed_num
|
||||||
|
FROM task
|
||||||
|
WHERE !is_deleted
|
||||||
|
AND task_project_id = #{projectId}
|
||||||
|
AND task_id != 0
|
||||||
|
GROUP BY task_holder_id) AS T
|
||||||
|
JOIN staff ON staff_id = T.task_holder_id;
|
||||||
|
</select>
|
||||||
<select id="selectTaskClosedNum" resultType="cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.TaskTrendDTO">
|
<select id="selectTaskClosedNum" resultType="cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.TaskTrendDTO">
|
||||||
SELECT closed_date AS task_date,
|
SELECT closed_date AS task_date,
|
||||||
task_status,
|
task_status,
|
||||||
|
|
Loading…
Reference in New Issue