Browse Source

添加公司新增坐标以及地址

huangyan 3 months ago
parent
commit
cd22b2fe8d
5 changed files with 71 additions and 42 deletions
  1. 1 0
      controllers/Data.go
  2. 21 11
      controllers/User.go
  3. 19 12
      models/Account/Company.go
  4. 29 19
      models/Device/Device.go
  5. 1 0
      models/Device/DeviceData.go

+ 1 - 0
controllers/Data.go

@@ -2641,6 +2641,7 @@ func (c *DataController) GetNewLocus() {
 						},
 						Sn:     sn,
 						T_name: device.T_devName,
+						Time:   list[i].T_time.Format("2006-01-02 15:04:05"),
 					})
 				}
 				response.Code = 200

+ 21 - 11
controllers/User.go

@@ -118,16 +118,20 @@ func (c *UserController) Company_Add() {
 	T_data := c.GetString("T_data")
 	T_v3d := c.GetString("T_v3d")
 	T_type, _ := c.GetInt("T_type")
+	T_Address := c.GetString("T_Address")
+	T_coordinate := c.GetString("T_coordinate")
 
 	var_ := Account.Company{
-		T_mid:     T_mid,
-		T_name:    T_name,
-		T_State:   1,
-		T_plan:    T_plan,
-		T_data:    T_data,
-		T_v3d:     T_v3d,
-		T_warning: 1,
-		T_type:    T_type,
+		T_mid:        T_mid,
+		T_name:       T_name,
+		T_State:      1,
+		T_plan:       T_plan,
+		T_data:       T_data,
+		T_v3d:        T_v3d,
+		T_warning:    1,
+		T_type:       T_type,
+		T_Address:    T_Address,
+		T_coordinate: T_coordinate,
 	}
 
 	id, err := Account.Add_Company(var_)
@@ -170,16 +174,22 @@ func (c *UserController) Company_Edit() {
 
 	T_name := c.GetString("T_name")
 	T_type, _ := c.GetInt("T_type")
-
+	T_Address := c.GetString("T_Address")
+	T_coordinate := c.GetString("T_coordinate")
 	if len(T_name) > 0 {
 		Company_r.T_name = T_name
 	}
 	if T_type > 0 {
 		Company_r.T_type = T_type
-
+	}
+	if len(T_Address) > 0 {
+		Company_r.T_Address = T_Address
+	}
+	if len(T_coordinate) > 0 {
+		Company_r.T_coordinate = T_coordinate
 	}
 
-	is := Account.Update_Company(Company_r, "T_name", "T_type")
+	is := Account.Update_Company(Company_r, "T_name", "T_type", "T_Address", "T_coordinate")
 	if !is {
 		c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改失败!"}
 		c.ServeJSON()

+ 19 - 12
models/Account/Company.go

@@ -27,6 +27,9 @@ type Company struct {
 	T_data string `orm:"type(text);null"` //  大数据
 	T_v3d  string `orm:"type(text);null"` //  3D 视图
 
+	T_Address    string `orm:"size(256);null"` // 地址
+	T_coordinate string `orm:"size(256);null"` // 坐标
+
 	T_path     string    `orm:"size(256);null"` // 公司路径 /0/1/5/
 	T_money    float32   `orm:"digits(12);decimals(2)"`
 	T_State    int       `orm:"size(200);default(1)"`                                  // 0删除  1正常
@@ -39,18 +42,20 @@ type Company struct {
 }
 
 type Company_R struct {
-	Id         int
-	T_mid      int     // 上一级 ID
-	T_name     string  // 公司名称
-	T_plan     string  // 平面图
-	T_data     string  // 大数据
-	T_v3d      string  // 3D 视图
-	T_money    float32 // 余额
-	T_warning  int     // 报警统计
-	T_key      string
-	T_type     int // 公司类型 1-医药公司 2-运输企业
-	T_Charging int
-	Children   []Company_R
+	Id           int
+	T_mid        int     // 上一级 ID
+	T_name       string  // 公司名称
+	T_plan       string  // 平面图
+	T_data       string  // 大数据
+	T_v3d        string  // 3D 视图
+	T_money      float32 // 余额
+	T_warning    int     // 报警统计
+	T_key        string
+	T_type       int // 公司类型 1-医药公司 2-运输企业
+	T_Charging   int
+	T_Address    string
+	T_coordinate string
+	Children     []Company_R
 }
 
 func CompanyToCompany_R(r Company) (v Company_R) {
@@ -65,6 +70,8 @@ func CompanyToCompany_R(r Company) (v Company_R) {
 	v.T_key = r.T_key
 	v.T_Charging = r.T_Charging
 	v.T_type = r.T_type
+	v.T_Address = r.T_Address
+	v.T_coordinate = r.T_coordinate
 	return v
 }
 

+ 29 - 19
models/Device/Device.go

@@ -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
 }
 

+ 1 - 0
models/Device/DeviceData.go

@@ -64,6 +64,7 @@ type DeviceData_R2 struct {
 	DeviceData_
 	Sn     string `json:"sn"`
 	T_name string `json:"t_name"` // 设备名称
+	Time   string `json:"t_time"`
 }
 
 // 模板