|
@@ -23,7 +23,6 @@ import com.ym.mec.common.exception.BizException;
|
|
import com.ym.mec.thirdparty.storage.StoragePluginContext;
|
|
import com.ym.mec.thirdparty.storage.StoragePluginContext;
|
|
import com.ym.mec.thirdparty.storage.provider.KS3StoragePlugin;
|
|
import com.ym.mec.thirdparty.storage.provider.KS3StoragePlugin;
|
|
import com.ym.mec.util.upload.UploadUtil;
|
|
import com.ym.mec.util.upload.UploadUtil;
|
|
-import org.apache.commons.io.FileUtils;
|
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -31,7 +30,6 @@ import org.springframework.security.oauth2.provider.OAuth2Authentication;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.web.socket.BinaryMessage;
|
|
import org.springframework.web.socket.BinaryMessage;
|
|
-import org.springframework.web.socket.TextMessage;
|
|
|
|
import org.springframework.web.socket.WebSocketSession;
|
|
import org.springframework.web.socket.WebSocketSession;
|
|
|
|
|
|
import javax.sound.sampled.UnsupportedAudioFileException;
|
|
import javax.sound.sampled.UnsupportedAudioFileException;
|
|
@@ -88,15 +86,10 @@ public class SoundCompareHandler implements WebSocketEventHandler {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@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:
|
|
case SoundSocketService.MUSIC_XML:
|
|
userSoundInfoMap.put(phone, new SoundCompareHelper());
|
|
userSoundInfoMap.put(phone, new SoundCompareHelper());
|
|
userSoundInfoMap.get(phone).setClientId(((OAuth2Authentication)session.getPrincipal()).getOAuth2Request().getClientId());
|
|
userSoundInfoMap.get(phone).setClientId(((OAuth2Authentication)session.getPrincipal()).getOAuth2Request().getClientId());
|
|
@@ -508,9 +501,7 @@ public class SoundCompareHandler implements WebSocketEventHandler {
|
|
private WebSocketInfo createPushInfo(String phone, String command, Integer measureIndex,
|
|
private WebSocketInfo createPushInfo(String phone, String command, Integer measureIndex,
|
|
BigDecimal intonation, BigDecimal cadence, BigDecimal integrity){
|
|
BigDecimal intonation, BigDecimal cadence, BigDecimal integrity){
|
|
WebSocketInfo webSocketInfo = new WebSocketInfo();
|
|
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);
|
|
Map<String, Object> result = new HashMap<>(5);
|
|
BigDecimal score = cadence;
|
|
BigDecimal score = cadence;
|
|
if(Objects.isNull(userSoundInfoMap.get(phone).getSubjectId())||userSoundInfoMap.get(phone).getSubjectId()!=23){
|
|
if(Objects.isNull(userSoundInfoMap.get(phone).getSubjectId())||userSoundInfoMap.get(phone).getSubjectId()!=23){
|
|
@@ -528,11 +519,7 @@ public class SoundCompareHandler implements WebSocketEventHandler {
|
|
LOGGER.info("小节频分:{}", JSON.toJSONString(webSocketInfo));
|
|
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;
|
|
return webSocketInfo;
|
|
}
|
|
}
|
|
}
|
|
}
|