You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							65 lines
						
					
					
						
							1.8 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							65 lines
						
					
					
						
							1.8 KiB
						
					
					
				| package adaptors | |
| 
 | |
| import ( | |
| 	"encoding/json" | |
| 	"goInOut/consumers/HBJCAS/protoFiles_hb" | |
| 	"goInOut/models" | |
| 	"google.golang.org/protobuf/proto" | |
| 	"time" | |
| ) | |
| 
 | |
| // Adaptor_AXYES_HBGL 统一采集软件数据 转换 湘潭健康监测平台 | |
| type Adaptor_AXYES_HBGL struct { | |
| 	//传感器code转换信息 | |
| 	GnssMap map[string]string | |
| 	RainMap map[string]string | |
| 	NBWYMap map[string]string | |
| 	DXSWMap map[string]string | |
| 	//一些必要信息 | |
| 	Info map[string]string | |
| } | |
| 
 | |
| func (the Adaptor_AXYES_HBGL) Transform(rawMsg string) []NeedPush { | |
| 	esAggDateHistogram := models.EsThemeAggDateHistogram{} | |
| 	var needPush []NeedPush | |
| 	err := json.Unmarshal([]byte(rawMsg), &esAggDateHistogram) | |
| 	if err != nil { | |
| 		return nil | |
| 	} | |
| 	needPush = append(needPush, NeedPush{ | |
| 		Payload: the.EsAggTopToHBJCAS(esAggDateHistogram), | |
| 	}) | |
| 	return needPush | |
| } | |
| 
 | |
| func (the Adaptor_AXYES_HBGL) EsAggTopToHBJCAS(esAgg models.EsThemeAggDateHistogram) (result []byte) { | |
| 
 | |
| 	Atime := time.Now() | |
| 	QjComplexData := &protoFiles_hb.ComplexData{} | |
| 	dataDefinitionStatisticData := &protoFiles_hb.DataDefinition_StatisticData{ | |
| 		StatisticData: &protoFiles_hb.StatisticData{ | |
| 			MonitorType: protoFiles_hb.MonitoryType_INC, | |
| 			MonitorCode: 13000100001, | |
| 			EventTime:   Atime.Add(-8 * time.Hour).UnixMilli(), | |
| 			Interval:    60 * 1000, | |
| 			DataBody: &protoFiles_hb.StatisticData_Inc{Inc: &protoFiles_hb.INCStatistic{ | |
| 				MaxAbsoluteValueX: 0, | |
| 				AvgValueX:         0, | |
| 				RootMeanSquareX:   0, | |
| 				MaxAbsoluteValueY: 0, | |
| 				AvgValueY:         0, | |
| 				RootMeanSquareY:   0, | |
| 			}}, | |
| 		}, | |
| 	} | |
| 
 | |
| 	dataDefinition := &protoFiles_hb.DataDefinition{ | |
| 		DataType:   protoFiles_hb.DataType_STATISTICS, | |
| 		UniqueCode: "130109", //乃积沟大桥 | |
| 		DataBody:   dataDefinitionStatisticData, | |
| 	} | |
| 
 | |
| 	QjComplexData.SensorData = append(QjComplexData.SensorData, dataDefinition) | |
| 	result, _ = proto.Marshal(QjComplexData) | |
| 	return result | |
| }
 | |
| 
 |