win代码上传
parent
f1af214b75
commit
ddfa81b18d
6
pom.xml
6
pom.xml
|
|
@ -226,9 +226,9 @@
|
||||||
<version>3.0.2</version>
|
<version>3.0.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.clojars.zentrope</groupId>
|
<groupId>com.oracle</groupId>
|
||||||
<artifactId>ojdbc</artifactId>
|
<artifactId>ojdbc6</artifactId>
|
||||||
<version>11.2.0.3.0</version>
|
<version>11.2.0.4.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
|
||||||
|
|
@ -70,9 +70,9 @@
|
||||||
<artifactId>ruoyi-generator</artifactId>
|
<artifactId>ruoyi-generator</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.clojars.zentrope</groupId>
|
<groupId>com.oracle</groupId>
|
||||||
<artifactId>ojdbc</artifactId>
|
<artifactId>ojdbc6</artifactId>
|
||||||
<version>11.2.0.3.0</version>
|
<version>11.2.0.4.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ public class IdentifierStatusController
|
||||||
private IdentifierStatusService identifierStatusService;
|
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.alibaba.fastjson.JSON;
|
||||||
import com.ruoyi.common.core.domain.entity.DataResponse;
|
import com.ruoyi.common.core.domain.entity.*;
|
||||||
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.page.PageDomain;
|
import com.ruoyi.common.core.page.PageDomain;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.core.page.TableSupport;
|
import com.ruoyi.common.core.page.TableSupport;
|
||||||
import com.ruoyi.common.utils.SocketModel;
|
import com.ruoyi.common.utils.SocketModel;
|
||||||
import com.ruoyi.common.utils.SocketUtil;
|
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.BeanUtils;
|
||||||
import com.ruoyi.common.utils.bean.ModbusResponse;
|
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.ISysIdentifierService;
|
||||||
import com.ruoyi.system.service.ISysRadarService;
|
import com.ruoyi.system.service.ISysRadarService;
|
||||||
import com.ruoyi.system.service.PrimaryRadarDataService;
|
import com.ruoyi.system.service.PrimaryRadarDataService;
|
||||||
import com.ruoyi.system.service.impl.IdentifierStatusServiceImpl;
|
import com.ruoyi.common.config.RadarStatusWebSocket;
|
||||||
import com.ruoyi.web.core.config.RadarStatusWebSocket;
|
|
||||||
import com.serotonin.modbus4j.ModbusMaster;
|
|
||||||
import lombok.Data;
|
|
||||||
import org.apache.commons.compress.utils.Lists;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.ModelMap;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.Inet4Address;
|
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.net.UnknownHostException;
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
||||||
import java.sql.ResultSet;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.Statement;
|
import java.sql.SQLException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
@ -68,8 +54,9 @@ public class RadarStatusController implements InitializingBean {
|
||||||
|
|
||||||
public static CopyOnWriteArrayList<SocketModel> allRadar = new CopyOnWriteArrayList<>();
|
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";
|
return prefix + "/radarstatus";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public TableDataInfo list(@RequestBody SysRadar sysRadar) {
|
public TableDataInfo list(@RequestBody SysRadar sysRadar) {
|
||||||
TableDataInfo rspData = new TableDataInfo();
|
TableDataInfo rspData = new TableDataInfo();
|
||||||
List<SysRadar> radarList = service.selectRadarList(sysRadar);
|
List<SysRadar> radarList = service.selectRadarList(sysRadar);
|
||||||
|
// int year = 2024;
|
||||||
// 异步连接硬件
|
// int month = 2; // 8月代表9月,因为月份是从0开始计数的
|
||||||
// CompletableFuture<List<ModbusResponse>> listCompletableFuture = CompletableFuture.supplyAsync(() -> {
|
// int day = 25;
|
||||||
// List<ModbusResponse> responses = new ArrayList<>();
|
// java.sql.Date date2 = new java.sql.Date(year - 1900, month - 1, day);
|
||||||
// final ConnectionStatus connectionStatus = new ConnectionStatus();
|
// List<TsanaRadar> tsanaRadarList = new ArrayList<>();
|
||||||
// Timer timer = new Timer();
|
// TsanaRadar tsanaRadar = new TsanaRadar("111","111","111","111",date2,date2 , 1);
|
||||||
// boolean connected = false;
|
// TsanaRadar tsanaRadar1 = new TsanaRadar("222","222","222","222",date2,date2 , 2);
|
||||||
// TimerTask task = new TimerTask() {
|
// TsanaRadar tsanaRadar2 = new TsanaRadar("333","333","333","333",date2,date2 , 3);
|
||||||
// @Override
|
// TsanaRadar tsanaRadar3 = new TsanaRadar("444","444","444","444",date2,date2 , 4);
|
||||||
// public void run() {
|
// 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) {
|
// Connection connection = null;
|
||||||
// System.out.println("=======radar=====" + radar.getRadarIp());
|
// PreparedStatement preparedStatement = null;
|
||||||
// try {
|
// try {
|
||||||
// DataResponse data = SocketUtil.getData(radar.getRadarIp(), 23, radar.getRadarLocation());
|
// Class.forName("oracle.jdbc.driver.OracleDriver");
|
||||||
// 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 {
|
|
||||||
//
|
//
|
||||||
// }
|
// String url = "jdbc:oracle:thin:@172.16.18.195:1523:xccb";
|
||||||
// RadarStatusWebSocket.sendToAll(JSON.toJSONString(data));
|
// String user = "radartest";
|
||||||
// } catch (Exception e) {
|
// String password = "radartest";
|
||||||
//// if (e.equals("java.net.SocketTimeoutException: connect timed out")) {
|
// connection = DriverManager.getConnection(url,user,password);
|
||||||
//// System.err.println("从串口读取失败:" + "连接超时");
|
// System.out.println(" ============= 连接数据库成功 ==========");
|
||||||
//// }
|
// String insertStatement = "INSERT INTO xccb.TS_ANARADAR (RADARCODE, LABELCODE, LOCATIONIP , LABELNUM , TIMEBEGIN , TIMEEND , TIMECOUNT) VALUES (?, ?, ?, ?, ?, ?, ?)";
|
||||||
//// DataResponse dataResponse = new DataResponse();
|
//
|
||||||
//// dataResponse.setRadarIp(radar.getRadarIp());
|
// preparedStatement = connection.prepareStatement(insertStatement);
|
||||||
//// dataResponse.setRadarLocation(radar.getRadarLocation());
|
// for (TsanaRadar radar : tsanaRadarList) {
|
||||||
//// dataResponse.setStatus(0);
|
// preparedStatement.setString(1,radar.getRadarCode());
|
||||||
//// RadarStatusWebSocket.sendToAll(JSON.toJSONString(dataResponse));
|
// preparedStatement.setString(2,radar.getLabelCode());
|
||||||
//// e.printStackTrace();
|
// 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();
|
||||||
// }
|
// }
|
||||||
// };
|
// }
|
||||||
// timer.scheduleAtFixedRate(task, 1, 10000);
|
// if (connection != null) {
|
||||||
//
|
// try {
|
||||||
// return responses;
|
// connection.close();
|
||||||
// });
|
// } catch (SQLException e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||||
if (null == pageDomain.getPageNum() || null == pageDomain.getPageSize()) {
|
if (null == pageDomain.getPageNum() || null == pageDomain.getPageSize()) {
|
||||||
rspData.setRows(radarList);
|
rspData.setRows(radarList);
|
||||||
|
|
@ -156,19 +165,18 @@ public class RadarStatusController implements InitializingBean {
|
||||||
rspData.setRows(radarList.subList(pageNum, pageSize));
|
rspData.setRows(radarList.subList(pageNum, pageSize));
|
||||||
rspData.setTotal(radarList.size());
|
rspData.setTotal(radarList.size());
|
||||||
|
|
||||||
// RadarStatusWebSocket.sendToAll(rspData);
|
// RadarStatusWebSocket.sendToAll(rspData);
|
||||||
return rspData;
|
return rspData;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void asyncWebSocket(List<SysRadar> radarList) {
|
private void asyncWebSocket(List<SysRadar> radarList) {
|
||||||
CompletableFuture.runAsync(()->{
|
CompletableFuture.runAsync(() -> {
|
||||||
|
|
||||||
buildAllRadar(radarList);
|
buildAllRadar(radarList);
|
||||||
|
|
||||||
TimerTask task = new TimerTask() {
|
TimerTask task = new TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
int count = 0;
|
|
||||||
allRadar.forEach(socketModel -> {
|
allRadar.forEach(socketModel -> {
|
||||||
asyncReadRadar(socketModel);
|
asyncReadRadar(socketModel);
|
||||||
});
|
});
|
||||||
|
|
@ -207,36 +215,85 @@ public class RadarStatusController implements InitializingBean {
|
||||||
|
|
||||||
|
|
||||||
private void asyncReadRadar(SocketModel socketModel) {
|
private void asyncReadRadar(SocketModel socketModel) {
|
||||||
CompletableFuture.runAsync(()->{
|
CompletableFuture.runAsync(() -> {
|
||||||
try {
|
try {
|
||||||
|
List<SysDiscern> discernList = new ArrayList<>();
|
||||||
|
// socket连接成功返回数据
|
||||||
DataResponse data = SocketUtil.getData(socketModel);
|
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);
|
ModbusResponse modbusResponse = getModbusResponse(data);
|
||||||
String tag = modbusResponse.getTagId();
|
String tag = modbusResponse.getTagId();
|
||||||
|
// 雷达原始数据对象
|
||||||
PrimaryRadarData primaryRadarData = new PrimaryRadarData();
|
PrimaryRadarData primaryRadarData = new PrimaryRadarData();
|
||||||
|
// 标识器对象
|
||||||
SysIdentifier sysIdentifier = new SysIdentifier();
|
SysIdentifier sysIdentifier = new SysIdentifier();
|
||||||
|
// 拷贝封装类属性到雷达原始数据对象
|
||||||
BeanUtils.copyProperties(modbusResponse, primaryRadarData);
|
BeanUtils.copyProperties(modbusResponse, primaryRadarData);
|
||||||
|
|
||||||
|
//判断读取数据中是否携带标签
|
||||||
if (!"0".equals(modbusResponse.getTagId())) {
|
if (!"0".equals(modbusResponse.getTagId())) {
|
||||||
|
// 根据标签去数据库查询标签列表
|
||||||
sysIdentifier = identifierService.selectIdentifierByTag(tag);
|
sysIdentifier = identifierService.selectIdentifierByTag(tag);
|
||||||
primaryRadarData.setLadleNumber(sysIdentifier.getLadleNumber());
|
//判断数据库查询结果是否有数据
|
||||||
primaryRadarData.setRadarLocation(socketModel.getRadarLocation());
|
if (sysIdentifier != null) {
|
||||||
primaryRadarData.setRadarIp(socketModel.getRadarIp());
|
// 有数据将查询到的标识器配置属性放进原始数据对象
|
||||||
|
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 {
|
} else {
|
||||||
|
// 没有配置过将铁包号置空
|
||||||
primaryRadarData.setLadleNumber(null);
|
primaryRadarData.setLadleNumber(null);
|
||||||
primaryRadarData.setRadarLocation(null);
|
primaryRadarData.setRadarLocation(null);
|
||||||
primaryRadarData.setRadarIp(socketModel.getRadarIp());
|
primaryRadarData.setRadarIp(socketModel.getRadarIp());
|
||||||
}
|
}
|
||||||
if (modbusResponse.getValue4() != null && !"0".equals(modbusResponse.getValue4())) {
|
if (modbusResponse.getValue4() != null && modbusResponse.getValue4() != 0) {
|
||||||
primaryRadarDataService.insertPrimaryRadarData(primaryRadarData);
|
primaryRadarDataService.insertPrimaryRadarData(primaryRadarData);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
}
|
}
|
||||||
RadarStatusWebSocket.sendToAll(JSON.toJSONString(data));
|
|
||||||
} catch (Exception e) {
|
} 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) {
|
private static ModbusResponse getModbusResponse(DataResponse data) {
|
||||||
ModbusResponse modbusResponse = new ModbusResponse();
|
ModbusResponse modbusResponse = new ModbusResponse();
|
||||||
modbusResponse.setRadarNum(data.getData().get(0).toString());
|
modbusResponse.setRadarNum(data.getData().get(0).toString());
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@
|
||||||
var editFlag = [[${@permission.hasPermi('system:menu:edit')}]];
|
var editFlag = [[${@permission.hasPermi('system:menu:edit')}]];
|
||||||
var removeFlag = [[${@permission.hasPermi('system:menu:remove')}]];
|
var removeFlag = [[${@permission.hasPermi('system:menu:remove')}]];
|
||||||
var datas = [[${@dict.getType('sys_show_hide')}]];
|
var datas = [[${@dict.getType('sys_show_hide')}]];
|
||||||
var prefix = ctx + "system/identifierStatus";
|
var prefix = ctx + "system/radarstatus";
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
var options = {
|
var options = {
|
||||||
|
|
|
||||||
|
|
@ -1,114 +1,90 @@
|
||||||
<!DOCTYPE html>
|
<!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>
|
<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>
|
</head>
|
||||||
<body class="gray-bg">
|
<body class="gray-bg">
|
||||||
<div class="container-div">
|
<div id="vm" style="padding: 24px">
|
||||||
<div class="row">
|
<div style="display: flex;justify-content: flex-start;flex-wrap: wrap;background: white">
|
||||||
<div class="col-sm-12 select-table table-striped">
|
<div v-for="item in tableData" style="height:100px;width: 100px;margin-left: 10px;margin-top: 20px">
|
||||||
<table id="bootstrap-table" data-page-size="10"
|
<img class="cell_image" alt="image" :src="getImageUrl(item.status)">
|
||||||
data-show-custom-view="true" data-custom-view="customViewFormatter"
|
<p class="cell_p">{{item.radarIp}}</p>
|
||||||
data-show-custom-view-button="false">
|
<p class="cell_p">{{item.radarLocation}}</p>
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</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>
|
<div th:include="include :: footer"></div>
|
||||||
<th:block th:include="include :: bootstrap-table-custom-view-js" />
|
|
||||||
<script th:inline="javascript">
|
<script th:inline="javascript">
|
||||||
var prefix = ctx + "system/radarstatus";
|
new Vue({
|
||||||
var datas = [[${@dict.getType('sys_normal_disable')}]];
|
el: '#vm',
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
tableData: [],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
axios.post('http://localhost/system/radarstatus/list', {})
|
||||||
|
.then((data) => {
|
||||||
|
this.tableData = data.data.rows
|
||||||
|
})
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
var socket = new WebSocket("ws://localhost/websocket");
|
||||||
|
|
||||||
$(function() {
|
socket.onopen = function (event) {
|
||||||
var options = {
|
console.log("WebSocket连接已打开");
|
||||||
url: prefix + "/list",
|
};
|
||||||
showSearch: false,
|
|
||||||
showRefresh: false,
|
socket.onmessage = (event) => {
|
||||||
showToggle: false,
|
var data = JSON.parse(event.data);
|
||||||
showColumns: false,
|
console.log("接收到数据:" + JSON.stringify(data));
|
||||||
showExport: true,
|
this.tableData.forEach(item => {
|
||||||
columns: [{
|
if (item.radarIp === data.radarIp) {
|
||||||
checkbox: true
|
item.status = data.status
|
||||||
},
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
},
|
})
|
||||||
{
|
};
|
||||||
title: '操作',
|
|
||||||
align: 'center',
|
socket.onclose = function (event) {
|
||||||
formatter: function(value, row, index) {
|
console.log("WebSocket连接已关闭");
|
||||||
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>');
|
methods: {
|
||||||
return actions.join('');
|
getImageUrl(status) {
|
||||||
}
|
if (status === 1) {
|
||||||
}]
|
return "http://localhost/img/radarGreen.png";
|
||||||
};
|
} else if (status === 0) {
|
||||||
$.table.init(options);
|
return "http://localhost/img/radarRed.jpg";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
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)
|
|
||||||
})
|
|
||||||
|
|
||||||
return `<div class="row mx-0">${view}</div>`
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</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>
|
</html>
|
||||||
|
|
@ -16,6 +16,10 @@
|
||||||
</description>
|
</description>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<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 org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.websocket.*;
|
import javax.websocket.*;
|
||||||
import javax.websocket.server.ServerEndpoint;
|
import javax.websocket.server.ServerEndpoint;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@ServerEndpoint(value="/websocket",configurator = WebSocketConfig.class)
|
@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.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
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 lombok.Data;
|
||||||
|
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class SocketModel {
|
public class SocketModel {
|
||||||
|
|
@ -16,5 +17,5 @@ public class SocketModel {
|
||||||
|
|
||||||
private int readCount;
|
private int readCount;
|
||||||
|
|
||||||
private long lastReceiveTimestamp;
|
private Date updateTime;
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package com.ruoyi.common.utils;
|
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 com.ruoyi.common.core.domain.entity.DataResponse;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
|
|
@ -17,14 +19,13 @@ public class SocketUtil {
|
||||||
Socket socket = socketModel.getSocket();
|
Socket socket = socketModel.getSocket();
|
||||||
String radarLocation = socketModel.getRadarLocation();
|
String radarLocation = socketModel.getRadarLocation();
|
||||||
String radarIp = socketModel.getRadarIp();
|
String radarIp = socketModel.getRadarIp();
|
||||||
|
dataResponse.setRadarIp(radarIp);
|
||||||
|
dataResponse.setRadarLocation(radarLocation);
|
||||||
try {
|
try {
|
||||||
boolean connected = socket.isConnected();
|
boolean connected = socket.isConnected();
|
||||||
|
|
||||||
if (!connected) {
|
if (!connected) {
|
||||||
System.out.println(radarLocation+": "+connected);
|
System.out.println("雷达:" + radarIp + "===" + radarLocation + ": 连接异常:{}" + connected);
|
||||||
dataResponse.setRadarIp(radarIp);
|
dataResponse.setStatus(0);
|
||||||
dataResponse.setRadarLocation(radarLocation);
|
|
||||||
dataResponse.setStatus(1);
|
|
||||||
dataResponse.setData(null);
|
dataResponse.setData(null);
|
||||||
return dataResponse;
|
return dataResponse;
|
||||||
}
|
}
|
||||||
|
|
@ -43,14 +44,14 @@ public class SocketUtil {
|
||||||
decimal.add(s);
|
decimal.add(s);
|
||||||
}
|
}
|
||||||
dataResponse.setData(decimal);
|
dataResponse.setData(decimal);
|
||||||
dataResponse.setRadarIp(radarIp);
|
|
||||||
dataResponse.setStatus(1);
|
dataResponse.setStatus(1);
|
||||||
dataResponse.setRadarLocation(radarLocation);
|
RadarStatusWebSocket.sendToAll(JSON.toJSONString(dataResponse));
|
||||||
return dataResponse;
|
return dataResponse;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println("读取数据异常:"+radarIp);
|
System.out.println("读取数据异常:" + radarIp);
|
||||||
}
|
}
|
||||||
|
|
||||||
dataResponse.setRadarIp(radarIp);
|
dataResponse.setRadarIp(radarIp);
|
||||||
dataResponse.setRadarLocation(radarLocation);
|
dataResponse.setRadarLocation(radarLocation);
|
||||||
dataResponse.setStatus(0);
|
dataResponse.setStatus(0);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue