siked 1 жил өмнө
commit
a5c982d00a
21 өөрчлөгдсөн 782 нэмэгдсэн , 0 устгасан
  1. 8 0
      .idea/.gitignore
  2. 9 0
      .idea/App_Warn.iml
  3. 21 0
      .idea/deployment.xml
  4. 8 0
      .idea/modules.xml
  5. BIN
      App_Warn
  6. 64 0
      Nats/Nats.go
  7. 1 0
      Nats/NatsStruct.go
  8. 114 0
      Server/Websocket.go
  9. 8 0
      Z_Build.bat
  10. 3 0
      conf/conf.ini
  11. 21 0
      conf/config.go
  12. 12 0
      dome_test.go
  13. 48 0
      go.mod
  14. 136 0
      go.sum
  15. 121 0
      lib/lib.go
  16. 38 0
      lib/libString.go
  17. 29 0
      logs/LogPrintln.go
  18. 70 0
      logs/logs.log
  19. 38 0
      logs/logs/logs.log
  20. 7 0
      logs/nohup.sh
  21. 26 0
      main.go

+ 8 - 0
.idea/.gitignore

@@ -0,0 +1,8 @@
+# 默认忽略的文件
+/shelf/
+/workspace.xml
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
+# 基于编辑器的 HTTP 客户端请求
+/httpRequests/

+ 9 - 0
.idea/App_Warn.iml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="WEB_MODULE" version="4">
+  <component name="Go" enabled="true" />
+  <component name="NewModuleRootManager">
+    <content url="file://$MODULE_DIR$" />
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+  </component>
+</module>

+ 21 - 0
.idea/deployment.xml

@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="PublishConfigData" remoteFilesAllowedToDisappearOnAutoupload="false">
+    <serverData>
+      <paths name="Alot">
+        <serverdata>
+          <mappings>
+            <mapping local="$PROJECT_DIR$" web="/" />
+          </mappings>
+        </serverdata>
+      </paths>
+      <paths name="huitong">
+        <serverdata>
+          <mappings>
+            <mapping local="$PROJECT_DIR$" web="/" />
+          </mappings>
+        </serverdata>
+      </paths>
+    </serverData>
+  </component>
+</project>

+ 8 - 0
.idea/modules.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/.idea/App_Warn.iml" filepath="$PROJECT_DIR$/.idea/App_Warn.iml" />
+    </modules>
+  </component>
+</project>

BIN
App_Warn


+ 64 - 0
Nats/Nats.go

@@ -0,0 +1,64 @@
+package Nats
+
+import (
+	"App_Warn/Server"
+	"App_Warn/conf"
+	"App_Warn/logs"
+	"github.com/nats-io/nats.go"
+	"github.com/vmihailenco/msgpack/v5"
+)
+
+var Nats *nats.Conn
+
+func init() {
+
+}
+
+func NatsInit() {
+
+	var err error
+	// 连接Nats服务器
+	Nats, err = nats.Connect("nats://" + conf.NatsServer_Url)
+	if err != nil {
+		logs.Println("nats 连接失败!")
+		panic(any("nats 连接失败!" + "nats://" + conf.NatsServer_Url))
+	}
+	logs.Println("nats OK!")
+
+	//// 发布-订阅 模式,异步订阅 test1
+	//_, _ = Nats.Subscribe("test1", func(m *nats.Msg) {
+	//	fmt.Printf("Received a message: %s\n", string(m.Data))
+	//})
+
+	//// 队列 模式,订阅 test2, 队列为queue, test2 发向所有队列,同一队列只有一个能收到消息
+	//_, _ = Nats.QueueSubscribe("test2", "queue", func(msg *nats.Msg) {
+	//	fmt.Printf("Queue a message: %s\n", string(msg.Data))
+	//})
+
+	//// 请求-响应, 响应 test3 消息。
+	//_, _ = Nats.Subscribe("test3", func(m *nats.Msg) {
+	//	fmt.Printf("Reply a message: %s\n", string(m.Data))
+	//	_ = Nats.Publish(m.Reply, []byte("I can help!!"))
+	//})
+
+	// 队列 模式,订阅 test2, 队列为queue, test2 发向所有队列,同一队列只有一个能收到消息
+	_, _ = Nats.Subscribe("App_Warn", func(m *nats.Msg) {
+		logs.Println("Nats => App_Warn: %s\n", string(m.Data))
+		type App_Warn struct {
+			Uuid string
+			Data string
+		}
+
+		var item App_Warn
+		err = msgpack.Unmarshal(m.Data, &item)
+		if err != nil {
+			logs.Println(err)
+			_ = Nats.Publish(m.Reply, []byte("数据解析错误!"))
+			return
+		}
+
+		_ = Nats.Publish(m.Reply, []byte(Server.App_Warn_Sand(item.Uuid, item.Data)))
+
+	})
+
+}

+ 1 - 0
Nats/NatsStruct.go

@@ -0,0 +1 @@
+package Nats

+ 114 - 0
Server/Websocket.go

@@ -0,0 +1,114 @@
+package Server
+
+import (
+	"App_Warn/lib"
+	"App_Warn/logs"
+	"fmt"
+	"github.com/gin-gonic/gin"
+	"github.com/gorilla/websocket"
+	"net/http"
+	"time"
+)
+
+var upGrader = websocket.Upgrader{
+	ReadBufferSize:   1024,
+	WriteBufferSize:  1024,
+	HandshakeTimeout: 10 * time.Second,
+	CheckOrigin: func(r *http.Request) bool {
+		return true
+	},
+}
+
+func WsHandle(c *gin.Context) {
+	//升级get请求为webSocket协议
+	ws, err := upGrader.Upgrade(c.Writer, c.Request, nil)
+	if err != nil {
+		c.Writer.Write([]byte(err.Error()))
+		return
+	}
+
+	defer func() {
+		ClearSubscription(ws) // 清楚订阅
+		ws.Close()
+	}()
+
+	uuid, _ := c.GetQuery("uuid")
+	logs.Println("ws上线:", fmt.Sprintf("%p", ws), "uuid:", uuid)
+
+	// 追加 订阅UUID
+	SubConn := []*websocket.Conn{}
+	// 从map中读取数据
+	val, ok := lib.SubClinets.Load(uuid)
+	if ok {
+		SubConn = val.([]*websocket.Conn)
+	}
+	SubConn = append(SubConn, ws)
+	// 写入map
+	lib.SubClinets.Store(uuid, SubConn)
+
+	for {
+		//读取ws中的数据
+		_, _, err := ws.ReadMessage()
+		if err != nil {
+			c.Writer.Write([]byte(err.Error()))
+			break
+		}
+		//fmt.Println("client message " + string(message) +"|"+ string(mt))
+		//fmt.Println(mt)
+		////time.Sleep(time.Second * 10)
+		//写入ws数据
+		err = ws.WriteMessage(1, []byte(time.Now().String()))
+		if err != nil {
+			ClearSubscription(ws) // 清楚订阅
+			ws.Close()
+			break
+		}
+		//fmt.Println("system message " + time.Now().String())
+	}
+}
+
+// 发送 数据
+func WebsocketWriteJSON(client *websocket.Conn, msg interface{}) error {
+	err := client.WriteJSON(msg)
+	if err != nil {
+		ClearSubscription(client) // 清楚订阅
+		client.Close()
+	}
+	return nil
+}
+
+func App_Warn_Sand(Uuid string, msg interface{}) string {
+	val, ok := lib.SubClinets.Load(Uuid)
+	if ok {
+		SubConn := val.([]*websocket.Conn)
+		for _, v := range SubConn {
+			WebsocketWriteJSON(v, msg)
+		}
+	} else {
+		return "发送无手机在线!"
+	}
+
+	return "发送成功!"
+
+}
+
+// 清楚订阅
+func ClearSubscription(client *websocket.Conn) {
+	logs.Println("清楚订阅:", fmt.Sprintf("%p", client))
+	// 编列所有订阅号
+	lib.SubClinets.Range(func(key, value interface{}) bool {
+		ConnList := value.([]*websocket.Conn)
+		Sn := key.(string)
+		logs.Println("SubClinets_数量|", Sn, len(ConnList))
+		for i, v := range ConnList {
+			if v == client {
+				logs.Println("删除订阅:", fmt.Sprintf("%p", v), Sn)
+				ConnList = append(ConnList[:i], ConnList[i+1:]...)
+				lib.SubClinets.Store(Sn, ConnList)
+				break
+			}
+		}
+
+		return true
+	})
+}

+ 8 - 0
Z_Build.bat

@@ -0,0 +1,8 @@
+cd %~dp0
+set GOARCH=amd64
+set GOOS=linux
+set GOPATH=C:\Users\SIKED\go
+set GO111MODULE=auto
+
+
+go build -o App_Warn main.go

+ 3 - 0
conf/conf.ini

@@ -0,0 +1,3 @@
+# Nats
+NatsServer_Url = 127.0.0.1:4222
+

+ 21 - 0
conf/config.go

@@ -0,0 +1,21 @@
+package conf
+
+import (
+	"github.com/Unknwon/goconfig"
+)
+
+var Config *goconfig.ConfigFile
+
+var NatsServer_Url string
+
+func init() {
+	var err error
+	Config, err = goconfig.LoadConfigFile("conf/conf.ini")
+	if err != nil {
+		panic(any("conf/conf.ini 没找到!"))
+	}
+
+	// Nats
+	NatsServer_Url, _ = Config.GetValue("", "NatsServer_Url")
+
+}

+ 12 - 0
dome_test.go

@@ -0,0 +1,12 @@
+package main
+
+import (
+	"testing"
+)
+
+func TestName(t *testing.T) {
+
+	//
+	//println(Server.App_Warn_Sand("18927494331","i2ixE1","温度超标报警"))
+
+}

+ 48 - 0
go.mod

@@ -0,0 +1,48 @@
+module App_Warn
+
+go 1.19
+
+require (
+	github.com/Unknwon/goconfig v1.0.0
+	github.com/gin-gonic/gin v1.9.1
+	github.com/gorilla/websocket v1.5.1
+	github.com/nats-io/nats.go v1.16.0
+	github.com/vmihailenco/msgpack/v5 v5.3.5
+)
+
+require (
+	github.com/bytedance/sonic v1.9.1 // indirect
+	github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
+	github.com/gabriel-vasile/mimetype v1.4.2 // indirect
+	github.com/gin-contrib/sse v0.1.0 // indirect
+	github.com/go-playground/locales v0.14.1 // indirect
+	github.com/go-playground/universal-translator v0.18.1 // indirect
+	github.com/go-playground/validator/v10 v10.14.0 // indirect
+	github.com/goccy/go-json v0.10.2 // indirect
+	github.com/golang/protobuf v1.5.2 // indirect
+	github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00 // indirect
+	github.com/json-iterator/go v1.1.12 // indirect
+	github.com/klauspost/cpuid/v2 v2.2.4 // indirect
+	github.com/leodido/go-urn v1.2.4 // indirect
+	github.com/mattn/go-isatty v0.0.19 // indirect
+	github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
+	github.com/modern-go/reflect2 v1.0.2 // indirect
+	github.com/nats-io/nats-server/v2 v2.8.4 // indirect
+	github.com/nats-io/nkeys v0.3.0 // indirect
+	github.com/nats-io/nuid v1.0.1 // indirect
+	github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
+	github.com/pelletier/go-toml/v2 v2.0.8 // indirect
+	github.com/smartystreets/assertions v1.1.0 // indirect
+	github.com/smartystreets/goconvey v1.6.4 // indirect
+	github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
+	github.com/ugorji/go/codec v1.2.11 // indirect
+	github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
+	golang.org/x/arch v0.3.0 // indirect
+	golang.org/x/crypto v0.19.0 // indirect
+	golang.org/x/net v0.21.0 // indirect
+	golang.org/x/sys v0.17.0 // indirect
+	golang.org/x/text v0.14.0 // indirect
+	google.golang.org/protobuf v1.30.0 // indirect
+	gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
+	gopkg.in/yaml.v3 v3.0.1 // indirect
+)

+ 136 - 0
go.sum

