win代码上传
parent
f1af214b75
commit
ddfa81b18d
6
pom.xml
6
pom.xml
|
|
@ -226,9 +226,9 @@
|
|||
<version>3.0.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.clojars.zentrope</groupId>
|
||||
<artifactId>ojdbc</artifactId>
|
||||
<version>11.2.0.3.0</version>
|
||||
<groupId>com.oracle</groupId>
|
||||
<artifactId>ojdbc6</artifactId>
|
||||
<version>11.2.0.4.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
|
|
|||
|
|
@ -70,9 +70,9 @@
|
|||
<artifactId>ruoyi-generator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.clojars.zentrope</groupId>
|
||||
<artifactId>ojdbc</artifactId>
|
||||
<version>11.2.0.3.0</version>
|
||||
<groupId>com.oracle</groupId>
|
||||
<artifactId>ojdbc6</artifactId>
|
||||
<version>11.2.0.4.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ public class IdentifierStatusController
|
|||
private IdentifierStatusService identifierStatusService;
|
||||
|
||||
|
||||
private String prefix = "/system/identifierStatus";
|
||||
private String prefix = "system/identifierStatus";
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -2,44 +2,30 @@ package com.ruoyi.web.controller.system;
|
|||
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.ruoyi.common.core.domain.entity.DataResponse;
|
||||
import com.ruoyi.common.core.domain.entity.PrimaryRadarData;
|
||||
import com.ruoyi.common.core.domain.entity.SysIdentifier;
|
||||
import com.ruoyi.common.core.domain.entity.SysRadar;
|
||||
import com.ruoyi.common.core.domain.entity.*;
|
||||
import com.ruoyi.common.core.page.PageDomain;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.page.TableSupport;
|
||||
import com.ruoyi.common.utils.SocketModel;
|
||||
import com.ruoyi.common.utils.SocketUtil;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.bean.BeanUtils;
|
||||
import com.ruoyi.common.utils.bean.ModbusResponse;
|
||||
import com.ruoyi.common.utils.modbus.ModbusUtils;
|
||||
import com.ruoyi.framework.web.domain.server.Sys;
|
||||
import com.ruoyi.system.service.ISysIdentifierService;
|
||||
import com.ruoyi.system.service.ISysRadarService;
|
||||
import com.ruoyi.system.service.PrimaryRadarDataService;
|
||||
import com.ruoyi.system.service.impl.IdentifierStatusServiceImpl;
|
||||
import com.ruoyi.web.core.config.RadarStatusWebSocket;
|
||||
import com.serotonin.modbus4j.ModbusMaster;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.compress.utils.Lists;
|
||||
import com.ruoyi.common.config.RadarStatusWebSocket;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.Inet4Address;
|
||||
import java.net.Socket;
|
||||
import java.net.UnknownHostException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
|
@ -68,8 +54,9 @@ public class RadarStatusController implements InitializingBean {
|
|||
|
||||
public static CopyOnWriteArrayList<SocketModel> allRadar = new CopyOnWriteArrayList<>();
|
||||
|
||||
private String prefix = "system/radarstatus";
|
||||
public static Integer count = 0 ;
|
||||
|
||||
private String prefix = "system/radarstatus";
|
||||
|
||||
/**
|
||||
* 按钮页
|
||||
|
|
@ -79,69 +66,91 @@ public class RadarStatusController implements InitializingBean {
|
|||
return prefix + "/radarstatus";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping("/list")
|
||||
@ResponseBody
|
||||
public TableDataInfo list(@RequestBody SysRadar sysRadar) {
|
||||
TableDataInfo rspData = new TableDataInfo();
|
||||
List<SysRadar> radarList = service.selectRadarList(sysRadar);
|
||||
|
||||
// 异步连接硬件
|
||||
// CompletableFuture<List<ModbusResponse>> listCompletableFuture = CompletableFuture.supplyAsync(() -> {
|
||||
// List<ModbusResponse> responses = new ArrayList<>();
|
||||
// final ConnectionStatus connectionStatus = new ConnectionStatus();
|
||||
// Timer timer = new Timer();
|
||||
// boolean connected = false;
|
||||
// TimerTask task = new TimerTask() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// int year = 2024;
|
||||
// int month = 2; // 8月代表9月,因为月份是从0开始计数的
|
||||
// int day = 25;
|
||||
// java.sql.Date date2 = new java.sql.Date(year - 1900, month - 1, day);
|
||||
// List<TsanaRadar> tsanaRadarList = new ArrayList<>();
|
||||
// TsanaRadar tsanaRadar = new TsanaRadar("111","111","111","111",date2,date2 , 1);
|
||||
// TsanaRadar tsanaRadar1 = new TsanaRadar("222","222","222","222",date2,date2 , 2);
|
||||
// TsanaRadar tsanaRadar2 = new TsanaRadar("333","333","333","333",date2,date2 , 3);
|
||||
// TsanaRadar tsanaRadar3 = new TsanaRadar("444","444","444","444",date2,date2 , 4);
|
||||
// TsanaRadar tsanaRadar4 = new TsanaRadar("555","555","555","555",date2,date2 , 5);
|
||||
// tsanaRadarList.add(tsanaRadar);
|
||||
// tsanaRadarList.add(tsanaRadar1);
|
||||
// tsanaRadarList.add(tsanaRadar2);
|
||||
// tsanaRadarList.add(tsanaRadar3);
|
||||
// tsanaRadarList.add(tsanaRadar4);
|
||||
//
|
||||
// for (SysRadar radar : radarList) {
|
||||
// System.out.println("=======radar=====" + radar.getRadarIp());
|
||||
// Connection connection = null;
|
||||
// PreparedStatement preparedStatement = null;
|
||||
// try {
|
||||
// DataResponse data = SocketUtil.getData(radar.getRadarIp(), 23, radar.getRadarLocation());
|
||||
// System.out.println(radar.getRadarIp() +": "+ data);
|
||||
// ModbusResponse modbusResponse = getModbusResponse(data);
|
||||
// String tag = modbusResponse.getTagId();
|
||||
// PrimaryRadarData primaryRadarData = new PrimaryRadarData();
|
||||
// SysIdentifier sysIdentifier = new SysIdentifier();
|
||||
// BeanUtils.copyProperties(modbusResponse, primaryRadarData);
|
||||
// if (!"0".equals(modbusResponse.getTagId())) {
|
||||
// sysIdentifier = identifierService.selectIdentifierByTag(tag);
|
||||
// primaryRadarData.setLadleNumber(sysIdentifier.getLadleNumber());
|
||||
// primaryRadarData.setRadarLocation(radar.getRadarLocation());
|
||||
// primaryRadarData.setRadarIp(radar.getRadarIp());
|
||||
// } else {
|
||||
// primaryRadarData.setLadleNumber(null);
|
||||
// primaryRadarData.setRadarLocation(null);
|
||||
// primaryRadarData.setRadarIp(radar.getRadarIp());
|
||||
// }
|
||||
// String ip = Inet4Address.getLocalHost().getHostAddress();
|
||||
// if (modbusResponse.getValue4() != null && !"0".equals(modbusResponse.getValue4())) {
|
||||
// primaryRadarDataService.insertPrimaryRadarData(primaryRadarData);
|
||||
// } else {
|
||||
// Class.forName("oracle.jdbc.driver.OracleDriver");
|
||||
//
|
||||
// }
|
||||
// RadarStatusWebSocket.sendToAll(JSON.toJSONString(data));
|
||||
// } catch (Exception e) {
|
||||
//// if (e.equals("java.net.SocketTimeoutException: connect timed out")) {
|
||||
//// System.err.println("从串口读取失败:" + "连接超时");
|
||||
//// }
|
||||
//// DataResponse dataResponse = new DataResponse();
|
||||
//// dataResponse.setRadarIp(radar.getRadarIp());
|
||||
//// dataResponse.setRadarLocation(radar.getRadarLocation());
|
||||
//// dataResponse.setStatus(0);
|
||||
//// RadarStatusWebSocket.sendToAll(JSON.toJSONString(dataResponse));
|
||||
//// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
// timer.scheduleAtFixedRate(task, 1, 10000);
|
||||
// String url = "jdbc:oracle:thin:@172.16.18.195:1523:xccb";
|
||||
// String user = "radartest";
|
||||
// String password = "radartest";
|
||||
// connection = DriverManager.getConnection(url,user,password);
|
||||
// System.out.println(" ============= 连接数据库成功 ==========");
|
||||
// String insertStatement = "INSERT INTO xccb.TS_ANARADAR (RADARCODE, LABELCODE, LOCATIONIP , LABELNUM , TIMEBEGIN , TIMEEND , TIMECOUNT) VALUES (?, ?, ?, ?, ?, ?, ?)";
|
||||
//
|
||||
// return responses;
|
||||
// });
|
||||
// preparedStatement = connection.prepareStatement(insertStatement);
|
||||
// for (TsanaRadar radar : tsanaRadarList) {
|
||||
// preparedStatement.setString(1,radar.getRadarCode());
|
||||
// preparedStatement.setString(2,radar.getLabelCode());
|
||||
// preparedStatement.setString(3,radar.getLocationIp());
|
||||
// preparedStatement.setString(4,radar.getLabelNum());
|
||||
// preparedStatement.setDate(5,radar.getTimeBegin());
|
||||
// preparedStatement.setDate(6,radar.getTimeEnd());
|
||||
// preparedStatement.setInt(7,radar.getTimeCount());
|
||||
// }
|
||||
// int i = preparedStatement.executeUpdate();
|
||||
// System.out.println("新增数据成功,新增数量: " + i);
|
||||
// }catch (Exception e){
|
||||
// System.out.println("连接异常======" + e);
|
||||
// }finally {
|
||||
// // 关闭连接和statement
|
||||
// if (preparedStatement != null) {
|
||||
// try {
|
||||
// preparedStatement.close();
|
||||
// } catch (SQLException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// if (connection != null) {
|
||||
// try {
|
||||
// connection.close();
|
||||
// } catch (SQLException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||
if (null == pageDomain.getPageNum() || null == pageDomain.getPageSize()) {
|
||||
rspData.setRows(radarList);
|
||||
|
|
@ -161,14 +170,13 @@ public class RadarStatusController implements InitializingBean {
|
|||
}
|
||||
|
||||
private void asyncWebSocket(List<SysRadar> radarList) {
|
||||
CompletableFuture.runAsync(()->{
|
||||
CompletableFuture.runAsync(() -> {
|
||||
|
||||
buildAllRadar(radarList);
|
||||
|
||||
TimerTask task = new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
int count = 0;
|
||||
allRadar.forEach(socketModel -> {
|
||||
asyncReadRadar(socketModel);
|
||||
});
|
||||
|
|
@ -207,36 +215,85 @@ public class RadarStatusController implements InitializingBean {
|
|||
|
||||
|
||||
private void asyncReadRadar(SocketModel socketModel) {
|
||||
CompletableFuture.runAsync(()->{
|
||||
CompletableFuture.runAsync(() -> {
|
||||
try {
|
||||
List<SysDiscern> discernList = new ArrayList<>();
|
||||
// socket连接成功返回数据
|
||||
DataResponse data = SocketUtil.getData(socketModel);
|
||||
System.out.println(socketModel.getRadarIp() +": "+ data);
|
||||
SysDiscern sysDiscern = copyDataToDiscern(data);
|
||||
|
||||
System.out.println(socketModel.getRadarIp() + ": " + data);
|
||||
// 雷达数据返回封装类赋值
|
||||
ModbusResponse modbusResponse = getModbusResponse(data);
|
||||
String tag = modbusResponse.getTagId();
|
||||
// 雷达原始数据对象
|
||||
PrimaryRadarData primaryRadarData = new PrimaryRadarData();
|
||||
// 标识器对象
|
||||
SysIdentifier sysIdentifier = new SysIdentifier();
|
||||
// 拷贝封装类属性到雷达原始数据对象
|
||||
BeanUtils.copyProperties(modbusResponse, primaryRadarData);
|
||||
|
||||
//判断读取数据中是否携带标签
|
||||
if (!"0".equals(modbusResponse.getTagId())) {
|
||||
// 根据标签去数据库查询标签列表
|
||||
sysIdentifier = identifierService.selectIdentifierByTag(tag);
|
||||
//判断数据库查询结果是否有数据
|
||||
if (sysIdentifier != null) {
|
||||
// 有数据将查询到的标识器配置属性放进原始数据对象
|
||||
primaryRadarData.setLadleNumber(sysIdentifier.getLadleNumber());
|
||||
primaryRadarData.setRadarLocation(socketModel.getRadarLocation());
|
||||
primaryRadarData.setRadarIp(socketModel.getRadarIp());
|
||||
|
||||
if (modbusResponse.getValue4() != 0){
|
||||
// 给雷达识别报表赋值
|
||||
sysDiscern.setType(sysIdentifier.getType());
|
||||
sysDiscern.setRadarLocation(socketModel.getRadarLocation());
|
||||
sysDiscern.setLadleNumber(sysIdentifier.getLadleNumber());
|
||||
sysDiscern.setCreateTime(new Date());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
// 没有配置过将铁包号置空
|
||||
primaryRadarData.setLadleNumber(null);
|
||||
primaryRadarData.setRadarLocation(null);
|
||||
primaryRadarData.setRadarIp(socketModel.getRadarIp());
|
||||
}
|
||||
if (modbusResponse.getValue4() != null && !"0".equals(modbusResponse.getValue4())) {
|
||||
if (modbusResponse.getValue4() != null && modbusResponse.getValue4() != 0) {
|
||||
primaryRadarDataService.insertPrimaryRadarData(primaryRadarData);
|
||||
} else {
|
||||
|
||||
}
|
||||
RadarStatusWebSocket.sendToAll(JSON.toJSONString(data));
|
||||
|
||||
} catch (Exception e) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 雷达识别报表赋值
|
||||
*
|
||||
* @param data
|
||||
* @return ModbusResponse
|
||||
*/
|
||||
private static SysDiscern copyDataToDiscern(DataResponse data) {
|
||||
SysDiscern discern = new SysDiscern();
|
||||
discern.setTagId(data.getData().get(3).toString());
|
||||
discern.setValue4(data.getData().get(7));
|
||||
discern.setNumber(data.getData().get(11));
|
||||
return discern;
|
||||
}
|
||||
|
||||
/**
|
||||
* 雷达数据返回封装类赋值
|
||||
*
|
||||
* @param data
|
||||
* @return ModbusResponse
|
||||
*/
|
||||
private static ModbusResponse getModbusResponse(DataResponse data) {
|
||||
ModbusResponse modbusResponse = new ModbusResponse();
|
||||
modbusResponse.setRadarNum(data.getData().get(0).toString());
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@
|
|||
var editFlag = [[${@permission.hasPermi('system:menu:edit')}]];
|
||||
var removeFlag = [[${@permission.hasPermi('system:menu:remove')}]];
|
||||
var datas = [[${@dict.getType('sys_show_hide')}]];
|
||||
var prefix = ctx + "system/identifierStatus";
|
||||
var prefix = ctx + "system/radarstatus";
|
||||
|
||||
$(function() {
|
||||
var options = {
|
||||
|
|
|
|||
|
|
@ -1,114 +1,90 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<th:block th:include="include :: header('标识器状态列表')" />
|
||||
<th:block th:include="include :: header('自定义视图分页')"/>
|
||||
<meta charset="UTF-8">
|
||||
<script src="/js/vue.js"></script>
|
||||
<script src="/js/axios.js"></script>
|
||||
<!-- 引入样式 -->
|
||||
<link rel="stylesheet" href="/css/index.css">
|
||||
<!-- 引入组件库 -->
|
||||
<script src="/js/eleindex.js"></script>
|
||||
</head>
|
||||
<body class="gray-bg">
|
||||
<div class="container-div">
|
||||
<div class="row">
|
||||
<div class="col-sm-12 select-table table-striped">
|
||||
<table id="bootstrap-table" data-page-size="10"
|
||||
data-show-custom-view="true" data-custom-view="customViewFormatter"
|
||||
data-show-custom-view-button="false">
|
||||
</table>
|
||||
<div id="vm" style="padding: 24px">
|
||||
<div style="display: flex;justify-content: flex-start;flex-wrap: wrap;background: white">
|
||||
<div v-for="item in tableData" style="height:100px;width: 100px;margin-left: 10px;margin-top: 20px">
|
||||
<img class="cell_image" alt="image" :src="getImageUrl(item.status)">
|
||||
<p class="cell_p">{{item.radarIp}}</p>
|
||||
<p class="cell_p">{{item.radarLocation}}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<template id="profileTemplate">
|
||||
<div class="col-sm-4">
|
||||
<div class="contact-box">
|
||||
<a href="profile.html">
|
||||
<div class="col-sm-4">
|
||||
<div class="text-center">
|
||||
<img alt="image" class="img-circle m-t-xs img-responsive" src="%IMAGE%">
|
||||
<div class="m-t-xs font-bold">%radarIp%</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-8">
|
||||
<h3><strong>%radarLocation%</strong></h3>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div th:include="include :: footer"></div>
|
||||
<th:block th:include="include :: bootstrap-table-custom-view-js" />
|
||||
|
||||
<script th:inline="javascript">
|
||||
var prefix = ctx + "system/radarstatus";
|
||||
var datas = [[${@dict.getType('sys_normal_disable')}]];
|
||||
|
||||
$(function() {
|
||||
var options = {
|
||||
url: prefix + "/list",
|
||||
showSearch: false,
|
||||
showRefresh: false,
|
||||
showToggle: false,
|
||||
showColumns: false,
|
||||
showExport: true,
|
||||
columns: [{
|
||||
checkbox: true
|
||||
},
|
||||
{
|
||||
field : 'userId',
|
||||
title : '用户ID'
|
||||
},
|
||||
{
|
||||
field : 'userCode',
|
||||
title : '用户编号'
|
||||
},
|
||||
{
|
||||
field : 'radarIp',
|
||||
title : '雷达ip'
|
||||
},
|
||||
{
|
||||
field : 'userPhone',
|
||||
title : '用户手机'
|
||||
},
|
||||
{
|
||||
field : 'userEmail',
|
||||
title : '用户邮箱'
|
||||
},
|
||||
{
|
||||
field : 'userBalance',
|
||||
title : '用户余额'
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
title: '用户状态',
|
||||
align: 'center',
|
||||
formatter: function(value, row, index) {
|
||||
return $.table.selectDictLabel(datas, value);
|
||||
new Vue({
|
||||
el: '#vm',
|
||||
data() {
|
||||
return {
|
||||
tableData: [],
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
align: 'center',
|
||||
formatter: function(value, row, index) {
|
||||
var actions = [];
|
||||
actions.push('<a class="btn btn-success btn-xs" href="javascript:;"><i class="fa fa-edit"></i>编辑</a> ');
|
||||
actions.push('<a class="btn btn-danger btn-xs" href="javascript:;"><i class="fa fa-remove"></i>删除</a>');
|
||||
return actions.join('');
|
||||
}
|
||||
}]
|
||||
};
|
||||
$.table.init(options);
|
||||
});
|
||||
|
||||
function customViewFormatter (data) {
|
||||
var template = $('#profileTemplate').html()
|
||||
var view = ''
|
||||
$.each(data, function (i, row) {
|
||||
view += template.replace('%userCode%', row.userCode)
|
||||
.replace('%IMAGE%', "https://xjl559.oss-cn-shanghai.aliyuncs.com/2023/12/11/%E6%88%AA%E5%B1%8F2024-01-08%2013.57.36.png")
|
||||
.replace('%radarIp%', row.radarIp)
|
||||
.replace('%radarLocation%', row.radarLocation)
|
||||
mounted() {
|
||||
axios.post('http://localhost/system/radarstatus/list', {})
|
||||
.then((data) => {
|
||||
this.tableData = data.data.rows
|
||||
})
|
||||
},
|
||||
created() {
|
||||
var socket = new WebSocket("ws://localhost/websocket");
|
||||
|
||||
return `<div class="row mx-0">${view}</div>`
|
||||
socket.onopen = function (event) {
|
||||
console.log("WebSocket连接已打开");
|
||||
};
|
||||
|
||||
socket.onmessage = (event) => {
|
||||
var data = JSON.parse(event.data);
|
||||
console.log("接收到数据:" + JSON.stringify(data));
|
||||
this.tableData.forEach(item => {
|
||||
if (item.radarIp === data.radarIp) {
|
||||
item.status = data.status
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
socket.onclose = function (event) {
|
||||
console.log("WebSocket连接已关闭");
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
getImageUrl(status) {
|
||||
if (status === 1) {
|
||||
return "http://localhost/img/radarGreen.png";
|
||||
} else if (status === 0) {
|
||||
return "http://localhost/img/radarRed.jpg";
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
<style>
|
||||
.cell_image{
|
||||
vertical-align: middle;
|
||||
width: 100%;
|
||||
height: 60%;
|
||||
}
|
||||
.cell_p{
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
vertical-align: middle;
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
height: 20%;
|
||||
margin: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
</html>
|
||||
|
|
@ -16,6 +16,10 @@
|
|||
</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
|
|
|
|||
|
|
@ -1,15 +1,11 @@
|
|||
package com.ruoyi.web.core.config;
|
||||
package com.ruoyi.common.config;
|
||||
|
||||
import com.ruoyi.common.core.domain.entity.DataResponse;
|
||||
import com.ruoyi.common.core.domain.entity.PrimaryRadarData;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.websocket.*;
|
||||
import javax.websocket.server.ServerEndpoint;
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@ServerEndpoint(value="/websocket",configurator = WebSocketConfig.class)
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.ruoyi.web.core.config;
|
||||
package com.ruoyi.common.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
package com.ruoyi.common.core.domain.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.sql.Date;
|
||||
|
||||
|
||||
@Data
|
||||
public class TsanaRadar {
|
||||
public String radarCode;
|
||||
|
||||
public String labelCode;
|
||||
|
||||
public String locationIp;
|
||||
|
||||
public String labelNum;
|
||||
|
||||
public Date timeBegin;
|
||||
|
||||
public Date timeEnd;
|
||||
|
||||
public Integer timeCount;
|
||||
|
||||
|
||||
public TsanaRadar(String radarCode, String labelCode, String locationIp, String labelNum, Date timeBegin, Date timeEnd, Integer timeCount) {
|
||||
this.radarCode = radarCode;
|
||||
this.labelCode = labelCode;
|
||||
this.locationIp = locationIp;
|
||||
this.labelNum = labelNum;
|
||||
this.timeBegin = timeBegin;
|
||||
this.timeEnd = timeEnd;
|
||||
this.timeCount = timeCount;
|
||||
}
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@ package com.ruoyi.common.utils;
|
|||
import lombok.Data;
|
||||
|
||||
import java.net.Socket;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class SocketModel {
|
||||
|
|
@ -16,5 +17,5 @@ public class SocketModel {
|
|||
|
||||
private int readCount;
|
||||
|
||||
private long lastReceiveTimestamp;
|
||||
private Date updateTime;
|
||||
}
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
package com.ruoyi.common.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.ruoyi.common.config.RadarStatusWebSocket;
|
||||
import com.ruoyi.common.core.domain.entity.DataResponse;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
|
|
@ -17,14 +19,13 @@ public class SocketUtil {
|
|||
Socket socket = socketModel.getSocket();
|
||||
String radarLocation = socketModel.getRadarLocation();
|
||||
String radarIp = socketModel.getRadarIp();
|
||||
try {
|
||||
boolean connected = socket.isConnected();
|
||||
|
||||
if (!connected) {
|
||||
System.out.println(radarLocation+": "+connected);
|
||||
dataResponse.setRadarIp(radarIp);
|
||||
dataResponse.setRadarLocation(radarLocation);
|
||||
dataResponse.setStatus(1);
|
||||
try {
|
||||
boolean connected = socket.isConnected();
|
||||
if (!connected) {
|
||||
System.out.println("雷达:" + radarIp + "===" + radarLocation + ": 连接异常:{}" + connected);
|
||||
dataResponse.setStatus(0);
|
||||
dataResponse.setData(null);
|
||||
return dataResponse;
|
||||
}
|
||||
|
|
@ -43,14 +44,14 @@ public class SocketUtil {
|
|||
decimal.add(s);
|
||||
}
|
||||
dataResponse.setData(decimal);
|
||||
dataResponse.setRadarIp(radarIp);
|
||||
dataResponse.setStatus(1);
|
||||
dataResponse.setRadarLocation(radarLocation);
|
||||
RadarStatusWebSocket.sendToAll(JSON.toJSONString(dataResponse));
|
||||
return dataResponse;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("读取数据异常:"+radarIp);
|
||||
System.out.println("读取数据异常:" + radarIp);
|
||||
}
|
||||
|
||||
dataResponse.setRadarIp(radarIp);
|
||||
dataResponse.setRadarLocation(radarLocation);
|
||||
dataResponse.setStatus(0);
|
||||
|
|
|
|||
Loading…
Reference in New Issue