Ver código fonte

Merge branch 'music_score'

Joburgess 4 anos atrás
pai
commit
b67cbb0373

+ 9 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SysMusicCompareRecordDao.java

@@ -23,6 +23,15 @@ public interface SysMusicCompareRecordDao extends BaseDAO<Long, SysMusicCompareR
                                                   @Param("endTime") String endTime);
 
     /**
+     * @describe 获取用户最后一次评测数据
+     * @author Joburgess
+     * @date 2021/8/23 0023
+     * @param userId:
+     * @return com.ym.mec.biz.dal.entity.SysMusicCompareRecord
+     */
+    SysMusicCompareRecord getUserLastEvaluationData(@Param("userId") Integer userId);
+
+    /**
      * @describe 获取用户训练总览
      * @author Joburgess
      * @date 2021/8/11 0011

+ 41 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/MusicalNotesPlayStatDto.java

@@ -0,0 +1,41 @@
+package com.ym.mec.biz.dal.dto;
+
+import com.ym.mec.biz.dal.enums.MusicalErrorTypeEnum;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @Author Joburgess
+ * @Date 2021/8/23 0023
+ */
+public class MusicalNotesPlayStatDto {
+
+    @ApiModelProperty("音符数")
+    private int musicalNotesIndex;
+
+    @ApiModelProperty("错误类型")
+    private MusicalErrorTypeEnum musicalErrorType;
+
+    public MusicalNotesPlayStatDto() {
+    }
+
+    public MusicalNotesPlayStatDto(int musicalNotesIndex, MusicalErrorTypeEnum musicalErrorType) {
+        this.musicalNotesIndex = musicalNotesIndex;
+        this.musicalErrorType = musicalErrorType;
+    }
+
+    public int getMusicalNotesIndex() {
+        return musicalNotesIndex;
+    }
+
+    public void setMusicalNotesIndex(int musicalNotesIndex) {
+        this.musicalNotesIndex = musicalNotesIndex;
+    }
+
+    public MusicalErrorTypeEnum getMusicalErrorType() {
+        return musicalErrorType;
+    }
+
+    public void setMusicalErrorType(MusicalErrorTypeEnum musicalErrorType) {
+        this.musicalErrorType = musicalErrorType;
+    }
+}

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/SoundCompareHelper.java

