Bläddra i källkod

update CPA acvtive

root 3 veckor sedan
förälder
incheckning
020cc47d06

+ 68 - 39
internal/app/ami/action/call.go

@@ -177,19 +177,15 @@ func InterruptRunningTask(toRunTask string) string {
 	case "SPC":
 		if toRunTask == "C2C" {
 			HangupICP()
-			//alstatus.PaStatus("", "SPC", "end")
 		} else {
 			ConfbridgeKick(task.ConfbridgeID, "all")
-			alstatus.PaStatus("", "SPC", "end")
 		}
 		time.Sleep(time.Millisecond * 200)
 	case "CHK":
 		if toRunTask == "C2C" {
 			HangupICP()
-			//alstatus.PaStatus("", "CHK", "end")
 		} else {
 			ConfbridgeKick(task.ConfbridgeID, "all")
-			alstatus.PaStatus("", "CHK", "end")
 		}
 		time.Sleep(time.Millisecond * 200)
 	case "DCS":
@@ -197,10 +193,8 @@ func InterruptRunningTask(toRunTask string) string {
 			return taskName
 		} else if toRunTask == "C2C" {
 			HangupICP()
-			//alstatus.PaStatus("", "DCS", "end")
 		} else {
 			ConfbridgeKick(task.ConfbridgeID, "all")
-			alstatus.PaStatus("", "DCS", "end")
 		}
 
 		time.Sleep(time.Millisecond * 200)
@@ -209,33 +203,30 @@ func InterruptRunningTask(toRunTask string) string {
 			return taskName
 		} else if toRunTask == "C2C" {
 			HangupICP()
-			//alstatus.PaStatus("", "STN", "end")
 		} else {
 			ConfbridgeKick(task.ConfbridgeID, "all")
-			alstatus.PaStatus("", "STN", "end")
 		}
 		time.Sleep(time.Millisecond * 200)
 	case "CPA":
 		//kick CPA members
 		if toRunTask != "C2C" {
-			CPAConfbridgeKick(task.ConfbridgeID)
-			alstatus.PaStatus("", "CPA", "end")
+			CPAConfbridgeKick(task)
+			task.Running = false
+			//alstatus.PaStatus("", "CPA", "end")
 		} else if toRunTask == "C2C" {
 			HangupICP()
-			//alstatus.PaStatus("", "CPA", "end")
 		}
 		time.Sleep(time.Millisecond * 200)
 	case "EMG":
 		//kick EMG members
 		if toRunTask == "EMG" {
 			ConfbridgeKick(task.ConfbridgeID, "all")
-			//alstatus.PaStatus("", "EMG", "end")
 		} else if toRunTask != "C2C" {
-			EMGConfbridgeKick(task.ConfbridgeID)
+			EMGConfbridgeKick(task)
+			task.Running = false
 			//alstatus.PaStatus("", "EMG", "end")
 		} else if toRunTask == "C2C" {
 			HangupICP()
-			//alstatus.PaStatus("", "EMG", "end")
 		}
 		time.Sleep(time.Millisecond * 200)
 	case "C2C": // Interrupt C2C task running,
@@ -339,6 +330,8 @@ func InterruptRunningTask(toRunTask string) string {
 					Hangup("1411")
 				} else if active.ActivedCabDelay == "8" {
 					Hangup("1481")
+				} else {
+					Hangup("1411")
 				}
 			}
 
@@ -668,19 +661,40 @@ func ConfbridgeKick(confnum, channel string) (res map[string]string, err error)
 	return res, nil
 }
 
