Compare commits
29 Commits
Author | SHA1 | Date |
---|---|---|
|
d22a9f388f | 2 years ago |
|
40cbbe738a | 2 years ago |
|
0e11628791 | 2 years ago |
|
cf4d754740 | 2 years ago |
|
9cce456609 | 2 years ago |
|
4e65d033b5 | 2 years ago |
|
4069cb9eb8 | 2 years ago |
|
b58e177621 | 2 years ago |
|
2336119dac | 2 years ago |
|
66af59182d | 2 years ago |
|
631e9004ab | 2 years ago |
|
3b97f643af | 2 years ago |
|
8f226ed1f8 | 2 years ago |
|
de78944359 | 2 years ago |
|
c5531aa625 | 2 years ago |
|
a917d4d386 | 2 years ago |
|
d9985ab370 | 2 years ago |
|
b8e92dd1b7 | 2 years ago |
|
c946ef8422 | 2 years ago |
|
38416a4755 | 2 years ago |
|
4827b7dd1e | 2 years ago |
|
d826ae4c52 | 2 years ago |
|
cc998fa35a | 2 years ago |
|
5473878bd8 | 2 years ago |
|
004f2a52be | 2 years ago |
|
6371399e09 | 2 years ago |
|
0a2ae9e530 | 2 years ago |
|
bf86451a0c | 2 years ago |
|
791f7bfdde | 2 years ago |
@ -1,12 +0,0 @@
|
|||||||
package com.glxp.sale.admin.config;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
public class WebSocketConfig {
|
|
||||||
@Bean
|
|
||||||
public ServerEndpointExporter serverEndpointExporter() {
|
|
||||||
return new ServerEndpointExporter();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
package com.glxp.sale.admin.constant;
|
|
||||||
|
|
||||||
public interface SocketMsgType {
|
|
||||||
|
|
||||||
|
|
||||||
String DL_ALL_DATA = "DL_ALL_DATA";
|
|
||||||
String BASIC_DATA_DELETE = "BASIC_DATA_DELETE";
|
|
||||||
String BASIC_MANAGE_DELETE = "BASIC_MANAGE_DELETE";
|
|
||||||
|
|
||||||
String BASIC_CORP_MAINTAIN_DELETE = "BASIC_CORP_MAINTAIN_DELETE"; //供应商字典
|
|
||||||
|
|
||||||
String BASIC_BUSINESS_TYPE_DELETE = "BASIC_BUSINESS_TYPE_DELETE"; //单据类型
|
|
||||||
String STAT_DATA_REQUEST = "STAT_DATA_REQUEST"; //汇总日报
|
|
||||||
String STAT_DATA = "STAT_DATA"; //
|
|
||||||
}
|
|
@ -1,80 +0,0 @@
|
|||||||
package com.glxp.sale.admin.entity.sync;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@TableName(value = "code_rel")
|
|
||||||
public class CodeRel {
|
|
||||||
|
|
||||||
|
|
||||||
@TableId(type = IdType.AUTO)
|
|
||||||
public Integer id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 器械最小销售产品标识
|
|
||||||
*/
|
|
||||||
@TableField(value = "diNameCode")
|
|
||||||
public String diNameCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 阿里药品标识码
|
|
||||||
*/
|
|
||||||
@TableField(value = "drugCode")
|
|
||||||
public String drugCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 医保编码
|
|
||||||
*/
|
|
||||||
@TableField(value = "ybbm")
|
|
||||||
public String ybbm;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 阳光采购平台编码
|
|
||||||
*/
|
|
||||||
@TableField(value = "ycCode")
|
|
||||||
public String ycCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 商品条码
|
|
||||||
*/
|
|
||||||
@TableField(value = "sptm")
|
|
||||||
public String sptm;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 药品本位码
|
|
||||||
*/
|
|
||||||
@TableField(value = "ypbwm")
|
|
||||||
public String ypbwm;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 统一社会信用号
|
|
||||||
*/
|
|
||||||
@TableField(value = "tyshxyh")
|
|
||||||
public String tyshxyh;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 国家编码9码
|
|
||||||
*/
|
|
||||||
@TableField(value = "gjbm")
|
|
||||||
public String gjbm;
|
|
||||||
|
|
||||||
@TableField(value = "status")
|
|
||||||
public String status;
|
|
||||||
|
|
||||||
@TableField(value = "updateTime")
|
|
||||||
public Date updateTime;
|
|
||||||
|
|
||||||
@TableField(value = "createTime")
|
|
||||||
public Date createTime;
|
|
||||||
|
|
||||||
@TableField(value = "fromType")
|
|
||||||
public Integer fromType;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
package com.glxp.sale.admin.entity.sync;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* websocket 消息体
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Builder
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class SocketMsgEntity {
|
|
||||||
private String type;
|
|
||||||
private Object content;
|
|
||||||
private String remark;
|
|
||||||
}
|
|
@ -1,34 +0,0 @@
|
|||||||
package com.glxp.sale.admin.socket.client;
|
|
||||||
|
|
||||||
import com.glxp.sale.admin.socket.server.SpsSyncWebSocket;
|
|
||||||
import org.jfree.util.Log;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class SocketMsgService {
|
|
||||||
|
|
||||||
@Value("${SPMS_WEBSOCKET_TOKEN}")
|
|
||||||
String token;
|
|
||||||
@Resource
|
|
||||||
SpsSyncWebSocket spsSyncWebSocket;
|
|
||||||
|
|
||||||
public void sendNoticeMsg(String message) {
|
|
||||||
spsSyncWebSocket.sendMessage(message, "2:" + token);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void sendDeleteMsg(String message) {
|
|
||||||
spsSyncWebSocket.sendMessage(message, "2:" + token);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void sendGetMsg(String message) {
|
|
||||||
Log.error("发送管理系统的信息{}"+message);
|
|
||||||
spsSyncWebSocket.sendMessage(message, "2:" + token);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,127 +0,0 @@
|
|||||||
package com.glxp.sale.admin.socket.client;
|
|
||||||
|
|
||||||
import com.glxp.sale.admin.constant.SocketMsgType;;
|
|
||||||
import org.java_websocket.WebSocket;
|
|
||||||
import org.java_websocket.client.WebSocketClient;
|
|
||||||
import org.java_websocket.framing.Framedata;
|
|
||||||
import org.java_websocket.handshake.ServerHandshake;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import java.net.URI;
|
|
||||||
import java.net.URISyntaxException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class SpsWebSocketClient extends WebSocketClient {
|
|
||||||
|
|
||||||
private String excptMessage;
|
|
||||||
|
|
||||||
Logger log = LoggerFactory.getLogger(SpsWebSocketClient.class);
|
|
||||||
|
|
||||||
private static List<SpsWebSocketClient> list = new ArrayList<>();
|
|
||||||
@Resource
|
|
||||||
SocketMsgService socketMsgService;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void setSocketMsgService(SocketMsgService socketMsgService) {
|
|
||||||
this.socketMsgService = socketMsgService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SpsWebSocketClient(String serverUri) throws URISyntaxException {
|
|
||||||
super(new URI(serverUri));
|
|
||||||
this.setConnectionLostTimeout(0);
|
|
||||||
if (list.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (SpsWebSocketClient client : list) {
|
|
||||||
client.close();
|
|
||||||
}
|
|
||||||
list.clear();
|
|
||||||
list.add(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onOpen(ServerHandshake serverHandshake) {
|
|
||||||
log.info("在线日志socket连接成功");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public synchronized void onMessage(String s) {
|
|
||||||
log.info("收到消息:" + s);
|
|
||||||
//收到更新下载数据则赋值由外部处理,多个任务只处理一次避免重复处理
|
|
||||||
if (s.contains(SocketMsgType.DL_ALL_DATA)) {
|
|
||||||
this.excptMessage = s;
|
|
||||||
} else if (s.contains(SocketMsgType.BASIC_DATA_DELETE)) {
|
|
||||||
socketMsgService.sendDeleteMsg(s);
|
|
||||||
} else if (s.contains(SocketMsgType.BASIC_MANAGE_DELETE)) {
|
|
||||||
socketMsgService.sendDeleteMsg(s);
|
|
||||||
} else if (s.contains(SocketMsgType.BASIC_CORP_MAINTAIN_DELETE)) {
|
|
||||||
socketMsgService.sendDeleteMsg(s);
|
|
||||||
} else if (s.contains(SocketMsgType.BASIC_BUSINESS_TYPE_DELETE)) {
|
|
||||||
socketMsgService.sendDeleteMsg(s);
|
|
||||||
}else if (s.contains(SocketMsgType.STAT_DATA)) {
|
|
||||||
socketMsgService.sendGetMsg(s);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
//通知类消息则需转发
|
|
||||||
socketMsgService.sendNoticeMsg(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClose(int i, String s, boolean b) {
|
|
||||||
log.info("在线日志socket断开");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onWebsocketPing(WebSocket conn, Framedata f) {
|
|
||||||
try {
|
|
||||||
Thread.sleep(1000 * 5);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
send("---pong---");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public static void destroy() {
|
|
||||||
if (list.isEmpty())
|
|
||||||
return;
|
|
||||||
for (SpsWebSocketClient client : list) {
|
|
||||||
client.close();
|
|
||||||
}
|
|
||||||
list.clear();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//发送消息
|
|
||||||
public void sendMessage(String message) {
|
|
||||||
this.send(message);
|
|
||||||
System.out.println("已发送消息:" + message);
|
|
||||||
}
|
|
||||||
|
|
||||||
//获取接收到的信息
|
|
||||||
public String getExcptMessage() {
|
|
||||||
if (excptMessage != null) {
|
|
||||||
String message = new String(excptMessage);
|
|
||||||
excptMessage = null;
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,48 +0,0 @@
|
|||||||
package com.glxp.sale.admin.util;
|
|
||||||
|
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
|
||||||
import com.beust.jcommander.internal.Lists;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
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