|
@@ -10,19 +10,19 @@ import (
|
|
|
// DeviceService device service接口
|
|
|
type DeviceService interface {
|
|
|
// 获取厂商已经激活的设备总数
|
|
|
- GetDeviceCount(vendorid uint) (int, error)
|
|
|
+ GetDeviceCount(vendorid string) (int, error)
|
|
|
//返回厂商某天激活的设备数
|
|
|
- GetActiveNumberOfDate(vendor uint, datetime string) (int, error)
|
|
|
+ GetActiveNumberOfDate(vendor string, datetime string) (int, error)
|
|
|
//获取厂商某天活跃的设备数
|
|
|
- GetLivelyCountOfDate(uint, string) (int, error)
|
|
|
+ GetLivelyCountOfDate(string, string) (int, error)
|
|
|
//获取近N日激活设备数据
|
|
|
- GetActiveOfNumDays(uint, int) ([]map[string]interface{}, error)
|
|
|
+ GetActiveOfNumDays(string, int) ([]map[string]interface{}, error)
|
|
|
//获取近N日活跃设备数据
|
|
|
- GetLivelyOfNumDays(uint, int) ([]map[string]interface{}, error)
|
|
|
+ GetLivelyOfNumDays(string, int) ([]map[string]interface{}, error)
|
|
|
//获取已经激活的设备列表
|
|
|
- GetDevices(vendorid uint, proid, pi, ps int, deviceid string) ([]*models.Devices, int, error)
|
|
|
+ GetDevices(vendorid string, proid, pi, ps int, deviceid string) ([]*models.Devices, int, error)
|
|
|
//获取用户下所有设备的数量,在线设备的数量,离线设备的数量
|
|
|
- GetDevicesCountByVenderId(vendorid uint) (map[string]interface{}, error)
|
|
|
+ GetDevicesCountByVenderId(vendorid string) (map[string]interface{}, error)
|
|
|
}
|
|
|
|
|
|
type deviceservice struct {
|
|
@@ -35,7 +35,7 @@ func NewDeviceService(models *model.All) DeviceService {
|
|
|
models: models,
|
|
|
}
|
|
|
}
|
|
|
-func (a deviceservice) GetDevices(vendorid uint, proid, pi, ps int, deviceid string) ([]*models.Devices, int, error) {
|
|
|
+func (a deviceservice) GetDevices(vendorid string, proid, pi, ps int, deviceid string) ([]*models.Devices, int, error) {
|
|
|
|
|
|
data, total, err := a.models.Device.GetDevices(vendorid, proid, pi, ps, deviceid)
|
|
|
|
|
@@ -48,7 +48,7 @@ func (a deviceservice) GetDevices(vendorid uint, proid, pi, ps int, deviceid str
|
|
|
for _, device := range data {
|
|
|
|
|
|
onlineargs := rpcs.ArgsGetDeviceOnlineStatus{
|
|
|
- Id: uint64(device.ID),
|
|
|
+ Id: device.RecordId,
|
|
|
}
|
|
|
|
|
|
onlinereply := rpcs.ReplyGetDeviceOnlineStatus{}
|
|
@@ -72,23 +72,22 @@ func (a deviceservice) GetDevices(vendorid uint, proid, pi, ps int, deviceid str
|
|
|
|
|
|
return dataMap, total, nil
|
|
|
}
|
|
|
-
|
|
|
-func (a deviceservice) GetDeviceCount(vendorid uint) (int, error) {
|
|
|
+func (a deviceservice) GetDeviceCount(vendorid string) (int, error) {
|
|
|
return a.models.Device.GetDeviceCount(vendorid)
|
|
|
}
|
|
|
-func (a deviceservice) GetActiveNumberOfDate(vendorid uint, datetime string) (int, error) {
|
|
|
+func (a deviceservice) GetActiveNumberOfDate(vendorid string, datetime string) (int, error) {
|
|
|
return a.models.Device.GetActiveNumberOfDate(vendorid, datetime)
|
|
|
}
|
|
|
-func (a deviceservice) GetLivelyCountOfDate(vendorid uint, datetime string) (int, error) {
|
|
|
+func (a deviceservice) GetLivelyCountOfDate(vendorid string, datetime string) (int, error) {
|
|
|
return a.models.Device.GetLivelyCountOfDate(vendorid, datetime)
|
|
|
}
|
|
|
-func (a deviceservice) GetActiveOfNumDays(vendorid uint, days int) ([]map[string]interface{}, error) {
|
|
|
+func (a deviceservice) GetActiveOfNumDays(vendorid string, days int) ([]map[string]interface{}, error) {
|
|
|
return a.models.Device.GetActiveOfNumDays(vendorid, days)
|
|
|
}
|
|
|
-func (a deviceservice) GetLivelyOfNumDays(vendorid uint, days int) ([]map[string]interface{}, error) {
|
|
|
+func (a deviceservice) GetLivelyOfNumDays(vendorid string, days int) ([]map[string]interface{}, error) {
|
|
|
return a.models.Device.GetLivelyOfNumDays(vendorid, days)
|
|
|
}
|
|
|
-func (a deviceservice) GetDevicesCountByVenderId(vendorid uint) (map[string]interface{}, error) {
|
|
|
+func (a deviceservice) GetDevicesCountByVenderId(vendorid string) (map[string]interface{}, error) {
|
|
|
data, err := a.models.Device.GetDevicesByVenderId(vendorid)
|
|
|
|
|
|
if err != nil {
|
|
@@ -100,7 +99,7 @@ func (a deviceservice) GetDevicesCountByVenderId(vendorid uint) (map[string]inte
|
|
|
var offlineCount int
|
|
|
for _, device := range data {
|
|
|
onlineargs := rpcs.ArgsGetDeviceOnlineStatus{
|
|
|
- Id: uint64(device.ID),
|
|
|
+ Id: device.RecordId,
|
|
|
}
|
|
|
onlinereply := rpcs.ReplyGetDeviceOnlineStatus{}
|
|
|
err = server.RPCCallByName(nil, "devicemanager", "DeviceManager.GetDeviceOnlineStatus", onlineargs, &onlinereply)
|