Merge remote-tracking branch 'origin/feature-BOX一期' into feature-BOX一期
This commit is contained in:
commit
a05df74aba
4
.gitignore
vendored
4
.gitignore
vendored
@ -34,7 +34,11 @@ build/
|
||||
|
||||
*.log
|
||||
/logs/
|
||||
logs/
|
||||
logs/**
|
||||
/logs/**
|
||||
**/logs/**
|
||||
logs/**/**
|
||||
/logs/**/**
|
||||
**/logs/**/**
|
||||
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
package com.qiuguo.iot.base.date;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public abstract class Date{
|
||||
|
||||
}
|
||||
@ -0,0 +1,211 @@
|
||||
package com.qiuguo.iot.base.date;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public enum DateEnum implements IDate{
|
||||
//现在,今天,明天,后天,昨天,前天,*天后,*天,
|
||||
// 下周*, *周后,*周,
|
||||
// 下个月*, *个月 *月后
|
||||
// 今年,明年,后年,去年,前年,*年 *年后
|
||||
//*分钟
|
||||
//*小时
|
||||
//*秒
|
||||
|
||||
/**
|
||||
* 今天
|
||||
*/
|
||||
TODAY("今天"){
|
||||
@Override
|
||||
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||
return localDateTime;
|
||||
}
|
||||
|
||||
},
|
||||
/**
|
||||
* 今天
|
||||
*/
|
||||
NOW("现在"){
|
||||
@Override
|
||||
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||
return localDateTime;
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 明天
|
||||
*/
|
||||
TOMORROW("明天"){
|
||||
@Override
|
||||
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||
return localDateTime.minusDays(-1);
|
||||
}
|
||||
|
||||
},
|
||||
/**
|
||||
* 明天
|
||||
*/
|
||||
YESTERDAY("昨天"){
|
||||
@Override
|
||||
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||
return localDateTime.minusDays(1);
|
||||
}
|
||||
|
||||
},
|
||||
/**
|
||||
* 明天
|
||||
*/
|
||||
BEFOR_YESTERDAY("前天"){
|
||||
@Override
|
||||
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||
return localDateTime.minusDays(2);
|
||||
}
|
||||
|
||||
},
|
||||
/**
|
||||
* 后天
|
||||
*/
|
||||
AFTER_TOMORROW("后天"){
|
||||
@Override
|
||||
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||
return localDateTime.minusDays(-2);
|
||||
}
|
||||
|
||||
},
|
||||
/**
|
||||
* n天后
|
||||
*/
|
||||
N_AFTER_DAY("天后"){
|
||||
@Override
|
||||
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||
return localDateTime.minusDays(-2);
|
||||
}
|
||||
|
||||
},
|
||||
/**
|
||||
* n天
|
||||
*/
|
||||
N_DAY("天"){
|
||||
@Override
|
||||
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||
return localDateTime.minusDays(-2);
|
||||
}
|
||||
|
||||
},
|
||||
/**
|
||||
* N月后
|
||||
*/
|
||||
N_AFTER_MONTH("月后"){
|
||||
@Override
|
||||
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||
return localDateTime.minusDays(-2);
|
||||
}
|
||||
|
||||
},
|
||||
/**
|
||||
* N月
|
||||
*/
|
||||
N_MONTH("月"){
|
||||
@Override
|
||||
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||
return localDateTime.minusDays(-2);
|
||||
}
|
||||
|
||||
},
|
||||
/**
|
||||
* N年后
|
||||
*/
|
||||
N_AFTER_YEAR("年后"){
|
||||
@Override
|
||||
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||
return localDateTime.minusDays(-2);
|
||||
}
|
||||
|
||||
},
|
||||
/**
|
||||
* N年
|
||||
*/
|
||||
N_YEAR("年"){
|
||||
@Override
|
||||
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||
return localDateTime.minusDays(-2);
|
||||
}
|
||||
|
||||
},
|
||||
/**
|
||||
* N小时后
|
||||
*/
|
||||
N_AFTER_HOUR("小时后"){
|
||||
@Override
|
||||
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||
return localDateTime.minusDays(-2);
|
||||
}
|
||||
|
||||
},
|
||||
/**
|
||||
* N小时
|
||||
*/
|
||||
N_HOUR("小时"){
|
||||
@Override
|
||||
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||
return localDateTime.minusDays(-2);
|
||||
}
|
||||
|
||||
},
|
||||
/**
|
||||
* N分钟后
|
||||
*/
|
||||
N_AFTER_MINUTE("分钟后"){
|
||||
@Override
|
||||
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||
return localDateTime.minusDays(-2);
|
||||
}
|
||||
|
||||
},
|
||||
/**
|
||||
* N分钟
|
||||
*/
|
||||
N_MINUTE("分钟"){
|
||||
@Override
|
||||
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||
return localDateTime.minusDays(-2);
|
||||
}
|
||||
|
||||
},
|
||||
/**
|
||||
* N秒后
|
||||
*/
|
||||
N_AFTER_SECOND("秒后"){
|
||||
@Override
|
||||
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||
return localDateTime.minusDays(-2);
|
||||
}
|
||||
|
||||
},
|
||||
/**
|
||||
* N秒
|
||||
*/
|
||||
N_SECOND("秒"){
|
||||
@Override
|
||||
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||
return localDateTime.minusDays(-2);
|
||||
}
|
||||
|
||||
},
|
||||
;
|
||||
Date date;
|
||||
String code;
|
||||
DateEnum(String c) {
|
||||
code = c;
|
||||
}
|
||||
|
||||
public static DateEnum getWithCode(String c) {
|
||||
for (DateEnum dateEnum:values()
|
||||
) {
|
||||
if(c.equals(dateEnum.code)){
|
||||
return dateEnum;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
package com.qiuguo.iot.base.date;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public interface IDate {
|
||||
public LocalDateTime getDateTime(LocalDateTime localDateTime);
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
package com.qiuguo.iot.base.date;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class Tomorrow extends Date{
|
||||
|
||||
}
|
||||
@ -73,4 +73,8 @@ public class SystemTalkAnswerConfigEntity extends GenericEntity<Long> {
|
||||
@Column(name = "answer_type", nullable = false)
|
||||
private Integer answerType;
|
||||
|
||||
@Comment("音频时播放状态:0 开始播放 1 暂停 2 继续 3 停止 10无此资源")
|
||||
@Column(name = "play_type", nullable = false)
|
||||
private Integer playType;
|
||||
|
||||
}
|
||||
@ -56,4 +56,10 @@ public class SystemTalkAnswerConfigRequest implements java.io.Serializable {
|
||||
|
||||
//"回答类型0:文本问答 1:iOT控制 2:天气 3:闹钟 4:U3D 5:音乐声音 100:固件升级"
|
||||
private Integer answerType;
|
||||
|
||||
/**
|
||||
* 音频时播放状态:0 开始播放 1 暂停 2 继续 3 停止 10无此资源
|
||||
*/
|
||||
|
||||
private Integer playType;
|
||||
}
|
||||
@ -34,4 +34,10 @@ public class SystemTalkAnswerConfigResp {
|
||||
|
||||
//"回答类型0:文本问答 1:iOT控制 2:天气 3:闹钟 4:U3D 5:音乐声音 100:固件升级"
|
||||
private Integer answerType;
|
||||
|
||||
/**
|
||||
* 音频时播放状态:0 开始播放 1 暂停 2 继续 3 停止 10无此资源
|
||||
*/
|
||||
|
||||
private Integer playType;
|
||||
}
|
||||
@ -27,4 +27,13 @@ public class MusicResp {
|
||||
* 歌名
|
||||
*/
|
||||
String name;
|
||||
/**
|
||||
* 进度条 0 - 100
|
||||
*/
|
||||
Integer progress;
|
||||
|
||||
/**
|
||||
* 声音大小 0- 100
|
||||
*/
|
||||
Integer sound;
|
||||
}
|
||||
|
||||
@ -101,6 +101,10 @@ public class SystemTalkAnswerConfigService extends GenericReactiveCrudService<Sy
|
||||
if(request.getAnswerType() != null){
|
||||
reactiveQuery = reactiveQuery.and(SystemTalkAnswerConfigRequest::getAnswerType, request.getAnswerType());
|
||||
}
|
||||
|
||||
if(request.getPlayType() != null){
|
||||
reactiveQuery = reactiveQuery.and(SystemTalkAnswerConfigRequest::getPlayType, request.getPlayType());
|
||||
}
|
||||
SortOrder sortOrder = null;
|
||||
if(StringUtils.isNotEmpty(request.getOrder())){
|
||||
if(StringUtils.isNotEmpty(request.getSort()) && request.getSort().compareTo("0") == 0){
|
||||
@ -166,6 +170,9 @@ public class SystemTalkAnswerConfigService extends GenericReactiveCrudService<Sy
|
||||
if(request.getKeyOrder() != null){
|
||||
reactiveQuery = reactiveQuery.and(SystemTalkAnswerConfigRequest::getKeyOrder, request.getKeyOrder());
|
||||
}
|
||||
if(request.getPlayType() != null){
|
||||
reactiveQuery = reactiveQuery.and(SystemTalkAnswerConfigRequest::getPlayType, request.getPlayType());
|
||||
}
|
||||
SortOrder sortOrder = null;
|
||||
if(StringUtils.isNotEmpty(request.getOrder())){
|
||||
if(StringUtils.isNotEmpty(request.getSort()) && request.getSort().compareTo("0") == 0){
|
||||
@ -239,6 +246,9 @@ public class SystemTalkAnswerConfigService extends GenericReactiveCrudService<Sy
|
||||
if(entity.getAnswerType() != null){
|
||||
update = update.set(SystemTalkAnswerConfigEntity::getAnswerType, entity.getAnswerType());
|
||||
}
|
||||
if(entity.getPlayType() != null){
|
||||
update = update.set(SystemTalkAnswerConfigEntity::getPlayType, entity.getPlayType());
|
||||
}
|
||||
return update.where(SystemTalkAnswerConfigEntity::getId, entity.getId()).and("is_delete", 0).execute();
|
||||
}
|
||||
|
||||
@ -258,6 +268,7 @@ public class SystemTalkAnswerConfigService extends GenericReactiveCrudService<Sy
|
||||
update = update.set(SystemTalkAnswerConfigEntity::getAnswerBackImg, entity.getAnswerBackImg());
|
||||
update = update.set(SystemTalkAnswerConfigEntity::getKeyOrder, entity.getKeyOrder());
|
||||
update = update.set(SystemTalkAnswerConfigEntity::getAnswerType, entity.getAnswerType());
|
||||
update = update.set(SystemTalkAnswerConfigEntity::getPlayType, entity.getPlayType());
|
||||
return update.where(SystemTalkAnswerConfigEntity::getId, entity.getId()).and("is_delete", 0).execute();
|
||||
}
|
||||
|
||||
|
||||
@ -1,15 +1,11 @@
|
||||
package com.qiuguo.iot.third.nlp.action;
|
||||
|
||||
import com.qiuguo.iot.base.date.DateEnum;
|
||||
import com.qiuguo.iot.base.utils.StringUtils;
|
||||
import com.qiuguo.iot.data.entity.system.SystemTalkAnswerConfigEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.DayOfWeek;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ActionTime {
|
||||
@ -47,17 +43,7 @@ public class ActionTime {
|
||||
|
||||
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
DateTimeFormatter df1 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
if(t.equals("今天")){
|
||||
|
||||
}else if(t.equals("明天")){
|
||||
localDateTime = localDateTime.minusDays(-1);
|
||||
}else if(t.equals("后天")){
|
||||
localDateTime = localDateTime.minusDays(-2);
|
||||
}else if(t.equals("昨天")){
|
||||
localDateTime = localDateTime.minusDays(1);
|
||||
}else if(t.equals("前天")){
|
||||
localDateTime = localDateTime.minusDays(2);
|
||||
}
|
||||
localDateTime = DateEnum.getWithCode(t).getDateTime(localDateTime);
|
||||
dateTime = localDateTime.format(df);
|
||||
dateDetailTime = localDateTime.format(df1);
|
||||
|
||||
|
||||
10
iot-gateway/.gitignore
vendored
10
iot-gateway/.gitignore
vendored
@ -31,3 +31,13 @@ build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
*.log
|
||||
/logs/
|
||||
logs/
|
||||
logs/**
|
||||
/logs/**
|
||||
**/logs/**
|
||||
logs/**/**
|
||||
/logs/**/**
|
||||
**/logs/**/**
|
||||
10
iot-modules/iot-admin-http-api/.gitignore
vendored
10
iot-modules/iot-admin-http-api/.gitignore
vendored
@ -31,3 +31,13 @@ build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
*.log
|
||||
/logs/
|
||||
logs/
|
||||
logs/**
|
||||
/logs/**
|
||||
**/logs/**
|
||||
logs/**/**
|
||||
/logs/**/**
|
||||
**/logs/**/**
|
||||
10
iot-modules/iot-box-user-api/.gitignore
vendored
10
iot-modules/iot-box-user-api/.gitignore
vendored
@ -37,3 +37,13 @@ build/
|
||||
### Mac OS ###
|
||||
.DS_Store
|
||||
/logs/
|
||||
|
||||
*.log
|
||||
/logs/
|
||||
logs/
|
||||
logs/**
|
||||
/logs/**
|
||||
**/logs/**
|
||||
logs/**/**
|
||||
/logs/**/**
|
||||
**/logs/**/**
|
||||
10
iot-modules/iot-box-websocket-api/.gitignore
vendored
10
iot-modules/iot-box-websocket-api/.gitignore
vendored
@ -31,3 +31,13 @@ build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
*.log
|
||||
/logs/
|
||||
logs/
|
||||
logs/**
|
||||
/logs/**
|
||||
**/logs/**
|
||||
logs/**/**
|
||||
/logs/**/**
|
||||
**/logs/**/**
|
||||
@ -1,5 +1,6 @@
|
||||
package com.qiuguo.iot.box.websocket.api.domain;
|
||||
|
||||
import com.qiuguo.iot.data.resp.third.MusicResp;
|
||||
import lombok.Data;
|
||||
import org.springframework.web.reactive.socket.WebSocketMessage;
|
||||
import org.springframework.web.reactive.socket.WebSocketSession;
|
||||
@ -15,9 +16,15 @@ public class BaseSession {
|
||||
protected WebSocketSession session;
|
||||
protected FluxSink<WebSocketMessage> sink;
|
||||
|
||||
protected String logId;//当前请求日志ID
|
||||
/**
|
||||
* 当前请求日志ID
|
||||
*/
|
||||
protected String logId;
|
||||
|
||||
protected String customerIP;//客户端IP
|
||||
/**
|
||||
* 客户端IP
|
||||
*/
|
||||
protected String customerIP;
|
||||
/***
|
||||
* 用户id
|
||||
*/
|
||||
@ -25,5 +32,11 @@ public class BaseSession {
|
||||
/***
|
||||
* 当前使用的BoxId,如果未绑定,那么就是0
|
||||
*/
|
||||
protected Long deviceId = 0l;
|
||||
protected Long deviceId = 0L;
|
||||
|
||||
/***
|
||||
* 当前歌曲状态。正常客户端同步
|
||||
* 用户登录时同步
|
||||
*/
|
||||
MusicResp music;
|
||||
}
|
||||
|
||||
@ -0,0 +1,14 @@
|
||||
package com.qiuguo.iot.box.websocket.api.domain.box;
|
||||
|
||||
import com.qiuguo.iot.box.websocket.api.domain.BaseSession;
|
||||
import com.qiuguo.iot.data.resp.third.MusicResp;
|
||||
import lombok.Data;
|
||||
import org.springframework.web.reactive.socket.WebSocketMessage;
|
||||
import org.springframework.web.reactive.socket.WebSocketSession;
|
||||
import reactor.core.publisher.FluxSink;
|
||||
|
||||
@Data
|
||||
public class BoxSession extends BaseSession {
|
||||
|
||||
|
||||
}
|
||||
@ -6,6 +6,7 @@ import com.qiuguo.iot.base.enums.PlayEnum;
|
||||
import com.qiuguo.iot.base.enums.RespCodeEnum;
|
||||
import com.qiuguo.iot.base.utils.StringUtils;
|
||||
import com.qiuguo.iot.box.websocket.api.domain.BaseSession;
|
||||
import com.qiuguo.iot.box.websocket.api.domain.box.BoxSession;
|
||||
import com.qiuguo.iot.box.websocket.api.domain.box.resp.BoxMessageResp;
|
||||
import com.qiuguo.iot.box.websocket.api.domain.user.UserTalkMessage;
|
||||
import com.qiuguo.iot.box.websocket.api.filter.LogMdcConfiguration;
|
||||
@ -38,6 +39,7 @@ import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.swing.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@ -70,7 +72,7 @@ public class BaseWebSocketProcess {
|
||||
|
||||
protected static ConcurrentHashMap<Long, BaseSession> userGroup = new ConcurrentHashMap<>();
|
||||
|
||||
protected static ConcurrentHashMap<String, BaseSession> boxGroup = new ConcurrentHashMap<>();
|
||||
protected static ConcurrentHashMap<String, BoxSession> boxGroup = new ConcurrentHashMap<>();
|
||||
|
||||
protected static String apiType = "api-type";
|
||||
protected static String apiToken = "api-token";
|
||||
@ -221,28 +223,43 @@ public class BaseWebSocketProcess {
|
||||
if(StringUtils.isNotEmpty(action.getPName())){
|
||||
search = search.replaceAll(action.getPName(), "");
|
||||
}
|
||||
musicService.searchMusic(search, 1).defaultIfEmpty(new ArrayList<>()).map(resultSongs -> {
|
||||
BoxMessageResp resp = new BoxMessageResp();
|
||||
MusicResp musicResp = new MusicResp();
|
||||
if(resultSongs.size() > 0){
|
||||
//
|
||||
SongInfoResponse.ResultSong song = resultSongs.get(0);
|
||||
musicResp.setPlay(PlayEnum.START.getCode());
|
||||
musicResp.setName(song.getName());
|
||||
musicResp.setUrl(song.getUrl());
|
||||
musicResp.setSinger(song.getArtistName());
|
||||
resp.setText("现在为您播放" + song.getName() +
|
||||
(StringUtils.isNotEmpty(song.getArtistName()) ? ("来自" + song.getArtistName()) : ""));
|
||||
}else{
|
||||
musicResp.setPlay(PlayEnum.NONE.getCode());
|
||||
resp.setText("未找到相关资源");
|
||||
}
|
||||
resp.setMusic(musicResp);
|
||||
resp.setType(action.getSystemTalkAnswerConfigEntity().getAnswerType());
|
||||
BoxMessageResp resp = new BoxMessageResp();
|
||||
if(action.getSystemTalkAnswerConfigEntity().getPlayType().equals(PlayEnum.START.getCode())){
|
||||
musicService.searchMusic(search, 1).defaultIfEmpty(new ArrayList<>()).map(resultSongs -> {
|
||||
//BoxMessageResp resp = new BoxMessageResp();
|
||||
MusicResp musicResp = new MusicResp();
|
||||
if(resultSongs.size() > 0){
|
||||
//
|
||||
SongInfoResponse.ResultSong song = resultSongs.get(0);
|
||||
musicResp.setPlay(PlayEnum.START.getCode());
|
||||
musicResp.setName(song.getName());
|
||||
musicResp.setUrl(song.getUrl());
|
||||
musicResp.setSinger(song.getArtistName());
|
||||
resp.setText("现在为您播放" + song.getName() +
|
||||
(StringUtils.isNotEmpty(song.getArtistName()) ? ("来自" + song.getArtistName()) : ""));
|
||||
}else{
|
||||
musicResp.setPlay(PlayEnum.NONE.getCode());
|
||||
resp.setText("未找到相关资源");
|
||||
}
|
||||
resp.setMusic(musicResp);
|
||||
resp.setType(action.getSystemTalkAnswerConfigEntity().getAnswerType());
|
||||
|
||||
sendMessage(action, baseSession, resp);
|
||||
return resultSongs;
|
||||
}).subscribe();
|
||||
}else if(baseSession.getMusic() != null){
|
||||
//做相应的动作
|
||||
baseSession.getMusic().setPlay(action.getSystemTalkAnswerConfigEntity().getPlayType());
|
||||
resp.setMusic(baseSession.getMusic());
|
||||
resp.setText("已" + action.getAction());
|
||||
resp.setType(action.getSystemTalkAnswerConfigEntity().getAnswerType());
|
||||
sendMessage(action, baseSession, resp);
|
||||
return resultSongs;
|
||||
}).subscribe();
|
||||
}else{
|
||||
resp.setType(AskTypeEnum.TTS.getCode());
|
||||
resp.setText("目前无播放资源,无法操作");
|
||||
sendMessage(action, baseSession, resp);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -257,33 +274,62 @@ public class BaseWebSocketProcess {
|
||||
talkRecord.setUserId(baseSession.getUserId());
|
||||
talkRecord.setDeviceId(baseSession.getDeviceId());
|
||||
if(resp.getType().equals(AskTypeEnum.MUSIC.getCode())) {
|
||||
//客户端推送的
|
||||
if(this instanceof CustomerWebSocketHandler) {
|
||||
log.info("推送Box播放音乐");
|
||||
BaseSession boxSession = getBoxSessionWithSn(baseSession.getSn());
|
||||
BoxSession boxSession = getBoxSessionWithSn(baseSession.getSn());
|
||||
if(boxSession != null){
|
||||
boxSession.getSink().next(baseSession.getSession().textMessage(JSONObject.toJSONString(resp)));
|
||||
//记录音乐状态
|
||||
if(resp.getMusic().getPlay().equals(PlayEnum.STOP.getCode())){
|
||||
//去掉内存中音乐同步对象
|
||||
boxSession.setMusic(null);
|
||||
baseSession.setMusic(null);
|
||||
}else{
|
||||
boxSession.setMusic(resp.getMusic());
|
||||
}
|
||||
}else{
|
||||
log.info("设备sn:{}不在线,无法播放", baseSession.getSn());
|
||||
resp.setText("设备不在线,无法播放");
|
||||
}
|
||||
}else{//果box的
|
||||
//记录音乐状态
|
||||
BaseSession userSession = getUserSessionWithUserId(baseSession.getUserId());
|
||||
//记录音乐状态
|
||||
if(resp.getMusic().getPlay().equals(PlayEnum.STOP.getCode())){
|
||||
//去掉内存中音乐同步对象
|
||||
if(userSession != null){
|
||||
userSession.setMusic(null);
|
||||
//如果在线推送用户端
|
||||
}
|
||||
baseSession.setMusic(null);
|
||||
}else{
|
||||
if(userSession != null){
|
||||
userSession.setMusic(resp.getMusic());
|
||||
//如果在线推送用户端
|
||||
}
|
||||
baseSession.setMusic(resp.getMusic());
|
||||
}
|
||||
}
|
||||
}
|
||||
deviceUserTalkRecordService.insertDeviceUserTalkRecord(talkRecord).map(i ->{
|
||||
String msg = JSONObject.toJSONString(resp);
|
||||
log.info("推送通知到端msg:{}", msg);
|
||||
if(this instanceof BoxWebSocketHandler){
|
||||
log.info("推送通知到客户端");
|
||||
log.info("果box聊天记录,同步到客户端");
|
||||
BaseSession userSession = getUserSessionWithUserId(baseSession.getUserId());
|
||||
if(userSession != null){
|
||||
userSession.getSink().next(baseSession.getSession().textMessage(JSONObject.toJSONString(resp)));
|
||||
}
|
||||
}
|
||||
baseSession.getSink().next(baseSession.getSession().textMessage(JSONObject.toJSONString(resp)));
|
||||
baseSession.getSink().next(baseSession.getSession().textMessage(msg));
|
||||
|
||||
return Mono.empty();
|
||||
}).subscribe();//保存聊天记录
|
||||
|
||||
}
|
||||
|
||||
public BaseSession getBoxSessionWithSn(String sn) {
|
||||
public BoxSession getBoxSessionWithSn(String sn) {
|
||||
if(boxGroup.containsKey(sn)){
|
||||
return boxGroup.get(sn);
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@ import com.qiuguo.iot.base.enums.DeviceTypeEnum;
|
||||
import com.qiuguo.iot.base.enums.YesNo;
|
||||
import com.qiuguo.iot.base.model.UserDeviceInfoModel;
|
||||
import com.qiuguo.iot.box.websocket.api.domain.BaseSession;
|
||||
import com.qiuguo.iot.box.websocket.api.domain.box.BoxSession;
|
||||
import com.qiuguo.iot.box.websocket.api.domain.box.BoxTalkMessage;
|
||||
import com.qiuguo.iot.box.websocket.api.filter.LogMdcConfiguration;
|
||||
import com.qiuguo.iot.box.websocket.api.filter.LogWebFilter;
|
||||
@ -102,7 +103,7 @@ public class BoxWebSocketHandler extends BaseWebSocketProcess implements WebSock
|
||||
//MDC.remove(LogMdcConfiguration.PRINT_LOG_ID);
|
||||
return Mono.empty();
|
||||
}).then();
|
||||
BaseSession boxSession = new BaseSession();
|
||||
BoxSession boxSession = new BoxSession();
|
||||
boxSession.setSn(sn);
|
||||
boxSession.setCustomerIP(ip);
|
||||
boxSession.setSession(session);
|
||||
|
||||
10
iot-modules/iot-customer-http-api/.gitignore
vendored
10
iot-modules/iot-customer-http-api/.gitignore
vendored
@ -31,3 +31,13 @@ build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
*.log
|
||||
/logs/
|
||||
logs/
|
||||
logs/**
|
||||
/logs/**
|
||||
**/logs/**
|
||||
logs/**/**
|
||||
/logs/**/**
|
||||
**/logs/**/**
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user