|
|
@@ -8,7 +8,6 @@ import (
|
|
|
"pbx-api-gin/pkg/lfshook"
|
|
|
"pbx-api-gin/pkg/utils"
|
|
|
"strconv"
|
|
|
- "strings"
|
|
|
"time"
|
|
|
|
|
|
"github.com/sirupsen/logrus"
|
|
|
@@ -93,39 +92,9 @@ func HandleAMI(event map[string]string) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- case "Newchannel":
|
|
|
- //lfshook.NewLogger().Infof("=========%s", event["Event"])
|
|
|
- if utils.IsPAIU(event["CallerIDNum"]) && event["Exten"] == "0300" { // Alarm dial queue start; PAD dialing
|
|
|
- if priority.PADStart == 0 {
|
|
|
- priority.PADStart = 1
|
|
|
- alstatus.PaStatus(event["CallerIDNum"], "PAD", "start")
|
|
|
- }
|
|
|
-
|
|
|
- alstatus.AlarmStatus(event["CallerIDNum"], "dial")
|
|
|
- }
|
|
|
-
|
|
|
case "Hangup":
|
|
|
|
|
|
lfshook.NewLogger().Infof("=========%s", event["Event"])
|
|
|
- if utils.IsPAIU(event["CallerIDNum"]) && !strings.Contains(event["Channel"], "Local") { // PAD hangup, check if PAD all end, send PAD end status
|
|
|
-
|
|
|
- res, _ := QueueStatus("0300", "") // check ICP queue ,if empty PAD end
|
|
|
- res1, _ := QueueStatus("0301", "") // check OCC queue ,if empty PAD end
|
|
|
- if res.Calls == "0" && res1.Calls == "0" {
|
|
|
- //priority.CleanPriorityTag()
|
|
|
- //HangupAllLocalChan()
|
|
|
- if priority.PADStart == 1 {
|
|
|
- alstatus.PaStatus(event["CallerIDNum"], "PAD", "end")
|
|
|
- priority.PADStart = 0
|
|
|
- }
|
|
|
- /*if priority.ResumeEmgPara.FileName != "" {
|
|
|
- CheckEmgResume()
|
|
|
- }*/
|
|
|
- priority.ICPAnswer = 0
|
|
|
- priority.OCCAnswer = 0
|
|
|
- break
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
//OCC answer PAD, hangup, redirect the next PAD to OCC
|
|
|
if (event["CallerIDNum"] == "ano1" || event["CallerIDNum"] == "ano8") && utils.IsIO(event["ConnectedLineNum"]) && utils.IsPAIU(event["CallerIDName"]) {
|
|
|
@@ -140,7 +109,6 @@ func HandleAMI(event map[string]string) {
|
|
|
time.Sleep(time.Second)
|
|
|
CheckEmgResume()
|
|
|
}
|
|
|
-
|
|
|
break
|
|
|
} else { //OCC queue is not empty
|
|
|
HangupAllLocalChan()
|
|
|
@@ -149,14 +117,38 @@ func HandleAMI(event map[string]string) {
|
|
|
time.Sleep(time.Second)
|
|
|
Dial("0401", "0512", "pad-rule-pacus-occ", "ano1", event["CallerIDName"], "1") // PACUs dial OCC1
|
|
|
//goto ConfbridgeJoin, OCC1 answer PAD
|
|
|
+ break
|
|
|
} else if active.ActivedCab == "8" && ExtenStatus("1481") == "Idle" {
|
|
|
time.Sleep(time.Second)
|
|
|
Dial("0401", "0512", "pad-rule-pacus-occ", "ano8", event["CallerIDName"], "8") // PACUs dial OCC8
|
|
|
//goto ConfbridgeJoin, OCC8 answer PAD
|
|
|
+ break
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if utils.IsPAIU(event["CallerIDNum"]) { // PAD hangup, check if PAD all end, send PAD end status
|
|
|
+
|
|
|
+ res, _ := QueueStatus("0300", "") // check ICP queue ,if empty PAD end
|
|
|
+ res1, _ := QueueStatus("0301", "") // check OCC queue ,if empty PAD end
|
|
|
+
|
|
|
+ lfshook.NewLogger().Infof("==calls:%s===calls1:%s====", res.Calls, res1.Calls)
|
|
|
+ if res.Calls == "0" && res1.Calls == "0" {
|
|
|
+ //priority.CleanPriorityTag()
|
|
|
+ //HangupAllLocalChan()
|
|
|
+ if priority.PADStart == 1 {
|
|
|
+ alstatus.PaStatus(event["CallerIDNum"], "PAD", "end")
|
|
|
+ priority.PADStart = 0
|
|
|
+ }
|
|
|
+ /*if priority.ResumeEmgPara.FileName != "" {
|
|
|
+ CheckEmgResume()
|
|
|
+ }*/
|
|
|
+ priority.ICPAnswer = 0
|
|
|
+ priority.OCCAnswer = 0
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
case "QueueCallerJoin":
|
|
|
lfshook.NewLogger().Infof("=========%s", event["Event"])
|
|
|
if priority.OCCAnswer == 1 && event["Queue"] == "0300" { //New PAD Goto the OCC queue in the first time, if OCC answered
|
|
|
@@ -175,10 +167,10 @@ func HandleAMI(event map[string]string) {
|
|
|
}
|
|
|
|
|
|
if priority.ICPAnswer == 0 && ICPQueue.Calls == "1" { //ICP did not answer any first call to the ICP queue ; Ready to Set Occ Queue Timer
|
|
|
- lfshook.NewLogger().Infof("====SET TM===calls:%s", ICPQueue.Calls)
|
|
|
+
|
|
|
active.QueueTimer = time.AfterFunc(30*time.Second, func() { // check the PAD 30s timeout
|
|
|
|
|
|
- lfshook.NewLogger().Infof("==Afterfunc to=OCC-QueueStatus=")
|
|
|
+ //lfshook.NewLogger().Infof("==Afterfunc to=OCC-QueueStatus=")
|
|
|
res, err := QueueStatus("0301", "") // check OCC queue , if empty OCC-PAD start
|
|
|
if err != nil {
|
|
|
lfshook.NewLogger().Infof("===OCC-QueueStatus==%+v", err)
|
|
|
@@ -217,7 +209,10 @@ func HandleAMI(event map[string]string) {
|
|
|
if priority.PADOccStart == 0 {
|
|
|
alstatus.OccPad("start")
|
|
|
priority.PADOccStart = 1
|
|
|
- alstatus.PaStatus(event["CallerIDNum"], "PAD", "start")
|
|
|
+ if priority.PADStart == 0 {
|
|
|
+ alstatus.PaStatus(event["CallerIDNum"], "PAD", "start")
|
|
|
+ priority.PADStart = 1
|
|
|
+ }
|
|
|
}
|
|
|
Dial("0401", "0512", "pad-rule-pacus-occ", "ano1", event["CallerIDNum"], "1") // PACUs dial OCC1
|
|
|
//Goto event=ConfbridgeJoin;OCC answer PAD
|
|
|
@@ -225,7 +220,10 @@ func HandleAMI(event map[string]string) {
|
|
|
if priority.PADOccStart == 0 {
|
|
|
alstatus.OccPad("start")
|
|
|
priority.PADOccStart = 1
|
|
|
- alstatus.PaStatus(event["CallerIDNum"], "PAD", "start")
|
|
|
+ if priority.PADStart == 0 {
|
|
|
+ alstatus.PaStatus(event["CallerIDNum"], "PAD", "start")
|
|
|
+ priority.PADStart = 1
|
|
|
+ }
|
|
|
}
|
|
|
Dial("0401", "0512", "pad-rule-pacus-occ", "ano8", event["CallerIDNum"], "8") // PACUs dial OCC8
|
|
|
//Goto event=ConfbridgeJoin;OCC answer PAD
|