@@ -0,0 +1,136 @@
+github.com/Unknwon/goconfig v1.0.0 h1:9IAu/BYbSLQi8puFjUQApZTxIHqSwrj5d8vpP8vTq4A=
+github.com/Unknwon/goconfig v1.0.0/go.mod h1:wngxua9XCNjvHjDiTiV26DaKDT+0c63QR6H5hjVUUxw=
+github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
+github.com/bytedance/sonic v1.9.1 h1:6iJ6NqdoxCDr6mbY8h18oSO+cShGSMRGCEo7F2h0x8s=
+github.com/bytedance/sonic v1.9.1/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U=
+github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY=
+github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams=
+github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk=
+github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU=
+github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA=
+github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
+github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
+github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg=
+github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU=
+github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
+github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
+github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
+github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
+github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
+github.com/go-playground/validator/v10 v10.14.0 h1:vgvQWe3XCz3gIeFDm/HnTIbj6UGmg/+t63MyGU2n5js=
+github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
+github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
+github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
+github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
+github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
+github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
+github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
+github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
+github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
+github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00 h1:l5lAOZEym3oK3SQ2HBHWsJUfbNBiTXJDeW2QDxw9AQ0=
+github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
+github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY=
+github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=
+github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
+github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
+github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
+github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
+github.com/klauspost/compress v1.14.4 h1:eijASRJcobkVtSt81Olfh7JX43osYLwy5krOJo6YEu4=
+github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
+github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk=
+github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY=
+github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
+github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
+github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
+github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
+github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
+github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
+github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
+github.com/minio/highwayhash v1.0.2 h1:Aak5U0nElisjDCfPSG79Tgzkn2gl66NxOMspRrKnA/g=
+github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
+github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
+github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
+github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
+github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
+github.com/nats-io/jwt/v2 v2.2.1-0.20220330180145-442af02fd36a h1:lem6QCvxR0Y28gth9P+wV2K/zYUUAkJ+55U8cpS0p5I=
+github.com/nats-io/nats-server/v2 v2.8.4 h1:0jQzze1T9mECg8YZEl8+WYUXb9JKluJfCBriPUtluB4=
+github.com/nats-io/nats-server/v2 v2.8.4/go.mod h1:8zZa+Al3WsESfmgSs98Fi06dRWLH5Bnq90m5bKD/eT4=
+github.com/nats-io/nats.go v1.16.0 h1:zvLE7fGBQYW6MWaFaRdsgm9qT39PJDQoju+DS8KsO1g=
+github.com/nats-io/nats.go v1.16.0/go.mod h1:BPko4oXsySz4aSWeFgOHLZs3G4Jq4ZAyE6/zMCxRT6w=
+github.com/nats-io/nkeys v0.3.0 h1:cgM5tL53EvYRU+2YLXIK0G2mJtK12Ft9oeooSZMA2G8=
+github.com/nats-io/nkeys v0.3.0/go.mod h1:gvUNGjVcM2IPr5rCsRsC6Wb3Hr2CQAm08dsxtV6A5y4=
+github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw=
+github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
+github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
+github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
+github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ=
+github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4=
+github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
+github.com/smartystreets/assertions v1.1.0 h1:MkTeG1DMwsrdH7QtLXy5W+fUxWq+vmb6cLmyJ7aRtF0=
+github.com/smartystreets/assertions v1.1.0/go.mod h1:tcbTF8ujkAEcZ8TElKY+i30BzYlVhC/LOxJk7iOWnoo=
+github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
+github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
+github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
+github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
+github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
+github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
+github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
+github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
+github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY=
+github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
+github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
+github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
+github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU=
+github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
+github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9znI5mJU=
+github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc=
+github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
+github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
+golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
+golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k=
+golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
+golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/crypto v0.0.0-20210314154223-e6e6c4f2bb5b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
+golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo=
+golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
+golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
+golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
+golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
+golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
+golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
+golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
+golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
+golang.org/x/time v0.0.0-20211116232009-f0f3c7e86c11 h1:GZokNIeuVkl3aZHJchRrr13WCsols02MLUcz1U9is6M=
+golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
+golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
+golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
+google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
+google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
+google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
+gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
+gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=

+ 121 - 0
lib/lib.go

@@ -0,0 +1,121 @@
+package lib
+
+import (
+	"encoding/json"
+	"fmt"
+	"strconv"
+	"sync"
+)
+
+type Cl_ struct {
+	Uuid_list map[string]string // 泛型
+}
+
+var SubClinets sync.Map // 订阅Map
+
+func init() {
+
+}
+
+func To_float32(value interface{}) float32 {
+	var key float32
+	if value == nil {
+		return key
+	}
+
+	switch value.(type) {
+	case float64:
+		key = float32(value.(float64))
+	case float32:
+		key = float32(value.(float32))
+	case int:
+		key = float32(value.(int))
+	case uint:
+		key = float32(value.(uint))
+	case int8:
+		key = float32(value.(int8))
+	case uint8:
+		key = float32(value.(uint8))
+	case int16:
+		key = float32(value.(int16))
+	case uint16:
+		key = float32(value.(uint16))
+	case int32:
+		key = float32(value.(int32))
+	case uint32:
+		key = float32(value.(uint32))
+	case int64:
+		key = float32(value.(int64))
+	case uint64:
+		key = float32(value.(uint64))
+	case string:
+		key_float64, _ := strconv.ParseFloat(value.(string), 32/64)
+		key = float32(key_float64)
+	case []byte:
+		key_float64, _ := strconv.ParseFloat(string(value.([]byte)), 32/64)
+		key = float32(key_float64)
+	default:
+		newValue, _ := json.Marshal(value)
+		key_float64, _ := strconv.ParseFloat(string(newValue), 32/64)
+		key = float32(key_float64)
+	}
+
+	key_float64, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", key), 32/64)
+	key = float32(key_float64)
+
+	return key
+}
+
+func To_string(value interface{}) string {
+	var key string
+	if value == nil {
+		return key
+	}
+
+	switch value.(type) {
+	case float64:
+		ft := value.(float64)
+		key = strconv.FormatFloat(ft, 'f', -1, 64)
+	case float32:
+		ft := value.(float32)
+		key = strconv.FormatFloat(float64(ft), 'f', -1, 64)
+	case int:
+		it := value.(int)
+		key = strconv.Itoa(it)
+	case uint:
+		it := value.(uint)
+		key = strconv.Itoa(int(it))
+	case int8:
+		it := value.(int8)
+		key = strconv.Itoa(int(it))
+	case uint8:
+		it := value.(uint8)
+		key = strconv.Itoa(int(it))
+	case int16:
+		it := value.(int16)
+		key = strconv.Itoa(int(it))
+	case uint16:
+		it := value.(uint16)
+		key = strconv.Itoa(int(it))
+	case int32:
+		it := value.(int32)
+		key = strconv.Itoa(int(it))
+	case uint32:
+		it := value.(uint32)
+		key = strconv.Itoa(int(it))
+	case int64:
+		it := value.(int64)
+		key = strconv.FormatInt(it, 10)
+	case uint64:
+		it := value.(uint64)
+		key = strconv.FormatUint(it, 10)
+	case string:
+		key = value.(string)
+	case []byte:
+		key = string(value.([]byte))
+	default:
+		newValue, _ := json.Marshal(value)
+		key = string(newValue)
+	}
+	return key
+}

