win代码上传
parent
d9010a27c1
commit
d54c1285eb
6
pom.xml
6
pom.xml
|
|
@ -225,7 +225,11 @@
|
|||
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||
<version>3.0.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.clojars.zentrope</groupId>
|
||||
<artifactId>ojdbc</artifactId>
|
||||
<version>11.2.0.3.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
|
|
|||
|
|
@ -69,7 +69,11 @@
|
|||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-generator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.clojars.zentrope</groupId>
|
||||
<artifactId>ojdbc</artifactId>
|
||||
<version>11.2.0.3.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
|||
|
|
@ -30,6 +30,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
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.concurrent.CompletableFuture;
|
||||
|
||||
|
|
@ -112,7 +116,7 @@ public class RadarStatusController {
|
|||
} else {
|
||||
dataResponse.setStatus("0");
|
||||
}
|
||||
RadarStatusWebSocket.sendToAll(dataResponse.toString());
|
||||
RadarStatusWebSocket.sendToAll(dataResponse);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
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.multipart.MultipartFile;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 雷达配置
|
||||
*
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/system/radar")
|
||||
public class SysRadarController extends BaseController
|
||||
{
|
||||
public class SysRadarController extends BaseController {
|
||||
private String prefix = "system/radar";
|
||||
|
||||
|
||||
@Autowired
|
||||
private ISysRadarService radarService;
|
||||
|
||||
@GetMapping()
|
||||
public String user()
|
||||
{
|
||||
public String user() {
|
||||
return prefix + "/radar";
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
@ResponseBody
|
||||
public TableDataInfo list(SysRadar radar)
|
||||
{
|
||||
public TableDataInfo list(SysRadar radar) {
|
||||
startPage();
|
||||
List<SysRadar> list = radarService.selectRadarList(radar);
|
||||
return getDataTable(list);
|
||||
|
|
@ -60,8 +59,7 @@ public class SysRadarController extends BaseController
|
|||
* 新增雷达配置
|
||||
*/
|
||||
@GetMapping("/add")
|
||||
public String add(ModelMap mmap)
|
||||
{
|
||||
public String add(ModelMap mmap) {
|
||||
return prefix + "/add";
|
||||
}
|
||||
|
||||
|
|
@ -72,8 +70,7 @@ public class SysRadarController extends BaseController
|
|||
@Log(title = "雷达配置管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/add")
|
||||
@ResponseBody
|
||||
public AjaxResult addSave(@Validated SysRadar radar)
|
||||
{
|
||||
public AjaxResult addSave(@Validated SysRadar radar) {
|
||||
radar.setCreateBy(getLoginName());
|
||||
return toAjax(radarService.insertRadar(radar));
|
||||
}
|
||||
|
|
@ -83,9 +80,8 @@ public class SysRadarController extends BaseController
|
|||
*/
|
||||
// @RequiresPermissions("system:user:edit")
|
||||
@GetMapping("/edit/{id}")
|
||||
public String edit(@PathVariable("id") Long id, ModelMap mmap)
|
||||
{
|
||||
mmap.put("radar", radarService.selectRadarById(id));
|
||||
public String edit(@PathVariable("id") Long id, ModelMap mmap) {
|
||||
mmap.put("radar", radarService.selectRadarById(id));
|
||||
return prefix + "/edit";
|
||||
}
|
||||
|
||||
|
|
@ -96,8 +92,7 @@ public class SysRadarController extends BaseController
|
|||
@Log(title = "雷达修改", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/edit")
|
||||
@ResponseBody
|
||||
public AjaxResult editSave(@Validated SysRadar radar)
|
||||
{
|
||||
public AjaxResult editSave(@Validated SysRadar radar) {
|
||||
|
||||
radar.setUpdateBy(getLoginName());
|
||||
return toAjax(radarService.updateUser(radar));
|
||||
|
|
@ -105,8 +100,7 @@ public class SysRadarController extends BaseController
|
|||
|
||||
@PostMapping("/remove")
|
||||
@ResponseBody
|
||||
public AjaxResult remove(String ids)
|
||||
{
|
||||
public AjaxResult remove(String ids) {
|
||||
|
||||
return toAjax(radarService.deleteRadarByIds(ids));
|
||||
}
|
||||
|
|
@ -114,11 +108,11 @@ public class SysRadarController extends BaseController
|
|||
|
||||
@PostMapping("/export")
|
||||
@ResponseBody
|
||||
public AjaxResult export(SysRadar sysRadar)
|
||||
{
|
||||
List<SysRadar> list = radarService.selectRadarList(sysRadar);;
|
||||
public AjaxResult export(SysRadar sysRadar) {
|
||||
List<SysRadar> list = radarService.selectRadarList(sysRadar);
|
||||
;
|
||||
List<RadarExcel> collect = list.stream().map(identifier -> {
|
||||
RadarExcel normalExcel = new RadarExcel();
|
||||
RadarExcel normalExcel = new RadarExcel();
|
||||
BeanUtils.copyProperties(identifier, normalExcel);
|
||||
return normalExcel;
|
||||
}
|
||||
|
|
@ -130,19 +124,61 @@ public class SysRadarController extends BaseController
|
|||
|
||||
@GetMapping("/importTemplate")
|
||||
@ResponseBody
|
||||
public AjaxResult importTemplate()
|
||||
{
|
||||
public AjaxResult importTemplate() {
|
||||
ExcelUtil<RadarExcel> util = new ExcelUtil<RadarExcel>(RadarExcel.class);
|
||||
return util.importTemplateExcel("雷达配置");
|
||||
}
|
||||
|
||||
@PostMapping("/importData")
|
||||
@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);
|
||||
List<RadarExcel> radarList = util.importExcel(file.getInputStream());
|
||||
String message = radarService.importData(radarList, updateSupport);
|
||||
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.databind.json.JsonMapper;
|
||||
import com.ruoyi.common.core.domain.entity.DataResponse;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
import javax.websocket.EncodeException;
|
||||
|
|
@ -15,9 +16,9 @@ import javax.websocket.EndpointConfig;
|
|||
* @description: 实体编码器
|
||||
* @date 2022/8/22 0022下午 14:15
|
||||
*/
|
||||
public class BaseModelEncoder implements Encoder.Text<TableDataInfo> {
|
||||
public class BaseModelEncoder implements Encoder.Text<DataResponse> {
|
||||
@Override
|
||||
public String encode(TableDataInfo baseResponseMessage) throws EncodeException {
|
||||
public String encode(DataResponse baseResponseMessage) throws EncodeException {
|
||||
try {
|
||||
JsonMapper jsonMapper = new JsonMapper();
|
||||
return jsonMapper.writeValueAsString(baseResponseMessage);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@ServerEndpoint(value="/websocket",configurator = WebSocketConfig.class,encoders = {BaseModelEncoder.class})
|
||||
@ServerEndpoint(value="/websocket",configurator = WebSocketConfig.class)
|
||||
@Component
|
||||
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) {
|
||||
try {
|
||||
session.getBasicRemote().sendObject(dataResponse);
|
||||
|
|
|
|||
|
|
@ -87,8 +87,10 @@
|
|||
|
||||
socket.onmessage = function(event) {
|
||||
var data = event.data;
|
||||
console.log("接收到数据:" + data);
|
||||
// console.log("接收到数据:" + data);
|
||||
// 在这里更新前端界面,显示接收到的数据
|
||||
let parse = JSON.parse(data);
|
||||
console.log("接收到数据:" + parse);
|
||||
};
|
||||
|
||||
socket.onclose = function(event) {
|
||||
|
|
|
|||
|
|
@ -2,8 +2,12 @@ package com.ruoyi.common.core.domain.entity;
|
|||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class DataResponse {
|
||||
public class DataResponse implements Serializable {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 雷达ip
|
||||
|
|
@ -19,4 +23,13 @@ public class DataResponse {
|
|||
*/
|
||||
private String status = "0" ;
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DataResponse{" +
|
||||
"radarIp='" + radarIp + '\'' +
|
||||
", radarLocation='" + radarLocation + '\'' +
|
||||
", status='" + status + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue