浏览代码

fix 云教练整合接口cbsDetail

shangke 4 月之前
父节点
当前提交
784a2deeca

+ 50 - 14
mec-application/src/main/java/com/ym/mec/student/controller/StudentManageController.java

@@ -1,9 +1,8 @@
 package com.ym.mec.student.controller;
 
-import com.google.common.collect.Maps;
+import com.beust.jcommander.internal.Lists;
 import com.google.common.collect.Sets;
 import com.microsvc.toolkit.middleware.oss.wrapper.OssWrapper;
-import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.CloudTeacherOrderDao;
 import com.ym.mec.biz.dal.dto.CashAccountDetail;
@@ -11,7 +10,6 @@ import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.ClientEnum;
 import com.ym.mec.biz.dal.page.SysSuggestionQueryInfo;
 import com.ym.mec.biz.dal.wrapper.ImGroupWrapper;
-import com.ym.mec.biz.dal.wrapper.InstrumentWrapper;
 import com.ym.mec.biz.service.*;
 import com.ym.mec.biz.service.im.ImGroupCoreService;
 import com.ym.mec.common.controller.BaseController;
@@ -28,9 +26,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
 import org.springframework.http.MediaType;
-import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -266,7 +262,8 @@ public class StudentManageController extends BaseController {
             } else  if("122".equals(student.getSubjectIdList())){
                 subjectId = "122,121,113,23";
             }
-            List<Integer> instrumentIdsBySubjectId = instrumentService.getInstrumentIdsBySubjectId(subjectId);
+            List<Integer> instrumentIdsBySubjectId = instrumentService.getInstrumentIdsBySubjectId(subjectId)
+                .stream().map(Instrument::getId).collect(Collectors.toList());
             if (CollectionUtils.isNotEmpty(instrumentIdsBySubjectId)) {
                 // 逗号隔开
                 datas.put("instrumentId", StringUtils.join(instrumentIdsBySubjectId, ","));
@@ -289,15 +286,54 @@ public class StudentManageController extends BaseController {
                 }
             }
 
-            List<Integer> instrumentIdsBySubjectId = instrumentService.getInstrumentIdsBySubjectId(StringUtils.join(extInstrumentIds,","));
-            Map<Integer, InstrumentWrapper.Instrument> mapByIds = instrumentService.getMapByIds(instrumentIdsBySubjectId);
-            Map<Integer,String> extInstrumentNamesMap = new HashMap<>();
-            mapByIds.forEach((k,v)->{
-                if (v !=null) {
-                    extInstrumentNamesMap.put(k, v.getName());
+            // 根据声部查询对应乐器信息
+            List<Instrument> instruments = instrumentService.getInstrumentIdsBySubjectId(StringUtils.join(extInstrumentIds, ","));
+            List<Map<String, Object>> extInstrumentNames = Lists.newArrayList();
+            if (CollectionUtils.isNotEmpty(instruments)) {
+
+                Map<Integer, List<Instrument>> collect = instruments.stream().collect(Collectors.groupingBy(Instrument::getSubjectId, Collectors.toList()));
+                for (Map.Entry<Integer, String> entry : student.getExtSjectNamesMap().entrySet()) {
+
+                    // 默认声部映射乐器ID
+                    String instrumentIds = collect.get(entry.getKey()).stream()
+                        .map(Instrument::getId).map(String::valueOf).collect(Collectors.joining(","));
+
+                    // 萨克斯乐器,对应中音萨克斯
+                    if (entry.getKey() == 5 || entry.getKey() == 6) {
+
+                        instrumentIds = collect.entrySet().stream()
+                            .filter(x -> x.getKey() == 5 || x.getKey() == 6)
+                            .flatMap(x -> x.getValue().stream())
+                            .map(Instrument::getId)
+                            .map(String::valueOf).collect(Collectors.joining(","));
+                    }
+
+                    // 打击乐器,对应小军鼓,打击乐(键盘),打击乐(键盘+小鼓),打击乐
+                    if (entry.getKey() == 122 || entry.getKey() == 121 || entry.getKey() == 113 || entry.getKey() == 23) {
+
+                        instrumentIds = collect.entrySet().stream()
+                            .filter(x -> x.getKey() == 122 || x.getKey() == 121 || x.getKey() == 113 || x.getKey() == 23)
+                            .flatMap(x -> x.getValue().stream())
+                            .map(Instrument::getId)
+                            .map(String::valueOf).collect(Collectors.joining(","));
+                    }
+                    String finalInstrumentIds = instrumentIds;
+                    extInstrumentNames.add(new HashMap<String, Object>(){{
+                        put("subjectId", entry.getKey());
+                        put("subjectName", entry.getValue());
+                        put("instrumentIds", finalInstrumentIds);
+                    }});
                 }
-            });
-            student.setExtInstrumentNamesMap(extInstrumentNamesMap);
+
+                /*List<Integer> instrumentIdsBySubjectId = instruments.stream().map(Instrument::getId).collect(Collectors.toList());
+                Map<Integer, InstrumentWrapper.Instrument> mapByIds = instrumentService.getMapByIds(instrumentIdsBySubjectId);
+                mapByIds.forEach((k,v)->{
+                    if (v !=null) {
+                        extInstrumentNamesMap.put(k, v.getName());
+                    }
+                });*/
+            }
+            student.setExtInstrumentNames(extInstrumentNames);
         }
 
 

