Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qsh-wc
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
honghuiliu
qsh-wc
Commits
2c127487
Commit
2c127487
authored
Nov 10, 2022
by
honghuiliu
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
日常提交
parent
0a0b243c
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
64 additions
and
5 deletions
+64
-5
data.go
server/api/v1/web/data.go
+15
-0
go.mod
server/go.mod
+1
-1
main.go
server/main.go
+3
-4
dataRequest.go
server/request/dataRequest.go
+4
-0
web.go
server/router/web.go
+1
-0
dataService.go
server/service/web/dataService.go
+40
-0
No files found.
server/api/v1/web/data.go
View file @
2c127487
...
@@ -42,3 +42,18 @@ func GetHistoryDataList(c *gin.Context) {
...
@@ -42,3 +42,18 @@ func GetHistoryDataList(c *gin.Context) {
},
c
)
},
c
)
}
}
func
GetDeviceData
(
c
*
gin
.
Context
)
{
var
arg
request
.
GetDeviceData
if
err
:=
c
.
ShouldBindJSON
(
&
arg
);
err
!=
nil
{
response
.
FailWithMessage
(
err
.
Error
(),
c
)
return
}
list
,
err
:=
DataService
.
GetDeviceData
(
arg
)
if
err
!=
nil
{
response
.
FailWithMessage
(
err
.
Error
(),
c
)
return
}
response
.
OkWithData
(
list
,
c
)
}
server/go.mod
View file @
2c127487
...
@@ -11,7 +11,7 @@ require (
...
@@ -11,7 +11,7 @@ require (
github.com/beego/beego/v2 v2.0.5
github.com/beego/beego/v2 v2.0.5
github.com/casbin/casbin/v2 v2.11.0
github.com/casbin/casbin/v2 v2.11.0
github.com/casbin/gorm-adapter/v3 v3.0.2
github.com/casbin/gorm-adapter/v3 v3.0.2
github.com/eclipse/paho.mqtt.golang v1.4.2
// indirect
github.com/eclipse/paho.mqtt.golang v1.4.2
github.com/flipped-aurora/ws v1.0.2
github.com/flipped-aurora/ws v1.0.2
github.com/fsnotify/fsnotify v1.4.9
github.com/fsnotify/fsnotify v1.4.9
github.com/fvbock/endless v0.0.0-20170109170031-447134032cb6
github.com/fvbock/endless v0.0.0-20170109170031-447134032cb6
...
...
server/main.go
View file @
2c127487
package
main
package
main
import
(
import
(
"fmt"
"github.com/flipped-aurora/gin-vue-admin/server/core"
"github.com/flipped-aurora/gin-vue-admin/server/core"
"github.com/flipped-aurora/gin-vue-admin/server/global"
"github.com/flipped-aurora/gin-vue-admin/server/global"
"github.com/flipped-aurora/gin-vue-admin/server/initialize"
"github.com/flipped-aurora/gin-vue-admin/server/initialize"
...
@@ -50,9 +48,10 @@ func main() {
...
@@ -50,9 +48,10 @@ func main() {
// 净化设施服务
// 净化设施服务
if
global
.
GVA_VP
.
GetBool
(
"mqttServer.enable"
)
{
if
global
.
GVA_VP
.
GetBool
(
"mqttServer.enable"
)
{
server
.
OnMqttMessage
(
func
(
data
server
.
JingHuaData
)
error
{
server
.
OnMqttMessage
(
func
(
data
server
.
JingHuaData
)
error
{
service
:=
new
(
web
.
DataService
)
// {301022041237 {"MBR池溶氧值":0,"出水池PH值":4,"出水池流量值":0,"厌氧池PH值":4,"好氧池PH值":4.0,"好氧池溶氧值":0,"调节池流量值":0.1}}
// {301022041237 {"MBR池溶氧值":0,"出水池PH值":4,"出水池流量值":0,"厌氧池PH值":4,"好氧池PH值":4.0,"好氧池溶氧值":0,"调节池流量值":0.1}}
fmt
.
Println
(
data
)
//
fmt.Println(data)
return
nil
return
service
.
DataInJingHua
(
data
)
})
})
go
server
.
InitJinghuaServer
(
global
.
GVA_VP
.
GetString
(
"mqttServer.addr"
))
go
server
.
InitJinghuaServer
(
global
.
GVA_VP
.
GetString
(
"mqttServer.addr"
))
}
}
...
...
server/request/dataRequest.go
View file @
2c127487
...
@@ -14,3 +14,7 @@ type GetHistoryDataList struct {
...
@@ -14,3 +14,7 @@ type GetHistoryDataList struct {
EndTime
string
`json:"end_time"`
EndTime
string
`json:"end_time"`
ToiletID
int
`json:"toilet_id"`
ToiletID
int
`json:"toilet_id"`
}
}
type
GetDeviceData
struct
{
ToiletID
int
`json:"toilet_id"`
}
server/router/web.go
View file @
2c127487
...
@@ -32,6 +32,7 @@ func InitWebRouter(router *gin.Engine) {
...
@@ -32,6 +32,7 @@ func InitWebRouter(router *gin.Engine) {
{
{
data
.
POST
(
"getHistoryDataList"
,
web
.
GetHistoryDataList
)
data
.
POST
(
"getHistoryDataList"
,
web
.
GetHistoryDataList
)
data
.
POST
(
"getYewei"
,
web
.
GetYewei
)
data
.
POST
(
"getYewei"
,
web
.
GetYewei
)
data
.
POST
(
"getDeviceData"
,
web
.
GetDeviceData
)
}
}
typeData
:=
webRouter
.
Group
(
"type"
)
typeData
:=
webRouter
.
Group
(
"type"
)
...
...
server/service/web/dataService.go
View file @
2c127487
...
@@ -6,6 +6,7 @@ import (
...
@@ -6,6 +6,7 @@ import (
"github.com/flipped-aurora/gin-vue-admin/server/model/admin"
"github.com/flipped-aurora/gin-vue-admin/server/model/admin"
"github.com/flipped-aurora/gin-vue-admin/server/request"
"github.com/flipped-aurora/gin-vue-admin/server/request"
"github.com/flipped-aurora/gin-vue-admin/server/server"
"github.com/flipped-aurora/gin-vue-admin/server/server"
"github.com/songzhibin97/gkit/tools/gjson"
"gorm.io/gorm"
"gorm.io/gorm"
)
)
...
@@ -29,6 +30,33 @@ func (s *DataService) DataInYeWei(arg server.YeWeiData) error {
...
@@ -29,6 +30,33 @@ func (s *DataService) DataInYeWei(arg server.YeWeiData) error {
})
.
Error
})
.
Error
}
}
func
(
s
*
DataService
)
DataInJingHua
(
arg
server
.
JingHuaData
)
error
{
//先查询设备绑定厕所
var
toiletInfo
admin
.
QshToilet
err
:=
global
.
GVA_DB
.
Model
(
admin
.
QshToilet
{})
.
Where
(
"jinghua_device_id = ?"
,
arg
.
JinghuaDeviceId
)
.
First
(
&
toiletInfo
)
.
Error
if
err
!=
nil
{
return
errors
.
New
(
"设备ID未绑定公厕信息!"
)
}
var
need
=
[][]
string
{{
"MBR池溶氧值"
,
"mg/l"
},
{
"出水池PH值"
,
""
},
{
"出水池流量值"
,
"m3/h"
},
{
"厌氧池PH值"
,
""
},
{
"好氧池PH值"
,
""
},
{
"好氧池溶氧值"
,
"mg/l"
},
{
"调节池流量值"
,
"m3/h"
}}
var
data
[]
admin
.
QshMonitorData
for
_
,
v
:=
range
need
{
if
gjson
.
Get
(
arg
.
Data
,
v
[
0
])
.
Exists
()
{
data
=
append
(
data
,
admin
.
QshMonitorData
{
RawDeviceId
:
arg
.
JinghuaDeviceId
,
ToiletId
:
int
(
toiletInfo
.
ID
),
TypeName
:
v
[
0
],
Unit
:
v
[
1
],
Value
:
gjson
.
Get
(
arg
.
Data
,
v
[
0
])
.
String
(),
})
}
}
return
global
.
GVA_DB
.
Create
(
&
data
)
.
Error
}
func
(
s
*
DataService
)
getData
()
{
}
//GetYewei 获取液位
//GetYewei 获取液位
func
(
s
*
DataService
)
GetYewei
(
arg
request
.
GetYewei
)
(
admin
.
QshMonitorData
,
error
)
{
func
(
s
*
DataService
)
GetYewei
(
arg
request
.
GetYewei
)
(
admin
.
QshMonitorData
,
error
)
{
var
data
admin
.
QshMonitorData
var
data
admin
.
QshMonitorData
...
@@ -67,3 +95,15 @@ func (s *DataService) GetHistoryDataList(arg request.GetHistoryDataList) ([]admi
...
@@ -67,3 +95,15 @@ func (s *DataService) GetHistoryDataList(arg request.GetHistoryDataList) ([]admi
}
}
return
data
,
count
,
nil
return
data
,
count
,
nil
}
}
func
(
s
*
DataService
)
GetDeviceData
(
arg
request
.
GetDeviceData
)
([]
admin
.
QshMonitorData
,
error
)
{
var
data
[]
admin
.
QshMonitorData
var
need
=
[]
string
{
"液位"
,
"MBR池溶氧值"
,
"出水池PH值"
,
"出水池流量值"
,
"厌氧池PH值"
,
"好氧池PH值"
,
"好氧池溶氧值"
,
"调节池流量值"
}
err
:=
global
.
GVA_DB
.
Debug
()
.
Select
(
"max(id) id,type_name,toilet_id,raw_device_id,value,unit,created_at,updated_at,deleted_at"
)
.
Model
(
admin
.
QshMonitorData
{})
.
Where
(
"toilet_id = ?"
,
arg
.
ToiletID
)
.
Where
(
"type_name IN ?"
,
need
)
.
Group
(
"type_name"
)
.
Find
(
&
data
)
.
Error
if
err
!=
nil
{
return
data
,
err
}
return
data
,
nil
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment