Commit 3e0ec55f authored by wdy's avatar wdy

任务小组成员名称、部门获取

parent 860c2515
......@@ -2,6 +2,7 @@ package com.ruoyi.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.domain.Task;
import com.ruoyi.domain.TaskUserRelation;
import com.ruoyi.domain.vo.EnterpriseFilePdfVO;
import com.ruoyi.domain.vo.InspectionReportPdfVO;
import com.ruoyi.web.request.TaskFindFinishRequest;
......@@ -10,6 +11,7 @@ import com.ruoyi.web.request.TaskFindRequest;
import com.ruoyi.web.request.TaskListRequest;
import com.ruoyi.web.response.TaskFindResponse;
import com.ruoyi.web.response.TaskScenarioResponse;
import com.ruoyi.web.response.UserNameResponse;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
......@@ -56,4 +58,12 @@ public interface TaskMapper extends BaseMapper<Task> {
// 根据任务列表查询对应的场景数量
List<TaskScenarioResponse> findByTaskList(@Param("responses") List<TaskFindResponse> responses);
// 任务列表查询小组成员名称、部门
List<UserNameResponse> findByUserIdList(@Param("responses") List<TaskFindResponse> responses);
// 任务小组关系列表查询小组成员名称、部门
List<UserNameResponse> findByRelation(@Param("relation") List<TaskUserRelation> relation);
List<UserNameResponse> findByFinishTaskList(@Param("taskList") List<Task> taskList);
}
......@@ -11,4 +11,6 @@ import java.util.List;
public interface TestRecordsMapper extends BaseMapper<TestRecords> {
List<TestRecords> findByTaskId(@Param("id") String id);
Long countResult(@Param("projectId") String projectId);
}
......@@ -220,6 +220,10 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
List<TaskFindResponse> responses = taskMapper.findPending(request,userId);
if (responses != null && responses.size() != 0) {
// 小组成员
List<UserNameResponse> userList = taskMapper.findByUserIdList(responses);
setLeader(userList,responses);
// 体系审查子任务列表
List<SystemReviewTask> systemReviewTaskList = systemReviewTaskMapper.findByTaskList(responses);
setSystemProgress(systemReviewTaskList,responses);
......@@ -253,7 +257,14 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
@Override
public List<Task> findFinish(TaskFindFinishRequest request) {
return taskMapper.findFinish(request);
List<Task> taskList = taskMapper.findFinish(request);
List<UserNameResponse> responseList = taskMapper.findByFinishTaskList(taskList);
setFinishLeader(responseList,taskList);
return taskList;
}
@Override
......@@ -354,26 +365,34 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
@Override
public List<TaskFindResponse> findCreate(TaskFindRequest request,Long userId) {
List<TaskFindResponse> responses = taskMapper.findByUserId(request,userId);
for (TaskFindResponse response : responses) {
if (response.getSystemReviewTaskId() != null) {
SystemReviewTask systemReviewTask = systemReviewTaskMapper.selectById(response.getSystemReviewTaskId());
if (Objects.equals(systemReviewTask.getTaskStatus(), SystemReviewTask.STATUS_FINISH)) {
response.setSystemReview(100.0);
} else {
BigDecimal num = new BigDecimal(((double)reviewDetailsMapper.count(response.getSystemReviewTaskId(),SystemReviewTask.TYPE))* 100 * 0.9);
response.setSystemReview(num.setScale(1,BigDecimal.ROUND_UP).doubleValue());
}
}
if (response.getCarReviewTaskId() != null) {
CarReviewTask carReviewTask = carReviewTaskMapper.selectById(response.getCarReviewTaskId());
if (Objects.equals(carReviewTask.getTaskStatus(), CarReviewTask.TASK_STATUS_FINISH)) {
response.setCarReview(100.0);
if (responses != null && responses.size() != 0) {
// 小组成员
List<UserNameResponse> userList = taskMapper.findByUserIdList(responses);
setLeader(userList,responses);
// 体系审查子任务列表
List<SystemReviewTask> systemReviewTaskList = systemReviewTaskMapper.findByTaskList(responses);
setSystemProgress(systemReviewTaskList,responses);
// 车型问卷子任务列表
List<CarReviewTask> carReviewTaskList = carReviewTaskMapper.findByTaskList(responses);
setCarProgress(carReviewTaskList,responses);
// 车型试验子任务列表
List<ModelTestTask> modelTestTaskList = modelTestTaskMapper.findByTaskList(responses);
setModelProgress(modelTestTaskList,responses);
for (TaskFindResponse response : responses) {
String[] taskList = response.getTaskList().split(",");
if (response.getPointer() < taskList.length) {
response.setNextSubTask(taskList[response.getPointer()]);
} else {
BigDecimal num = new BigDecimal(((double) reviewDetailsMapper.count(response.getCarReviewTaskId(), CarReviewTask.TYPE)) * 100 * 0.9);
response.setCarReview(num.setScale(1, BigDecimal.ROUND_UP).doubleValue());
response.setNextSubTask(taskList[taskList.length - 1]);
}
}
}
return responses;
}
......@@ -435,7 +454,13 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
@Override
public List<Task> findUserFinish(TaskFindFinishRequest request,Long userId) {
return taskMapper.findUserFinish(request,userId);
List<Task> taskList = taskMapper.findUserFinish(request,userId);
List<UserNameResponse> responseList = taskMapper.findByFinishTaskList(taskList);
setFinishLeader(responseList,taskList);
return taskList;
}
@Override
......@@ -679,6 +704,34 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
}
private void setFinishLeader(List<UserNameResponse> responseList, List<Task> taskList) {
if (responseList != null && responseList.size() != 0) {
for (UserNameResponse response : responseList) {
for (Task task : taskList) {
if (Objects.equals(response.getUserId(), task.getLeaderId())) {
task.setLeader(response.getName());
}
}
}
}
}
private void setLeader(List<UserNameResponse> userList, List<TaskFindResponse> responses) {
if (userList != null && userList.size() != 0) {
for (UserNameResponse response : userList) {
for (TaskFindResponse findResponse : responses) {
if (Objects.equals(findResponse.getLeaderId(), response.getUserId())) {
findResponse.setLeader(response.getName());
}
}
}
}
}
private void setTaskScenario(List<TaskScenarioResponse> scenarioResponseList, List<TaskFindResponse> responses) {
if (scenarioResponseList != null && scenarioResponseList.size() != 0) {
......@@ -1019,6 +1072,18 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
// 小组成员
List<TaskUserRelation> relation = taskUserRelationService.selectQTeamMembers(id);
// 小组成员姓名、部门
List<UserNameResponse> userList = taskMapper.findByRelation(relation);
for (UserNameResponse response : userList) {
for (TaskUserRelation taskUserRelation : relation) {
if (Objects.equals(response.getUserId(), taskUserRelation.getUserId())) {
taskUserRelation.setName(response.getName());
taskUserRelation.setDeptName(response.getDeptName());
}
}
}
// 小组成员状态
List<TaskUserRelation> relationList = taskUserRelationMapper.findByIdList(relation);
......
package com.ruoyi.web.response;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("检验员VO")
public class UserNameResponse {
@ApiModelProperty("检验员id")
private Long userId;
@ApiModelProperty("名称")
private String name;
@ApiModelProperty("部门名称")
private String deptName;
}
......@@ -182,6 +182,8 @@
t.task_begin_time,
t.task_end_time,
t.standard_no,
t.task_list,
t.pointer,
srt.task_begin_time system_task_begin_time,
srt.task_end_time system_task_end_time,
srt.task_status review_status,
......@@ -351,6 +353,33 @@
</foreach>
GROUP BY task_id
</select>
<select id="findByUserIdList" resultType="com.ruoyi.web.response.UserNameResponse">
SELECT s.user_id userId, s.nick_name name, sd.dept_name deptName
FROM sys_user s
LEFT JOIN sys_dept sd ON s.dept_id = sd.dept_id
WHERE s.user_id IN
<foreach item="item" collection="responses" open="(" separator="," close=")">
#{item.leaderId}
</foreach>
</select>
<select id="findByRelation" resultType="com.ruoyi.web.response.UserNameResponse">
SELECT s.user_id userId, s.nick_name name, sd.dept_name deptName
FROM sys_user s
LEFT JOIN sys_dept sd ON s.dept_id = sd.dept_id
WHERE s.user_id IN
<foreach item="item" collection="relation" open="(" separator="," close=")">
#{item.userId}
</foreach>
</select>
<select id="findByFinishTaskList" resultType="com.ruoyi.web.response.UserNameResponse">
SELECT s.user_id userId, s.nick_name name, sd.dept_name deptName
FROM sys_user s
LEFT JOIN sys_dept sd ON s.dept_id = sd.dept_id
WHERE s.user_id IN
<foreach item="item" collection="taskList" open="(" separator="," close=")">
#{item.leaderId}
</foreach>
</select>
</mapper>
......@@ -23,6 +23,11 @@
FROM t_test_records
WHERE project_id = #{id}
</select>
<select id="countResult" resultType="java.lang.Long">
SELECT COUNT(*) FROM t_test_records
WHERE project_id = #{projectId}
GROUP BY project_id
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment