mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-29 09:21:26 +08:00
【feat】完成tcp,http的设备上报,及模拟设备测试
This commit is contained in:
@@ -136,7 +136,7 @@ func (p *DeviceApi) GetDeviceTelemetryHistory(rc *restfulx.ReqCtx) {
|
||||
limit := restfulx.QueryInt(rc, "limit", 1000)
|
||||
device := p.DeviceApp.FindOne(id)
|
||||
sql := `select ts,? from ? where ts > '?' and ts < '?' and ? is not null ORDER BY ts DESC LIMIT ? `
|
||||
rs, err := global.TdDb.GetAll(sql, key, fmt.Sprintf("%s_telemetry", device.Name), startTime, endTime, key, limit)
|
||||
rs, err := global.TdDb.GetAll(sql, key, fmt.Sprintf("%s_telemetry", strings.ToLower(device.Name)), startTime, endTime, key, limit)
|
||||
biz.ErrIsNilAppendErr(err, "查询设备属性的遥测历史失败")
|
||||
rc.ResData = rs
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import (
|
||||
|
||||
"pandax/apps/device/entity"
|
||||
"pandax/apps/device/services"
|
||||
ruleService "pandax/apps/rule/services"
|
||||
)
|
||||
|
||||
type ProductApi struct {
|
||||
@@ -23,6 +24,7 @@ type ProductApi struct {
|
||||
DeviceApp services.DeviceModel
|
||||
TemplateApp services.ProductTemplateModel
|
||||
OtaAPP services.ProductOtaModel
|
||||
RuleApp ruleService.RuleChainModel
|
||||
}
|
||||
|
||||
// GetProductList Product列表数据
|
||||
@@ -103,6 +105,12 @@ func (p *ProductApi) InsertProduct(rc *restfulx.ReqCtx) {
|
||||
data.Id = tool.GenerateID()
|
||||
data.Owner = rc.LoginAccount.UserName
|
||||
data.OrgId = rc.LoginAccount.OrganizationId
|
||||
// 如果未设置规则链,默认为主链
|
||||
if data.RuleChainId == "" {
|
||||
root := p.RuleApp.FindOneByRoot()
|
||||
data.RuleChainId = root.Id
|
||||
}
|
||||
|
||||
p.ProductApp.Insert(data)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user