浏览代码

ICP take PAD back from OCC

dujunchen 5 天之前
父节点
当前提交
2495b3d6cb
共有 2 个文件被更改,包括 48 次插入4 次删除
  1. 17 4
      internal/app/ami/action/index.go
  2. 31 0
      internal/app/stc/broadcast/stc-broadcast.go

+ 17 - 4
internal/app/ami/action/index.go

@@ -137,12 +137,25 @@ func HandleAMI(event map[string]string) {
 		}
 
 	case "BridgeEnter":
-		//ICP and PAD connected
+		//ICP and PACU connected
 		if utils.IsPACU(event["CallerIDNum"]) {
-			if utils.IsPAIU(event["CallerIDName"]) { //relate to PACU Dial ICP caller name in AlarmHandle
+			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
-				go RedirectInQueue(event["CallerIDName"], "2311", "chanspy-rule", "") // 1车ICP接听PAIU
+				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
 			lfshook.NewLogger().Infof("====BridgeEnter==IN action===%s===ID:%s   Name:%s", event["Event"], event["CallerIDNum"], event["CallerIDName"])

+ 31 - 0
internal/app/stc/broadcast/stc-broadcast.go

@@ -427,6 +427,37 @@ func AlarmHandle(data []byte) {
 		} else if active.CabNum == "8" && active.Actived {
 			action.Hangup("2381") //8 车接听
 		}
+
+	case 0x04: //take back from OCC
+		//OCC - ICP <<< PAD-spy OCC
+		//break hangup occ first , keep pad spy-channel ,reconnect Pacu and icp , redirect pad channel to spy-icp
+		if active.CabNum == "1" && active.Actived { //hangup OCC MC1
+			action.Hangup("1411")
+		} else if active.CabNum == "8" && active.Actived { //hangup OCC MC8
+			action.Hangup("1481")
+		}
+
+		//get pacu status
+		var infoExt model.Extension
+		_, er := mysql.DBOrmInstance.Where("exten = ?", PacuNum).Get(&infoExt)
+		if er != nil {
+			lfshook.NewLogger().Logger.Infof("update special voice to exten err : %+v", er.Error())
+		}
+
+		lfshook.NewLogger().Logger.Infof("================IPC take over PAD from OCC================:%s ", exten)
+		if infoExt.Status == "Idle" {
+			if active.CabNum == "1" && active.Actived {
+				action.Dial("0402", PacuNum, "default", PacuNum, exten, "1") // PACU dial OCC MC1
+			} else if active.CabNum == "8" && active.Actived {
+				action.Dial("0402", PacuNum, "default", PacuNum, exten, "8") // PACU dial OCC MC8
+			}
+		} else {
+			if active.CabNum == "1" && active.Actived {
+				action.RedirectInQueue(exten, "0402", "default", "1") // PAD dial OCC MC1
+			} else if active.CabNum == "8" && active.Actived {
+				action.RedirectInQueue(exten, "0402", "default", "8") // PAD dial OCC MC8
+			}
+		}
 	}
 }