|
|
@ -4,6 +4,8 @@ import ( |
|
|
|
"encoding/json" |
|
|
|
"fmt" |
|
|
|
"goInOut/consumers/GZG2ZJHL/protoFiles_zjhl" |
|
|
|
"strconv" |
|
|
|
"strings" |
|
|
|
|
|
|
|
//"goInOut/consumers/GZG2ZJHL/protoFiles_zjhl"
|
|
|
|
"goInOut/consumers/HBJCAS" |
|
|
@ -12,8 +14,6 @@ import ( |
|
|
|
"google.golang.org/protobuf/proto" |
|
|
|
"log" |
|
|
|
"math" |
|
|
|
"strconv" |
|
|
|
"strings" |
|
|
|
"time" |
|
|
|
) |
|
|
|
|
|
|
@ -77,22 +77,30 @@ func (the Adaptor_ZWYES_ZJHL) EsAggTopToHBJCAS(structId int64, factorId int, esA |
|
|
|
continue |
|
|
|
} |
|
|
|
|
|
|
|
dataBody := the.EsAgg2StatisticData(factorId, monitorCode, dateBucket) |
|
|
|
if dataBody == nil { |
|
|
|
log.Printf("[s:%d,f:%d]测点[%d] 特征数据组包异常,跳过", structId, factorId, sensorId) |
|
|
|
continue |
|
|
|
} |
|
|
|
dataDefinition := &protoFiles_zjhl.DataDefinition{ |
|
|
|
DataType: protoFiles_zjhl.DataType_STATISTICS, |
|
|
|
//BridgeCode: fmt.Sprintf("%d", uniqueCode), //提示 不传该字段
|
|
|
|
DataBody: the.EsAgg2StatisticData(factorId, monitorCode, dateBucket), |
|
|
|
DataBody: dataBody, |
|
|
|
} |
|
|
|
|
|
|
|
complexData.SensorData = append(complexData.SensorData, dataDefinition) |
|
|
|
} |
|
|
|
} |
|
|
|
v, _ := json.Marshal(complexData) |
|
|
|
log.Printf("[s:%d,f:%d] 特征数据=> %s", structId, factorId, v) |
|
|
|
log.Printf("[struct:%d,factor:%d] 特征数据=> %s", structId, factorId, v) |
|
|
|
result, _ = proto.Marshal(complexData) |
|
|
|
return result |
|
|
|
} |
|
|
|
func (the Adaptor_ZWYES_ZJHL) getMonitorTypeByFactorId(factorId int) protoFiles_zjhl.MonitoryType { |
|
|
|
//桥墩倾斜 15 裂缝18 支座位移20 桥面振动28 加速度三项监测592
|
|
|
|
//结构温度4 桥墩倾斜 15 裂缝18 支座位移20 桥面振动28 加速度三项监测592
|
|
|
|
switch factorId { |
|
|
|
case 4: |
|
|
|
return protoFiles_zjhl.MonitoryType_TMP |
|
|
|
case 15: |
|
|
|
return protoFiles_zjhl.MonitoryType_INC |
|
|
|
case 18: |
|
|
@ -130,6 +138,25 @@ func (the Adaptor_ZWYES_ZJHL) EsAgg2StatisticData(factorId int, monitorCode int6 |
|
|
|
} |
|
|
|
|
|
|
|
switch factorId { |
|
|
|
case 4: //结构温度
|
|
|
|
dataDefinitionStatisticData.StatisticData.DataBody = &protoFiles_zjhl.StatisticData_Tmp{Tmp: &protoFiles_zjhl.TMPStatistic{ |
|
|
|
MaxTemperature: float32(dateBucket.X.Max), |
|
|
|
MinTemperature: float32(dateBucket.X.Min), |
|
|
|
AvgTemperature: float32(avgValueX), |
|
|
|
MaxDifference: float32(dateBucket.X.Max - dateBucket.X.Min), |
|
|
|
}} |
|
|
|
case 6: //索力
|
|
|
|
dataDefinitionStatisticData.StatisticData.DataBody = &protoFiles_zjhl.StatisticData_Vic{Vic: &protoFiles_zjhl.VICStatistic{ |
|
|
|
MaxValue: float32(dateBucket.X.Max), |
|
|
|
MinValue: float32(dateBucket.X.Min), |
|
|
|
AvgValue: float32(avgValueX), |
|
|
|
RootMeanSquare: float32(rootMeanSquareX), |
|
|
|
}} |
|
|
|
case 11: //应变
|
|
|
|
dataDefinitionStatisticData.StatisticData.DataBody = &protoFiles_zjhl.StatisticData_Rsg{Rsg: &protoFiles_zjhl.RSGStatistic{ |
|
|
|
MaxAbsoluteValue: float32(maxAbsoluteValueX), |
|
|
|
AvgValue: float32(avgValueX), |
|
|
|
}} |
|
|
|
case 15: //倾角
|
|
|
|
dataDefinitionStatisticData.StatisticData.DataBody = &protoFiles_zjhl.StatisticData_Inc{Inc: &protoFiles_zjhl.INCStatistic{ |
|
|
|
MaxAbsoluteValueX: float32(maxAbsoluteValueX), |
|
|
@ -176,10 +203,10 @@ func (the Adaptor_ZWYES_ZJHL) getUniqueCode(structId int64) (uniqueCode int64) { |
|
|
|
} |
|
|
|
|
|
|
|
func (the Adaptor_ZWYES_ZJHL) getPointCodeFromLabel(label string) int64 { |
|
|
|
//解析label {13010600001}
|
|
|
|
//解析label {ID:6500030042}
|
|
|
|
pointUniqueCode := int64(0) |
|
|
|
if len(label) > 2 { |
|
|
|
newLabel := strings.TrimLeft(label, "{") |
|
|
|
if len(label) > 5 { |
|
|
|
newLabel := strings.TrimLeft(label, "{ID:") |
|
|
|
str := strings.TrimRight(newLabel, "}") |
|
|
|
codeInt64, err := strconv.ParseInt(str, 10, 64) |
|
|
|
if err != nil { |
|
|
|