Browse Source

update 添加裂缝18 特征数据上报支持

dev
lucas 3 months ago
parent
commit
f424fcbf9a
  1. 43
      adaptors/安心云es主题特征to河北公路设施监测.go
  2. 18
      configFiles/config_河北省公路基础设施监测_承德_轻量化特征数据.yaml
  3. 19
      consumers/consumerHBJCAS.go
  4. 2
      dbOperate/httpHelper.go
  5. 2
      dbOperate/mqttHelper.go
  6. 8
      models/esThemeAggDateHistogram.go

43
adaptors/安心云es主题特征to河北公路设施监测.go

@ -78,10 +78,12 @@ func (the Adaptor_AXYES_HBGL) EsAggTopToHBJCAS(structId int64, factorId int, esA
return result
}
func (the Adaptor_AXYES_HBGL) getMonitorTypeByFactorId(factorId int) protoFiles_hb.MonitoryType {
//桥墩倾斜 15 支座位移20 桥面振动28
//桥墩倾斜 15 裂缝18 支座位移20 桥面振动28
switch factorId {
case 15:
return protoFiles_hb.MonitoryType_INC
case 18:
return protoFiles_hb.MonitoryType_CRK
case 20:
return protoFiles_hb.MonitoryType_AND
case 28:
@ -90,14 +92,15 @@ func (the Adaptor_AXYES_HBGL) getMonitorTypeByFactorId(factorId int) protoFiles_
return protoFiles_hb.MonitoryType_CMM
}
}
func (the Adaptor_AXYES_HBGL) EsAgg2StatisticData(factorId int, monitorCode int64, dateBucket models.BucketsXY) *protoFiles_hb.DataDefinition_StatisticData {
Atime := dateBucket.KeyAsString.Add(-8 * time.Hour).UnixMilli()
maxAbsoluteValueX := max(math.Abs(dateBucket.X.Max), math.Abs(dateBucket.X.Min))
avgValueX := dateBucket.X.Avg
rootMeanSquareX := math.Sqrt(dateBucket.X.SumOfSquares / float64(dateBucket.X.Count))
maxAbsoluteValueY := max(math.Abs(dateBucket.Y.Max), math.Abs(dateBucket.Y.Min))
avgValueY := dateBucket.Y.Avg
rootMeanSquareX := math.Sqrt(dateBucket.X.SumOfSquares / float64(dateBucket.X.Count))
rootMeanSquareY := math.Sqrt(dateBucket.Y.SumOfSquares / float64(dateBucket.Y.Count))
monitoryType := the.getMonitorTypeByFactorId(factorId)
@ -107,17 +110,35 @@ func (the Adaptor_AXYES_HBGL) EsAgg2StatisticData(factorId int, monitorCode int6
MonitorCode: monitorCode, //测点唯一编码
EventTime: Atime,
Interval: 60 * 1000,
DataBody: &protoFiles_hb.StatisticData_Inc{Inc: &protoFiles_hb.INCStatistic{
MaxAbsoluteValueX: float32(maxAbsoluteValueX),
AvgValueX: float32(avgValueX),
RootMeanSquareX: float32(rootMeanSquareX),
MaxAbsoluteValueY: float32(maxAbsoluteValueY),
AvgValueY: float32(avgValueY),
RootMeanSquareY: float32(rootMeanSquareY),
}},
},
}
switch factorId {
case 15: //倾角
dataDefinitionStatisticData.StatisticData.DataBody = &protoFiles_hb.StatisticData_Inc{Inc: &protoFiles_hb.INCStatistic{
MaxAbsoluteValueX: float32(maxAbsoluteValueX),
AvgValueX: float32(avgValueX),
RootMeanSquareX: float32(rootMeanSquareX),
MaxAbsoluteValueY: float32(maxAbsoluteValueY),
AvgValueY: float32(avgValueY),
RootMeanSquareY: float32(rootMeanSquareY),
}}
case 18: //裂缝监测
dataDefinitionStatisticData.StatisticData.DataBody = &protoFiles_hb.StatisticData_Crk{Crk: &protoFiles_hb.CRKStatistic{
MaxAbsoluteValue: float32(maxAbsoluteValueX),
AvgValue: float32(avgValueX),
RootMeanSquare: float32(rootMeanSquareX),
TotalAbsoluteValue: float32(dateBucket.X.Max - dateBucket.X.Min),
}}
case 20: //支座位移
dataDefinitionStatisticData.StatisticData.DataBody = &protoFiles_hb.StatisticData_Dis{Dis: &protoFiles_hb.DISStatistic{
MaxAbsoluteValue: float32(maxAbsoluteValueX),
AvgValue: float32(avgValueX),
RootMeanSquare: float32(rootMeanSquareX),
TotalAbsoluteValue: float32(dateBucket.X.Max - dateBucket.X.Min),
}}
}
return dataDefinitionStatisticData
}

