|
@@ -14,6 +14,7 @@ import (
|
|
|
"math"
|
|
|
"net/http"
|
|
|
"os"
|
|
|
+ "regexp"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
"time"
|
|
@@ -208,7 +209,7 @@ func (c *DataController) Company_Device_Sensor_List_ByKey() {
|
|
|
|
|
|
}
|
|
|
|
|
|
-// 传感器数据列表
|
|
|
+// Device_Sensor_Data 传感器数据列表
|
|
|
func (c *DataController) Device_Sensor_Data() {
|
|
|
page, _ := c.GetInt("page")
|
|
|
page_z, _ := c.GetInt("page_z")
|
|
@@ -229,7 +230,24 @@ func (c *DataController) Device_Sensor_Data() {
|
|
|
var cnt int
|
|
|
Device.Read_DeviceSensorParameter_All_Map(SN, T_id)
|
|
|
r_jsons.DeviceSensor_data, cnt = Device.Read_DeviceData_ById_List(SN, T_id, Time_start, Time_end, page, page_z)
|
|
|
+ var latLngPattern = regexp.MustCompile(`^-?\d{1,3}\.\d+,-?\d{1,3}\.\d+$`)
|
|
|
|
|
|
+ // 第一次遍历:将所有非法坐标标记为 nil 或 ""
|
|
|
+ for i := range r_jsons.DeviceSensor_data {
|
|
|
+ if !latLngPattern.MatchString(r_jsons.DeviceSensor_data[i].T_site) {
|
|
|
+ r_jsons.DeviceSensor_data[i].T_site = ""
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 第二次遍历:向前查找最近的有效坐标补全空值
|
|
|
+ lastValidSite := ""
|
|
|
+ for i := range r_jsons.DeviceSensor_data {
|
|
|
+ if r_jsons.DeviceSensor_data[i].T_site != "" {
|
|
|
+ lastValidSite = r_jsons.DeviceSensor_data[i].T_site
|
|
|
+ } else if lastValidSite != "" {
|
|
|
+ r_jsons.DeviceSensor_data[i].T_site = lastValidSite
|
|
|
+ }
|
|
|
+ }
|
|
|
page_size := math.Ceil(float64(cnt) / float64(page_z))
|
|
|
r_jsons.Page = page
|
|
|
r_jsons.Page_size = int(page_size)
|
|
@@ -241,7 +259,7 @@ func (c *DataController) Device_Sensor_Data() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-// 实时轨迹
|
|
|
+// Device_Sensor_Data_Real 实时轨迹
|
|
|
func (c *DataController) Device_Sensor_Data_Real() {
|
|
|
page, _ := c.GetInt("page")
|
|
|
page_z, _ := c.GetInt("page_z")
|