diff --git a/adaptors/安心云es主题特征to广东省平台.go b/adaptors/安心云es主题特征to广东省平台.go index d6b7371..11ddfbb 100644 --- a/adaptors/安心云es主题特征to广东省平台.go +++ b/adaptors/安心云es主题特征to广东省平台.go @@ -2,10 +2,12 @@ package adaptors import ( "encoding/json" + "fmt" "goInOut/consumers/GDJKJC" "goInOut/consumers/HBJCAS" "goInOut/consumers/HBJCAS/protoFiles_hb" "goInOut/dbOperate" + "goInOut/models" "log" "math" @@ -64,16 +66,16 @@ func (the Adaptor_AXYES_GDJKJC) EsAggTopToGDJKJC(structId int64, factorId int, e sensorId := sensorBucket.Key for _, dateBucket := range sensorBucket.GroupDate.Buckets { //优先redis获取 - //station := models.Station{} - //k1 := fmt.Sprintf("station:%d", sensorId) - //errRedis := the.Redis.GetObj(k1, &station) - //if errRedis != nil { - // log.Printf("redis 获取[s:%d,f:%d]测点[%d]标签异常", structId, factorId, sensorId) - // continue - //} - monitorCode := "LJ-VIB-P01-004-01" //the.getPointCodeFromLabel(station.Labels) + station := models.Station{} + k1 := fmt.Sprintf("station:%d", sensorId) + errRedis := the.Redis.GetObj(k1, &station) + if errRedis != nil { + log.Printf("redis 获取[s:%d,f:%d]测点[%d]异常", structId, factorId, sensorId) + continue + } + monitorCode := station.Name if monitorCode == "" { - log.Printf("redis 获取[s:%d,f:%d]测点[%d]信息,异常,跳过", structId, factorId, sensorId) + log.Printf("redis 获取[s:%d,f:%d]测点[%d] 无信息,跳过", structId, factorId, sensorId) continue } @@ -90,7 +92,7 @@ func (the Adaptor_AXYES_GDJKJC) EsAggTopToGDJKJC(structId int64, factorId int, e return result } func (the Adaptor_AXYES_GDJKJC) getMonitorTypeByFactorId(factorId int) protoFiles_hb.MonitoryType { - //桥墩倾斜 15 裂缝18 支座位移20 桥面振动28 加速度三项监测592 + //应变11 桥墩倾斜 15 裂缝18 支座位移20 桥面振动28 加速度三项监测592 switch factorId { case 15: return protoFiles_hb.MonitoryType_INC @@ -124,6 +126,12 @@ func (the Adaptor_AXYES_GDJKJC) EsAgg2StatisticData(factorId int, monitorCode st } var destStruct any switch factorId { + case 11, 18: //应变11 裂缝18 + destStruct = GDJKJC.A44Strain{ + CommonBody: commonBody, + Avg: avgValueX, + Max: dateBucket.X.Max, + } case 15: //倾角 destStruct = GDJKJC.A43AngleBody{ CommonBody: commonBody, @@ -140,6 +148,13 @@ func (the Adaptor_AXYES_GDJKJC) EsAgg2StatisticData(factorId int, monitorCode st Max: maxAbsoluteValueX / 100, //省平台 加速度单位 m/s² 实际设备单位 cm/s² Rms: rootMeanSquareX / 100, //均方根 } + case 63: //支护结构变形(主梁位移) + destStruct = GDJKJC.A40DisplacementBody{ + CommonBody: commonBody, + Avg: avgValueY, + Max: maxAbsoluteValueY, + Rms: rootMeanSquareY, + } } if destStruct != nil { dataBytes, _ = json.Marshal(destStruct) diff --git a/configFiles/config_安心云测点特征数据_广东省平台.yaml b/configFiles/config_安心云测点特征数据_广东省平台.yaml index 636c815..a735614 100644 --- a/configFiles/config_安心云测点特征数据_广东省平台.yaml +++ b/configFiles/config_安心云测点特征数据_广东省平台.yaml @@ -9,16 +9,13 @@ ioConfig: method: "post" monitor: #振动是触发式,数据迟缓 cron10min也改成1小时一次 最多上报6条,不进行10min实时上报 - cron10min: 36 0/1 * * * #6/10 * * * * + cron10min: 56 0/1 * * * #6/10 * * * * #普通类型 特征数据 - cron1hour: 20 0/1 * * * + cron1hour: 35 0/1 * * * info: 5450: #隆江大桥 appKey: db43bc5d74534348 appSecret: 162c0a92f089464eaf9349358af4a830 - 5452: #深汕东边坡 - appKey: cdf1493747174885 - appSecret: 563e5d752181450da3b9d1617f75b527 5455: #螺河特大桥 appKey: 11b8f81901134570 appSecret: 1505ef9480e4491bb578e2d7d9781620 @@ -31,9 +28,8 @@ queryComponent: address: 10.8.30.160:30379 #结构物id对应 structInfo: - 5450: G0000000000001 #隆江大桥 - 5452: G0000000000002 #深汕东边坡 - 5455: G0000000000003 #螺河特大桥 - 5456: G0000000000004 #螺河东大桥 + 5450: G15445224L1120 #隆江大桥 + 5455: G15441581L1320 #螺河特大桥 + 5456: G15441581L1310 #螺河东大桥 diff --git a/consumers/consumerAXYES2GDJKJC.go b/consumers/consumerAXYES2GDJKJC.go index a9edf27..3e47df4 100644 --- a/consumers/consumerAXYES2GDJKJC.go +++ b/consumers/consumerAXYES2GDJKJC.go @@ -103,6 +103,7 @@ func (the *consumerAXYES2GDJKJC) Work() { "sign": utils.GetSign(string(push.Payload), rnd, appKey, appSecret), } + log.Printf("推送数据=%s", push.Payload) _, err := the.outHttp.PublishWithHeader(push.Payload, Header) if err != nil { log.Printf("数据推送异常=> %s", err.Error()) @@ -132,7 +133,7 @@ func (the *consumerAXYES2GDJKJC) getStructIds() []int64 { func (the *consumerAXYES2GDJKJC) getEs1HourAggData() { start, end := utils.GetTimeRangeByHour(-1) log.Printf("查询数据时间范围 %s - %s", start, end) - hourFactorIds := []int{15, 18, 20} + hourFactorIds := []int{15} //[]int{11, 15, 18, 20} //应变11 桥墩倾斜15 裂缝监测18 支护结构变形63 structIds := the.getStructIds() for _, structId := range structIds { for _, factorId := range hourFactorIds { @@ -140,6 +141,12 @@ func (the *consumerAXYES2GDJKJC) getEs1HourAggData() { auth := map[string]string{"Authorization": "Bear 85a441d4-022b-4613-abba-aaa8e2693bf7"} esAggResultStr := the.InHttp.HttpGetWithHeader(esQuery, auth) + lenRes := len(esAggResultStr) + if lenRes < 250 { + log.Printf("[s=%d,f=%d],es agg 返回无数据", structId, factorId) + continue + } + adaptor := the.getAdaptor() adaptor.PointInfo = the.ConfigInfo.PointInfo adaptor.StructInfo = the.ConfigInfo.StructInfo diff --git a/dbOperate/httpHelper.go b/dbOperate/httpHelper.go index 236ae87..0b82989 100644 --- a/dbOperate/httpHelper.go +++ b/dbOperate/httpHelper.go @@ -180,7 +180,7 @@ func HttpPostWithHeader(url string, queryBody string, headers map[string]string) req.Header.Add(k, v) } - log.Printf("http post 开始请求,%s,\n,%v \n", url, req) + log.Printf("http post 开始请求,url=%s,header=%v", url, req.Header) resp, err := client.Do(req) if err != nil { log.Println("请求POST异常 ", err, resp)