|
@@ -10,9 +10,6 @@ import com.gyee.ygys.protocol.BitMapMessage;
|
|
import com.gyee.ygys.utils.BytesUtil;
|
|
import com.gyee.ygys.utils.BytesUtil;
|
|
import com.rtdb.api.callbackInter.RSDataChangeEx;
|
|
import com.rtdb.api.callbackInter.RSDataChangeEx;
|
|
import com.rtdb.api.model.RtdbData;
|
|
import com.rtdb.api.model.RtdbData;
|
|
-import com.rtdb.api.util.DateUtil;
|
|
|
|
-import com.rtdb.enums.DataSort;
|
|
|
|
-import com.rtdb.model.SearchCondition;
|
|
|
|
import com.rtdb.service.impl.ServerImpl;
|
|
import com.rtdb.service.impl.ServerImpl;
|
|
import com.rtdb.service.impl.SnapshotImpl;
|
|
import com.rtdb.service.impl.SnapshotImpl;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -21,8 +18,8 @@ import org.springframework.kafka.core.KafkaTemplate;
|
|
import org.springframework.scheduling.annotation.Async;
|
|
import org.springframework.scheduling.annotation.Async;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
+import java.io.IOException;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
-import java.util.concurrent.ConcurrentLinkedQueue;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
@@ -54,7 +51,7 @@ public class CalculateServer {
|
|
private HashMap<Integer, TagPoint> tagPointMap;
|
|
private HashMap<Integer, TagPoint> tagPointMap;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
- private KafkaTemplate<String, BitMapMessage> messageKafkaTemplate;
|
|
|
|
|
|
+ private KafkaTemplate<String, byte[]> messageKafkaTemplate;
|
|
|
|
|
|
public boolean start() {
|
|
public boolean start() {
|
|
if (serverStarted) {
|
|
if (serverStarted) {
|
|
@@ -134,9 +131,17 @@ public class CalculateServer {
|
|
|
|
|
|
@Async
|
|
@Async
|
|
void publishRstdData(RtdbData[] goldenDatas) {
|
|
void publishRstdData(RtdbData[] goldenDatas) {
|
|
|
|
+
|
|
|
|
+
|
|
BitMapMessage msg = createBitMapMessage(goldenDatas);
|
|
BitMapMessage msg = createBitMapMessage(goldenDatas);
|
|
|
|
+
|
|
//todo: 发送到kafka
|
|
//todo: 发送到kafka
|
|
- messageKafkaTemplate.send("NSSFJ", msg);
|
|
|
|
|
|
+ try {
|
|
|
|
+ //byte[] bytes = msg.toBytes();
|
|
|
|
+ messageKafkaTemplate.send("NSSFJ", msg.toBytes());
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -161,10 +166,10 @@ public class CalculateServer {
|
|
if (tpd.getTagPoint().getGroupIndex() != groupIndex) {
|
|
if (tpd.getTagPoint().getGroupIndex() != groupIndex) {
|
|
if (groupIndex != -1) {
|
|
if (groupIndex != -1) {
|
|
//重置datasize
|
|
//重置datasize
|
|
- byte[] tmp = new byte[dataOffset+1];
|
|
|
|
- System.arraycopy(bitMapGroup.getData(),0, tmp,0, dataOffset+1);
|
|
|
|
|
|
+ byte[] tmp = new byte[dataOffset];
|
|
|
|
+ System.arraycopy(bitMapGroup.getData(),0, tmp,0, dataOffset);
|
|
bitMapGroup.setData(tmp);
|
|
bitMapGroup.setData(tmp);
|
|
- bitMapGroup.setGroupLength(dataOffset+bitMapGroup.getBitMapLength() + 5);
|
|
|
|
|
|
+ bitMapGroup.setGroupLength(dataOffset+bitMapGroup.getBitMapLength() + 10);
|
|
}
|
|
}
|
|
|
|
|
|
//创建新的BitMapGroup
|
|
//创建新的BitMapGroup
|
|
@@ -255,10 +260,10 @@ public class CalculateServer {
|
|
}
|
|
}
|
|
|
|
|
|
//最后一个BitMapGroup修改data
|
|
//最后一个BitMapGroup修改data
|
|
- byte[] tmp = new byte[dataOffset+1];
|
|
|
|
- System.arraycopy(bitMapGroup.getData(),0, tmp,0, dataOffset+1);
|
|
|
|
|
|
+ byte[] tmp = new byte[dataOffset];
|
|
|
|
+ System.arraycopy(bitMapGroup.getData(),0, tmp,0, dataOffset);
|
|
bitMapGroup.setData(tmp);
|
|
bitMapGroup.setData(tmp);
|
|
- bitMapGroup.setGroupLength(dataOffset+bitMapGroup.getBitMapLength() + 5);
|
|
|
|
|
|
+ bitMapGroup.setGroupLength(dataOffset+bitMapGroup.getBitMapLength() + 10);
|
|
|
|
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|