-func CPAConfbridgeKick(confnum string) (res map[string]string, err error) {
+func CPAConfbridgeKick(confInfo priority.TaskInfo) (res map[string]string, err error) {
 	utils.LoggerDebug.Printf("CPA CPAConfbridgeKick , kick all members .")
 
-	chans, err := ConfbridgeList(confnum)
+	chans, err := ConfbridgeList(confInfo.ConfbridgeID)
 	if err != nil {
 		return nil, errors.New(res["Message"])
 	}
 
 	for _, confChan := range chans {
-		if !strings.Contains(confChan, "PJSIP/1481") {
-			ConfbridgeKick(confnum, confChan)
+		if active.TrainDevide == 1 {
+			if active.CabNum == "1" { //在1车车厢内
+				if !strings.Contains(confChan, "PJSIP/1411") {
+					ConfbridgeKick(confInfo.ConfbridgeID, confChan)
+				}
+			} else { //在8车车厢内
+				if !strings.Contains(confChan, "PJSIP/1481") {
+					ConfbridgeKick(confInfo.ConfbridgeID, confChan)
+				}
+			}
+		} else {
+			if active.ActivedCab != "1" {
+				if !strings.Contains(confChan, "PJSIP/1411") {
+					ConfbridgeKick(confInfo.ConfbridgeID, confChan)
+				}
+			} else {
+				if !strings.Contains(confChan, "PJSIP/1481") {
+					ConfbridgeKick(confInfo.ConfbridgeID, confChan)
+				}
+			}
 		}
 	}
+	if confInfo.Running {
+		alstatus.PaStatus("", "CPA", "end")
+	}
 	return res, nil
 }
 
@@ -688,28 +702,17 @@ func CPAConfbridgeReinvite(confID string) bool {
 	time.Sleep(time.Millisecond * 100)
 	utils.LoggerDebug.Printf("CPA CPAConfbridgeReinvite , resume CPA .")
 
-	/*if priority.TaskCreating == "" || priority.CABInterrupt == 1 { //高优先级被cabcab打断,或者高优先级直接挂断
-
-		for _, ext := range Speakers {
-			if utils.IsICP(ext) {
-				if priority.CABInterrupt == 0 {
-					utils.LoggerDebug.Printf("CPA CPAConfbridgeReinvite , Get CABCAB Interrupt resume CPA , ignore %s continue .", ext)
-					continue
-				}
-			}
-
-			ConfbridgeReinvite(ext, "call-speakers-cpa", confID)
-		}
-	} else {
-		utils.LoggerDebug.Printf("CPA CPAConfbridgeReinvite , Interrupt by other ,return !")
+	chans, err := ConfbridgeList(confID)
+	if len(chans) > 1 || err != nil {
+		utils.LoggerDebug.Printf("CPA CPAConfbridgeReinvite , return . ConfbridgeList chans > 1 or err !")
 		return false
 	}
-	return true*/
 
 	if priority.PAInterrupt == 1 { // PA 打断标签判断
 		utils.LoggerDebug.Printf("CPA ConfbridgeReinvite , PA ready to go , return !")
 		return false
 	} else if priority.CABInterrupt == 1 { //CABCAB 打断标签判断
+		priority.TaskCreating = "CPA"
 		for _, ext := range Speakers { //高优先级被cabcab打断,或者高优先级直接挂断
 			if utils.IsICP(ext) {
 				if priority.CABInterrupt == 1 {
@@ -719,40 +722,58 @@ func CPAConfbridgeReinvite(confID string) bool {
 			}
 			ConfbridgeReinvite(ext, "call-speakers-cpa", confID)
 		}
+		time.Sleep(time.Millisecond * 200) //等待通道建立
+		priority.TaskCreating = ""
+		alstatus.PaStatus("", "CPA", "start")
 	} else if priority.TaskCreating != "" {
 		utils.LoggerDebug.Printf("CPA ConfbridgeReinvite , other PA ready to go , return !")
 		return false
 	} else {
+		priority.TaskCreating = "CPA"
 		for _, ext := range Speakers {
 			ConfbridgeReinvite(ext, "call-speakers-cpa", confID)
 		}
+		time.Sleep(time.Millisecond * 200) //等待通道建立
+		priority.TaskCreating = ""
+		alstatus.PaStatus("", "CPA", "start")
 	}
 	return true
 }
 
-func EMGConfbridgeKick(confnum string) (res map[string]string, err error) {
+func EMGConfbridgeKick(confInfo priority.TaskInfo) (res map[string]string, err error) {
 	utils.LoggerDebug.Printf("EMG EMGConfbridgeKick , kick all members .")
-	chans, err := ConfbridgeList(confnum)
+	chans, err := ConfbridgeList(confInfo.ConfbridgeID)
 	if err != nil {
 		return nil, errors.New(res["Message"])
 	}
 
 	for _, confChan := range chans {
 		if !strings.Contains(confChan, "0502@default") {
-			ConfbridgeKick(confnum, confChan)
+			ConfbridgeKick(confInfo.ConfbridgeID, confChan)
 		}
 	}
+
+	if confInfo.Running {
+		alstatus.PaStatus("", "EMG", "end")
+	}
 	return res, nil
 }
 
 func EMGConfbridgeReinvite(confID string) {
-	time.Sleep(time.Millisecond * 100)
+
+	//if priority.CABInterrupt != 1 {
+	//	time.Sleep(time.Millisecond * 100)
+	//} else {
+	time.Sleep(time.Second * 1) //wait cpa start first
+	//}
+
 	utils.LoggerDebug.Printf("EMG ConfbridgeReinvite , resume EMG .")
 
 	if priority.PAInterrupt == 1 { // PA 打断标签判断
 		utils.LoggerDebug.Printf("EMG ConfbridgeReinvite , PA ready to go , return !")
 		return
 	} else if priority.CABInterrupt == 1 { //CABCAB 打断标签判断
+		priority.TaskCreating = "EMG"
 		for _, ext := range Speakers { //高优先级被cabcab打断,或者高优先级直接挂断
 			if utils.IsICP(ext) {
 				if priority.CABInterrupt == 1 {
@@ -762,13 +783,21 @@ func EMGConfbridgeReinvite(confID string) {
 			}
 			ConfbridgeReinvite(ext, "call-speakers-emg", confID)
 		}
+
+		time.Sleep(time.Millisecond * 200) //等待通道建立
+		priority.TaskCreating = ""
+		alstatus.PaStatus("", "EMG", "start")
 	} else if priority.TaskCreating != "" {
 		utils.LoggerDebug.Printf("EMG ConfbridgeReinvite , other PA ready to go , return !")
 		return
 	} else {
+		priority.TaskCreating = "EMG"
 		for _, ext := range Speakers {
 			ConfbridgeReinvite(ext, "call-speakers-emg", confID)
 		}
+		time.Sleep(time.Millisecond * 200) //等待通道建立
+		priority.TaskCreating = ""
+		alstatus.PaStatus("", "EMG", "start")
 	}
 }
 
@@ -825,10 +854,10 @@ func ConfbridgeReinvite(src, context, confID string) {
 
 func ICPConfbridgeReinvite(confID, paType string) {
 
-	if priority.CABInterrupt == 1 || priority.CABInterrupt == 1 {
+	/*if priority.CABInterrupt == 1 || priority.CABInterrupt == 1 {
 		utils.LoggerDebug.Printf("ICPConfbridgeReinvite, Get PA/CABCAB Interrupt resume %s faild .", paType)
 		return
-	}
+	}*/
 
 	switch paType {
 	case "PAD-OCC":

+ 54 - 54
internal/app/ami/action/index.go

@@ -67,6 +67,8 @@ func HandleAMI(event map[string]string) {
 		if event["UserEvent"] == "CallType" && (event["Type"] == "PA" || event["Type"] == "CPA") { //PA start; check manual PA priority
 			//PA & CPA interrupt others
 			if utils.IsICP(event["CallerIDNum"]) { //PA
+				//清除标记
+
 				utils.LoggerDebug.Printf("Get UserEvent , %s calling !", event["Type"])
 				if active.ActivedCab == "" { //No active Signal on both side,Hangup caller
 					Hangup(event["CallerIDNum"])
@@ -85,6 +87,10 @@ func HandleAMI(event map[string]string) {
 						time.Sleep(time.Millisecond * 100) //wait endpoint release
 					}
 
+					if priority.TaskCreating == "PA" {
+						utils.LoggerDebug.Printf("PA : Clean priority.TaskCreating = '' !")
+						priority.TaskCreating = ""
+					}
 				} else {
 					if priority.TaskCreating == "PA" {
 						utils.LoggerDebug.Printf("PA : Clean priority.TaskCreating = '' !")
@@ -95,12 +101,16 @@ func HandleAMI(event map[string]string) {
 				}
 
 				time.Sleep(1 * time.Second)
-				if priority.TaskCreating == "PA" {
-					utils.LoggerDebug.Printf("PA : Clean priority.TaskCreating = '' !")
-					priority.TaskCreating = ""
-				}
+				priority.PAInterrupt = 0
 			} else if utils.IsIO(event["CallerIDNum"]) { // CPA
 
+				if /*priority.CABInterrupt == 1 || */ priority.PAInterrupt == 1 {
+					utils.LoggerDebug.Printf("Get UserEvent CPA calling !  Ignored because of PAInterrupt=1 !")
+					Hangup(event["CallerIDNum"])
+					//priority.CPAActived = 1 //CPA触发,但未运行
+					return
+				}
+
 				utils.LoggerDebug.Printf("Get UserEvent , %s calling !", event["Type"])
 				WaitTaskCreate("CPA", event["CallerIDNum"])
 
@@ -149,6 +159,7 @@ func HandleAMI(event map[string]string) {
 					}
 					utils.LoggerDebug.Printf("CPA calling failed , check priority return false !")
 					Hangup(event["CallerIDNum"]) //lowwer priority ,hangup caller
+					//priority.CPAActived = 1      //CPA触发,但未运行
 				}
 
 				time.Sleep(1 * time.Second)
@@ -159,7 +170,7 @@ func HandleAMI(event map[string]string) {
 			}
 		} else if event["UserEvent"] == "CallType" && event["Type"] == "C2C" { //CabCab start; check cab cab priority
 			utils.LoggerDebug.Printf("Get UserEvent , %s calling !", event["Type"])
-			priority.CABInterrupt = 0
+
 			WaitTaskCreate("C2C", event["CallerIDNum"])
 
 			if priority.CheckPriority("CabCab") { // interrupt OCC-PAD
@@ -187,6 +198,8 @@ func HandleAMI(event map[string]string) {
 					}
 					//}
 				}
+				time.Sleep(time.Second * 1)
+				priority.CABInterrupt = 0
 
 			} else { // hangup caller; C2C start failed
 				//lfshook.NewLogger().Infof("CabCab  hangup caller %s", event["CallerIDNum"])
@@ -361,15 +374,14 @@ func HandleAMI(event map[string]string) {
 				priority.RegistryTask.StopAndUnregister("PAD-OCC")
 				ConfbridgeKick(taskTmp.ConfbridgeID, "all")
 
+				time.Sleep(time.Millisecond * 500) //wait CPA Active
 				//check resume
 				taskName, task, ok := priority.RegistryTask.HighestPriorityRunningTask1()
 				if ok {
 					if taskName == "EMG" {
 						EMGConfbridgeReinvite(task.ConfbridgeID)
 					} else if taskName == "CPA" {
-						if CPAConfbridgeReinvite(task.ConfbridgeID) {
-							alstatus.PaStatus("", "CPA", "start")
-						}
+						CPAConfbridgeReinvite(task.ConfbridgeID)
 					}
 				}
 
@@ -386,7 +398,7 @@ func HandleAMI(event map[string]string) {
 				//time.Sleep(time.Millisecond * 100) //wait io idle
 				//lfshook.NewLogger().Infof("====Start OCC-PAD===next==%+v", res)
 				if active.TrainDevide == 0 { //列车没有断开
-					if (active.ActivedCab == "1" && ExtenStatus("1411") == "Idle") || (active.ActivedCab == "" && active.ActivedCabDelay == "1" && ExtenStatus("1411") == "Idle") { //check active and OCC status
+					if (ExtenStatus("1411") == "Idle") && ((active.ActivedCab == "1" || (active.ActivedCab == "" && active.ActivedCabDelay == "1")) || (active.ActivedCab == "" && active.ActivedCabDelay == "")) { //check active and OCC status
 						time.Sleep(time.Second)
 						PADChan := ""
 
@@ -499,16 +511,14 @@ func HandleAMI(event map[string]string) {
 				}
 
 				if priority.OCCAnswer == 0 { // not OCC-PAD
+					time.Sleep(time.Millisecond * 500) //wait CPA Active
 					//check resume
 					taskName, task, ok := priority.RegistryTask.HighestPriorityRunningTask1()
 					if ok {
 						if taskName == "EMG" {
 							EMGConfbridgeReinvite(task.ConfbridgeID)
-							//alstatus.PaStatus("", "EMG", "start")
 						} else if taskName == "CPA" {
-							if CPAConfbridgeReinvite(task.ConfbridgeID) {
-								alstatus.PaStatus("", "CPA", "start")
-							}
+							CPAConfbridgeReinvite(task.ConfbridgeID)
 						}
 					}
 				}
@@ -531,11 +541,8 @@ func HandleAMI(event map[string]string) {
 			if ok {
 				if taskName == "EMG" {
 					EMGConfbridgeReinvite(task.ConfbridgeID)
-					//alstatus.PaStatus("", "EMG", "start")
 				} else if taskName == "CPA" {
-					if CPAConfbridgeReinvite(task.ConfbridgeID) {
-						alstatus.PaStatus("", "CPA", "start")
-					}
+					CPAConfbridgeReinvite(task.ConfbridgeID)
 				}
 			}
 		}
@@ -656,7 +663,7 @@ func HandleAMI(event map[string]string) {
 				time.Sleep(time.Millisecond * 300)
 
 				if active.TrainDevide == 0 { //列车没有断开
-					if (active.ActivedCab == "1" && ExtenStatus("1411") == "Idle") || (active.ActivedCab == "" && active.ActivedCabDelay == "1" && ExtenStatus("1411") == "Idle") { //check active and OCC status
+					if (ExtenStatus("1411") == "Idle") && ((active.ActivedCab == "1" || (active.ActivedCab == "" && active.ActivedCabDelay == "1")) || (active.ActivedCab == "" && active.ActivedCabDelay == "")) { //check active and OCC status
 						utils.LoggerDebug.Printf("PAD %s goto OCC1 .", event["CallerIDNum"])
 						alstatus.AlarmStatus(event["CallerIDNum"], "connect")
 						go RedirectInQueue(event["Channel"], "1411", "pad-page-occ-icp", event["CallerIDNum"]) //PAD Page(OCC+ICPs)
@@ -907,7 +914,7 @@ func HandleAMI(event map[string]string) {
 		*/
 		//Send PA start msg to STC
 		if utils.IsICP(event["CallerIDNum"]) && event["Exten"] == "0500" { // PA start
-
+			priority.PAInterrupt = 0
 			alstatus.PaStatus(event["CallerIDNum"], "PA", "start")
 			//================================
 			task := priority.TaskInfo{
@@ -926,7 +933,6 @@ func HandleAMI(event map[string]string) {
 				priority.TaskCreating = ""
 			}
 
-			priority.PAInterrupt = 0 //清除标记
 			//check PAD timer
 			if priority.AllTasks.PADOCC.Priority > priority.AllTasks.PA.Priority {
 				if active.QueueTimer != nil {
@@ -954,7 +960,7 @@ func HandleAMI(event map[string]string) {
 			utils.LoggerDebug.Printf("CPA Runing , Set CPA task info %+v .", task)
 			priority.RegistryTask.Register("CPA", task)
 
-			utils.LoggerDebug.Printf("CPA Runing , Set CPA task info %+v .", priority.RegistryTask.ListAll())
+			//utils.LoggerDebug.Printf("CPA Runing , Set CPA task info %+v .", priority.RegistryTask.ListAll())
 
 			if priority.TaskCreating == "CPA" {
 				utils.LoggerDebug.Printf("CPA Connected : Clean priority.TaskCreating = '' !")
@@ -1056,21 +1062,19 @@ func HandleAMI(event map[string]string) {
 	case "ConfbridgeLeave":
 		lfshook.NewLogger().Infof("=========%s", event["Event"])
 		if utils.IsICP(event["CallerIDNum"]) && event["Exten"] == "0500" { // PA end
-
 			alstatus.PaStatus(event["CallerIDNum"], "PA", "end")
 
 			priority.RegistryTask.StopAndUnregister("PA")
 			SetPadTimer()
+
+			time.Sleep(time.Millisecond * 500) //wait CPA Active
 			// check resume
 			taskName, task, ok := priority.RegistryTask.HighestPriorityRunningTask1()
 			if ok {
 				if taskName == "EMG" {
 					EMGConfbridgeReinvite(task.ConfbridgeID)
-					//alstatus.PaStatus("", "EMG", "start")
 				} else if taskName == "CPA" {
-					if CPAConfbridgeReinvite(task.ConfbridgeID) {
-						alstatus.PaStatus("", "CPA", "start")
-					}
+					CPAConfbridgeReinvite(task.ConfbridgeID)
 				}
 			}
 
@@ -1085,12 +1089,13 @@ func HandleAMI(event map[string]string) {
 			}
 			priority.RegistryTask.StopAndUnregister("CPA")
 			SetPadTimer()
+
+			time.Sleep(time.Millisecond * 500) //wait CPA Active
 			//check resume
 			taskName, task, ok := priority.RegistryTask.HighestPriorityRunningTask1()
 			if ok {
 				if taskName == "EMG" {
 					EMGConfbridgeReinvite(task.ConfbridgeID)
-					//alstatus.PaStatus("", "EMG", "start")
 				}
 			}
 
@@ -1106,13 +1111,13 @@ func HandleAMI(event map[string]string) {
 			}
 			priority.RegistryTask.StopAndUnregister("EMG")
 			SetPadTimer()
+
+			time.Sleep(time.Millisecond * 500) //wait CPA Active
 			//check resume
 			taskName, task, ok := priority.RegistryTask.HighestPriorityRunningTask1()
 			if ok {
 				if taskName == "CPA" {
-					if CPAConfbridgeReinvite(task.ConfbridgeID) {
-						alstatus.PaStatus("", "CPA", "start")
-					}
+					CPAConfbridgeReinvite(task.ConfbridgeID)
 				}
 			}
 
@@ -1127,16 +1132,15 @@ func HandleAMI(event map[string]string) {
 			}
 			priority.RegistryTask.StopAndUnregister("STN")
 			SetPadTimer()
+
+			time.Sleep(time.Millisecond * 500) //wait CPA Active
 			//check resume
 			taskName, task, ok := priority.RegistryTask.HighestPriorityRunningTask1()
 			if ok {
 				if taskName == "CPA" {
-					if CPAConfbridgeReinvite(task.ConfbridgeID) {
-						alstatus.PaStatus("", "CPA", "start")
-					}
+					CPAConfbridgeReinvite(task.ConfbridgeID)
 				} else if taskName == "EMG" {
 					EMGConfbridgeReinvite(task.ConfbridgeID)
-					//alstatus.PaStatus("", "EMG", "start")
 				}
 			}
 
@@ -1151,16 +1155,15 @@ func HandleAMI(event map[string]string) {
 			}
 			priority.RegistryTask.StopAndUnregister("DCS")
 			SetPadTimer()
+
+			time.Sleep(time.Millisecond * 500) //wait CPA Active
 			//check resume
 			taskName, task, ok := priority.RegistryTask.HighestPriorityRunningTask1()
 			if ok {
 				if taskName == "CPA" {
-					if CPAConfbridgeReinvite(task.ConfbridgeID) {
-						alstatus.PaStatus("", "CPA", "start")
-					}
+					CPAConfbridgeReinvite(task.ConfbridgeID)
 				} else if taskName == "EMG" {
 					EMGConfbridgeReinvite(task.ConfbridgeID)
-					//alstatus.PaStatus("", "EMG", "start")
 				}
 			}
 
@@ -1175,16 +1178,15 @@ func HandleAMI(event map[string]string) {
 			}
 			priority.RegistryTask.StopAndUnregister("SPC")
 			SetPadTimer()
+
+			time.Sleep(time.Millisecond * 500) //wait CPA Active
 			//check resume
 			taskName, task, ok := priority.RegistryTask.HighestPriorityRunningTask1()
 			if ok {
 				if taskName == "CPA" {
-					if CPAConfbridgeReinvite(task.ConfbridgeID) {
-						alstatus.PaStatus("", "CPA", "start")
-					}
+					CPAConfbridgeReinvite(task.ConfbridgeID)
 				} else if taskName == "EMG" {
 					EMGConfbridgeReinvite(task.ConfbridgeID)
-					//alstatus.PaStatus("", "EMG", "start")
 				}
 			}
 
@@ -1199,16 +1201,15 @@ func HandleAMI(event map[string]string) {
 			}
 			priority.RegistryTask.StopAndUnregister("CHK")
 			SetPadTimer()
+
+			time.Sleep(time.Millisecond * 500) //wait CPA Active
 			//check resume
 			taskName, task, ok := priority.RegistryTask.HighestPriorityRunningTask1()
 			if ok {
 				if taskName == "CPA" {
-					if CPAConfbridgeReinvite(task.ConfbridgeID) {
-						alstatus.PaStatus("", "CPA", "start")
-					}
+					CPAConfbridgeReinvite(task.ConfbridgeID)
 				} else if taskName == "EMG" {
 					EMGConfbridgeReinvite(task.ConfbridgeID)
-					//alstatus.PaStatus("", "EMG", "start")
 				}
 			}
 
@@ -1223,16 +1224,15 @@ func HandleAMI(event map[string]string) {
 			}
 			priority.RegistryTask.StopAndUnregister("VOL")
 			SetPadTimer()
+
+			time.Sleep(time.Millisecond * 500) //wait CPA Active
 			//check resume
 			taskName, task, ok := priority.RegistryTask.HighestPriorityRunningTask1()
 			if ok {
 				if taskName == "CPA" {
-					if CPAConfbridgeReinvite(task.ConfbridgeID) {
-						alstatus.PaStatus("", "CPA", "start")
-					}
+					CPAConfbridgeReinvite(task.ConfbridgeID)
 				} else if taskName == "EMG" {
 					EMGConfbridgeReinvite(task.ConfbridgeID)
-					//alstatus.PaStatus("", "EMG", "start")
 				}
 			}
 		}
@@ -1252,6 +1252,7 @@ func HandleAMI(event map[string]string) {
 			}
 
 			priority.RegistryTask.Register("C2C", task)
+			priority.CABInterrupt = 0
 			alstatus.PaStatus(event["CallerIDNum"], "C2C", "start")
 			if priority.TaskCreating == "C2C" {
 				utils.LoggerDebug.Printf("C2C Connected : Clean priority.TaskCreating = '' !")
@@ -1319,20 +1320,19 @@ func HandleAMI(event map[string]string) {
 		//lfshook.NewLogger().Infof("=========%s", event["Event"])
 		//Cab Cab end
 		if utils.IsICP(event["CallerIDNum"]) && utils.IsICP(event["ConnectedLineNum"]) && event["Exten"] == "0400" {
-
 			alstatus.PaStatus(event["CallerIDNum"], "C2C", "end")
 			priority.RegistryTask.StopAndUnregister("C2C")
 			//time.Sleep(time.Millisecond * 100)
 			SetPadTimer()
+
+			time.Sleep(time.Millisecond * 500) //wait CPA Active
 			//check resume
 			taskName, task, ok := priority.RegistryTask.HighestPriorityRunningTask1()
 			if ok {
 				if taskName == "EMG" {
 					EMGConfbridgeReinvite(task.ConfbridgeID)
 				} else if taskName == "CPA" {
-					if CPAConfbridgeReinvite(task.ConfbridgeID) {
-						alstatus.PaStatus("", "CPA", "start")
-					}
+					CPAConfbridgeReinvite(task.ConfbridgeID)
 				} else {
 					ICPConfbridgeReinvite(task.ConfbridgeID, taskName)
 				}

+ 14 - 2
internal/app/stc/broadcast/stc-broadcast.go

@@ -763,7 +763,13 @@ func AlarmHandleICP(data []byte) {
 			action.Dial("0402", "0511", "pad-rule-pacus", "ani8", exten, "8") // PACUs dial ICP8
 			//goto ami event ConfbridgeJoin, ICP answer PAD
 		} else if active.ActivedCab == "" { // No cab occupied
-			action.Dial("0402", "0511", "pad-rule-pacus", "ani1", exten, "1") // PACUs dial ICP1
+			if active.ActivedCabDelay == "1" {
+				action.Dial("0402", "0511", "pad-rule-pacus", "ani1", exten, "1") // PACUs dial ICP1
+			} else if active.ActivedCabDelay == "8" {
+				action.Dial("0402", "0511", "pad-rule-pacus", "ani8", exten, "8") // PACUs dial ICP8
+			} else {
+				action.Dial("0402", "0511", "pad-rule-pacus", "ani1", exten, "1") // PACUs dial ICP1
+			}
 		}
 
 	case 0x02: //hold  重新放回队列里面
@@ -819,7 +825,13 @@ func AlarmHandleTMS(data []byte) {
 				action.Dial("0403", PacuNum, "pad-tms-dial-pacu", PacuNum, exten, "8") // PACU dial ICP8
 				//goto ami event BridgeEnter, ICP1 whisper ICP8
 			} else if active.ActivedCab == "" { // No cab occupied
-				action.Dial("0403", PacuNum, "pad-tms-dial-pacu", PacuNum, exten, "1") // PACU dial ICP1
+				if active.ActivedCabDelay == "1" {
+					action.Dial("0403", PacuNum, "pad-tms-dial-pacu", PacuNum, exten, "1") // PACU dial ICP1
+				} else if active.ActivedCabDelay == "8" {
+					action.Dial("0403", PacuNum, "pad-tms-dial-pacu", PacuNum, exten, "8") // PACU dial ICP8
+				} else {
+					action.Dial("0403", PacuNum, "pad-tms-dial-pacu", PacuNum, exten, "1") // PACU dial ICP1
+				}
 			}
 		} else {
 			action.RedirectInQueue(exten, "0405", "default", exten) // PAD dial ICPs

+ 3 - 0
internal/app/stc/priority/index.go

@@ -30,6 +30,9 @@ var InterruptedPad = ""
 var CABInterrupt = 0
 var PAInterrupt = 0
 
+// 是否有CPA激活
+//var CPAActived = 0
+
 var filePath = "/etc/asterisk/priority.conf"
 
 type TaskInfo struct {