新增websocket通信(中继服务同步相关)
parent
24739fb392
commit
7ed62f3b38
@ -0,0 +1,8 @@
|
|||||||
|
package com.glxp.api.constant;
|
||||||
|
|
||||||
|
public interface SocketMsgType {
|
||||||
|
|
||||||
|
|
||||||
|
String DL_ALL_DATA = "DL_ALL_DATA"; //生产入库
|
||||||
|
String DL_NOTICE = "DL_NOTICE"; //通知类消息
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package com.glxp.api.entity.sync;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* websocket 消息体
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class SocketMsgEntity {
|
||||||
|
private String type;
|
||||||
|
private String content;
|
||||||
|
private String remark;
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
package com.glxp.api.util;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
|
import com.beust.jcommander.internal.Lists;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ByteArraySplitter {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对String分片转换为List<byte[]>
|
||||||
|
*
|
||||||
|
* @param source 字符串
|
||||||
|
* @param size 分片的长度 单位字节
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static List<byte[]> split(String source, int size) {
|
||||||
|
// 存放最终结果
|
||||||
|
List<byte[]> result = Lists.newArrayList();
|
||||||
|
|
||||||
|
if (StringUtils.isEmpty(source)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
byte[] sourceBytes = source.getBytes();
|
||||||
|
if (size > sourceBytes.length) {
|
||||||
|
result.add(sourceBytes);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
// 开始进行split
|
||||||
|
int startIndex = 0;
|
||||||
|
int endIndex = sourceBytes.length - 1;
|
||||||
|
boolean isRunning = true;
|
||||||
|
while (isRunning) {
|
||||||
|
if ((endIndex + 1) - startIndex > size) {
|
||||||
|
result.add(ArrayUtil.sub(sourceBytes, startIndex, startIndex + size));
|
||||||
|
startIndex += size;
|
||||||
|
} else {
|
||||||
|
result.add(ArrayUtil.sub(sourceBytes, startIndex, endIndex + 1));
|
||||||
|
isRunning = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue