Commit 88d8c95c authored by wdy's avatar wdy

待办任务车型测试子任务进度

parent 07ec99a8
......@@ -2,6 +2,9 @@ package com.ruoyi.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.domain.ModelTestTask;
import com.ruoyi.web.response.ResultCountResponse;
import com.ruoyi.web.response.TaskFindResponse;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
......@@ -15,4 +18,10 @@ public interface ModelTestTaskMapper extends BaseMapper<ModelTestTask> {
// 查询pending状态下的所有任务
List<ModelTestTask> findByStatus();
// 根据总任务列表查询子任务
List<ModelTestTask> findByTaskList(@Param("responses") List<TaskFindResponse> responses);
// 根据子任务列表查询进度
List<ResultCountResponse> testAnswerCount(@Param("responses")List<TaskFindResponse> responses);
}
......@@ -22,9 +22,7 @@ import com.ruoyi.web.response.DataStatisticsResponse;
import com.ruoyi.web.response.ResultCountResponse;
import com.ruoyi.web.response.TaskFindResponse;
import com.ruoyi.web.response.TaskGetInfoResponse;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -103,6 +101,9 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
@Autowired
private TaskFileRelationService taskFileRelationService;
@Autowired
private ModelTestTaskMapper modelTestTaskMapper;
@Override
public List<Task> findList(TaskListRequest request) {
return taskMapper.findList(request);
......@@ -213,60 +214,16 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
if (responses != null && responses.size() != 0) {
// 体系审查子任务列表
List<SystemReviewTask> systemReviewTaskList = systemReviewTaskMapper.findByTaskList(responses);
if (systemReviewTaskList != null && systemReviewTaskList.size() != 0) {
// 子任务列表进度
List<ResultCountResponse> responseLists = reviewDetailsMapper.systemAnswerCount(systemReviewTaskList,SystemReviewTask.TYPE);
if (responseLists != null && responseLists.size() != 0) {
// 设置子任务不为finish时,最大进度为90
for (ResultCountResponse response : responseLists) {
if (Objects.equals(response.getTaskStatus(), SystemReviewTask.STATUS_FINISH)) {
response.setSchedule(100.0);
} else {
BigDecimal num = new BigDecimal(response.getSchedule());
response.setSchedule(num.setScale(1,BigDecimal.ROUND_UP).doubleValue());
}
}
for (ResultCountResponse responseList : responseLists) {
for (TaskFindResponse response : responses) {
if (responseList.getTaskId().equals(response.getSystemReviewTaskId())) {
response.setSystemReview(responseList.getSchedule());
}
}
}
}
}
setSystemProgress(systemReviewTaskList,responses);
// 车型问卷子任务列表
List<CarReviewTask> carReviewTaskList = carReviewTaskMapper.findByTaskList(responses);
setCarProgress(carReviewTaskList,responses);
if (carReviewTaskList != null && carReviewTaskList.size() != 0) {
// 子任务列表进度
List<ResultCountResponse> carResponseList = reviewDetailsMapper.carAnswerCount(carReviewTaskList,CarReviewTask.TYPE);
if (carResponseList != null && carResponseList.size() != 0) {
// 设置子任务不为finish时,最大进度为90
for (ResultCountResponse response : carResponseList) {
if (Objects.equals(response.getTaskStatus(), CarReviewTask.TASK_STATUS_FINISH)) {
response.setSchedule(100.0);
} else {
BigDecimal num = new BigDecimal(response.getSchedule());
response.setSchedule(num.setScale(1,BigDecimal.ROUND_UP).doubleValue());
}
}
// 车型试验子任务列表
List<ModelTestTask> modelTestTaskList = modelTestTaskMapper.findByTaskList(responses);
setModelProgress(modelTestTaskList,responses);
for (ResultCountResponse responseList : carResponseList) {
for (TaskFindResponse response : responses) {
if (responseList.getTaskId().equals(response.getCarReviewTaskId())) {
response.setCarReview(responseList.getSchedule());
}
}
}
}
}
for (TaskFindResponse response : responses) {
String[] taskList = response.getTaskList().split(",");
......@@ -349,6 +306,30 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
systemReviewTaskMapper.deleteById(task.getSystemReviewTaskId());
carReviewTaskMapper.deleteById(task.getCarReviewTaskId());
modelTestTaskMapper.deleteById(task.getModelTestTaskId());
// 小组
List<TaskUserRelation> list = taskUserRelationService.selectQTeamMembers(task.getId());
if (list != null && list.size() != 0) {
taskFileRelationService.removeBatchByIds(list);
}
// 样品
List<TaskSampleRelation> relationList = taskSampleRelationService.selectByTaskId(task.getId(),TaskSampleRelation.COMPLETE_VEHICLE_SAMPLE);
if (relationList != null && relationList.size() != 0) {
taskSampleRelationService.removeBatchByIds(relationList);
}
List<TaskSampleRelation> partRelationList = taskSampleRelationService.selectByTaskId(task.getId(),TaskSampleRelation.PART_VEHICLE_SAMPLE);
if (partRelationList != null && partRelationList.size() != 0) {
taskSampleRelationService.removeBatchByIds(partRelationList);
}
// 文件
List<TaskFileRelation> fileList = taskFileRelationService.findByTaskId(task.getId());
if (fileList != null && fileList.size() != 0) {
taskFileRelationService.removeBatchByIds(fileList);
}
taskMapper.deleteById(request.getId());
}
......@@ -479,7 +460,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
// 找到审查组长
TaskUserRelation leader = null;
List<TaskUserRelation> auditors = request.getAuditors();
if (auditors.size() != 0 && auditors != null) {
if (auditors != null && auditors.size() != 0) {
for(TaskUserRelation auditor : auditors) {
if(auditor.getIsLeader() == 1) {
leader = auditor;
......@@ -542,7 +523,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
// 找到审查组长
TaskUserRelation leader = null;
List<TaskUserRelation> auditors = request.getAuditors();
if (auditors.size() != 0 && auditors != null) {
if (auditors != null && auditors.size() != 0) {
for(TaskUserRelation auditor : auditors) {
if(auditor.getIsLeader() == 1) {
leader = auditor;
......@@ -678,6 +659,97 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
}
private void setModelProgress(List<ModelTestTask> modelTestTaskList, List<TaskFindResponse> responses) {
if (modelTestTaskList != null && modelTestTaskList.size() != 0) {
// 子任务进度列表
List<ResultCountResponse> testResponseList = modelTestTaskMapper.testAnswerCount(responses);
if (testResponseList != null && testResponseList.size() != 0) {
// 设置子任务不为finish时,最大进度为90 进度为null时,改为0
for (ResultCountResponse response : testResponseList) {
if (Objects.equals(response.getTaskStatus(), ModelTestTask.TASK_STATUS_FINISH)) {
response.setSchedule(100.0);
} else if (Objects.equals(response.getTaskStatus(), ModelTestTask.TASK_STATUS_SIGNED)) {
response.setSchedule(90.0);
} else if (response.getSchedule() == null) {
response.setSchedule(0.0);
} else {
BigDecimal num = new BigDecimal(response.getSchedule());
response.setSchedule(num.setScale(1,BigDecimal.ROUND_UP).doubleValue());
}
}
for (ResultCountResponse responseList : testResponseList) {
for (TaskFindResponse response : responses) {
if (responseList.getTaskId().equals(response.getModelTestTaskId())) {
response.setTest(responseList.getSchedule());
}
}
}
}
}
}
private void setCarProgress(List<CarReviewTask> carReviewTaskList, List<TaskFindResponse> responses) {
if (carReviewTaskList != null && carReviewTaskList.size() != 0) {
// 子任务列表进度
List<ResultCountResponse> carResponseList = reviewDetailsMapper.carAnswerCount(carReviewTaskList,CarReviewTask.TYPE);
if (carResponseList != null && carResponseList.size() != 0) {
// 设置子任务不为finish时,最大进度为90
for (ResultCountResponse response : carResponseList) {
if (Objects.equals(response.getTaskStatus(), CarReviewTask.TASK_STATUS_FINISH)) {
response.setSchedule(100.0);
} else {
BigDecimal num = new BigDecimal(response.getSchedule());
response.setSchedule(num.setScale(1,BigDecimal.ROUND_UP).doubleValue());
}
}
for (ResultCountResponse responseList : carResponseList) {
for (TaskFindResponse response : responses) {
if (responseList.getTaskId().equals(response.getCarReviewTaskId())) {
response.setCarReview(responseList.getSchedule());
}
}
}
}
}
}
private void setSystemProgress(List<SystemReviewTask> systemReviewTaskList,List<TaskFindResponse> responses) {
if (systemReviewTaskList != null && systemReviewTaskList.size() != 0) {
// 子任务列表进度
List<ResultCountResponse> responseLists = reviewDetailsMapper.systemAnswerCount(systemReviewTaskList,SystemReviewTask.TYPE);
if (responseLists != null && responseLists.size() != 0) {
// 设置子任务不为finish时,最大进度为90
for (ResultCountResponse response : responseLists) {
if (Objects.equals(response.getTaskStatus(), SystemReviewTask.STATUS_FINISH)) {
response.setSchedule(100.0);
} else {
BigDecimal num = new BigDecimal(response.getSchedule());
response.setSchedule(num.setScale(1,BigDecimal.ROUND_UP).doubleValue());
}
}
for (ResultCountResponse responseList : responseLists) {
for (TaskFindResponse response : responses) {
if (responseList.getTaskId().equals(response.getSystemReviewTaskId())) {
response.setSystemReview(responseList.getSchedule());
}
}
}
}
}
}
// 按顺序设置taskList
private void setTaskList(List<String> taskList, Task task) {
// 定义一个比较器,按照 "sraif, grfis, trfis" 的顺序排序
......
......@@ -31,6 +31,34 @@
SELECT id,task_no,task_status,task_initiator,task_initiator_dept,task_result,task_begin_time,task_end_time,test_case,create_time,leader_id,leader,standard_id,name,standard_no,submit_id,submit_name,images_url,details,standards,test_scheme_id
FROM t_model_test_task WHERE task_status = 'PENDING'
</select>
<select id="findByTaskList" resultType="com.ruoyi.domain.ModelTestTask">
SELECT id,task_no,task_status,task_initiator,task_initiator_dept,task_result,task_begin_time,task_end_time,test_case,create_time,leader_id,leader,standard_id,name,standard_no,submit_id,submit_name,images_url,details,standards,test_scheme_id
FROM t_model_test_task
WHERE id IN
<foreach collection="responses" item="task" open="(" separator="," close=")">
#{task.modelTestTaskId}
</foreach>
</select>
<select id="testAnswerCount" resultType="com.ruoyi.web.response.ResultCountResponse">
<foreach item="task" collection="responses" separator="UNION ALL">
SELECT
#{task.modelTestTaskId} AS taskId,
(IFNULL(
(SELECT COUNT(*) FROM t_test_records WHERE task_id = #{task.modelTestTaskId}),
0
) /
IFNULL(
(SELECT COUNT(*) FROM t_task_scenario_relation tsr
INNER JOIN t_test_scenario tts ON tts.id = tsr.test_scenario_id
INNER JOIN t_test_usecase ttu ON tts.id = ttu.test_scenario_id
WHERE tsr.task_id = #{task.id}),
1
)) * 90 AS schedule,
tm.task_status AS taskStatus
from t_model_test_task tm where tm.id = #{task.modelTestTaskId}
</foreach>
group by taskId
</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