+ 38 - 0
lib/libString.go

@@ -0,0 +1,38 @@
+package lib
+
+import (
+	"crypto/md5"
+	"encoding/hex"
+	"math/rand"
+	"strings"
+	"time"
+)
+
+// #取得随机字符串:通过打乱slice来操作
+func GetRandstring(length int, char string, rand_x int64) string {
+	if length < 1 {
+		return ""
+	}
+
+	if len(char) <= 6 || len(char) <= length {
+		char = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
+	}
+
+	charArr := strings.Split(char, "")
+	ran := rand.New(rand.NewSource(time.Now().Unix() + rand_x))
+
+	l := len(charArr)
+	for i := l - 1; i > 0; i-- {
+		r := ran.Intn(i)
+		charArr[r], charArr[i] = charArr[i], charArr[r]
+	}
+	rchar := charArr[:length]
+	return strings.Join(rchar, "")
+}
+
+// 返回一个32位md5加密后的字符串
+func Md5(str string) string {
+	h := md5.New()
+	h.Write([]byte(str))
+	return hex.EncodeToString(h.Sum(nil))
+}

+ 29 - 0
logs/LogPrintln.go

@@ -0,0 +1,29 @@
+package logs
+
+import (
+	"fmt"
+	"log"
+	"os"
+)
+
+func init() {
+	logFile, err := os.OpenFile("logs/logs.log", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0644)
+	if err != nil {
+		fmt.Println("open log file failed, err:", err)
+		return
+	}
+	log.SetOutput(logFile)
+	//log.SetFlags(log.Lshortfile | log.Lmicroseconds | log.Ldate)
+	//
+
+	//log.Println("这是一条很普通的日志。")
+	//v := "很普通的"
+	//log.Printf("这是一条%s日志。\n", v)
+	//log.Fatalln("这是一条会触发fatal的日志。")
+	//log.Panicln("这是一条会触发panic的日志。")
+}
+
+func Println(a ...interface{}) {
+	log.Println(a)
+	//fmt.Println(a)
+}

+ 70 - 0
logs/logs.log

@@ -0,0 +1,70 @@
+2023/03/03 15:19:50 [nats 连接失败!]
+2023/04/14 16:26:21 [nats 连接失败!]
+2023/04/14 16:27:50 [nats OK!]
+2023/04/14 16:27:50 [Nats => 18777951277 HeWYR3 {"name1":"tttttt","name1":"2023-01-18 17:27:40","name1":"ttttttt","name1":"yyyyyyyyyy","T_T":"21.700000762939453","T_RH":"41.5",}]
+2023/04/14 16:27:50 [<nil>]
+2023/04/14 16:29:57 [nats OK!]
+2023/04/14 16:29:57 [Nats => 18777951277 HeWYR3 {"name1":"tttttt","name1":"2023-01-18 17:27:40","name1":"ttttttt","name1":"yyyyyyyyyy","T_T":"21.700000762939453","T_RH":"41.5",}]
+2023/04/14 16:29:57 [<nil>]
+2023/04/14 16:34:33 [nats OK!]
+2023/04/14 16:34:33 [Nats => 18777951277 HeWYR3 {"name1":"tttttt","name1":"2023-01-18 17:27:40","name1":"ttttttt","name1":"yyyyyyyyyy","T_T":"21.700000762939453","T_RH":"41.5",}]
+2023/04/14 16:34:33 [<nil>]
+2023/04/14 16:39:39 [nats OK!]
+2023/04/14 16:39:39 [Nats => 18777951277 HeWYR3 {"name1":"tttttt","name2":"2023-01-18 17:27:40","name3":"ttttttt","name4":"yyyyyyyyyy","T_T":"21.700000762939453","T_RH":"41.5",}]
+2023/04/14 16:39:39 [<nil>]
+2023/04/14 16:39:39 [{"T_RH":"41.5","T_T":"21.7","name1":"tttttt","name2":"2023-01-18 17:27:40","name3":"ttttttt","name4":"yyyyyyyyyy"}]
+2023/04/14 16:39:40 [_result.Body: {"status":"success","send_id":"6d04815974134f1840903fe8c84e67a6","fee":2}]
+2023/04/14 16:47:30 [nats OK!]
+2023/04/14 16:47:30 [Nats => App_Warn: %s
+ ��PhoneNumbers�18777951277�TemplateCode�HeWYR3�TemplateParamف{"name1":"tttttt","name2":"2023-01-18 17:27:40","name3":"ttttttt","name4":"yyyyyyyyyy","T_T":"21.700000762939453","T_RH":"41.5",}]
+2023/04/14 16:47:30 [<nil>]
+2023/04/14 16:47:30 [{"T_RH":"41.5","T_T":"21.7","name1":"tttttt","name2":"2023-01-18 17:27:40","name3":"ttttttt","name4":"yyyyyyyyyy"}]
+2023/04/14 16:47:30 [map[appid:94309 project:HeWYR3 signature:8c79de85cc4bc61d93b36ff89862e3e6 to:18777951277 vars:{"T_RH":"41.5","T_T":"21.7","name1":"tttttt","name2":"2023-01-18 17:27:40","name3":"ttttttt","name4":"yyyyyyyyyy"}]]
+2023/04/14 16:47:31 [_result.Body: {"status":"success","send_id":"2d46a8f1c5e14e9067aeee858bacb97c","fee":2}]
+2023/04/14 16:48:08 [nats OK!]
+2023/04/14 16:48:08 [Nats => App_Warn: %s
+ ��PhoneNumbers�18777951277�TemplateCode�JDHNV4�TemplateParamف{"name1":"tttttt","name2":"2023-01-18 17:27:40","name3":"ttttttt","name4":"yyyyyyyyyy","T_T":"21.700000762939453","T_RH":"41.5",}]
+2023/04/14 16:48:08 [<nil>]
+2023/04/14 16:48:08 [{"T_RH":"41.5","T_T":"21.7","name1":"tttttt","name2":"2023-01-18 17:27:40","name3":"ttttttt","name4":"yyyyyyyyyy"}]
+2023/04/14 16:48:08 [map[appid:94309 project:JDHNV4 signature:8c79de85cc4bc61d93b36ff89862e3e6 to:18777951277 vars:{"T_RH":"41.5","T_T":"21.7","name1":"tttttt","name2":"2023-01-18 17:27:40","name3":"ttttttt","name4":"yyyyyyyyyy"}]]
+2023/04/14 16:48:08 [_result.Body: {"status":"success","send_id":"ba394c1e915f4db342faf9ebab3d4a7f","fee":2}]
+2023/08/08 14:21:21 [_result.Body: {"status":"error","code":101,"msg":"Incorrect APP ID or the Content-type does not match the data format"}]
+2023/08/08 14:23:57 [_result.Body: {"status":"success","send_id":"c39b10540a04469443f0ca2eaaab2344","fee":0.09}]
+2023/08/08 14:27:50 [_result.Body: {"status":"success","send_id":"17f3fbc8aa2345ca7c78a841eabda2ee","fee":0.09}]
+2023/08/08 14:31:32 [_result.Body: {"status":"success","send_id":"9273acc66ac84b6948fe7957eefcd446","fee":0.09}]
+2023/08/08 14:32:15 [_result.Body: {"status":"success","send_id":"934f0c6ef769472a608417b15e737891","fee":0.09}]
+2023/08/08 14:33:44 [_result.Body: {"status":"success","send_id":"5d3cf470f1ad46ff45ce29e61830c8fe","fee":0.09}]
+2023/08/08 14:34:25 [_result.Body: {"status":"success","send_id":"04c298c857fb462258dc160149afa3dc","fee":0.09}]
+2024/02/20 14:52:58 http: response.Write on hijacked connection from github.com/gin-gonic/gin.(*responseWriter).Write (response_writer.go:83)
+2024/02/20 14:54:57 http: response.Write on hijacked connection from github.com/gin-gonic/gin.(*responseWriter).Write (response_writer.go:83)
+2024/02/20 16:16:23 [nats OK!]
+2024/02/20 16:16:31 [ws上线: 0xc00050a000 uuid: 123333333333]
+2024/02/20 16:17:20 [nats OK!]
+2024/02/20 16:17:23 [ws上线: 0xc000520000 uuid: 123333333333]
+2024/02/20 16:17:41 [nats OK!]
+2024/02/20 16:18:26 [ws上线: 0xc00016c160 uuid: 123333333333]
+2024/02/20 16:20:07 [ws上线: 0xc000148160 uuid: 123333333333]
+2024/02/20 16:20:36 [ws上线: 0xc000148160 uuid: 123333333333]
+2024/02/20 16:21:26 [清楚订阅: 0xc000148160]
+2024/02/20 16:21:26 [SubClinets_数量| 123333333333 1]
+2024/02/20 16:21:26 [清楚订阅: 0xc000148160]
+2024/02/20 16:21:26 [SubClinets_数量| 123333333333 0]
+2024/02/20 16:21:40 [ws上线: 0xc000148160 uuid: 123333333333]
+2024/02/20 16:22:14 [ws上线: 0xc0000f6160 uuid: 123333333333]
+2024/02/20 16:22:21 http: response.Write on hijacked connection from github.com/gin-gonic/gin.(*responseWriter).Write (response_writer.go:83)
+2024/02/20 16:22:21 [清楚订阅: 0xc0000f6160]
+2024/02/20 16:22:21 [SubClinets_数量| 123333333333 1]
+2024/02/20 16:22:27 [ws上线: 0xc0000f6420 uuid: 123333333333]
+2024/02/20 16:22:55 [ws上线: 0xc000148160 uuid: 123333333333]
+2024/02/20 16:23:00 http: response.Write on hijacked connection from github.com/gin-gonic/gin.(*responseWriter).Write (response_writer.go:83)
+2024/02/20 16:23:00 [清楚订阅: 0xc000148160]
+2024/02/20 16:23:00 [SubClinets_数量| 123333333333 1]
+2024/02/20 16:29:42 [ws上线: 0xc000594160 uuid: 123333333333]
+2024/02/20 16:29:54 http: response.Write on hijacked connection from github.com/gin-gonic/gin.(*responseWriter).Write (response_writer.go:83)
+2024/02/20 16:29:54 [清楚订阅: 0xc000594160]
+2024/02/20 16:29:54 [SubClinets_数量| 123333333333 1]
+2024/02/20 16:30:21 [ws上线: 0xc000124160 uuid: 123333333333]
+2024/02/20 16:35:37 [ws上线: 0xc000148160 uuid: 123333333333]
+2024/02/20 16:35:39 http: response.Write on hijacked connection from github.com/gin-gonic/gin.(*responseWriter).Write (response_writer.go:83)
+2024/02/20 16:35:39 [清楚订阅: 0xc000148160]
+2024/02/20 16:35:39 [SubClinets_数量| 123333333333 1]