+ 11 - 9
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/Student.java

@@ -1,12 +1,13 @@
 package com.ym.mec.biz.dal.entity;
 
-import com.baomidou.mybatisplus.annotation.TableField;
 import com.ym.mec.auth.api.entity.SysUser;
 import io.swagger.annotations.ApiModelProperty;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -79,7 +80,7 @@ public class Student extends SysUser {
 	private String extSubjectIds;
 	
 	private Map<Integer,String> extSjectNamesMap = new HashMap<Integer, String>();
-	private Map<Integer,String> extInstrumentNamesMap = new HashMap<Integer, String>();
+	private List<Map<String, Object>> extInstrumentNames = new ArrayList<>();
 
 	@ApiModelProperty(value = "家长姓名")
 	private String parentName;
@@ -93,15 +94,16 @@ public class Student extends SysUser {
     @ApiModelProperty("IM绑定设备")
     private String imDeviceId;
 
-    public Map<Integer, String> getExtInstrumentNamesMap() {
-        return extInstrumentNamesMap;
-    }
+	public List<Map<String, Object>> getExtInstrumentNames() {
+		return extInstrumentNames;
+	}
 
-    public void setExtInstrumentNamesMap(Map<Integer, String> extInstrumentNamesMap) {
-        this.extInstrumentNamesMap = extInstrumentNamesMap;
-    }
+	public Student setExtInstrumentNames(List<Map<String, Object>> extInstrumentNames) {
+		this.extInstrumentNames = extInstrumentNames;
+		return this;
+	}
 
-    public String getImDeviceId() {
+	public String getImDeviceId() {
         return imDeviceId;
     }
 

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/InstrumentService.java

@@ -53,7 +53,7 @@ public interface InstrumentService extends IService<Instrument>  {
 
     List<InstrumentWrapper.Instrument> getList(InstrumentWrapper.InstrumentQuery query);
 
-    List<Integer> getInstrumentIdsBySubjectId(String subjectId);
+    List<Instrument> getInstrumentIdsBySubjectId(String subjectId);
 
     void modify(InstrumentWrapper.Update update);
 }

+ 2 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/InstrumentServiceImpl.java

@@ -193,12 +193,12 @@ public class InstrumentServiceImpl extends ServiceImpl<InstrumentDao, Instrument
     }
 
     @Override
-    public List<Integer> getInstrumentIdsBySubjectId(String subjectId) {
+    public List<Instrument> getInstrumentIdsBySubjectId(String subjectId) {
         List<Instrument> list = instrumentDao.getBySubjectId(subjectId);
         if (CollectionUtils.isEmpty(list)) {
             return new ArrayList<>();
         }
-        return list.stream().map(Instrument::getId).collect(Collectors.toList());
+        return list;
     }
 
     @Override