Browse Source

add:添加或者设备接口

zoie 2 weeks ago
parent
commit
7a2cc972cc
7 changed files with 46 additions and 92 deletions
  1. 6 0
      .idea/ColdVerify_server.iml
  2. 6 6
      conf/app.conf
  3. 1 47
      conf/app_test.conf
  4. 23 0
      controllers/Device.go
  5. 0 34
      controllers/TaskData.go
  6. 5 1
      models/Device/Device.go
  7. 5 4
      routers/Device.go

+ 6 - 0
.idea/ColdVerify_server.iml

@@ -1,9 +1,15 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <module type="WEB_MODULE" version="4">
+  <component name="FacetManager">
+    <facet type="Python" name="Python facet">
+      <configuration sdkName="Python 3.11" />
+    </facet>
+  </component>
   <component name="Go" enabled="true" />
   <component name="NewModuleRootManager">
     <content url="file://$MODULE_DIR$" />
     <orderEntry type="inheritedJdk" />
     <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="library" name="Python 3.11 interpreter library" level="application" />
   </component>
 </module>

+ 6 - 6
conf/app.conf

@@ -6,20 +6,20 @@ EnableDocs = true
 copyrequestbody = true
 
 # Nats
-NatsServer_Url = "203.34.49.130:4222"
+NatsServer_Url = "182.44.114.34:4222"
 NatsForbidden = true
 
-MysqlServer_UrlPort = "203.34.49.130:3306"
+MysqlServer_UrlPort = "182.44.114.34:3306"
 MysqlServer_Database = "coldverify"
-MysqlServer_Username = "coldverify"
-MysqlServer_Password = "Bd3d34yJ7aibiEi"
+MysqlServer_Username = "root"
+MysqlServer_Password = "mysql_Ks7WAX"
 MysqlServer_MaxIdleConnections = 100
 MysqlServer_MaxOpenConnections = 200
 
 
 # Redis
-Redis_address = "203.34.49.130:6379"
-Redis_password = "redis_JJ56d5"
+Redis_address = "182.44.114.34:6379"
+Redis_password = "redis_F2tj7p"
 Redis_dbNum = "2"
 
 

+ 1 - 47
conf/app_test.conf

@@ -1,48 +1,3 @@
-package conf
-
-appname = ColdVerify_server6300
-HTTPPort = 6300
-runmode = dev
-Graceful = true
-EnableDocs = true
-copyrequestbody = true
-
-# Nats
-NatsServer_Url = "203.34.49.130:4222"
-NatsForbidden = true
-
-MysqlServer_UrlPort = "203.34.49.130:3306"
-MysqlServer_Database = "coldverify"
-MysqlServer_Username = "coldverify"
-MysqlServer_Password = "Bd3d34yJ7aibiEi"
-MysqlServer_MaxIdleConnections = 100
-MysqlServer_MaxOpenConnections = 200
-
-
-# Redis
-Redis_address = "203.34.49.130:6379"
-Redis_password = "redis_JJ56d5"
-Redis_dbNum = "2"
-
-
-
-# 静态资源
-Qiniu_AccessKey = "-8ezB_d-8-eUFTMvhOGbGzgeQRPeKQnaQ3DBcUxo"
-Qiniu_SecretKey = "KFhkYxTAJ2ZPN3ZS3euTsfWk8-C92rKgkhAMkDRN"
-Qiniu_BUCKET = "bzdcoldverify"
-Oss = "https://bzdcoldverifyoss.baozhida.cn"
-
-
-# 发送微信通知
-WechatNews_GroupName = "宝智达-软件组"
-WechatNews_Url = "http://111.85.177.202:12088/send"
-
-# 老板 uuid
-BoosUuid = "fa5be10f-5be1-42be-a8dc-8d142e006266"
-# 冷链验证 报告负责人
-VdelUuid = "1c13436c-4511-4030-8b26-baadad88445a"
-
-
 appname = ColdVerify_server6300
 HTTPPort = 6300
 runmode = dev
@@ -86,5 +41,4 @@ BoosUuid = "fa5be10f-5be1-42be-a8dc-8d142e006266"
 VdelUuid = "1c13436c-4511-4030-8b26-baadad88445a"
 
 OpenApi_Key = "coldverify"
-OpenApi_Secret = "H3L9OPQR2VX8ZZYN7STKFG5JMWB1CV4D"
-
+OpenApi_Secret = "H3L9OPQR2VX8ZZYN7STKFG5JMWB1CV4D"

+ 23 - 0
controllers/Device.go

@@ -89,6 +89,29 @@ func (c *DeviceController) Add() {
 }
 
 // 修改-
+func (c *DeviceController) Get() {
+	// 验证登录 User_is, User_r
+	_, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
+	if !User_is {
+		c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
+		c.ServeJSON()
+		return
+	}
+
+	T_sn := c.GetString("T_sn")
+
+	r, is := Device.Read_Device(T_sn)
+	if !is {
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id 错误!"}
+		c.ServeJSON()
+		return
+	}
+
+	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Device.DeviceToDevice_R(r, "0")}
+	c.ServeJSON()
+	return
+}
+
 func (c *DeviceController) Up() {
 	// 验证登录 User_is, User_r
 	user_r, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))

