Browse Source

update 更新版本到V3

dev
lucas 2 months 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
* 202310-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