+ 38 - 0
logs/logs/logs.log

@@ -0,0 +1,38 @@
+2023/01/06 11:34:12.997589 C:/BZD/Cold/APP/App_Warn/logs/LogPrintln.go:28: [nats OK!]
+2023/01/06 11:35:05.639922 LogPrintln.go:28: [nats OK!]
+2023/01/06 11:35:31 [nats OK!]
+2023/01/06 11:37:47 [nats OK!]
+2023/01/18 17:18:03 [nats 连接失败!]
+2023/01/18 17:18:51 [nats OK!]
+2023/01/18 17:18:51 [Nats => 18777951277 SMS_232170337 {"T_Title":"温度超下限报警","T_Ut":"2023-01-18 17:12:42","T_Addr":"贵州科开医药有限公司1号库管理主机","T_Name":"1-2-07(特温库一)","T_T":"20.5","T_RH":"42.79999923706055",}]
+2023/01/18 17:19:10 [nats OK!]
+2023/01/18 17:19:10 [Nats => 18777951277 SMS_232170337 {"T_Title":"温度超下限报警","T_Ut":"2023-01-18 17:12:42","T_Addr":"贵州科开医药有限公司1号库管理主机","T_Name":"1-2-07(特温库一)","T_T":"20.5","T_RH":"42.79999923706055",}]
+2023/01/18 17:20:33 [nats OK!]
+2023/01/18 17:20:33 [Nats => 18777951277 SMS_232170337 {"T_Title":"温度超下限报警","T_Ut":"2023-01-18 17:12:42","T_Addr":"贵州科开医药有限公司1号库管理主机","T_Name":"1-2-07(特温库一)","T_T":"20.5","T_RH":"42.79999923706055",}]
+2023/01/18 17:20:55 [nats OK!]
+2023/01/18 17:20:55 [Nats => 18777951277 SMS_232170337 {"T_Title":"温度超下限报警","T_Ut":"2023-01-18 17:12:42","T_Addr":"贵州科开医药有限公司1号库管理主机","T_Name":"1-2-07(特温库一)","T_T":"20.5","T_RH":"42.79999923706055",}]
+2023/01/18 17:22:00 [nats OK!]
+2023/01/18 17:22:01 [Nats => 18777951277 SMS_232170337 {"T_Title":"温度超下限报警","T_Ut":"2023-01-18 17:12:42","T_Addr":"贵州科开医药有限公司1号库管理主机","T_Name":"1-2-07(特温库一)","T_T":"20.5","T_RH":"42.79999923706055",}]
+2023/01/18 17:22:08 [_result.Body: {
+   "Code": "isv.PARAM_LENGTH_LIMIT",
+   "Message": "参数超过长度限制:35",
+   "RequestId": "5062B908-9BA4-50D0-82E3-D4752006B388"
+}]
+2023/01/18 17:29:47 [nats OK!]
+2023/01/18 17:29:47 [Nats => 18777951277 SMS_232170337 {"T_Title":"tttttt","T_Ut":"2023-01-18 17:27:40","T_Addr":"ttttttt","T_Name":"yyyyyyyyyy","T_T":"21.700000762939453","T_RH":"41.5",}]
+2023/01/18 17:30:48 [nats OK!]
+2023/01/18 17:30:48 [Nats => 18777951277 SMS_232170337 {"T_Title":"tttttt","T_Ut":"2023-01-18 17:27:40","T_Addr":"ttttttt","T_Name":"yyyyyyyyyy","T_T":"21.700000762939453","T_RH":"41.5",}]
+2023/01/18 17:31:11 [nats OK!]
+2023/01/18 17:31:11 [Nats => 18777951277 SMS_232170337 {"T_Title":"tttttt","T_Ut":"2023-01-18 17:27:40","T_Addr":"ttttttt","T_Name":"yyyyyyyyyy","T_T":"21.700000762939453","T_RH":"41.5",}]
+2023/01/18 17:32:29 [nats OK!]
+2023/01/18 17:32:29 [Nats => 18777951277 SMS_232170337 {"T_Title":"tttttt","T_Ut":"2023-01-18 17:27:40","T_Addr":"ttttttt","T_Name":"yyyyyyyyyy","T_T":"21.700000762939453","T_RH":"41.5",}]
+2023/01/18 17:33:51 [nats OK!]
+2023/01/18 17:33:51 [Nats => 18777951277 SMS_232170337 {"T_Title":"tttttt","T_Ut":"2023-01-18 17:27:40","T_Addr":"ttttttt","T_Name":"yyyyyyyyyy","T_T":"21.700000762939453","T_RH":"41.5",}]
+2023/01/18 17:34:00 [nats OK!]
+2023/01/18 17:34:00 [Nats => 18777951277 SMS_232170337 {"T_Title":"tttttt","T_Ut":"2023-01-18 17:27:40","T_Addr":"ttttttt","T_Name":"yyyyyyyyyy","T_T":"21.700000762939453","T_RH":"41.5",}]
+2023/01/18 17:34:00 [_result.Body: {
+   "BizId": "831300974034440359^0",
+   "Code": "OK",
+   "Message": "OK",
+   "RequestId": "FDD8C924-079A-5356-A04F-F238347A6D57"
+}]

