Skip to content

Commit

Permalink
发布V2版本代码,代码深度重构与优化,支持最新go版本。
Browse files Browse the repository at this point in the history
  • Loading branch information
microrain authored and microrain committed Feb 27, 2024
1 parent 0477fa5 commit dc697cc
Show file tree
Hide file tree
Showing 1,090 changed files with 30,613 additions and 26,889 deletions.
15 changes: 7 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
.idea/
.settings/
.vscode/
*.iml
vendor/
composer.lock
gitpush.sh
Expand All @@ -16,15 +17,13 @@ cbuild
main
output/
manifest/output/
manifest/config/config.yaml
temp/
resource/log/
#resource/public/
resource/public/*
logs/
upload/product_icon/
manifest/config/config.yaml
manifest/docker-compose/emqx/
manifest/docker-compose/mysql/data
manifest/docker-compose/redis/data
manifest/docker-compose/taos/
manifest/docker-compose/iot-open/resource/log
extend/log/
extend/log/
hack/config.yaml
go.sum
gf
829 changes: 160 additions & 669 deletions LICENSE

Large diffs are not rendered by default.

67 changes: 0 additions & 67 deletions Makefile

This file was deleted.

28 changes: 27 additions & 1 deletion README.zh-cn.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Sagoo IOT
SagooIOT Community V2
========

<div align="center">
Expand Down Expand Up @@ -53,6 +53,25 @@ SagooIOT是一个基于golang开发的轻量级的物联网平台。支持跨平
密码admin123456


**注意**

当前主分支为V2版本V1版本请切换到V1分支 https://github.com/sagoo-cloud/sagooiot/tree/sagooiot-v1


## V2版变化

1重构设备数据上报处理链路增加中间缓存队列提高数据上报处理效率
2重构缓存处理统一使用方式并对多处频繁调用的数据进行了缓存处理提高数据处理效率
3重构消息队列及定时任务的处理改为分布式的任务队列处理方式提高消息队列的处理效率及可靠性并提供可视化的消息队列监控界面
4重构部分代码的编写方式规范入参及接口处理方式提高代码可读性及可维护性产品与设备所涉及调用统一为key的方式
5插件的编写方式进行了调整独立出来方便插件的编写及维护并简化主工程的代码量
6增加模块化的开发方式进行模块功能与核心功能分离方便功能的扩展及维护并简化主工程的代码量
7调整目录结构公共处理统一到pkg目录中方便其它功能开发调用及代码的维护管理
8增加核心处理程序web服务程序任务队列处理程序分离单独运行的支持提高程序的稳定性及可靠性
9强化性能分析及监控功能方便对系统进行性能分析及监控并提供可视化的性能分析及监控界面



## 平台简介
* 基于全新Go Frame 2.0+Vue3+Element Plus开发的全栈前后端分离的管理系统
* 前端采用vue-next-adminVueElement UI
Expand Down Expand Up @@ -107,3 +126,10 @@ SagooIOT是一个基于golang开发的轻量级的物联网平台。支持跨平
## 免责声明

SagooIOT社区版是一个开源学习项目与商业行为无关用户在使用该项目时应遵循法律法规不得进行非法活动如果SagooIOT发现用户有违法行为将会配合相关机关进行调查并向政府部门举报用户因非法行为造成的任何法律责任均由用户自行承担如因用户使用造成第三方损害的用户应当依法予以赔偿使用SagooIOT所有相关资源均由用户自行承担风险.







2 changes: 1 addition & 1 deletion api/v1/alarm/alarm_level.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package alarm

import (
"github.com/sagoo-cloud/sagooiot/internal/model"
"sagooiot/internal/model"

"github.com/gogf/gf/v2/frame/g"
)
Expand Down
12 changes: 8 additions & 4 deletions api/v1/alarm/alarm_log.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package alarm

import (
"github.com/sagoo-cloud/sagooiot/internal/model"
"sagooiot/api/v1/common"
"sagooiot/internal/model"

"github.com/gogf/gf/v2/frame/g"
)
Expand All @@ -16,14 +17,17 @@ type AlarmLogDetailRes struct {

type AlarmLogListReq struct {
g.Meta `path:"/log/list" method:"get" summary:"告警日志" tags:"告警"`
*model.AlarmLogListInput
Status string `p:"status"` //告警状态
common.PaginationReq
}
type AlarmLogListRes struct {
*model.AlarmLogListOutput
}

type AlarmLogHandleReq struct {
g.Meta `path:"/log/handle" method:"post" summary:"告警处理" tags:"告警"`
model.AlarmLogHandleInput
g.Meta `path:"/log/handle" method:"post" summary:"告警处理" tags:"告警"`
Id uint64 `json:"id" dc:"告警日志ID" v:"required#告警日志ID不能为空"`
Status int `json:"status" d:"1" dc:"处理状态" v:"required|in:1,2#请选择处理状态|未知的处理状态,请正确选择"`
Content string `json:"content" dc:"处理意见"`
}
type AlarmLogHandleRes struct{}
18 changes: 16 additions & 2 deletions api/v1/alarm/alarm_rule.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package alarm

import (
"github.com/sagoo-cloud/sagooiot/internal/model"
"sagooiot/api/v1/common"
"sagooiot/internal/model"

"github.com/gogf/gf/v2/frame/g"
)

type AlarmRuleListReq struct {
g.Meta `path:"/rule/list" method:"get" summary:"告警规则列表" tags:"告警"`
*model.AlarmRuleListInput
common.PaginationReq
}
type AlarmRuleListRes struct {
*model.AlarmRuleListOutput
Expand Down Expand Up @@ -71,7 +72,20 @@ type AlarmRuleTriggerParamReq struct {
g.Meta `path:"/rule/trigger_param" method:"get" summary:"触发条件参数" tags:"告警"`
ProductKey string `json:"productKey" dc:"产品标识"`
TriggerType int `json:"triggerType" dc:"触发类型:1=上线,2=离线,3=属性上报,4=事件上报"`
EventKey string `json:"eventKey" dc:"事件标识"`
}
type AlarmRuleTriggerParamRes struct {
List []model.TriggerParamOutput `json:"list" dc:"触发条件参数列表"`
}

type AlarmCronRuleAddReq struct {
g.Meta `path:"/rule/cron/add" method:"post" summary:"新增定时触发告警规则" tags:"告警"`
*model.AlarmCronRuleAddInput
}
type AlarmCronRuleAddRes struct{}

type AlarmCronRuleEditReq struct {
g.Meta `path:"/rule/cron/edit" method:"put" summary:"编辑定时触发告警规则" tags:"告警"`
*model.AlarmCronRuleEditInput
}
type AlarmCronRuleEditRes struct{}
53 changes: 53 additions & 0 deletions api/v1/analysis/alarm.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package analysis

import (
"github.com/gogf/gf/v2/frame/g"
"sagooiot/internal/model"
)

// DeviceAlertCountByYearMonthReq 按年度每月设备告警数统计
type DeviceAlertCountByYearMonthReq struct {
g.Meta `path:"/deviceAlertCountByYearMonth" method:"get" summary:"按年度每月设备告警数统计" tags:"IOT数据分析"`
Year string `json:"year" v:"required#日期不能为空" dc:"日期:年-yyyy"`
}
type DeviceAlertCountByYearMonthRes struct {
Data []model.CountData `json:"data" dc:"月设备告警计数"`
}

// DeviceAlertCountByMonthDayReq 按月度每日设备告警数统计
type DeviceAlertCountByMonthDayReq struct {
g.Meta `path:"/deviceAlertCountByMonthDay" method:"get" summary:"按月度每日设备告警数统计" tags:"IOT数据分析"`
Month string `json:"month" v:"required#日期不能为空" dc:"日期:年-月 yyyy-MM"`
}
type DeviceAlertCountByMonthDayRes struct {
Data []model.CountData `json:"data" dc:"日设备告警计数"`
}

// DeviceAlertCountByDayHourReq 按日每小时设备告警数统计
type DeviceAlertCountByDayHourReq struct {
g.Meta `path:"/deviceAlertCountsByDayHour" method:"get" summary:"按日每小时设备告警数统计" tags:"IOT数据分析"`
Day string `json:"day" v:"required#日期不能为空" dc:"日期:年-月-日 yyyy-MM-dd"`
}
type DeviceAlertCountByDayHourRes struct {
Data []model.CountData `json:"data" dc:"小时设备告警计数"`
}

// DeviceAlarmTotalCountReq 指定时间的告警总数统计,按年,月,日分别指定
type DeviceAlarmTotalCountReq struct {
g.Meta `path:"/deviceAlarmTotalCount" method:"get" summary:"告警总数统计(当年、当月、当日)" tags:"IOT数据分析"`
DateType string `json:"dateType" v:"required#日期类型不能为空" dc:"日期类型:year 年,month 月,day 日"`
Date string `json:"date" v:"required#日期不能为空" dc:"日期:年 yyyy,月 yyyy-MM,日 yyyy-MM-dd"`
}
type DeviceAlarmTotalCountRes struct {
Number int64 `json:"number" dc:"告警总数"`
}

// DeviceAlarmLevelCountReq 告警级别统计
type DeviceAlarmLevelCountReq struct {
g.Meta `path:"/deviceAlarmLevelCount" method:"get" summary:"告警按级别统计" tags:"IOT数据分析"`
DateType string `json:"dateType" v:"required#日期类型不能为空" dc:"日期类型:year 年,month 月,day 日"`
Date string `json:"date" v:"required#日期不能为空" dc:"日期:年 yyyy,月 MM,日 dd"`
}
type DeviceAlarmLevelCountRes struct {
Data []model.CountData `json:"data" dc:"告警级别统计"`
}
33 changes: 33 additions & 0 deletions api/v1/analysis/device.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package analysis

import (
"github.com/gogf/gf/v2/frame/g"
"sagooiot/internal/model"
)

// DeviceDataTotalCountReq 设备消息总数统计(当年、当月、当日)
type DeviceDataTotalCountReq struct {
g.Meta `path:"/deviceDataTotalCount" method:"get" summary:"设备消息总数统计(当年、当月、当日)" tags:"IOT数据分析"`
DateType string `json:"dateType" v:"required#日期类型不能为空" dc:"日期类型:year 年,month 月,day 日"`
}
type DeviceDataTotalCountRes struct {
Number int64 `json:"number" dc:"消息总数"`
}

// DeviceOnlineOfflineCountReq 设备在线离线统计
type DeviceOnlineOfflineCountReq struct {
g.Meta `path:"/deviceOnlineOfflineCount" method:"get" summary:"设备在线离线统计" tags:"IOT数据分析"`
}
type DeviceOnlineOfflineCountRes struct {
Data model.DeviceOnlineOfflineCount
}

// DeviceDataCountReq 按年度每月设备消息统计
type DeviceDataCountReq struct {
g.Meta `path:"/deviceDataCount" method:"get" summary:"按年度统计1-12月份设备消息统计" tags:"IOT数据分析"`
DateType string `json:"dateType" v:"required#日期类型不能为空" dc:"日期类型:year 年,month 月,day 日"`
//Date string `json:"date" v:"" dc:"日期:年-yyyy"`
}
type DeviceDataCountRes struct {
Data []model.CountData `json:"data" dc:"1-12月份设备消息量统计数据"`
}
47 changes: 47 additions & 0 deletions api/v1/analysis/deviceData.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package analysis

import (
"github.com/gogf/gf/v2/frame/g"
"sagooiot/api/v1/common"
"sagooiot/internal/model"
)

// DeviceDataReq 按年度每月设备消息统计
type DeviceDataReq struct {
g.Meta `path:"/deviceData" method:"get" summary:"设备最近的数据" tags:"IOT数据分析"`
DeviceKey string `json:"deviceKey" v:"required#设备key不能为空" dc:"设备key"`
common.PaginationReq
}
type DeviceDataRes struct {
Data []interface{}
common.PaginationRes
}

// DeviceDataForProductByLatestReq 按产品查询设备最近的数据
type DeviceDataForProductByLatestReq struct {
g.Meta `path:"/deviceDataForProductByLatest" method:"get" summary:"按产品查询设备最近的数据" tags:"IOT数据分析"`
ProductKey string `json:"productKey" v:"required#产品key不能为空" dc:"产品key"`
}

type DeviceDataForProductByLatestRes struct {
Data []model.DeviceDataRes
}

type DeviceDataForTsdReq struct {
g.Meta `path:"/deviceDataForTsd" method:"get" summary:"设备的时序数据" tags:"IOT数据分析"`
common.PaginationReq
}
type DeviceDataForTsdRes struct {
Data []interface{}
common.PaginationRes
}

// DeviceAlarmLogDataReq 设备告警日志数据请求
type DeviceAlarmLogDataReq struct {
g.Meta `path:"/deviceAlarmLogData" method:"get" summary:"设备告警日志数据" tags:"IOT数据分析"`
common.PaginationReq
}
type DeviceAlarmLogDataRes struct {
Data interface{}
common.PaginationRes
}
25 changes: 25 additions & 0 deletions api/v1/analysis/product.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package analysis

import (
"github.com/gogf/gf/v2/frame/g"
)

// ProductCountReq 按年度每月设备消息统计
type ProductCountReq struct {
g.Meta `path:"/productCount" method:"get" summary:"产品数量统计" tags:"IOT数据分析"`
}
type ProductCountRes struct {
Total int `json:"total" dc:"产品总数"`
Enable int `json:"enable" dc:"启用产品数"`
Disable int `json:"disable" dc:"禁用产品数"`
Added int `json:"added" dc:"新增产品数"`
}

// DeviceCountForProductReq 获取属于该产品下的设备数量
type DeviceCountForProductReq struct {
g.Meta `path:"/deviceCountForProduct" method:"get" summary:"获取属于该产品下的设备数量" tags:"IOT数据分析"`
ProductKey string `json:"productKey" v:"required#ProductKey,产品key不能为空" dc:"产品key"`
}
type DeviceCountForProductRes struct {
Number int `json:"number" dc:"设备数"`
}
Loading

0 comments on commit dc697cc

Please sign in to comment.