|
|
@@ -15,9 +15,7 @@ import (
|
|
|
"pbx-api-gin/internal/app/stc/priority"
|
|
|
alstatus "pbx-api-gin/internal/app/stc/sendstatus"
|
|
|
"pbx-api-gin/pkg/lfshook"
|
|
|
- "sort"
|
|
|
"strconv"
|
|
|
- "strings"
|
|
|
"sync"
|
|
|
"time"
|
|
|
|
|
|
@@ -85,82 +83,82 @@ func processPacket(packet []byte) {
|
|
|
|
|
|
switch packet[5] {
|
|
|
case 0x01: //heartbeat
|
|
|
-
|
|
|
- //PAD-OCC异常情况处理
|
|
|
- if priority.OCCAnswer == 1 {
|
|
|
- //定时监测ICP queue 转到OCC queue, 避免异常情形下PAD进入ICP queue之后无法被接听
|
|
|
- resCaller, err := action.QueueStatus("0300", "") // check ICP queue, get entries
|
|
|
- if err != nil {
|
|
|
- lfshook.NewLogger().Infof("==ICP=QueueStatus==%+v", err)
|
|
|
- return
|
|
|
- }
|
|
|
- if resCaller.Calls != "0" {
|
|
|
- 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=Pos:%s==", caller.CallerIDNum, caller.Position)
|
|
|
- //order by pos
|
|
|
- action.RedirectInQueue(caller.CallerIDNum, "0301", "queues-occ", caller.CallerIDNum) // redirect All ICP-PAD redirect to OCC queue
|
|
|
- time.Sleep(time.Microsecond * 200) //200 ms delay
|
|
|
+ /*
|
|
|
+ //PAD-OCC异常情况处理
|
|
|
+ if priority.OCCAnswer == 1 {
|
|
|
+ //定时监测ICP queue 转到OCC queue, 避免异常情形下PAD进入ICP queue之后无法被接听
|
|
|
+ resCaller, err := action.QueueStatus("0300", "") // check ICP queue, get entries
|
|
|
+ if err != nil {
|
|
|
+ lfshook.NewLogger().Infof("==ICP=QueueStatus==%+v", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if resCaller.Calls != "0" {
|
|
|
+ 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=Pos:%s==", caller.CallerIDNum, caller.Position)
|
|
|
+ //order by pos
|
|
|
+ action.RedirectInQueue(caller.CallerIDNum, "0301", "queues-occ", caller.CallerIDNum) // redirect All ICP-PAD redirect to OCC queue
|
|
|
+ time.Sleep(time.Microsecond * 200) //200 ms delay
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- //定时监测OCC queue, 避免异常情况下PAD 在OCC queue里面不能自动转到OCC
|
|
|
- res, err := action.QueueStatus("0301", "") // check OCC queue ,if empty PAD end
|
|
|
- if err != nil {
|
|
|
- lfshook.NewLogger().Infof("==OCC=QueueStatus==%+v", err)
|
|
|
- return
|
|
|
- }
|
|
|
- if res.Calls != "0" { //OCC queue is not empty
|
|
|
- // HangupAllLocalChan()
|
|
|
- lfshook.NewLogger().Infof("====Start OCC-PAD===next==%+v", res)
|
|
|
- if active.ActivedCab == "1" && action.ExtenStatus("1411") == "Idle" { //check active and OCC status
|
|
|
- time.Sleep(time.Second)
|
|
|
- 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
|
|
|
+ //定时监测OCC queue, 避免异常情况下PAD 在OCC queue里面不能自动转到OCC
|
|
|
+ res, err := action.QueueStatus("0301", "") // check OCC queue ,if empty PAD end
|
|
|
+ if err != nil {
|
|
|
+ lfshook.NewLogger().Infof("==OCC=QueueStatus==%+v", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if res.Calls != "0" { //OCC queue is not empty
|
|
|
+ // HangupAllLocalChan()
|
|
|
+ lfshook.NewLogger().Infof("====Start OCC-PAD===next==%+v", res)
|
|
|
+ if active.ActivedCab == "1" && action.ExtenStatus("1411") == "Idle" { //check active and OCC status
|
|
|
+ time.Sleep(time.Second)
|
|
|
+ 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 action.RedirectInQueue(PADChan, "1411", "pad-page-occ-icp", "1") //PAD Page(OCC+ICPs)
|
|
|
+ if PADChan != "" {
|
|
|
+ alstatus.AlarmStatus(strings.Split(strings.Split(res.Entrys[0].Channel, "/")[1], "-")[0], "connect")
|
|
|
+ go action.RedirectInQueue(PADChan, "1411", "pad-page-occ-icp", "1") //PAD Page(OCC+ICPs)
|
|
|
|
|
|
- go action.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" && action.ExtenStatus("1481") == "Idle" {
|
|
|
- time.Sleep(time.Second)
|
|
|
- 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 action.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" && action.ExtenStatus("1481") == "Idle" {
|
|
|
+ time.Sleep(time.Second)
|
|
|
+ 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 action.RedirectInQueue(PADChan, "1481", "pad-page-occ-icp", "8") //PAD Page(OCC+ICPs)
|
|
|
+ if PADChan != "" {
|
|
|
+ alstatus.AlarmStatus(strings.Split(strings.Split(res.Entrys[0].Channel, "/")[1], "-")[0], "connect")
|
|
|
+ go action.RedirectInQueue(PADChan, "1481", "pad-page-occ-icp", "8") //PAD Page(OCC+ICPs)
|
|
|
|
|
|
- go action.Dial("0401", "0512", "pad-rule-pacus-occ", "ano8", "ano8", "8") // PACUs dial OCC1
|
|
|
- } else {
|
|
|
- lfshook.NewLogger().Infof("===OCC-QueueStatus==PADCchan NULL")
|
|
|
+ go action.Dial("0401", "0512", "pad-rule-pacus-occ", "ano8", "ano8", "8") // PACUs dial OCC1
|
|
|
+ } else {
|
|
|
+ lfshook.NewLogger().Infof("===OCC-QueueStatus==PADCchan NULL")
|
|
|
+ }
|
|
|
+ break
|
|
|
}
|
|
|
- break
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
+ */
|
|
|
case 0x02: // STN
|
|
|
if priority.CheckPriority("STN") {
|
|
|
action.HangupRunningTask("STN") //STN interrupt other
|