1.新增字典功能
2.RocketMQ新增治理消息模板
This commit is contained in:
@@ -38,6 +38,9 @@ public interface ServerInfo {
|
||||
String CS_HARMONIC_BOOT = "cs-harmonic-boot";
|
||||
|
||||
String CS_REPORT_BOOT = "cs-report-boot";
|
||||
String CS_STAT_BOOT = "stat-boot";
|
||||
String CS_RT_BOOT = "rt-boot";
|
||||
String CS_ZL_EVENT_BOOT = "zl-event-boot";
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -473,5 +473,56 @@ public class PubUtils {
|
||||
return new String(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将字节数组转成Float数组
|
||||
* @param bytes
|
||||
* @return
|
||||
*/
|
||||
public static List<Float> byteArrayToFloatList(byte[] bytes){
|
||||
List<Float> d = new ArrayList<>(bytes.length/8);
|
||||
byte[] doubleBuffer = new byte[4];
|
||||
for(int j = 0; j < bytes.length; j += 4) {
|
||||
System.arraycopy(bytes, j, doubleBuffer, 0, doubleBuffer.length);
|
||||
d.add(bytes2Float(doubleBuffer));
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
public static float bytes2Float(byte[] arr) {
|
||||
int accum = 0;
|
||||
accum = accum|(arr[0] & 0xff);
|
||||
accum = accum|(arr[1] & 0xff) << 8;
|
||||
accum = accum|(arr[2] & 0xff) << 16;
|
||||
accum = accum|(arr[3] & 0xff) << 24;
|
||||
return Float.intBitsToFloat(accum);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将字节数组转成Double数组
|
||||
* @param arr
|
||||
* @return
|
||||
*/
|
||||
public static List<Double> byteArrayToDoubleList(byte[] arr){
|
||||
List<Double> d = new ArrayList<>(arr.length/8);
|
||||
byte[] doubleBuffer = new byte[8];
|
||||
for(int j = 0; j < arr.length; j += 8) {
|
||||
System.arraycopy(arr, j, doubleBuffer, 0, doubleBuffer.length);
|
||||
d.add(bytes2Double(doubleBuffer));
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将byte转换成double
|
||||
* @param arr
|
||||
* @return
|
||||
*/
|
||||
public static double bytes2Double(byte[] arr) {
|
||||
long value = 0;
|
||||
for (int i = 0; i < 8; i++) {
|
||||
value |= ((long) (arr[i] & 0xff)) << (8 * i);
|
||||
}
|
||||
return Double.longBitsToDouble(value);
|
||||
}
|
||||
//***************************************************添加结束********************************************************
|
||||
}
|
||||
|
||||
@@ -12,4 +12,13 @@ public interface BusinessTopic {
|
||||
*/
|
||||
String NJCJ_USER_TOPIC = "njcnUserTopic";
|
||||
|
||||
/**
|
||||
* 治理主送推送数据接收主题
|
||||
*/
|
||||
String NJCJ_APP_AUTO_DATA_TOPIC = "njcnAppAutoDataTopic";
|
||||
|
||||
/**
|
||||
* 治理事件接收主题
|
||||
*/
|
||||
String NJCJ_APP_EVENT_TOPIC = "njcnAppEventTopic";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.njcn.mq.message;
|
||||
|
||||
import com.njcn.middle.rocket.domain.BaseMessage;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/8/11 15:06
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class AppAutoDataMessage extends BaseMessage {
|
||||
|
||||
@ApiModelProperty("网络设备码")
|
||||
private String id;
|
||||
|
||||
private Integer mid;
|
||||
|
||||
@ApiModelProperty("逻辑设备 治理逻辑设备为1 电能质量设备为2")
|
||||
private Integer did;
|
||||
|
||||
private Integer pri;
|
||||
|
||||
private Integer type;
|
||||
|
||||
private Msg msg;
|
||||
|
||||
@Data
|
||||
public static class Msg{
|
||||
|
||||
@ApiModelProperty("逻辑子设备 治理逻辑设备为0 电能质量设备为1、2")
|
||||
private Integer clDid;
|
||||
|
||||
private Integer dataType;
|
||||
|
||||
@ApiModelProperty("数据属性:无-0、实时-1、统计-2")
|
||||
private Integer dataAttr;
|
||||
|
||||
private Integer dsNameIdx;
|
||||
|
||||
private List<DataArray> dataArray;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class DataArray{
|
||||
|
||||
@ApiModelProperty("数据属性 1-Max 2-Min 3-Avg 4-Cp95")
|
||||
private Integer dataAttr;
|
||||
|
||||
private Long dataTimeSec;
|
||||
|
||||
private Integer dataTimeUSec;
|
||||
|
||||
@ApiModelProperty("数据是否参与合格率统计")
|
||||
private Integer dataTag;
|
||||
|
||||
private String data;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.njcn.mq.template;
|
||||
|
||||
import com.njcn.middle.rocket.template.RocketMQEnhanceTemplate;
|
||||
import com.njcn.mq.constant.BusinessTopic;
|
||||
import com.njcn.mq.message.AppAutoDataMessage;
|
||||
import org.apache.rocketmq.client.producer.SendResult;
|
||||
import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/8/11 15:28
|
||||
*/
|
||||
@Component
|
||||
public class AppAutoDataMessageTemplate extends RocketMQEnhanceTemplate {
|
||||
|
||||
public AppAutoDataMessageTemplate(RocketMQTemplate template) {
|
||||
super(template);
|
||||
}
|
||||
|
||||
public SendResult sendMember(AppAutoDataMessage appAutoDataMessage) {
|
||||
return send(BusinessTopic.NJCJ_APP_AUTO_DATA_TOPIC, "CREATE", appAutoDataMessage);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user