diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysRadarDataController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysRadarDataController.java index d266b24..5b109e6 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysRadarDataController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysRadarDataController.java @@ -54,4 +54,14 @@ public class SysRadarDataController extends BaseController List list = primaryRadarDataService.selectPrimaryRadarDataList(primaryRadarData); return getDataTable(list); } + + + @PostMapping("/export") + @ResponseBody + public AjaxResult export(PrimaryRadarData primaryRadarData) + { + List list = primaryRadarDataService.selectPrimaryRadarDataList(primaryRadarData); + ExcelUtil util = new ExcelUtil(PrimaryRadarData.class); + return util.exportExcel(list, "雷达原始数据"); + } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/RadarStatusController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/RadarStatusController.java index 1563003..43f4746 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/RadarStatusController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/RadarStatusController.java @@ -1,13 +1,17 @@ package com.ruoyi.web.controller.system; +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.TableDataInfo; import com.ruoyi.common.core.page.TableSupport; +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; @@ -43,6 +47,9 @@ public class RadarStatusController @Autowired private PrimaryRadarDataService primaryRadarDataService; + @Autowired + private ISysIdentifierService identifierService; + private String prefix = "/system/radarStatus"; @@ -71,20 +78,29 @@ public class RadarStatusController public void run() { try { for (SysRadar radar : radarList) { - ModbusResponse modbusResponse = new ModbusResponse(); +// ModbusResponse modbusResponse = new ModbusResponse(); ModbusMaster master = ModbusUtils.getSlave(radar.getRadarIp(), 23); System.out.println(radar.getRadarIp()); - - modbusResponse = ModbusUtils.holdingRegister(); + ModbusResponse modbusResponse = ModbusUtils.holdingRegister(); System.out.println(modbusResponse); + String tag = modbusResponse.getTagId(); + SysIdentifier sysIdentifier = identifierService.selectIdentifierByTag(tag); + PrimaryRadarData primaryRadarData = new PrimaryRadarData(); + BeanUtils.copyProperties(modbusResponse,primaryRadarData); + primaryRadarData.setRadarLocation(radar.getRadarLocation()); + primaryRadarData.setRadarIp(radar.getRadarIp()); + primaryRadarData.setLadleNumber(sysIdentifier.getLadleNumber()); + primaryRadarDataService.insertPrimaryRadarData(primaryRadarData); RadarStatusWebSocket.sendToAll(modbusResponse.toString()); } } catch (Exception e) { - System.err.println("从串口读取失败:" + e.getMessage()); + if (e.equals("java.net.SocketTimeoutException: connect timed out")) { + System.err.println("从串口读取失败:" + "连接超时"); + } } } }; - timer.scheduleAtFixedRate(task, 1, 20); + timer.scheduleAtFixedRate(task, 1, 100); return responses; }); diff --git a/ruoyi-admin/src/main/resources/application-druid.yml b/ruoyi-admin/src/main/resources/application-druid.yml index 6d3a469..707937c 100644 --- a/ruoyi-admin/src/main/resources/application-druid.yml +++ b/ruoyi-admin/src/main/resources/application-druid.yml @@ -6,7 +6,7 @@ spring: druid: # 主库数据源 master: - url: jdbc:mysql://localhost:3306/ry?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + url: jdbc:mysql://192.168.120.21:3306/ry?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 username: root password: 12345678 # 从库数据源 diff --git a/ruoyi-admin/src/main/resources/templates/monitor/radarData/radarData.html b/ruoyi-admin/src/main/resources/templates/monitor/radarData/radarData.html index 63922d4..3793c61 100644 --- a/ruoyi-admin/src/main/resources/templates/monitor/radarData/radarData.html +++ b/ruoyi-admin/src/main/resources/templates/monitor/radarData/radarData.html @@ -76,7 +76,7 @@ exportUrl: prefix + "/export", sortName: "createTime", sortOrder: "desc", - modalName: "任务", + modalName: "数据", columns: [{ checkbox: true }, @@ -118,7 +118,7 @@ title: '峰5幅度', }, { - field: 'baseline', + field: 'baseLine', title: 'BaseLine', }, { diff --git a/ruoyi-admin/src/main/resources/templates/system/radarStatus/radarStatus.html b/ruoyi-admin/src/main/resources/templates/system/radarStatus/radarStatus.html index 268f64d..c3315e5 100644 --- a/ruoyi-admin/src/main/resources/templates/system/radarStatus/radarStatus.html +++ b/ruoyi-admin/src/main/resources/templates/system/radarStatus/radarStatus.html @@ -97,7 +97,7 @@ $.table.init(options); }); - var socket = new WebSocket("ws://localhost:8080/websocket"); + var socket = new WebSocket("ws://localhost/websocket"); socket.onopen = function(event) { console.log("WebSocket连接已打开"); diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/PrimaryRadarData.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/PrimaryRadarData.java index 842a586..9bfe0ed 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/PrimaryRadarData.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/PrimaryRadarData.java @@ -16,48 +16,68 @@ public class PrimaryRadarData extends BaseEntity private static final long serialVersionUID = 1L; /** 用户ID */ - @Excel(name = "常温标识器序号", cellType = ColumnType.NUMERIC, prompt = "常温标识器序号") + @Excel(name = "数据序号", cellType = ColumnType.NUMERIC) private Long id; /** * 标签id号 */ + @Excel(name = "标签id号") private String tagId; /** * 峰值1· */ + @Excel(name = "峰值1") private Integer value1; /** * 峰值2· */ + @Excel(name = "峰值2") private Integer value2; /** * 峰值3· */ + @Excel(name = "峰值3") private Integer value3; /** * 峰值4· */ + @Excel(name = "峰值4") private Integer value4; /** * 峰值5· */ + @Excel(name = "峰值5") private Integer value5; /** * baseLine· */ + @Excel(name = "baseLine") private Integer baseLine; /** * 查询频率 */ + @Excel(name = "查询频率") private Integer queryFre; /** * 天线号 */ + @Excel(name = "天线号") private Integer number; - + /** + * 雷达位置 + */ + @Excel(name = "雷达位置") private String radarLocation; - + /**、 + * 车架号 + */ + @Excel(name = "车架号") private String ladleNumber; + /** + * 雷达ip + */ + @Excel(name = "雷达ip") + private String radarIp; /** 删除标志(0代表存在 2代表删除) */ private String delFlag; @@ -160,6 +180,14 @@ public class PrimaryRadarData extends BaseEntity this.ladleNumber = ladleNumber; } + public String getRadarIp() { + return radarIp; + } + + public void setRadarIp(String radarIp) { + this.radarIp = radarIp; + } + public String getDelFlag() { return delFlag; } @@ -183,6 +211,7 @@ public class PrimaryRadarData extends BaseEntity .append("number",getNumber()) .append("radarLocation",getRadarLocation()) .append("ladleNumber",getLadleNumber()) + .append("radarIp",getRadarIp()) .append("delFlag", getDelFlag()) .append("createBy", getCreateBy()) .append("createTime", getCreateTime()) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/modbus/ModbusUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/modbus/ModbusUtils.java index 3269951..5519862 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/modbus/ModbusUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/modbus/ModbusUtils.java @@ -40,7 +40,7 @@ public class ModbusUtils { // 当接收到响应时释放写锁 lock.readLock().unlock(); - if (integerBatchResults!=null) { + // int i = BitUtils.covertInt(integerBatchResults); ModbusResponse modbusResponse = new ModbusResponse(); modbusResponse.setTagId(Integer.toString(BitUtils.covertInt(integerBatchResults))); @@ -53,8 +53,7 @@ public class ModbusUtils { modbusResponse.setQueryFre (Integer.parseInt(integerBatchResults.getValue(8).toString())); modbusResponse.setNumber (Integer.parseInt(integerBatchResults.getValue(9).toString())); return modbusResponse; - } - return new ModbusResponse(); + } @@ -76,7 +75,7 @@ public class ModbusUtils { // modbusFactory.createAsciiMaster(wrapper);//ASCII 协议 master = modbusFactory.createTcpMaster(params, false); //最大等待时间 - master.setTimeout(1000); + master.setTimeout(10); //最大连接次数 master.setRetries(5); master.init(); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysIdentifierMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysIdentifierMapper.java index 9a15e0d..d7e29d9 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysIdentifierMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysIdentifierMapper.java @@ -32,4 +32,6 @@ public interface SysIdentifierMapper int updateNormalIdentifier(SysIdentifier identifier); List selectAllIdentifierList(); + + SysIdentifier selectIdentifierByTag(String tag); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysIdentifierService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysIdentifierService.java index d6dae08..8c95d4e 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysIdentifierService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysIdentifierService.java @@ -29,4 +29,6 @@ public interface ISysIdentifierService SysIdentifier selectNormalIdentifierById(Long id); int updateNormalIdentifier(SysIdentifier identifier); + + SysIdentifier selectIdentifierByTag(String tag); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysIdentifierServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysIdentifierServiceImpl.java index de059f0..2bf1310 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysIdentifierServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysIdentifierServiceImpl.java @@ -90,6 +90,12 @@ public class SysIdentifierServiceImpl implements ISysIdentifierService return identifierMapper.updateNormalIdentifier(identifier); } + @Override + public SysIdentifier selectIdentifierByTag(String tag) { + + return identifierMapper.selectIdentifierByTag(tag); + } + @Override public SysIdentifier selectIdentifierById(Long id) { diff --git a/ruoyi-system/src/main/resources/mapper/system/PrimaryRadarDataMapper.xml b/ruoyi-system/src/main/resources/mapper/system/PrimaryRadarDataMapper.xml index f35dc39..27ea3b3 100644 --- a/ruoyi-system/src/main/resources/mapper/system/PrimaryRadarDataMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/PrimaryRadarDataMapper.xml @@ -17,6 +17,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -26,7 +27,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + + insert into sys_primary_radar_data( + id, + tag_id, + value1, + value2, + value3, + value4, + value5, + base_line, + query_fre, + number, + radar_location, + ladle_number, + radar_ip, + create_by, + remark, + create_time, + update_time + )values( + #{id}, + #{tagId}, + #{value1}, + #{value2}, + #{value3}, + #{value4}, + #{value5}, + #{baseLine}, + #{queryFre}, + #{number}, + #{radarLocation}, + #{ladleNumber}, + #{radarIp}, + #{createBy}, + #{remark}, + sysdate(), + sysdate() + ) + + + diff --git a/ruoyi-system/src/main/resources/mapper/system/SysIdentifierMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysIdentifierMapper.xml index 4b43058..f882bba 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysIdentifierMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysIdentifierMapper.xml @@ -135,5 +135,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select i.id,i.identifier_id,i.identifier_two,i.ladle_number,i.create_by,i.create_time,i.update_by,i.update_time,i.remark,i.del_flag from sys_identifier i where i.del_flag = '0' and i.type = 0 - - \ No newline at end of file + + + \ No newline at end of file