|
@@ -248,23 +248,35 @@ public class SubjectServiceImpl extends BaseServiceImpl<Integer, Subject> implem
|
|
|
dataList = subjectDao.queryPageByIdOrName(params);
|
|
|
List<Integer> subjectIds = dataList.stream().map(Subject::getId).collect(Collectors.toList());
|
|
|
List<Instrument> list = instrumentService.lambdaQuery().in(Instrument::getSubjectId, subjectIds).list();
|
|
|
+ Map<Integer, List<Instrument>> groupBySubjectId = list.stream().collect(Collectors.groupingBy(Instrument::getSubjectId));
|
|
|
List<Integer> instrumentIds = list.stream().map(Instrument::getId).collect(Collectors.toList());
|
|
|
CbsMusicalInstrumentWrapper.MusicalInstrumentQuery query = new CbsMusicalInstrumentWrapper.MusicalInstrumentQuery();
|
|
|
query.setIds(instrumentIds);
|
|
|
query.setPage(1);
|
|
|
query.setRows(instrumentIds.size());
|
|
|
- R<com.microsvc.toolkit.common.response.paging.PageInfo<CbsMusicalInstrumentWrapper.MusicalInstrumentQueryDto>> infoR = musicFeignClientService.musicalInstrumentPage(query);
|
|
|
+ R<com.microsvc.toolkit.common.response.paging.PageInfo<CbsMusicalInstrumentWrapper.MusicalInstrumentQueryDto>> infoR =
|
|
|
+ musicFeignClientService.musicalInstrumentPage(query);
|
|
|
if (infoR.getCode() != 200){
|
|
|
throw new BizException("调用内容平台失败 : {}",infoR.getMessage());
|
|
|
}
|
|
|
List<CbsMusicalInstrumentWrapper.MusicalInstrumentQueryDto> rows = infoR.getData().getRows();
|
|
|
Map<Integer,CbsMusicalInstrumentWrapper.MusicalInstrumentQueryDto> map = rows.stream()
|
|
|
- .collect(Collectors.toMap(CbsMusicalInstrumentWrapper.MusicalInstrumentQueryDto::getSubjectId, Function.identity()));
|
|
|
+ .collect(Collectors.toMap(CbsMusicalInstrumentWrapper.MusicalInstrumentQueryDto::getId, Function.identity()));
|
|
|
for (Subject subject : dataList) {
|
|
|
- CbsMusicalInstrumentWrapper.MusicalInstrumentQueryDto dto = map.get(subject.getCbsSubjectId());
|
|
|
- if (dto != null) {
|
|
|
- subject.setInstrumentName(dto.getName());
|
|
|
- subject.setInstrumentIds(dto.getId().toString());
|
|
|
+ List<Instrument> instruments = groupBySubjectId.get(subject.getId());
|
|
|
+ if(!CollectionUtils.isEmpty(instruments)){
|
|
|
+ subject.setInstrumentIds(instruments.stream().map(Instrument::getId).map(String::valueOf).collect(Collectors.joining(",")));
|
|
|
+ StringBuffer sb = new StringBuffer();
|
|
|
+ for (Instrument instrument : instruments) {
|
|
|
+ CbsMusicalInstrumentWrapper.MusicalInstrumentQueryDto dto = map.get(instrument.getId());
|
|
|
+ if (dto != null) {
|
|
|
+ if(sb.length() > 0){
|
|
|
+ sb.append(",");
|
|
|
+ }
|
|
|
+ sb.append(dto.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subject.setInstrumentName(sb.toString());
|
|
|
}
|
|
|
}
|
|
|
}
|