Commit 9896112c authored by wdy's avatar wdy

Merge branch 'wangdingyi' into 'dev'

查询进行中的任务

See merge request !206
parents d25c5159 508227d4
......@@ -2,6 +2,7 @@ package com.ruoyi.mapper;
import com.ruoyi.domain.CarReviewTask;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.web.response.TaskFindResponse;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
......@@ -21,6 +22,8 @@ public interface CarReviewTaskMapper extends BaseMapper<CarReviewTask> {
List<CarReviewTask> findListByTaskStatus(@Param("taskStatus") String taskStatus);
List<CarReviewTask> findByDetailsResult(@Param("detailId") Long detailId);
List<CarReviewTask> findByTaskList(@Param("responses") List<TaskFindResponse> responses);
}
......
package com.ruoyi.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.domain.CarReviewTask;
import com.ruoyi.domain.ReviewDetails;
import com.ruoyi.domain.ReviewKeyPoint;
import com.ruoyi.domain.SystemReviewTask;
import com.ruoyi.web.request.ReviewFindListRequest;
import com.ruoyi.web.response.ResultCountResponse;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
......@@ -22,6 +25,10 @@ public interface ReviewDetailsMapper extends BaseMapper<ReviewDetails> {
Double count (@Param("taskId")Long taskId, @Param("type")String type);
List<ResultCountResponse> systemAnswerCount(@Param("systemReviewTaskList")List<SystemReviewTask> systemReviewTaskList, @Param("type")String type);
List<ResultCountResponse> carAnswerCount(@Param("carReviewTaskList")List<CarReviewTask> carReviewTaskList, @Param("type")String type);
// 根据要点id查询细则列表
List<ReviewDetails> findByKeyPointId(@Param("keyPointId") Long keyPointId);
......
......@@ -2,6 +2,7 @@ package com.ruoyi.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.domain.SystemReviewTask;
import com.ruoyi.web.response.TaskFindResponse;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
......@@ -15,4 +16,6 @@ public interface SystemReviewTaskMapper extends BaseMapper<SystemReviewTask> {
List<SystemReviewTask> findListInProcess();
List<SystemReviewTask> findByDetailsResult(@Param("detailId") Long detailId);
List<SystemReviewTask> findByTaskList(@Param("responses") List<TaskFindResponse> responses);
}
......@@ -184,25 +184,66 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
@Override
public List<TaskFindResponse> findPending(TaskFindPendingRequest request,Long userId) {
List<TaskFindResponse> responses = taskMapper.findPending(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);
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(((double)reviewDetailsMapper.count(response.getSystemReviewTaskId(),SystemReviewTask.TYPE))* 100 * 0.9);
response.setSystemReview(num.setScale(1,BigDecimal.ROUND_UP).doubleValue());
BigDecimal num = new BigDecimal(response.getSchedule());
response.setSchedule(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);
for (ResultCountResponse responseList : responseLists) {
for (TaskFindResponse response : responses) {
if (responseList.getTaskId().equals(response.getSystemReviewTaskId())) {
response.setSystemReview(responseList.getSchedule());
}
}
}
}
}
// 车型问卷子任务列表
List<CarReviewTask> carReviewTaskList = carReviewTaskMapper.findByTaskList(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(((double) reviewDetailsMapper.count(response.getCarReviewTaskId(), CarReviewTask.TYPE)) * 100 * 0.9);
response.setCarReview(num.setScale(1, BigDecimal.ROUND_UP).doubleValue());
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());
}
}
}
}
}
for (TaskFindResponse response : responses) {
String[] taskList = response.getTaskList().split(",");
if (response.getPointer() < taskList.length) {
response.setNextSubTask(taskList[response.getPointer()]);
......@@ -210,6 +251,9 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
response.setNextSubTask(taskList[taskList.length - 1]);
}
}
}
return responses;
}
......
......@@ -56,4 +56,12 @@
LEFT JOIN t_review_details_result trdr ON tr.id = trdr.task_id
WHERE trdr.review_details_id = #{detailId} and tr.task_status = 'PENDING'
</select>
<select id="findByTaskList" resultType="com.ruoyi.domain.CarReviewTask">
SELECT id,task_no,task_status,task_initiator,task_initiator_dept,task_result,task_begin_time,task_end_time,standard,create_time,leader_id,leader,standard_id,name,standard_no,file,submit_id,submit_name,images_url,details,standards
FROM t_car_review_task
WHERE id IN
<foreach collection="responses" item="task" open="(" separator="," close=")">
#{task.carReviewTaskId}
</foreach>
</select>
</mapper>
......@@ -30,6 +30,46 @@
INNER JOIN t_review_standard trs ON trs.id = trk.review_standard_id
WHERE trs.type = #{type}), 1) AS resultOverSum
</select>
<select id="systemAnswerCount" resultType="com.ruoyi.web.response.ResultCountResponse">
<foreach item="task" collection="systemReviewTaskList" separator="UNION ALL">
SELECT
#{task.id} AS taskId,
(IFNULL(
(SELECT COUNT(*) FROM t_review_details_result WHERE task_id = #{task.id}),
0
) /
IFNULL(
(SELECT COUNT(*) FROM t_review_details trd
INNER JOIN t_review_keypoint trk ON trk.id = trd.review_keypoint_id
INNER JOIN t_review_standard trs ON trs.id = trk.review_standard_id
WHERE trs.type = #{type}),
1
)) * 90 AS schedule,
ts.task_status AS taskStatus
from t_system_review_task ts where ts.id = #{task.id}
</foreach>
group by taskId
</select>
<select id="carAnswerCount" resultType="com.ruoyi.web.response.ResultCountResponse">
<foreach item="task" collection="carReviewTaskList" separator="UNION ALL">
SELECT
#{task.id} AS taskId,
(IFNULL(
(SELECT COUNT(*) FROM t_review_details_result WHERE task_id = #{task.id}),
0
) /
IFNULL(
(SELECT COUNT(*) FROM t_review_details trd
INNER JOIN t_review_keypoint trk ON trk.id = trd.review_keypoint_id
INNER JOIN t_review_standard trs ON trs.id = trk.review_standard_id
WHERE trs.type = #{type}),
1
)) * 90 AS schedule,
tc.task_status AS taskStatus
from t_car_review_task tc where tc.id = #{task.id}
</foreach>
group by taskId
</select>
<select id="findByKeyPointId" resultType="com.ruoyi.domain.ReviewDetails">
SELECT id, text, review_keypoint_id FROM t_review_details
WHERE review_keypoint_id = #{keyPointId}
......
......@@ -48,5 +48,13 @@
LEFT JOIN t_review_details_result trdr ON ts.id = trdr.task_id
WHERE trdr.review_details_id = #{detailId} and ts.task_status = 'PENDING'
</select>
<select id="findByTaskList" resultType="com.ruoyi.domain.SystemReviewTask">
SELECT id, task_no, task_status, task_initiator, task_initiator_dept, task_result, task_begin_time, task_end_time, standard, create_time,leader,leader_id, standard_id, name, standard_no, file, submit_by_id, submit_by_name,images_url,details,standards
FROM t_system_review_task
WHERE id IN
<foreach collection="responses" item="task" open="(" separator="," close=")">
#{task.systemReviewTaskId}
</foreach>
</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