浏览代码

1.修复ICP接听PAD时不能2个ICP同时出声的问题

dujunchen 1 周之前
父节点
当前提交
5b1551665e

+ 55 - 23
internal/app/ami/action/call.go

@@ -6,7 +6,6 @@ import (
 	"pbx-api-gin/internal/app/stc/priority"
 	"pbx-api-gin/pkg/lfshook"
 	"pbx-api-gin/pkg/utils"
-	"strconv"
 	"strings"
 	"time"
 )
@@ -33,12 +32,12 @@ func InActiveHangup() {
 
 // check EMG resume
 func CheckEmgResume() {
-
-	time.AfterFunc(2*time.Second, func() {
-		if priority.CheckPriority("EMG") || priority.RunningType == "C2C" {
-			PlaybackPacu(strconv.Quote(priority.ResumeEmgPara.FileName), priority.ResumeEmgPara.Count, priority.ResumeEmgPara.Delay, priority.ResumeEmgPara.BroadcastType)
-		}
-	})
+	/*
+		time.AfterFunc(2*time.Second, func() {
+			if priority.CheckPriority("EMG") || priority.RunningType == "C2C" {
+				PlaybackPacu(strconv.Quote(priority.ResumeEmgPara.FileName), priority.ResumeEmgPara.Count, priority.ResumeEmgPara.Delay, priority.ResumeEmgPara.BroadcastType)
+			}
+		})*/
 }
 
 // Hangup 挂断指定分机或通道
@@ -97,7 +96,7 @@ func HangupAllExcept(caller string) {
 
 // Hangup all ICP
 func HangupRunningTask(toRunTask string) {
-	lfshook.NewLogger().Infof("===HangupRunningTask=toRuntask=%s   RunningTask:%s  ", toRunTask, priority.RunningType)
+	lfshook.NewLogger().Infof("===HangupRunningTask=toRuntask=%s====   RunningTask:%s===", toRunTask, priority.RunningType)
 
 	//same type return
 	if toRunTask == priority.RunningType {
@@ -111,24 +110,27 @@ func HangupRunningTask(toRunTask string) {
 		switch priority.RunningType {
 
 		case "PAD-ICP", "PAD-TMS": // Interrupt PAD task running,
-
-			chans, err := CoreShowChannels()
-			if err != nil {
-				lfshook.NewLogger().Errorf("CoreShowChannels %+v", err)
-			}
-
-			//1. Redirect the connected PAD to 0300
-			for _, ret := range chans {
-				if utils.IsPAIU(ret.CallerIDNum) && ret.ChannelStateDesc == "Up" {
-					err := RedirectInQueue(ret.Channel, "0300", "default", ret.Channel)
+			//lfshook.NewLogger().Infof("===HangupRunningTask=PAD=======%s==== ", priority.RunningType)
+			/*		chans, err := CoreShowChannels()
 					if err != nil {
-						lfshook.NewLogger().Errorf("Redirect %+v", err)
+						lfshook.NewLogger().Errorf("CoreShowChannels %+v", err)
 					}
-				}
-			}
-
+					lfshook.NewLogger().Infof("===HangupRunningTask=PAD1=======%+v==== ", chans)
+					//1. Redirect the connected PAD to 0300
+					for _, ret := range chans {
+						exten := strings.Split(strings.Split(ret.Channel, "/")[1], "-")[0]
+						if utils.IsPAIU(ret.CallerIDNum) && ret.ChannelStateDesc == "Up" && utils.IsPAIU(exten) {
+							//err := RedirectInQueue(ret.Channel, "0300", "default", "PAD")
+							err := Redirect(ret.Channel, "0300", "default", exten, "PAD")
+							if err != nil {
+								lfshook.NewLogger().Errorf("Redirect %+v", err)
+							}
+						}
+					}
+			*/
 			//2. hangup task channel (ICP + PACU)
 			HangupAllLocalChan()
+			//HangupICP()
 			priority.CleanPriorityTag()
 
 		case "PAD-OCC": // Interrupt PAD-OCC task running,
@@ -138,7 +140,7 @@ func HangupRunningTask(toRunTask string) {
 
 			} else {
 				//1. Hangup connected PAD
-				//Hangup(priority.RunningPATaskChan)
+				Hangup(priority.RunningPATaskChan)
 
 				//2. Redirect all the other pads in 0301 to 0300
 				resCaller, err := QueueStatus("0301", "") // check OCC queue, get entries
@@ -147,6 +149,7 @@ func HangupRunningTask(toRunTask string) {
 				}
 				for _, caller := range resCaller.Entrys {
 					go RedirectInQueue(caller.CallerIDNum, "0300", "default", caller.CallerIDNum) // redirect All PAD redirect to ICP queue
+					time.Sleep(time.Microsecond * 200)
 				}
 
 				//3. Hangup OI & ICP
@@ -311,3 +314,32 @@ func RedirectInQueue(channel, dst, dialrule, callerID string) (err error) {
 	lfshook.NewLogger().Info(res)
 	return err
 }
+
+// Redirect 转接
+func Redirect(channel, dst, dialrule, callerID, callerName string) (err error) {
+	//callerID := "redirect"
+	lfshook.NewLogger().Infof("redirect src %s to dst %s", channel, dst)
+	if !utils.IsChannel(channel) {
+		callerID = channel
+		if channel, err = GetChannelByExten(channel); err != nil {
+			return err
+		}
+	}
+
+	action := map[string]string{
+		"Action":   "Redirect",
+		"Channel":  channel,
+		"Exten":    dst,
+		"Context":  dialrule,
+		"CallerID": fmt.Sprintf("%s<%s>", callerName, callerID),
+		"Priority": "1",
+		"async":    "true",
+	}
+	lfshook.NewLogger().Infof("redirect %+v", action)
+	res, _, err := AminInstance.Send(action)
+	if err != nil {
+		lfshook.NewLogger().Error(err)
+	}
+	lfshook.NewLogger().Info(res)
+	return err
+}

+ 146 - 92
internal/app/ami/action/index.go

@@ -7,6 +7,7 @@ import (
 	"pbx-api-gin/internal/pkg/configs"
 	"pbx-api-gin/pkg/lfshook"
 	"pbx-api-gin/pkg/utils"
+	"sort"
 	"strconv"
 	"strings"
 	"time"
@@ -22,6 +23,27 @@ func HandleAMI(event map[string]string) {
 	//lfshook.NewLogger().Infof("===start======%s", event["Event"]
 
 	switch event["Event"] {
+	case "DTMFBegin":
+		if utils.IsICP(event["CallerIDNum"]) {
+			exten := strings.Split(strings.Split(event["Channel"], "/")[1], "-")[0]
+			if utils.IsICP(exten) {
+				chans, err := CoreShowChannels()
+				if err != nil {
+					lfshook.NewLogger().Errorf("CoreShowChannels %+v", err)
+				}
+				lfshook.NewLogger().Infof("===HangupRunningTask=PAD1=======%+v==== ", chans)
+				//1. Redirect the connected PAD to 0300
+				for _, ret := range chans {
+
+					if utils.IsPAIU(ret.CallerIDNum) && ret.ChannelStateDesc == "Up" && utils.IsPAIU(exten) {
+						err := Redirect(ret.Channel, "0300", "default", exten, "PAD")
+						if err != nil {
+							lfshook.NewLogger().Errorf("Redirect %+v", err)
+						}
+					}
+				}
+			}
+		}
 
 	case "UserEvent": // RCD filename; PA;CPA; CabCab
 		lfshook.NewLogger().Infof("========event:%s   File:%s", event["Event"], event["FILENAME"])
@@ -98,13 +120,18 @@ func HandleAMI(event map[string]string) {
 		lfshook.NewLogger().Infof("=========%s", event["Event"])
 
 		//OCC answer PAD, hangup, redirect the next PAD to OCC
-		if (event["CallerIDNum"] == "ano1" || event["CallerIDNum"] == "ano8") && utils.IsIO(event["ConnectedLineNum"]) {
+		if utils.IsIO(event["CallerIDNum"]) && (event["ConnectedLineNum"] == "ano1" || event["ConnectedLineNum"] == "ano8") && event["Context"] == "default" {
+			lfshook.NewLogger().Infof("====Hangup OCC-PAD=====%+v", event)
+			// OCC hangup detected, hangup other running channels
 			HangupAllLocalChan()
+			Hangup(priority.RunningPATaskChan)
+
 			res, _ := QueueStatus("0301", "") // check OCC queue ,if empty PAD end
 			if res.Calls == "0" {             //OCC queue is empty
 				priority.CleanPriorityTag()
 				alstatus.OccPad("end")
 				priority.OCCAnswer = 0
+				priority.PADOccStart = 0
 
 				if priority.ResumeEmgPara.FileName != "" {
 					time.Sleep(time.Second)
@@ -112,17 +139,47 @@ func HandleAMI(event map[string]string) {
 				}
 				break
 			} else { //OCC queue is not empty
-				HangupAllLocalChan()
-
+				//	HangupAllLocalChan()
+				lfshook.NewLogger().Infof("====Start OCC-PAD===next==%+v", res)
 				if active.ActivedCab == "1" && ExtenStatus("1411") == "Idle" { //check active and OCC status
 					time.Sleep(time.Second)
-					Dial("0401", "0512", "pad-rule-pacus-occ", "ano1", "ano1", "1") // PACUs dial OCC1
-					//goto ConfbridgeJoin, OCC1 answer PAD
+					PADChan := ""
+					for _, chanEntry := range res.Entrys {
+						lfshook.NewLogger().Infof("====PAD answered by OCC1 pos:%s===chan:%s=", chanEntry.Position, chanEntry.Channel)
+						if chanEntry.Position == "1" {
+							PADChan = chanEntry.Channel
+							break
+						}
+					}
+
+					if PADChan != "" {
+						alstatus.AlarmStatus(strings.Split(strings.Split(res.Entrys[0].Channel, "/")[1], "-")[0], "connect")
+						go RedirectInQueue(PADChan, "1411", "pad-page-occ-icp", "1") //PAD Page(OCC+ICPs)
+
+						go Dial("0401", "0512", "pad-rule-pacus-occ", "ano1", "ano1", "1") // PACUs dial OCC1
+					} else {
+						lfshook.NewLogger().Infof("===OCC-QueueStatus==PADCchan NULL")
+					}
 					break
 				} else if active.ActivedCab == "8" && ExtenStatus("1481") == "Idle" {
 					time.Sleep(time.Second)
-					Dial("0401", "0512", "pad-rule-pacus-occ", "ano8", "ano8", "8") // PACUs dial OCC8
-					//goto ConfbridgeJoin, OCC8 answer PAD
+					PADChan := ""
+					for _, chanEntry := range res.Entrys {
+						lfshook.NewLogger().Infof("====PAD answered by OCC1 pos:%s===chan:%s=", chanEntry.Position, chanEntry.Channel)
+						if chanEntry.Position == "1" {
+							PADChan = chanEntry.Channel
+							break
+						}
+					}
+
+					if PADChan != "" {
+						alstatus.AlarmStatus(strings.Split(strings.Split(res.Entrys[0].Channel, "/")[1], "-")[0], "connect")
+						go RedirectInQueue(PADChan, "1481", "pad-page-occ-icp", "8") //PAD Page(OCC+ICPs)
+
+						go Dial("0401", "0512", "pad-rule-pacus-occ", "ano8", "ano8", "8") // PACUs dial OCC1
+					} else {
+						lfshook.NewLogger().Infof("===OCC-QueueStatus==PADCchan NULL")
+					}
 					break
 				}
 			}
@@ -158,7 +215,7 @@ func HandleAMI(event map[string]string) {
 			break
 		}
 
-		if utils.IsPAIU(event["CallerIDNum"]) && event["Queue"] == "0300" { // Alarm join the queue, PAD in the queue
+		if utils.IsPAIU(event["CallerIDNum"]) && utils.IsPAIU(event["CallerIDName"]) && event["Queue"] == "0300" { // Alarm join the queue, PAD in the queue
 			alstatus.AlarmStatus(event["CallerIDNum"], "queue") //send status to STC
 
 			ICPQueue, err := QueueStatus("0300", "") // check ICP queue, get entries
@@ -184,11 +241,16 @@ func HandleAMI(event map[string]string) {
 							lfshook.NewLogger().Infof("==ICP=QueueStatus==%+v", err)
 							return
 						}
+						sort.Slice(resCaller.Entrys, func(i, j int) bool {
+							return resCaller.Entrys[i].Position < resCaller.Entrys[j].Position
+						})
+
 						for _, caller := range resCaller.Entrys {
 							priority.ICPAnswer = 0
-							lfshook.NewLogger().Infof("====Redirect to 0301 entry:%s===", caller.CallerIDNum)
-							go RedirectInQueue(caller.CallerIDNum, "0301", "queues-occ", caller.CallerIDNum) // redirect All ICP-PAD redirect to OCC queue
-							time.Sleep(time.Microsecond * 200)                                               //200 ms delay
+							lfshook.NewLogger().Infof("====Redirect to 0301 entry:%s=Pos:%s==", caller.CallerIDNum, caller.Position)
+							//order by pos
+							RedirectInQueue(caller.CallerIDNum, "0301", "queues-occ", caller.CallerIDNum) // redirect All ICP-PAD redirect to OCC queue
+							time.Sleep(time.Microsecond * 500)                                            //200 ms delay
 						}
 					}
 				})
@@ -198,16 +260,15 @@ func HandleAMI(event map[string]string) {
 		}
 
 		//first PAD caller goto OCC
-		//PACUs dial OCC;
-		//PAD chanspy(WqE) OCC;
-		//ICPs chanspy(qE) PAD;
+		//OCC dial PACUs;
+		//PAD Page OCC+ICPs;
 		if utils.IsPAIU(event["CallerIDNum"]) && event["Queue"] == "0301" && priority.OCCAnswer == 0 { // The first PAD to OCC ,caller is PAD
 
 			if priority.CheckPriority("PAD-OCC") {
 				HangupRunningTask("PAD-OCC") //PAD-OCC interrupt other
 				priority.OCCAnswer = 1
 
-				if active.ActivedCab == "1" && ExtenStatus("1411") == "Idle" { //check active and OCC status
+				if active.ActivedCab == "1" /* && ExtenStatus("1411") == "Idle" */ { //check active and OCC status
 					if priority.PADOccStart == 0 {
 						alstatus.OccPad("start")
 						priority.PADOccStart = 1
@@ -216,9 +277,36 @@ func HandleAMI(event map[string]string) {
 							priority.PADStart = 1
 						}
 					}
-					Dial("0401", "0512", "pad-rule-pacus-occ", "ano1", "ano1", "1") // PACUs dial OCC1
-					//Goto event=ConfbridgeJoin;OCC answer PAD
-				} else if active.ActivedCab == "8" && ExtenStatus("1481") == "Idle" {
+
+					/*res, err := QueueStatus("0301", "") // check OCC queue , if empty OCC-PAD start
+					if err != nil {
+						lfshook.NewLogger().Infof("===OCC-QueueStatus==%+v", err)
+						return
+					}
+
+					lfshook.NewLogger().Infof("===OCC-QueueStatus= res=%+v", res)
+
+					PADChan := ""
+					for _, chanEntry := range res.Entrys {
+						lfshook.NewLogger().Infof("====PAD answered by OCC1 pos:%s===chan:%s=", chanEntry.Position, chanEntry.Channel)
+						if chanEntry.Position == "1" {
+							PADChan = chanEntry.Channel
+							break
+						}
+					}
+					*/
+					//if PADChan != "" {
+					//alstatus.AlarmStatus(strings.Split(strings.Split(res.Entrys[0].Channel, "/")[1], "-")[0], "connect")
+					alstatus.AlarmStatus(event["CallerIDNum"], "connect")
+					go RedirectInQueue(event["Channel"], "1411", "pad-page-occ-icp", "1") //PAD Page(OCC+ICPs)
+					//go RedirectInQueue(PADChan, "1411", "pad-page-occ-icp", "1") //PAD Page(OCC+ICPs)
+
+					go Dial("0401", "0512", "pad-rule-pacus-occ", "ano1", "ano1", "1") // PACUs dial OCC1
+					//	} else {
+					//	lfshook.NewLogger().Infof("===OCC-QueueStatus==PADCchan NULL")
+					//}
+
+				} else if active.ActivedCab == "8" /*&& ExtenStatus("1481") == "Idle" */ {
 					if priority.PADOccStart == 0 {
 						alstatus.OccPad("start")
 						priority.PADOccStart = 1
@@ -227,8 +315,29 @@ func HandleAMI(event map[string]string) {
 							priority.PADStart = 1
 						}
 					}
-					Dial("0401", "0512", "pad-rule-pacus-occ", "ano8", "ano8", "8") // PACUs dial OCC8
-					//Goto event=ConfbridgeJoin;OCC answer PAD
+					/*		res, err := QueueStatus("0301", "") // check OCC queue , if empty OCC-PAD start
+							if err != nil {
+								lfshook.NewLogger().Infof("===OCC-QueueStatus==%+v", err)
+								return
+							}
+							PADChan := ""
+							for _, chanEntry := range res.Entrys {
+								lfshook.NewLogger().Infof("====PAD answered by OCC1 pos:%s===chan:%s=", chanEntry.Position, chanEntry.Channel)
+								if chanEntry.Position == "1" {
+									PADChan = chanEntry.Channel
+									break
+								}
+							}
+					*/
+					//if PADChan != "" {
+					//alstatus.AlarmStatus(strings.Split(strings.Split(res.Entrys[0].Channel, "/")[1], "-")[0], "connect")
+					//go RedirectInQueue(PADChan, "1481", "pad-page-occ-icp", "8") //PAD Page(OCC+ICPs);goto confbrdigeIoin
+					alstatus.AlarmStatus(event["CallerIDNum"], "connect")
+					go RedirectInQueue(event["Channel"], "1411", "pad-page-occ-icp", "1") //PAD Page(OCC+ICPs)
+					go Dial("0401", "0512", "pad-rule-pacus-occ", "ano8", "ano8", "8")    // PACUs dial OCC1
+					//} else {
+					//	lfshook.NewLogger().Infof("===OCC-QueueStatus==PADCchan NULL")
+					//}
 				}
 			} else {
 				lfshook.NewLogger().Infof("====PAD-OCC Priority false===")
@@ -313,7 +422,9 @@ func HandleAMI(event map[string]string) {
 			return
 		}
 
-		//ICP answer PAD;
+		//ICP answer PAD;PACUs connected ICP
+		//PAD chanspy ICP1
+		//ICP8 call PAD
 		if event["ConnectedLineNum"] == "ani1" && event["Exten"] == "0511" { //PAD answered by ICP; PACUs connected ICP1
 			lfshook.NewLogger().Infof("====PAD answered by ICP1:%s=====", event["ConnectedLineName"])
 			alstatus.AlarmStatus(event["ConnectedLineName"], "connect")
@@ -321,10 +432,10 @@ func HandleAMI(event map[string]string) {
 			priority.RunningPATaskChan = event["Channel"]
 			priority.RunningType = "PAD-ICP"
 			priority.RunningTypePriority, _ = strconv.Atoi(priority.Priority.PADICP)
-			go RedirectInQueue(event["ConnectedLineName"], "2311", "chanspy-rule-whisper", event["ConnectedLineName"])               //PAD chanspy(EqW) ICP1
-			go Dial("0402", event["ConnectedLineName"], "chanspy-rule", event["ConnectedLineName"], event["ConnectedLineName"], "8") //ICP8 chanspy PAD
-			//goto event=ChanSpyStart; PAD whisper ICP8
-			break
+			go RedirectInQueue(event["ConnectedLineName"], "2311", "chanspy-rule-whisper", event["ConnectedLineName"]) //PAD chanspy(EqW) ICP1
+
+			go Dial("0402", event["ConnectedLineName"], "call-pad-rule", event["ConnectedLineName"], event["ConnectedLineName"], "8") // PAD call ICP8
+
 		}
 		if event["ConnectedLineNum"] == "ani8" && event["Exten"] == "0511" { //PAD ansered by ICP8; PACUs connected ICP8
 			lfshook.NewLogger().Infof("====PAD answered by ICP8:%s=====", event["ConnectedLineName"])
@@ -333,84 +444,28 @@ func HandleAMI(event map[string]string) {
 			priority.RunningPATaskChan = event["Channel"]
 			priority.RunningType = "PAD-ICP"
 			priority.RunningTypePriority, _ = strconv.Atoi(priority.Priority.PADICP)
-			go RedirectInQueue(event["ConnectedLineName"], "2381", "chanspy-rule-whisper", event["ConnectedLineName"])               //PAD chanspy(EqW) ICP8
-			go Dial("0402", event["ConnectedLineName"], "chanspy-rule", event["ConnectedLineName"], event["ConnectedLineName"], "1") //ICP1 chanspy PAD
-			//goto event=ChanSpyStart; PAD whisper ICP1
-			break
-		}
+			go RedirectInQueue(event["ConnectedLineName"], "2381", "chanspy-rule-whisper", event["ConnectedLineName"]) //PAD chanspy(EqW) ICP8
 
-		//OCC1 answer PAD;
-		if utils.IsIO(event["CallerIDNum"]) && event["Exten"] == "0512" && event["ConnectedLineName"] == "ano1" { //PAD answered by OCC1; PACUs connected IO1
-			lfshook.NewLogger().Infof("====PAD answered by OCC1:====")
-
-			priority.RunningPATaskChan = event["Channel"]
-			priority.RunningType = "PAD-OCC"
-			priority.RunningTypePriority, _ = strconv.Atoi(priority.Priority.PADOCC)
-
-			res, err := QueueStatus("0301", "") // check OCC queue , if empty OCC-PAD start
-			if err != nil {
-				lfshook.NewLogger().Infof("===OCC-QueueStatus==%+v", err)
-				return
-			}
-
-			PADChan := ""
-			for _, chanEntry := range res.Entrys {
-				lfshook.NewLogger().Infof("====PAD answered by OCC1 pos:%s===chan:%s=", chanEntry.Position, chanEntry.Channel)
-				if chanEntry.Position == "1" {
-					PADChan = chanEntry.Channel
-					break
-				}
-			}
+			go Dial("0402", event["ConnectedLineName"], "call-pad-rule", event["ConnectedLineName"], event["ConnectedLineName"], "1") // PAD call ICP2
 
-			if PADChan != "" {
-				alstatus.AlarmStatus(strings.Split(strings.Split(res.Entrys[0].Channel, "/")[1], "-")[0], "connect")
-				go RedirectInQueue(PADChan, "1411", "chanspy-rule-whisper", event["ConnectedLineName"]) //PAD chanspy(EqW) IO1
-			} else {
-				lfshook.NewLogger().Infof("===OCC-QueueStatus==PADCchan NULL")
-			}
-			//goto event=ChanSpyStart; ICPs spy PAD
 			break
 		}
 
-		//OCC8 answer PAD;
-		if utils.IsIO(event["CallerIDNum"]) && event["Exten"] == "0512" && event["ConnectedLineName"] == "ano8" { //PAD ansered by OCC8; PACUs connected IO8
-			lfshook.NewLogger().Infof("====PAD answered by OCC8:%s=====", event["ConnectedLineName"])
+		//OCC answer PAD;Set the task channel
+		if utils.IsPAIU(event["CallerIDNum"]) && utils.IsIO(event["Exten"]) && event["Context"] == "pad-page-occ-icp" { //PAD Page OCC1+ICPs connected
+			lfshook.NewLogger().Infof("====PAD answered by OCC:====")
 
 			priority.RunningPATaskChan = event["Channel"]
 			priority.RunningType = "PAD-OCC"
 			priority.RunningTypePriority, _ = strconv.Atoi(priority.Priority.PADOCC)
-
-			res, err := QueueStatus("0301", "") // check OCC queue , if empty OCC-PAD start
-			if err != nil {
-				lfshook.NewLogger().Infof("===OCC-QueueStatus==%+v", err)
-				return
-			}
-
-			PADChan := ""
-			for _, chanEntry := range res.Entrys {
-				lfshook.NewLogger().Infof("====PAD answered by OCC8 pos:%s===chan:%s=", chanEntry.Position, chanEntry.Channel)
-				if chanEntry.Position == "1" {
-					PADChan = chanEntry.Channel
-					break
-				}
-			}
-
-			if PADChan != "" {
-				alstatus.AlarmStatus(strings.Split(strings.Split(res.Entrys[0].Channel, "/")[1], "-")[0], "connect")
-				go RedirectInQueue(PADChan, "1481", "chanspy-rule-whisper", event["ConnectedLineName"]) //PAD chanspy(EqW) IO8
-			} else {
-				lfshook.NewLogger().Infof("===OCC-QueueStatus==PADCchan NULL")
-			}
-			//goto event=ChanSpyStart; ICPs spy PAD
 			break
 		}
-
 	case "ChanSpyStart":
 		lfshook.NewLogger().Infof("=========event:%s   callerid:%s   SpyeeConnectedLineName:%s  SpyerExten:%s", event["Event"], event["CallerIDNum"], event["SpyeeConnectedLineName"], event["SpyerExten"])
 		//PAD answered by OCC; ICPs chanspy PAD
-		if utils.IsPAIU(event["SpyeeConnectedLineName"]) && utils.IsIO(event["SpyerExten"]) { // check if it is PAD whisper IO/OCC
-			go Dial("0404", event["SpyeeConnectedLineName"], "chanspy-rule", "ano", "ano", "") //ICPs chanspy PAD
-		}
+		//if utils.IsPAIU(event["SpyeeConnectedLineName"]) && utils.IsIO(event["SpyerExten"]) { // check if it is PAD whisper IO/OCC
+		//go Dial("0404", event["SpyeeConnectedLineName"], "chanspy-rule", "ano", "ano", "") //ICPs chanspy PAD
+		//}
 
 	case "ConfbridgeLeave":
 		lfshook.NewLogger().Infof("=========%s", event["Event"])
@@ -470,7 +525,6 @@ func HandleAMI(event map[string]string) {
 			if priority.ResumeEmgPara.FileName != "" {
 				CheckEmgResume()
 			}
-
 		}
 
 	case "DialEnd":
@@ -513,10 +567,10 @@ func HandleAMI(event map[string]string) {
 			priority.RunningTypePriority, _ = strconv.Atoi(priority.Priority.PADTMS)
 			if active.ActivedCab == "1" {
 				go RedirectInQueue(event["CallerIDName"], "2311", "chanspy-rule-whisper", "") //PAD chanspy(EqW) ICP1
-				go Dial("0403", event["CallerIDName"], "chanspy-rule", "2381", "2381", "8")   //ICP8---chanspy----PAD
+				go Dial("0403", event["CallerIDName"], "call-pad-rule", "2381", "2381", "8")   //ICP8---call----PAD
 			} else if active.ActivedCab == "8" {
 				go RedirectInQueue(event["CallerIDName"], "2381", "chanspy-rule-whisper", "") //PAD chanspy(EqW) ICP8
-				go Dial("0403", event["CallerIDName"], "chanspy-rule", "2311", "2311", "1")   //ICP1---chanspy----PAD
+				go Dial("0403", event["CallerIDName"], "call-pad-rule", "2311", "2311", "1")   //ICP1---call----PAD
 			}
 		} else if utils.IsPAIU(event["CallerIDNum"]) && event["Exten"] == "0405" { // PAD connect ICP-TMS;PACU not available
 

+ 4 - 5
internal/app/stc/broadcast/stc-broadcast.go

@@ -324,7 +324,8 @@ func SelfCheck(data []byte) {
 
 	check := data[8]
 	delay := data[9]
-	cycleCount := data[10]
+	//cycleCount := data[10]
+	cycleCount := 0x32
 	datalen := int(data[11])
 
 	filename := msgdata.SubstrByRune(string(data[12:]), 0, datalen-4)
@@ -364,8 +365,7 @@ func AlarmHandleICP(data []byte) {
 
 	//Drop other handler in 2 sec
 	//PACUs---call---->ICP1
-	//PAD---->Chanspy(WEq)-->ICP1
-	//ICP2--->Chanspy(Eq)---->PAD
+	//PAD---->Chanspy(WEq)-->ICP1;PAD--->Call---->ICP2
 	if handler == 0x01 {
 		if _, loaded := suppressedExts.LoadOrStore(key, struct{}{}); loaded {
 			lfshook.NewLogger().Logger.Infof("Suppressed duplicate ICP Alarm (handler=0x01) for exten: %s within 4 seconds", exten)
@@ -441,8 +441,7 @@ func AlarmHandleTMS(data []byte) {
 	switch handler {
 	case 0x01: //answer(ICP+Alarm+PACU)
 		//PACU---call---->ICP1
-		//PAD---->Chanspy(WEq)-->ICP1
-		//ICP2--->spy(Eq)---->PAD
+		//PAD---->Chanspy(WEq)-->ICP1;PAD--->Call---->ICP2
 		if priority.PADStart == 0 {
 			alstatus.PaStatus(exten, "PAD", "start")
 			priority.PADStart = 1

+ 0 - 12
internal/app/stc/index.go

@@ -316,15 +316,3 @@ func SendheartbeatToSipServer(ctx context.Context, conn net.Conn) {
 		}
 	}
 }
-
-// 检查PA server是主状态还是从状态
-func CheckMaster(conn net.Conn) bool {
-	//	var count uint8
-	//init heartbeat data
-	protocol := msgdata.NewProtocol()
-	protocol.SourceID = 0x02
-	protocol.DestinationID = 0x01
-	protocol.MessageID = 0x21
-	protocol.DataLength = 0x04
-	return false
-}

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

@@ -105,6 +105,7 @@ func GetPriorityByKey(key string) string {
 
 // check priority , if the running priority is lowwer than the to run priority
 func CheckPriority(runType string) bool {
+	return true
 	lfshook.NewLogger().Logger.Infof("=========Check Pri runType:%s====RunningTypePriority:%d====SpecialVoice:%d========", runType, RunningTypePriority, SpecialVoice)
 	//Check special voice can not interrupt
 	if SpecialVoice == 1 {