You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
2.6 KiB
79 lines
2.6 KiB
package echomeet
|
|
|
|
import (
|
|
"yunyan/comm"
|
|
"yunyan/pb"
|
|
"yunyan/utils"
|
|
)
|
|
|
|
// @Summary 处理Echomeet异步通知 [内部RPC]
|
|
// @Description 接收由HTTP回调网关转发来的已验证的支付通知,并处理业务逻辑
|
|
// @Tags Echomeet
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Security BearerAuth
|
|
// @Param notify body pb.EchomeetCallbackReq true "回调参数"
|
|
// @Success 200 {object} comm.HttpResult "处理结果"
|
|
// @Router /api/home/echomeet_backcall [post]
|
|
func (this *apiComp) BackCall(session comm.IUserSession, req *pb.EchomeetCallbackReq) (resp []byte, errdata *pb.ErrorData) {
|
|
var (
|
|
id uint64
|
|
model *pb.DBEchoMeetRecord
|
|
|
|
err error
|
|
)
|
|
id = utils.StringToUInt64(req.CallbackData)
|
|
model, err = this.module.model.getrecord(id)
|
|
if err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
// 抢收尾权:回调重放、或轮询/兜底扫描已经收完之后迟到的这一次,都在这里被挡掉。
|
|
// ⚠️ 挡掉时仍回 SUCCESS:对第三方来说这次通知已经被正确接收了,
|
|
// 回错只会让它按失败重投,重投的还是同一条已经处理过的结果。
|
|
if !this.module.tasks.beginTranscribeFinish(model) {
|
|
this.module.Infof("BackCall id:%d 状态已是 %s 或收尾进行中,忽略本次回调",
|
|
model.Id, model.State.String())
|
|
resp = []byte(utils.ToString(map[string]string{
|
|
"code": "SUCCESS",
|
|
"message": "成功",
|
|
}))
|
|
return
|
|
}
|
|
defer this.module.tasks.endTranscribeFinish(model.Id)
|
|
|
|
if req.Code != 20000000 {
|
|
model.State = pb.DBEchoMeetRecordState_TranscribeFail
|
|
this.module.model.saverecord(model)
|
|
resp = []byte(utils.ToString(map[string]string{
|
|
"code": "SUCCESS",
|
|
"message": "成功",
|
|
}))
|
|
return
|
|
}
|
|
contexts := make([]*pb.ContextStruct, 0, len(req.Result.Utterances))
|
|
for _, v := range req.Result.Utterances {
|
|
contexts = append(contexts, &pb.ContextStruct{
|
|
Content: v.Text,
|
|
Starttime: v.StartTime,
|
|
Endtime: v.EndTime,
|
|
Speaker: v.Additions.Speaker, // 原始编号,格式化交给 normalizeSpeakers
|
|
})
|
|
}
|
|
// 说话人标签与 Personnel 一律走这一个函数,四条写入路径才不会各拼各的。
|
|
// 顺带修掉一个边角:没开说话人分离时编号是空串,原来会拼出 `Speaker_` 这种空尾巴。
|
|
normalizeSpeakers(model, contexts)
|
|
model.Original = utils.ToString(contexts)
|
|
model.State = pb.DBEchoMeetRecordState_AwaitSummarizing
|
|
this.module.tasks.TranslateProcess(model, contexts)
|
|
this.module.model.saverecord(model)
|
|
_ = this.module.tasks.submitAITaskOnce(model)
|
|
resp = []byte(utils.ToString(map[string]string{
|
|
"code": "SUCCESS",
|
|
"message": "成功",
|
|
}))
|
|
return
|
|
}
|
|
|