win代码上传
parent
b3927c894a
commit
5b5fb4030a
|
|
@ -54,4 +54,14 @@ public class SysRadarDataController extends BaseController
|
|||
List<PrimaryRadarData> list = primaryRadarDataService.selectPrimaryRadarDataList(primaryRadarData);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/export")
|
||||
@ResponseBody
|
||||
public AjaxResult export(PrimaryRadarData primaryRadarData)
|
||||
{
|
||||
List<PrimaryRadarData> list = primaryRadarDataService.selectPrimaryRadarDataList(primaryRadarData);
|
||||
ExcelUtil<PrimaryRadarData> util = new ExcelUtil<PrimaryRadarData>(PrimaryRadarData.class);
|
||||
return util.exportExcel(list, "雷达原始数据");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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
|
||||
# 从库数据源
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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连接已打开");
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -32,4 +32,6 @@ public interface SysIdentifierMapper
|
|||
int updateNormalIdentifier(SysIdentifier identifier);
|
||||
|
||||
List<SysIdentifier> selectAllIdentifierList();
|
||||
|
||||
SysIdentifier selectIdentifierByTag(String tag);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,4 +29,6 @@ public interface ISysIdentifierService
|
|||
SysIdentifier selectNormalIdentifierById(Long id);
|
||||
|
||||
int updateNormalIdentifier(SysIdentifier identifier);
|
||||
|
||||
SysIdentifier selectIdentifierByTag(String tag);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<result property="number" column="number" />
|
||||
<result property="radarLocation" column="radar_location" />
|
||||
<result property="ladleNumber" column="ladle_number" />
|
||||
<result property="radarIp" column="radar_ip" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
|
|
@ -26,7 +27,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</resultMap>
|
||||
|
||||
<select id="selectPrimaryRadarDataList" resultMap="PrimaryRadarDataResult">
|
||||
select p.id,p.tag_id,p.value1,p.value2,p.value3,p.value4,p.value5,p.base_line,p.query_fre,p.number,p.radar_location,p.ladle_number,p.create_by,p.create_time,p.update_by,p.update_time,p.remark,p.del_flag from sys_primary_radar_data p
|
||||
select p.id,p.tag_id,p.value1,p.value2,p.value3,p.value4,p.value5,p.base_line,p.query_fre,p.number,p.radar_location,p.ladle_number,p.radar_ip,p.create_by,p.create_time,p.update_by,p.update_time,p.remark,p.del_flag from sys_primary_radar_data p
|
||||
where p.del_flag = '0'
|
||||
<if test="radarLocation != null and radarLocation != ''">
|
||||
AND p.radar_location like concat('%',#{radarLocation}, '%')
|
||||
|
|
@ -40,10 +41,49 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="createTime != null and updateTime != null">
|
||||
AND DATE_FORMAT(p.update_time,'%Y-%m-%d') between DATE_FORMAT(#{createTime},'%Y-%m-%d') and DATE_FORMAT(#{updateTime},'%Y-%m-%d')
|
||||
</if>
|
||||
order by i.id asc
|
||||
</select>
|
||||
|
||||
<!-- <insert id="insertPrimaryRadarData">-->
|
||||
<insert id="insertPrimaryRadarData">
|
||||
insert into sys_primary_radar_data(
|
||||
<if test="id != null and id != 0">id,</if>
|
||||
<if test="tagId != null and tagId != ''">tag_id,</if>
|
||||
<if test="value1 != null and value1 != ''">value1,</if>
|
||||
<if test="value2 != null and value2 != ''">value2,</if>
|
||||
<if test="value3 != null and value3 != ''">value3,</if>
|
||||
<if test="value4 != null and value4 != ''">value4,</if>
|
||||
<if test="value5 != null and value5 != ''">value5,</if>
|
||||
<if test="baseLine != null and baseLine != ''">base_line,</if>
|
||||
<if test="queryFre != null ">query_fre,</if>
|
||||
<if test="number != null and number != ''">number,</if>
|
||||
<if test="radarLocation != null and radarLocation != ''">radar_location,</if>
|
||||
<if test="ladleNumber != null and ladleNumber != ''">ladle_number,</if>
|
||||
<if test="radarIp != null and radarIp != ''">radar_ip,</if>
|
||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||
<if test="remark != null and remark != ''">remark,</if>
|
||||
create_time,
|
||||
update_time
|
||||
)values(
|
||||
<if test="id != null and id != 0">#{id},</if>
|
||||
<if test="tagId != null and tagId != ''">#{tagId},</if>
|
||||
<if test="value1 != null and value1 != ''">#{value1},</if>
|
||||
<if test="value2 != null and value2 != ''">#{value2},</if>
|
||||
<if test="value3 != null and value3 != ''">#{value3},</if>
|
||||
<if test="value4 != null and value4 != ''">#{value4},</if>
|
||||
<if test="value5 != null and value5 != ''">#{value5},</if>
|
||||
<if test="baseLine != null and baseLine != ''">#{baseLine},</if>
|
||||
<if test="queryFre != null">#{queryFre},</if>
|
||||
<if test="number != null and number != ''">#{number},</if>
|
||||
<if test="radarLocation != null and radarLocation != ''">#{radarLocation},</if>
|
||||
<if test="ladleNumber != null and ladleNumber != ''">#{ladleNumber},</if>
|
||||
<if test="radarIp != null and radarIp != ''">#{radarIp},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
<if test="remark != null and remark != ''">#{remark},</if>
|
||||
sysdate(),
|
||||
sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- <insert id="insertPrimaryRadarData">-->
|
||||
|
||||
<!-- insert into sys_normalIdentifier(-->
|
||||
<!-- <if test="id != null and id != 0">id,</if>-->
|
||||
|
|
|
|||
|
|
@ -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
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
<select id="selectIdentifierByTag" resultMap="SysIdentifierResult">
|
||||
select i.id,i.identifier_id,i.identifier_two,i.identifier_three,i.identifier_four,i.type,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.identifier_id = #{tag} or identifier_two = #{tag} or identifier_three = #{tag} or identifier_four = #{tag}
|
||||
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue