Browse Source

update:修改字体

zoie 3 months ago
parent
commit
165a187e41
5 changed files with 59 additions and 17 deletions
  1. 42 13
      Nats/Nats.go
  2. 1 1
      conf/app.conf
  3. 15 1
      controllers/Data.go
  4. 1 1
      controllers/Warning.go
  5. 0 1
      models/Device/DeviceData.go

+ 42 - 13
Nats/Nats.go

@@ -47,7 +47,7 @@ func init() {
 func NatsInit() {
 
 	// 获取微信二维码 返回结果
-	_, _ = lib.Nats.QueueSubscribe("Wx_BasicMessage_Event_QRCode","Wx_BasicMessage_Event_QRCode", func(m *nats.Msg) {
+	_, _ = lib.Nats.QueueSubscribe("Wx_BasicMessage_Event_QRCode", "Wx_BasicMessage_Event_QRCode", func(m *nats.Msg) {
 		//fmt.Printf(" => Nats   Wx_BasicMessage_Event_QRCode message: %s\n", string(m.Data))
 
 		type Person_QRCode struct {
@@ -113,7 +113,7 @@ func NatsInit() {
 	})
 
 	// 请求-响应 验证登录
-	_, _ = lib.Nats.QueueSubscribe("Cold_User_verification","Cold_User_verification", func(m *nats.Msg) {
+	_, _ = lib.Nats.QueueSubscribe("Cold_User_verification", "Cold_User_verification", func(m *nats.Msg) {
 		fmt.Printf("Cold_User_verification message: %s\n", string(m.Data))
 
 		type T_R struct {
@@ -154,7 +154,7 @@ func NatsInit() {
 	})
 
 	// 请求-响应 通过公司名获取所有公司信息
-	_, _ = lib.Nats.QueueSubscribe("Cold_User_CompanyListAllByT_name","Cold_User_CompanyListAllByT_name", func(m *nats.Msg) {
+	_, _ = lib.Nats.QueueSubscribe("Cold_User_CompanyListAllByT_name", "Cold_User_CompanyListAllByT_name", func(m *nats.Msg) {
 		fmt.Printf("CompanyListAll message: %s\n", string(m.Data))
 
 		type T_R struct {
@@ -172,7 +172,7 @@ func NatsInit() {
 		_ = lib.Nats.Publish(m.Reply, b)
 	})
 	// 请求-响应 获取公司
-	_, _ = lib.Nats.QueueSubscribe("Cold_ReadCompanyByT_id","Cold_ReadCompanyByT_id", func(m *nats.Msg) {
+	_, _ = lib.Nats.QueueSubscribe("Cold_ReadCompanyByT_id", "Cold_ReadCompanyByT_id", func(m *nats.Msg) {
 		fmt.Printf("Cold_ReadCompanyByT_id message: %s\n", string(m.Data))
 
 		type T_R struct {
@@ -201,8 +201,37 @@ func NatsInit() {
 		_ = lib.Nats.Publish(m.Reply, b)
 	})
 
+	// 请求-响应 获取公司 通过秘钥
+	_, _ = lib.Nats.QueueSubscribe("Cold_ReadCompanyByT_key", "Cold_ReadCompanyByT_key", func(m *nats.Msg) {
+		fmt.Printf("Cold_ReadCompanyByT_key message: %s\n", string(m.Data))
+
+		type T_R struct {
+			Code int16           `xml:"Code"`
+			Msg  string          `xml:"Msg"`
+			Data Account.Company `xml:"Data"` // 泛型
+		}
+
+		var t_R T_R
+
+		company, err := Account.Read_Company_ByKey(string(m.Data))
+
+		if err != nil {
+			t_R.Code = 202
+			t_R.Msg = err.Error()
+			b, _ := msgpack.Marshal(&t_R)
+			_ = lib.Nats.Publish(m.Reply, b)
+		}
+
+		t_R.Code = 200
+		t_R.Msg = "ok"
+		t_R.Data = company
+
+		b, _ := msgpack.Marshal(&t_R)
+		_ = lib.Nats.Publish(m.Reply, b)
+	})
+
 	// 请求-响应 获取所有用户列表
-	_, _ = lib.Nats.QueueSubscribe("Cold_User_UserListAll","Cold_User_UserListAll", func(m *nats.Msg) {
+	_, _ = lib.Nats.QueueSubscribe("Cold_User_UserListAll", "Cold_User_UserListAll", func(m *nats.Msg) {
 
 		type T_R struct {
 			Code int16             `xml:"Code"`
@@ -219,7 +248,7 @@ func NatsInit() {
 		_ = lib.Nats.Publish(m.Reply, b)
 	})
 	// 请求-响应 检查用户权限
-	_, _ = lib.Nats.QueueSubscribe("Cold_User_CheckUserPermissions","Cold_User_CheckUserPermissions", func(m *nats.Msg) {
+	_, _ = lib.Nats.QueueSubscribe("Cold_User_CheckUserPermissions", "Cold_User_CheckUserPermissions", func(m *nats.Msg) {
 		fmt.Printf("Cold_User_CheckUserPermissions message: %s\n", string(m.Data))
 		type T_Req struct {
 			Power_Id int    `xml:"Power_Id"` // 权限id
@@ -321,7 +350,7 @@ func NatsInit() {
 	})
 
 	// 请求-响应 获取设备
-	_, _ = lib.Nats.QueueSubscribe("Cold_ReadDeviceByT_sn","Cold_ReadDeviceByT_sn", func(m *nats.Msg) {
+	_, _ = lib.Nats.QueueSubscribe("Cold_ReadDeviceByT_sn", "Cold_ReadDeviceByT_sn", func(m *nats.Msg) {
 		fmt.Printf("CheckUserPermissions message: %s\n", string(m.Data))
 
 		type T_R struct {
@@ -350,7 +379,7 @@ func NatsInit() {
 	})
 
 	// 请求-响应 获取传感器列表
-	_, _ = lib.Nats.QueueSubscribe("Cold_ReadDeviceSensorALLByT_sn","Cold_ReadDeviceSensorALLByT_sn",  func(m *nats.Msg) {
+	_, _ = lib.Nats.QueueSubscribe("Cold_ReadDeviceSensorALLByT_sn", "Cold_ReadDeviceSensorALLByT_sn", func(m *nats.Msg) {
 		fmt.Printf("CheckUserPermissions message: %s\n", string(m.Data))
 
 		type T_R struct {
@@ -372,7 +401,7 @@ func NatsInit() {
 	})
 
 	// 请求-响应 获取设备数据列表
-	_, _ = lib.Nats.QueueSubscribe("Cold_ReadDeviceDataListBy_T_snid","Cold_ReadDeviceDataListBy_T_snid", func(m *nats.Msg) {
+	_, _ = lib.Nats.QueueSubscribe("Cold_ReadDeviceDataListBy_T_snid", "Cold_ReadDeviceDataListBy_T_snid", func(m *nats.Msg) {
 		fmt.Printf("Cold_ReadDeviceDataListBy_T_snid message: %s\n", string(m.Data))
 		type T_Req struct {
 			T_snid     string `xml:"T_snid"`
@@ -411,7 +440,7 @@ func NatsInit() {
 	})
 
 	// 请求-响应 通过key获取传感器列表
-	_, _ = lib.Nats.QueueSubscribe("Cold_CompanyDeviceSensor_List_ByKey","Cold_CompanyDeviceSensor_List_ByKey",func(m *nats.Msg) {
+	_, _ = lib.Nats.QueueSubscribe("Cold_CompanyDeviceSensor_List_ByKey", "Cold_CompanyDeviceSensor_List_ByKey", func(m *nats.Msg) {
 		fmt.Printf("Cold_CompanyDeviceSensor_List_ByKey message: %s\n", string(m.Data))
 		type T_Req struct {
 			T_sn  string `xml:"T_sn"`
@@ -459,8 +488,8 @@ func NatsInit() {
 		_ = lib.Nats.Publish(m.Reply, b)
 	})
 
-	// 请求-响应 根据时间获取设备数据(单条)
-	_, _ = lib.Nats.QueueSubscribe("Cold_ReadDeviceDataBy_T_snid_T_time","Cold_ReadDeviceDataBy_T_snid_T_time", func(m *nats.Msg) {
+	// 请求-响应 根据时间获取设备数据(单条)最新数据
+	_, _ = lib.Nats.QueueSubscribe("Cold_ReadDeviceDataBy_T_snid_T_time", "Cold_ReadDeviceDataBy_T_snid_T_time", func(m *nats.Msg) {
 		fmt.Printf("Cold_ReadDeviceDataBy_T_snid_T_time message: %s\n", string(m.Data))
 		type T_Req struct {
 			T_sn string `xml:"T_sn"`
@@ -495,7 +524,7 @@ func NatsInit() {
 	})
 
 	// 请求-响应 获取设备
-	_, _ = lib.Nats.QueueSubscribe("Cold_ReadDevice_List","Cold_ReadDevice_List", func(m *nats.Msg) {
+	_, _ = lib.Nats.QueueSubscribe("Cold_ReadDevice_List", "Cold_ReadDevice_List", func(m *nats.Msg) {
 		fmt.Printf("Cold_ReadDevice_List message: %s\n", string(m.Data))
 		type T_Req struct {
 			Key    string `xml:"Key"`

+ 1 - 1
conf/app.conf

@@ -79,7 +79,7 @@ Weixin_Notify = "https://cold.coldbaozhida.com/api/WxPay/Notify"
 
 # 日志配置
 # 0-控制台输出 1-文件输出 2-文件和控制台输出
-adapter_type = 0
+adapter_type = 1
 # 文件最多保存多少天
 maxdays = 7
 # 日志级别 (0-紧急 1-报警 2-严重错误 3-错误 4-警告 5-注意 6-信息 7-调试)

+ 15 - 1
controllers/Data.go

@@ -806,7 +806,7 @@ func (c *DataController) Device_Sensor_Data_PDF() {
 	//	log.Fatalln(err)
 	//}
 
-	err = pdf.AddTTFFont("simsun", "static/fonts/三极行楷简体-粗.ttf")
+	err = pdf.AddTTFFont("simsun", "static/fonts/MiSans-Medium.ttf")
 	if err != nil {
 		c.Data["json"] = lib.JSONS{Code: 202, Msg: err.Error()}
 		c.ServeJSON()
@@ -893,6 +893,20 @@ func (c *DataController) Device_Sensor_Data_PDF() {
 		var textH float64 = 25 // if text height is 25px.
 		pdf.SetNewY(y, textH)
 		y = pdf.GetY()
+		// newY = 20
+		if y < 30 {
+			lib.RectFillColor(pdf, "序号", 12, 22, y, 30, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+			lib.RectFillColor(pdf, "传感器名称", 12, 52, y, 100, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+			lib.RectFillColor(pdf, "温度℃", 12, 152, y, 50, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+
+			lib.RectFillColor(pdf, "湿度%", 12, 202, y, 50, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+
+			lib.RectFillColor(pdf, "温度范围", 12, 252, y, 80, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+			lib.RectFillColor(pdf, "湿度范围", 12, 332, y, 80, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+			lib.RectFillColor(pdf, "记录时间", 12, 412, y, 120, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+			lib.RectFillColor(pdf, "备注", 12, 532, y, 40, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+			y += 20
+		}
 		//pdf.SetX(x) // must after pdf.SetNewY() called.
 		//err = pdf.Text(text)
 		//if err != nil {

+ 1 - 1
controllers/Warning.go

@@ -673,7 +673,7 @@ func (c *DeviceController) DeviceWarning_Del() {
 		}
 	} else {
 		warning = Warning.Read_Warning_ById(int64(id))
-		if warning.Id == 0 {
+		if warning.Id > 0 {
 			c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_id Err!"}
 			c.ServeJSON()
 			return

+ 0 - 1
models/Device/DeviceData.go

@@ -82,7 +82,6 @@ type DeviceData_Pdf struct {
 	T_time string   // sn
 	T_id1  *float32 // 传感器id1温度
 	T_id2  *float32 // 传感器id2温度
-
 }
 
 type DeviceData_BackUp struct {