dujunchen 2 weeks ago
parent
commit
f3fa7e399e

+ 3 - 3
.gitignore

@@ -1,3 +1,3 @@
-./info.log
-./deployments/pbx-panel
-./deployments/pbx-panel-32
+info.log
+deployments/pbx-panel
+deployments/pbx-panel-32

BIN
deployments/pbx-panel


BIN
deployments/pbx-panel-32


+ 8 - 9
internal/app/ami/action/call.go

@@ -2,7 +2,6 @@ package action
 
 
 import (
 import (
 	"fmt"
 	"fmt"
-	"pbx-api-gin/internal/app/ami"
 	"pbx-api-gin/pkg/lfshook"
 	"pbx-api-gin/pkg/lfshook"
 	"pbx-api-gin/pkg/utils"
 	"pbx-api-gin/pkg/utils"
 	"strings"
 	"strings"
@@ -21,7 +20,7 @@ func Hangup(channel string) {
 		"Channel": channel,
 		"Channel": channel,
 	}
 	}
 	lfshook.NewLogger().Infof("hangup action %+v", action)
 	lfshook.NewLogger().Infof("hangup action %+v", action)
-	if _, _, err := ami.AminInstance.Send(action); err != nil {
+	if _, _, err := AminInstance.Send(action); err != nil {
 		lfshook.NewLogger().Errorf("Hangup %+v", err)
 		lfshook.NewLogger().Errorf("Hangup %+v", err)
 	}
 	}
 }
 }
@@ -40,7 +39,7 @@ func Dial(src, dst, dialrule, callerID, callerName string, callType string) {
 		"async":    "true",
 		"async":    "true",
 	}
 	}
 	lfshook.NewLogger().Infof("dial action %+v", action)
 	lfshook.NewLogger().Infof("dial action %+v", action)
-	res, _, err := ami.AminInstance.Send(action)
+	res, _, err := AminInstance.Send(action)
 	if err != nil {
 	if err != nil {
 		lfshook.NewLogger().Errorf("%+v", err)
 		lfshook.NewLogger().Errorf("%+v", err)
 	}
 	}
@@ -71,7 +70,7 @@ func ChanSpy(src, dst string, whisper, bargein bool) {
 		"Async":       "true",
 		"Async":       "true",
 	}
 	}
 	lfshook.NewLogger().Infof("ChanSpy action %+v", action)
 	lfshook.NewLogger().Infof("ChanSpy action %+v", action)
-	_, _, err := ami.AminInstance.Send(action)
+	_, _, err := AminInstance.Send(action)
 	if err != nil {
 	if err != nil {
 		lfshook.NewLogger().Errorf("%+v", err)
 		lfshook.NewLogger().Errorf("%+v", err)
 	}
 	}
@@ -103,7 +102,7 @@ func Page(src string, extensions []string, duplex bool) {
 		"async":       "true",
 		"async":       "true",
 	}
 	}
 	lfshook.NewLogger().Infof("page action %+v", action)
 	lfshook.NewLogger().Infof("page action %+v", action)
-	res, _, err := ami.AminInstance.Send(action)
+	res, _, err := AminInstance.Send(action)
 	if err != nil {
 	if err != nil {
 		lfshook.NewLogger().Errorf("%+v", err)
 		lfshook.NewLogger().Errorf("%+v", err)
 	}
 	}
@@ -145,7 +144,7 @@ func Play(name, UUID string, extensions []string, hangupAll bool, autoanswer str
 		"async":    "true",
 		"async":    "true",
 	}
 	}
 	lfshook.NewLogger().Infof("play action %+v", action)
 	lfshook.NewLogger().Infof("play action %+v", action)
-	_, _, err := ami.AminInstance.Send(action)
+	_, _, err := AminInstance.Send(action)
 	if err != nil {
 	if err != nil {
 		lfshook.NewLogger().Errorf("%+v", err)
 		lfshook.NewLogger().Errorf("%+v", err)
 	}
 	}
@@ -172,7 +171,7 @@ func Redirect(channel, dst, dialrule string) (err error) {
 		"async":    "true",
 		"async":    "true",
 	}
 	}
 	lfshook.NewLogger().Infof("redirect %+v", action)
 	lfshook.NewLogger().Infof("redirect %+v", action)
-	res, _, err := ami.AminInstance.Send(action)
+	res, _, err := AminInstance.Send(action)
 	if err != nil {
 	if err != nil {
 		lfshook.NewLogger().Error(err)
 		lfshook.NewLogger().Error(err)
 	}
 	}
@@ -196,7 +195,7 @@ func BlindTransfer(channel, dst, dialrule string) (err error) {
 		"Context": dialrule,
 		"Context": dialrule,
 	}
 	}
 	lfshook.NewLogger().Infof("BlindTransfer %+v", action)
 	lfshook.NewLogger().Infof("BlindTransfer %+v", action)
-	res, _, err := ami.AminInstance.Send(action)
+	res, _, err := AminInstance.Send(action)
 	if err != nil {
 	if err != nil {
 		lfshook.NewLogger().Error(err)
 		lfshook.NewLogger().Error(err)
 	}
 	}
@@ -220,7 +219,7 @@ func Atxfer(channel, dst, dialrule string) (err error) {
 		"Context": dialrule,
 		"Context": dialrule,
 	}
 	}
 	lfshook.NewLogger().Infof("atxfer action %+v", action)
 	lfshook.NewLogger().Infof("atxfer action %+v", action)
-	res, _, err := ami.AminInstance.Send(action)
+	res, _, err := AminInstance.Send(action)
 	if err != nil {
 	if err != nil {
 		lfshook.NewLogger().Errorf("%+v", err)
 		lfshook.NewLogger().Errorf("%+v", err)
 		return err
 		return err

+ 3 - 4
internal/app/ami/action/channel.go

@@ -3,7 +3,6 @@ package action
 import (
 import (
 	"errors"
 	"errors"
 	"pbx-api-gin/api/model"
 	"pbx-api-gin/api/model"
-	"pbx-api-gin/internal/app/ami"
 	"pbx-api-gin/pkg/lfshook"
 	"pbx-api-gin/pkg/lfshook"
 	"pbx-api-gin/pkg/utils"
 	"pbx-api-gin/pkg/utils"
 )
 )
@@ -11,7 +10,7 @@ import (
 // CoreShowChannels 获取通话通道
 // CoreShowChannels 获取通话通道
 func CoreShowChannels() (result []model.CoreShowChannelResVO, err error) {
 func CoreShowChannels() (result []model.CoreShowChannelResVO, err error) {
 	// 通过 src 查询对应通道
 	// 通过 src 查询对应通道
-	_, events, err := ami.AminInstance.Send(map[string]string{
+	_, events, err := AminInstance.Send(map[string]string{
 		"Action": "CoreShowChannels",
 		"Action": "CoreShowChannels",
 	})
 	})
 	if err != nil {
 	if err != nil {
@@ -42,7 +41,7 @@ func CoreShowChannels() (result []model.CoreShowChannelResVO, err error) {
 // GetChannelByExten  通过 exten 查询对应通道
 // GetChannelByExten  通过 exten 查询对应通道
 func GetChannelByExten(exten string) (channel string, err error) {
 func GetChannelByExten(exten string) (channel string, err error) {
 	lfshook.NewLogger().Infof("GetChannelByExten %s", exten)
 	lfshook.NewLogger().Infof("GetChannelByExten %s", exten)
-	_, events, err := ami.AminInstance.Send(map[string]string{
+	_, events, err := AminInstance.Send(map[string]string{
 		"Action": "CoreShowChannels",
 		"Action": "CoreShowChannels",
 	})
 	})
 	if err != nil {
 	if err != nil {
@@ -69,7 +68,7 @@ func GetChannelByExten(exten string) (channel string, err error) {
 // GetBridgedChan  通过 exten 查询对应通道
 // GetBridgedChan  通过 exten 查询对应通道
 func GetExtenChan(exten string) (channel string, err error) {
 func GetExtenChan(exten string) (channel string, err error) {
 	lfshook.NewLogger().Infof("GetExtenChan %s", exten)
 	lfshook.NewLogger().Infof("GetExtenChan %s", exten)
-	_, events, err := ami.AminInstance.Send(map[string]string{
+	_, events, err := AminInstance.Send(map[string]string{
 		"Action": "CoreShowChannels",
 		"Action": "CoreShowChannels",
 	})
 	})
 	if err != nil {
 	if err != nil {

+ 7 - 8
internal/app/ami/action/conference.go

@@ -2,7 +2,6 @@ package action
 
 
 import (
 import (
 	"errors"
 	"errors"
-	"pbx-api-gin/internal/app/ami"
 )
 )
 
 
 func ListRoom(options map[string]string) (res map[string]string, err error) {
 func ListRoom(options map[string]string) (res map[string]string, err error) {
@@ -14,7 +13,7 @@ func ListRoom(options map[string]string) (res map[string]string, err error) {
 		action[key] = value
 		action[key] = value
 	}
 	}
 
 
-	res, _, err = ami.AminInstance.Send(action)
+	res, _, err = AminInstance.Send(action)
 	if err != nil {
 	if err != nil {
 		return nil, err
 		return nil, err
 	}
 	}
@@ -31,7 +30,7 @@ func List(confnum string) (res map[string]string, err error) {
 		"Conference": confnum,
 		"Conference": confnum,
 	}
 	}
 
 
-	res, _, err = ami.AminInstance.Send(action)
+	res, _, err = AminInstance.Send(action)
 	if err != nil {
 	if err != nil {
 		return nil, err
 		return nil, err
 	}
 	}
@@ -49,7 +48,7 @@ func Kick(confnum, channel string) (res map[string]string, err error) {
 		"Channel":    channel,
 		"Channel":    channel,
 	}
 	}
 
 
-	res, _, err = ami.AminInstance.Send(action)
+	res, _, err = AminInstance.Send(action)
 	if err != nil {
 	if err != nil {
 		return nil, err
 		return nil, err
 	}
 	}
@@ -67,7 +66,7 @@ func Mute(confnum, channel string) (res map[string]string, err error) {
 		"Channel":    channel,
 		"Channel":    channel,
 	}
 	}
 
 
-	res, _, err = ami.AminInstance.Send(action)
+	res, _, err = AminInstance.Send(action)
 	if err != nil {
 	if err != nil {
 		return nil, err
 		return nil, err
 	}
 	}
@@ -85,7 +84,7 @@ func UnMute(confnum, channel string) (res map[string]string, err error) {
 		"Channel":    channel,
 		"Channel":    channel,
 	}
 	}
 
 
-	res, _, err = ami.AminInstance.Send(action)
+	res, _, err = AminInstance.Send(action)
 	if err != nil {
 	if err != nil {
 		return nil, err
 		return nil, err
 	}
 	}
@@ -102,7 +101,7 @@ func Lock(confnum string) (res map[string]string, err error) {
 		"Conference": confnum,
 		"Conference": confnum,
 	}
 	}
 
 
-	res, _, err = ami.AminInstance.Send(action)
+	res, _, err = AminInstance.Send(action)
 	if err != nil {
 	if err != nil {
 		return nil, err
 		return nil, err
 	}
 	}
@@ -119,7 +118,7 @@ func UnLock(confnum string) (res map[string]string, err error) {
 		"Conference": confnum,
 		"Conference": confnum,
 	}
 	}
 
 
-	res, _, err = ami.AminInstance.Send(action)
+	res, _, err = AminInstance.Send(action)
 	if err != nil {
 	if err != nil {
 		return nil, err
 		return nil, err
 	}
 	}

+ 1 - 2
internal/app/ami/action/extension.go

@@ -2,7 +2,6 @@ package action
 
 
 import (
 import (
 	"errors"
 	"errors"
-	"pbx-api-gin/internal/app/ami"
 	"pbx-api-gin/internal/app/ami/model"
 	"pbx-api-gin/internal/app/ami/model"
 )
 )
 
 
@@ -11,7 +10,7 @@ func ExtensionStateList() (result []*model.ExtensionStatus, err error) {
 		"Action": "ExtensionStateList",
 		"Action": "ExtensionStateList",
 	}
 	}
 
 
-	res, events, err := ami.AminInstance.Send(action)
+	res, events, err := AminInstance.Send(action)
 
 
 	if err != nil {
 	if err != nil {
 		return nil, err
 		return nil, err

+ 63 - 32
internal/app/ami/index.go

@@ -1,4 +1,4 @@
-package ami
+package action
 
 
 import (
 import (
 	"net"
 	"net"
@@ -16,39 +16,18 @@ import (
 
 
 var AminInstance *amigo.Amigo
 var AminInstance *amigo.Amigo
 
 
-func StartAMI(connectOKCallBack func(), handleEvents []func(event map[string]string), conn net.Conn) {
-	lfshook.NewLogger().Info("Start AMI")
-	settings := &amigo.Settings{
-		Host:     configs.ConfigGlobal.AsteriskAMIHost,
-		Port:     configs.ConfigGlobal.AsteriskAMIPort,
-		Username: configs.ConfigGlobal.AsteriskAMIUser,
-		Password: configs.ConfigGlobal.AsteriskAMISecret,
-		LogLevel: logrus.ErrorLevel}
-	lfshook.NewLogger().Infof("ami setting: %+v", settings)
-	AminInstance = amigo.New(settings, lfshook.NewLogger())
-	AminInstance.EventOn(func(payload ...interface{}) {
-		// lfshook.NewLogger().Infof("ami event on %+v", payload[0])
-		event := payload[0].(map[string]string)
-		handleAMI(event, conn)
-
-		for _, handle := range handleEvents {
-			go handle(event)
-		}
-
-	})
-	AminInstance.ConnectOn(func(payload ...interface{}) {
-		lfshook.NewLogger().Infof("ami connect on %+v", payload[0])
-		if payload[0] == pkg.Connect_OK {
+const pacu1 = "2111"
+const pacu2 = "2121"
+const pacu3 = "2131"
+const pacu4 = "2141"
+const pacu5 = "2151"
+const pacu6 = "2161"
+const pacu7 = "2171"
+const pacu8 = "2181"
 
 
-			connectOKCallBack()
-		} else {
-			lfshook.NewLogger().Errorf("ami connect failure %+v", payload)
-		}
-	})
-	AminInstance.Connect()
-}
+//type Operation func(src, dst string, whisper, bargein bool)
 
 
-func handleAMI(event map[string]string, conn net.Conn) {
+func HandleAMI(event map[string]string, conn net.Conn) {
 	switch event["Event"] {
 	switch event["Event"] {
 	case "DialBegin":
 	case "DialBegin":
 
 
@@ -66,7 +45,27 @@ func handleAMI(event map[string]string, conn net.Conn) {
 
 
 		if utils.IsPAIU(event["CallerIDNum"]) {
 		if utils.IsPAIU(event["CallerIDNum"]) {
 			alstatus.AlarmStatus(event["CallerIDNum"], "queue", conn) // Alarm join the queue
 			alstatus.AlarmStatus(event["CallerIDNum"], "queue", conn) // Alarm join the queue
+
+			switch string(event["CallerIDNum"][2]) { // connect the pacu to pad acording to the pad number
+			case "1":
+				ChanSpy(pacu1, event["CallerIDNum"], false, true) //connect pacu to pad
+			case "2":
+				ChanSpy(pacu2, event["CallerIDNum"], false, true) //connect pacu to pad
+			case "3":
+				ChanSpy(pacu3, event["CallerIDNum"], false, true) //connect pacu to pad
+			case "4":
+				ChanSpy(pacu4, event["CallerIDNum"], false, true) //connect pacu to pad
+			case "5":
+				ChanSpy(pacu5, event["CallerIDNum"], false, true) //connect pacu to pad
+			case "6":
+				ChanSpy(pacu6, event["CallerIDNum"], false, true) //connect pacu to pad
+			case "7":
+				ChanSpy(pacu7, event["CallerIDNum"], false, true) //connect pacu to pad
+			case "8":
+				ChanSpy(pacu8, event["CallerIDNum"], false, true) //connect pacu to pad
+			}
 		}
 		}
+
 	case "ExtensionStatus":
 	case "ExtensionStatus":
 
 
 		if event["StatusText"] == "Idle" || event["StatusText"] == "Unavailable" {
 		if event["StatusText"] == "Idle" || event["StatusText"] == "Unavailable" {
@@ -88,6 +87,38 @@ func handleAMI(event map[string]string, conn net.Conn) {
 	}
 	}
 }
 }
 
 
+func StartAMI(connectOKCallBack func(), handleEvents []func(event map[string]string), conn net.Conn) {
+	lfshook.NewLogger().Info("Start AMI")
+	settings := &amigo.Settings{
+		Host:     configs.ConfigGlobal.AsteriskAMIHost,
+		Port:     configs.ConfigGlobal.AsteriskAMIPort,
+		Username: configs.ConfigGlobal.AsteriskAMIUser,
+		Password: configs.ConfigGlobal.AsteriskAMISecret,
+		LogLevel: logrus.ErrorLevel}
+	lfshook.NewLogger().Infof("ami setting: %+v", settings)
+	AminInstance = amigo.New(settings, lfshook.NewLogger())
+	AminInstance.EventOn(func(payload ...interface{}) {
+		// lfshook.NewLogger().Infof("ami event on %+v", payload[0])
+		event := payload[0].(map[string]string)
+		HandleAMI(event, conn)
+
+		for _, handle := range handleEvents {
+			go handle(event)
+		}
+
+	})
+	AminInstance.ConnectOn(func(payload ...interface{}) {
+		lfshook.NewLogger().Infof("ami connect on %+v", payload[0])
+		if payload[0] == pkg.Connect_OK {
+
+			connectOKCallBack()
+		} else {
+			lfshook.NewLogger().Errorf("ami connect failure %+v", payload)
+		}
+	})
+	AminInstance.Connect()
+}
+
 func Connected() bool {
 func Connected() bool {
 	if AminInstance != nil {
 	if AminInstance != nil {
 		return AminInstance.Connected()
 		return AminInstance.Connected()

+ 4 - 5
internal/app/ami/action/meetme.go

@@ -2,7 +2,6 @@ package action
 
 
 import (
 import (
 	"errors"
 	"errors"
-	"pbx-api-gin/internal/app/ami"
 	"pbx-api-gin/internal/app/ami/model"
 	"pbx-api-gin/internal/app/ami/model"
 	"pbx-api-gin/pkg/lfshook"
 	"pbx-api-gin/pkg/lfshook"
 	"pbx-api-gin/pkg/utils"
 	"pbx-api-gin/pkg/utils"
@@ -19,7 +18,7 @@ func ListRoomMeetMe(options map[string]string) (points []*model.MeetMeListRooms,
 		action[key] = value
 		action[key] = value
 	}
 	}
 
 
-	res, events, err := ami.AminInstance.Send(action)
+	res, events, err := AminInstance.Send(action)
 	if err != nil {
 	if err != nil {
 		return nil, err
 		return nil, err
 	}
 	}
@@ -46,7 +45,7 @@ func ListMeetMe(confnum string) (points []*model.MeetmeList, err error) {
 		action["Conference"] = confnum
 		action["Conference"] = confnum
 	}
 	}
 
 
-	res, events, err := ami.AminInstance.Send(action)
+	res, events, err := AminInstance.Send(action)
 	if err != nil {
 	if err != nil {
 		return points, err
 		return points, err
 	}
 	}
@@ -84,7 +83,7 @@ func MuteMeetMe(meetme, usernum string) (res map[string]string, err error) {
 		"Usernum": usernum,
 		"Usernum": usernum,
 	}
 	}
 	lfshook.NewLogger().Infof("meetme action %+v", action)
 	lfshook.NewLogger().Infof("meetme action %+v", action)
-	res, _, err = ami.AminInstance.Send(action)
+	res, _, err = AminInstance.Send(action)
 	if err != nil {
 	if err != nil {
 		return nil, err
 		return nil, err
 	}
 	}
@@ -102,7 +101,7 @@ func UnMuteMeetMe(meetme, usernum string) (res map[string]string, err error) {
 		"Usernum": usernum,
 		"Usernum": usernum,
 	}
 	}
 
 
-	res, _, err = ami.AminInstance.Send(action)
+	res, _, err = AminInstance.Send(action)
 	if err != nil {
 	if err != nil {
 		return nil, err
 		return nil, err
 	}
 	}

+ 3 - 4
internal/app/ami/action/park.go

@@ -2,7 +2,6 @@ package action
 
 
 import (
 import (
 	"errors"
 	"errors"
-	"pbx-api-gin/internal/app/ami"
 	amiModel "pbx-api-gin/internal/app/ami/model"
 	amiModel "pbx-api-gin/internal/app/ami/model"
 	"pbx-api-gin/pkg/lfshook"
 	"pbx-api-gin/pkg/lfshook"
 
 
@@ -22,7 +21,7 @@ func Park(extension, lot string) (err error) {
 		action["Parkinglot"] = lot
 		action["Parkinglot"] = lot
 	}
 	}
 
 
-	res, events, err := ami.AminInstance.Send(action)
+	res, events, err := AminInstance.Send(action)
 	if err != nil {
 	if err != nil {
 		return err
 		return err
 	}
 	}
@@ -38,7 +37,7 @@ func ParkedCalls(lot string) (result []*amiModel.ParkedCall, err error) {
 		"Action":     "ParkedCalls",
 		"Action":     "ParkedCalls",
 		"Parkinglot": lot,
 		"Parkinglot": lot,
 	}
 	}
-	res, events, err := ami.AminInstance.Send(action)
+	res, events, err := AminInstance.Send(action)
 	if err != nil {
 	if err != nil {
 		return nil, err
 		return nil, err
 	}
 	}
@@ -62,7 +61,7 @@ func Parkinglots() (result []*amiModel.Parkinglot, err error) {
 	action := map[string]string{
 	action := map[string]string{
 		"Action": "Parkinglots",
 		"Action": "Parkinglots",
 	}
 	}
-	res, events, err := ami.AminInstance.Send(action)
+	res, events, err := AminInstance.Send(action)
 	if err != nil {
 	if err != nil {
 		return nil, err
 		return nil, err
 	}
 	}

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

@@ -3,7 +3,6 @@ package action
 import (
 import (
 	"errors"
 	"errors"
 	"fmt"
 	"fmt"
-	"pbx-api-gin/internal/app/ami"
 	"strings"
 	"strings"
 )
 )
 
 
@@ -22,7 +21,7 @@ func PlaybackPacu(filename string, count int, delay int, PaType string) (err err
 		"Variable": Para,
 		"Variable": Para,
 	}
 	}
 
 
-	res, _, err := ami.AminInstance.Send(action)
+	res, _, err := AminInstance.Send(action)
 	if err != nil {
 	if err != nil {
 		return err
 		return err
 	}
 	}

+ 5 - 6
internal/app/ami/action/queue.go

@@ -2,7 +2,6 @@ package action
 
 
 import (
 import (
 	"errors"
 	"errors"
-	"pbx-api-gin/internal/app/ami"
 	"pbx-api-gin/internal/app/ami/model"
 	"pbx-api-gin/internal/app/ami/model"
 
 
 	"github.com/mitchellh/mapstructure"
 	"github.com/mitchellh/mapstructure"
@@ -19,7 +18,7 @@ func QueueStatus(queue, member string) (queueParams *model.QueueParams, err erro
 	if member != "" {
 	if member != "" {
 		action["Member"] = member
 		action["Member"] = member
 	}
 	}
-	_, events, _ := ami.AminInstance.Send(action)
+	_, events, _ := AminInstance.Send(action)
 	for _, event := range events {
 	for _, event := range events {
 		if event.Data["Event"] == "QueueParams" {
 		if event.Data["Event"] == "QueueParams" {
 			queueParams = &model.QueueParams{Members: make([]*model.QueueMember, 0), Entrys: make([]*model.QueueEntry, 0)}
 			queueParams = &model.QueueParams{Members: make([]*model.QueueMember, 0), Entrys: make([]*model.QueueEntry, 0)}
@@ -52,7 +51,7 @@ func QueueAllStatus(queue, member string) (queuesMap map[string]*model.QueuePara
 	if member != "" {
 	if member != "" {
 		action["Member"] = member
 		action["Member"] = member
 	}
 	}
-	_, events, _ := ami.AminInstance.Send(action)
+	_, events, _ := AminInstance.Send(action)
 	for _, event := range events {
 	for _, event := range events {
 		if event.Data["Event"] == "QueueParams" {
 		if event.Data["Event"] == "QueueParams" {
 			queueParams := &model.QueueParams{Members: make([]*model.QueueMember, 0), Entrys: make([]*model.QueueEntry, 0)}
 			queueParams := &model.QueueParams{Members: make([]*model.QueueMember, 0), Entrys: make([]*model.QueueEntry, 0)}
@@ -88,7 +87,7 @@ func QueueAdd(queue, interface_value, pause string) error {
 		"Interface": interface_value,
 		"Interface": interface_value,
 		"Paused":    pause,
 		"Paused":    pause,
 	}
 	}
-	res, _, err := ami.AminInstance.Send(action)
+	res, _, err := AminInstance.Send(action)
 	if err != nil {
 	if err != nil {
 		return err
 		return err
 	}
 	}
@@ -105,7 +104,7 @@ func QueueRemove(queue, interface_value string) error {
 		"Queue":     queue,
 		"Queue":     queue,
 		"Interface": interface_value,
 		"Interface": interface_value,
 	}
 	}
-	res, _, err := ami.AminInstance.Send(action)
+	res, _, err := AminInstance.Send(action)
 	if err != nil {
 	if err != nil {
 		return err
 		return err
 	}
 	}
@@ -123,7 +122,7 @@ func QueuePasue(queue, interface_value, pause string) error {
 		"Interface": interface_value,
 		"Interface": interface_value,
 		"Paused":    pause,
 		"Paused":    pause,
 	}
 	}
-	res, _, err := ami.AminInstance.Send(action)
+	res, _, err := AminInstance.Send(action)
 	if err != nil {
 	if err != nil {
 		return err
 		return err
 	}
 	}

+ 2 - 2
internal/app/index.go

@@ -1,7 +1,7 @@
 package app
 package app
 
 
 import (
 import (
-	"pbx-api-gin/internal/app/ami"
+	"pbx-api-gin/internal/app/ami/action"
 	"pbx-api-gin/internal/app/mysql"
 	"pbx-api-gin/internal/app/mysql"
 	"pbx-api-gin/internal/app/stc"
 	"pbx-api-gin/internal/app/stc"
 
 
@@ -13,7 +13,7 @@ func StartApp() {
 
 
 	conn := stc.CreateConnection("192.168.17.14", 6090)
 	conn := stc.CreateConnection("192.168.17.14", 6090)
 
 
-	go ami.StartAMI(func() {
+	go action.StartAMI(func() {
 		lfshook.NewLogger().Info("ami callback")
 		lfshook.NewLogger().Info("ami callback")
 		// 首次连接才进行初始化
 		// 首次连接才进行初始化
 	}, []func(event map[string]string){}, conn)
 	}, []func(event map[string]string){}, conn)

+ 11 - 10
internal/app/stc/broadcast/stc-broadcast.go

@@ -10,8 +10,9 @@ import (
 	"pbx-api-gin/pkg/lfshook"
 	"pbx-api-gin/pkg/lfshook"
 )
 )
 
 
-var BroadcastExtens = []string{"2111", "2121", "2131", "2141", "2151", "2161", "2171", "2181"}
-var AlarmExtens = []string{"2111", "2121", "2131", "2141", "2151", "2161", "2171", "2181"}
+var Pacus = []string{"2111", "2121", "2131", "2141", "2151", "2161", "2171", "2181"}
+
+//var AlarmExtens = []string{"2111", "2121", "2131", "2141", "2151", "2161", "2171", "2181"}
 
 
 func HandleStcCmd(conn net.Conn) {
 func HandleStcCmd(conn net.Conn) {
 
 
@@ -71,7 +72,7 @@ func StationAnn(data []byte) (err error) {
 	filename := msgdata.SubstrByRune(string(data[12:]), 0, datalen-4)
 	filename := msgdata.SubstrByRune(string(data[12:]), 0, datalen-4)
 
 
 	//update special voice
 	//update special voice
-	_, er := mysql.DBOrmInstance.In("exten", BroadcastExtens).Update(&model.Extension{Special: specialVoice, PaType: "STN"})
+	_, er := mysql.DBOrmInstance.In("exten", Pacus).Update(&model.Extension{Special: specialVoice, PaType: "STN"})
 	if er != nil {
 	if er != nil {
 		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())
 		return er
 		return er
@@ -105,7 +106,7 @@ func SpecialAnn(data []byte) {
 	filename := msgdata.SubstrByRune(string(data[11:]), 0, datalen-3)
 	filename := msgdata.SubstrByRune(string(data[11:]), 0, datalen-3)
 
 
 	//update pa type
 	//update pa type
-	_, er := mysql.DBOrmInstance.In("exten", BroadcastExtens).Update(&model.Extension{PaType: "SPC"})
+	_, er := mysql.DBOrmInstance.In("exten", Pacus).Update(&model.Extension{PaType: "SPC"})
 	if er != nil {
 	if er != nil {
 		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())
 	}
 	}
@@ -126,7 +127,7 @@ func EmgMsg(data []byte) {
 	filename := msgdata.SubstrByRune(string(data[11:]), 0, datalen-3)
 	filename := msgdata.SubstrByRune(string(data[11:]), 0, datalen-3)
 
 
 	//update pa type
 	//update pa type
-	_, er := mysql.DBOrmInstance.In("exten", BroadcastExtens).Update(&model.Extension{PaType: "EMG"})
+	_, er := mysql.DBOrmInstance.In("exten", Pacus).Update(&model.Extension{PaType: "EMG"})
 	if er != nil {
 	if er != nil {
 		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())
 	}
 	}
@@ -152,11 +153,11 @@ func AnnStop(data [4]byte) {
 	case 0x09:
 	case 0x09:
 
 
 	}
 	}
-	for _, ext := range BroadcastExtens {
+	for _, ext := range Pacus {
 		action.Hangup(ext)
 		action.Hangup(ext)
 	}
 	}
 	//update pa type
 	//update pa type
-	_, er := mysql.DBOrmInstance.Cols("patype").In("exten", BroadcastExtens).Update(&model.Extension{PaType: ""})
+	_, er := mysql.DBOrmInstance.Cols("patype").In("exten", Pacus).Update(&model.Extension{PaType: ""})
 	if er != nil {
 	if er != nil {
 		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())
 	}
 	}
@@ -171,7 +172,7 @@ func DcsAnn(data []byte) {
 	filename := msgdata.SubstrByRune(string(data[11:]), 0, datalen-3)
 	filename := msgdata.SubstrByRune(string(data[11:]), 0, datalen-3)
 
 
 	//update pa type
 	//update pa type
-	_, er := mysql.DBOrmInstance.In("exten", BroadcastExtens).Update(&model.Extension{PaType: "DCS"})
+	_, er := mysql.DBOrmInstance.In("exten", Pacus).Update(&model.Extension{PaType: "DCS"})
 	if er != nil {
 	if er != nil {
 		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())
 	}
 	}
@@ -193,7 +194,7 @@ 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
 	//update pa type
-	_, er := mysql.DBOrmInstance.In("exten", BroadcastExtens).Update(&model.Extension{PaType: "CHK"})
+	_, er := mysql.DBOrmInstance.In("exten", Pacus).Update(&model.Extension{PaType: "CHK"})
 	if er != nil {
 	if er != nil {
 		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())
 	}
 	}
@@ -259,7 +260,7 @@ func RecordStorageConf(data []byte) {
 	cpaRcdDel := data[6]
 	cpaRcdDel := data[6]
 
 
 	//update pa type
 	//update pa type
-	_, er := mysql.DBOrmInstance.In("exten", BroadcastExtens).Update(&model.Extension{PaType: "CHK"})
+	_, er := mysql.DBOrmInstance.In("exten", Pacus).Update(&model.Extension{PaType: "CHK"})
 	if er != nil {
 	if er != nil {
 		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())
 	}
 	}

+ 7 - 5
internal/app/stc/sendstatus/status.go

@@ -42,14 +42,16 @@ func AlarmStatus(exten string, status string, conn net.Conn) {
 	switch status {
 	switch status {
 	case "unavailable", "Unavailable": //offline
 	case "unavailable", "Unavailable": //offline
 		protocol.Data[2] = 0x00
 		protocol.Data[2] = 0x00
+
 	case "idle", "Idle": //idle
 	case "idle", "Idle": //idle
 		protocol.Data[2] = 0x01
 		protocol.Data[2] = 0x01
-	case "dial": //dial
-		protocol.Data[2] = 0x02
-		//invite the PACU to queue
-		//action.Dial("PACU", "0300", "default", "0300", "0300", "PJSIP")
-	case "queue": //hold
+
+	//case "dial": //dial
+	//	protocol.Data[2] = 0x02
+
+	case "queue": //PAD alarm
 		protocol.Data[2] = 0x03
 		protocol.Data[2] = 0x03
+
 	case "connect": //connect
 	case "connect": //connect
 		protocol.Data[2] = 0x04
 		protocol.Data[2] = 0x04
 	}
 	}