win代码上传
parent
d9010a27c1
commit
d54c1285eb
6
pom.xml
6
pom.xml
|
|
@ -225,7 +225,11 @@
|
||||||
<artifactId>spring-boot-starter-websocket</artifactId>
|
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||||
<version>3.0.2</version>
|
<version>3.0.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.clojars.zentrope</groupId>
|
||||||
|
<artifactId>ojdbc</artifactId>
|
||||||
|
<version>11.2.0.3.0</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,11 @@
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-generator</artifactId>
|
<artifactId>ruoyi-generator</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.clojars.zentrope</groupId>
|
||||||
|
<artifactId>ojdbc</artifactId>
|
||||||
|
<version>11.2.0.3.0</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
import java.net.Inet4Address;
|
import java.net.Inet4Address;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.Statement;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
|
@ -112,7 +116,7 @@ public class RadarStatusController {
|
||||||
} else {
|
} else {
|
||||||
dataResponse.setStatus("0");
|
dataResponse.setStatus("0");
|
||||||
}
|
}
|
||||||
RadarStatusWebSocket.sendToAll(dataResponse.toString());
|
RadarStatusWebSocket.sendToAll(dataResponse);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (e.equals("java.net.SocketTimeoutException: connect timed out")) {
|
if (e.equals("java.net.SocketTimeoutException: connect timed out")) {
|
||||||
|
|
|
||||||
|
|
@ -24,33 +24,32 @@ import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.sql.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 雷达配置
|
* 雷达配置
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/system/radar")
|
@RequestMapping("/system/radar")
|
||||||
public class SysRadarController extends BaseController
|
public class SysRadarController extends BaseController {
|
||||||
{
|
|
||||||
private String prefix = "system/radar";
|
private String prefix = "system/radar";
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysRadarService radarService;
|
private ISysRadarService radarService;
|
||||||
|
|
||||||
@GetMapping()
|
@GetMapping()
|
||||||
public String user()
|
public String user() {
|
||||||
{
|
|
||||||
return prefix + "/radar";
|
return prefix + "/radar";
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public TableDataInfo list(SysRadar radar)
|
public TableDataInfo list(SysRadar radar) {
|
||||||
{
|
|
||||||
startPage();
|
startPage();
|
||||||
List<SysRadar> list = radarService.selectRadarList(radar);
|
List<SysRadar> list = radarService.selectRadarList(radar);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
|
|
@ -60,8 +59,7 @@ public class SysRadarController extends BaseController
|
||||||
* 新增雷达配置
|
* 新增雷达配置
|
||||||
*/
|
*/
|
||||||
@GetMapping("/add")
|
@GetMapping("/add")
|
||||||
public String add(ModelMap mmap)
|
public String add(ModelMap mmap) {
|
||||||
{
|
|
||||||
return prefix + "/add";
|
return prefix + "/add";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -72,8 +70,7 @@ public class SysRadarController extends BaseController
|
||||||
@Log(title = "雷达配置管理", businessType = BusinessType.INSERT)
|
@Log(title = "雷达配置管理", businessType = BusinessType.INSERT)
|
||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult addSave(@Validated SysRadar radar)
|
public AjaxResult addSave(@Validated SysRadar radar) {
|
||||||
{
|
|
||||||
radar.setCreateBy(getLoginName());
|
radar.setCreateBy(getLoginName());
|
||||||
return toAjax(radarService.insertRadar(radar));
|
return toAjax(radarService.insertRadar(radar));
|
||||||
}
|
}
|
||||||
|
|
@ -83,9 +80,8 @@ public class SysRadarController extends BaseController
|
||||||
*/
|
*/
|
||||||
// @RequiresPermissions("system:user:edit")
|
// @RequiresPermissions("system:user:edit")
|
||||||
@GetMapping("/edit/{id}")
|
@GetMapping("/edit/{id}")
|
||||||
public String edit(@PathVariable("id") Long id, ModelMap mmap)
|
public String edit(@PathVariable("id") Long id, ModelMap mmap) {
|
||||||
{
|
mmap.put("radar", radarService.selectRadarById(id));
|
||||||
mmap.put("radar", radarService.selectRadarById(id));
|
|
||||||
return prefix + "/edit";
|
return prefix + "/edit";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -96,8 +92,7 @@ public class SysRadarController extends BaseController
|
||||||
@Log(title = "雷达修改", businessType = BusinessType.UPDATE)
|
@Log(title = "雷达修改", businessType = BusinessType.UPDATE)
|
||||||
@PostMapping("/edit")
|
@PostMapping("/edit")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult editSave(@Validated SysRadar radar)
|
public AjaxResult editSave(@Validated SysRadar radar) {
|
||||||
{
|
|
||||||
|
|
||||||
radar.setUpdateBy(getLoginName());
|
radar.setUpdateBy(getLoginName());
|
||||||
return toAjax(radarService.updateUser(radar));
|
return toAjax(radarService.updateUser(radar));
|
||||||
|
|
@ -105,8 +100,7 @@ public class SysRadarController extends BaseController
|
||||||
|
|
||||||
@PostMapping("/remove")
|
@PostMapping("/remove")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult remove(String ids)
|
public AjaxResult remove(String ids) {
|
||||||
{
|
|
||||||
|
|
||||||
return toAjax(radarService.deleteRadarByIds(ids));
|
return toAjax(radarService.deleteRadarByIds(ids));
|
||||||
}
|
}
|
||||||
|
|
@ -114,11 +108,11 @@ public class SysRadarController extends BaseController
|
||||||
|
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult export(SysRadar sysRadar)
|
public AjaxResult export(SysRadar sysRadar) {
|
||||||
{
|
List<SysRadar> list = radarService.selectRadarList(sysRadar);
|
||||||
List<SysRadar> list = radarService.selectRadarList(sysRadar);;
|
;
|
||||||
List<RadarExcel> collect = list.stream().map(identifier -> {
|
List<RadarExcel> collect = list.stream().map(identifier -> {
|
||||||
RadarExcel normalExcel = new RadarExcel();
|
RadarExcel normalExcel = new RadarExcel();
|
||||||
BeanUtils.copyProperties(identifier, normalExcel);
|
BeanUtils.copyProperties(identifier, normalExcel);
|
||||||
return normalExcel;
|
return normalExcel;
|
||||||
}
|
}
|
||||||
|
|
@ -130,19 +124,61 @@ public class SysRadarController extends BaseController
|
||||||
|
|
||||||
@GetMapping("/importTemplate")
|
@GetMapping("/importTemplate")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult importTemplate()
|
public AjaxResult importTemplate() {
|
||||||
{
|
|
||||||
ExcelUtil<RadarExcel> util = new ExcelUtil<RadarExcel>(RadarExcel.class);
|
ExcelUtil<RadarExcel> util = new ExcelUtil<RadarExcel>(RadarExcel.class);
|
||||||
return util.importTemplateExcel("雷达配置");
|
return util.importTemplateExcel("雷达配置");
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/importData")
|
@PostMapping("/importData")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
|
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception {
|
||||||
{
|
|
||||||
ExcelUtil<RadarExcel> util = new ExcelUtil<RadarExcel>(RadarExcel.class);
|
ExcelUtil<RadarExcel> util = new ExcelUtil<RadarExcel>(RadarExcel.class);
|
||||||
List<RadarExcel> radarList = util.importExcel(file.getInputStream());
|
List<RadarExcel> radarList = util.importExcel(file.getInputStream());
|
||||||
String message = radarService.importData(radarList, updateSupport);
|
String message = radarService.importData(radarList, updateSupport);
|
||||||
return AjaxResult.success(message);
|
return AjaxResult.success(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// 数据库连接信息
|
||||||
|
String url = "jdbc:oracle:thin:@localhost:1521:xccb";
|
||||||
|
String username = "system";
|
||||||
|
String password = "radartest";
|
||||||
|
|
||||||
|
// 注册Oracle驱动程序
|
||||||
|
try {
|
||||||
|
Class.forName("oracle.jdbc.driver.OracleDriver");
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取数据库连接
|
||||||
|
try (Connection conn = DriverManager.getConnection(url, username, password)) {
|
||||||
|
// 创建Statement对象
|
||||||
|
try (Statement stmt = conn.createStatement()) {
|
||||||
|
// 执行SQL语句
|
||||||
|
String sql = "SELECT table_name FROM all_tables where owner = 'radartest'";
|
||||||
|
try (ResultSet rs = stmt.executeQuery(sql)) {
|
||||||
|
//// 处理查询结果
|
||||||
|
// ResultSetMetaData metaData = rs.getMetaData();
|
||||||
|
// int columnCount = metaData.getColumnCount();
|
||||||
|
//
|
||||||
|
// for (int i = 1; i < columnCount; i++) {
|
||||||
|
// String columnName = metaData.getColumnName(i);
|
||||||
|
// System.out.println("columnName = " + columnName);
|
||||||
|
// }
|
||||||
|
while (rs.next()) {
|
||||||
|
String name = rs.getString("table_name");
|
||||||
|
// 处理每一行数据
|
||||||
|
System.out.println( " name: " + name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2,6 +2,7 @@ package com.ruoyi.web.core.config;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.json.JsonMapper;
|
import com.fasterxml.jackson.databind.json.JsonMapper;
|
||||||
|
import com.ruoyi.common.core.domain.entity.DataResponse;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
|
|
||||||
import javax.websocket.EncodeException;
|
import javax.websocket.EncodeException;
|
||||||
|
|
@ -15,9 +16,9 @@ import javax.websocket.EndpointConfig;
|
||||||
* @description: 实体编码器
|
* @description: 实体编码器
|
||||||
* @date 2022/8/22 0022下午 14:15
|
* @date 2022/8/22 0022下午 14:15
|
||||||
*/
|
*/
|
||||||
public class BaseModelEncoder implements Encoder.Text<TableDataInfo> {
|
public class BaseModelEncoder implements Encoder.Text<DataResponse> {
|
||||||
@Override
|
@Override
|
||||||
public String encode(TableDataInfo baseResponseMessage) throws EncodeException {
|
public String encode(DataResponse baseResponseMessage) throws EncodeException {
|
||||||
try {
|
try {
|
||||||
JsonMapper jsonMapper = new JsonMapper();
|
JsonMapper jsonMapper = new JsonMapper();
|
||||||
return jsonMapper.writeValueAsString(baseResponseMessage);
|
return jsonMapper.writeValueAsString(baseResponseMessage);
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@ServerEndpoint(value="/websocket",configurator = WebSocketConfig.class,encoders = {BaseModelEncoder.class})
|
@ServerEndpoint(value="/websocket",configurator = WebSocketConfig.class)
|
||||||
@Component
|
@Component
|
||||||
public class RadarStatusWebSocket {
|
public class RadarStatusWebSocket {
|
||||||
|
|
||||||
|
|
@ -38,7 +38,7 @@ public class RadarStatusWebSocket {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendToAll(TableDataInfo dataResponse) {
|
public static void sendToAll(DataResponse dataResponse) {
|
||||||
for (Session session : sessions) {
|
for (Session session : sessions) {
|
||||||
try {
|
try {
|
||||||
session.getBasicRemote().sendObject(dataResponse);
|
session.getBasicRemote().sendObject(dataResponse);
|
||||||
|
|
|
||||||
|
|
@ -87,8 +87,10 @@
|
||||||
|
|
||||||
socket.onmessage = function(event) {
|
socket.onmessage = function(event) {
|
||||||
var data = event.data;
|
var data = event.data;
|
||||||
console.log("接收到数据:" + data);
|
// console.log("接收到数据:" + data);
|
||||||
// 在这里更新前端界面,显示接收到的数据
|
// 在这里更新前端界面,显示接收到的数据
|
||||||
|
let parse = JSON.parse(data);
|
||||||
|
console.log("接收到数据:" + parse);
|
||||||
};
|
};
|
||||||
|
|
||||||
socket.onclose = function(event) {
|
socket.onclose = function(event) {
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,12 @@ package com.ruoyi.common.core.domain.entity;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class DataResponse {
|
public class DataResponse implements Serializable {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 雷达ip
|
* 雷达ip
|
||||||
|
|
@ -19,4 +23,13 @@ public class DataResponse {
|
||||||
*/
|
*/
|
||||||
private String status = "0" ;
|
private String status = "0" ;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "DataResponse{" +
|
||||||
|
"radarIp='" + radarIp + '\'' +
|
||||||
|
", radarLocation='" + radarLocation + '\'' +
|
||||||
|
", status='" + status + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue