|
@@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
@@ -55,15 +56,20 @@ public class PipelineServiceImpl implements PipelineService {
|
|
|
// 获取流水线历史
|
|
// 获取流水线历史
|
|
|
List<PipelineRecordPO> records = pipelineRecordMapper.selectPipelinesLatestRecords(pipelineIds);
|
|
List<PipelineRecordPO> records = pipelineRecordMapper.selectPipelinesLatestRecords(pipelineIds);
|
|
|
Map<Integer, PipelineRecordPO> recordMap = records.stream().collect(Collectors.toMap(PipelineRecordPO::getPipelineId, x->x));
|
|
Map<Integer, PipelineRecordPO> recordMap = records.stream().collect(Collectors.toMap(PipelineRecordPO::getPipelineId, x->x));
|
|
|
|
|
+ List<Integer> userIds = new ArrayList<>();
|
|
|
|
|
+ Map<Integer, String> usernameMap = new HashMap<>();
|
|
|
|
|
+ if (records.size() != 0){
|
|
|
|
|
+ userIds = records.stream().map(PipelineRecordPO::getUserId).collect(Collectors.toList());
|
|
|
|
|
+ usernameMap = userMapper.selectByIds(userIds).stream().collect(Collectors.toMap(UserPO::getId, UserPO::getUsername));
|
|
|
|
|
+ }
|
|
|
// 获取流水线历史中具体执行人信息
|
|
// 获取流水线历史中具体执行人信息
|
|
|
- List<Integer> userIds = records.stream().map(PipelineRecordPO::getUserId).collect(Collectors.toList());
|
|
|
|
|
- Map<Integer, String> usernameMap = userMapper.selectByIds(userIds).stream().collect(Collectors.toMap(UserPO::getId, UserPO::getUsername));
|
|
|
|
|
|
|
+ Map<Integer, String> finalUsernameMap = usernameMap;
|
|
|
return pipelinePOS.stream().map(x->{
|
|
return pipelinePOS.stream().map(x->{
|
|
|
PipelineRecordPO pipelineRecordPO = recordMap.getOrDefault(x.getId(),null);
|
|
PipelineRecordPO pipelineRecordPO = recordMap.getOrDefault(x.getId(),null);
|
|
|
if (pipelineRecordPO == null){
|
|
if (pipelineRecordPO == null){
|
|
|
return new PipelineInfoVO(x,null,null);
|
|
return new PipelineInfoVO(x,null,null);
|
|
|
}
|
|
}
|
|
|
- String username = usernameMap.get(pipelineRecordPO.getUserId());
|
|
|
|
|
|
|
+ String username = finalUsernameMap.get(pipelineRecordPO.getUserId());
|
|
|
return new PipelineInfoVO(x,pipelineRecordPO,username);
|
|
return new PipelineInfoVO(x,pipelineRecordPO,username);
|
|
|
}).collect(Collectors.toList());
|
|
}).collect(Collectors.toList());
|
|
|
}
|
|
}
|