|
@@ -19,7 +19,7 @@ var AminInstance *amigo.Amigo
|
|
|
//type Operation func(src, dst string, whisper, bargein bool)
|
|
//type Operation func(src, dst string, whisper, bargein bool)
|
|
|
|
|
|
|
|
func HandleAMI(event map[string]string) {
|
|
func HandleAMI(event map[string]string) {
|
|
|
-
|
|
|
|
|
|
|
+ lfshook.NewLogger().Infof("===start======%s", event["Event"])
|
|
|
//return if not actived
|
|
//return if not actived
|
|
|
if !active.Actived {
|
|
if !active.Actived {
|
|
|
return
|
|
return
|
|
@@ -79,26 +79,11 @@ func HandleAMI(event map[string]string) {
|
|
|
case "QueueCallerLeave": // Alarm timeout , redirect to OCC
|
|
case "QueueCallerLeave": // Alarm timeout , redirect to OCC
|
|
|
|
|
|
|
|
if utils.IsPAIU(event["CallerIDNum"]) { // caller is PAD
|
|
if utils.IsPAIU(event["CallerIDNum"]) { // caller is PAD
|
|
|
- var infoExt model.Extension
|
|
|
|
|
- PacuNum := utils.GetPacuByPad(event["CallerIDNum"])
|
|
|
|
|
-
|
|
|
|
|
- _, er := mysql.DBOrmInstance.Where("exten = ?", PacuNum).Get(&infoExt)
|
|
|
|
|
- if er != nil {
|
|
|
|
|
- lfshook.NewLogger().Logger.Infof("update special voice to exten err : %+v", er.Error())
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- if infoExt.Status == "Idle" { //check PACU status
|
|
|
|
|
- if active.CabNum == "1" && active.Actived {
|
|
|
|
|
- Dial("0401", PacuNum, "default", PacuNum, event["CallerIDNum"], "1") // PACU dial OCC1
|
|
|
|
|
- } else if active.CabNum == "8" && active.Actived {
|
|
|
|
|
- Dial("0401", PacuNum, "default", PacuNum, event["CallerIDNum"], "8") // PACU dial OCC8
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- if active.CabNum == "1" && active.Actived {
|
|
|
|
|
- RedirectInQueue(event["CallerIDNum"], "0401", "default", "1") // PAD dial OCC1
|
|
|
|
|
- } else if active.CabNum == "8" && active.Actived {
|
|
|
|
|
- RedirectInQueue(event["CallerIDNum"], "0401", "default", "8") // PAD dial OCC8
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if active.CabNum == "1" && active.Actived {
|
|
|
|
|
+ Dial("0401", "0511", "pad-rule-cab1", "ano-1", event["CallerIDNum"], "1") // PACUs dial OCC1
|
|
|
|
|
+ } else if active.CabNum == "8" && active.Actived {
|
|
|
|
|
+ Dial("0401", "0512", "pad-rule-cab8", "ano-8", event["CallerIDNum"], "8") // PACUs dial OCC8
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -108,18 +93,30 @@ func HandleAMI(event map[string]string) {
|
|
|
lfshook.NewLogger().Infof("====PA status:%s=====", "start")
|
|
lfshook.NewLogger().Infof("====PA status:%s=====", "start")
|
|
|
alstatus.PaStatus(event["CallerIDNum"], "PA", "start")
|
|
alstatus.PaStatus(event["CallerIDNum"], "PA", "start")
|
|
|
}
|
|
}
|
|
|
- if utils.IsIO(event["CallerIDNum"]) && event["Exten"] == "0500" { //CPA start
|
|
|
|
|
|
|
+ if utils.IsIO(event["CallerIDNum"]) && event["Exten"] == "0501" { //CPA start
|
|
|
lfshook.NewLogger().Infof("====CPA status:%s=====", "start")
|
|
lfshook.NewLogger().Infof("====CPA status:%s=====", "start")
|
|
|
alstatus.PaStatus(event["CallerIDNum"], "CPA", "start")
|
|
alstatus.PaStatus(event["CallerIDNum"], "CPA", "start")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if utils.IsIO(event["CallerIDNum"]) && event["Exten"] == "0511" { //PAD answered by ICP; PACUs connected ICP1
|
|
|
|
|
+ lfshook.NewLogger().Infof("====PAD answered by ICP1:%s=====", event["CallerIDNum"])
|
|
|
|
|
+ alstatus.AlarmStatus(event["CallerIDNum"], "connect")
|
|
|
|
|
+ go RedirectInQueue(event["CallerIDName"], "2311", "chanspy-rule", "") //PAD whisper ICP1
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if utils.IsIO(event["CallerIDNum"]) && event["Exten"] == "0512" { //PAD ansered by ICP8; PACUs connected ICP8
|
|
|
|
|
+ lfshook.NewLogger().Infof("====PAD answered by ICP8:%s=====", event["CallerIDNum"])
|
|
|
|
|
+ alstatus.AlarmStatus(event["CallerIDNum"], "connect")
|
|
|
|
|
+ go RedirectInQueue(event["CallerIDName"], "2381", "chanspy-rule", "") //PAD whisper ICP8
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
case "ConfbridgeLeave":
|
|
case "ConfbridgeLeave":
|
|
|
lfshook.NewLogger().Infof("=========%s", event["Event"])
|
|
lfshook.NewLogger().Infof("=========%s", event["Event"])
|
|
|
if utils.IsICP(event["CallerIDNum"]) && event["Exten"] == "0500" { // PA end
|
|
if utils.IsICP(event["CallerIDNum"]) && event["Exten"] == "0500" { // PA end
|
|
|
lfshook.NewLogger().Infof("====PA status =====%s", "end")
|
|
lfshook.NewLogger().Infof("====PA status =====%s", "end")
|
|
|
alstatus.PaStatus(event["CallerIDNum"], "PA", "end")
|
|
alstatus.PaStatus(event["CallerIDNum"], "PA", "end")
|
|
|
}
|
|
}
|
|
|
- if utils.IsIO(event["CallerIDNum"]) && event["Exten"] == "0500" { //CPA end
|
|
|
|
|
|
|
+ if utils.IsIO(event["CallerIDNum"]) && event["Exten"] == "0501" { //CPA end
|
|
|
lfshook.NewLogger().Infof("====CPA status =====%s", "end")
|
|
lfshook.NewLogger().Infof("====CPA status =====%s", "end")
|
|
|
alstatus.PaStatus(event["CallerIDNum"], "CPA", "end")
|
|
alstatus.PaStatus(event["CallerIDNum"], "CPA", "end")
|
|
|
}
|
|
}
|
|
@@ -155,32 +152,18 @@ func HandleAMI(event map[string]string) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
case "BridgeEnter":
|
|
case "BridgeEnter":
|
|
|
|
|
+ lfshook.NewLogger().Infof("=========event:%s callerid:%s", event["Event"], event["CallerIDNum"])
|
|
|
//ICP and PACU connected
|
|
//ICP and PACU connected
|
|
|
- if utils.IsPACU(event["CallerIDNum"]) {
|
|
|
|
|
- if utils.IsPAIU(event["CallerIDName"]) && event["Exten"] == "0402" { //relate to PACU Dial ICP caller name in AlarmHandle
|
|
|
|
|
- lfshook.NewLogger().Infof("====BridgeEnter==IN action===%s===ID:%s Name:%s", event["Event"], event["CallerIDNum"], event["CallerIDName"])
|
|
|
|
|
- alstatus.AlarmStatus(event["CallerIDName"], "connect") // Alarm connected
|
|
|
|
|
- if active.CabNum == "1" && active.Actived {
|
|
|
|
|
- go RedirectInQueue(event["CallerIDName"], "2311", "chanspy-rule", "") // 1车ICP接听PAIU
|
|
|
|
|
- } else if active.CabNum == "8" && active.Actived {
|
|
|
|
|
- go RedirectInQueue(event["CallerIDName"], "2381", "chanspy-rule", "") // 1车ICP接听PAIU
|
|
|
|
|
- }
|
|
|
|
|
- } else if utils.IsPAIU(event["CallerIDName"]) && event["Exten"] == "0401" { // PAD connect to OCC
|
|
|
|
|
- lfshook.NewLogger().Infof("====BridgeEnter==IN action===%s===ID:%s Name:%s", event["Event"], event["CallerIDNum"], event["CallerIDName"])
|
|
|
|
|
- alstatus.AlarmStatus(event["CallerIDName"], "connect") // Alarm connected
|
|
|
|
|
-
|
|
|
|
|
- if active.CabNum == "1" && active.Actived {
|
|
|
|
|
- go RedirectInQueue(event["CallerIDName"], "1411", "chanspy-rule", "") // 1车OCC接听PAIU
|
|
|
|
|
- } else if active.CabNum == "8" && active.Actived {
|
|
|
|
|
- go RedirectInQueue(event["CallerIDName"], "1481", "chanspy-rule", "") // 8车OCC接听PAIU
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- } else if utils.IsPAIU(event["CallerIDNum"]) { //No PACU available in the cab
|
|
|
|
|
|
|
+ if utils.IsPACU(event["CallerIDNum"]) { //TMS-ICP connected PACU
|
|
|
lfshook.NewLogger().Infof("====BridgeEnter==IN action===%s===ID:%s Name:%s", event["Event"], event["CallerIDNum"], event["CallerIDName"])
|
|
lfshook.NewLogger().Infof("====BridgeEnter==IN action===%s===ID:%s Name:%s", event["Event"], event["CallerIDNum"], event["CallerIDName"])
|
|
|
alstatus.AlarmStatus(event["CallerIDName"], "connect") // Alarm connected
|
|
alstatus.AlarmStatus(event["CallerIDName"], "connect") // Alarm connected
|
|
|
|
|
+ if active.CabNum == "1" && active.Actived {
|
|
|
|
|
+ go RedirectInQueue(event["CallerIDName"], "2311", "chanspy-rule", "") // 1车TMS-ICP接听PAIU, PAD whisper ICP
|
|
|
|
|
+ } else if active.CabNum == "8" && active.Actived {
|
|
|
|
|
+ go RedirectInQueue(event["CallerIDName"], "2381", "chanspy-rule", "") // 8车TMS-ICP接听PAIU, PAD whisper ICP
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func StartAMI(connectOKCallBack func(), handleEvents []func(event map[string]string)) {
|
|
func StartAMI(connectOKCallBack func(), handleEvents []func(event map[string]string)) {
|
|
@@ -197,7 +180,7 @@ func StartAMI(connectOKCallBack func(), handleEvents []func(event map[string]str
|
|
|
// lfshook.NewLogger().Infof("ami event on %+v", payload[0])
|
|
// lfshook.NewLogger().Infof("ami event on %+v", payload[0])
|
|
|
event := payload[0].(map[string]string)
|
|
event := payload[0].(map[string]string)
|
|
|
|
|
|
|
|
- HandleAMI(event)
|
|
|
|
|
|
|
+ go HandleAMI(event)
|
|
|
|
|
|
|
|
for _, handle := range handleEvents {
|
|
for _, handle := range handleEvents {
|
|
|
go handle(event)
|
|
go handle(event)
|