+ 7 - 0
logs/nohup.sh

@@ -0,0 +1,7 @@
+#!/bin/sh 
+#获取前一天的日期 
+date=`date -d "yesterday" +%Y_%m_%d` 
+#复制原始nohup.out到备份目录,并以前一天的日期进行命名 
+cp /bzd/project/ColdVerify_server/log/nohup.out /bzd/project/ColdVerify_server/log/$date.out 
+#清空原始nohup.out中的内容
+cat /dev/null > /bzd/project/ColdVerify_server/log/nohup.out

+ 26 - 0
main.go

@@ -0,0 +1,26 @@
+package main
+
+import (
+	"App_Warn/Nats"
+	"App_Warn/Server"
+	"github.com/gin-gonic/gin"
+)
+
+func main() {
+
+	Nats.NatsInit()
+
+	bindAddress := "localhost:6211"
+	r := gin.Default()
+	r.GET("/ws", Server.WsHandle)
+
+	// 测试
+	//go func() {
+	//	println(Server.App_Warn_Sand("123333333333","{\"name1\":\"tttttt\",\"name2\":\"2023-01-18 17:27:40\",\"name3\":\"ttttttt\",\"name4\":\"yyyyyyyyyy\",\"T_T\":\"21.700000762939453\",\"T_RH\":\"41.5\",}"))
+	//	time.Sleep(time.Second * 3)
+	//	println(Server.App_Warn_Sand("123333333333","{\"name1\":\"tttttt\",\"name2\":\"2023-01-18 17:27:40\",\"name3\":\"ttttttt\",\"name4\":\"yyyyyyyyyy\",\"T_T\":\"21.700000762939453\",\"T_RH\":\"41.5\",}"))
+	//}()
+
+	r.Run(bindAddress)
+
+}