|
|
@@ -7,6 +7,7 @@ import (
|
|
|
"io"
|
|
|
"net"
|
|
|
"net/http"
|
|
|
+ "pbx-api-gin/api/panel/asterisk"
|
|
|
"pbx-api-gin/internal/app/ami/action"
|
|
|
"pbx-api-gin/internal/app/ami/model"
|
|
|
"pbx-api-gin/internal/app/mysql"
|
|
|
@@ -112,7 +113,7 @@ func StationAnn(data []byte) (err error) {
|
|
|
filename := msgdata.SubstrByRune(string(data[12:]), 0, datalen-4)
|
|
|
lfshook.NewLogger().Logger.Infof("=============Get filename : %v", filename)
|
|
|
|
|
|
- //update special voice
|
|
|
+ //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())
|
|
|
@@ -133,7 +134,7 @@ func Active(data [1]byte) {
|
|
|
|
|
|
switch Num { // 设置全局的激活信号,并通过协议(待定)通知终端注册到对应的激活主机上
|
|
|
case 0:
|
|
|
-
|
|
|
+ lfshook.NewLogger().Logger.Infof("=================Inactive==================")
|
|
|
info.Name = "cab_active"
|
|
|
info.Value = "0"
|
|
|
|
|
|
@@ -143,7 +144,8 @@ func Active(data [1]byte) {
|
|
|
return
|
|
|
}
|
|
|
case 1:
|
|
|
- if active.CabNum == "1" {
|
|
|
+ lfshook.NewLogger().Logger.Infof("=================active===MC1===============")
|
|
|
+ if active.CabNum == "1" { // local cab is MC1
|
|
|
info.Name = "cab_active"
|
|
|
info.Value = "1"
|
|
|
active.Actived = true
|
|
|
@@ -158,8 +160,8 @@ func Active(data [1]byte) {
|
|
|
return
|
|
|
}
|
|
|
case 8:
|
|
|
-
|
|
|
- if active.CabNum == "8" {
|
|
|
+ lfshook.NewLogger().Logger.Infof("=================active===MC8===============")
|
|
|
+ if active.CabNum == "8" { //Local cab is MC8
|
|
|
info.Name = "cab_active"
|
|
|
info.Value = "1"
|
|
|
active.Actived = true
|
|
|
@@ -185,13 +187,13 @@ func SpecialAnn(data []byte) {
|
|
|
datalen := int(data[10])
|
|
|
|
|
|
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())
|
|
|
- }
|
|
|
- */
|
|
|
+
|
|
|
+ //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())
|
|
|
+ }
|
|
|
+
|
|
|
lfshook.NewLogger().Infof("======count:%x", cycleCount)
|
|
|
if int(cycleCount) == 255 {
|
|
|
action.PlaybackPacu(filename, 9999999, int(delay), "SPC")
|
|
|
@@ -207,13 +209,13 @@ func EmgMsg(data []byte) {
|
|
|
datalen := int(data[10])
|
|
|
|
|
|
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())
|
|
|
- }
|
|
|
- */
|
|
|
+
|
|
|
+ //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())
|
|
|
+ }
|
|
|
+
|
|
|
lfshook.NewLogger().Infof("======count:%x", cycleCount)
|
|
|
if int(cycleCount) == 255 {
|
|
|
action.PlaybackPacu(filename, 9999999, int(delay), "EMG")
|
|
|
@@ -224,28 +226,30 @@ func EmgMsg(data []byte) {
|
|
|
|
|
|
// 停止指定类型广播
|
|
|
func AnnStop(data [4]byte) {
|
|
|
+ RunningType := ""
|
|
|
+
|
|
|
switch data[0] {
|
|
|
case 0x03:
|
|
|
-
|
|
|
+ RunningType = "DCS"
|
|
|
case 0x04:
|
|
|
-
|
|
|
+ RunningType = "EMG"
|
|
|
case 0x07:
|
|
|
-
|
|
|
+ RunningType = "SPC"
|
|
|
case 0x08:
|
|
|
-
|
|
|
+ RunningType = "STN"
|
|
|
case 0x09:
|
|
|
-
|
|
|
+ RunningType = "CHK"
|
|
|
}
|
|
|
for _, ext := range Pacus {
|
|
|
action.Hangup(ext)
|
|
|
}
|
|
|
- /*
|
|
|
- //update pa type
|
|
|
- _, er := mysql.DBOrmInstance.Cols("patype").In("exten", Pacus).Update(&model.Extension{PaType: ""})
|
|
|
- if er != nil {
|
|
|
- lfshook.NewLogger().Logger.Infof("update special voice to exten err : %+v", er.Error())
|
|
|
- }
|
|
|
- */
|
|
|
+
|
|
|
+ //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())
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
// DCS 语音
|
|
|
@@ -255,14 +259,14 @@ func DcsAnn(data []byte) {
|
|
|
datalen := int(data[10])
|
|
|
|
|
|
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)
|
|
|
+
|
|
|
+ //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)
|
|
|
if int(cycleCount) == 255 {
|
|
|
action.PlaybackPacu(filename, 9999999, int(delay), "DCS")
|
|
|
} else {
|
|
|
@@ -278,18 +282,20 @@ func SelfCheck(data []byte) {
|
|
|
datalen := int(data[11])
|
|
|
|
|
|
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())
|
|
|
- }
|
|
|
- */
|
|
|
+
|
|
|
+ //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:
|
|
|
action.PlaybackPacu(filename, int(cycleCount), int(delay), "CHK")
|
|
|
case 0x02:
|
|
|
- //asterisk.Hangup(Exten)
|
|
|
+ for _, ext := range Pacus {
|
|
|
+ asterisk.Hangup(ext)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -334,38 +340,45 @@ func AlarmHandle(data []byte) {
|
|
|
case 0x01: //answer(ICP+Alarm+PACU)
|
|
|
//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())
|
|
|
+ }
|
|
|
+
|
|
|
lfshook.NewLogger().Logger.Infof("================ICP Answer PAD================:%s ", exten)
|
|
|
- if active.CabNum == "1" {
|
|
|
- action.Dial("0402", PacuNum, "default", PacuNum, exten, "1") // PACU dial ICP
|
|
|
- //action.Dial(PacuNum, "0402", "ani-rule", PacuNum, exten, "1") // PACU dial ICP
|
|
|
+ if infoExt.Status == "Idle" {
|
|
|
+ if active.CabNum == "1" && active.Actived {
|
|
|
+ action.Dial("0402", PacuNum, "default", PacuNum, exten, "1") // PACU dial ICP
|
|
|
+ } else if active.CabNum == "8" && active.Actived {
|
|
|
+ action.Dial("0402", PacuNum, "default", PacuNum, exten, "8") // PACU dial ICP
|
|
|
+ }
|
|
|
} else {
|
|
|
- action.Dial("0402", PacuNum, "default", PacuNum, exten, "8") // PACU dial ICP
|
|
|
- //action.Dial(PacuNum, "0402", "ani-rule", PacuNum, exten, "8") // PACU dial ICP
|
|
|
+ if active.CabNum == "1" && active.Actived {
|
|
|
+ action.RedirectInQueue(exten, "0402", "default", "1") // PACU dial ICP
|
|
|
+ } else if active.CabNum == "8" && active.Actived {
|
|
|
+ action.RedirectInQueue(exten, "0402", "default", "8") // PACU dial ICP
|
|
|
+ }
|
|
|
}
|
|
|
- //invite PACU join in
|
|
|
- //action.Hangup("PACU")
|
|
|
- //action.ChanSpy("PACU", exten, false, true)
|
|
|
-
|
|
|
- case 0x04: //answer(PACU+Alarm+OCC)
|
|
|
- action.Dial(PacuNum, "0401", "ano-rule", PacuNum, exten, "PJSIP") // PACU dial OCC
|
|
|
|
|
|
- //invite PACU join in
|
|
|
- //action.Hangup("PACU")
|
|
|
- //action.ChanSpy("PACU", exten, false, true)
|
|
|
- lfshook.NewLogger().Logger.Infof("================OCC Answer PAD================:%s ", exten)
|
|
|
case 0x02: //hold 重新放回队列里面
|
|
|
NotifyPaiu(exten, "hold")
|
|
|
err := action.RedirectInQueue(exten, "0300", "default", "1")
|
|
|
if err != nil {
|
|
|
lfshook.NewLogger().Info(err)
|
|
|
}
|
|
|
- action.Hangup("2311") //1 车接听
|
|
|
+ if active.CabNum == "1" && active.Actived {
|
|
|
+ action.Hangup("2311") //1 车接听
|
|
|
+ } else if active.CabNum == "8" && active.Actived {
|
|
|
+ action.Hangup("2381") //8 车接听
|
|
|
+ }
|
|
|
case 0x03: //hangup
|
|
|
//NotifyPaiu(exten, "hangup")
|
|
|
action.Hangup(exten)
|
|
|
- if active.CabNum == "1" {
|
|
|
+ if active.CabNum == "1" && active.Actived {
|
|
|
action.Hangup("2311") //1 车接听
|
|
|
- } else {
|
|
|
+ } else if active.CabNum == "8" && active.Actived {
|
|
|
action.Hangup("2381") //8 车接听
|
|
|
}
|
|
|
}
|
|
|
@@ -409,7 +422,7 @@ func AlarmResetAll() {
|
|
|
|
|
|
var AlarmExts []model.Extension
|
|
|
|
|
|
- er := mysql.DBOrmInstance.Where("exttype = ?", "PAIU").Find(&AlarmExts)
|
|
|
+ er := mysql.DBOrmInstance.Where("dev_type = ?", "PAIU").Find(&AlarmExts)
|
|
|
if er != nil {
|
|
|
lfshook.NewLogger().Logger.Infof("update special voice to exten err : %+v", er.Error())
|
|
|
}
|