+ 0 - 34
controllers/TaskData.go

@@ -1465,37 +1465,3 @@ func splitData(data []Device.DeviceClassList, threshold float64, idWidthMap map[
 
 	return result
 }
-
-func AddWatermark(task Task.Task, pdf *gopdf.GoPdf) {
-	// 设置透明度 (通过绘制透明背景实现)
-	// 使用浅色字体来模拟透明度
-	//originalX := pdf.GetX()
-	//originalY := pdf.GetY()
-	//grayColor := color.RGBA{R: 200, G: 200, B: 200, A: 255} // 浅灰色,接近透明效果
-	//pdf.SetTextColor(grayColor.R, grayColor.G, grayColor.B) // 设置字体颜色
-	//pdf.SetFontSize(50)
-	//
-	//// 设置水印的重复布局
-	//text := "水印"
-	//xOffset := 180.0 // X 坐标的偏移量
-	//yOffset := 180.0 // Y 坐标的偏移量
-	//angle := 45.0    // 旋转角度(度)
-	//
-	//// 循环绘制水印
-	//for y := 0.0; y < 780; y += yOffset { // 842 是 A4 页面高度的像素数 (72 DPI)
-	//	for x := -100.0; x < 595; x += xOffset { // 595 是 A4 页面宽度的像素数 (72 DPI)
-	//		// 保存当前的绘制状态
-	//		pdf.SetX(x)
-	//		pdf.SetY(y)
-	//		pdf.Rotate(angle, x+100, y+50) // 旋转水印
-	//		pdf.Cell(nil, text)
-	//		pdf.RotateReset() // 恢复旋转状态
-	//	}
-	//}
-	//
-	//grayColor2 := color.RGBA{R: 0, G: 0, B: 0, A: 0}           // 浅灰色,接近透明效果
-	//pdf.SetTextColor(grayColor2.R, grayColor2.G, grayColor2.B) // 设置字体颜色
-	//pdf.SetFontSize(10)
-	//pdf.SetX(originalX)
-	//pdf.SetY(originalY)
-}

+ 5 - 1
models/Device/Device.go

@@ -54,12 +54,13 @@ type Device_R struct {
 	T_note_time_interval int     // 记录时间间隔
 	T_note_file_num      int     // 记录文件数量
 	T_State              int     // 0 删除   1 正常
+	UpdateTime           string  // 采集时间
 }
 
 func DeviceToDevice_R(t Device, T_id string) (r Device_R) {
 	r.Id = t.Id
 	r.T_sn = t.T_sn
-	r.T_id = T_id
+	//r.T_id = T_id
 	r.T_t = t.T_t
 	r.T_rh = t.T_rh
 	if !t.T_time.IsZero() {
@@ -73,6 +74,9 @@ func DeviceToDevice_R(t Device, T_id string) (r Device_R) {
 	r.T_note_time_interval = t.T_note_time_interval
 	r.T_note_file_num = t.T_note_file_num
 	r.T_State = t.T_State
+	if !t.UpdateTime.IsZero() {
+		r.UpdateTime = t.UpdateTime.Format("2006-01-02 15:04:05")
+	}
 	return r
 }
 

+ 5 - 4
routers/Device.go

@@ -28,10 +28,11 @@ func init() {
 	beego.Router("/DeviceClassList/Auto_fill_Remark", &controllers.DeviceClassController{}, "*:Auto_fill_Remark")                     // 通过模版布点自动填写到设备备注
 
 	// - 设备管理
-	beego.Router("/Device/List", &controllers.DeviceController{}, "*:List") // 设别列表
-	beego.Router("/Device/Add", &controllers.DeviceController{}, "*:Add")   // 添加设别
-	beego.Router("/Device/Up", &controllers.DeviceController{}, "*:Up")     // 编辑设别
-	beego.Router("/Device/Del", &controllers.DeviceController{}, "*:Del")   // 删除设别
+	beego.Router("/Device/List", &controllers.DeviceController{}, "*:List") // 设备列表
+	beego.Router("/Device/Add", &controllers.DeviceController{}, "*:Add")   // 添加设备
+	beego.Router("/Device/Get", &controllers.DeviceController{}, "*:Get")   // 编辑设备
+	beego.Router("/Device/Up", &controllers.DeviceController{}, "*:Up")     // 编辑设备
+	beego.Router("/Device/Del", &controllers.DeviceController{}, "*:Del")   // 删除设备
 
 	beego.Router("/Device/Class", &controllers.DeviceController{}, "*:Device_Class") // 设备分类
 	beego.Router("/Device/Data", &controllers.DeviceController{}, "*:Device_Data")   // 设备数据