dujunchen преди 1 месец
родител
ревизия
acc73ffaab
променени са 3 файла, в които са добавени 69 реда и са изтрити 10 реда
  1. 18 3
      internal/app/ami/action/call.go
  2. 48 4
      internal/app/ami/action/index.go
  3. 3 3
      internal/app/stc/broadcast/stc-broadcast.go

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

@@ -207,7 +207,9 @@ func InterruptRunningTask(toRunTask string) {
 		for _, ret := range chans {
 			// Redirect the connected PAD to 0300
 			if utils.IsPAIU(ret.CallerIDNum) {
-				if ret.ConnectedLineNum == "<unknown>" { //redirect pad chanspy channel
+				lfshook.NewLogger().Infof("====interrupt PAD ==== %+v ", ret)
+
+				if utils.IsICP(ret.ConnectedLineNum) { //redirect pad chanspy channel
 					err := Redirect(ret.Channel, "0300", "queues-icp-redirect", "", "PAD")
 					if err != nil {
 						lfshook.NewLogger().Infof("InterruptRunningTask Redirect err:%+v", err)
@@ -364,7 +366,7 @@ func Dial(src, dst, dialrule, callerID, callerName string, callType string) {
 		"Variable": fmt.Sprintf("CAB=%s", callType),
 		"async":    "true",
 	}
-	//lfshook.NewLogger().Infof("dial action %+v", action)
+	lfshook.NewLogger().Infof("================dial action %+v", action)
 	res, _, err := AminInstance.Send(action)
 	if err != nil {
 		lfshook.NewLogger().Errorf("%+v", err)
@@ -566,12 +568,25 @@ func SetPadTimer() {
 					for _, caller := range resCaller.Entrys {
 						priority.ICPAnswer = 0
 						//lfshook.NewLogger().Infof("====SetPadTimer==QueueTimer==2=")
-						//lfshook.NewLogger().Infof("==SetPadTimer==Redirect to 0301 entry:%s=Pos:%s==", caller.CallerIDNum, caller.Position)
+						lfshook.NewLogger().Infof("Q300==SetPadTimer==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.Millisecond * 100)                                            //200 ms delay
 					}
 				}
+
+				//==============test info =====================
+				/*
+					time.Sleep(2 * time.Second)
+					occque, err1 := QueueStatus("0301", "") // check ICP queue, get entries
+					if err1 != nil {
+						lfshook.NewLogger().Infof("ICP QueueStatus err:%+v", err)
+						return
+					}
+
+					for _, caller := range occque.Entrys {
+						lfshook.NewLogger().Infof("Q301==SetPadTimer==Redirect to 0301 entry:%s=Pos:%s==", caller.CallerIDNum, caller.Position)
+					}*/
 			}
 		})
 	}

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

@@ -502,6 +502,20 @@ func HandleAMI(event map[string]string) {
 								time.Sleep(time.Millisecond * 100)                                            //200 ms delay
 							}
 						}
+
+						//==============test info =====================
+						/*
+							time.Sleep(2 * time.Second)
+							occque, err1 := QueueStatus("0301", "") // check ICP queue, get entries
+							if err1 != nil {
+								lfshook.NewLogger().Infof("ICP QueueStatus err:%+v", err)
+								return
+							}
+
+							for _, caller := range occque.Entrys {
+								lfshook.NewLogger().Infof("Q301====666666=SetPadTimer= entry:%s=Pos:%s==", caller.CallerIDNum, caller.Position)
+							}*/
+
 					}
 				})
 			}
@@ -1036,6 +1050,36 @@ func HandleAMI(event map[string]string) {
 			}
 		}
 
