Prechádzať zdrojové kódy

Merge branch 'zx_saas_cbs' of http://git.dayaedu.com/yonge/mec into dev

zouxuan 1 rok pred
rodič
commit
5b5d857e9f

+ 9 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CbsSubjectServiceImpl.java

@@ -4,6 +4,7 @@ import com.dayaedu.cbs.openfeign.service.CbsSubjectService;
 import com.dayaedu.cbs.openfeign.wrapper.music.CbsSubjectApiWrapper;
 import com.google.common.collect.Lists;
 import com.ym.mec.biz.dal.entity.Subject;
+import com.ym.mec.biz.dal.wrapper.InstrumentWrapper;
 import com.ym.mec.biz.dal.wrapper.SubjectWrapper;
 import com.ym.mec.biz.service.SubjectService;
 import com.ym.mec.common.page.PageInfo;
@@ -15,6 +16,7 @@ import org.springframework.stereotype.Service;
 import javax.annotation.Resource;
 import java.util.List;
 import java.util.Map;
+import java.util.function.Function;
 import java.util.stream.Collectors;
 
 @Service
@@ -43,13 +45,16 @@ public class CbsSubjectServiceImpl implements CbsSubjectService {
             subjectQuery.setSubjectIds(subjectIds.stream().map(String::valueOf).collect(Collectors.joining(",")));
         }
         PageInfo<SubjectWrapper.Subject> subjectPageInfo = subjectService.selectPage(subjectQuery);
-        Map<Long, String> cbsSubjectIdNameMap = subjectPageInfo.getRows().stream().collect(Collectors.toMap(SubjectWrapper.Subject::getCbsSubjectId, SubjectWrapper.Subject::getName));
+        Map<Long, SubjectWrapper.Subject> cbsSubjectIdNameMap = subjectPageInfo.getRows().stream().collect(Collectors.toMap(SubjectWrapper.Subject::getCbsSubjectId, Function.identity()));
 
         List<CbsSubjectApiWrapper.Subject> subjects = subjectService.getDao().queryCbsSubjects(query);
         for (CbsSubjectApiWrapper.Subject subject : subjects) {
-            Long cbsSubjectId = subject.getCbsSubjectId();
-            if (cbsSubjectIdNameMap.containsKey(cbsSubjectId)) {
-                subject.setSubjectName(cbsSubjectIdNameMap.get(cbsSubjectId));
+            SubjectWrapper.Subject cbsSubject = cbsSubjectIdNameMap.get(subject.getCbsSubjectId());
+            if (cbsSubject != null) {
+                List<InstrumentWrapper.Instrument> instruments = cbsSubject.getInstruments();
+                if (CollectionUtils.isNotEmpty(instruments)) {
+                    subject.setSubjectName(instruments.stream().map(e->e.getName()).collect(Collectors.joining(",")));
+                }
             }
         }
         return subjects;