|
@@ -7,14 +7,15 @@ import (
|
|
|
"io"
|
|
"io"
|
|
|
"net"
|
|
"net"
|
|
|
"net/http"
|
|
"net/http"
|
|
|
- "pbx-api-gin/api/panel/asterisk"
|
|
|
|
|
"pbx-api-gin/internal/app/ami/action"
|
|
"pbx-api-gin/internal/app/ami/action"
|
|
|
"pbx-api-gin/internal/app/ami/model"
|
|
"pbx-api-gin/internal/app/ami/model"
|
|
|
"pbx-api-gin/internal/app/mysql"
|
|
"pbx-api-gin/internal/app/mysql"
|
|
|
"pbx-api-gin/internal/app/stc/active"
|
|
"pbx-api-gin/internal/app/stc/active"
|
|
|
msgdata "pbx-api-gin/internal/app/stc/data"
|
|
msgdata "pbx-api-gin/internal/app/stc/data"
|
|
|
|
|
+ "pbx-api-gin/internal/app/stc/priority"
|
|
|
alstatus "pbx-api-gin/internal/app/stc/sendstatus"
|
|
alstatus "pbx-api-gin/internal/app/stc/sendstatus"
|
|
|
"pbx-api-gin/pkg/lfshook"
|
|
"pbx-api-gin/pkg/lfshook"
|
|
|
|
|
+ "strconv"
|
|
|
"sync"
|
|
"sync"
|
|
|
"time"
|
|
"time"
|
|
|
)
|
|
)
|
|
@@ -26,34 +27,29 @@ func HandleStcCmd(ctx context.Context, conn net.Conn) {
|
|
|
for {
|
|
for {
|
|
|
select {
|
|
select {
|
|
|
case <-ctx.Done():
|
|
case <-ctx.Done():
|
|
|
- lfshook.NewLogger().Logger.Infof("HandleStcCmd===ctx==ret======")
|
|
|
|
|
return
|
|
return
|
|
|
|
|
|
|
|
default:
|
|
default:
|
|
|
- var buf bytes.Buffer // 用于累积未处理完的数据流
|
|
|
|
|
|
|
+ var buf bytes.Buffer
|
|
|
tmp := make([]byte, 1024)
|
|
tmp := make([]byte, 1024)
|
|
|
|
|
|
|
|
if conn != nil {
|
|
if conn != nil {
|
|
|
n, err := conn.Read(tmp)
|
|
n, err := conn.Read(tmp)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
if err != io.EOF {
|
|
if err != io.EOF {
|
|
|
- fmt.Println("Error reading from server:", err)
|
|
|
|
|
conn.Close()
|
|
conn.Close()
|
|
|
}
|
|
}
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- // 将新读取的数据追加到缓冲区
|
|
|
|
|
buf.Write(tmp[:n])
|
|
buf.Write(tmp[:n])
|
|
|
}
|
|
}
|
|
|
- // 尝试从缓冲区中提取完整数据包
|
|
|
|
|
|
|
+
|
|
|
for {
|
|
for {
|
|
|
packet, err := msgdata.ExtractPacket(&buf)
|
|
packet, err := msgdata.ExtractPacket(&buf)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
- break // 没有完整包或出错,等待更多数据
|
|
|
|
|
|
|
+ break
|
|
|
}
|
|
}
|
|
|
- // 成功提取一个包,进行处理
|
|
|
|
|
- go processPacket(packet) // 使用 goroutine 避免阻塞接收
|
|
|
|
|
|
|
+ go processPacket(packet)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -66,7 +62,7 @@ func processPacket(packet []byte) {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //for test
|
|
|
|
|
|
|
+ //for recv data log debug
|
|
|
if packet[5] != 0x03 && packet[5] != 0x0c && packet[5] != 0x01 {
|
|
if packet[5] != 0x03 && packet[5] != 0x0c && packet[5] != 0x01 {
|
|
|
lfshook.NewLogger().Logger.Infof("Get data from STC ===============:%x", packet)
|
|
lfshook.NewLogger().Logger.Infof("Get data from STC ===============:%x", packet)
|
|
|
}
|
|
}
|
|
@@ -84,32 +80,64 @@ func processPacket(packet []byte) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
switch packet[5] {
|
|
switch packet[5] {
|
|
|
- case 0x01: // heartbeat
|
|
|
|
|
- // handle heartbeat
|
|
|
|
|
|
|
+ case 0x01:
|
|
|
|
|
+ break
|
|
|
|
|
+
|
|
|
case 0x02: // STN
|
|
case 0x02: // STN
|
|
|
- lfshook.NewLogger().Infof("=====STN=========")
|
|
|
|
|
- StationAnn(packet)
|
|
|
|
|
- //case 0x03: // ACTIVE
|
|
|
|
|
- // Active([1]byte{packet[8]})
|
|
|
|
|
|
|
+ if priority.CheckPriority("STN") {
|
|
|
|
|
+ action.HangupAll()
|
|
|
|
|
+ StationAnn(packet)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
case 0x05: // SPC
|
|
case 0x05: // SPC
|
|
|
- lfshook.NewLogger().Infof("=====SPC=========")
|
|
|
|
|
- SpecialAnn(packet)
|
|
|
|
|
|
|
+ if priority.CheckPriority("SPC-TMS") {
|
|
|
|
|
+ action.HangupAll()
|
|
|
|
|
+ SpecialAnn(packet)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
case 0x06: // EMG
|
|
case 0x06: // EMG
|
|
|
- lfshook.NewLogger().Infof("=====EMG=========")
|
|
|
|
|
EmgMsg(packet)
|
|
EmgMsg(packet)
|
|
|
|
|
+
|
|
|
case 0x07: // STOP
|
|
case 0x07: // STOP
|
|
|
AnnStop([4]byte{packet[8], packet[9], packet[10], packet[11]})
|
|
AnnStop([4]byte{packet[8], packet[9], packet[10], packet[11]})
|
|
|
|
|
+
|
|
|
case 0x08: // DCS
|
|
case 0x08: // DCS
|
|
|
- lfshook.NewLogger().Infof("=====DCS=========")
|
|
|
|
|
- DcsAnn(packet)
|
|
|
|
|
|
|
+ if priority.CheckPriority("DCS") {
|
|
|
|
|
+ action.HangupAll()
|
|
|
|
|
+ DcsAnn(packet)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
case 0x09: // SELF CHECK
|
|
case 0x09: // SELF CHECK
|
|
|
- SelfCheck(packet)
|
|
|
|
|
|
|
+ if priority.CheckPriority("CHK") {
|
|
|
|
|
+ action.HangupAll()
|
|
|
|
|
+ SelfCheck(packet)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ case 0x10: // SELF CHECK
|
|
|
|
|
+ if priority.CheckPriority("CHK") {
|
|
|
|
|
+ action.HangupAll()
|
|
|
|
|
+ VolumeAdjust(packet)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
case 0x0a:
|
|
case 0x0a:
|
|
|
- AlarmHandle(packet)
|
|
|
|
|
|
|
+ if priority.CheckPriority("PAD-TMS") {
|
|
|
|
|
+ action.HangupAll()
|
|
|
|
|
+ //AlarmHandleTMS(packet)
|
|
|
|
|
+ AlarmHandleICP(packet) //for test
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
case 0x0b:
|
|
case 0x0b:
|
|
|
- AlarmResetAll()
|
|
|
|
|
|
|
+ AlarmHoldResetAll(packet[8])
|
|
|
|
|
+
|
|
|
case 0x0c:
|
|
case 0x0c:
|
|
|
RecordStorageConf(packet[8:])
|
|
RecordStorageConf(packet[8:])
|
|
|
|
|
+
|
|
|
|
|
+ case 0x0d:
|
|
|
|
|
+ if priority.CheckPriority("PAD-ICP") {
|
|
|
|
|
+ action.HangupAll()
|
|
|
|
|
+ AlarmHandleICP(packet)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
default:
|
|
default:
|
|
|
fmt.Printf("Unknown command: %x\n", packet[5])
|
|
fmt.Printf("Unknown command: %x\n", packet[5])
|
|
|
}
|
|
}
|
|
@@ -124,16 +152,12 @@ func StationAnn(data []byte) (err error) {
|
|
|
datalen := int(data[11])
|
|
datalen := int(data[11])
|
|
|
|
|
|
|
|
filename := msgdata.SubstrByRune(string(data[12:]), 0, datalen-4)
|
|
filename := msgdata.SubstrByRune(string(data[12:]), 0, datalen-4)
|
|
|
- lfshook.NewLogger().Logger.Infof("=============Get filename : %v", filename)
|
|
|
|
|
|
|
|
|
|
- //update stn voice
|
|
|
|
|
- _, er := mysql.DBOrmInstance.In("exten", Pacus).Update(&model.Extension{Special: specialVoice, PaType: "STN"})
|
|
|
|
|
- if er != nil {
|
|
|
|
|
- lfshook.NewLogger().Logger.Infof("update special voice to exten err : %+v", er.Error())
|
|
|
|
|
- return er
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ //set spc voice tag
|
|
|
|
|
+ priority.SpecialVoice = specialVoice
|
|
|
|
|
|
|
|
//Pa status report
|
|
//Pa status report
|
|
|
|
|
+ priority.RunningType, _ = strconv.Atoi(priority.Priority.STN)
|
|
|
alstatus.PaStatus("", "STN", "start")
|
|
alstatus.PaStatus("", "STN", "start")
|
|
|
|
|
|
|
|
action.PlaybackPacu(filename, int(cycleCount), int(delay), "STN")
|
|
action.PlaybackPacu(filename, int(cycleCount), int(delay), "STN")
|
|
@@ -211,16 +235,10 @@ func SpecialAnn(data []byte) {
|
|
|
|
|
|
|
|
filename := msgdata.SubstrByRune(string(data[11:]), 0, datalen-4)
|
|
filename := msgdata.SubstrByRune(string(data[11:]), 0, datalen-4)
|
|
|
|
|
|
|
|
- //update pa type
|
|
|
|
|
- _, er := mysql.DBOrmInstance.In("exten", Pacus).Update(&model.Extension{PaType: "SPC"})
|
|
|
|
|
- if er != nil {
|
|
|
|
|
- lfshook.NewLogger().Logger.Infof("update special voice to exten err : %+v", er.Error())
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
//Pa status report
|
|
//Pa status report
|
|
|
|
|
+ priority.RunningType, _ = strconv.Atoi(priority.Priority.SPCTMS)
|
|
|
alstatus.PaStatus("", "SPC", "start")
|
|
alstatus.PaStatus("", "SPC", "start")
|
|
|
|
|
|
|
|
- lfshook.NewLogger().Infof("======count:%x", cycleCount)
|
|
|
|
|
if int(cycleCount) == 255 {
|
|
if int(cycleCount) == 255 {
|
|
|
action.PlaybackPacu(filename, 9999999, int(delay), "SPC")
|
|
action.PlaybackPacu(filename, 9999999, int(delay), "SPC")
|
|
|
} else {
|
|
} else {
|
|
@@ -236,16 +254,10 @@ func EmgMsg(data []byte) {
|
|
|
|
|
|
|
|
filename := msgdata.SubstrByRune(string(data[11:]), 0, datalen-4)
|
|
filename := msgdata.SubstrByRune(string(data[11:]), 0, datalen-4)
|
|
|
|
|
|
|
|
- //update pa type
|
|
|
|
|
- _, er := mysql.DBOrmInstance.In("exten", Pacus).Update(&model.Extension{PaType: "EMG"})
|
|
|
|
|
- if er != nil {
|
|
|
|
|
- lfshook.NewLogger().Logger.Infof("update special voice to exten err : %+v", er.Error())
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
//Pa status report
|
|
//Pa status report
|
|
|
|
|
+ priority.RunningType, _ = strconv.Atoi(priority.Priority.EMGTMS)
|
|
|
alstatus.PaStatus("", "EMG", "start")
|
|
alstatus.PaStatus("", "EMG", "start")
|
|
|
|
|
|
|
|
- lfshook.NewLogger().Infof("======count:%x", cycleCount)
|
|
|
|
|
if int(cycleCount) == 255 {
|
|
if int(cycleCount) == 255 {
|
|
|
action.PlaybackPacu(filename, 9999999, int(delay), "EMG")
|
|
action.PlaybackPacu(filename, 9999999, int(delay), "EMG")
|
|
|
} else {
|
|
} else {
|
|
@@ -256,32 +268,24 @@ func EmgMsg(data []byte) {
|
|
|
// 停止指定类型广播
|
|
// 停止指定类型广播
|
|
|
func AnnStop(data [4]byte) {
|
|
func AnnStop(data [4]byte) {
|
|
|
|
|
|
|
|
- RunningType := ""
|
|
|
|
|
|
|
+ PaType := ""
|
|
|
|
|
|
|
|
switch data[0] {
|
|
switch data[0] {
|
|
|
case 0x03:
|
|
case 0x03:
|
|
|
- RunningType = "DCS"
|
|
|
|
|
|
|
+ PaType = "DCS"
|
|
|
case 0x04:
|
|
case 0x04:
|
|
|
- RunningType = "EMG"
|
|
|
|
|
|
|
+ PaType = "EMG"
|
|
|
case 0x07:
|
|
case 0x07:
|
|
|
- RunningType = "SPC"
|
|
|
|
|
|
|
+ PaType = "SPC"
|
|
|
case 0x08:
|
|
case 0x08:
|
|
|
- RunningType = "STN"
|
|
|
|
|
|
|
+ PaType = "STN"
|
|
|
case 0x09:
|
|
case 0x09:
|
|
|
- RunningType = "CHK"
|
|
|
|
|
|
|
+ PaType = "CHK"
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- alstatus.PaStatus("", RunningType, "end")
|
|
|
|
|
-
|
|
|
|
|
- for _, ext := range Pacus {
|
|
|
|
|
- action.Hangup(ext)
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //update pa type
|
|
|
|
|
- _, er := mysql.DBOrmInstance.Cols("patype").Where("pa_type = ?", RunningType).Update(&model.Extension{PaType: ""})
|
|
|
|
|
- if er != nil {
|
|
|
|
|
- lfshook.NewLogger().Logger.Infof("update special voice to exten err : %+v", er.Error())
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ priority.RunningType = 0
|
|
|
|
|
+ alstatus.PaStatus("", PaType, "end")
|
|
|
|
|
+ action.HangupAll()
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -293,14 +297,8 @@ func DcsAnn(data []byte) {
|
|
|
|
|
|
|
|
filename := msgdata.SubstrByRune(string(data[11:]), 0, datalen-4)
|
|
filename := msgdata.SubstrByRune(string(data[11:]), 0, datalen-4)
|
|
|
|
|
|
|
|
- //update pa type
|
|
|
|
|
- _, er := mysql.DBOrmInstance.In("exten", Pacus).Update(&model.Extension{PaType: "DCS"})
|
|
|
|
|
- if er != nil {
|
|
|
|
|
- lfshook.NewLogger().Logger.Infof("update special voice to exten err : %+v", er.Error())
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //lfshook.NewLogger().Infof("======count:%x", cycleCount)
|
|
|
|
|
//Pa status report
|
|
//Pa status report
|
|
|
|
|
+ priority.RunningType, _ = strconv.Atoi(priority.Priority.DCS)
|
|
|
alstatus.PaStatus("", "DCS", "start")
|
|
alstatus.PaStatus("", "DCS", "start")
|
|
|
|
|
|
|
|
if int(cycleCount) == 255 {
|
|
if int(cycleCount) == 255 {
|
|
@@ -310,8 +308,8 @@ func DcsAnn(data []byte) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// 自检广播
|
|
|
|
|
-func SelfCheck(data []byte) {
|
|
|
|
|
|
|
+// 调音广播
|
|
|
|
|
+func VolumeAdjust(data []byte) {
|
|
|
|
|
|
|
|
check := data[8]
|
|
check := data[8]
|
|
|
delay := data[9]
|
|
delay := data[9]
|
|
@@ -320,28 +318,43 @@ func SelfCheck(data []byte) {
|
|
|
|
|
|
|
|
filename := msgdata.SubstrByRune(string(data[12:]), 0, datalen-4)
|
|
filename := msgdata.SubstrByRune(string(data[12:]), 0, datalen-4)
|
|
|
|
|
|
|
|
- //update pa type
|
|
|
|
|
- _, er := mysql.DBOrmInstance.In("exten", Pacus).Update(&model.Extension{PaType: "CHK"})
|
|
|
|
|
- if er != nil {
|
|
|
|
|
- lfshook.NewLogger().Logger.Infof("update special voice to exten err : %+v", er.Error())
|
|
|
|
|
|
|
+ switch check {
|
|
|
|
|
+ case 0x01: //start
|
|
|
|
|
+
|
|
|
|
|
+ //Pa status report
|
|
|
|
|
+ priority.RunningType, _ = strconv.Atoi(priority.Priority.CHK)
|
|
|
|
|
+ alstatus.PaStatus("", "VOL", "start")
|
|
|
|
|
+ action.PlaybackPacu(filename, int(cycleCount), int(delay), "VOL")
|
|
|
|
|
+ case 0x02: //stop
|
|
|
|
|
+
|
|
|
|
|
+ alstatus.PaStatus("", "VOL", "end")
|
|
|
|
|
+ action.HangupAll()
|
|
|
}
|
|
}
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// 自检广播
|
|
|
|
|
+func SelfCheck(data []byte) {
|
|
|
|
|
+
|
|
|
|
|
+ check := data[8]
|
|
|
|
|
+ delay := data[9]
|
|
|
|
|
+ cycleCount := data[10]
|
|
|
|
|
+ datalen := int(data[11])
|
|
|
|
|
+
|
|
|
|
|
+ filename := msgdata.SubstrByRune(string(data[12:]), 0, datalen-4)
|
|
|
|
|
|
|
|
switch check {
|
|
switch check {
|
|
|
case 0x01: //start
|
|
case 0x01: //start
|
|
|
|
|
|
|
|
//Pa status report
|
|
//Pa status report
|
|
|
|
|
+ priority.RunningType, _ = strconv.Atoi(priority.Priority.CHK)
|
|
|
alstatus.PaStatus("", "CHK", "start")
|
|
alstatus.PaStatus("", "CHK", "start")
|
|
|
action.PlaybackPacu(filename, int(cycleCount), int(delay), "CHK")
|
|
action.PlaybackPacu(filename, int(cycleCount), int(delay), "CHK")
|
|
|
case 0x02: //stop
|
|
case 0x02: //stop
|
|
|
|
|
|
|
|
//Pa status report
|
|
//Pa status report
|
|
|
|
|
+ priority.RunningType = 0
|
|
|
alstatus.PaStatus("", "CHK", "end")
|
|
alstatus.PaStatus("", "CHK", "end")
|
|
|
-
|
|
|
|
|
- for _, ext := range Pacus {
|
|
|
|
|
- asterisk.Hangup(ext)
|
|
|
|
|
- }
|
|
|
|
|
- asterisk.Hangup("2311")
|
|
|
|
|
- asterisk.Hangup("2381")
|
|
|
|
|
|
|
+ action.HangupAll()
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -357,25 +370,24 @@ func suppressKey(exten string, handler byte) string {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// ICP操作乘客报警(根据激活信息判断转到1车还是8车================)
|
|
// ICP操作乘客报警(根据激活信息判断转到1车还是8车================)
|
|
|
-func AlarmHandle(data []byte) {
|
|
|
|
|
|
|
+func AlarmHandleICP(data []byte) {
|
|
|
handler := data[8]
|
|
handler := data[8]
|
|
|
- //extlen := data[9]
|
|
|
|
|
carr := data[12]
|
|
carr := data[12]
|
|
|
pos := data[13]
|
|
pos := data[13]
|
|
|
exten := fmt.Sprintf("24%c%c", carr, pos)
|
|
exten := fmt.Sprintf("24%c%c", carr, pos)
|
|
|
- PacuNum := fmt.Sprintf("21%c%c", carr, pos)
|
|
|
|
|
|
|
|
|
|
key := suppressKey(exten, handler)
|
|
key := suppressKey(exten, handler)
|
|
|
|
|
|
|
|
//Drop other handler in 2 sec
|
|
//Drop other handler in 2 sec
|
|
|
- // 只对 handler == 0x01 做 2 秒去重
|
|
|
|
|
|
|
+ //PACUs---call---->ICP1
|
|
|
|
|
+ //PAD---->Chanspy(WEq)-->ICP1
|
|
|
|
|
+ //ICP2--->Chanspy(Eq)---->PAD
|
|
|
if handler == 0x01 {
|
|
if handler == 0x01 {
|
|
|
if _, loaded := suppressedExts.LoadOrStore(key, struct{}{}); loaded {
|
|
if _, loaded := suppressedExts.LoadOrStore(key, struct{}{}); loaded {
|
|
|
lfshook.NewLogger().Logger.Infof("Suppressed duplicate ICP Alarm (handler=0x01) for exten: %s within 4 seconds", exten)
|
|
lfshook.NewLogger().Logger.Infof("Suppressed duplicate ICP Alarm (handler=0x01) for exten: %s within 4 seconds", exten)
|
|
|
- return // 已存在,说明在2秒窗口期内,直接丢弃
|
|
|
|
|
|
|
+ return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 设置4秒后删除该 key,允许下次通过
|
|
|
|
|
time.AfterFunc(4*time.Second, func() {
|
|
time.AfterFunc(4*time.Second, func() {
|
|
|
suppressedExts.Delete(key)
|
|
suppressedExts.Delete(key)
|
|
|
lfshook.NewLogger().Logger.Debugf("Suppression released for key: %s", key)
|
|
lfshook.NewLogger().Logger.Debugf("Suppression released for key: %s", key)
|
|
@@ -385,27 +397,14 @@ func AlarmHandle(data []byte) {
|
|
|
switch handler {
|
|
switch handler {
|
|
|
case 0x01: //answer(ICP+Alarm+PACU)
|
|
case 0x01: //answer(ICP+Alarm+PACU)
|
|
|
//NotifyPaiu(exten, "answer")
|
|
//NotifyPaiu(exten, "answer")
|
|
|
-
|
|
|
|
|
- //get pacu status
|
|
|
|
|
- var infoExt model.Extension
|
|
|
|
|
- _, er := mysql.DBOrmInstance.Where("exten = ?", PacuNum).Get(&infoExt)
|
|
|
|
|
- if er != nil {
|
|
|
|
|
- lfshook.NewLogger().Logger.Infof("update special voice to exten err : %+v", er.Error())
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+ priority.ICPAnswer = 1
|
|
|
lfshook.NewLogger().Logger.Infof("================ICP Answer PAD================:%s ", exten)
|
|
lfshook.NewLogger().Logger.Infof("================ICP Answer PAD================:%s ", exten)
|
|
|
- if infoExt.Status == "Idle" {
|
|
|
|
|
- if active.CabNum == "1" && active.Actived {
|
|
|
|
|
- action.Dial("0402", PacuNum, "default", PacuNum, exten, "1") // PACU dial ICP MC1
|
|
|
|
|
- } else if active.CabNum == "8" && active.Actived {
|
|
|
|
|
- action.Dial("0402", PacuNum, "default", PacuNum, exten, "8") // PACU dial ICP MC8
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- if active.CabNum == "1" && active.Actived {
|
|
|
|
|
- action.RedirectInQueue(exten, "0402", "default", "1") // PAD dial ICP MC1
|
|
|
|
|
- } else if active.CabNum == "8" && active.Actived {
|
|
|
|
|
- action.RedirectInQueue(exten, "0402", "default", "8") // PAD dial ICP MC8
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if active.CabNum == "1" && active.Actived {
|
|
|
|
|
+ action.Dial("0402", "0511", "pad-rule-pacus", "ani1", exten, "1") // PACUs dial ICP1
|
|
|
|
|
+ //goto ami event ConfbridgeJoin, ICP answer PAD
|
|
|
|
|
+ } else if active.CabNum == "8" && active.Actived {
|
|
|
|
|
+ action.Dial("0402", "0511", "pad-rule-pacus", "ani8", exten, "8") // PACUs dial ICP8
|
|
|
|
|
+ //goto ami event ConfbridgeJoin, ICP answer PAD
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
case 0x02: //hold 重新放回队列里面
|
|
case 0x02: //hold 重新放回队列里面
|
|
@@ -414,50 +413,82 @@ func AlarmHandle(data []byte) {
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
lfshook.NewLogger().Info(err)
|
|
lfshook.NewLogger().Info(err)
|
|
|
}
|
|
}
|
|
|
- if active.CabNum == "1" && active.Actived {
|
|
|
|
|
- action.Hangup("2311") //1 车接听
|
|
|
|
|
- } else if active.CabNum == "8" && active.Actived {
|
|
|
|
|
- action.Hangup("2381") //8 车接听
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ action.Hangup("2311") //1 车接听
|
|
|
|
|
+ action.Hangup("2381") //8 车接听
|
|
|
|
|
+
|
|
|
case 0x03: //hangup
|
|
case 0x03: //hangup
|
|
|
//NotifyPaiu(exten, "hangup")
|
|
//NotifyPaiu(exten, "hangup")
|
|
|
- action.Hangup(exten)
|
|
|
|
|
- if active.CabNum == "1" && active.Actived {
|
|
|
|
|
- action.Hangup("2311") //1 车接听
|
|
|
|
|
- } else if active.CabNum == "8" && active.Actived {
|
|
|
|
|
- action.Hangup("2381") //8 车接听
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ /* action.Hangup(exten) //Pad
|
|
|
|
|
+ action.Hangup("2311") //1 车接听
|
|
|
|
|
+ action.Hangup("2381") //8 车接听
|
|
|
|
|
+ */
|
|
|
|
|
+ action.HangupAll()
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
- case 0x04: //take back from OCC
|
|
|
|
|
- //OCC - ICP <<< PAD-spy OCC
|
|
|
|
|
- //break hangup occ first , keep pad spy-channel ,reconnect Pacu and icp , redirect pad channel to spy-icp
|
|
|
|
|
- if active.CabNum == "1" && active.Actived { //hangup OCC MC1
|
|
|
|
|
- action.Hangup("1411")
|
|
|
|
|
- } else if active.CabNum == "8" && active.Actived { //hangup OCC MC8
|
|
|
|
|
- action.Hangup("1481")
|
|
|
|
|
- }
|
|
|
|
|
|
|
+// TMS操作乘客报警(根据激活信息判断转到1车还是8车================)
|
|
|
|
|
+func AlarmHandleTMS(data []byte) {
|
|
|
|
|
+ handler := data[8]
|
|
|
|
|
+ //extlen := data[9]
|
|
|
|
|
+ carr := data[12]
|
|
|
|
|
+ pos := data[13]
|
|
|
|
|
+ exten := fmt.Sprintf("24%c%c", carr, pos)
|
|
|
|
|
+ PacuNum := fmt.Sprintf("21%c%c", carr, pos)
|
|
|
|
|
+
|
|
|
|
|
+ key := suppressKey(exten, handler)
|
|
|
|
|
|
|
|
- //get pacu status
|
|
|
|
|
- var infoExt model.Extension
|
|
|
|
|
- _, er := mysql.DBOrmInstance.Where("exten = ?", PacuNum).Get(&infoExt)
|
|
|
|
|
- if er != nil {
|
|
|
|
|
- lfshook.NewLogger().Logger.Infof("update special voice to exten err : %+v", er.Error())
|
|
|
|
|
|
|
+ //Drop other handler in 2 sec
|
|
|
|
|
+ // 只对 handler == 0x01 做 2 秒去重
|
|
|
|
|
+ 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)
|
|
|
|
|
+ return // 已存在,说明在2秒窗口期内,直接丢弃
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- lfshook.NewLogger().Logger.Infof("================IPC take over PAD from OCC================:%s ", exten)
|
|
|
|
|
- if infoExt.Status == "Idle" {
|
|
|
|
|
|
|
+ // 设置4秒后删除该 key,允许下次通过
|
|
|
|
|
+ time.AfterFunc(4*time.Second, func() {
|
|
|
|
|
+ suppressedExts.Delete(key)
|
|
|
|
|
+ lfshook.NewLogger().Logger.Debugf("Suppression released for key: %s", key)
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ switch handler {
|
|
|
|
|
+ case 0x01: //answer(ICP+Alarm+PACU)
|
|
|
|
|
+ //PACU---call---->ICP1
|
|
|
|
|
+ //PAD---->Chanspy(WEq)-->ICP1
|
|
|
|
|
+ //ICP2--->spy(Eq)---->PAD
|
|
|
|
|
+
|
|
|
|
|
+ priority.ICPAnswer = 1
|
|
|
|
|
+ lfshook.NewLogger().Logger.Infof("================TMS Answer PAD:%s===PACU:%s==========", exten, PacuNum)
|
|
|
|
|
+ if action.ExtenStatus(PacuNum) == "Idle" {
|
|
|
if active.CabNum == "1" && active.Actived {
|
|
if active.CabNum == "1" && active.Actived {
|
|
|
- action.Dial("0402", PacuNum, "default", PacuNum, exten, "1") // PACU dial ICP MC1
|
|
|
|
|
|
|
+ action.Dial("0403", PacuNum, "default", PacuNum, exten, "1") // PACU dial ICP1
|
|
|
|
|
+ //goto ami event BridgeEnter, ICP8 whisper ICP1
|
|
|
} else if active.CabNum == "8" && active.Actived {
|
|
} else if active.CabNum == "8" && active.Actived {
|
|
|
- action.Dial("0402", PacuNum, "default", PacuNum, exten, "8") // PACU dial ICP MC8
|
|
|
|
|
|
|
+ action.Dial("0403", PacuNum, "default", PacuNum, exten, "8") // PACU dial ICP8
|
|
|
|
|
+ //goto ami event BridgeEnter, ICP1 whisper ICP8
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
- if active.CabNum == "1" && active.Actived {
|
|
|
|
|
- action.RedirectInQueue(exten, "0402", "default", "1") // PAD dial ICP MC1
|
|
|
|
|
- } else if active.CabNum == "8" && active.Actived {
|
|
|
|
|
- action.RedirectInQueue(exten, "0402", "default", "8") // PAD dial ICP MC8
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ action.RedirectInQueue(exten, "0405", "default", exten) // PAD dial ICPs
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ case 0x02: //hold 重新放回队列里面
|
|
|
|
|
+ NotifyPaiu(exten, "hold")
|
|
|
|
|
+ err := action.RedirectInQueue(exten, "0300", "default", "1")
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ lfshook.NewLogger().Info(err)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ action.Hangup("2311") //1 车接听
|
|
|
|
|
+ action.Hangup("2381") //8 车接听
|
|
|
|
|
+
|
|
|
|
|
+ case 0x03: //hangup
|
|
|
|
|
+ //NotifyPaiu(exten, "hangup")
|
|
|
|
|
+ /*action.Hangup(exten) //PAD
|
|
|
|
|
+ action.Hangup("2311") //1 车接听
|
|
|
|
|
+ action.Hangup("2381") //8 车接听
|
|
|
|
|
+ */
|
|
|
|
|
+ action.HangupAll()
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -495,7 +526,7 @@ func NotifyPaiu(Exten, Action string) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 挂断所有报警器
|
|
// 挂断所有报警器
|
|
|
-func AlarmResetAll() {
|
|
|
|
|
|
|
+func AlarmHoldResetAll(data byte) {
|
|
|
|
|
|
|
|
var AlarmExts []model.Extension
|
|
var AlarmExts []model.Extension
|
|
|
|
|
|
|
@@ -504,16 +535,34 @@ func AlarmResetAll() {
|
|
|
lfshook.NewLogger().Logger.Infof("update special voice to exten err : %+v", er.Error())
|
|
lfshook.NewLogger().Logger.Infof("update special voice to exten err : %+v", er.Error())
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- for _, ext := range AlarmExts {
|
|
|
|
|
- action.Hangup(ext.Extension)
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ //all hold
|
|
|
|
|
+ if data == 1 {
|
|
|
|
|
+ for _, ext := range AlarmExts {
|
|
|
|
|
+ err := action.RedirectInQueue(ext.Extension, "0300", "default", "1")
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ lfshook.NewLogger().Info(err)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- if active.CabNum == "1" && active.Actived {
|
|
|
|
|
- action.Hangup("2311") //1 车接听
|
|
|
|
|
- alstatus.AlarmStatus("0000", "allreset") //send all reset status
|
|
|
|
|
- } else if active.CabNum == "8" && active.Actived {
|
|
|
|
|
- action.Hangup("2381") //8 车接听
|
|
|
|
|
- alstatus.AlarmStatus("0000", "allreset") // send all reset status
|
|
|
|
|
|
|
+ if active.CabNum == "1" && active.Actived {
|
|
|
|
|
+ action.Hangup("2311") //1 车接听
|
|
|
|
|
+ alstatus.AlarmStatus("0000", "allhold") //send all hold status
|
|
|
|
|
+ } else if active.CabNum == "8" && active.Actived {
|
|
|
|
|
+ action.Hangup("2381") //8 车接听
|
|
|
|
|
+ alstatus.AlarmStatus("0000", "allhold") // send all hold status
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if data == 2 { //all reset
|
|
|
|
|
+ for _, ext := range AlarmExts {
|
|
|
|
|
+ action.Hangup(ext.Extension)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if active.CabNum == "1" && active.Actived {
|
|
|
|
|
+ action.Hangup("2311") //1 车接听
|
|
|
|
|
+ alstatus.AlarmStatus("0000", "allreset") //send all reset status
|
|
|
|
|
+ } else if active.CabNum == "8" && active.Actived {
|
|
|
|
|
+ action.Hangup("2381") //8 车接听
|
|
|
|
|
+ alstatus.AlarmStatus("0000", "allreset") // send all reset status
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -529,8 +578,8 @@ func RecordStorageConf(data []byte) {
|
|
|
info.PadRcdDelDays = int(data[4])
|
|
info.PadRcdDelDays = int(data[4])
|
|
|
info.PaRcdDelDays = int(data[5])
|
|
info.PaRcdDelDays = int(data[5])
|
|
|
info.CpaRcdDelDays = int(data[6])
|
|
info.CpaRcdDelDays = int(data[6])
|
|
|
- info.OpaRcdStorageDays = int(data[7])
|
|
|
|
|
- info.OpaRcdDelDays = int(data[8])
|
|
|
|
|
|
|
+ //info.OpaRcdStorageDays = int(data[7])
|
|
|
|
|
+ //info.OpaRcdDelDays = int(data[8])
|
|
|
|
|
|
|
|
//lfshook.NewLogger().Infof("=============Set record Conf : %+v", info)
|
|
//lfshook.NewLogger().Infof("=============Set record Conf : %+v", info)
|
|
|
|
|
|