Commit 5960a3ed authored by 赵文静's avatar 赵文静

修改问题

parent 6cc89e2a
......@@ -2,6 +2,8 @@
## [0.0.1-beta.3] - 2025.6.6
### Changed
- 更改为redis存储sessionId
- 修复查询历史上的今天切片越界问题
- 修改闹钟兜底回复不播报的问题
## [0.0.1-beta.2] - 2025.5.29
### Changed
......
......@@ -14,7 +14,7 @@ Content-Type: application/json
"trafficParameter": "mode=childxxx;macWifi=28b77c218ed1;mid=10f05;vender=7e000025;macVoice=testyuntiancloud;ver=3.0;scenario=smarthome;filterName=nlu;req_nlu_length=1;returnType=json;fullDuplex=true;appendLength=1;additionalService=geli_nlu2;version=0.5;filterUrl=https://testnlu.gree.com:443/semantic/unisoundc2c/querys;"
},
"nluRet": {
"text": "今天天气"
"text": "历史上的今天发生了什么"
},
"postProc": {}
}
......@@ -33,7 +33,7 @@ Content-Type: application/json
},
"nluRet": {
"asr_recongize": "",
"text": "白日依山尽的下一句是什么"
"text": "播放月亮还没来"
}
},
"version": "v0"
......@@ -55,7 +55,7 @@ Content-Type: application/json
"trafficParameter": "mode=childxx;macWifi=ece154a73d38;mid=11011;macVoice=testyuntiancloud;ver=3.0;scenario=smarthome;filterName=nlu;req_nlu_length=1;returnType=json;fullDuplex=true;appendLength=1;additionalService=geli_nlu2;version=0.5;filterUrl=https://testnlu.gree.com:443/semantic/unisoundc2c/querys;"
},
"nluRet": {
"text": "明天空气质量多少"
"text": "创建一个昨天的闹钟"
},
"postProc": {}
}
......
......@@ -125,32 +125,65 @@ func calendarDomain(params *model.SpeechDomainParams) []byte {
}
var l int
var resStrb string
//var resStrb string
if len(sliceData) < global.GetLimitedSetting(params.Mid).HistoryNum {
l = len(sliceData)
} else { // 使用限制的条数
l = global.GetLimitedSetting(params.Mid).HistoryNum
}
if len(sliceData) > l {
sliceData = sliceData[:l]
var titles []string
for i := 0; i < l; i++ {
item, ok := sliceData[i].(map[string]interface{})
if !ok {
global.Logger.WithFields(logger.Fields{
"requestId": params.RequestId,
"mac": params.Mac,
"mid": params.Mid,
"vender": params.MidType,
}).Errorf("resultData[%d] 不是 map[string]interface{} 类型", i)
continue // 跳过无效数据
}
for _, item := range sliceData {
itemBytes, _ := json.Marshal(item)
var con model.Result
if err := json.Unmarshal(itemBytes, &con); err != nil {
title, ok := item["title"].(string)
if !ok {
global.Logger.WithFields(logger.Fields{
"requestId": params.RequestId,
"mac": params.Mac,
"mid": params.Mid,
"vender": params.MidType,
}).Errorf("json.Unmarshal元素解析失败: %v", err)
return replyWithChat(error_reply, "doudi")
}).Errorf("resultData[%d].title 不是字符串类型", i)
continue // 跳过无效数据
}
resStrb += fmt.Sprintf("%s", con.Title)
titles = append(titles, title)
}
res.ResponseText = resStrb
// 4. 拼接成最终响应文本
if len(titles) == 0 {
res.ResponseText = "未找到有效数据"
} else {
res.ResponseText = strings.Join(titles, "") // 用换行符连接多个 title
}
//if len(sliceData) > l {
// sliceData = sliceData[:l]
//}
//
//for _, item := range sliceData {
// itemBytes, _ := json.Marshal(item)
// var con model.Result
// if err := json.Unmarshal(itemBytes, &con); err != nil {
// global.Logger.WithFields(logger.Fields{
// "requestId": params.RequestId,
// "mac": params.Mac,
// "mid": params.Mid,
// "vender": params.MidType,
// }).Errorf("json.Unmarshal元素解析失败: %v", err)
// return replyWithChat(error_reply, "doudi")
// }
// resStrb += fmt.Sprintf("%s", con.Title)
//}
//res.ResponseText = resStrb
}
}
......@@ -450,6 +483,19 @@ func alarmDomain(params *model.SpeechDomainParams) []byte {
}
if !params.CheckDm() || !params.CheckCommandParam() {
if !params.CheckCommandParam() {
switch params.SpeechWsResp.Dm.IntentName {
case "创建提醒":
result.Header.Semantic.Intent = "new"
case "删除提醒":
result.Header.Semantic.Intent = "delete"
case "查询提醒":
result.Header.Semantic.Intent = "check"
default:
result.Header.Semantic.Intent = "new" //兜底,如果是chat的话不会播报
}
}
if result.ResponseText != "" {
return Marshal(params, &result)
}
......@@ -521,101 +567,6 @@ func alarmDomain(params *model.SpeechDomainParams) []byte {
}
//
//var result model.ResponseBody
//result.Header.Semantic.Code = 0
//result.Header.Semantic.Msg = speech_nlu_parse
//result.Header.Semantic.SessionComplete = params.SpeechWsResp.Dm.ShouldEndSession
////result.Header.Semantic.SkillId = result.Header.Semantic.Domain + "." + result.Header.Semantic.Intent
//result.AsrRecongize = params.SpeechWsResp.Dm.Input
//
//var alarmDBData model.AlarmRemindInfo
//alarmDBData.Mac = params.Mac
//alarmDBData.Note = ""
//alarmDBData.URL = ""
//alarmDBData.Speech_Type = onlyTTS
//alarmDBData.Createtime = time.Now().String()[:19]
////items := ""
//contentTTS := ""
//
//if params.SpeechWsResp.Dm.Param.Object == "闹钟" {
// alarmDBData.E_type = alarm
// result.Header.Semantic.Domain = "alarm"
//} else {
// alarmDBData.E_type = remind
// result.Header.Semantic.Domain = "reminder_v2"
// if !params.CheckEvent() {
// contentTTS = alarm_remind_common + params.SpeechWsResp.Dm.Param.Event
// } else {
// contentTTS = alarm_remind_raw
// }
// alarmDBData.Note = contentTTS
//}
//fmt.Println(contentTTS)
//
//if params.SpeechWsResp.Dm.Api == "DUI.Alerts.SetAlert" {
// result.Header.Semantic.Intent = "new"
// if !params.CheckDate() {
// global.Logger.WithFields(logger.Fields{
// "requestId": params.RequestId,
// "mac": params.Mac,
// "mid": params.Mid,
// "vender": params.MidType}).Error("params.CheckDate() error")
// return replyWithChat(error_reply, "doudi")
// } else {
// //如果日期存在
// t, err := time.Parse("20060102", params.SpeechWsResp.Dm.Param.Date)
// if err != nil {
// global.Logger.WithFields(logger.Fields{
// "requestId": params.RequestId,
// "mac": params.Mac,
// "mid": params.Mid,
// "vender": params.MidType}).Error(err.Error())
// return replyWithChat(error_reply, "doudi")
// }
//
// // 将日期转换为目标格式
// formatted := t.Format("2006-01-02")
// alarmDBData.E_date = formatted
// //获得时间
// alarmDBData.E_time = params.SpeechWsResp.Dm.Param.Time
// }
//
// if !params.CheckRepeat() {
// alarmDBData.Repeat_type = 1
// } else if params.SpeechWsResp.Dm.Param.Repeat == "W1W2W3W4W5W6W7" {
// alarmDBData.Repeat_type = 2
// } else if params.SpeechWsResp.Dm.Param.Repeat == "W1W2W3W4W5" {
// alarmDBData.Repeat_type = 5
// } else if strings.Contains(strings.ToLower(params.SpeechWsResp.Dm.Param.Repeat), "M") {
// alarmDBData.Repeat_type = 4
// } else if strings.Contains(strings.ToLower(params.SpeechWsResp.Dm.Param.Repeat), "W") {
// alarmDBData.Repeat_type = 3
// //每周几待写
// }
// dao.SaveAlarmRemindData(alarmDBData)
// if params.SpeechWsResp.Dm.Nlg != "" {
// result.ResponseText = params.SpeechWsResp.Dm.Nlg
// } else {
// result.ResponseText = "已经设置好了"
// }
//
//} else if params.SpeechWsResp.Dm.Api == "DUI.Alerts.QueryAlert" {
// result.Header.Semantic.Intent = "check"
// dao.DeleteOverdueAlarmRemindData(mac)
//
//} else if params.SpeechWsResp.Dm.Api == "DUI.Alerts.DeleteAlert" {
// result.Header.Semantic.Intent = "delete"
//}
//
//result.Header.Semantic.SkillId = result.Header.Semantic.Domain + "." + result.Header.Semantic.Intent
//
//if !alarmDevFilter(params) {
// return Marshal(params, &result)
//}
//
//return Marshal(params, &result)
return Marshal(params, &result)
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment