浏览代码

1.优化广播状态反馈机制;2.优化优先级判断机制

dujunchen 2 周之前
父节点
当前提交
bbe6efe654

+ 10 - 1
internal/app/ami/action/call.go

@@ -94,8 +94,17 @@ func HangupAllExcept(caller string) {
 
 // Hangup all ICP
 func HangupRunningTask(toRunTask string) {
-	lfshook.NewLogger().Infof("===HangupRunningTask=task=%+v", toRunTask)
+	lfshook.NewLogger().Infof("===HangupRunningTask=toRuntask=%s   RunningTask:%s  ", toRunTask, priority.RunningType)
+
+	//same type return
+	if toRunTask == priority.RunningType {
+		if toRunTask == "PAD-ICP" || toRunTask == "PAD-TMS" {
+			return
+		}
+	}
+
 	if priority.RunningPATaskChan != "" {
+
 		switch priority.RunningType {
 
 		case "PAD-ICP", "PAD-TMS": // Interrupt PAD task running,

+ 18 - 11
internal/app/ami/action/index.go

@@ -91,7 +91,11 @@ func HandleAMI(event map[string]string) {
 	case "Newchannel":
 		//lfshook.NewLogger().Infof("=========%s", event["Event"])
 		if utils.IsPAIU(event["CallerIDNum"]) && event["Exten"] == "0300" { // Alarm dial queue start; PAD dialing
-			alstatus.PaStatus(event["CallerIDNum"], "PAD", "start")
+			if priority.PADStart == 0 {
+				priority.PADStart = 1
+				alstatus.PaStatus(event["CallerIDNum"], "PAD", "start")
+			}
+
 			alstatus.AlarmStatus(event["CallerIDNum"], "dial")
 		}
 
@@ -147,7 +151,10 @@ func HandleAMI(event map[string]string) {
 			res, _ := QueueStatus("0300", "") // check ICP queue ,if empty PAD end
 			if res.Calls == "0" {
 				priority.CleanPriorityTag()
-				alstatus.PaStatus(event["CallerIDNum"], "PAD", "end")
+				if priority.PADStart == 1 && utils.IsPAIU(event["CallerIDNum"]) {
+					alstatus.PaStatus(event["CallerIDNum"], "PAD", "end")
+					priority.PADStart = 0
+				}
 				if priority.ResumeEmgPara.FileName != "" {
 					CheckEmgResume()
 				}
@@ -161,7 +168,10 @@ func HandleAMI(event map[string]string) {
 			res, _ := QueueStatus("0300", "") // check ICP queue ,if empty PAD end
 			if res.Calls == "0" {
 				priority.CleanPriorityTag()
-				alstatus.PaStatus(event["CallerIDNum"], "PAD", "end")
+				if priority.PADStart == 1 && utils.IsPAIU(event["CallerIDNum"]) {
+					alstatus.PaStatus(event["CallerIDNum"], "PAD", "end")
+					priority.PADStart = 0
+				}
 				if priority.ResumeEmgPara.FileName != "" {
 					CheckEmgResume()
 				}
@@ -175,7 +185,10 @@ func HandleAMI(event map[string]string) {
 			res, _ := QueueStatus("0300", "") // check ICP queue ,if empty PAD end
 			if res.Calls == "0" {
 				priority.CleanPriorityTag()
-				alstatus.PaStatus(event["CallerIDNum"], "PAD", "end")
+				if priority.PADStart == 1 && utils.IsPAIU(event["CallerIDNum"]) {
+					alstatus.PaStatus(event["CallerIDNum"], "PAD", "end")
+					priority.PADStart = 0
+				}
 				if priority.ResumeEmgPara.FileName != "" {
 					CheckEmgResume()
 				}
@@ -287,7 +300,6 @@ func HandleAMI(event map[string]string) {
 		//set priority and send PA status msg
 		switch event["CallerIDName"] {
 		case "EMG":
-			alstatus.PaStatus(event["CallerIDNum"], "EMG", "start")
 			priority.RunningPATaskChan = event["Channel"]
 			priority.RunningType = "EMG"
 			//Pa status report
@@ -295,7 +307,6 @@ func HandleAMI(event map[string]string) {
 			alstatus.PaStatus("", "EMG", "start")
 
 		case "SPC":
-			alstatus.PaStatus(event["CallerIDNum"], "SPC", "start")
 			priority.RunningPATaskChan = event["Channel"]
 			priority.RunningType = "SPC"
 			//Pa status report
@@ -303,7 +314,6 @@ func HandleAMI(event map[string]string) {
 			alstatus.PaStatus("", "SPC", "start")
 
 		case "DCS":
-			alstatus.PaStatus(event["CallerIDNum"], "DCS", "start")
 			priority.RunningPATaskChan = event["Channel"]
 			priority.RunningType = "DCS"
 			//Pa status report
@@ -311,7 +321,6 @@ func HandleAMI(event map[string]string) {
 			alstatus.PaStatus("", "DCS", "start")
 
 		case "STN":
-			alstatus.PaStatus(event["CallerIDNum"], "STN", "start")
 			priority.RunningPATaskChan = event["Channel"]
 			priority.RunningType = "STN"
 			//Pa status report
@@ -319,7 +328,6 @@ func HandleAMI(event map[string]string) {
 			alstatus.PaStatus("", "STN", "start")
 
 		case "CHK":
-			alstatus.PaStatus(event["CallerIDNum"], "CHK", "start")
 			priority.RunningPATaskChan = event["Channel"]
 			priority.RunningType = "CHK"
 			//Pa status report
@@ -327,7 +335,6 @@ func HandleAMI(event map[string]string) {
 			alstatus.PaStatus("", "CHK", "start")
 
 		case "VOL": // tone-test
-			alstatus.PaStatus(event["CallerIDNum"], "VOL", "start")
 			priority.RunningPATaskChan = event["Channel"]
 			priority.RunningType = "VOL"
 			//Pa status report
@@ -458,7 +465,7 @@ func HandleAMI(event map[string]string) {
 				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
 			}
-		} else if utils.IsPAIU(event["CallerIDNum"]) { // PAD connect ICP-TMS;PACU not available
+		} else if utils.IsPAIU(event["CallerIDNum"]) && event["Exten"] == "0405" { // PAD connect ICP-TMS;PACU not available
 
 			priority.RunningPATaskChan = event["Channel"]
 			priority.RunningType = "PAD-TMS"

+ 2 - 0
internal/app/ami/action/playback.go

@@ -24,6 +24,8 @@ func PlaybackPacu(filename string, count int, delay int, PaType string) (err err
 		Chan = "Local/0510" //paging pacu
 	case "EMG":
 		Chan = "Local/0502" //emg-rule
+	case "VOL":
+		Chan = "Local/0513" //emg-rule
 	}
 
 	action := map[string]string{

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

@@ -126,7 +126,7 @@ func processPacket(packet []byte) {
 			alstatus.PaStatus("", "CHK", "refuse")
 		}
 
-	case 0x10: // Tone-test
+	case 0x0a: // Tone-test
 		if priority.CheckPriority("VOL") && active.Actived {
 			//check active signal  before VOL
 			if !active.Actived {
@@ -139,11 +139,10 @@ func processPacket(packet []byte) {
 			alstatus.PaStatus("", "VOL", "refuse")
 		}
 
-	case 0x0a: //TMS answer PAD
+	case 0x0e: //TMS answer PAD
 		if priority.CheckPriority("PAD-TMS") {
 			action.HangupRunningTask("PAD-TMS") //PAD-TMS interrupt other
-			AlarmHandleICP(packet)              //for test
-			//AlarmHandleTMS(packet)
+			AlarmHandleTMS(packet)
 		} else {
 			alstatus.PaStatus("", "PAD-TMS", "refuse")
 		}

+ 30 - 8
internal/app/stc/priority/index.go

@@ -15,6 +15,7 @@ var RunningTypePriority = 0
 var RunningType = ""
 var SpecialVoice = 0
 var RunningPATaskChan = ""
+var PADStart = 0
 
 type BroadcastResumeParas struct {
 	FileName      string `json:"filename"`
@@ -104,38 +105,59 @@ func GetPriorityByKey(key string) string {
 // check priority , if the running priority is lowwer than the to run priority
 func CheckPriority(runType string) bool {
 	lfshook.NewLogger().Logger.Infof("=========Check Pri runType:%s====RunningTypePriority:%d====SpecialVoice:%d========", runType, RunningTypePriority, SpecialVoice)
-	//check special voice
+	//Check special voice can not interrupt
 	if SpecialVoice == 1 {
 		return false
 	}
 
-	//no any runing task
+	//No any runing task now
 	if RunningTypePriority == 0 {
 		return true
 	}
 
-	//get the priority to run in the config file
+	//Get the to run priority number in the config file
 	ret, err := strconv.Atoi(GetPriorityByKey(runType))
 	if err != nil {
 		lfshook.NewLogger().Logger.Infof("=========Check Pri GetPriorityByKey err:%+v", err)
 		return false
 	}
 
-	if ret == RunningTypePriority && runType == "VOL" {
-		return true
-	}
-	if ret == RunningTypePriority && runType == "CHK" {
-		return true
+	//special same priority number task return true
+	if ret == RunningTypePriority {
+		switch runType {
+		case "PAD-ICP":
+			return true
+		case "PAD-TMS":
+			return true
+			/*	case "VOL":
+					return true
+				case "CHK":
+					return true*/
+		}
 	}
+
 	//if the running task priority is lowwer
 	if ret < RunningTypePriority && ret != 0 {
 		return true
+	} else {
+		//C2C run together with other task except ..
+		if RunningType == "C2C" {
+			if runType != "PA" || runType != "PAD-ICP" || runType != "PAD-TMS" || runType != "C2C" {
+				return true
+			}
+		} else if runType == "C2C" {
+			if RunningType != "PA" || RunningType != "PAD-ICP" || RunningType != "PAD-TMS" || RunningType != "C2C" {
+				return true
+			}
+		}
 	}
 	return false
 }
 
 // Clean all priority tag
 func CleanPriorityTag() {
+	lfshook.NewLogger().Logger.Infof("=========CleanPriorityTag===============")
+
 	ICPAnswer = 0
 	OCCAnswer = 0
 	RunningTypePriority = 0

+ 2 - 2
internal/app/stc/sendstatus/status.go

@@ -99,10 +99,10 @@ func PaStatus(src string, patype string, operation string) {
 		protocol.Data[0] = 0x01
 	case "2381": //mc8
 		protocol.Data[0] = 0x08
-	case "1411": //mc8
+	/*case "1411": //mc8
 		protocol.Data[0] = 0x08
 	case "1481": //mc8
-		protocol.Data[0] = 0x08
+		protocol.Data[0] = 0x08*/
 	default: //
 		protocol.Data[0] = 0x00
 	}