@@ -63,6 +63,9 @@ public class SoundCompareHelper implements PitchDetectionHandler {
     @ApiModelProperty(value = "音符频率字典")
     private Map<Integer, Float> musicalNotePitchMap = new HashMap<>();
 
+    @ApiModelProperty(value = "每个音符评测结果")
+    private List<MusicalNotesPlayStatDto> musicalNotesPlayStats = new ArrayList<>();
+
     @ApiModelProperty(value = "偏移时间量,解决客户端录音播放不同步导致的声音留白")
     private int offsetTime = -1;
 
@@ -186,6 +189,14 @@ public class SoundCompareHelper implements PitchDetectionHandler {
         this.measureEndTime = measureEndTime;
     }
 
+    public List<MusicalNotesPlayStatDto> getMusicalNotesPlayStats() {
+        return musicalNotesPlayStats;
+    }
+
+    public void setMusicalNotesPlayStats(List<MusicalNotesPlayStatDto> musicalNotesPlayStats) {
+        this.musicalNotesPlayStats = musicalNotesPlayStats;
+    }
+
     public List<MusicPitchDetailDto> getRecordMeasurePithInfo() {
         return recordMeasurePithInfo;
     }

+ 67 - 10
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/WebSocketInfo.java

@@ -1,32 +1,89 @@
 package com.ym.mec.biz.dal.dto;
 
-import com.alibaba.fastjson.JSONObject;
-
-import java.util.HashMap;
+import com.ym.mec.biz.dal.enums.WebsocketTypeEnum;
+import org.springframework.http.HttpStatus;
 
 /**
  * @Author Joburgess
  * @Date 2021/6/17 0017
  */
-public class WebSocketInfo {
+public class WebSocketInfo<T> {
+
+    private Head header = new Head();
+
+    private T body;
+
+    public static class Head{
+        private HttpStatus status = HttpStatus.OK;
+        private String commond = "";
+        private WebsocketTypeEnum type;
+
+        public Head() {
+        }
+
+        public Head(HttpStatus status) {
+            this.status = status;
+        }
+
+        public Head(String commond) {
+            this.commond = commond;
+        }
+
+        public Head(String commond, WebsocketTypeEnum type) {
+            this.commond = commond;
+            this.type = type;
+        }
+
+        public HttpStatus getStatus() {
+            return status;
+        }
+
+        public void setStatus(HttpStatus status) {
+            this.status = status;
+        }
+
+        public String getCommond() {
+            return commond;
+        }
 
-    private HashMap<String, String> header = new HashMap<>();
+        public void setCommond(String commond) {
+            this.commond = commond;
+        }
+
+        public WebsocketTypeEnum getType() {
+            return type;
+        }
+
+        public void setType(WebsocketTypeEnum type) {
+            this.type = type;
+        }
+    }
+
+    public WebSocketInfo() {
+    }
+
+    public WebSocketInfo(Head header) {
+        this.header = header;
+    }
+
+    public static WebSocketInfo success(){
+        return new WebSocketInfo(new Head());
+    }
 
-    private Object body;
 
-    public HashMap<String, String> getHeader() {
+    public Head getHeader() {
         return header;
     }
 
-    public void setHeader(HashMap<String, String> header) {
+    public void setHeader(Head header) {
         this.header = header;
     }
 
-    public Object getBody() {
+    public T getBody() {
         return body;
     }
 
-    public void setBody(Object body) {
+    public void setBody(T body) {
         this.body = body;
     }
 }

+ 38 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/MusicalErrorTypeEnum.java

@@ -0,0 +1,38 @@
+package com.ym.mec.biz.dal.enums;
+
+import com.ym.mec.common.enums.BaseEnum;
+
+/**
+ * 员工角色枚举
+ */
+public enum MusicalErrorTypeEnum implements BaseEnum<String, MusicalErrorTypeEnum> {
+	RIGHT("RIGHT", "演奏正确"),
+	WRONG("WRONG", "错音"),
+	NOT_PLAY("NOT_PLAY", "未演奏");
+
+	private String code;
+
+	private String msg;
+
+	MusicalErrorTypeEnum(String code, String msg) {
+		this.code = code;
+		this.msg = msg;
+	}
+
+	public void setCode(String code) {
+		this.code = code;
+	}
+
+	public String getMsg() {
+		return msg;
+	}
+
+	public void setMsg(String msg) {
+		this.msg = msg;
+	}
+
+	@Override
+	public String getCode() {
+		return this.code;
+	}
+}

+ 31 - 6
mec-biz/src/main/java/com/ym/mec/biz/handler/WebSocketHandler.java

@@ -1,20 +1,24 @@
 package com.ym.mec.biz.handler;
 
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.ym.mec.biz.dal.dto.WebSocketClientDetail;
 import com.ym.mec.biz.dal.dto.WebSocketInfo;
 import com.ym.mec.biz.dal.enums.WebsocketTypeEnum;
 import com.ym.mec.biz.service.SoundSocketService;
 import com.ym.mec.biz.service.WebSocketEventHandler;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.ss.formula.functions.T;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
 import org.springframework.web.socket.*;
 import org.springframework.web.socket.handler.AbstractWebSocketHandler;
 
+import java.io.IOException;
 import java.util.Date;
 import java.util.Map;
+import java.util.Objects;
 import java.util.concurrent.ConcurrentHashMap;
 
 /**
@@ -24,7 +28,7 @@ import java.util.concurrent.ConcurrentHashMap;
 @Service
 public class WebSocketHandler extends AbstractWebSocketHandler {
 
-    private final Logger LOGGER = LoggerFactory.getLogger(WebSocketHandler.class);
+    private static final Logger LOGGER = LoggerFactory.getLogger(WebSocketHandler.class);
 
     /**
      * @describe 存储客户端链接
@@ -67,13 +71,13 @@ public class WebSocketHandler extends AbstractWebSocketHandler {
     protected void handleTextMessage(WebSocketSession session, TextMessage message){
         String phone = session.getPrincipal().getName().split(":")[1];
         LOGGER.info("{}: {}", phone, message.getPayload());
-        WebSocketInfo webSocketInfo = JSON.parseObject(message.getPayload(), WebSocketInfo.class);
+        WebSocketInfo<JSONObject> webSocketInfo = JSON.parseObject(message.getPayload(), WebSocketInfo.class);
 
-        WebsocketTypeEnum websocketType = WebsocketTypeEnum.SOUND_COMPARE;
-        if(webSocketInfo.getHeader().containsKey(SoundSocketService.TAG)){
-            websocketType = WebsocketTypeEnum.valueOf(webSocketInfo.getHeader().get(SoundSocketService.TAG));
+        if(Objects.isNull(webSocketInfo.getHeader().getType())){
+            webSocketInfo.getHeader().setType(WebsocketTypeEnum.SOUND_COMPARE);
         }
-        appMap.get(websocketType).receiveTextMessage(session, phone, message);
+
+        appMap.get(webSocketInfo.getHeader().getType()).receiveTextMessage(session, phone, webSocketInfo);
     }
 
     @Override
@@ -114,4 +118,25 @@ public class WebSocketHandler extends AbstractWebSocketHandler {
     public boolean supportsPartialMessages() {
         return super.supportsPartialMessages();
     }
+
+    /**
+     * @describe 发送文本消息
+     * @author Joburgess
+     * @date 2021/8/23 0023
+     * @param phone: 接收人手机号
+     * @param message:
+     * @return boolean
+     */
+    public static <T> boolean sendTextMessage(String phone, T message){
+        if(!WS_CLIENTS.containsKey(phone)||!WS_CLIENTS.get(phone).getSession().isOpen()){
+            return false;
+        }
+        try {
+            WS_CLIENTS.get(phone).getSession().sendMessage(new TextMessage(JSON.toJSONString(message)));
+        } catch (IOException e) {
+            LOGGER.error("消息发送失败:{}", e);
+            return false;
+        }
+        return true;
+    }
 }

+ 11 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/SysMusicCompareRecordService.java

@@ -1,14 +1,12 @@
 package com.ym.mec.biz.service;
 
-import com.ym.mec.biz.dal.dto.CountStudentTrainDataDto;
-import com.ym.mec.biz.dal.dto.MusicCompareRankingDto;
-import com.ym.mec.biz.dal.dto.SoundCompareHelper;
-import com.ym.mec.biz.dal.dto.StatDto;
+import com.ym.mec.biz.dal.dto.*;
 import com.ym.mec.biz.dal.entity.SysMusicCompareRecord;
 import com.ym.mec.biz.dal.page.SysMusicCompareRecordQueryInfo;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.BaseService;
 
+import java.util.List;
 import java.util.Map;
 
 public interface SysMusicCompareRecordService extends BaseService<Long, SysMusicCompareRecord> {
@@ -24,6 +22,15 @@ public interface SysMusicCompareRecordService extends BaseService<Long, SysMusic
     void saveMusicCompareData(String phone, SoundCompareHelper soundCompareInfo);
 
     /**
+     * @describe 用户最后一次评测数据
+     * @author Joburgess
+     * @date 2021/8/23 0023
+     * @param userId:
+     * @return java.util.List<com.ym.mec.biz.dal.dto.MusicalNotesPlayStatDto>
+     */
+    List<MusicalNotesPlayStatDto> getLastEvaluationMusicalNotesPlayStats(Integer userId);
+
+    /**
      * @describe 云教练排行榜
      * @author Joburgess
      * @date 2021/8/11 0011

+ 2 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/WebSocketEventHandler.java

@@ -1,5 +1,6 @@
 package com.ym.mec.biz.service;
 
+import com.ym.mec.biz.dal.dto.WebSocketInfo;
 import org.springframework.web.socket.BinaryMessage;
 import org.springframework.web.socket.TextMessage;
 import org.springframework.web.socket.WebSocketSession;
@@ -10,8 +11,6 @@ import org.springframework.web.socket.WebSocketSession;
  **/
 public interface WebSocketEventHandler {
 
-
-
     /**
      * @describe 连接成功
      * @author Joburgess
@@ -29,7 +28,7 @@ public interface WebSocketEventHandler {
      * @param message: 文本信息
      * @return void
      */
-    void receiveTextMessage(WebSocketSession session, String phone, TextMessage message);
+    void receiveTextMessage(WebSocketSession session, String phone, WebSocketInfo message);
 
     /**
      * @describe 接收到二进制数据

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

@@ -50,7 +50,7 @@ public class SoundCheckHandler implements WebSocketEventHandler {
     }
 
     @Override
-    public void receiveTextMessage(WebSocketSession session, String phone, TextMessage message) {
+    public void receiveTextMessage(WebSocketSession session, String phone, WebSocketInfo message) {
         userSoundCheckInfo.put(phone, 0);
     }
 
@@ -68,6 +68,7 @@ public class SoundCheckHandler implements WebSocketEventHandler {
         } catch (UnsupportedAudioFileException e) {
             throw new BizException("{}校音异常:{}", phone, e);
         }
+        WebSocketHandler.sendTextMessage(phone, WebSocketInfo.success());
     }
 
     @Override

+ 20 - 22
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SoundCompareHandler.java

@@ -8,11 +8,9 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.ym.mec.biz.dal.config.SoundCompareConfig;
 import com.ym.mec.biz.dal.dao.SysMusicScoreAccompanimentDao;
-import com.ym.mec.biz.dal.dto.MusicPitchDetailDto;
-import com.ym.mec.biz.dal.dto.SoundCompareHelper;
-import com.ym.mec.biz.dal.dto.WavHeader;
-import com.ym.mec.biz.dal.dto.WebSocketInfo;
+import com.ym.mec.biz.dal.dto.*;
 import com.ym.mec.biz.dal.enums.DeviceTypeEnum;
+import com.ym.mec.biz.dal.enums.MusicalErrorTypeEnum;
 import com.ym.mec.biz.dal.enums.WebsocketTypeEnum;
 import com.ym.mec.biz.handler.WebSocketHandler;
 import com.ym.mec.biz.service.SoundSocketService;
@@ -23,7 +21,6 @@ import com.ym.mec.common.exception.BizException;
 import com.ym.mec.thirdparty.storage.StoragePluginContext;
 import com.ym.mec.thirdparty.storage.provider.KS3StoragePlugin;
 import com.ym.mec.util.upload.UploadUtil;
-import org.apache.commons.io.FileUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -31,7 +28,6 @@ import org.springframework.security.oauth2.provider.OAuth2Authentication;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 import org.springframework.web.socket.BinaryMessage;
-import org.springframework.web.socket.TextMessage;
 import org.springframework.web.socket.WebSocketSession;
 
 import javax.sound.sampled.UnsupportedAudioFileException;
@@ -88,15 +84,10 @@ public class SoundCompareHandler implements WebSocketEventHandler {
     }
 
     @Override
-    public void receiveTextMessage(WebSocketSession session, String phone, TextMessage message) {
-        WebSocketInfo webSocketInfo = JSON.parseObject(message.getPayload(), WebSocketInfo.class);
-        JSONObject bodyObject = (JSONObject) webSocketInfo.getBody();
+    public void receiveTextMessage(WebSocketSession session, String phone, WebSocketInfo message) {
+        JSONObject bodyObject = (JSONObject) message.getBody();
 
-        String commond = "";
-        if(webSocketInfo.getHeader().containsKey(SoundSocketService.COMMOND)){
-            commond = webSocketInfo.getHeader().get(SoundSocketService.COMMOND);
-        }
-        switch (commond){
+        switch (message.getHeader().getCommond()){
             case SoundSocketService.MUSIC_XML:
                 userSoundInfoMap.put(phone, new SoundCompareHelper());
                 userSoundInfoMap.get(phone).setClientId(((OAuth2Authentication)session.getPrincipal()).getOAuth2Request().getClientId());
@@ -397,6 +388,9 @@ public class SoundCompareHandler implements WebSocketEventHandler {
                     userSoundInfoMap.get(phone).getMusicalNotePitchMap().put(musicXmlInfo.getMusicalNotesIndex(), (float) pitch);
                 }
 
+                boolean cadenceRight = false;
+                boolean intonationRight = false;
+
                 //有效节奏占比
                 float cadenceDuty = cadenceValidNum/compareNum;
                 //如果频率出现断层或这个音量出现断层,则当前音符节奏无效
@@ -406,6 +400,7 @@ public class SoundCompareHandler implements WebSocketEventHandler {
                 //节奏
                 if(cadenceDuty>=soundCompareConfig.cadenceValidDuty){
                     cadenceNum++;
+                    cadenceRight = true;
                 }
                 //音准
                 if (!CollectionUtils.isEmpty(measureSoundPitchInfos)){
@@ -427,6 +422,7 @@ public class SoundCompareHandler implements WebSocketEventHandler {
                     }
                     intonationScore += score;
                     musicXmlInfo.setAvgFrequency(avgPitch.floatValue());
+                    intonationRight = score>70;
                 }
                 //完成度
                 if(integrityValidNum > compareNum){
@@ -434,6 +430,14 @@ public class SoundCompareHandler implements WebSocketEventHandler {
                 }
                 float integrityDuty = integrityValidNum/compareNum;
                 integrityScore += integrityDuty;
+
+                if(cadenceRight&&intonationRight){
+                    userSoundInfoMap.get(phone).getMusicalNotesPlayStats().add(new MusicalNotesPlayStatDto(musicXmlInfo.getMusicalNotesIndex(), MusicalErrorTypeEnum.RIGHT));
+                }else if(cadenceRight&&!intonationRight){
+                    userSoundInfoMap.get(phone).getMusicalNotesPlayStats().add(new MusicalNotesPlayStatDto(musicXmlInfo.getMusicalNotesIndex(), MusicalErrorTypeEnum.WRONG));
+                }else{
+                    userSoundInfoMap.get(phone).getMusicalNotesPlayStats().add(new MusicalNotesPlayStatDto(musicXmlInfo.getMusicalNotesIndex(), MusicalErrorTypeEnum.NOT_PLAY));
+                }
             }
 
             BigDecimal measureNum = new BigDecimal(totalCompareNum);
@@ -508,9 +512,7 @@ public class SoundCompareHandler implements WebSocketEventHandler {
     private WebSocketInfo createPushInfo(String phone, String command, Integer measureIndex,
                                          BigDecimal intonation, BigDecimal cadence, BigDecimal integrity){
         WebSocketInfo webSocketInfo = new WebSocketInfo();
-        HashMap<String, String> header = new HashMap<>();
-        header.put("commond", command);
-        webSocketInfo.setHeader(header);
+        webSocketInfo.setHeader(new WebSocketInfo.Head(command));
         Map<String, Object> result = new HashMap<>(5);
         BigDecimal score = cadence;
         if(Objects.isNull(userSoundInfoMap.get(phone).getSubjectId())||userSoundInfoMap.get(phone).getSubjectId()!=23){
@@ -528,11 +530,7 @@ public class SoundCompareHandler implements WebSocketEventHandler {
         LOGGER.info("小节频分:{}", JSON.toJSONString(webSocketInfo));
 
         //推送结果
-        try {
-            WebSocketHandler.WS_CLIENTS.get(phone).getSession().sendMessage(new TextMessage(JSON.toJSONString(webSocketInfo)));
-        } catch (IOException e) {
-            LOGGER.error("{}评分结果推送失败", phone);
-        }
+        WebSocketHandler.sendTextMessage(phone, webSocketInfo);
         return webSocketInfo;
     }
 }

+ 19 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysMusicCompareRecordServiceImpl.java

@@ -1,6 +1,7 @@
 package com.ym.mec.biz.service.impl;
 
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.StudentDao;
 import com.ym.mec.biz.dal.dao.SysMusicCompareRecordDao;
@@ -15,6 +16,7 @@ import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.util.collection.MapUtil;
 import com.ym.mec.util.date.DateUtil;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
@@ -56,7 +58,10 @@ public class SysMusicCompareRecordServiceImpl extends BaseServiceImpl<Long, SysM
 		sysMusicCompareRecord.setUserId(user.getId());
 		sysMusicCompareRecord.setSysMusicScoreId(soundCompareInfo.getMusicScoreId());
 		sysMusicCompareRecord.setBehaviorId(soundCompareInfo.getBehaviorId());
-		sysMusicCompareRecord.setScoreData(JSON.toJSONString(soundCompareInfo.getUserMeasureScoreMap()));
+		Map<String, Object> scoreData = new HashMap<>();
+		scoreData.put("userMeasureScore", soundCompareInfo.getUserMeasureScoreMap());
+		scoreData.put("musicalNotesPlayStats", soundCompareInfo.getMusicalNotesPlayStats());
+		sysMusicCompareRecord.setScoreData(JSON.toJSONString(scoreData));
 		if (Objects.nonNull(soundCompareInfo.getUserMeasureScoreMap()) && soundCompareInfo.getUserMeasureScoreMap().containsKey(-1)){
 			Map<String, Object> finalScore = soundCompareInfo.getUserMeasureScoreMap().get(-1);
 			sysMusicCompareRecord.setScore((BigDecimal) finalScore.get("score"));
@@ -76,6 +81,19 @@ public class SysMusicCompareRecordServiceImpl extends BaseServiceImpl<Long, SysM
 	}
 
 	@Override
+	public List<MusicalNotesPlayStatDto> getLastEvaluationMusicalNotesPlayStats(Integer userId) {
+		SysMusicCompareRecord userLastEvaluationData = sysMusicCompareRecordDao.getUserLastEvaluationData(userId);
+		if(StringUtils.isBlank(userLastEvaluationData.getScoreData())){
+			return Collections.emptyList();
+		}
+		JSONObject jsonObject = JSON.parseObject(userLastEvaluationData.getScoreData());
+		if(!jsonObject.containsKey("musicalNotesPlayStats")){
+			return Collections.emptyList();
+		}
+		return jsonObject.getObject("musicalNotesPlayStats", List.class);
+	}
+
+	@Override
 	public StatDto rankingList(Integer headUserId,int type, String startDate, String endDate) {
 		StatDto result = new StatDto();
 		MusicCompareRankingDto head = new MusicCompareRankingDto();

+ 4 - 0
mec-biz/src/main/resources/config/mybatis/SysMusicCompareRecordMapper.xml

@@ -372,4 +372,8 @@
 							   DATE( smcr.create_time_ ))= CURDATE()) t
 		GROUP BY t.organ_id_
 	</select>
+
+    <select id="getUserLastEvaluationData" resultMap="SysMusicCompareRecord">
+		SELECT * FROM sys_music_compare_record WHERE user_id_=#{userId} ORDER BY create_time_ DESC LIMIT 1
+	</select>
 </mapper>

+ 13 - 0
mec-student/src/main/java/com/ym/mec/student/controller/SysMusicCompareRecordController.java

@@ -2,6 +2,7 @@ package com.ym.mec.student.controller;
 
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.dto.MusicalNotesPlayStatDto;
 import com.ym.mec.biz.dal.entity.SysMusicCompareRecord;
 import com.ym.mec.biz.service.SysMusicCompareRecordService;
 import com.ym.mec.common.controller.BaseController;
@@ -10,10 +11,12 @@ import com.ym.mec.common.exception.BizException;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.List;
 import java.util.Objects;
 
 /**
@@ -45,4 +48,14 @@ public class SysMusicCompareRecordController extends BaseController {
         return succeed(sysMusicCompareRecordService.insert(record));
     }
 
+    @ApiOperation(value = "用户最后一次评测数据")
+    @GetMapping("getLastEvaluationMusicalNotesPlayStats")
+    public HttpResponseResult<List<MusicalNotesPlayStatDto>> getLastEvaluationMusicalNotesPlayStats(){
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if(sysUser == null){
+            throw new BizException("请登录");
+        }
+        return succeed(sysMusicCompareRecordService.getLastEvaluationMusicalNotesPlayStats(sysUser.getId()));
+    }
+
 }

+ 13 - 0
mec-teacher/src/main/java/com/ym/mec/teacher/controller/SysMusicCompareRecordController.java

@@ -2,6 +2,7 @@ package com.ym.mec.teacher.controller;
 
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.dto.MusicalNotesPlayStatDto;
 import com.ym.mec.biz.dal.entity.SysMusicCompareRecord;
 import com.ym.mec.biz.service.SysMusicCompareRecordService;
 import com.ym.mec.common.controller.BaseController;
@@ -10,10 +11,12 @@ import com.ym.mec.common.exception.BizException;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.List;
 import java.util.Objects;
 
 /**
@@ -45,4 +48,14 @@ public class SysMusicCompareRecordController extends BaseController {
         return succeed(sysMusicCompareRecordService.insert(record));
     }
 
+    @ApiOperation(value = "用户最后一次评测数据")
+    @GetMapping("getLastEvaluationMusicalNotesPlayStats")
+    public HttpResponseResult<List<MusicalNotesPlayStatDto>> getLastEvaluationMusicalNotesPlayStats(){
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if(sysUser == null){
+            throw new BizException("请登录");
+        }
+        return succeed(sysMusicCompareRecordService.getLastEvaluationMusicalNotesPlayStats(sysUser.getId()));
+    }
+
 }

+ 13 - 0
mec-web/src/main/java/com/ym/mec/web/controller/education/SysMusicCompareRecordController.java

@@ -2,6 +2,7 @@ package com.ym.mec.web.controller.education;
 
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.dto.MusicalNotesPlayStatDto;
 import com.ym.mec.biz.dal.entity.SysMusicCompareRecord;
 import com.ym.mec.biz.service.SysMusicCompareRecordService;
 import com.ym.mec.common.controller.BaseController;
@@ -10,10 +11,12 @@ import com.ym.mec.common.exception.BizException;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.List;
 import java.util.Objects;
 
 /**
@@ -45,4 +48,14 @@ public class SysMusicCompareRecordController extends BaseController {
         return succeed(sysMusicCompareRecordService.insert(record));
     }
 
+    @ApiOperation(value = "用户最后一次评测数据")
+    @GetMapping("getLastEvaluationMusicalNotesPlayStats")
+    public HttpResponseResult<List<MusicalNotesPlayStatDto>> getLastEvaluationMusicalNotesPlayStats(){
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if(sysUser == null){
+            throw new BizException("请登录");
+        }
+        return succeed(sysMusicCompareRecordService.getLastEvaluationMusicalNotesPlayStats(sysUser.getId()));
+    }
+
 }