+		//TMS Answer PAD (有时asterisk反馈的BridgeEnter事件有问题,根据dialend判断)
+		if utils.IsPAIU(event["CallerIDName"]) && utils.IsPACU(event["CallerIDNum"]) && event["DialStatus"] == "ANSWER" && event["Exten"] == "0403" {
+			lfshook.NewLogger().Infof("====BridgeEnter==IN action===%s===ID:%s   Name:%s", event["Event"], event["CallerIDNum"], event["CallerIDName"])
+			alstatus.AlarmStatus(event["CallerIDName"], "connect") // Alarm connected
+
+			//=============================
+			task := priority.TaskInfo{
+				RunChannel:   event["Channel"],
+				LocalChan:    event["Channel"],
+				RunType:      "PAD-TMS",
+				Priority:     priority.AllTasks.PADTMS.Priority,
+				ConfbridgeID: "",
+				Running:      true,
+			}
+			priority.RegistryTask.Register("PAD-TMS", task)
+
+			lfshook.NewLogger().Infof("=========PAD-TMS answer==ListAll===%+v", priority.RegistryTask.ListAll())
+
+			if active.ActivedCab == "1" {
+				go RedirectInQueue(event["CallerIDName"], "2311", "chanspy-rule-whisper", "") //PAD chanspy(EqW) ICP1
+				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"], "call-pad-rule", "2311", "2311", "1")  //ICP1---call----PAD
+			} else if active.ActivedCab == "" {
+				go RedirectInQueue(event["CallerIDName"], "2311", "chanspy-rule-whisper", "") //PAD chanspy(EqW) ICP1
+				go Dial("0403", event["CallerIDName"], "call-pad-rule", "2381", "2381", "8")  //ICP8---call----PAD
+			}
+		}
+
 	case "BridgeLeave":
 		//lfshook.NewLogger().Infof("=========%s", event["Event"])
 		//Cab Cab end
@@ -1064,7 +1108,7 @@ func HandleAMI(event map[string]string) {
 		}
 
 	case "BridgeEnter": // TMS-ICP answer PAD; PACU connect ICP
-		//lfshook.NewLogger().Infof("=========event:%s   callerid:%s", event["Event"], event["CallerIDNum"])
+		lfshook.NewLogger().Infof("=========event:%s   callerid-num:%s callerid-name:%s", event["Event"], event["CallerIDNum"], event["CallerIDName"])
 
 		//PAD-OCC start
 		if utils.IsIO(event["CallerIDNum"]) && utils.IsPAIU(event["ConnectedLineNum"]) {
@@ -1079,8 +1123,8 @@ func HandleAMI(event map[string]string) {
 			}
 		}
 
-		if utils.IsPACU(event["CallerIDNum"]) && utils.IsPAIU(event["CallerIDName"]) { //ICP and PACU connected
-			//lfshook.NewLogger().Infof("====BridgeEnter==IN action===%s===ID:%s   Name:%s", event["Event"], event["CallerIDNum"], event["CallerIDName"])
+		/*if utils.IsPACU(event["CallerIDNum"]) && utils.IsPAIU(event["CallerIDName"]) { //ICP and PACU connected -----TMS Answer PAD
+			lfshook.NewLogger().Infof("====BridgeEnter==IN action===%s===ID:%s   Name:%s", event["Event"], event["CallerIDNum"], event["CallerIDName"])
 			alstatus.AlarmStatus(event["CallerIDName"], "connect") // Alarm connected
 
 			//=============================
@@ -1106,7 +1150,7 @@ func HandleAMI(event map[string]string) {
 				go RedirectInQueue(event["CallerIDName"], "2311", "chanspy-rule-whisper", "") //PAD chanspy(EqW) ICP1
 				go Dial("0403", event["CallerIDName"], "call-pad-rule", "2381", "2381", "8")  //ICP8---call----PAD
 			}
-		} else if utils.IsPAIU(event["CallerIDNum"]) && event["Exten"] == "0405" { // PAD connect ICP-TMS;PACU not available
+		} else*/if utils.IsPAIU(event["CallerIDNum"]) && event["Exten"] == "0405" { // PAD connect ICP-TMS;PACU not available
 
 			//=============================
 			task := priority.TaskInfo{

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

@@ -666,13 +666,13 @@ func AlarmHandleTMS(data []byte) {
 		lfshook.NewLogger().Logger.Infof("==============TMS Answer PAD Exten:%s PACU:%s==========", exten, PacuNum)
 		if action.ExtenStatus(PacuNum) == "Idle" {
 			if active.ActivedCab == "1" {
-				action.Dial("0403", PacuNum, "default", PacuNum, exten, "1") // PACU dial ICP1
+				action.Dial("0403", PacuNum, "pad-tms-dial-pacu", PacuNum, exten, "1") // PACU dial ICP1
 				//goto ami event BridgeEnter, ICP8 whisper ICP1
 			} else if active.ActivedCab == "8" {
-				action.Dial("0403", PacuNum, "default", PacuNum, exten, "8") // PACU dial ICP8
+				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, "default", PacuNum, exten, "1") // PACU dial ICP1
+				action.Dial("0403", PacuNum, "pad-tms-dial-pacu", PacuNum, exten, "1") // PACU dial ICP1
 			}
 		} else {
 			action.RedirectInQueue(exten, "0405", "default", exten) // PAD dial ICPs