|
@@ -55,21 +55,24 @@ type Device struct {
|
|
|
}
|
|
|
|
|
|
type Device_R struct {
|
|
|
- T_sn string // 设备序列号 KF开头,环境监测主机。 YD开头,温途监测主机
|
|
|
- T_devName string // 设备名称
|
|
|
- T_protocol int // 1 1.0协议 2 2.0协议
|
|
|
- T_VerifyTime string // 验证时间
|
|
|
- T_CalibrationTime string // 校准时间
|
|
|
- T_PatrolTime string // 巡检时间
|
|
|
- T_abandonTime string // 弃用时间
|
|
|
- T_ist int // 温度 1开启 2关闭
|
|
|
- T_ish int // 湿度 1开启 2关闭
|
|
|
- T_Dattery int // 电量
|
|
|
- T_Site string // GPS
|
|
|
- T_monitor int // 监控状态 0 未监控 1 监控 停止记录
|
|
|
- T_online int // 在线状态 0 未启用 1 在线 2 离线
|
|
|
- T_online_s int // 在线状态-备用 0 未启用 1 在线 2 离线
|
|
|
- T_State int // 0 屏蔽 1 正常
|
|
|
+ T_sn string // 设备序列号 KF开头,环境监测主机。 YD开头,温途监测主机
|
|
|
+ T_devName string // 设备名称
|
|
|
+ T_protocol int // 1 1.0协议 2 2.0协议
|
|
|
+ T_VerifyTime string // 验证时间
|
|
|
+ T_CalibrationTime string // 校准时间
|
|
|
+ T_PatrolTime string // 巡检时间
|
|
|
+ T_abandonTime string // 弃用时间
|
|
|
+ T_VerifyEndTime string // 验证到期时间
|
|
|
+ T_CalibrationEndTime string // 校准到期时间
|
|
|
+
|
|
|
+ T_ist int // 温度 1开启 2关闭
|
|
|
+ T_ish int // 湿度 1开启 2关闭
|
|
|
+ T_Dattery int // 电量
|
|
|
+ T_Site string // GPS
|
|
|
+ T_monitor int // 监控状态 0 未监控 1 监控 停止记录
|
|
|
+ T_online int // 在线状态 0 未启用 1 在线 2 离线
|
|
|
+ T_online_s int // 在线状态-备用 0 未启用 1 在线 2 离线
|
|
|
+ T_State int // 0 屏蔽 1 正常
|
|
|
// 硬件信息
|
|
|
T_model string // KF200BG 产品型号
|
|
|
T_ProductTypeName string // 验证工具LoRa 产品统称 + 类型
|
|
@@ -121,10 +124,10 @@ func DeviceToDevice_R(r Device) (t Device_R) {
|
|
|
t.T_VerifyTime = r.T_VerifyTime.Format("2006-01-02 15:04:05")
|
|
|
}
|
|
|
if !r.T_VerifyEndTime.IsZero() {
|
|
|
- t.T_VerifyTime = r.T_VerifyTime.Format("2006-01-02 15:04:05")
|
|
|
+ t.T_VerifyEndTime = r.T_VerifyEndTime.Format("2006-01-02 15:04:05")
|
|
|
}
|
|
|
if !r.T_CalibrationEndTime.IsZero() {
|
|
|
- t.T_VerifyTime = r.T_VerifyTime.Format("2006-01-02 15:04:05")
|
|
|
+ t.T_CalibrationEndTime = r.T_CalibrationEndTime.Format("2006-01-02 15:04:05")
|
|
|
}
|
|
|
if !r.T_CalibrationTime.IsZero() {
|
|
|
t.T_CalibrationTime = r.T_CalibrationTime.Format("2006-01-02 15:04:05")
|
|
@@ -174,6 +177,7 @@ func Redis_Device_Set(r Device) (err error) {
|
|
|
if err != nil {
|
|
|
logs.Error("set key:", r.T_sn, ",value:", str, err)
|
|
|
}
|
|
|
+ fmt.Println(string(str))
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -220,7 +224,10 @@ func Read_Device_ByT_sn(T_sn string) (r Device, err error) {
|
|
|
logs.Error(lib.FuncName(), err)
|
|
|
return r, err
|
|
|
}
|
|
|
- Redis_Device_Set(r) // Redis 更新缓存
|
|
|
+ err = Redis_Device_Set(r)
|
|
|
+ if err != nil {
|
|
|
+ return Device{}, err
|
|
|
+ } // Redis 更新缓存
|
|
|
return r, nil
|
|
|
}
|
|
|
|
|
@@ -257,7 +264,10 @@ func Update_Device(r Device, cols ...string) bool {
|
|
|
return false
|
|
|
}
|
|
|
logs.Info("Number of records updated in database:", num)
|
|
|
- Redis_Device_Set(r) // Redis 更新缓存
|
|
|
+ err = Redis_Device_Set(r)
|
|
|
+ if err != nil {
|
|
|
+ return false
|
|
|
+ } // Redis 更新缓存
|
|
|
return true
|
|
|
}
|
|
|
|