Browse Source

Update:对接电信传感器接口获取公司及其子公司所有传感器列表

zoie 9 months ago
parent
commit
7f7f15222e
2 changed files with 5 additions and 3 deletions
  1. 3 1
      controllers/Data.go
  2. 2 2
      models/Device/DeviceSensor.go

+ 3 - 1
controllers/Data.go

@@ -2135,6 +2135,8 @@ func (c *DataController) Docking_Real_Data() {
 		c.ServeJSON()
 		return
 	}
+	// 查询公司下面所有子公司id
+	T_pids := Account.ReadCompanyIds_T_path(Company_r.T_path)
 
 	type R_JSONS struct {
 		//必须的大写开头
@@ -2142,7 +2144,7 @@ func (c *DataController) Docking_Real_Data() {
 	}
 	var r_jsons R_JSONS
 
-	r_jsons.Data = Device.Read_Docking_Real_Data(Company_r.Id)
+	r_jsons.Data = Device.Read_Docking_Real_Data(T_pids)
 
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
 	c.ServeJSON()

+ 2 - 2
models/Device/DeviceSensor.go

@@ -1668,7 +1668,7 @@ func Read_DeviceSensor_All() (DeviceSensor_r []DeviceSensor) {
 }
 
 // 获取对接电信的实时数据
-func Read_Docking_Real_Data(T_pid int) (DeviceData_r []DeviceData_Docking) {
+func Read_Docking_Real_Data(T_pids []int) (DeviceData_r []DeviceData_Docking) {
 	o := orm.NewOrm()
 	// 也可以直接使用 Model 结构体作为表名
 
@@ -1676,7 +1676,7 @@ func Read_Docking_Real_Data(T_pid int) (DeviceData_r []DeviceData_Docking) {
 
 	var r []DeviceSensor
 	cond := orm.NewCondition()
-	cond1 := cond.And("T_pid", T_pid)
+	cond1 := cond.And("T_pid__in", T_pids)
 
 	_, err := qs.SetCond((*orm2.Condition)(cond1)).All(&r)
 	if err != nil {