Browse Source

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

huangyan 2 months ago
parent
commit
1f221bafaf
4 changed files with 96 additions and 75 deletions
  1. 5 5
      controllers/Device.go
  2. 80 66
      models/Account/Company.go
  3. 2 2
      models/Announcement/bulletin.go
  4. 9 2
      models/Device/DeviceData.go

+ 5 - 5
controllers/Device.go

@@ -283,11 +283,11 @@ func (c *DeviceController) Device_Applet_Get() {
 		c.ServeJSON()
 		return
 	}
-	if Device_r.T_pid != c.T_pid {
-		c.Data["json"] = lib.JSONS{Code: 202, Msg: "无权查看!"}
-		c.ServeJSON()
-		return
-	}
+	//if Device_r.T_pid != c.T_pid {
+	//	c.Data["json"] = lib.JSONS{Code: 202, Msg: "无权查看!"}
+	//	c.ServeJSON()
+	//	return
+	//}
 
 	Dsp, _ := Device.Read_DeviceSensorParameter(T_sn, T_id)
 	DeviceData := Device.Read_DeviceData(T_sn, T_id)

+ 80 - 66
models/Account/Company.go

@@ -299,18 +299,20 @@ func Read_Company_Tree(admin_r Admin, T_name string) (CompanyList []Company_R) {
 				continue
 			}
 			r := Company_R{
-				Id:         maps[i].Id,
-				T_mid:      maps[i].T_mid,
-				T_name:     maps[i].T_name,
-				T_plan:     maps[i].T_plan,
-				T_data:     maps[i].T_data,
-				T_v3d:      maps[i].T_v3d,
-				T_money:    maps[i].T_money,
-				T_warning:  maps[i].T_warning,
-				T_Charging: maps[i].T_Charging,
-				T_key:      maps[i].T_key,
-				T_type:     maps[i].T_type,
-				Children:   nil,
+				Id:           maps[i].Id,
+				T_mid:        maps[i].T_mid,
+				T_name:       maps[i].T_name,
+				T_plan:       maps[i].T_plan,
+				T_data:       maps[i].T_data,
+				T_v3d:        maps[i].T_v3d,
+				T_money:      maps[i].T_money,
+				T_warning:    maps[i].T_warning,
+				T_Charging:   maps[i].T_Charging,
+				T_key:        maps[i].T_key,
+				T_type:       maps[i].T_type,
+				T_Address:    maps[i].T_Address,
+				T_coordinate: maps[i].T_coordinate,
+				Children:     nil,
 			}
 			info := CompanyCall(maps, r)
 			CompanyList = append(CompanyList, info)
