| 
					
				 | 
			
			
				@@ -2,6 +2,8 @@ package services 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	"sparrow/pkg/models" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	"sparrow/pkg/rpcs" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	"sparrow/pkg/server" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	"sparrow/services/knowoapi/model" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -18,7 +20,7 @@ type DeviceService interface { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	//获取近N日活跃设备数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	GetLivelyOfNumDays(uint, int) ([]map[string]interface{}, error) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	//获取已经激活的设备列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	GetDevices(vendorid uint, proid, pi, ps int, deviceid string) ([]models.Device, int, error) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	GetDevices(vendorid uint, proid, pi, ps int, deviceid string) ([]*models.Devices, int, error) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 type deviceservice struct { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -31,8 +33,35 @@ func NewDeviceService(models *model.All) DeviceService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		models: models, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-func (a deviceservice) GetDevices(vendorid uint, proid, pi, ps int, deviceid string) ([]models.Device, int, error) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	return a.models.Device.GetDevices(vendorid, proid, pi, ps, deviceid) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+func (a deviceservice) GetDevices(vendorid uint, proid, pi, ps int, deviceid string) ([]*models.Devices, int, error) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	datas, total, err := a.models.Device.GetDevices(vendorid, proid, pi, ps, deviceid) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	devicedatas := make([]*models.Devices, 0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	for _, device := range datas { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		onlineargs := rpcs.ArgsGetDeviceOnlineStatus{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			Id: uint64(device.ID), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		onlinereply := rpcs.ReplyGetDeviceOnlineStatus{} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		err = server.RPCCallByName(nil, "devicemanager", "DeviceManager.GetDeviceOnlineStatus", onlineargs, &onlinereply) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			server.Log.Errorf("get devie online status error: %v", err) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		devices := new(models.Devices) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		devices.Device = device 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if int(onlinereply.HeartbeatInterval) > 0 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			devices.Status = 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		devicedatas = append(devicedatas, devices) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	return devicedatas, total, err 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 func (a deviceservice) GetDeviceCount(vendorid uint) (int, error) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	return a.models.Device.GetDeviceCount(vendorid) 
			 |