8 次代碼提交 0fcda02dea ... 295b7bae52

作者 SHA1 備註 提交日期
  dujunchen 295b7bae52 Merge branch 'master' of http://bc.zycoo.com:3000/dujuncheng/crrc 1 月之前
  dujunchen 86a00cb53c fix hangup cab icp 1 月之前
  dujunchen 3654d538af update acvtive 1 月之前
  dujunchen 943c16aa31 add active action 1 月之前
  dujunchen e3aad25c6f fix mysql init 1 月之前
  dujunchen e15feb1615 hangup ICP too when hangup PAD 1 月之前
  dujunchen 3758eb6b30 fix alarm handle 1 月之前
  dujunchen 766f617501 test redirect 1 月之前

+ 3 - 2
internal/app/ami/action/call.go

@@ -27,8 +27,8 @@ func Hangup(channel string) {
 
 // Dial 拨打号码
 func Dial(src, dst, dialrule, callerID, callerName string, callType string) {
-	chanel := fmt.Sprintf("%s/%s", callType, src)
-
+	//chanel := fmt.Sprintf("%s/%s", callType, src)
+	chanel := fmt.Sprintf("Local/%s@pacu-ani-rule", src)
 	action := map[string]string{
 		"Action":   "Originate",
 		"Channel":  chanel,
@@ -36,6 +36,7 @@ func Dial(src, dst, dialrule, callerID, callerName string, callType string) {
 		"Context":  dialrule,
 		"CallerID": fmt.Sprintf("%s<%s>", callerName, callerID),
 		"Priority": "1",
+		"Variable": fmt.Sprintf("CAB=%s", callType),
 		"async":    "true",
 	}
 	lfshook.NewLogger().Infof("dial action %+v", action)

+ 1 - 0
internal/app/ami/action/channel.go

@@ -71,6 +71,7 @@ func GetChannelByExtenNotBridged(exten string) (channel string, err error) {
 	_, events, err := AminInstance.Send(map[string]string{
 		"Action": "CoreShowChannels",
 	})
+
 	if err != nil {
 		lfshook.NewLogger().Errorf("core show channels error %+v", err)
 		return "", err

+ 26 - 22
internal/app/ami/action/index.go

@@ -86,30 +86,34 @@ func HandleAMI(event map[string]string) {
 			}
 		}
 	case "BridgeEnter":
-		lfshook.NewLogger().Infof("====BridgeEnter=====%s====%s", event["Event"], event["CallerIDNum"])
-		if utils.IsPAIU(event["CallerIDNum"]) {
-			lfshook.NewLogger().Infof("====BridgeEnter=====%s====%s", event["Event"], event["CallerIDNum"])
-			alstatus.AlarmStatus(event["CallerIDNum"], "connect", conn) // Alarm connected
-
-			switch string(event["CallerIDNum"][2]) { // connect the pacu to pad acording to the pad number
-			case "1":
-				ChanSpy(event["CallerIDNum"], pacu1, false, true) //connect pacu to pad
-			case "2":
-				ChanSpy(event["CallerIDNum"], pacu2, false, true) //connect pacu to pad
-			case "3":
-				ChanSpy(event["CallerIDNum"], pacu3, false, true) //connect pacu to pad
-			case "4":
-				ChanSpy(event["CallerIDNum"], pacu4, false, true) //connect pacu to pad
-			case "5":
-				ChanSpy(event["CallerIDNum"], pacu5, false, true) //connect pacu to pad
-			case "6":
-				ChanSpy(event["CallerIDNum"], pacu6, false, true) //connect pacu to pad
-			case "7":
-				ChanSpy(event["CallerIDNum"], pacu7, false, true) //connect pacu to pad
-			case "8":
-				ChanSpy(event["CallerIDNum"], pacu8, false, true) //connect pacu to pad
+
+		if utils.IsPACU(event["CallerIDNum"]) {
+			if utils.IsPAIU(event["CallerIDName"]) { //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"])
+				go RedirectInQueue(event["CallerIDName"], "2311", "chanspy-rule", "") // 1车ICP接听PAIU
 			}
 
+			alstatus.AlarmStatus(event["CallerIDName"], "connect", conn) // Alarm connected
+			/*
+				switch string(event["CallerIDNum"][2]) { // connect the pacu to pad acording to the pad number
+				case "1":
+					ChanSpy(event["CallerIDNum"], pacu1, false, true) //connect pacu to pad
+				case "2":
+					ChanSpy(event["CallerIDNum"], pacu2, false, true) //connect pacu to pad
+				case "3":
+					ChanSpy(event["CallerIDNum"], pacu3, false, true) //connect pacu to pad
+				case "4":
+					ChanSpy(event["CallerIDNum"], pacu4, false, true) //connect pacu to pad
+				case "5":
+					ChanSpy(event["CallerIDNum"], pacu5, false, true) //connect pacu to pad
+				case "6":
+					ChanSpy(event["CallerIDNum"], pacu6, false, true) //connect pacu to pad
+				case "7":
+					ChanSpy(event["CallerIDNum"], pacu7, false, true) //connect pacu to pad
+				case "8":
+					ChanSpy(event["CallerIDNum"], pacu8, false, true) //connect pacu to pad
+				}
+			*/
 		}
 
 	}

+ 23 - 10
internal/app/stc/broadcast/stc-broadcast.go

@@ -305,8 +305,8 @@ func AlarmHandle(data []byte) {
 	carr := data[12]
 	pos := data[13]
 	exten := fmt.Sprintf("24%c%c", carr, pos)
+	PacuNum := fmt.Sprintf("21%c%c", carr, pos)
 
-	lfshook.NewLogger().Logger.Infof("================ICP Answer PAD================:%s ", exten)
 	key := suppressKey(exten, handler)
 
 	//Drop other handler in 2 sec
@@ -324,7 +324,7 @@ func AlarmHandle(data []byte) {
 		})
 	}
 
-	// 设置2秒后删除该 key,允许下次通过
+	// 设置1秒后删除该 key,允许下次通过
 	time.AfterFunc(1*time.Second, func() {
 		suppressedExts.Delete(key)
 		lfshook.NewLogger().Logger.Debugf("Suppression released for key: %s", key)
@@ -333,20 +333,28 @@ func AlarmHandle(data []byte) {
 	switch handler {
 	case 0x01: //answer(ICP+Alarm+PACU)
 		//NotifyPaiu(exten, "answer")
+
+		lfshook.NewLogger().Logger.Infof("================ICP Answer PAD================:%s ", exten)
 		if active.CabNum == "1" {
-			err := action.RedirectInQueue(exten, "0402", "ani-rule", "1") // 1车ICP接听PAIU
-			if err != nil {
-				lfshook.NewLogger().Logger.Infof("=========Cab1=======ICP Answer PAD====ERR============ : %+v", err.Error())
-			}
+			action.Dial(PacuNum, "0402", "ani-rule", PacuNum, exten, "1") // PACU dial ICP
 		} else {
-			err := action.RedirectInQueue(exten, "0402", "ani-rule", "8") // 8车ICP接听PAIU
-			if err != nil {
-				lfshook.NewLogger().Logger.Infof("=========Cab8=======ICP Answer PAD====ERR============ : %+v", err.Error())
-			}
+			action.Dial(PacuNum, "0402", "ani-rule", PacuNum, exten, "8") // PACU dial ICP
+		}
+		//invite PACU join in
+		//action.Hangup("PACU")
+		//action.ChanSpy("PACU", exten, false, true)
+
+	case 0x04: //answer(PACU+Alarm+OCC)
+		if active.CabNum == "1" {
+			action.Dial(PacuNum, "0401", "ano-rule", PacuNum, exten, "1") // PACU dial OCC
+		} else {
+			action.Dial(PacuNum, "0401", "ano-rule", PacuNum, exten, "8") // PACU dial OCC
 		}
+
 		//invite PACU join in
 		//action.Hangup("PACU")
 		//action.ChanSpy("PACU", exten, false, true)
+		lfshook.NewLogger().Logger.Infof("================OCC Answer PAD================:%s ", exten)
 	case 0x02: //hold  重新放回队列里面
 		NotifyPaiu(exten, "hold")
 
@@ -358,6 +366,11 @@ func AlarmHandle(data []byte) {
 	case 0x03: //hangup
 		//NotifyPaiu(exten, "hangup")
 		action.Hangup(exten)
+		if active.CabNum == "1" {
+			action.Hangup("2311") //1 车接听
+		} else {
+			action.Hangup("2381") //8 车接听
+		}
 	}
 }