|
@@ -3,6 +3,7 @@ package action
|
|
|
import (
|
|
import (
|
|
|
"fmt"
|
|
"fmt"
|
|
|
"os"
|
|
"os"
|
|
|
|
|
+ "path/filepath"
|
|
|
"pbx-api-gin/internal/app/stc/active"
|
|
"pbx-api-gin/internal/app/stc/active"
|
|
|
"pbx-api-gin/internal/app/stc/priority"
|
|
"pbx-api-gin/internal/app/stc/priority"
|
|
|
alstatus "pbx-api-gin/internal/app/stc/sendstatus"
|
|
alstatus "pbx-api-gin/internal/app/stc/sendstatus"
|
|
@@ -162,13 +163,13 @@ func HandleAMI(event map[string]string) {
|
|
|
//执行加密操作,并将录音信息写入日志文件
|
|
//执行加密操作,并将录音信息写入日志文件
|
|
|
DstFile := ""
|
|
DstFile := ""
|
|
|
if len(FileNames) > 0 { // 文件切割之后进入循环处理
|
|
if len(FileNames) > 0 { // 文件切割之后进入循环处理
|
|
|
- for _, filepath := range FileNames {
|
|
|
|
|
|
|
+ for _, filepathFull := range FileNames {
|
|
|
|
|
|
|
|
- file := strings.Replace(filepath, ".wav", "", -1)
|
|
|
|
|
|
|
+ file := strings.Replace(filepathFull, ".wav", "", -1)
|
|
|
DstFile = fmt.Sprintf("%s-encrypted.wav", file)
|
|
DstFile = fmt.Sprintf("%s-encrypted.wav", file)
|
|
|
|
|
|
|
|
//lfshook.NewLogger().Infof("Bin file====%s", DstFile)
|
|
//lfshook.NewLogger().Infof("Bin file====%s", DstFile)
|
|
|
- err = utils.AudioFileEncode(DstFile, filepath)
|
|
|
|
|
|
|
+ err = utils.AudioFileEncode(DstFile, filepathFull)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
lfshook.NewLogger().Infof("Encode file: %s err: %+v", DstFile, err)
|
|
lfshook.NewLogger().Infof("Encode file: %s err: %+v", DstFile, err)
|
|
|
continue
|
|
continue
|
|
@@ -176,34 +177,46 @@ func HandleAMI(event map[string]string) {
|
|
|
//切割&加密之后发送生成的文件名到STC;
|
|
//切割&加密之后发送生成的文件名到STC;
|
|
|
alstatus.SendRecordFile(DstFile, event["RecordType"])
|
|
alstatus.SendRecordFile(DstFile, event["RecordType"])
|
|
|
|
|
|
|
|
- trainInfo = active.ActivedCab
|
|
|
|
|
|
|
+ trainInfo = fmt.Sprintf("Train Number %s CabNumber %s", active.TrainNum, active.ActivedCab)
|
|
|
|
|
|
|
|
if strings.Contains(event["FILENAME"], "PAD") {
|
|
if strings.Contains(event["FILENAME"], "PAD") {
|
|
|
_, caller, callee := utils.GetPadInfo(event["FILENAME"])
|
|
_, caller, callee := utils.GetPadInfo(event["FILENAME"])
|
|
|
- utils.Logger.Printf("Train Information: CabNumber %s, MessageType: PAD , CabNumber: %c , LocationCode: %c, Connected: %s, RecordFileName:%s", trainInfo, caller[2], caller[3], callee, DstFile)
|
|
|
|
|
|
|
+ utils.Logger.Printf("Train Information:%s , MessageType: PAD , CabNumber: %c , LocationCode: %c, Connected: %s, RecordFileName:%s", trainInfo, caller[2], caller[3], callee, DstFile)
|
|
|
} else if strings.Contains(event["FILENAME"], "PA") {
|
|
} else if strings.Contains(event["FILENAME"], "PA") {
|
|
|
_, caller, _ := utils.GetPadInfo(event["FILENAME"])
|
|
_, caller, _ := utils.GetPadInfo(event["FILENAME"])
|
|
|
- utils.Logger.Printf("Train Information: CabNumber %s, MessageType: PA, Caller: %s, RecordFileName: %s", trainInfo, caller, DstFile)
|
|
|
|
|
|
|
+ utils.Logger.Printf("Train Information:%s , MessageType: PA, Caller: %s, RecordFileName: %s", trainInfo, caller, DstFile)
|
|
|
} else if strings.Contains(event["FILENAME"], "C2C") {
|
|
} else if strings.Contains(event["FILENAME"], "C2C") {
|
|
|
_, caller, _ := utils.GetPadInfo(event["FILENAME"])
|
|
_, caller, _ := utils.GetPadInfo(event["FILENAME"])
|
|
|
- utils.Logger.Printf("Train Information: CabNumber %s, MessageType: CabCab, Caller: %s, RecordFileName: %s", trainInfo, caller, DstFile)
|
|
|
|
|
|
|
+ utils.Logger.Printf("Train Information:%s , MessageType: CabCab, Caller: %s, RecordFileName: %s", trainInfo, caller, DstFile)
|
|
|
} else if strings.Contains(event["FILENAME"], "CPA") {
|
|
} else if strings.Contains(event["FILENAME"], "CPA") {
|
|
|
_, caller, _ := utils.GetPadInfo(event["FILENAME"])
|
|
_, caller, _ := utils.GetPadInfo(event["FILENAME"])
|
|
|
- utils.Logger.Printf("Train Information: CabNumber %s, MessageType: CPA, Caller: %s, RecordFileName: %s", trainInfo, caller, DstFile)
|
|
|
|
|
|
|
+ utils.Logger.Printf("Train Information:%s , MessageType: CPA, Caller: %s, RecordFileName: %s", trainInfo, caller, DstFile)
|
|
|
} else if strings.Contains(event["FILENAME"], "EMG") {
|
|
} else if strings.Contains(event["FILENAME"], "EMG") {
|
|
|
- utils.Logger.Printf("Train Information: CabNumber %s, MessageType: EMG, RecordFileName: %s", trainInfo, DstFile)
|
|
|
|
|
|
|
+ utils.Logger.Printf("Train Information:%s , MessageType: EMG, RecordFileName: %s", trainInfo, DstFile)
|
|
|
} else if strings.Contains(event["FILENAME"], "STN") {
|
|
} else if strings.Contains(event["FILENAME"], "STN") {
|
|
|
- utils.Logger.Printf("Train Information: CabNumber %s, MessageType: STN, RecordFileName: %s", trainInfo, DstFile)
|
|
|
|
|
|
|
+ utils.Logger.Printf("Train Information:%s , MessageType: STN, RecordFileName: %s", trainInfo, DstFile)
|
|
|
} else if strings.Contains(event["FILENAME"], "DCS") {
|
|
} else if strings.Contains(event["FILENAME"], "DCS") {
|
|
|
- utils.Logger.Printf("Train Information: CabNumber %s, MessageType: DCS, RecordFileName: %s", trainInfo, DstFile)
|
|
|
|
|
|
|
+ utils.Logger.Printf("Train Information:%s , MessageType: DCS, RecordFileName: %s", trainInfo, DstFile)
|
|
|
} else if strings.Contains(event["FILENAME"], "SPC") {
|
|
} else if strings.Contains(event["FILENAME"], "SPC") {
|
|
|
- utils.Logger.Printf("Train Information: CabNumber %s, MessageType: SPC, RecordFileName: %s", trainInfo, DstFile)
|
|
|
|
|
|
|
+ utils.Logger.Printf("Train Information:%s , MessageType: SPC, RecordFileName: %s", trainInfo, DstFile)
|
|
|
} else if strings.Contains(event["FILENAME"], "CHK") {
|
|
} else if strings.Contains(event["FILENAME"], "CHK") {
|
|
|
- utils.Logger.Printf("Train Information: CabNumber %s, MessageType: Self Check, RecordFileName: %s", trainInfo, DstFile)
|
|
|
|
|
|
|
+ utils.Logger.Printf("Train Information:%s , MessageType: Self Check, RecordFileName: %s", trainInfo, DstFile)
|
|
|
} else if strings.Contains(event["FILENAME"], "TONE") {
|
|
} else if strings.Contains(event["FILENAME"], "TONE") {
|
|
|
- utils.Logger.Printf("Train Information: CabNumber %s, MessageType: TONE Test, RecordFileName: %s", trainInfo, DstFile)
|
|
|
|
|
|
|
+ utils.Logger.Printf("Train Information:%s , MessageType: TONE Test, RecordFileName: %s", trainInfo, DstFile)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ //Get path & generate recording XML file
|
|
|
|
|
+ path := filepath.Dir(event["FILENAME"])
|
|
|
|
|
+ rcdFileName := filepath.Base(event["FILENAME"])
|
|
|
|
|
+ xmlFileName := strings.Replace(rcdFileName, "wav", "xml", 1)
|
|
|
|
|
+ xmlFilePath := path + xmlFileName
|
|
|
|
|
+
|
|
|
|
|
+ err := active.GenerateXML(xmlFilePath)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ lfshook.NewLogger().Infof("Generate recording XML err:%+v", err)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
} else {
|
|
} else {
|
|
|
lfshook.NewLogger().Infof("No files to upload!!!")
|
|
lfshook.NewLogger().Infof("No files to upload!!!")
|
|
|
break
|
|
break
|
|
@@ -312,7 +325,7 @@ func HandleAMI(event map[string]string) {
|
|
|
//SetPadTimer()
|
|
//SetPadTimer()
|
|
|
alstatus.PaStatus("", "PAD", "end")
|
|
alstatus.PaStatus("", "PAD", "end")
|
|
|
priority.PADStart = 0
|
|
priority.PADStart = 0
|
|
|
- priority.PADTMSStart = 0
|
|
|
|
|
|
|
+ //priority.PADTMSStart = 0
|
|
|
|
|
|
|
|
//clean confbridge
|
|
//clean confbridge
|
|
|
//PAD-ICP
|
|
//PAD-ICP
|
|
@@ -396,6 +409,7 @@ func HandleAMI(event map[string]string) {
|
|
|
lfshook.NewLogger().Logger.Infof("=========Release PAD timer false ! ============")
|
|
lfshook.NewLogger().Logger.Infof("=========Release PAD timer false ! ============")
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ lfshook.NewLogger().Logger.Infof("=========Start PAD timer !======%d=======", active.PADTimeout)
|
|
|
//active.QueueTimer = time.AfterFunc(time.Duration(active.PADTimeout)*time.Second, func() { // check the PAD 30s timeout
|
|
//active.QueueTimer = time.AfterFunc(time.Duration(active.PADTimeout)*time.Second, func() { // check the PAD 30s timeout
|
|
|
active.QueueTimer = time.AfterFunc(30*time.Second, func() { // check the PAD 30s timeout
|
|
active.QueueTimer = time.AfterFunc(30*time.Second, func() { // check the PAD 30s timeout
|
|
|
//if both not active , return
|
|
//if both not active , return
|