siked 2 years ago
parent
commit
36c18eaada

BIN
Cold_Api6200


BIN
Cold_Api6201


+ 117 - 0
Nats/Nats.go

@@ -7,11 +7,15 @@ import (
 	"Cold_Api/models/Device"
 	"encoding/xml"
 	"fmt"
+	"github.com/astaxie/beego/cache"
 	"github.com/nats-io/nats.go"
 	"strconv"
 	"strings"
+	"time"
 )
 
+var redisCache_NatsServer cache.Cache
+
 func init() {
 
 	logs.Println("============Nats init============")
@@ -25,6 +29,17 @@ func init() {
 	logs.Println("nats OK!")
 
 	go NatsInit()
+
+	config := fmt.Sprintf(`{"key":"%s","conn":"%s","dbNum":"%s","password":"%s"}`,
+		"redisCache_NatsServer", conf.Redis_address, conf.Redis_dbNum, conf.Redis_password)
+	fmt.Println(config)
+	redisCache_NatsServer, err = cache.NewCache("redis", config)
+	if err != nil || redisCache_NatsServer == nil {
+		errMsg := "failed to init redis"
+		fmt.Println(errMsg, err)
+		panic(errMsg)
+	}
+
 }
 
 func NatsInit() {
@@ -78,6 +93,108 @@ func NatsInit() {
 		_ = lib.Nats.Publish(m.Reply, []byte(""))
 	})
 
+	// 请求-响应, 响应 test3 消息。
+	_, _ = lib.Nats.Subscribe("Wx2_BasicMessage_Event_QRCode", func(m *nats.Msg) {
+		fmt.Printf(" => Nats   Wx2_BasicMessage_Event_QRCode message: %s\n", string(m.Data))
+
+		type Person_QRCode struct {
+			ToUserName   string `xml:"ToUserName"`   //注意这里有个反引号
+			FromUserName string `xml:"FromUserName"` //注意这里有个反引号
+			CreateTime   string `xml:"CreateTime"`   //注意这里有个反引号
+			EventKey     string `xml:"EventKey"`
+		}
+		var person_QRCode Person_QRCode
+		err1 := xml.Unmarshal(m.Data, &person_QRCode)
+		if err1 != nil {
+			fmt.Println("Unmarshal error")
+			_ = lib.Nats.Publish(m.Reply, []byte(""))
+			return
+		}
+		// 进入 二维码配对
+		fmt.Println("FromUserName-", person_QRCode.FromUserName)
+		fmt.Println("EventKey-", person_QRCode.EventKey)
+
+		// 开始  处理消息
+		if strings.Contains(person_QRCode.EventKey, "@宝智达 微信公众号通知") {
+			//"请将本内容发送到 深圳市宝智达科技有限公司 微信公众号-|"+lib.AesEncryptCBC(T_calss_id, "0123456789012345")+"|-",
+			Content_r := lib.GetBetweenStr(person_QRCode.EventKey, "-|", "|-")
+			decryptCode := lib.AesDecryptCBC(Content_r, "0123456789012345")
+			decryptCode_int, err := strconv.Atoi(decryptCode)
+			fmt.Println("解密结果:", decryptCode, "  decryptCode_int", decryptCode_int, "  Content_r:", Content_r)
+			R_DeviceClass, err := Device.Read_Class_ById(decryptCode_int)
+			if err != nil {
+				_ = lib.Nats.Publish(m.Reply, []byte(""))
+				return
+			}
+
+			if strings.Contains(R_DeviceClass.T_Notice_wx2, person_QRCode.FromUserName+"/重令名|") {
+				_ = lib.Nats.Publish(m.Reply, []byte(R_DeviceClass.T_name+" 重复扫码!请在 5分钟内 回复您的名字,否则将 无法收到报警消息!如回复:张三"))
+				return
+			}
+			if strings.Contains(R_DeviceClass.T_Notice_wx2, person_QRCode.FromUserName) {
+				_ = lib.Nats.Publish(m.Reply, []byte(R_DeviceClass.T_name+" 已绑定,无需重复绑定!"))
+				return
+			}
+
+			R_DeviceClass.T_Notice_wx2 = R_DeviceClass.T_Notice_wx2 + person_QRCode.FromUserName + "/重令名|"
+			Device.Update_Class_ById(R_DeviceClass)
+			redisCache_NatsServer.Put(person_QRCode.FromUserName, decryptCode_int, 5*time.Minute)
+			_ = lib.Nats.Publish(m.Reply, []byte(R_DeviceClass.T_name+" 扫码成功!请在 5分钟内 回复您的名字,否则将 无法收到报警消息!如回复:张三"))
+			return
+		}
+		_ = lib.Nats.Publish(m.Reply, []byte(""))
+	})
+
+	// 请求-响应, 响应 test3 消息。
+	_, _ = lib.Nats.Subscribe("Wx2_BasicMessage_Text", func(m *nats.Msg) {
+		logs.Println(" => Nats   Wx2_BasicMessage_Text message: %s\n", string(m.Data))
+
+		type Person_Text struct {
+			ToUserName   string `xml:"ToUserName"`   //注意这里有个反引号
+			FromUserName string `xml:"FromUserName"` //注意这里有个反引号
+			CreateTime   string `xml:"CreateTime"`   //注意这里有个反引号
+			MsgType      string `xml:"MsgType"`
+			Content      string `xml:"Content"`
+		}
+
+		var person_Text Person_Text
+		err1 := xml.Unmarshal(m.Data, &person_Text)
+		if err1 != nil {
+			fmt.Println("Unmarshal error")
+			_ = lib.Nats.Publish(m.Reply, []byte(""))
+			return
+		}
+		// 进入 二维码配对
+		fmt.Println("FromUserName-", person_Text.FromUserName)
+		fmt.Println("Content-", person_Text.Content)
+
+		if len(person_Text.Content) > 8*3 || len(person_Text.Content) <= 1*3 {
+			_ = lib.Nats.Publish(m.Reply, []byte("请正确输入您的名字!"))
+			return
+		}
+
+		if !redisCache_NatsServer.IsExist(person_Text.FromUserName) {
+			return
+		}
+		Class_ById := lib.To_int(redisCache_NatsServer.Get(person_Text.FromUserName))
+		R_DeviceClass, err := Device.Read_Class_ById(Class_ById)
+		if err != nil {
+			_ = lib.Nats.Publish(m.Reply, []byte(""))
+			return
+		}
+
+		R_DeviceClass.T_Notice_wx2 = strings.Replace(R_DeviceClass.T_Notice_wx2,
+			person_Text.FromUserName+"/重令名|",
+			person_Text.FromUserName+"/"+person_Text.Content+"|",
+			-1)
+		Device.Update_Class_ById(R_DeviceClass)
+
+		// 删除 缓存
+		redisCache_NatsServer.Delete(person_Text.FromUserName)
+
+		_ = lib.Nats.Publish(m.Reply, []byte("尊敬的 "+person_Text.Content+",您以成功绑定 "+R_DeviceClass.T_name))
+	})
+
 	//// 发布-订阅 模式,异步订阅 test1
 	//_, _ = Nats.Subscribe("test1", func(m *nats.Msg) {
 	//	fmt.Printf("Received a message: %s\n", string(m.Data))

+ 15 - 0
Nats/NatsServer/NatsWx.go

@@ -21,3 +21,18 @@ func Wx_GenerateQRCode(DeviceClass_id string) (string, bool) {
 
 	return string(msg.Data), false
 }
+
+func Wx_GenerateQRCode2(DeviceClass_id string) (string, bool) {
+	logs.Println(" => Nats", lib.FuncName(), DeviceClass_id)
+
+	// 请求-响应, 向 test3 发布一个 `help me` 请求数据,设置超时间3秒,如果有多个响应,只接收第一个收到的消息
+	msg, err := lib.Nats.Request("Wx2_GenerateQR", []byte(DeviceClass_id), 3*time.Second)
+	if err != nil {
+		fmt.Println(err)
+	} else {
+		fmt.Printf("Wx2_GenerateQR : %s\n", string(msg.Data))
+		return string(msg.Data), true
+	}
+
+	return string(msg.Data), false
+}

+ 1 - 1
conf/app.conf

@@ -32,7 +32,7 @@ MysqlServer_MaxOpenConnections = 200
 
 
 # Redis
-Redis_address = "192.168.192.63:6379"
+Redis_address = "47.111.15.17:6379"
 Redis_password = ""
 Redis_dbNum = "1"
 

+ 12 - 7
controllers/Data.go

@@ -329,7 +329,7 @@ func (c *DataController) Device_Sensor_Data_Excel() {
 
 	headStyleLower, _ := f.NewStyle(`{
 		   "font":{
-			  "color":"#a8f7ff",
+			  "color":"#ff8585",
 			 	"size":11,
       "family":"arial"
 		   }
@@ -359,11 +359,13 @@ func (c *DataController) Device_Sensor_Data_Excel() {
 		}
 		f.SetCellValue("Sheet1", fmt.Sprintf("G%d", line), v.T_time)
 
-		if v.T_t < v.T_Tlower || v.T_rh < v.T_RHlower {
+		if v.T_t < v.T_Tlower || v.T_t > v.T_Tupper {
 			f.SetCellStyle("Sheet1", fmt.Sprintf("A%d", line), fmt.Sprintf("G%d", line), headStyleLower)
 		}
-		if v.T_t > v.T_Tupper || v.T_rh > v.T_RHupper {
-			f.SetCellStyle("Sheet1", fmt.Sprintf("A%d", line), fmt.Sprintf("G%d", line), headStyleUpper)
+		if !(admin_r.Admin_rh == 0 && strings.Contains(v.T_sn, "YD")) {
+			if v.T_rh < v.T_RHlower || v.T_rh > v.T_RHupper {
+				f.SetCellStyle("Sheet1", fmt.Sprintf("A%d", line), fmt.Sprintf("G%d", line), headStyleUpper)
+			}
 		}
 
 	}
@@ -503,11 +505,13 @@ func (c *DataController) Device_Sensor_Data_Excel_m() {
 		}
 		f.SetCellValue("Sheet1", fmt.Sprintf("G%d", line), v.T_time)
 
-		if v.T_t < v.T_Tlower || v.T_rh < v.T_RHlower {
+		if v.T_t < v.T_Tlower || v.T_t > v.T_Tupper {
 			f.SetCellStyle("Sheet1", fmt.Sprintf("A%d", line), fmt.Sprintf("G%d", line), headStyleLower)
 		}
-		if v.T_t > v.T_Tupper || v.T_rh > v.T_RHupper {
-			f.SetCellStyle("Sheet1", fmt.Sprintf("A%d", line), fmt.Sprintf("G%d", line), headStyleUpper)
+		if !(admin_r.Admin_rh == 0 && strings.Contains(v.T_sn, "YD")) {
+			if v.T_rh < v.T_RHlower || v.T_rh > v.T_RHupper {
+				f.SetCellStyle("Sheet1", fmt.Sprintf("A%d", line), fmt.Sprintf("G%d", line), headStyleUpper)
+			}
 		}
 
 		// -------
@@ -535,6 +539,7 @@ func (c *DataController) Device_Sensor_Data_Excel_m() {
 		if v.T_t < v.T_Tlower || v.T_rh < v.T_RHlower {
 			f.SetCellStyle("Sheet1", fmt.Sprintf("A%d", line), fmt.Sprintf("G%d", line), headStyleLower)
 		}
+
 		if v.T_t > v.T_Tupper || v.T_rh > v.T_RHupper {
 			f.SetCellStyle("Sheet1", fmt.Sprintf("A%d", line), fmt.Sprintf("G%d", line), headStyleUpper)
 		}

+ 44 - 1
controllers/Device.go

@@ -1552,10 +1552,16 @@ func (c *DeviceController) DeviceClass_html() {
 }
 
 func (c *DeviceController) DeviceClass_() {
+	// 验证登录
+	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
+	if !b_ {
+		c.Ctx.Redirect(302, "Login")
+		return
+	}
 	id, _ := c.GetInt("id")
 	c.Data["T"], _ = Device.Read_Class_ById(id)
 	c.Data["id"] = id
-
+	c.Data["Admin_r"] = admin_r
 	c.TplName = "Device/DeviceClass-.html"
 }
 
@@ -2006,6 +2012,43 @@ func (c *DeviceController) Get_DeviceClassId_QRCode() {
 	c.ServeJSON()
 	return
 }
+func (c *DeviceController) Get_DeviceClassId_QRCode2() {
+	// 验证登录
+	b_, _ := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
+	if !b_ {
+		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
+		c.ServeJSON()
+		return
+	}
+
+	T_calss_id := c.GetString("T_class_id")
+	if len(T_calss_id) == 0 {
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_calss_id Err!"}
+		c.ServeJSON()
+		return
+	}
+
+	T_calss_id_str, _ := NatsServer.Wx_GenerateQRCode2("-|" + lib.AesEncryptCBC(T_calss_id, "0123456789012345") + "|- @宝智达 微信公众号通知")
+	if len(T_calss_id_str) == 0 {
+		c.Data["json"] = lib.JSONS{Code: 201, Msg: "Err!"}
+		c.ServeJSON()
+		return
+	}
+
+	type Text struct {
+		QR   string
+		Code string
+	}
+
+	T_calss_id_str = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + T_calss_id_str
+	Text_r := Text{
+		QR:   T_calss_id_str,
+		Code: "请将本内容发送到 宝智达冷链科技有限公司 微信公众号-|" + lib.AesEncryptCBC(T_calss_id, "0123456789012345") + "|- @宝智达 微信公众号通知    ",
+	}
+	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Text_r}
+	c.ServeJSON()
+	return
+}
 
 func (c *DeviceController) DeviceData_Add() {
 	// 验证登录

+ 1 - 1
lastupdate.tmp

@@ -1 +1 @@
-{"C:\\BZD\\Cold\\Cold_Api\\controllers":1659515790364846300}
+{"C:\\BZD\\Cold\\Cold_Api\\controllers":1660010519349563900}

+ 14 - 0
logs/logx/logx.log

@@ -37,3 +37,17 @@
 2022/08/01 11:50:58.851 [I]  2022-08-01 11:50:58>%!(EXTRA []interface {}=[nats OK!])
 2022/08/05 15:14:29.743 [I]  2022-08-05 15:14:29>%!(EXTRA []interface {}=[============Nats init============])
 2022/08/05 15:14:29.874 [I]  2022-08-05 15:14:29>%!(EXTRA []interface {}=[nats OK!])
+2022/08/09 11:07:31.425 [I]  2022-08-09 11:07:31>%!(EXTRA []interface {}=[============Nats init============])
+2022/08/09 11:07:31.554 [I]  2022-08-09 11:07:31>%!(EXTRA []interface {}=[nats OK!])
+2022/08/09 11:09:20.722 [I]  2022-08-09 11:09:20>%!(EXTRA []interface {}=[============Nats init============])
+2022/08/09 11:09:20.877 [I]  2022-08-09 11:09:20>%!(EXTRA []interface {}=[nats OK!])
+2022/08/09 11:10:06.181 [I]  2022-08-09 11:10:06>%!(EXTRA []interface {}=[============Nats init============])
+2022/08/09 11:10:28.862 [I]  2022-08-09 11:10:28>%!(EXTRA []interface {}=[============Nats init============])
+2022/08/09 11:10:29.000 [I]  2022-08-09 11:10:29>%!(EXTRA []interface {}=[nats OK!])
+2022/08/09 11:11:11.338 [I]  2022-08-09 11:11:11>%!(EXTRA []interface {}=[============Nats init============])
+2022/08/09 11:11:11.467 [I]  2022-08-09 11:11:11>%!(EXTRA []interface {}=[nats OK!])
+2022/08/09 11:22:12.824 [I]  2022-08-09 11:22:12>%!(EXTRA []interface {}=[============Nats init============])
+2022/08/09 11:22:12.952 [I]  2022-08-09 11:22:12>%!(EXTRA []interface {}=[nats OK!])
+2022/08/09 11:46:46.028 [I]  2022-08-09 11:46:46>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Pu_DeviceParameter {4642 YD861656606475148 保温箱 0 300 120 120 120 60 120 60 10 0 0 0 贵州宝智达网络科技有限公司 MPT-II 6384 10993 1 [1,0,0,0,0,0,0,0,0,0] 5ca76637-000b-000a-000b-0c9b90f9586a 0 0 2 2022-08-09 11:46:45.8599105 +0800 CST 2022-08-09 11:46:45.8599105 +0800 CST}])
+2022/08/09 11:47:48.673 [I]  2022-08-09 11:47:48>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Pu_DeviceParameter {4643 YD861656606475148 保温箱 0 300 120 120 120 60 120 60 10 0 0 0 贵州宝智达网络科技有限公司 MPT-II 6384 10993 1 [1,0,0,0,0,0,0,0,0,0] 5ca76637-000b-000a-000b-0c9b90f9586a 0 0 2 2022-08-09 11:47:48.5034992 +0800 CST 2022-08-09 11:47:48.5034992 +0800 CST}])
+2022/08/09 11:48:11.123 [I]  2022-08-09 11:48:11>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Pu_DeviceParameter {4644 YD861656606475148 保温箱 0 300 120 120 120 60 120 60 10 0 0 0 贵州宝智达网络科技有限公司 MPT-II 6384 10993 28 [1,2,3,4,5,6,7,0,0,0] 5ca76637-000b-000a-000b-0c9b90f9586a 0 0 2 2022-08-09 11:48:10.956093 +0800 CST 2022-08-09 11:48:10.956093 +0800 CST}])

+ 3 - 2
routers/Device.go

@@ -48,8 +48,9 @@ func init() {
 	beego.Router("/Device/DeviceClassBind_Del", &controllers.DeviceController{}, "*:DeviceClassBind_Del")    // 获取未读消息
 	beego.Router("/Device/DeviceClassBind_Add", &controllers.DeviceController{}, "*:DeviceClassBind_Add")    // 获取未读消息
 
-	beego.Router("/Device/Get_DeviceClassId_QRCode", &controllers.DeviceController{}, "*:Get_DeviceClassId_QRCode") // 获取未读消息
-	beego.Router("/Device/Get_DeviceClassId", &controllers.DeviceController{}, "*:Get_DeviceClassId")               // 获取未读消息
+	beego.Router("/Device/Get_DeviceClassId_QRCode", &controllers.DeviceController{}, "*:Get_DeviceClassId_QRCode")   // 获取未读消息
+	beego.Router("/Device/Get_DeviceClassId_QRCode2", &controllers.DeviceController{}, "*:Get_DeviceClassId_QRCode2") // 获取未读消息
+	beego.Router("/Device/Get_DeviceClassId", &controllers.DeviceController{}, "*:Get_DeviceClassId")                 // 获取未读消息
 
 	beego.Router("/Device/Device_List", &controllers.DeviceController{}, "*:Device_List")                                 // 获取未读消息
 	beego.Router("/Device/Device_Parameter", &controllers.DeviceController{}, "*:Device_Parameter_html")                  // 获取未读消息

+ 1 - 1
server.pid

@@ -1 +1 @@
-15104
+31688

+ 1 - 2
tests/default_test.go

@@ -2,13 +2,12 @@ package test
 
 import (
 	"fmt"
-	"strings"
 	"testing"
 )
 
 // TestBeego is a sample to run an endpoint test
 func TestBeego(t *testing.T) {
 
-	fmt.Println(strings.Split("HG324234234", "_")) //打印结果:2017-04-11 13:24:04
+	fmt.Println(len("你")) //打印结果:2017-04-11 13:24:04
 
 }

+ 9 - 5
views/Data/DataList.html

@@ -556,12 +556,17 @@
         for (let i = 0; i < DS_lite.length; i++) {
 
             style_s = ""
-            if(DS_lite[i].T_t <  DS_lite[i].T_Tlower || DS_lite[i].T_rh < DS_lite[i].T_RHlower){
-                style_s = " style='background-color: #a8f7ff' "
-            }
-            if(DS_lite[i].T_t >  DS_lite[i].T_Tupper || DS_lite[i].T_rh > DS_lite[i].T_RHupper){
+            if(DS_lite[i].T_t <  DS_lite[i].T_Tlower || DS_lite[i].T_t >  DS_lite[i].T_Tupper){
                 style_s = " style='background-color: #ff8585' "
             }
+            if(Admin_rh == 0 && DS_lite[i].T_sn.indexOf("YD") != -1){
+
+            }else {
+                if(DS_lite[i].T_rh < DS_lite[i].T_RHlower || DS_lite[i].T_rh > DS_lite[i].T_RHupper){
+                    style_s = " style='background-color: #ff8585' "
+                }
+            }
+
 
             hidden = ""
             if(Admin_rh == 0 && DS_lite[i].T_sn.indexOf("YD") != -1){
@@ -578,7 +583,6 @@
                 "    <td>"+DS_lite[i].T_time+"</td>\n" +
                 "</tr>")
         }
-
     }
     function Add_DeviceSensor_data_Pages(Pages) {
         for (let i = 0; i < Pages.length; i++) {

+ 2 - 2
views/Data/DataRealCalss.html

@@ -423,6 +423,7 @@
     run_WebSocket()
     function run_WebSocket() {
         console.log("run_WebSocket");
+        T_sn_list = []
         if ('WebSocket' in window) {
             url = window.location.host
             console.log("url:",url)
@@ -521,8 +522,7 @@
         //获取当前URL
         var local_url = document.location.href;
         //获取要取得的get参数位置
-        var get = local_url.indexOf(par + "=")
-        ;
+        var get = local_url.indexOf(par + "=");
         if (get == -1) {
             return false;
         }

+ 0 - 1
views/Device/Device.html

@@ -72,7 +72,6 @@
                                             <span style="color: #ff7d7d">设备无网络</span>
                                             {{end}}
                                         {{end}}
-                                        {{$elem.T_online_4g }}
                                         {{if eq 1 $elem.T_online_4g }}
                                             <span style="color: #00FF00">[4G] </span>
                                         {{end}}

+ 106 - 1
views/Device/DeviceClass-.html

@@ -56,6 +56,9 @@
                             <ul class="layui-tab-title">
                                 <li class="layui-this">通知规则</li>
                                 <li class="">微信通知</li>
+                                {{if eq 0 $.Admin_r.Admin_master}}
+                                <li class="">微信通知(冷链)</li>
+                                {{end}}
                                 <li class="">短信通知</li>
                                 <li class="">电话通知</li>
                                 <li class="">邮箱通知</li>
@@ -104,6 +107,46 @@
                                     </div>
 
                                 </div>
+                                {{if eq 0 $.Admin_r.Admin_master}}
+                                <div class="layui-tab-item " >
+                                    <div class="layui-row" style="margin: 0px 10px">
+                                        <div class="layui-col-xs6" >
+                                            <div class="layui-row no_select" style="margin: 10px 0px;font-size: 15px;color: #1E9FFF">
+                                                方式一:二维码
+                                            </div>
+                                            <div class="layui-row no_select" style="margin: 0px 10px">
+                                                <div style="float: left;margin-bottom: 8px">
+                                                    让被通知者 通过微信扫描二维码,二维码有效期7天。
+                                                </div>
+                                                <img id="myimg2" style="width: 150px;height: 150px;float: left" src="https://osscold.baozhida.cn/images/二维码.png">
+
+                                            </div>
+<!--                                            <div class="layui-row no_select" style="margin: 10px 0px;font-size: 15px;color: #1E9FFF;margin-top: 18px">-->
+<!--                                                方式二:回复内容-->
+<!--                                            </div>-->
+<!--                                            <div id="Code" class="layui-row" style="height: 50px;margin: 0px 10px;border:1px solid  #cbcbcb;box-shadow: 0px 0px 8px #316fe7;padding: 6px;border-radius:5px;">-->
+
+<!--                                            </div>-->
+                                        </div>
+                                        <div id="Notice_wx2_list" class="layui-col-xs6" style="padding-left: 6px;padding-right: 6px;height: 350px;border-left:1px solid  #cbcbcb;overflow-y:auto;">
+<!--                                            <div class="layui-col" style="height: 32px;background-color: #fafafa;border-radius:5px;margin-bottom: 4px;">-->
+<!--                                                <img style="float: left;width: 30px;margin: 0px 10px;margin-top: 2px;" src="https://osscold.baozhida.cn/images/微信.png" height="30"-->
+<!--                                                     width="30"/>-->
+<!--                                                <div style="float: left;overflow:hidden;text-overflow:ellipsis;white-space:nowrap">-->
+<!--                                                    <div style="margin-top: 8px;font-size: 15px">SN:KF20210510143443</div>-->
+<!--                                                </div>-->
+<!--                                                <div class="layui-card-header" style="float: right; padding: 0px;height: 0px;">-->
+
+<!--                                                    <span style="float: right;margin-top: 0px;color: rgba(255,73,91,0.95);height: 20px;margin-right: 6px;margin-top: -4px;"-->
+<!--                                                          onclick=""><i class="iconfont" style="margin-right: 2px">&#xe69d;</i>删除</span>-->
+<!--                                                </div>-->
+<!--                                            </div>-->
+
+                                        </div>
+                                    </div>
+
+                                </div>
+                                {{end}}
                                 <div class="layui-tab-item">
                                     <div class="layui-row" style="margin: 0px 10px">
                                         <div class="layui-col-xs6" >
@@ -289,6 +332,7 @@
             }
             var T_name = "{{.T.T_name}}"
             var T_Notice_wx = "{{.T.T_Notice_wx}}"
+            var T_Notice_wx2 = "{{.T.T_Notice_wx2}}"
             var T_Notice_phone = "{{.T.T_Notice_phone}}"
             var T_Notice_message = "{{.T.T_Notice_message}}"
             var T_Notice_mailbox = "{{.T.T_Notice_mailbox}}"
@@ -306,10 +350,10 @@
                     Show_Notice_mailbox_list();
                     Get_DeviceClassId_QRCode();
                     setTimeout("Automaticupdate_Notice_wx()", 1000)
+                    setTimeout("Automaticupdate_Notice_wx2()", 1000)
 
                     setInterval(function(){
                         if(forNotice_wx){
-
                             Automaticupdate_Notice_wx();
                         }
                     },2000);
@@ -320,6 +364,7 @@
             function Automaticupdate_Notice_wx() {
                 Get_DeviceClassId();
             }
+
             function Del_Notice_wx_plusXing(str, wid) {
 
                 a_x = str.indexOf(wid+"/")
@@ -336,6 +381,16 @@
                 Show_Notice_wx_list()
                 DeviceClass_Post(false)
             }
+            function Del_Notice_wx2(x) {
+                srt_r = Del_Notice_wx_plusXing(T_Notice_wx2,x)
+                if(T_Notice_wx2.indexOf(srt_r) == -1){
+                    layer.msg('删除失败');
+                    return
+                }
+                T_Notice_wx2 = T_Notice_wx2.replace(srt_r + "|", "")
+                Show_Notice_wx_list2()
+                DeviceClass_Post(false)
+            }
             function Show_Notice_wx_list() {
                 var scores = T_Notice_wx.split("|");
                 $('#Notice_wx_list').html("");
@@ -363,6 +418,32 @@
 
                 }
             }
+            function Show_Notice_wx_list2() {
+                var scores = T_Notice_wx2.split("|");
+                $('#Notice_wx2_list').html("");
+                for (let i = 0; i < scores.length; i++) {
+                    if(scores[i].length == 0){
+                        return
+                    }
+                    scores_l = scores[i].split("/")
+
+                    $('#Notice_wx2_list').append("" +
+                        "<div class=\"layui-col\" style=\"height: 32px;background-color: #fafafa;border-radius:5px;margin-bottom: 4px;\">\n" +
+                        "    <img style=\"float: left;width: 30px;margin: 0px 10px;margin-top: 2px;\" src=\"https://osscold.baozhida.cn/images/微信.png\" height=\"30\"\n" +
+                        "         width=\"30\"/>\n" +
+                        "    <div style=\"float: left;width: 170px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap\">\n" +
+                        "        <div style=\"margin-top: 8px;font-size: 15px\" ondblclick=\"ShowElement(this,'"+scores_l[0]+"')\" >"+scores_l[1]+"</div>\n" +
+                        "    </div>\n" +
+                        "    <div class=\"layui-card-header\" style=\"float: right; padding: 0px;height: 0px;\">\n" +
+                        "        <span style=\"float: right;margin-top: 0px;color: rgba(255,73,91,0.95);height: 20px;margin-right: 6px;margin-top: -4px;\"\n" +
+                        "              onclick=\"Del_Notice_wx2('"+scores_l[0]+"')\"><i class=\"iconfont\" style=\"margin-right: 2px\">&#xe69d;</i>删除</span>\n" +
+                        "    </div>\n" +
+                        "</div>")
+                }
+                if(scores.length == 0){
+                    $('#Notice_wx2_list').append("<div style=\"color: #1E9FFF;text-align: center;font-size: 15px;margin-top: 150px\" > 没有数据 < /div>" )
+                }
+            }
             // 手机
             function Add_Notice_phone() {
                 x = $("#E_phone").val()
@@ -518,6 +599,26 @@
 
                     }
                 });
+                $.ajax({
+                    type: 'POST',
+                    url: 'Get_DeviceClassId_QRCode2',//发送请求
+                    data: {
+                        User_tokey: $.cookie("User_tokey"),
+                        T_class_id: parseInt(getPar("id")),
+                    },
+                    success: function(result) {
+                        console.log(result)
+                        if (result.Code == 200 ){
+                            $("#myimg2").attr('src',result.Data.QR);
+                            // $('#Code').html(result.Data.Code);
+                        }else {
+                            layer.msg('二维码生成失败!', {
+                                time: 2000
+                            });
+                        }
+
+                    }
+                });
             }
             function Get_DeviceClassId(){
                 $.ajax({
@@ -531,6 +632,8 @@
                         if (result.Code == 200 ){
                             T_Notice_wx = result.Data.T_Notice_wx
                             Show_Notice_wx_list()
+                            T_Notice_wx2 = result.Data.T_Notice_wx2
+                            Show_Notice_wx_list2()
                         }else {
                             layer.msg('获取数据失败!', {
                                 time: 2000
@@ -540,6 +643,7 @@
                     }
                 });
             }
+
             function DeviceClass_Post(is){
                 var loading = layer.load(0, {
                     shade: false,
@@ -552,6 +656,7 @@
                         Id:"{{.id}}",
                         T_name:$("#T_name").val(),
                         T_Notice_wx:T_Notice_wx,
+                        T_Notice_wx2:T_Notice_wx2,
                         T_Notice_phone:T_Notice_phone,
                         T_Notice_message:T_Notice_message,
                         T_Notice_mailbox:T_Notice_mailbox,

+ 74 - 11
views/Device/Device_Parameter-.html

@@ -31,7 +31,7 @@
 
                 {{if gt $.DeviceParameter_lite_z 0 }}
                     <div style="{{if gt $.DeviceParameter_lite_SendState_z 0 }} background-color: #dedede; {{end}}">
-                    <form  class="layui-form" action="" lay-filter="example">
+                    <form  class="layui-form" action="" lay-filter="example1">
 
                         <div class="layui-form-item">
                             <div class="layui-inline">
@@ -170,16 +170,29 @@
                         </div>
 
                         <div class="layui-form-item">
-                            <div class="layui-inline">
-                                <label class="layui-form-label" style="width: 140px;">配置管理主机总终端数量</label>
-                                <div class="layui-input-inline" style="width: 120px;">
-                                    <input type="text" id="decTotal"  name="decTotal"  value="{{.DeviceParameter.T_decTotal}}"  autocomplete="off" class="layui-input">
-                                </div>
-                            </div>
+<!--                            <div class="layui-inline">-->
+<!--                                <label class="layui-form-label" style="width: 140px;">配置管理主机总终端数量</label>-->
+<!--                                <div class="layui-input-inline" style="width: 120px;">-->
+<!--                                    <input type="text" id="decTotal"  name="decTotal"  value="{{.DeviceParameter.T_decTotal}}"  autocomplete="off" class="layui-input">-->
+<!--                                </div>-->
+<!--                            </div>-->
                             <div class="layui-inline">
                                 <label class="layui-form-label" style="width: 100px;">配置每个通道数量</label>
+<!--                                <div class="layui-input-inline" style="width: 380px;">-->
+<!--                                    <input type="text" id="chDecTotal"  name="chDecTotal"  value="{{.DeviceParameter.T_chDecTotal}}"  autocomplete="off" class="layui-input">-->
+<!--                                </div>-->
+
                                 <div class="layui-input-inline" style="width: 380px;">
-                                    <input type="text" id="chDecTotal"  name="chDecTotal"  value="{{.DeviceParameter.T_chDecTotal}}"  autocomplete="off" class="layui-input">
+                                    <input type="text" id="chDecTotal0"  name="chDecTotal0" lay-verify="required|number" autocomplete="off" class="layui-input" style="width: 35px;float: left">
+                                    <input type="text" id="chDecTotal1"  name="chDecTotal1" lay-verify="required|number" autocomplete="off" class="layui-input" style="width: 35px;float: left">
+                                    <input type="text" id="chDecTotal2"  name="chDecTotal2" lay-verify="required|number" autocomplete="off" class="layui-input" style="width: 35px;float: left">
+                                    <input type="text" id="chDecTotal3"  name="chDecTotal3" lay-verify="required|number" autocomplete="off" class="layui-input" style="width: 35px;float: left">
+                                    <input type="text" id="chDecTotal4"  name="chDecTotal4" lay-verify="required|number" autocomplete="off" class="layui-input" style="width: 35px;float: left">
+                                    <input type="text" id="chDecTotal5"  name="chDecTotal5" lay-verify="required|number" autocomplete="off" class="layui-input" style="width: 35px;float: left">
+                                    <input type="text" id="chDecTotal6"  name="chDecTotal6" lay-verify="required|number" autocomplete="off" class="layui-input" style="width: 35px;float: left">
+                                    <input type="text" id="chDecTotal7"  name="chDecTotal7" lay-verify="required|number" autocomplete="off" class="layui-input" style="width: 35px;float: left">
+                                    <input type="text" id="chDecTotal8"  name="chDecTotal8" lay-verify="required|number" autocomplete="off" class="layui-input" style="width: 35px;float: left">
+                                    <input type="text" id="chDecTotal9"  name="chDecTotal9" lay-verify="required|number" autocomplete="off" class="layui-input" style="width: 35px;float: left">
                                 </div>
 
                             </div>
@@ -439,10 +452,33 @@
                         return false
                     }
                 });
+            }
+            function get_chDecTotal(x) {
+                texttext = "{{.DeviceParameter.T_chDecTotal}}"
+
+                texttext = texttext.replace('[', '');
+                texttext = texttext.replace(']', '');
+                // console.log(texttext)
 
+                texttextlistlist = texttext.split(",")
 
+                if (texttextlistlist[x] == undefined){
+                    return "0"
+                }
+                if (!(parseInt(texttextlistlist[x]) >= 0)){
+                    return "0"
+                }
+                if (texttextlistlist[x].length == 0){
+                    return "0"
+                }
 
+                return texttextlistlist[x]
             }
+
+
+
+
+            
             layui.use(['form', 'layer',"layedit"],
 
                 function() {
@@ -456,7 +492,18 @@
                             url: '/UpFile' //接口url
                         }
                     });
-
+                    form.val('example1', {
+                        "chDecTotal0": get_chDecTotal(0),
+                        "chDecTotal1": get_chDecTotal(1),
+                        "chDecTotal2": get_chDecTotal(2),
+                        "chDecTotal3": get_chDecTotal(3),
+                        "chDecTotal4": get_chDecTotal(4),
+                        "chDecTotal5": get_chDecTotal(5),
+                        "chDecTotal6": get_chDecTotal(6),
+                        "chDecTotal7": get_chDecTotal(7),
+                        "chDecTotal8": get_chDecTotal(8),
+                        "chDecTotal9": get_chDecTotal(9),
+                    });
                     //构建一个默认的编辑器
                     var index = layedit.build('T_text', {
                         height: 580 //设置编辑器高度,
@@ -527,6 +574,22 @@
                                 return false;
                             }
 
+                            if(data.field.chDecTotal0 < 0 || data.field.chDecTotal0 > 40
+                                || data.field.chDecTotal1 < 0 || data.field.chDecTotal1 > 40
+                                || data.field.chDecTotal2 < 0 || data.field.chDecTotal2 > 40
+                                || data.field.chDecTotal3 < 0 || data.field.chDecTotal3 > 40
+                                || data.field.chDecTotal4 < 0 || data.field.chDecTotal4 > 40
+                                || data.field.chDecTotal5 < 0 || data.field.chDecTotal5 > 40
+                                || data.field.chDecTotal6 < 0 || data.field.chDecTotal6 > 40
+                                || data.field.chDecTotal7 < 0 || data.field.chDecTotal7 > 40
+                                || data.field.chDecTotal8 < 0 || data.field.chDecTotal8 > 40
+                                || data.field.chDecTotal9 < 0 || data.field.chDecTotal9 > 40){
+                                layer.msg('配置每个通道数量 0~40');
+                                return false;
+                            }
+                            decTotal = parseInt(data.field.chDecTotal0)+parseInt(data.field.chDecTotal1)+parseInt(data.field.chDecTotal2)+parseInt(data.field.chDecTotal3)+parseInt(data.field.chDecTotal4)+parseInt(data.field.chDecTotal5)+parseInt(data.field.chDecTotal6)+parseInt(data.field.chDecTotal7)+parseInt(data.field.chDecTotal8)+parseInt(data.field.chDecTotal9)
+                            chDecTotal = "["+parseInt(data.field.chDecTotal0)+","+parseInt(data.field.chDecTotal1)+","+parseInt(data.field.chDecTotal2)+","+parseInt(data.field.chDecTotal3)+","+parseInt(data.field.chDecTotal4)+","+parseInt(data.field.chDecTotal5)+","+parseInt(data.field.chDecTotal6)+","+parseInt(data.field.chDecTotal7)+","+parseInt(data.field.chDecTotal8)+","+parseInt(data.field.chDecTotal9)+"]"
+
                             loading = layer.load(0, {
                                 shade: false,
                                 time: 99*1000
@@ -554,8 +617,8 @@
                                     T_btname:data.field.btname,
                                     T_btserverID:data.field.btserverID,
                                     T_btchar:data.field.btchar,
-                                    T_decTotal:data.field.decTotal,
-                                    T_chDecTotal:data.field.chDecTotal,
+                                    T_decTotal:decTotal,
+                                    T_chDecTotal:chDecTotal,
 
                                 },
                                 success: function(result) {

+ 2 - 2
views/index.html

@@ -2,7 +2,7 @@
 <html class="x-admin-sm">
     <head>
         <meta charset="UTF-8">
-        <title>宝智达 冷链系统 v2.0</title>
+        <title>宝智达 冷链系统 v2.1</title>
         <meta name="renderer" content="webkit|ie-comp|ie-stand">
         <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
         <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
@@ -35,7 +35,7 @@
         <!-- 顶部开始 -->
         <div class="container">
             <div class="logo">
-                <a href="/Index">宝智达 v2.0</a></div>
+                <a href="/Index">宝智达 v2.1</a></div>
             <div class="left_open">
                 <a><i title="展开左侧栏" class="iconfont">&#xe699;</i></a>
             </div>

+ 1 - 1
views/login.html

@@ -24,7 +24,7 @@
 <body class="login-bg">
 
 <div class="login layui-anim" style="margin-top: 15%;">
-    <div class="message">宝智达 v2.0-管理登录</div>
+    <div class="message">宝智达 v2.1-管理登录</div>
     <div id="darkbannerwrap"></div>
 
     <form method="post" class="layui-form" >