|
|
@@ -8,6 +8,7 @@ import (
|
|
|
"pbx-api-gin/pkg/lfshook"
|
|
|
"pbx-api-gin/pkg/utils"
|
|
|
"strconv"
|
|
|
+ "strings"
|
|
|
"time"
|
|
|
|
|
|
"github.com/sirupsen/logrus"
|
|
|
@@ -97,7 +98,7 @@ func HandleAMI(event map[string]string) {
|
|
|
lfshook.NewLogger().Infof("=========%s", event["Event"])
|
|
|
|
|
|
//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"]) {
|
|
|
+ if (event["CallerIDNum"] == "ano1" || event["CallerIDNum"] == "ano8") && utils.IsIO(event["ConnectedLineNum"]) {
|
|
|
HangupAllLocalChan()
|
|
|
res, _ := QueueStatus("0301", "") // check OCC queue ,if empty PAD end
|
|
|
if res.Calls == "0" { //OCC queue is empty
|
|
|
@@ -115,12 +116,12 @@ func HandleAMI(event map[string]string) {
|
|
|
|
|
|
if active.ActivedCab == "1" && ExtenStatus("1411") == "Idle" { //check active and OCC status
|
|
|
time.Sleep(time.Second)
|
|
|
- Dial("0401", "0512", "pad-rule-pacus-occ", "ano1", event["CallerIDName"], "1") // PACUs dial OCC1
|
|
|
+ Dial("0401", "0512", "pad-rule-pacus-occ", "ano1", "ano1", "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
|
|
|
+ Dial("0401", "0512", "pad-rule-pacus-occ", "ano8", "ano8", "8") // PACUs dial OCC8
|
|
|
//goto ConfbridgeJoin, OCC8 answer PAD
|
|
|
break
|
|
|
}
|
|
|
@@ -187,6 +188,7 @@ func HandleAMI(event map[string]string) {
|
|
|
priority.ICPAnswer = 0
|
|
|
lfshook.NewLogger().Infof("====Redirect to 0301 entry:%s===", caller.CallerIDNum)
|
|
|
go RedirectInQueue(caller.CallerIDNum, "0301", "queues-occ", caller.CallerIDNum) // redirect All ICP-PAD redirect to OCC queue
|
|
|
+ time.Sleep(time.Microsecond * 200) //200 ms delay
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
@@ -214,7 +216,7 @@ func HandleAMI(event map[string]string) {
|
|
|
priority.PADStart = 1
|
|
|
}
|
|
|
}
|
|
|
- Dial("0401", "0512", "pad-rule-pacus-occ", "ano1", event["CallerIDNum"], "1") // PACUs dial OCC1
|
|
|
+ Dial("0401", "0512", "pad-rule-pacus-occ", "ano1", "ano1", "1") // PACUs dial OCC1
|
|
|
//Goto event=ConfbridgeJoin;OCC answer PAD
|
|
|
} else if active.ActivedCab == "8" && ExtenStatus("1481") == "Idle" {
|
|
|
if priority.PADOccStart == 0 {
|
|
|
@@ -225,14 +227,16 @@ func HandleAMI(event map[string]string) {
|
|
|
priority.PADStart = 1
|
|
|
}
|
|
|
}
|
|
|
- Dial("0401", "0512", "pad-rule-pacus-occ", "ano8", event["CallerIDNum"], "8") // PACUs dial OCC8
|
|
|
+ Dial("0401", "0512", "pad-rule-pacus-occ", "ano8", "ano8", "8") // PACUs dial OCC8
|
|
|
//Goto event=ConfbridgeJoin;OCC answer PAD
|
|
|
}
|
|
|
+ } else {
|
|
|
+ lfshook.NewLogger().Infof("====PAD-OCC Priority false===")
|
|
|
}
|
|
|
}
|
|
|
|
|
|
case "ConfbridgeJoin":
|
|
|
- lfshook.NewLogger().Infof("=========%s", event["Event"])
|
|
|
+ lfshook.NewLogger().Infof("=========%+v", event["Event"])
|
|
|
|
|
|
//set priority and send PA status msg
|
|
|
switch event["CallerIDName"] {
|
|
|
@@ -335,10 +339,9 @@ func HandleAMI(event map[string]string) {
|
|
|
break
|
|
|
}
|
|
|
|
|
|
- //OCC answer PAD;
|
|
|
- if event["ConnectedLineNum"] == "ano1" && event["Exten"] == "0512" && utils.IsPAIU(event["ConnectedLineName"]) { //PAD answered by OCC; PACUs connected IO1
|
|
|
- lfshook.NewLogger().Infof("====PAD answered by OCC1:%s=====", event["ConnectedLineName"])
|
|
|
- alstatus.AlarmStatus(event["ConnectedLineName"], "connect")
|
|
|
+ //OCC1 answer PAD;
|
|
|
+ if utils.IsIO(event["CallerIDNum"]) && event["Exten"] == "0512" && event["ConnectedLineName"] == "ano1" { //PAD answered by OCC1; PACUs connected IO1
|
|
|
+ lfshook.NewLogger().Infof("====PAD answered by OCC1:====")
|
|
|
|
|
|
priority.RunningPATaskChan = event["Channel"]
|
|
|
priority.RunningType = "PAD-OCC"
|
|
|
@@ -349,8 +352,18 @@ func HandleAMI(event map[string]string) {
|
|
|
lfshook.NewLogger().Infof("===OCC-QueueStatus==%+v", err)
|
|
|
return
|
|
|
}
|
|
|
- PADChan := res.Entrys[0].Channel
|
|
|
+
|
|
|
+ PADChan := ""
|
|
|
+ for _, chanEntry := range res.Entrys {
|
|
|
+ lfshook.NewLogger().Infof("====PAD answered by OCC1 pos:%s===chan:%s=", chanEntry.Position, chanEntry.Channel)
|
|
|
+ if chanEntry.Position == "1" {
|
|
|
+ PADChan = chanEntry.Channel
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if PADChan != "" {
|
|
|
+ alstatus.AlarmStatus(strings.Split(strings.Split(res.Entrys[0].Channel, "/")[1], "-")[0], "connect")
|
|
|
go RedirectInQueue(PADChan, "1411", "chanspy-rule-whisper", event["ConnectedLineName"]) //PAD chanspy(EqW) IO1
|
|
|
} else {
|
|
|
lfshook.NewLogger().Infof("===OCC-QueueStatus==PADCchan NULL")
|
|
|
@@ -358,9 +371,10 @@ func HandleAMI(event map[string]string) {
|
|
|
//goto event=ChanSpyStart; ICPs spy PAD
|
|
|
break
|
|
|
}
|
|
|
- if event["ConnectedLineNum"] == "ano8" && event["Exten"] == "0512" && utils.IsPAIU(event["ConnectedLineName"]) { //PAD ansered by OCC8; PACUs connected IO8
|
|
|
+
|
|
|
+ //OCC8 answer PAD;
|
|
|
+ if utils.IsIO(event["CallerIDNum"]) && event["Exten"] == "0512" && event["ConnectedLineName"] == "ano8" { //PAD ansered by OCC8; PACUs connected IO8
|
|
|
lfshook.NewLogger().Infof("====PAD answered by OCC8:%s=====", event["ConnectedLineName"])
|
|
|
- alstatus.AlarmStatus(event["ConnectedLineName"], "connect")
|
|
|
|
|
|
priority.RunningPATaskChan = event["Channel"]
|
|
|
priority.RunningType = "PAD-OCC"
|
|
|
@@ -371,9 +385,18 @@ func HandleAMI(event map[string]string) {
|
|
|
lfshook.NewLogger().Infof("===OCC-QueueStatus==%+v", err)
|
|
|
return
|
|
|
}
|
|
|
- PADChan := res.Entrys[0].Channel
|
|
|
+
|
|
|
+ PADChan := ""
|
|
|
+ for _, chanEntry := range res.Entrys {
|
|
|
+ lfshook.NewLogger().Infof("====PAD answered by OCC8 pos:%s===chan:%s=", chanEntry.Position, chanEntry.Channel)
|
|
|
+ if chanEntry.Position == "1" {
|
|
|
+ PADChan = chanEntry.Channel
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
if PADChan != "" {
|
|
|
+ alstatus.AlarmStatus(strings.Split(strings.Split(res.Entrys[0].Channel, "/")[1], "-")[0], "connect")
|
|
|
go RedirectInQueue(PADChan, "1481", "chanspy-rule-whisper", event["ConnectedLineName"]) //PAD chanspy(EqW) IO8
|
|
|
} else {
|
|
|
lfshook.NewLogger().Infof("===OCC-QueueStatus==PADCchan NULL")
|