Browse Source

update 更新版本到V3

dev
lucas 2 years ago
parent
commit
d05952401f
  1. 71
      adaptors/知物云es主题特征to中交华联.go
  2. 2
      configFiles/config_知物云果子沟_中交华联_特征数据.yaml
  3. 801
      consumers/GZG2ZJHL/protoFiles_zjhl/MonitorDataProtocol-V1.3.1.proto
  4. 5329
      consumers/GZG2ZJHL/protoFiles_zjhl/protoFiles_zjhl_v3/MonitorDataProtocol-Ministry-v3.0.pb.go
  5. 2
      consumers/consumerGZG2ZJHL.go
  6. 109
      main_test.go

71
adaptors/知物云es主题特征to中交华联.go

@ -1,19 +1,18 @@
package adaptors
import (
"encoding/hex"
"encoding/json"
"fmt"
"goInOut/consumers/GZG2ZJHL/protoFiles_zjhl"
"strconv"
"strings"
//"goInOut/consumers/GZG2ZJHL/protoFiles_zjhl"
"goInOut/consumers/GZG2ZJHL/protoFiles_zjhl/protoFiles_zjhl_v3"
"goInOut/consumers/HBJCAS"
"goInOut/dbOperate"
"goInOut/models"
"google.golang.org/protobuf/proto"
"log"
"math"
"strconv"
"strings"
"time"
)
@ -36,7 +35,7 @@ func (the Adaptor_ZWYES_ZJHL) Transform(structId int64, factorId int, rawMsg str
}
Payload := the.EsAggTopToHBJCAS(structId, factorId, esAggDateHistogram)
if len(Payload) == 0 {
if len(Payload) >= 0 {
return needPush
}
@ -59,7 +58,7 @@ func (the Adaptor_ZWYES_ZJHL) EsAggTopToHBJCAS(structId int64, factorId int, esA
return
}
//数据汇总
complexData := &protoFiles_zjhl.ComplexData{}
complexData := &protoFiles_zjhl_v3.ComplexData{}
for _, sensorBucket := range buckets {
sensorId := sensorBucket.Key
for _, dateBucket := range sensorBucket.GroupDate.Buckets {
@ -82,8 +81,8 @@ func (the Adaptor_ZWYES_ZJHL) EsAggTopToHBJCAS(structId int64, factorId int, esA
log.Printf("[s:%d,f:%d]测点[%d] 特征数据组包异常,跳过", structId, factorId, sensorId)
continue
}
dataDefinition := &protoFiles_zjhl.DataDefinition{
DataType: protoFiles_zjhl.DataType_STATISTICS,
dataDefinition := &protoFiles_zjhl_v3.DataDefinition{
DataType: protoFiles_zjhl_v3.DataType_STATISTICS,
//BridgeCode: fmt.Sprintf("%d", uniqueCode), //提示 不传该字段
DataBody: dataBody,
}
@ -94,30 +93,37 @@ func (the Adaptor_ZWYES_ZJHL) EsAggTopToHBJCAS(structId int64, factorId int, esA
v, _ := json.Marshal(complexData)
log.Printf("[struct:%d,factor:%d] 特征数据=> %s", structId, factorId, v)
result, _ = proto.Marshal(complexData)
log.Printf("[struct:%d,factor:%d] protobuf数据=> %s", structId, factorId, hex.EncodeToString(result))
return result
}
func (the Adaptor_ZWYES_ZJHL) getMonitorTypeByFactorId(factorId int) protoFiles_zjhl.MonitoryType {
func (the Adaptor_ZWYES_ZJHL) getMonitorTypeByFactorId(factorId int) protoFiles_zjhl_v3.MonitoryType {
//结构温度4 桥墩倾斜 15 裂缝18 支座位移20 桥面振动28 加速度三项监测592
switch factorId {
case 4:
return protoFiles_zjhl.MonitoryType_TMP
return protoFiles_zjhl_v3.MonitoryType_TMP
case 6:
return protoFiles_zjhl_v3.MonitoryType_VIC
case 11:
return protoFiles_zjhl_v3.MonitoryType_RSG
case 15:
return protoFiles_zjhl.MonitoryType_INC
return protoFiles_zjhl_v3.MonitoryType_INC
case 18:
return protoFiles_zjhl.MonitoryType_CRK
case 20:
return protoFiles_zjhl.MonitoryType_DIS
return protoFiles_zjhl_v3.MonitoryType_CRK
case 19:
return protoFiles_zjhl_v3.MonitoryType_HPT
case 20, 24:
return protoFiles_zjhl_v3.MonitoryType_DIS
case 28:
return protoFiles_zjhl.MonitoryType_VIB
return protoFiles_zjhl_v3.MonitoryType_VIB
case 592:
return protoFiles_zjhl.MonitoryType_VIB
return protoFiles_zjhl_v3.MonitoryType_VIB
default:
log.Printf("factorId=%d,无匹配的MonitorType", factorId)
return protoFiles_zjhl.MonitoryType_CMM
return protoFiles_zjhl_v3.MonitoryType_CMM
}
}
func (the Adaptor_ZWYES_ZJHL) EsAgg2StatisticData(factorId int, monitorCode int64, dateBucket HBJCAS.BucketsXY) *protoFiles_zjhl.DataDefinition_StatisticData {
func (the Adaptor_ZWYES_ZJHL) EsAgg2StatisticData(factorId int, monitorCode int64, dateBucket HBJCAS.BucketsXY) *protoFiles_zjhl_v3.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
@ -128,8 +134,8 @@ func (the Adaptor_ZWYES_ZJHL) EsAgg2StatisticData(factorId int, monitorCode int6
rootMeanSquareY := math.Sqrt(dateBucket.Y.SumOfSquares / float64(dateBucket.Y.Count))
monitoryType := the.getMonitorTypeByFactorId(factorId)
dataDefinitionStatisticData := &protoFiles_zjhl.DataDefinition_StatisticData{
StatisticData: &protoFiles_zjhl.StatisticData{
dataDefinitionStatisticData := &protoFiles_zjhl_v3.DataDefinition_StatisticData{
StatisticData: &protoFiles_zjhl_v3.StatisticData{
MonitorType: monitoryType,
MonitorCode: monitorCode, //测点唯一编码
EventTime: Atime,
@ -139,26 +145,26 @@ 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{
dataDefinitionStatisticData.StatisticData.DataBody = &protoFiles_zjhl_v3.StatisticData_Tmp{Tmp: &protoFiles_zjhl_v3.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{
dataDefinitionStatisticData.StatisticData.DataBody = &protoFiles_zjhl_v3.StatisticData_Vic{Vic: &protoFiles_zjhl_v3.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{
dataDefinitionStatisticData.StatisticData.DataBody = &protoFiles_zjhl_v3.StatisticData_Rsg{Rsg: &protoFiles_zjhl_v3.RSGStatistic{
MaxAbsoluteValue: float32(maxAbsoluteValueX),
AvgValue: float32(avgValueX),
}}
case 15: //倾角
dataDefinitionStatisticData.StatisticData.DataBody = &protoFiles_zjhl.StatisticData_Inc{Inc: &protoFiles_zjhl.INCStatistic{
dataDefinitionStatisticData.StatisticData.DataBody = &protoFiles_zjhl_v3.StatisticData_Inc{Inc: &protoFiles_zjhl_v3.INCStatistic{
MaxAbsoluteValueX: float32(maxAbsoluteValueX),
AvgValueX: float32(avgValueX),
RootMeanSquareX: float32(rootMeanSquareX),
@ -167,35 +173,32 @@ func (the Adaptor_ZWYES_ZJHL) EsAgg2StatisticData(factorId int, monitorCode int6
RootMeanSquareY: float32(rootMeanSquareY),
}}
case 18: //裂缝监测
dataDefinitionStatisticData.StatisticData.DataBody = &protoFiles_zjhl.StatisticData_Crk{Crk: &protoFiles_zjhl.CRKStatistic{
dataDefinitionStatisticData.StatisticData.DataBody = &protoFiles_zjhl_v3.StatisticData_Crk{Crk: &protoFiles_zjhl_v3.CRKStatistic{
MaxAbsoluteValue: float32(maxAbsoluteValueX),
AvgValue: float32(avgValueX),
RootMeanSquare: float32(rootMeanSquareX),
TotalAbsoluteValue: float32(dateBucket.X.Max - dateBucket.X.Min),
}}
case 19: //挠度监测
dataDefinitionStatisticData.StatisticData.DataBody = &protoFiles_zjhl.StatisticData_Hpt{Hpt: &protoFiles_zjhl.HPTStatistic{
dataDefinitionStatisticData.StatisticData.DataBody = &protoFiles_zjhl_v3.StatisticData_Hpt{Hpt: &protoFiles_zjhl_v3.HPTStatistic{
MaxAbsoluteValue: float32(maxAbsoluteValueX),
AvgValue: float32(avgValueX),
RootMeanSquare: float32(rootMeanSquareX),
}}
case 20, 24: //支座位移20, 位移24
dataDefinitionStatisticData.StatisticData.DataBody = &protoFiles_zjhl.StatisticData_Dis{Dis: &protoFiles_zjhl.DISStatistic{
dataDefinitionStatisticData.StatisticData.DataBody = &protoFiles_zjhl_v3.StatisticData_Dis{Dis: &protoFiles_zjhl_v3.DISStatistic{
MaxAbsoluteValue: float32(maxAbsoluteValueX),
AvgValue: float32(avgValueX),
RootMeanSquare: float32(rootMeanSquareX),
TotalAbsoluteValue: float32(dateBucket.X.Max - dateBucket.X.Min),
}}
case 28: //振动
dataDefinitionStatisticData.StatisticData.DataBody = &protoFiles_zjhl.StatisticData_Vib{Vib: &protoFiles_zjhl.VIBStatistic{
dataDefinitionStatisticData.StatisticData.DataBody = &protoFiles_zjhl_v3.StatisticData_Vib{Vib: &protoFiles_zjhl_v3.VIBStatistic{
MaxAbsoluteValue: float32(maxAbsoluteValueX),
RootMeanSquare: float32(rootMeanSquareY),
}}
case 592: //加速度三项监测
dataDefinitionStatisticData.StatisticData.DataBody = &protoFiles_zjhl.StatisticData_Vib{Vib: &protoFiles_zjhl.VIBStatistic{
MaxAbsoluteValue: float32(maxAbsoluteValueX),
RootMeanSquare: float32(rootMeanSquareX),
}}
case 935: //gnss
dataDefinitionStatisticData.StatisticData.DataBody = &protoFiles_zjhl_v3.StatisticData_Gnss{Gnss: &protoFiles_zjhl_v3.GNSSStatistic{}}
}
return dataDefinitionStatisticData

2
configFiles/config_知物云果子沟_中交华联_特征数据.yaml

@ -16,7 +16,7 @@ monitor:
#振动是触发式,数据迟缓 cron10min也改成1小时一次 最多上报6条,不进行10min实时上报
cron10min: 29 0/1 * * * #6/10 * * * *
#普通类型 特征数据
cron1hour: 06 0/1 * * *
cron1hour: 07 0/1 * * *
info:
rc4key: t/gzgyy0219
queryComponent:

801
consumers/GZG2ZJHL/protoFiles_zjhl/MonitorDataProtocol-V1.3.1.proto

@ -1,801 +0,0 @@
/*
* Version 1.3.1
* 创建时间 2023–10-11
*/
// 指定protobuf的版本,proto3是最新的语法版本
syntax = "proto3";
option go_package = "../protoFiles_zjhl";
package protoFiles_zjhl;
enum DataType {REALTIME = 0;STATISTICS = 1; EMERGENCY = 2; INSPECTION = 3;}
enum MonitoryType {
//风速风向
UAN = 0;
//温湿度
RHS = 1;
//结构空间变形
GNSS = 2;
//振动法索力
VIC = 3;
//直接法索力
DIC = 4 ;
//支座位移、梁端纵向位移
DIS = 5;
//挠度
HPT = 6;
//应变
RSG = 7;
//转角
INC = 8;
//振动
VIB = 9;
//地震
VIE = 10;
//TMD监测
TMD = 11;
//车辆荷载
HSD = 12;
// 结构温度
TMP = 13;
// 雨量
PWS = 14;
//结冰
FRZ = 15;
//路面状况
LMZ = 16;
//支反力
STF = 17;
//基础冲刷
SCO = 18;
//裂缝
CRK = 19;
//腐蚀
COR = 20;
//振动法预应力
VIS = 21;
//直接法预应力
STR = 22;
//断丝
BRK = 23;
//螺栓紧固力
BTF = 24;
//索夹滑移
CSP = 25;
//能见度
VSB = 26;
//大气浓度
ACN = 27;
//水位
WLV = 28;
//通用
CMM = 99;
}
//复合类型
message ComplexData{
//各个监测数据组成的数据,解开后循环解析,生成CRC后进行加密
repeated DataDefinition sensorData = 1;
}
//定义数据内容
message DataDefinition{
DataType dataType = 1;
//不传该字段
string bridgeCode = 14;
oneof dataBody{
//实时数据
RealTimeData realTimeData = 2;
//特征值表
StatisticData statisticData = 3;
}
}
message RealTimeData{
//监测类型
MonitoryType monitorType = 1;
//测点编码的别名
int64 monitorCode = 2;
//记录时间戳
int64 eventTime = 3;
//采样周期
int32 interval = 100;
oneof dataBody{
//实时数据
//风速风向
UANRealTime uan = 4;
//温湿度
RHSRealTime rhs = 5;
//结构温度
TMPRealTime tmp = 6;
//空间变形
GNSSRealTime gnss = 7;
// 索力
VICRealTime vic = 8;
DICRealTime dic = 9;
// 位移
DISRealTime dis = 10;
//挠度
HPTRealTime hpt = 11;
//静应变
RSGRealTime rsg = 12;
//转角
INCRealTime inc = 13;
//地震船撞
VIERealTime vie = 14;
//TMD
TMDRealTime tmd = 15;
//动力特性
VIBRealTime vib = 16;
//动态称重
HSDRealTime hsd = 17;
// 雨量
PWSRealTime pws = 18;
//结冰
FRZRealTime frz = 19;
//路面状况
LMZRealTime lmz = 20;
//支反力
STFRealTime stf = 21;
//基础冲刷
SCORealTime sco = 22;
//裂缝
CRKRealTime crk = 23;
//腐蚀
CORRealTime cor = 25;
//振动法预应力
VISRealTime vis = 26;
// 直接法预应力
STRRealTime str = 27;
// 断丝
BRKRealTime brk = 28;
// 螺栓紧固力
BTFRealTime btf = 29;
// 索夹滑移
CSPRealTime csp = 30;
// 能见度
VSBRealTime vsb = 31;
//大气浓度
ACNRealTime acn = 32;
//水位
WLVRealTime wlv =33;
}
}
/*
实时数据发送格式
*/
//风速风向的指标hsd
message UANRealTime{
//风速
float windVelocity = 1;
//风向
float windDirection = 2;
//风攻角
optional float windAttackAngle = 3;
}
//温湿度指标
message RHSRealTime{
//温度
float temperature = 1;
//湿度
float humidity = 2;
}
//温度指标
message TMPRealTime{
//温度
float temperature = 1;
}
//空间变形
message GNSSRealTime{
//横桥向
float x = 1;
//纵桥向
float y = 2;
//竖向
float z = 3;
}
//索力监测
message VICRealTime{
//索力值
float cableForce = 1;
//基频
optional float fundamentalFrequency = 2;
}
//位移(支座位移、梁端纵向位移)
message DISRealTime{
//位移值
float displacement = 1;
//如传感器有温度数据
optional float temperature = 2;
}
//裂缝
message CRKRealTime{
//裂缝宽度
float crackWidth = 1;
//如传感器有温度数据
optional float temperature = 2;
}
//挠度监测
message HPTRealTime{
//挠度值
float deflection = 1;
//如传感器有温度数据
optional float temperature = 2;
}
//静应变监测
message RSGRealTime{
//应变值
float strain = 1;
//如传感器有温度数据
optional float temperature = 2;
}
//梁端转角监测
message INCRealTime{
// 横桥向X
float x = 1;
//纵桥向Y
float y = 2;
//如传感器有温度数据
repeated float temperature = 3 [packed = true];
}
//一秒钟内动力特性
message VIBRealTime{
repeated float monitorValues = 1 [packed = true];
}
//一秒钟内地震船撞
message VIERealTime{
//多通道监测值
repeated float monitorValues = 1 [packed = true];
}
//一秒钟内TMD
message TMDRealTime{
repeated float monitorValues = 1 [packed = true];
}
// 车辆荷载 --动态称重
message HSDRealTime{
//车道号
int32 laneId = 1;
//上下行
int32 operDirec = 2;
//轴数
int32 axleNum = 3;
//轴组数
int32 axleGrpNum = 4;
//车重
int32 grossLoad = 5;
//车型
int32 vehType = 6;
//左1轮重
int32 leftWheelWeight1 = 7;
//左2轮重
int32 leftWheelWeight2 = 8;
//左3轮重
int32 leftWheelWeight3 = 9;
//左4轮重
int32 leftWheelWeight4 = 10;
//左5轮重
int32 leftWheelWeight5 = 11;
//左6轮重
int32 leftWheelWeight6 = 12;
//左7轮重
int32 leftWheelWeight7 = 13;
//左8轮重
int32 leftWheelWeight8 = 14;
//右1轮重
int32 rightWheelWeight1 = 15;
//右2轮重
int32 rightWheelWeight2 = 16;
//右3轮重
int32 rightWheelWeight3 = 17;
//右4轮重
int32 rightWheelWeight4 = 18;
//右5轮重
int32 rightWheelWeight5 = 19;
//右6轮重
int32 rightWheelWeight6 = 20;
//右7轮重
int32 rightWheelWeight7 = 21;
//右8轮重
int32 rightWheelWeight8 = 22;
//轴1-轴2距离
int32 axleDis1 = 23;
//轴2-轴3距离
int32 axleDis2 = 24;
//轴3-轴4距离
int32 axleDis3 = 25;
//轴4-轴5距离
int32 axleDis4 = 26;
//轴5-轴6距离
int32 axleDis5 = 27;
//轴6-轴7距离
int32 axleDis6 = 28;
//轴7-轴8距离
int32 axleDis7 = 29;
//违例码
optional int32 violationId = 30;
//超限标示
optional int32 overloadSign = 31;
//车速
int32 speed = 32;
//加速度
optional float acceleration = 33;
//车辆长度
int32 vehLength = 34;
//当量轴次
optional float qat = 35;
//车牌号
optional string licencePlate = 36;
//车牌颜色
optional string licencePlateColor = 37;
//图片id
optional int32 picId = 38;
//路面温度
optional float roadTemperature = 39;
}
//雨量指标
message PWSRealTime{
//雨量
float rainfall = 1;
}
//结冰监测
message FRZRealTime{
//结冰厚度
float iceThickness = 1 ;
//如传感器有温度数据
float temperature = 2 ;
}
//路面状况监测
message LMZRealTime{
//路面状况
float roadCondition = 1;
//如传感器有温度数据
float temperature = 2;
}
//直接法测索力监测
message DICRealTime{
//索力值
float cableForce = 1;
//如传感器有温度数据
float temperature = 2 ;
}
//支反力监测
message STFRealTime{
//反力值
float supportAction = 1 ;
//如传感器有温度数据
float temperature = 2 ;
}
//基础冲刷监测
message SCORealTime{
//深度
float depth = 1;
}
//腐蚀监测
message CORRealTime{
//氯离子浓度
float chlorideConcentration = 1 ;
//侵蚀深度
float corrosionDepth = 2 ;
}
//振动法预应力监测
message VISRealTime{
//预应力
repeated float monitorValues = 1 [packed = true];
}
//预应力监测
message STRRealTime{
//预应力值
float stress = 1 ;
//如传感器有温度数据
optional float temperature = 2 ;
}
//断丝监测
message BRKRealTime{
//状态
bool state = 1;
}
//螺栓紧固力监测
message BTFRealTime{
//力值
float boltTightForce = 1;
//如传感器有温度数据
optional float temperature = 2;
}
//索夹滑移监测
message CSPRealTime{
//位移值
float displacement = 1 ;
//如传感器有温度数据
optional float temperature = 2;
}
//能见度
message VSBRealTime{
//能见度值
float value = 1;
}
//大气浓度
message ACNRealTime{
//大气浓度最大值
float value = 1;
}
//水位
message WLVRealTime{
//水位
float value = 1;
}
/*
特征值数据协议格式
*/
//特征值
message StatisticData{
//监测类型
MonitoryType monitorType = 1;
//测点编码的别名
int64 monitorCode = 2;
//记录时间戳
int64 eventTime = 3;
//采样周期
int32 interval = 100;
oneof dataBody{
//风速风向
UANStatistic uan = 4;
//温湿度
RHSStatistic rhs = 5;
//结构温度
TMPStatistic tmp = 6;
//空间变形
GNSSStatistic gnss = 7;
// 索力
VICStatistic vic = 8;
// 位移 (支座位移、梁端纵向位移)
DISStatistic dis = 9;
//挠度
HPTStatistic hpt = 10;
//应变
RSGStatistic rsg = 11;
//转角
INCStatistic inc = 12;
//地震船撞
VIEStatistic vie = 13;
//TMD
TMDStatistic tmd = 14;
//动力特性
VIBStatistic vib = 15;
//动态称重
HSDStatistic hsd = 16;
// 位移(锚定位移、拱脚位移、桥墩沉降)监测特征值数据表
ANDStatistic and = 17;
//裂缝
CRKStatistic crk = 18;
//结冰
FRZStatistic frz = 19;
//降雨量
PWSStatistic pws = 20;
//能见度
VSBStatistic vsb = 21;
//大气浓度
ACNStatistic acn = 22;
//水位
WLVStatistic wlv = 23;
//螺杆状态
BTFStatistic btf = 24;
//索夹滑移
CSPStatistic csp = 25;
}
}
//风速风向监测特征值 周期 10min
message UANStatistic{
//统计时间范围内的风速平均值
float avgVelocity = 1;
//统计时间范围内的风向平均值
float avgDirection = 2;
//统计时间范围内的风攻角平均值
optional float avgAttackAngle = 3;
}
//温湿度监测特征值,周期 1h
message RHSStatistic{
//统计时间范围内的温度最大值
float maxTemperature = 1;
//统计时间范围内的温度最小值
float minTemperature = 2;
//统计时间范围内的温度平均值
float avgTemperature = 3;
//统计时间范围内的温差值
float maxTemperatureDifference = 4;
//统计时间范围内的湿度最大值
float maxHumidity = 5;
//统计时间范围内的湿度最小值
float minHumidity = 6;
//统计时间范围内的湿度平均值
float avgHumidity = 7;
//湿度超限持续时间,分钟
int32 humidityExceedDuration = 8;
}
//温度监测特征值 周期 1h
message TMPStatistic{
//统计时间范围内的温度最大值
float maxTemperature = 1;
//统计时间范围内的温度最小值
float minTemperature = 2;
//统计时间范围内的温度平均值
float avgTemperature = 3;
//统计时间范围内的温差值
float maxDifference = 4;
}
//结构空间变形监测特征值 位移(主梁、塔顶、主缆、高墩墩顶、拱顶) 周期: 1h
message GNSSStatistic{
//统计时间范围内的空间变形X绝对最大值
float maxAbsoluteValueX = 1;
//统计时间范围内的空间变形X平均值
float avgValueX = 2;
//统计时间范围内的空间变形X均方根
float rootMeanSquareX = 3;
//统计时间范围内的空间变形Y绝对最大值
float maxAbsoluteValueY = 4;
//统计时间范围内的空间变形Y平均值
float avgValueY = 5;
//统计时间范围内的空间变形Y均方根
float rootMeanSquareY = 6;
//统计时间范围内的空间变形Z绝对最大值
float maxAbsoluteValueZ = 7;
//统计时间范围内的空间变形Z平均值
float avgValueZ = 8;
//统计时间范围内的空间变形Z均方根
float rootMeanSquareZ = 9;
}
// 位移(锚定位移、拱脚位移、桥墩沉降)监测特征值数据表 周期 24h
message ANDStatistic{
//统计时间范围内的空间变形X绝对最大值
float maxAbsoluteValueX = 1;
//统计时间范围内的空间变形X平均值
float avgValueX = 2;
//统计时间范围内的空间变形X均方根
float rootMeanSquareX = 3;
//统计时间范围内的空间变形Y绝对最大值
float maxAbsoluteValueY = 4;
//统计时间范围内的空间变形Y平均值
float avgValueY = 5;
//统计时间范围内的空间变形Y均方根
float rootMeanSquareY = 6;
//统计时间范围内的空间变形Z绝对最大值
float maxAbsoluteValueZ = 7;
//统计时间范围内的空间变形Z平均值
float avgValueZ = 8;
//统计时间范围内的空间变形Z均方根
float rootMeanSquareZ = 9;
}
//位移监测特征值 位移(支座位移、梁端纵向位移) 周期 1h
message DISStatistic{
//统计时间范围内的绝对最大值
float maxAbsoluteValue = 1;
//统计时间范围内的位移平均值
float avgValue = 2;
//统计时间范围内的位移均方根值
float rootMeanSquare = 3;
//统计时间范围内的绝对值累积量
float totalAbsoluteValue = 4;
}
//挠度监测特征值 周期1h
message HPTStatistic{
//统计时间范围内的绝对最大值
float maxAbsoluteValue = 1;
//统计时间范围内的位移平均值
float avgValue = 2;
//统计时间范围内的位移均方根值
float rootMeanSquare = 3;
}
//转角监测特征值 周期 1h
message INCStatistic{
//统计时间范围内横桥向的绝对最大值
float maxAbsoluteValueX = 1;
// 统计时间范围内横桥向的转角平均值
float avgValueX = 2;
//统计时间范围内横桥向的转角均方根值
float rootMeanSquareX = 3;
// 统计时间范围内纵桥向的绝对最大值
float maxAbsoluteValueY = 4;
// 统计时间范围内纵桥向的转角平均值
float avgValueY = 5;
// 统计时间范围内纵桥向的转角均方根值
float rootMeanSquareY = 6;
}
//应变监测特征值 周期 1h
message RSGStatistic{
//统计时间范围内的应变/应力绝对最大值
float maxAbsoluteValue = 1;
//统计时间范围内的应变/应力平均值
float avgValue = 2;
//统计时间范围内的温度平均值
optional float avgTemperature = 3;
}
//索力监测特征值 周期 1h
message VICStatistic{
//统计时间范围内的索力最大值
float maxValue = 1;
// 统计时间范围内的索力最小值
float minValue = 2;
// 统计时间范围内的索力平均值
float avgValue = 3;
// 统计时间范围内的索力均方根值
float rootMeanSquare = 4;
}
//动力特性监测特征值 振动(主梁、索塔、拱圈) 周期 10min
message VIBStatistic{
//统计时间范围内的绝对最大值
float maxAbsoluteValue = 1;
// 统计时间范围内的均方根值
float rootMeanSquare = 2;
}
//地震船撞特性监测特征值 周期10min
message VIEStatistic{
// 统计时间范围内的绝对最大值
float maxAbsoluteValue = 1;
// 统计时间范围内的均方根值
float rootMeanSquare = 2;
}
//TMD监测特征值 周期10min
message TMDStatistic{
//统计时间范围内的绝对最大值
float maxAbsoluteValue = 1;
// 统计时间范围内的均方根值
float rootMeanSquare = 2;
}
//车辆载荷监测特征值 -动态称重 周期 1h
message HSDStatistic{
//统计时间范围内的车流量
int32 trafficFlow = 1;
// 统计时间范围内的最大车重
int32 maxTotalLoad = 2;
// 统计时间范围内的最大轴重
int32 maxAxleLoad = 3;
// 统计时间范围内的超载车数量
int32 overLoadCount = 4;
}
//裂缝监测特征值 位移( 周期 1h)
message CRKStatistic{
//统计时间范围内的绝对最大值
float maxAbsoluteValue = 1;
//统计时间范围内的位移平均值
float avgValue = 2;
//统计时间范围内的位移均方根值
float rootMeanSquare = 3;
//统计时间范围内的绝对值累积量
float totalAbsoluteValue = 4;
}
//结冰(周期 1h)
message FRZStatistic{
//统计时间范围内的结冰最大值
float maxValue = 1;
// 统计时间范围内的结冰最小值
float minValue = 2;
// 统计时间范围内的结冰平均值
float avgValue = 3;
}
//降雨量(周期 10min)
message PWSStatistic{
// 统计时间范围内的降雨量平均值
float avgValue = 1;
}
//能见度(周期 10min)
message VSBStatistic{
// 统计时间范围内的能见度值
float avgValue = 1;
}
//大气浓度(周期 1h)
message ACNStatistic{
//统计时间范围内的大气浓度最大值
float maxValue = 1;
// 统计时间范围内的大气浓度最小值
float minValue = 2;
// 统计时间范围内的大气浓度平均值
float avgValue = 3;
}
//水位(周期 1h)
message WLVStatistic{
//统计时间范围内的水位最大值
float maxValue = 1;
// 统计时间范围内的水位最小值
float minValue = 2;
// 统计时间范围内的水位平均值
float avgValue = 3;
}
//螺杆状态(周期 1h)
message BTFStatistic{
//统计时间范围内的螺杆状态平均值
float avgValue = 1;
// 统计时间范围内的螺杆状态绝对最大值
float maxAbsoluteValue = 2;
// 统计时间范围内的螺杆状态均方根值
float rootMeanSquare = 3;
}
//索夹滑移(周期 1h)
message CSPStatistic{
//统计时间范围内的索夹滑移平均值
float avgValue = 1;
// 统计时间范围内的索夹滑移绝对最大值
float maxAbsoluteValue = 2;
// 统计时间范围内的索夹滑移均方根值
float rootMeanSquare = 3;
}

5329
consumers/GZG2ZJHL/protoFiles_zjhl/MonitorDataProtocol-V1.3.1.pb.go → consumers/GZG2ZJHL/protoFiles_zjhl/protoFiles_zjhl_v3/MonitorDataProtocol-Ministry-v3.0.pb.go

File diff suppressed because it is too large

2
consumers/consumerGZG2ZJHL.go

@ -145,6 +145,7 @@ func (the *consumerGZG2ZJHL) getEs1HourAggData() {
needPushes := adaptor.Transform(structId, factorId, esAggResultStr)
for i := range needPushes {
needPushes[i].Payload = the.crc16rc4(needPushes[i].Payload)
println("mqtt 推送报文=", hex.EncodeToString(needPushes[i].Payload))
}
if len(needPushes) > 0 {
@ -199,6 +200,7 @@ func (the *consumerGZG2ZJHL) crc16rc4(transBytes []byte) []byte {
cipher1.XORKeyStream(dest1, needRC4)
return dest1
}
func (the *consumerGZG2ZJHL) getESQueryStrByHour(structureId int64, factorId int, start, end string) string {
aggSubSql := getEsAggSubSqlByZwyFactorId(factorId)
esQuery := fmt.Sprintf(`

109
main_test.go

@ -4,8 +4,11 @@ import (
"bytes"
"crypto/rc4"
"encoding/hex"
"encoding/json"
"fmt"
"goInOut/consumers/GZG2ZJHL/protoFiles_zjhl"
"goInOut/utils"
"google.golang.org/protobuf/proto"
"log"
"sync"
"testing"
@ -16,7 +19,7 @@ import (
func TestCRC16CCITT(t *testing.T) {
hexs := "0a16080718a8ea8fab06620c0a0471bd54c11204e01d8641"
hexs = "0a2f080210f8b6d5d01218b395bffec3313a1e0a08a75fed41a75fed41120892c5d64292c5d6421a08f6c8a74379c9a743"
hexs = "0a3508011a1c10c7e84318959a9eb5d332220f69cdcc8c3f15333353401dcdcc0c40721331313131313131313131313131313131313131"
Hexdata, _ := hex.DecodeString(hexs)
crc := utils.NewCRC16CCITT().GetWCRCin(Hexdata)
log.Println(hex.EncodeToString(crc))
@ -28,17 +31,119 @@ func TestCRC16CCITT(t *testing.T) {
cipher1.XORKeyStream(dest1, needRC4)
log.Printf("最终报文 dest1=%s", hex.EncodeToString(dest1))
}
func TestCRC16CCITT2(t *testing.T) {
//果子沟
hexs := "0a3508011a1c10c7e84318e6b4e3b6d332220f0dcdcc8c3f15333353401dcdcc0c40721331313131313131313131313131313131313131"
HexData, _ := hex.DecodeString(hexs)
crc := utils.NewCRC16CCITT().GetWCRCin(HexData)
log.Println("crc=", hex.EncodeToString(crc))
log.Println("===1==")
needRC4 := append(HexData, crc...)
rc4Key := []byte("t/gzgyy0219")
dest1 := make([]byte, len(needRC4))
cipher1, _ := rc4.NewCipher(rc4Key)
cipher1.XORKeyStream(dest1, needRC4)
log.Printf("最终报文 dest1=%s", hex.EncodeToString(dest1))
}
func TestRC4(t *testing.T) {
rc4Key := []byte("t/500101")
log.Println("===2 test RC4==")
cipher2, _ := rc4.NewCipher(rc4Key)
raw := "0a2f080210f8b6d5d01218b395bffec3313a1e0a08a75fed41a75fed41120892c5d64292c5d6421a08f6c8a74379c9a743864c"
log.Println("原始报文 raw=", raw)
needRC4New, _ := hex.DecodeString(raw)
dest2 := make([]byte, len(needRC4New))
cipher2.XORKeyStream(dest2, needRC4New)
log.Printf("最终报文 dest1=%s", hex.EncodeToString(dest2))
}
func TestRC42(t *testing.T) {
rc4Key := []byte("t/gzgyy0219")
cipher2, _ := rc4.NewCipher(rc4Key)
raw := "0a3508011a1c10c7e84318959a9eb5d332220f69cdcc8c3f15333353401dcdcc0c407213313131313131313131313131313131313131310ea8"
log.Println("原始报文 raw=", raw)
needRC4New, _ := hex.DecodeString(raw)
dest2 := make([]byte, len(needRC4New))
cipher2.XORKeyStream(dest2, needRC4New)
log.Printf("最终报文 dest1=%s", hex.EncodeToString(dest2))
}
func TestDeRC4(b *testing.T) {
//rawStr := "115 75 64 219 28 135 13 201 130 163 32 82 47 39 63 225 28 87 107 175 184 7 177 47 201 105 189 124 131 171 56 167 196 44 45 48 168 223 209 197 214 169 113 3 71 223 30 246 205 130 44 81 145 106 71 230 225"
//var needRC4 []byte
//rawStrByte := strings.Split(rawStr, " ")
//
//for _, bis := range rawStrByte {
// distInt, _ := strconv.Atoi(bis)
// needRC4 = append(needRC4, byte(distInt))
//}
rawNeedRC4 := "735740db1cbe15037a55947d2ea192b2c5d2cc15476b3bf00859bc20ceb6f52b89715f2339aec5f4e7d801e953 "
needRC4, _ := hex.DecodeString(rawNeedRC4)
println("raw反解析 hex=", rawNeedRC4)
rc4KeyStr := "t/gzgyy0219"
rc4Key := []byte(rc4KeyStr) //the.RC4Key
// 加密操作
dest1 := make([]byte, len(needRC4))
rc4.NewCipher(rc4Key)
cipher1, _ := rc4.NewCipher(rc4Key)
cipher1.XORKeyStream(dest1, needRC4)
rawWithCrc16byte := hex.EncodeToString(dest1)
println("带crc", rawWithCrc16byte)
RawBytesNoCrc := dest1[:len(dest1)-2]
println("无crc", hex.EncodeToString(RawBytesNoCrc))
println("=========")
complexData := &protoFiles_zjhl.ComplexData{}
err := proto.Unmarshal(RawBytesNoCrc, complexData)
if err != nil {
println(err.Error())
}
bs, _ := json.Marshal(complexData)
str := string(bs)
println("原结构", str)
}
func TestDeRC4_2(b *testing.T) {
rawNeedRC4 := "735740db1cbe15037a55947d2ea192b2c5d2cc15476b3bf00859bc20ceb6f52b89715f2339aec5f4e7d801e953"
needRC4, _ := hex.DecodeString(rawNeedRC4)
println("raw反解析 hex=", rawNeedRC4)
rc4KeyStr := "t/gzgyy0219"
rc4Key := []byte(rc4KeyStr) //the.RC4Key
// 加密操作
dest1 := make([]byte, len(needRC4))
rc4.NewCipher(rc4Key)
cipher1, _ := rc4.NewCipher(rc4Key)
cipher1.XORKeyStream(dest1, needRC4)
rawWithCrc16byte := hex.EncodeToString(dest1)
println("带crc", rawWithCrc16byte)
RawBytesNoCrc := dest1[:len(dest1)-2]
println("无crc", hex.EncodeToString(RawBytesNoCrc))
println("=========")
complexData := &protoFiles_zjhl.ComplexData{}
err := proto.Unmarshal(RawBytesNoCrc, complexData)
if err != nil {
println(err.Error())
}
}
func TestProtobufDe(t *testing.T) {
s := "0a3508011a1c10c7e84318e6b4e3b6d332220f0dcdcc8c3f15333353401dcdcc0c40721331313131313131313131313131313131313131"
bs, _ := hex.DecodeString(s)
complexData := &protoFiles_zjhl.ComplexData{}
err := proto.Unmarshal(bs, complexData)
if err != nil {
println(err.Error())
}
}
func TestTemplate(t *testing.T) {
Create := func(name, t string) *template.Template {

Loading…
Cancel
Save