|
|
@@ -31,7 +31,7 @@ func HandleAMI(event map[string]string) {
|
|
|
if event["UserEvent"] == "SetRecordFile" { //get record file name
|
|
|
alstatus.SendRecordFile(event["FILENAME"], event["RecordType"])
|
|
|
|
|
|
- } else if event["UserEvent"] == "CallType" && (event["Type"] == "PA" || event["Type"] == "CPA") { //PA; check manual PA priority
|
|
|
+ } else if event["UserEvent"] == "CallType" && (event["Type"] == "PA" || event["Type"] == "CPA") { //PA start; check manual PA priority
|
|
|
//check active signal before PA
|
|
|
if active.CabNum == "1" && !active.Actived && event["CallerIDNum"] == "2311" {
|
|
|
Hangup(event["CallerIDNum"])
|
|
|
@@ -43,22 +43,40 @@ func HandleAMI(event map[string]string) {
|
|
|
if utils.IsICP(event["CallerIDNum"]) {
|
|
|
if priority.CheckPriority("ManuPa") {
|
|
|
//hangup others if priority is higher
|
|
|
- HangupRunningTask()
|
|
|
+ HangupRunningTask("PA") //PA interrupt other
|
|
|
} else {
|
|
|
Hangup(event["CallerIDNum"]) //lowwer priority ,hangup caller
|
|
|
}
|
|
|
+
|
|
|
} else if utils.IsIO(event["CallerIDNum"]) { // CPA
|
|
|
if priority.CheckPriority("CPA") {
|
|
|
//hangup others if priority is higher
|
|
|
- HangupRunningTask()
|
|
|
+ if priority.RunningType != "C2C" {
|
|
|
+ HangupRunningTask("CPA") //CPA interrupt other
|
|
|
+ } else {
|
|
|
+ //call to ICP , can not stop
|
|
|
+ lfshook.NewLogger().Info("==Running CabCab , CPA start call ICP(ICP is on the phone)=====")
|
|
|
+ }
|
|
|
} else {
|
|
|
Hangup(event["CallerIDNum"]) //lowwer priority ,hangup caller
|
|
|
}
|
|
|
}
|
|
|
- } else if event["UserEvent"] == "CallType" && event["Type"] == "C2C" { //CabCab; check cab cab priority
|
|
|
+ } else if event["UserEvent"] == "CallType" && event["Type"] == "C2C" { //CabCab start; check cab cab priority
|
|
|
|
|
|
if priority.CheckPriority("CabCab") {
|
|
|
- HangupRunningTask()
|
|
|
+
|
|
|
+ if priority.RunningType == "PA" || priority.RunningType == "PAD-ICP" {
|
|
|
+ HangupRunningTask("C2C") //C2C interrupt other
|
|
|
+ } else {
|
|
|
+ //Hangup the other ICP
|
|
|
+ if event["CallerIDNum"] == "2311" {
|
|
|
+ Hangup("2381")
|
|
|
+ } else {
|
|
|
+ Hangup("2311")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else { // hangup caller; C2C start failed
|
|
|
+ Hangup(event["CallerIDNum"])
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -72,34 +90,27 @@ func HandleAMI(event map[string]string) {
|
|
|
case "SoftHangupRequest": //pre-recored broadcast end
|
|
|
//lfshook.NewLogger().Infof("=========%s", event["Event"])
|
|
|
if event["CallerIDName"] == "EMG" && event["Exten"] == "0502" { // EMG broadcast hangup
|
|
|
- priority.RunningTypePriority = 0
|
|
|
- priority.RunningType = ""
|
|
|
-
|
|
|
+ priority.CleanPriorityTag()
|
|
|
alstatus.PaStatus(event["CallerIDName"], "EMG", "end")
|
|
|
|
|
|
} else if event["CallerIDName"] == "STN" && event["Exten"] == "0503" {
|
|
|
- priority.RunningTypePriority = 0
|
|
|
- priority.RunningType = ""
|
|
|
- priority.SpecialVoice = 0
|
|
|
+ priority.CleanPriorityTag()
|
|
|
alstatus.PaStatus(event["CallerIDName"], "STN", "end")
|
|
|
|
|
|
} else if event["CallerIDName"] == "DCS" && event["Exten"] == "0504" {
|
|
|
- priority.RunningTypePriority = 0
|
|
|
- priority.RunningType = ""
|
|
|
+ priority.CleanPriorityTag()
|
|
|
alstatus.PaStatus(event["CallerIDName"], "DCS", "end")
|
|
|
|
|
|
} else if event["CallerIDName"] == "SPC" && event["Exten"] == "0505" {
|
|
|
- priority.RunningTypePriority = 0
|
|
|
- priority.RunningType = ""
|
|
|
+ priority.CleanPriorityTag()
|
|
|
alstatus.PaStatus(event["CallerIDName"], "SPC", "end")
|
|
|
|
|
|
} else if event["CallerIDName"] == "CHK" && event["Exten"] == "0510" {
|
|
|
- priority.RunningTypePriority = 0
|
|
|
- priority.RunningType = ""
|
|
|
+ priority.CleanPriorityTag()
|
|
|
alstatus.PaStatus(event["CallerIDName"], "CHK", "end")
|
|
|
+
|
|
|
} else if event["CallerIDName"] == "VOL" && event["Exten"] == "0510" {
|
|
|
- priority.RunningTypePriority = 0
|
|
|
- priority.RunningType = ""
|
|
|
+ priority.CleanPriorityTag()
|
|
|
alstatus.PaStatus(event["CallerIDName"], "VOL", "end")
|
|
|
}
|
|
|
|
|
|
@@ -107,49 +118,53 @@ func HandleAMI(event map[string]string) {
|
|
|
|
|
|
//lfshook.NewLogger().Infof("=========%s", event["Event"])
|
|
|
if utils.IsPACU(event["CallerIDNum"]) && utils.IsICP(event["ConnectedLineNum"]) { // TMS-ICP answer PAD, hangup
|
|
|
+ HangupAllLocalChan()
|
|
|
res, _ := QueueStatus("0300", "") // check ICP queue ,if empty PAD end
|
|
|
if res.Calls == "0" {
|
|
|
- priority.ICPAnswer = 0
|
|
|
- priority.RunningTypePriority = 0
|
|
|
+ priority.CleanPriorityTag()
|
|
|
alstatus.PaStatus(event["CallerIDNum"], "PAD", "end")
|
|
|
+ //priority.ICPAnswer = 0
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if utils.IsPAIU(event["CallerIDNum"]) && utils.IsICP(event["ConnectedLineNum"]) { // TMS-ICP answer PAD(PACU not availabe), hangup
|
|
|
+ HangupAllLocalChan()
|
|
|
res, _ := QueueStatus("0300", "") // check ICP queue ,if empty PAD end
|
|
|
if res.Calls == "0" {
|
|
|
- priority.ICPAnswer = 0
|
|
|
- priority.RunningTypePriority = 0
|
|
|
+ priority.CleanPriorityTag()
|
|
|
alstatus.PaStatus(event["CallerIDNum"], "PAD", "end")
|
|
|
+ //priority.ICPAnswer = 0
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (event["CallerIDNum"] == "ani1" || event["CallerIDNum"] == "ani8") && utils.IsICP(event["ConnectedLineNum"]) { // ICP answer PAD, hangup
|
|
|
+ HangupAllLocalChan()
|
|
|
res, _ := QueueStatus("0300", "") // check ICP queue ,if empty PAD end
|
|
|
if res.Calls == "0" {
|
|
|
- priority.ICPAnswer = 0
|
|
|
- priority.RunningTypePriority = 0
|
|
|
+ priority.CleanPriorityTag()
|
|
|
alstatus.PaStatus(event["CallerIDNum"], "PAD", "end")
|
|
|
+ //priority.ICPAnswer = 0
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//OCC answer PAD, hangup, redirect the next PAD to OCC
|
|
|
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
|
|
|
- priority.OCCAnswer = 0
|
|
|
- priority.RunningTypePriority = 0
|
|
|
+ priority.CleanPriorityTag()
|
|
|
alstatus.OccPad("end")
|
|
|
+ //priority.OCCAnswer = 0
|
|
|
break
|
|
|
} else { //OCC queue is not empty
|
|
|
-
|
|
|
- if active.CabNum == "1" && active.Actived && alstatus.GetExtenStat("1411") == "Idle" { //check active and OCC status
|
|
|
+ HangupAllLocalChan()
|
|
|
+ if active.CabNum == "1" && active.Actived && ExtenStatus("1411") == "Idle" { //check active and OCC status
|
|
|
Dial("0401", "0512", "pad-rule-pacus-occ", "ano1", event["CallerIDNum"], "1") // PACUs dial OCC1
|
|
|
//goto ConfbridgeJoin, OCC1 answer PAD
|
|
|
- } else if active.CabNum == "8" && active.Actived && alstatus.GetExtenStat("1481") == "Idle" {
|
|
|
+ } else if active.CabNum == "8" && active.Actived && ExtenStatus("1481") == "Idle" {
|
|
|
Dial("0401", "0512", "pad-rule-pacus-occ", "ano8", event["CallerIDNum"], "8") // PACUs dial OCC8
|
|
|
//goto ConfbridgeJoin, OCC8 answer PAD
|
|
|
}
|
|
|
@@ -160,7 +175,7 @@ func HandleAMI(event map[string]string) {
|
|
|
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
|
|
|
alstatus.AlarmStatus(event["CallerIDNum"], "queue") //send status to STC
|
|
|
- go RedirectInQueue(event["CallerIDNum"], "0301", "queues-occ", "")
|
|
|
+ go RedirectInQueue(event["CallerIDNum"], "0301", "queues-occ", event["CallerIDNum"])
|
|
|
break
|
|
|
}
|
|
|
|
|
|
@@ -182,7 +197,7 @@ func HandleAMI(event map[string]string) {
|
|
|
}
|
|
|
|
|
|
for _, caller := range resCaller.Entrys {
|
|
|
- go RedirectInQueue(caller.CallerIDNum, "0301", "queues-occ", "") // redirect All ICP-PAD redirect to OCC queue
|
|
|
+ go RedirectInQueue(caller.CallerIDNum, "0301", "queues-occ", caller.CallerIDNum) // redirect All ICP-PAD redirect to OCC queue
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -195,18 +210,19 @@ 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 active.CabNum == "1" && active.Actived && alstatus.GetExtenStat("1411") == "Idle" { //check active and OCC status
|
|
|
- priority.OCCAnswer = 1
|
|
|
- alstatus.OccPad("start")
|
|
|
- priority.RunningTypePriority, _ = strconv.Atoi(priority.Priority.PADOCC) //Set running priority
|
|
|
- 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 && alstatus.GetExtenStat("1481") == "Idle" {
|
|
|
+ if priority.CheckPriority("PAD-OCC") {
|
|
|
+ HangupRunningTask("PAD-OCC") //PAD-OCC interrupt other
|
|
|
priority.OCCAnswer = 1
|
|
|
- priority.RunningTypePriority, _ = strconv.Atoi(priority.Priority.PADOCC) //Set running priority
|
|
|
- alstatus.OccPad("start")
|
|
|
- Dial("0401", "0512", "pad-rule-pacus-occ", "ano8", event["CallerIDNum"], "8") // PACUs dial OCC8
|
|
|
- //Goto event=ConfbridgeJoin;OCC answer PAD
|
|
|
+
|
|
|
+ if active.CabNum == "1" && active.Actived && ExtenStatus("1411") == "Idle" { //check active and OCC status
|
|
|
+ alstatus.OccPad("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" {
|
|
|
+ alstatus.OccPad("start")
|
|
|
+ Dial("0401", "0512", "pad-rule-pacus-occ", "ano8", event["CallerIDNum"], "8") // PACUs dial OCC8
|
|
|
+ //Goto event=ConfbridgeJoin;OCC answer PAD
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -310,7 +326,7 @@ func HandleAMI(event map[string]string) {
|
|
|
if event["ConnectedLineNum"] == "ano1" && event["Exten"] == "0512" { //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)
|
|
|
@@ -321,7 +337,7 @@ func HandleAMI(event map[string]string) {
|
|
|
if event["ConnectedLineNum"] == "ano8" && event["Exten"] == "0512" { //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)
|
|
|
@@ -341,16 +357,12 @@ func HandleAMI(event map[string]string) {
|
|
|
lfshook.NewLogger().Infof("=========%s", event["Event"])
|
|
|
if utils.IsICP(event["CallerIDNum"]) && event["Exten"] == "0500" { // PA end
|
|
|
lfshook.NewLogger().Infof("====PA status =====%s", "end")
|
|
|
- priority.RunningTypePriority = 0
|
|
|
- priority.RunningType = ""
|
|
|
- priority.RunningPATaskChan = ""
|
|
|
+ priority.CleanPriorityTag()
|
|
|
alstatus.PaStatus(event["CallerIDNum"], "PA", "end")
|
|
|
}
|
|
|
if utils.IsIO(event["CallerIDNum"]) && event["Exten"] == "0501" { //CPA end
|
|
|
lfshook.NewLogger().Infof("====CPA status =====%s", "end")
|
|
|
- priority.RunningTypePriority = 0
|
|
|
- priority.RunningType = ""
|
|
|
- priority.RunningPATaskChan = ""
|
|
|
+ priority.CleanPriorityTag()
|
|
|
alstatus.PaStatus(event["CallerIDNum"], "CPA", "end")
|
|
|
}
|
|
|
|
|
|
@@ -378,9 +390,6 @@ func HandleAMI(event map[string]string) {
|
|
|
//update extension status
|
|
|
if event["StatusText"] == "Idle" || event["StatusText"] == "Unavailable" {
|
|
|
if len(event["Exten"]) > 3 && utils.IsPAIU(event["Exten"]) {
|
|
|
- //alstatus.ExtenStatMap[event["Exten"]] = event["StatusText"]
|
|
|
- alstatus.SetExtenStat(event["Exten"], event["StatusText"])
|
|
|
- //lfshook.NewLogger().Infof("======Extension Map : %+v==============", alstatus.ExtenStatMap)
|
|
|
alstatus.AlarmStatus(event["Exten"], event["StatusText"]) // PAD idle + unavailable
|
|
|
}
|
|
|
}
|