18
configFiles/config_河北省公路基础设施监测_承德_轻量化特征数据.yaml

@ -3,7 +3,7 @@ ioConfig:
in:
http:
url: https://esproxy.anxinyun.cn/anxincloud_themes/_search
cronStr: 48 0/1 * * *
cronStr: 11 0/1 * * *
out:
mqtt:
host: 10.8.30.160
@ -17,10 +17,20 @@ info:
rc4key: sK3kJttzZyf7aZI94zSYgytBYCrfZRt6yil2
#结构物id对应
structInfo:
5011: 130110
5016: 130109
#点位id对应信息
pointInfo:
5011: #河北承德横河子中桥
#裂缝 crack
68397: 1301100001
68398: 1301100002
68399: 1301100001
5016: #河北承德乃积沟大桥
68384: 13000100001
68385: 13000100002
68386: 13000100003
68384: 13010900001
68385: 13010900002
68386: 13010900003
68387: 13010900004
68388: 13010900005
68389: 13010900006

19
consumers/consumerHBJCAS.go

@ -50,7 +50,7 @@ func (the *consumerHBJCAS) InputInitial() error {
MonitorHelper: &monitors.MonitorHelper{CronStr: the.Info.IoConfig.In.CronStr},
}
the.monitor.Start()
the.monitor.RegisterFun(the.getEsData)
the.monitor.RegisterFun(the.getEsHourAggData)
return nil
}
func (the *consumerHBJCAS) OutputInitial() error {
@ -103,10 +103,10 @@ func (the *consumerHBJCAS) getStructIds() []int64 {
}
return structIds
}
func (the *consumerHBJCAS) getEsData() {
func (the *consumerHBJCAS) getEsHourAggData() {
start, end := utils.GetTimeRangeByHour(-1)
log.Printf("查询数据时间范围 %s - %s", start, end)
hourFactorIds := []int{20} //, 15, 20 , 28
hourFactorIds := []int{18, 15, 20} //15, 20 , 28
structIds := the.getStructIds()
for _, structId := range structIds {
for _, factorId := range hourFactorIds {
@ -202,7 +202,7 @@ func (the *consumerHBJCAS) getESQueryStrByHour(structureId int64, factorId int,
}
func getEsAggSubSqlByFactorId(factorId int) string {
//桥墩倾斜 15 支座位移20 桥面振动28
//桥墩倾斜 15 裂缝 18 支座位移20 桥面振动28
subAggSQl := ""
switch factorId {
case 15:
@ -218,11 +218,20 @@ func getEsAggSubSqlByFactorId(factorId int) string {
"field": "data.y"
}
}
}`
case 18:
subAggSQl = `
{
"x": {
"extended_stats": {
"field": "data.crack"
}
}
}`
case 20:
subAggSQl = `
{
"displacement": {
"x": {
"extended_stats": {
"field": "data.displacement"
}

2
dbOperate/httpHelper.go

@ -11,6 +11,7 @@ import (
"net/url"
"os"
"strings"
"time"
)
type HttpHelper struct {
@ -22,6 +23,7 @@ type HttpHelper struct {
func (the *HttpHelper) Initial() {
the.client = http.Client{}
the.client.Timeout = time.Minute
}
func (the *HttpHelper) HttpGet(queryBody string) string {

2
dbOperate/mqttHelper.go

@ -86,7 +86,7 @@ func (the *MqttHelper) Publish(topic string, messageBytes []byte) {
token := the.client.Publish(topic, 1, false, messageBytes)
token.Wait()
//the.client.Disconnect(200)
log.Printf("[%s] -[%v]推送Msg 长度=%d \n", topic, the.client.IsConnected(), len(messageBytes))
log.Printf("[%s] -[%v]推送Msg 长度=%d byte \n", topic, the.client.IsConnected(), len(messageBytes))
}
}

8
models/esThemeAggDateHistogram.go

@ -34,12 +34,16 @@ type Buckets struct {
} `json:"groupDate"`
}
type BucketsXY struct {
type BucketsX struct {
KeyAsString time.Time `json:"key_as_string"`
Key int64 `json:"key"`
DocCount int `json:"doc_count"`
X ExtendedStats `json:"x"`
Y ExtendedStats `json:"y"`
}
type BucketsXY struct {
BucketsX
Y ExtendedStats `json:"y"`
}
type ExtendedStats struct {

Loading…
Cancel
Save