|
@@ -6,6 +6,7 @@ import (
|
|
"encoding/binary"
|
|
"encoding/binary"
|
|
"encoding/json"
|
|
"encoding/json"
|
|
"errors"
|
|
"errors"
|
|
|
|
+ "fmt"
|
|
"github.com/PuerkitoBio/goquery"
|
|
"github.com/PuerkitoBio/goquery"
|
|
"github.com/kgiannakakis/mp3duration/src/mp3duration"
|
|
"github.com/kgiannakakis/mp3duration/src/mp3duration"
|
|
"hongze/hz_eta_api/models"
|
|
"hongze/hz_eta_api/models"
|
|
@@ -21,10 +22,6 @@ import (
|
|
)
|
|
)
|
|
|
|
|
|
func CreateVideo(report *models.ReportDetail) (err error) {
|
|
func CreateVideo(report *models.ReportDetail) (err error) {
|
|
- if utils.XfAPPID == `` {
|
|
|
|
- // 如果科大讯飞未配置,那么就直接返回,不生成音频了
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
defer func() {
|
|
defer func() {
|
|
if err != nil {
|
|
if err != nil {
|
|
utils.FileLog.Error("CreateVideo Err:%s", err.Error())
|
|
utils.FileLog.Error("CreateVideo Err:%s", err.Error())
|
|
@@ -32,6 +29,24 @@ func CreateVideo(report *models.ReportDetail) (err error) {
|
|
//go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "Err:"+err.Error(), utils.EmailSendToUsers)
|
|
//go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "Err:"+err.Error(), utils.EmailSendToUsers)
|
|
}
|
|
}
|
|
}()
|
|
}()
|
|
|
|
+
|
|
|
|
+ // 获取基础配置, 若未配置则直接返回
|
|
|
|
+ conf, e := models.GetBusinessConf()
|
|
|
|
+ if e != nil {
|
|
|
|
+ err = fmt.Errorf("获取基础配置失败, Err: " + e.Error())
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if conf[models.BusinessConfUseXf] != "true" {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if conf[models.BusinessConfXfAppid] == "" || conf[models.BusinessConfXfApiKey] == "" || conf[models.BusinessConfXfApiSecret] == "" || conf[models.BusinessConfXfVcn] == "" {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ var xfReq XfParams
|
|
|
|
+ xfReq.XfAPPID = conf[models.BusinessConfXfAppid]
|
|
|
|
+ xfReq.XfAPIKey = conf[models.BusinessConfXfApiKey]
|
|
|
|
+ xfReq.XfAPISecret = conf[models.BusinessConfXfApiSecret]
|
|
|
|
+
|
|
ct, err := time.Parse(utils.FormatDateTime, report.CreateTime)
|
|
ct, err := time.Parse(utils.FormatDateTime, report.CreateTime)
|
|
createTime := ct.Format("0102")
|
|
createTime := ct.Format("0102")
|
|
videoName := report.Title + "(" + createTime + ")"
|
|
videoName := report.Title + "(" + createTime + ")"
|
|
@@ -46,11 +61,11 @@ func CreateVideo(report *models.ReportDetail) (err error) {
|
|
}
|
|
}
|
|
|
|
|
|
param := new(models.XfSendParam)
|
|
param := new(models.XfSendParam)
|
|
- param.Common.AppId = utils.XfAPPID
|
|
|
|
|
|
+ param.Common.AppId = conf[models.BusinessConfXfAppid]
|
|
param.Business.Aue = "lame"
|
|
param.Business.Aue = "lame"
|
|
param.Business.Sfl = 1
|
|
param.Business.Sfl = 1
|
|
param.Business.Auf = "audio/L16;rate=16000"
|
|
param.Business.Auf = "audio/L16;rate=16000"
|
|
- param.Business.Vcn = utils.XfVcn
|
|
|
|
|
|
+ param.Business.Vcn = conf[models.BusinessConfXfVcn]
|
|
param.Business.Speed = 50
|
|
param.Business.Speed = 50
|
|
param.Business.Volume = 100
|
|
param.Business.Volume = 100
|
|
param.Business.Pitch = 50
|
|
param.Business.Pitch = 50
|
|
@@ -74,7 +89,7 @@ func CreateVideo(report *models.ReportDetail) (err error) {
|
|
if err != nil {
|
|
if err != nil {
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
- err = GetXfVideo(result, savePath)
|
|
|
|
|
|
+ err = GetXfVideo(result, savePath, xfReq)
|
|
if err != nil {
|
|
if err != nil {
|
|
err = errors.New("GetXfVideo Err:" + err.Error())
|
|
err = errors.New("GetXfVideo Err:" + err.Error())
|
|
utils.FileLog.Error("GetXfVideo err", err.Error())
|
|
utils.FileLog.Error("GetXfVideo err", err.Error())
|
|
@@ -192,10 +207,6 @@ func getFourccType(boxHeader BoxHeader) (fourccType string) {
|
|
|
|
|
|
// CreateReportVideo 生成报告video
|
|
// CreateReportVideo 生成报告video
|
|
func CreateReportVideo(reportTitle, reportContent, reportTime string) (uploadUrl, videoName, sizeStr string, playSeconds float64, err error) {
|
|
func CreateReportVideo(reportTitle, reportContent, reportTime string) (uploadUrl, videoName, sizeStr string, playSeconds float64, err error) {
|
|
- if utils.XfAPPID == `` {
|
|
|
|
- // 如果科大讯飞未配置,那么就直接返回,不生成音频了
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
defer func() {
|
|
defer func() {
|
|
if err != nil {
|
|
if err != nil {
|
|
utils.FileLog.Error("CreateReportVideo Err:%s", err.Error())
|
|
utils.FileLog.Error("CreateReportVideo Err:%s", err.Error())
|
|
@@ -206,6 +217,24 @@ func CreateReportVideo(reportTitle, reportContent, reportTime string) (uploadUrl
|
|
if reportContent == "" {
|
|
if reportContent == "" {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ // 获取基础配置, 若未配置则直接返回
|
|
|
|
+ conf, e := models.GetBusinessConf()
|
|
|
|
+ if e != nil {
|
|
|
|
+ err = fmt.Errorf("获取基础配置失败, Err: " + e.Error())
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if conf[models.BusinessConfUseXf] != "true" {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if conf[models.BusinessConfXfAppid] == "" || conf[models.BusinessConfXfApiKey] == "" || conf[models.BusinessConfXfApiSecret] == "" || conf[models.BusinessConfXfVcn] == "" {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ var xfReq XfParams
|
|
|
|
+ xfReq.XfAPPID = conf[models.BusinessConfXfAppid]
|
|
|
|
+ xfReq.XfAPIKey = conf[models.BusinessConfXfApiKey]
|
|
|
|
+ xfReq.XfAPISecret = conf[models.BusinessConfXfApiSecret]
|
|
|
|
+
|
|
ct, err := time.Parse(utils.FormatDateTime, reportTime)
|
|
ct, err := time.Parse(utils.FormatDateTime, reportTime)
|
|
if err != nil {
|
|
if err != nil {
|
|
return
|
|
return
|
|
@@ -223,11 +252,11 @@ func CreateReportVideo(reportTitle, reportContent, reportTime string) (uploadUrl
|
|
}
|
|
}
|
|
|
|
|
|
param := new(models.XfSendParam)
|
|
param := new(models.XfSendParam)
|
|
- param.Common.AppId = utils.XfAPPID
|
|
|
|
|
|
+ param.Common.AppId = conf[models.BusinessConfXfAppid]
|
|
param.Business.Aue = "lame"
|
|
param.Business.Aue = "lame"
|
|
param.Business.Sfl = 1
|
|
param.Business.Sfl = 1
|
|
param.Business.Auf = "audio/L16;rate=16000"
|
|
param.Business.Auf = "audio/L16;rate=16000"
|
|
- param.Business.Vcn = utils.XfVcn
|
|
|
|
|
|
+ param.Business.Vcn = conf[models.BusinessConfXfVcn]
|
|
param.Business.Speed = 50
|
|
param.Business.Speed = 50
|
|
param.Business.Volume = 100
|
|
param.Business.Volume = 100
|
|
param.Business.Pitch = 50
|
|
param.Business.Pitch = 50
|
|
@@ -251,7 +280,7 @@ func CreateReportVideo(reportTitle, reportContent, reportTime string) (uploadUrl
|
|
if tmpErr != nil {
|
|
if tmpErr != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- err = GetXfVideo(result, savePath)
|
|
|
|
|
|
+ err = GetXfVideo(result, savePath, xfReq)
|
|
if err != nil {
|
|
if err != nil {
|
|
err = errors.New("GetXfVideo Err:" + err.Error())
|
|
err = errors.New("GetXfVideo Err:" + err.Error())
|
|
utils.FileLog.Error("GetXfVideo err", err.Error())
|
|
utils.FileLog.Error("GetXfVideo err", err.Error())
|