@@ -318,18 +320,20 @@ func Read_Company_Tree(admin_r Admin, T_name string) (CompanyList []Company_R) {
 	} else {
 		for i := 0; i < len(maps); i++ {
 			r := Company_R{
-				Id:         maps[i].Id,
-				T_mid:      maps[i].T_mid,
-				T_name:     maps[i].T_name,
-				T_plan:     maps[i].T_plan,
-				T_data:     maps[i].T_data,
-				T_v3d:      maps[i].T_v3d,
-				T_money:    maps[i].T_money,
-				T_warning:  maps[i].T_warning,
-				T_Charging: maps[i].T_Charging,
-				T_key:      maps[i].T_key,
-				T_type:     maps[i].T_type,
-				Children:   nil,
+				Id:           maps[i].Id,
+				T_mid:        maps[i].T_mid,
+				T_name:       maps[i].T_name,
+				T_plan:       maps[i].T_plan,
+				T_data:       maps[i].T_data,
+				T_v3d:        maps[i].T_v3d,
+				T_money:      maps[i].T_money,
+				T_warning:    maps[i].T_warning,
+				T_Charging:   maps[i].T_Charging,
+				T_key:        maps[i].T_key,
+				T_type:       maps[i].T_type,
+				T_Address:    maps[i].T_Address,
+				T_coordinate: maps[i].T_coordinate,
+				Children:     nil,
 			}
 			info := CompanyCall(maps, r)
 			CompanyList = append(CompanyList, info)
@@ -448,16 +452,18 @@ func Read_Company_List(T_name string) (CompanyList []Company_R) {
 				continue
 			}
 			r := Company_R{
-				Id:        maps[i].Id,
-				T_mid:     maps[i].T_mid,
-				T_name:    maps[i].T_name,
-				T_plan:    maps[i].T_plan,
-				T_data:    maps[i].T_data,
-				T_v3d:     maps[i].T_v3d,
-				T_money:   maps[i].T_money,
-				T_warning: maps[i].T_warning,
-				T_type:    maps[i].T_type,
-				Children:  nil,
+				Id:           maps[i].Id,
+				T_mid:        maps[i].T_mid,
+				T_name:       maps[i].T_name,
+				T_plan:       maps[i].T_plan,
+				T_data:       maps[i].T_data,
+				T_v3d:        maps[i].T_v3d,
+				T_money:      maps[i].T_money,
+				T_warning:    maps[i].T_warning,
+				T_type:       maps[i].T_type,
+				T_Address:    maps[i].T_Address,
+				T_coordinate: maps[i].T_coordinate,
+				Children:     nil,
 			}
 			info := CompanyCall(maps, r)
 			CompanyList = append(CompanyList, info)
@@ -465,16 +471,18 @@ func Read_Company_List(T_name string) (CompanyList []Company_R) {
 	} else {
 		for i := 0; i < len(maps); i++ {
 			r := Company_R{
-				Id:        maps[i].Id,
-				T_mid:     maps[i].T_mid,
-				T_name:    maps[i].T_name,
-				T_plan:    maps[i].T_plan,
-				T_data:    maps[i].T_data,
-				T_v3d:     maps[i].T_v3d,
-				T_money:   maps[i].T_money,
-				T_warning: maps[i].T_warning,
-				T_type:    maps[i].T_type,
-				Children:  nil,
+				Id:           maps[i].Id,
+				T_mid:        maps[i].T_mid,
+				T_name:       maps[i].T_name,
+				T_plan:       maps[i].T_plan,
+				T_data:       maps[i].T_data,
+				T_v3d:        maps[i].T_v3d,
+				T_money:      maps[i].T_money,
+				T_warning:    maps[i].T_warning,
+				T_type:       maps[i].T_type,
+				T_Address:    maps[i].T_Address,
+				T_coordinate: maps[i].T_coordinate,
+				Children:     nil,
 			}
 			info := CompanyCall(maps, r)
 			CompanyList = append(CompanyList, info)
@@ -513,17 +521,19 @@ func Read_Transport_Company_List(T_name string) (CompanyList []Company_R) {
 				continue
 			}
 			r := Company_R{
-				Id:         maps[i].Id,
-				T_mid:      maps[i].T_mid,
-				T_name:     maps[i].T_name,
-				T_plan:     maps[i].T_plan,
-				T_data:     maps[i].T_data,
-				T_v3d:      maps[i].T_v3d,
-				T_money:    maps[i].T_money,
-				T_warning:  maps[i].T_warning,
-				T_Charging: maps[i].T_Charging,
-				T_key:      maps[i].T_key,
-				Children:   nil,
+				Id:           maps[i].Id,
+				T_mid:        maps[i].T_mid,
+				T_name:       maps[i].T_name,
+				T_plan:       maps[i].T_plan,
+				T_data:       maps[i].T_data,
+				T_v3d:        maps[i].T_v3d,
+				T_money:      maps[i].T_money,
+				T_warning:    maps[i].T_warning,
+				T_Charging:   maps[i].T_Charging,
+				T_key:        maps[i].T_key,
+				T_Address:    maps[i].T_Address,
+				T_coordinate: maps[i].T_coordinate,
+				Children:     nil,
 			}
 			info := CompanyCall(maps, r)
 			CompanyList = append(CompanyList, info)
@@ -531,17 +541,19 @@ func Read_Transport_Company_List(T_name string) (CompanyList []Company_R) {
 	} else {
 		for i := 0; i < len(maps); i++ {
 			r := Company_R{
-				Id:         maps[i].Id,
-				T_mid:      maps[i].T_mid,
-				T_name:     maps[i].T_name,
-				T_plan:     maps[i].T_plan,
-				T_data:     maps[i].T_data,
-				T_v3d:      maps[i].T_v3d,
-				T_money:    maps[i].T_money,
-				T_warning:  maps[i].T_warning,
-				T_Charging: maps[i].T_Charging,
-				T_key:      maps[i].T_key,
-				Children:   nil,
+				Id:           maps[i].Id,
+				T_mid:        maps[i].T_mid,
+				T_name:       maps[i].T_name,
+				T_plan:       maps[i].T_plan,
+				T_data:       maps[i].T_data,
+				T_v3d:        maps[i].T_v3d,
+				T_money:      maps[i].T_money,
+				T_warning:    maps[i].T_warning,
+				T_Charging:   maps[i].T_Charging,
+				T_key:        maps[i].T_key,
+				T_Address:    maps[i].T_Address,
+				T_coordinate: maps[i].T_coordinate,
+				Children:     nil,
 			}
 			info := CompanyCall(maps, r)
 			CompanyList = append(CompanyList, info)
@@ -570,6 +582,8 @@ func CompanyCall(CompanyList []Company, company Company_R) Company_R {
 		mi.T_Charging = list[j].T_Charging
 		mi.T_key = list[j].T_key
 		mi.T_type = list[j].T_type
+		mi.T_Address = list[j].T_Address
+		mi.T_coordinate = list[j].T_coordinate
 		mi.Children = []Company_R{}
 		ms := CompanyCall(CompanyList, mi)
 		min = append(min, ms)

+ 2 - 2
models/Announcement/bulletin.go

@@ -197,9 +197,9 @@ func Read_Bulletin_List(t_uuid string, page int, page_z int, is_show string) (Bu
 	//}
 	var err error
 	if page_z == 9999 {
-		_, err = qs.SetCond((*orm2.Condition)(cond1)).OrderBy("-update_time").All(&maps)
+		_, err = qs.SetCond((*orm2.Condition)(cond1)).OrderBy("-create_time").All(&maps)
 	} else {
-		_, err = qs.Limit(page_z, offset).SetCond((*orm2.Condition)(cond1)).OrderBy("-update_time").All(&maps)
+		_, err = qs.Limit(page_z, offset).SetCond((*orm2.Condition)(cond1)).OrderBy("-create_time").All(&maps)
 	}
 	if err != nil {
 		logs.Error(lib.FuncName(), err)

+ 9 - 2
models/Device/DeviceData.go

@@ -541,6 +541,13 @@ func Read_DeviceData_By_T_snid_List(T_snid string, Time_start_ string, Time_end_
 			maps_num = maps_num + int64(r_maps_num)
 
 			logs.Debug("加载数据:", sn_id[0], sn_id[1], r_maps_num)
+		} else {
+			Read_DeviceSensorParameter_All_Map(sn_id[0], lib.To_int(sn_id[1]))
+			r_maps, r_maps_num := Read_DeviceData_ById_List(sn_id[0], lib.To_int(sn_id[1]), Time_start_, Time_end_, 0, 9999)
+			maps = append(maps, r_maps...)
+			maps_num = maps_num + int64(r_maps_num)
+
+			logs.Debug("加载数据:", sn_id[0], sn_id[1], r_maps_num)
 		}
 	}
 
@@ -685,7 +692,7 @@ func Read_DeviceData_BackUp_List(T_snid string, Time_start_ string, Time_end_ st
 	for _, v := range T_snid_list {
 		sn_id := strings.Split(v, ",")
 
-		if len(sn_id) == 2 {
+		if len(sn_id) >= 2 {
 
 			r_maps, r_maps_num := Read_DeviceData_BackUp(sn_id[0], lib.To_int(sn_id[1]), Time_start_, Time_end_)
 
@@ -822,7 +829,7 @@ func appendUniqueDeviceData(list []DeviceData_, newData []DeviceData_) []DeviceD
 	}
 	for _, d := range newData {
 		if !uniqueMap[d.T_time] {
-			if len(d.T_site) > 0 {
+			if len(d.T_site) > 0 && d.T_site != "0,0" {
 				split := strings.Split(d.T_site, ",")
 				defer func() {
 					if r := recover(); r != nil {