Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
DoubleLoong committed Oct 24, 2023
1 parent 27629a2 commit 9aee8de
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions services/device_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -1673,19 +1673,19 @@ func (*DeviceService) GetTenantDeviceCount(tenantId string, deviceType string) m
result := psql.Mydb.Model(&models.Device{}).Where("tenant_id = ? and parent_id=''", tenantId).Count(&count)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return map[string]int64{"count": 0}
return map[string]int64{"all": 0}
}
}
return map[string]int64{"count": count}
return map[string]int64{"all": count}
case deviceType == "1": //在线设备总数
sql := `select count(distinct entity_id) from ts_kv_latest where tenant_id = ? and key='SYS_ONLINE' and str_v='1' `
result := psql.Mydb.Raw(sql, tenantId).Count(&count)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return map[string]int64{"count": 0}
return map[string]int64{"online": 0}
}
}
return map[string]int64{"count": count}
return map[string]int64{"online": count}
default: //默认全部
result := psql.Mydb.Model(&models.Device{}).Where("tenant_id = ? and parent_id=''", tenantId).Count(&count)
if result.Error != nil {
Expand Down
10 changes: 5 additions & 5 deletions services/tp_warning_information_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,18 @@ func (*TpWarningInformationService) GetTenantWarningInformationCount(tenantId st
result := psql.Mydb.Model(&models.TpWarningInformation{}).Where("tenant_id = ? and processing_result=?", tenantId, processingresult).Count(&count)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return map[string]int64{"count": 0}
return map[string]int64{"unprocessed": 0}
}
}
return map[string]int64{"count": count}
return map[string]int64{"unprocessed": count}
case processingresult == "1": //已处理消息数
result := psql.Mydb.Model(&models.TpWarningInformation{}).Where("tenant_id = ? and processing_result=?", tenantId, processingresult).Count(&count)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return map[string]int64{"count": 0}
return map[string]int64{"processed": 0}
}
}
return map[string]int64{"count": count}
return map[string]int64{"processed": count}
default:
var dcount, ucount int64
result := psql.Mydb.Model(&models.TpWarningInformation{}).Where("tenant_id = ? and processing_result='1'", tenantId, processingresult).Count(&dcount)
Expand All @@ -148,6 +148,6 @@ func (*TpWarningInformationService) GetTenantWarningInformationCount(tenantId st
ucount = 0
}
}
return map[string]int64{"1": dcount, "0": ucount}
return map[string]int64{"processed": dcount, "unprocessed": ucount}
}
}

0 comments on commit 9aee8de

Please sign in to comment.