|
|
@@ -19,11 +19,7 @@ import (
|
|
|
var AminInstance *amigo.Amigo
|
|
|
|
|
|
func HandleAMI(event map[string]string) {
|
|
|
- //lfshook.NewLogger().Infof("===start======%s", event["Event"])
|
|
|
- //return if not actived
|
|
|
- if !active.Actived {
|
|
|
- return
|
|
|
- }
|
|
|
+ //lfshook.NewLogger().Infof("===start======%s", event["Event"]
|
|
|
|
|
|
switch event["Event"] {
|
|
|
|
|
|
@@ -34,14 +30,19 @@ func HandleAMI(event map[string]string) {
|
|
|
|
|
|
} else if event["UserEvent"] == "CallType" && (event["Type"] == "PA" || event["Type"] == "CPA") { //PA start; check manual PA priority
|
|
|
//check active signal before PA; hangup if not actived
|
|
|
- if active.CabNum == "1" && !active.Actived && event["CallerIDNum"] == "2311" {
|
|
|
- Hangup(event["CallerIDNum"])
|
|
|
- } else if active.CabNum == "8" && !active.Actived && event["CallerIDNum"] == "2381" {
|
|
|
- Hangup(event["CallerIDNum"])
|
|
|
- }
|
|
|
+ /* if active.ActivedCab == "1" && event["CallerIDNum"] == "2311" {
|
|
|
+ Hangup(event["CallerIDNum"])
|
|
|
+ } else if active.ActivedCab == "8" && event["CallerIDNum"] == "2381" {
|
|
|
+ Hangup(event["CallerIDNum"])
|
|
|
+ }*/
|
|
|
|
|
|
//PA & CPA interrupt others
|
|
|
if utils.IsICP(event["CallerIDNum"]) {
|
|
|
+
|
|
|
+ if active.ActivedCab == "" { //No active Signal on both side,Hangup caller
|
|
|
+ Hangup(event["CallerIDNum"])
|
|
|
+ }
|
|
|
+
|
|
|
if priority.CheckPriority("ManuPa") {
|
|
|
//hangup others if priority is higher
|
|
|
HangupRunningTask("PA") //PA interrupt other
|
|
|
@@ -53,9 +54,12 @@ func HandleAMI(event map[string]string) {
|
|
|
if priority.CheckPriority("CPA") {
|
|
|
|
|
|
//check active signal before CPA; hangup if not actived
|
|
|
- if active.CabNum == "1" && !active.Actived && event["CallerIDNum"] == "1411" {
|
|
|
- Hangup(event["CallerIDNum"])
|
|
|
- } else if active.CabNum == "8" && !active.Actived && event["CallerIDNum"] == "1481" {
|
|
|
+ /* if active.ActivedCab == "8" && event["CallerIDNum"] == "1411" {
|
|
|
+ Hangup(event["CallerIDNum"])
|
|
|
+ } else if active.ActivedCab == "1" && event["CallerIDNum"] == "1481" {
|
|
|
+ Hangup(event["CallerIDNum"])
|
|
|
+ }*/
|
|
|
+ if active.ActivedCab == "" { //No active Signal on both side,Hangup caller
|
|
|
Hangup(event["CallerIDNum"])
|
|
|
}
|
|
|
|
|
|
@@ -105,8 +109,9 @@ func HandleAMI(event map[string]string) {
|
|
|
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
|
|
|
- if res.Calls == "0" {
|
|
|
+ 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 {
|
|
|
@@ -116,7 +121,8 @@ func HandleAMI(event map[string]string) {
|
|
|
/*if priority.ResumeEmgPara.FileName != "" {
|
|
|
CheckEmgResume()
|
|
|
}*/
|
|
|
- //priority.ICPAnswer = 0
|
|
|
+ priority.ICPAnswer = 0
|
|
|
+ priority.OCCAnswer = 0
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
@@ -128,6 +134,7 @@ func HandleAMI(event map[string]string) {
|
|
|
if res.Calls == "0" { //OCC queue is empty
|
|
|
priority.CleanPriorityTag()
|
|
|
alstatus.OccPad("end")
|
|
|
+ priority.OCCAnswer = 0
|
|
|
|
|
|
if priority.ResumeEmgPara.FileName != "" {
|
|
|
time.Sleep(time.Second)
|
|
|
@@ -138,11 +145,11 @@ func HandleAMI(event map[string]string) {
|
|
|
} else { //OCC queue is not empty
|
|
|
HangupAllLocalChan()
|
|
|
|
|
|
- if active.CabNum == "1" && active.Actived && ExtenStatus("1411") == "Idle" { //check active and OCC status
|
|
|
+ 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
|
|
|
//goto ConfbridgeJoin, OCC1 answer PAD
|
|
|
- } else if active.CabNum == "8" && active.Actived && ExtenStatus("1481") == "Idle" {
|
|
|
+ } 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
|
|
|
@@ -161,28 +168,38 @@ func HandleAMI(event map[string]string) {
|
|
|
if utils.IsPAIU(event["CallerIDNum"]) && event["Queue"] == "0300" { // Alarm join the queue, PAD in the queue
|
|
|
alstatus.AlarmStatus(event["CallerIDNum"], "queue") //send status to STC
|
|
|
|
|
|
- time.AfterFunc(30*time.Second, func() { // check the PAD 30s timeout
|
|
|
- if priority.ICPAnswer == 0 { //ICP did not answer any
|
|
|
+ ICPQueue, err := QueueStatus("0300", "") // check ICP queue, get entries
|
|
|
+ if err != nil {
|
|
|
+ lfshook.NewLogger().Infof("==ICP=QueueStatus==%+v", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
+ 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=")
|
|
|
res, err := QueueStatus("0301", "") // check OCC queue , if empty OCC-PAD start
|
|
|
if err != nil {
|
|
|
lfshook.NewLogger().Infof("===OCC-QueueStatus==%+v", err)
|
|
|
return
|
|
|
}
|
|
|
- if res.Calls == "0" { // OCC queue empty
|
|
|
|
|
|
+ if res.Calls == "0" { // OCC queue empty
|
|
|
resCaller, err := QueueStatus("0300", "") // check ICP queue, get entries
|
|
|
if err != nil {
|
|
|
lfshook.NewLogger().Infof("==ICP=QueueStatus==%+v", err)
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
for _, caller := range resCaller.Entrys {
|
|
|
+ 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
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- })
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
break
|
|
|
}
|
|
|
|
|
|
@@ -191,21 +208,24 @@ func HandleAMI(event map[string]string) {
|
|
|
//PAD chanspy(WqE) OCC;
|
|
|
//ICPs chanspy(qE) PAD;
|
|
|
if utils.IsPAIU(event["CallerIDNum"]) && event["Queue"] == "0301" && priority.OCCAnswer == 0 { // The first PAD to OCC ,caller is PAD
|
|
|
+
|
|
|
if priority.CheckPriority("PAD-OCC") {
|
|
|
HangupRunningTask("PAD-OCC") //PAD-OCC interrupt other
|
|
|
priority.OCCAnswer = 1
|
|
|
|
|
|
- if active.CabNum == "1" && active.Actived && ExtenStatus("1411") == "Idle" { //check active and OCC status
|
|
|
+ if active.ActivedCab == "1" && ExtenStatus("1411") == "Idle" { //check active and OCC status
|
|
|
if priority.PADOccStart == 0 {
|
|
|
alstatus.OccPad("start")
|
|
|
priority.PADOccStart = 1
|
|
|
+ alstatus.PaStatus(event["CallerIDNum"], "PAD", "start")
|
|
|
}
|
|
|
Dial("0401", "0512", "pad-rule-pacus-occ", "ano1", event["CallerIDNum"], "1") // PACUs dial OCC1
|
|
|
//Goto event=ConfbridgeJoin;OCC answer PAD
|
|
|
- } else if active.CabNum == "8" && active.Actived && ExtenStatus("1481") == "Idle" {
|
|
|
+ } else if active.ActivedCab == "8" && ExtenStatus("1481") == "Idle" {
|
|
|
if priority.PADOccStart == 0 {
|
|
|
alstatus.OccPad("start")
|
|
|
priority.PADOccStart = 1
|
|
|
+ alstatus.PaStatus(event["CallerIDNum"], "PAD", "start")
|
|
|
}
|
|
|
Dial("0401", "0512", "pad-rule-pacus-occ", "ano8", event["CallerIDNum"], "8") // PACUs dial OCC8
|
|
|
//Goto event=ConfbridgeJoin;OCC answer PAD
|
|
|
@@ -288,7 +308,7 @@ func HandleAMI(event map[string]string) {
|
|
|
alstatus.PaStatus(event["CallerIDNum"], "CPA", "start")
|
|
|
priority.RunningPATaskChan = event["Channel"]
|
|
|
priority.RunningType = "CPA"
|
|
|
- break
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
//ICP answer PAD;
|
|
|
@@ -321,7 +341,7 @@ func HandleAMI(event map[string]string) {
|
|
|
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")
|
|
|
- priority.OCCAnswer = 1
|
|
|
+
|
|
|
priority.RunningPATaskChan = event["Channel"]
|
|
|
priority.RunningType = "PAD-OCC"
|
|
|
priority.RunningTypePriority, _ = strconv.Atoi(priority.Priority.PADOCC)
|
|
|
@@ -343,7 +363,7 @@ func HandleAMI(event map[string]string) {
|
|
|
if event["ConnectedLineNum"] == "ano8" && event["Exten"] == "0512" && utils.IsPAIU(event["ConnectedLineName"]) { //PAD ansered by OCC8; PACUs connected IO8
|
|
|
lfshook.NewLogger().Infof("====PAD answered by OCC8:%s=====", event["ConnectedLineName"])
|
|
|
alstatus.AlarmStatus(event["ConnectedLineName"], "connect")
|
|
|
- priority.OCCAnswer = 1
|
|
|
+
|
|
|
priority.RunningPATaskChan = event["Channel"]
|
|
|
priority.RunningType = "PAD-OCC"
|
|
|
priority.RunningTypePriority, _ = strconv.Atoi(priority.Priority.PADOCC)
|
|
|
@@ -470,10 +490,10 @@ func HandleAMI(event map[string]string) {
|
|
|
priority.RunningPATaskChan = event["Channel"]
|
|
|
priority.RunningType = "PAD-TMS"
|
|
|
priority.RunningTypePriority, _ = strconv.Atoi(priority.Priority.PADTMS)
|
|
|
- if active.CabNum == "1" && active.Actived {
|
|
|
+ if active.ActivedCab == "1" {
|
|
|
go RedirectInQueue(event["CallerIDName"], "2311", "chanspy-rule-whisper", "") //PAD chanspy(EqW) ICP1
|
|
|
go Dial("0403", event["CallerIDName"], "chanspy-rule", "2381", "2381", "8") //ICP8---chanspy----PAD
|
|
|
- } else if active.CabNum == "8" && active.Actived {
|
|
|
+ } else if active.ActivedCab == "8" {
|
|
|
go RedirectInQueue(event["CallerIDName"], "2381", "chanspy-rule-whisper", "") //PAD chanspy(EqW) ICP8
|
|
|
go Dial("0403", event["CallerIDName"], "chanspy-rule", "2311", "2311", "1") //ICP1---chanspy----PAD
|
|
|
}
|