Commit fd217a6c authored by W_Y's avatar W_Y

查看车辆审查任务

parent 57d07b73
......@@ -3,6 +3,7 @@ package com.ruoyi.service;
import com.ruoyi.domain.CarReviewTask;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.web.request.*;
import com.ruoyi.web.response.CarReviewTaskViewResponse;
import com.ruoyi.web.response.SystemReviewTaskViewResponse;
import java.util.List;
......@@ -32,7 +33,7 @@ public interface CarReviewTaskService extends IService<CarReviewTask> {
* @param taskId
* @return
*/
SystemReviewTaskViewResponse viewReviewTask(Long taskId);
CarReviewTaskViewResponse viewReviewTask(Long taskId);
/**
......
package com.ruoyi.service;
import com.ruoyi.domain.CarReviewTask;
import com.ruoyi.web.response.CarReviewTaskViewResponse;
public interface StrategyCarReviewTask {
CarReviewTaskViewResponse doView(CarReviewTask carReviewTask);
}
......@@ -17,6 +17,7 @@ import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.web.request.CarReviewTaskCreateRequest;
import com.ruoyi.web.request.CarReviewTaskStartRequest;
import com.ruoyi.web.request.CarReviewTaskSubmitRequest;
import com.ruoyi.web.response.CarReviewTaskViewResponse;
import com.ruoyi.web.response.SystemReviewTaskViewResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -50,6 +51,9 @@ public class CarReviewTaskServiceImpl extends ServiceImpl<CarReviewTaskMapper, C
@Autowired
private ReviewTaskUserRelationService relationService;
@Autowired
private StrategyCarReviewTaskContext strategyCarReviewTaskContext;
@Override
public List<CarReviewTask> findListByReviewStatus(String reviewStatus) {
return carReviewTaskMapper.findListByReviewStatus(reviewStatus);
......@@ -111,8 +115,9 @@ public class CarReviewTaskServiceImpl extends ServiceImpl<CarReviewTaskMapper, C
}
@Override
public SystemReviewTaskViewResponse viewReviewTask(Long taskId) {
return null;
public CarReviewTaskViewResponse viewReviewTask(Long taskId) {
CarReviewTask carReviewTask = carReviewTaskService.getById(taskId);
return strategyCarReviewTaskContext.getResource(carReviewTask.getTaskStatus()).doView(carReviewTask);
}
@Override
......
package com.ruoyi.service.impl;
import com.ruoyi.service.StrategyCarReviewTask;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@Transactional
@Service
public class StrategyCarReviewTaskContext {
@Autowired
private final Map<String, StrategyCarReviewTask> resourceMap = new ConcurrentHashMap<>();
public StrategyCarReviewTaskContext(Map<String, StrategyCarReviewTask> strategyMap) {
this.resourceMap.clear();
strategyMap.forEach(resourceMap::put);
}
public StrategyCarReviewTask getResource(String operation){
return resourceMap.get(operation);
}
}
package com.ruoyi.service.impl;
import com.ruoyi.domain.*;
import com.ruoyi.mapper.ReviewDetailsResultMapper;
import com.ruoyi.mapper.SystemReviewTaskMapper;
import com.ruoyi.service.ReviewDetailsResultService;
import com.ruoyi.service.ReviewSceneChangeTaskService;
import com.ruoyi.service.ReviewStandardService;
import com.ruoyi.service.StrategyCarReviewTask;
import com.ruoyi.web.response.CarReviewTaskViewResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
@Transactional
@Service(CarReviewTask.TASK_STATUS_PENDING)
public class StrategyCarReviewTaskPending implements StrategyCarReviewTask {
@Autowired
private ReviewStandardService reviewStandardService;
@Autowired
private ReviewDetailsResultService reviewDetailsResultService;
@Autowired
private ReviewSceneChangeTaskService reviewSceneChangeTaskService;
@Autowired
private SystemReviewTaskMapper systemReviewTaskMapper;
@Autowired
private ReviewDetailsResultMapper reviewDetailsResultMapper;
// PENDING状态下
// 1.standard字段查询当前最新问卷
// 2.查询场景变更任务
// 3.需要联查问卷答案
@Override
public CarReviewTaskViewResponse doView(CarReviewTask carReviewTask) {
// 获取最新问卷
List<ReviewStandard> standardTree = reviewStandardService.findTree(carReviewTask.getStandardId(), ReviewStandard.TYPE_CAR);
// 获取当前问卷答案
List<ReviewDetailsResult> results = reviewDetailsResultService.findByTaskId(carReviewTask.getId());
// 绑定问卷与答案
setDetailsResult(standardTree, results);
// 赋值给任务
carReviewTask.setStandard(standardTree);
// 查询场景变更任务便于提醒用户场景变动
List<ReviewSceneChangeTask> lastChanges = reviewSceneChangeTaskService.findLastChangeByTaskId(carReviewTask.getId());
// 构建返回结果
CarReviewTaskViewResponse response = new CarReviewTaskViewResponse();
response.setCarReviewTask(carReviewTask);
response.setReviewSceneChangeTasks(lastChanges);
return response;
}
private void setDetailsResult(List<ReviewStandard> standards, List<ReviewDetailsResult> results) {
Map<Long, ReviewDetailsResult> resultMap = results.stream().collect(Collectors.toMap(ReviewDetailsResult::getReviewDetailsId, Function.identity(), (v1, v2) -> v1));
for(ReviewStandard standard : standards) {
List<ReviewKeyPoint> keyPointList = standard.getKeyPointList();
for(ReviewKeyPoint keypoint : keyPointList) {
List<ReviewDetails> reviewDetailsList = keypoint.getReviewDetailsList();
for(ReviewDetails details : reviewDetailsList) {
details.setResult(resultMap.get(details.getId()));
}
}
}
}
}
package com.ruoyi.web.response;
import com.ruoyi.domain.CarReviewTask;
import com.ruoyi.domain.ReviewSceneChangeTask;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@ApiModel(value = "CarReviewTaskViewResponse", description = "查询车辆审查任务详情响应体")
@Data
public class CarReviewTaskViewResponse {
/**
* 任务信息
*/
@ApiModelProperty("任务信息")
private CarReviewTask carReviewTask;
/**
* 任务开始后的场景变更信息
*/
@ApiModelProperty("任务开始后的场景变更信息")
private List<ReviewSceneChangeTask> reviewSceneChangeTasks;
}
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