初始版本提交

This commit is contained in:
hzj
2025-01-21 16:22:57 +08:00
parent 04e3f48da8
commit 16f15b7cdd
6 changed files with 69 additions and 85 deletions

View File

@@ -22,11 +22,7 @@
<artifactId>common-core</artifactId> <artifactId>common-core</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>common-db</artifactId>
<version>${project.version}</version>
</dependency>
<dependency> <dependency>
<groupId>com.njcn</groupId> <groupId>com.njcn</groupId>
<artifactId>common-microservice</artifactId> <artifactId>common-microservice</artifactId>

View File

@@ -40,22 +40,22 @@ public class BeanVConverter {
// dataV.setRmscaCp95(); // dataV.setRmscaCp95();
//根据电压偏差正负赋值 //根据电压偏差正负赋值
if (messageDataV.getDeltaV() >= 0) { if (Objects.nonNull(messageDataV.getDeltaV())&&messageDataV.getDeltaV() >= 0) {
dataVRelation.setVlDev(messageDataV.getDeltaV()); dataVRelation.setVlDev(messageDataV.getDeltaV());
} else { } else {
dataVRelation.setVuDev(messageDataV.getDeltaV()); dataVRelation.setVuDev(messageDataV.getDeltaV());
} }
if (messageDataV.getGDeltaV() >= 0) { if (Objects.nonNull(messageDataV.getGDeltaV())&&messageDataV.getGDeltaV() >= 0) {
dataVRelation.setVlDevCp95(messageDataV.getGDeltaV()); dataVRelation.setVlDevCp95(messageDataV.getGDeltaV());
} else { } else {
dataVRelation.setVuDevCp95(messageDataV.getGDeltaV()); dataVRelation.setVuDevCp95(messageDataV.getGDeltaV());
} }
if (messageDataV.getDeltaV() >= 0) { if (Objects.nonNull(messageDataV.getMaxDeltaV())&&messageDataV.getMaxDeltaV() >= 0) {
dataVRelation.setVlDevMax(messageDataV.getDeltaV()); dataVRelation.setVlDevMax(messageDataV.getDeltaV());
} else { } else {
dataVRelation.setVuDevMax(messageDataV.getDeltaV()); dataVRelation.setVuDevMax(messageDataV.getDeltaV());
} }
if (messageDataV.getDeltaV() >= 0) { if (Objects.nonNull(messageDataV.getMinDeltaV())&&messageDataV.getMinDeltaV() >= 0) {
dataVRelation.setVlDevMin(messageDataV.getDeltaV()); dataVRelation.setVlDevMin(messageDataV.getDeltaV());
} else { } else {
dataVRelation.setVuDevMin(messageDataV.getDeltaV()); dataVRelation.setVuDevMin(messageDataV.getDeltaV());

View File

@@ -33,11 +33,6 @@
<artifactId>common-swagger</artifactId> <artifactId>common-swagger</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>2.0.5</version>
</dependency>
<dependency> <dependency>
<groupId>com.njcn.platform</groupId> <groupId>com.njcn.platform</groupId>
<artifactId>message-api</artifactId> <artifactId>message-api</artifactId>
@@ -49,18 +44,26 @@
<artifactId>data-processing-api</artifactId> <artifactId>data-processing-api</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
<scope>compile</scope> <scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>common-db</artifactId>
<groupId>com.njcn</groupId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.njcn.platform</groupId> <groupId>com.njcn.platform</groupId>
<artifactId>stat-api</artifactId> <artifactId>stat-api</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
<scope>compile</scope> <scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>common-db</artifactId>
<groupId>com.njcn</groupId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
<version>3.5.1</version>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@@ -23,11 +23,6 @@
<artifactId>common-core</artifactId> <artifactId>common-core</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>common-db</artifactId>
<version>${project.version}</version>
</dependency>
<dependency> <dependency>
<groupId>com.njcn</groupId> <groupId>com.njcn</groupId>
<artifactId>common-microservice</artifactId> <artifactId>common-microservice</artifactId>

View File

@@ -33,26 +33,6 @@
<artifactId>common-swagger</artifactId> <artifactId>common-swagger</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>2.0.5</version>
</dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>common-swagger</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>common-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>common-db</artifactId>
<version>${project.version}</version>
</dependency>
<dependency> <dependency>
<groupId>com.njcn</groupId> <groupId>com.njcn</groupId>
<artifactId>common-redis</artifactId> <artifactId>common-redis</artifactId>
@@ -64,11 +44,11 @@
<artifactId>rocket-mq-springboot-starter</artifactId> <artifactId>rocket-mq-springboot-starter</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
</dependency> </dependency>
<dependency> <!-- <dependency>-->
<groupId>com.baomidou</groupId> <!-- <groupId>com.baomidou</groupId>-->
<artifactId>dynamic-datasource-spring-boot-starter</artifactId> <!-- <artifactId>dynamic-datasource-spring-boot-starter</artifactId>-->
<version>3.5.1</version> <!-- <version>3.5.1</version>-->
</dependency> <!-- </dependency>-->
<dependency> <dependency>
<groupId>com.njcn.platform</groupId> <groupId>com.njcn.platform</groupId>
<artifactId>message-api</artifactId> <artifactId>message-api</artifactId>
@@ -78,6 +58,12 @@
<groupId>com.njcn.platform</groupId> <groupId>com.njcn.platform</groupId>
<artifactId>stat-api</artifactId> <artifactId>stat-api</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
<exclusions>
<exclusion>
<artifactId>common-db</artifactId>
<groupId>com.njcn</groupId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.njcn.platform</groupId> <groupId>com.njcn.platform</groupId>
@@ -89,17 +75,21 @@
<artifactId>rt-api</artifactId> <artifactId>rt-api</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
</dependency> </dependency>
<dependency> <!-- <dependency>-->
<groupId>com.njcn</groupId> <!-- <groupId>com.njcn</groupId>-->
<artifactId>pq-device-api</artifactId> <!-- <artifactId>pq-device-api</artifactId>-->
<version>1.0.0</version> <!-- <version>1.0.0</version>-->
<exclusions> <!-- <exclusions>-->
<exclusion> <!-- <exclusion>-->
<artifactId>pqs-influx</artifactId> <!-- <artifactId>pqs-influx</artifactId>-->
<groupId>com.njcn</groupId> <!-- <groupId>com.njcn</groupId>-->
</exclusion> <!-- </exclusion>-->
</exclusions> <!--&lt;!&ndash; <exclusion>&ndash;&gt;-->
</dependency> <!--&lt;!&ndash; <artifactId>common-db</artifactId>&ndash;&gt;-->
<!--&lt;!&ndash; <groupId>com.njcn</groupId>&ndash;&gt;-->
<!--&lt;!&ndash; </exclusion>&ndash;&gt;-->
<!-- </exclusions>-->
<!-- </dependency>-->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId> <artifactId>spring-boot-starter-websocket</artifactId>

View File

@@ -30,7 +30,7 @@ import java.util.concurrent.ConcurrentHashMap;
*/ */
@Slf4j @Slf4j
@Component @Component
@ServerEndpoint(value ="/api/pushMessage/{userIdAndlineId}") @ServerEndpoint(value ="/api/pushMessage/{userIdAndLineIdAndDevId}")
public class WebSocketServer { public class WebSocketServer {
@@ -46,13 +46,13 @@ public class WebSocketServer {
} }
private static LineFeignClient lineFeignClient; // private static LineFeignClient lineFeignClient;
//
// 注入的时候,给类的 service 注入 // // 注入的时候,给类的 service 注入
@Autowired // @Autowired
public void setLineFeignClient(LineFeignClient lineFeignClient) { // public void setLineFeignClient(LineFeignClient lineFeignClient) {
WebSocketServer.lineFeignClient = lineFeignClient; // WebSocketServer.lineFeignClient = lineFeignClient;
} // }
/** /**
* 静态变量,用来记录当前在线连接数。应该把它设计成线程安全的。 * 静态变量,用来记录当前在线连接数。应该把它设计成线程安全的。
*/ */
@@ -68,24 +68,24 @@ public class WebSocketServer {
/** /**
* 接收userId * 接收userId
*/ */
private String userIdAndlineId = ""; private String userIdAndLineIdAndDevId = "";
/** /**
* 连接建立成 * 连接建立成
* 功调用的方法 * 功调用的方法
*/ */
@OnOpen @OnOpen
public void onOpen(Session session, @PathParam("userIdAndlineId") String userIdAndlineId) { public void onOpen(Session session, @PathParam("userIdAndLineIdAndDevId") String userIdAndLineIdAndDevId) {
//lineId 是 userid+","+lineId //lineId 是 userid+","+lineId+","+Devid
this.session = session; this.session = session;
this.userIdAndlineId = userIdAndlineId; this.userIdAndLineIdAndDevId = userIdAndLineIdAndDevId;
if (webSocketMap.containsKey(userIdAndlineId)) { if (webSocketMap.containsKey(userIdAndLineIdAndDevId)) {
webSocketMap.remove(userIdAndlineId); webSocketMap.remove(userIdAndLineIdAndDevId);
//加入set中 //加入set中
webSocketMap.put(userIdAndlineId, this); webSocketMap.put(userIdAndLineIdAndDevId, this);
} else { } else {
//加入set中 //加入set中
webSocketMap.put(userIdAndlineId, this); webSocketMap.put(userIdAndLineIdAndDevId, this);
//在线数加1 //在线数加1
addOnlineCount(); addOnlineCount();
} }
@@ -100,12 +100,12 @@ public class WebSocketServer {
*/ */
@OnClose @OnClose
public void onClose() { public void onClose() {
if (webSocketMap.containsKey(userIdAndlineId)) { if (webSocketMap.containsKey(userIdAndLineIdAndDevId)) {
webSocketMap.remove(userIdAndlineId); webSocketMap.remove(userIdAndLineIdAndDevId);
//从set中删除 //从set中删除
subOnlineCount(); subOnlineCount();
} }
log.info("监测点退出:" + userIdAndlineId + ",当前在线监测点数为:" + getOnlineCount()); log.info("监测点退出:" + userIdAndLineIdAndDevId + ",当前在线监测点数为:" + getOnlineCount());
} }
/** /**
@@ -117,20 +117,20 @@ public class WebSocketServer {
@OnMessage @OnMessage
public void onMessage(String message, Session session) { public void onMessage(String message, Session session) {
//会每30s发送请求1次 //会每30s发送请求1次
log.info("监测点消息:" + userIdAndlineId + ",报文:" + message); log.info("监测点消息:" + userIdAndLineIdAndDevId + ",报文:" + message);
AskRealDataMessage askRealDataMessage = new AskRealDataMessage(); AskRealDataMessage askRealDataMessage = new AskRealDataMessage();
String[] split = userIdAndlineId.split(","); String[] split = userIdAndLineIdAndDevId.split(",");
askRealDataMessage.setLine(split[1]); askRealDataMessage.setLine(split[1]);
//测试设备187 //测试设备187
// askRealDataMessage.setDevSeries("fed656b21f89abb06204e8e4dc6c375a"); // askRealDataMessage.setDevSeries("fed656b21f89abb06204e8e4dc6c375a");
LineDetailDataVO data = lineFeignClient.getLineDetailData(split[1]).getData(); // LineDetailDataVO data = lineFeignClient.getLineDetailData(split[1]).getData();
askRealDataMessage.setDevSeries(data.getDevId()); askRealDataMessage.setDevSeries(split[2]);
BaseMessage baseMessage = new BaseMessage(); BaseMessage baseMessage = new BaseMessage();
baseMessage.setMessageBoy(JSONObject.toJSONString(askRealDataMessage)); baseMessage.setMessageBoy(JSONObject.toJSONString(askRealDataMessage));
// 发送消息到topic1 // 发送消息到topic1
askRealDataMessaggeTemplate.sendMember(baseMessage); askRealDataMessaggeTemplate.sendMember(baseMessage);
redisUtil.saveByKey("AskRealData:".concat(split[1]),"AskRealData:".concat(split[1])); redisUtil.saveByKey("AskRealData:".concat(split[1]),"AskRealData:".concat(split[1]));
log.info("监测点连接:" + userIdAndlineId + ",当前在线监测点数为:" + getOnlineCount()); log.info("监测点连接:" + userIdAndLineIdAndDevId + ",当前在线监测点数为:" + getOnlineCount());
} }
@@ -142,7 +142,7 @@ public class WebSocketServer {
@OnError @OnError
public void onError(Session session, Throwable error) { public void onError(Session session, Throwable error) {
log.error("监测点错误:" + this.userIdAndlineId + ",原因:" + error.getMessage()); log.error("监测点错误:" + this.userIdAndLineIdAndDevId + ",原因:" + error.getMessage());
error.printStackTrace(); error.printStackTrace();
} }