win代码上传
parent
3b1afb5d73
commit
f81d48c84b
|
|
@ -57,8 +57,6 @@ public class RadarStatusController {
|
||||||
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);
|
||||||
// oracleInsert(tsanaRadarList);
|
|
||||||
|
|
||||||
|
|
||||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||||
if (null == pageDomain.getPageNum() || null == pageDomain.getPageSize()) {
|
if (null == pageDomain.getPageNum() || null == pageDomain.getPageSize()) {
|
||||||
|
|
@ -77,51 +75,6 @@ public class RadarStatusController {
|
||||||
return rspData;
|
return rspData;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void oracleInsert(TsanaRadar tsanaRadar) {
|
|
||||||
Connection connection = null;
|
|
||||||
PreparedStatement preparedStatement = null;
|
|
||||||
try {
|
|
||||||
Class.forName("oracle.jdbc.driver.OracleDriver");
|
|
||||||
|
|
||||||
String url = "jdbc:oracle:thin:@172.16.18.195:1523:xccb";
|
|
||||||
String user = "radartest";
|
|
||||||
String password = "radartest";
|
|
||||||
connection = DriverManager.getConnection(url,user,password);
|
|
||||||
System.out.println(" ============= 连接数据库成功 ==========");
|
|
||||||
String insertStatement = "INSERT INTO xccb.TS_ANARADAR (RADARCODE, LABELCODE, LOCATIONIP , LABELNUM , TIMEBEGIN , TIMEEND , TIMECOUNT) VALUES (?, ?, ?, ?, ?, ?, ?)";
|
|
||||||
|
|
||||||
preparedStatement = connection.prepareStatement(insertStatement);
|
|
||||||
|
|
||||||
preparedStatement.setString(1,tsanaRadar.getRadarCode());
|
|
||||||
preparedStatement.setString(2,tsanaRadar.getLabelCode());
|
|
||||||
preparedStatement.setString(3,tsanaRadar.getLocationIp());
|
|
||||||
preparedStatement.setString(4,tsanaRadar.getLabelNum());
|
|
||||||
preparedStatement.setDate(5,tsanaRadar.getTimeBegin());
|
|
||||||
preparedStatement.setDate(6,tsanaRadar.getTimeEnd());
|
|
||||||
preparedStatement.setInt(7,tsanaRadar.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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (connection != null) {
|
|
||||||
try {
|
|
||||||
connection.close();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -77,7 +78,9 @@ public class SysRadarController extends BaseController {
|
||||||
radar.setCreateBy(getLoginName());
|
radar.setCreateBy(getLoginName());
|
||||||
int result = radarService.insertRadar(radar);
|
int result = radarService.insertRadar(radar);
|
||||||
List<SysRadar> sysRadars = radarService.selectRadarList(new SysRadar());
|
List<SysRadar> sysRadars = radarService.selectRadarList(new SysRadar());
|
||||||
radarRealTimeDataService.addRadar(sysRadars);
|
CompletableFuture.runAsync(()->{
|
||||||
|
radarRealTimeDataService.addRadar(sysRadars);
|
||||||
|
});
|
||||||
return toAjax(result);
|
return toAjax(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -109,7 +112,9 @@ public class SysRadarController extends BaseController {
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult remove(String ids) {
|
public AjaxResult remove(String ids) {
|
||||||
int result = radarService.deleteRadarByIds(ids);
|
int result = radarService.deleteRadarByIds(ids);
|
||||||
radarRealTimeDataService.delRadar(Long.valueOf(ids));
|
CompletableFuture.runAsync(()->{
|
||||||
|
radarRealTimeDataService.delRadar(Long.valueOf(ids));
|
||||||
|
});
|
||||||
return toAjax(result);
|
return toAjax(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -143,7 +148,9 @@ public class SysRadarController extends BaseController {
|
||||||
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);
|
||||||
radarRealTimeDataService.addRadar(radarService.selectRadarList(new SysRadar()));
|
CompletableFuture.runAsync(()->{
|
||||||
|
radarRealTimeDataService.addRadar(radarService.selectRadarList(new SysRadar()));
|
||||||
|
});
|
||||||
return AjaxResult.success(message);
|
return AjaxResult.success(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,8 @@ public class PrimaryRadarData extends BaseEntity
|
||||||
/** 删除标志(0代表存在 2代表删除) */
|
/** 删除标志(0代表存在 2代表删除) */
|
||||||
private String delFlag;
|
private String delFlag;
|
||||||
|
|
||||||
|
private Integer stationCode;
|
||||||
|
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
public String getType() {
|
public String getType() {
|
||||||
|
|
@ -208,6 +210,14 @@ public class PrimaryRadarData extends BaseEntity
|
||||||
this.totalCount = totalCount;
|
this.totalCount = totalCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getStationCode() {
|
||||||
|
return stationCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStationCode(Integer stationCode) {
|
||||||
|
this.stationCode = stationCode;
|
||||||
|
}
|
||||||
|
|
||||||
public String getDelFlag() {
|
public String getDelFlag() {
|
||||||
return delFlag;
|
return delFlag;
|
||||||
}
|
}
|
||||||
|
|
@ -232,6 +242,7 @@ public class PrimaryRadarData extends BaseEntity
|
||||||
.append("type",getType())
|
.append("type",getType())
|
||||||
.append("totalCount",getTotalCount())
|
.append("totalCount",getTotalCount())
|
||||||
.append("radarLocation",getRadarLocation())
|
.append("radarLocation",getRadarLocation())
|
||||||
|
.append("stationCode",getStationCode())
|
||||||
.append("ladleNumber",getLadleNumber())
|
.append("ladleNumber",getLadleNumber())
|
||||||
.append("radarIp",getRadarIp())
|
.append("radarIp",getRadarIp())
|
||||||
.append("delFlag", getDelFlag())
|
.append("delFlag", getDelFlag())
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,8 @@ public class SysDiscern extends BaseEntity
|
||||||
*/
|
*/
|
||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
|
|
||||||
|
private Integer stationCode;
|
||||||
|
|
||||||
public SysDiscern() {
|
public SysDiscern() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -132,6 +134,14 @@ public class SysDiscern extends BaseEntity
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getStationCode() {
|
||||||
|
return stationCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStationCode(Integer stationCode) {
|
||||||
|
this.stationCode = stationCode;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Date getCreateTime() {
|
public Date getCreateTime() {
|
||||||
return createTime;
|
return createTime;
|
||||||
|
|
@ -161,6 +171,7 @@ public class SysDiscern extends BaseEntity
|
||||||
.append("number",getNumber())
|
.append("number",getNumber())
|
||||||
.append("type",getType())
|
.append("type",getType())
|
||||||
.append("count",getCount())
|
.append("count",getCount())
|
||||||
|
.append("stationCode",getStationCode())
|
||||||
.append("radarLocation",getRadarLocation())
|
.append("radarLocation",getRadarLocation())
|
||||||
.append("ladleNumber",getLadleNumber())
|
.append("ladleNumber",getLadleNumber())
|
||||||
.append("createTime", getCreateTime())
|
.append("createTime", getCreateTime())
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,10 @@ public class TsanaRadar {
|
||||||
|
|
||||||
public Integer timeCount;
|
public Integer timeCount;
|
||||||
|
|
||||||
|
public TsanaRadar(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public TsanaRadar(String radarCode, String labelCode, String locationIp, String labelNum, Date timeBegin, Date timeEnd, Integer timeCount) {
|
public TsanaRadar(String radarCode, String labelCode, String locationIp, String labelNum, Date timeBegin, Date timeEnd, Integer timeCount) {
|
||||||
this.radarCode = radarCode;
|
this.radarCode = radarCode;
|
||||||
|
|
|
||||||
|
|
@ -19,24 +19,21 @@ public class SocketUtil {
|
||||||
dataResponse.setRadarIp(radarIp);
|
dataResponse.setRadarIp(radarIp);
|
||||||
dataResponse.setRadarLocation(radarLocation);
|
dataResponse.setRadarLocation(radarLocation);
|
||||||
try {
|
try {
|
||||||
// boolean connected = socket.isConnected();
|
boolean connected = socket.isConnected();
|
||||||
// if (!connected) {
|
if (!connected) {
|
||||||
//
|
dataResponse.setStatus(0);
|
||||||
// }else {
|
}else {
|
||||||
//
|
dataResponse.setStatus(1);
|
||||||
// }
|
}
|
||||||
|
RadarStatusWebSocket.sendToAll(JSON.toJSONString(dataResponse));
|
||||||
InputStream inputStream = socket.getInputStream(); // 获取输入流
|
InputStream inputStream = socket.getInputStream(); // 获取输入流
|
||||||
int available = inputStream.available();
|
int available = inputStream.available();
|
||||||
byte[] buffer = new byte[available];
|
byte[] buffer = new byte[available];
|
||||||
inputStream.read(buffer, 0, available);
|
inputStream.read(buffer, 0, available);
|
||||||
if (buffer.length!= 0){
|
|
||||||
dataResponse.setStatus(1);
|
|
||||||
}else {
|
|
||||||
// System.out.println("雷达:" + radarIp + "===" + radarLocation + ": 连接异常:{}" );
|
// System.out.println("雷达:" + radarIp + "===" + radarLocation + ": 连接异常:{}" );
|
||||||
dataResponse.setStatus(0);
|
|
||||||
dataResponse.setData(null);
|
|
||||||
}
|
|
||||||
String hex = new BigInteger(1, buffer).toString(16);
|
String hex = new BigInteger(1, buffer).toString(16);
|
||||||
|
|
||||||
if (!"0".equals(hex)) {
|
if (!"0".equals(hex)) {
|
||||||
|
|
@ -50,7 +47,6 @@ public class SocketUtil {
|
||||||
|
|
||||||
dataResponse.setData(decimal);
|
dataResponse.setData(decimal);
|
||||||
|
|
||||||
RadarStatusWebSocket.sendToAll(JSON.toJSONString(dataResponse));
|
|
||||||
return dataResponse;
|
return dataResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,16 +5,19 @@ import com.ruoyi.common.utils.SocketModel;
|
||||||
import com.ruoyi.common.utils.SocketUtil;
|
import com.ruoyi.common.utils.SocketUtil;
|
||||||
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.system.service.ISysIdentifierService;
|
import com.ruoyi.system.service.*;
|
||||||
import com.ruoyi.system.service.ISysRadarService;
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import com.ruoyi.system.service.PrimaryRadarDataService;
|
import org.apache.commons.lang3.RandomUtils;
|
||||||
import com.ruoyi.system.service.RadarRealTimeDataService;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
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.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
@ -31,6 +34,9 @@ public class RadarRealTimeDataServiceImpl implements RadarRealTimeDataService, I
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysRadarService service;
|
private ISysRadarService service;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysDiscernService discernService;
|
||||||
|
|
||||||
public static CopyOnWriteArrayList<String> allRadar = new CopyOnWriteArrayList<>();
|
public static CopyOnWriteArrayList<String> allRadar = new CopyOnWriteArrayList<>();
|
||||||
|
|
||||||
// public static Integer count = 0 ;
|
// public static Integer count = 0 ;
|
||||||
|
|
@ -38,10 +44,10 @@ public class RadarRealTimeDataServiceImpl implements RadarRealTimeDataService, I
|
||||||
// private Integer consecutiveZeros = 0;
|
// private Integer consecutiveZeros = 0;
|
||||||
|
|
||||||
|
|
||||||
private Map<Long,String> radarDelMap = new HashMap<>();
|
private Map<Long, String> radarDelMap = new HashMap<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterPropertiesSet() {
|
public void afterPropertiesSet() {
|
||||||
List<SysRadar> radarList = service.selectRadarList(new SysRadar());
|
List<SysRadar> radarList = service.selectRadarList(new SysRadar());
|
||||||
|
|
||||||
CompletableFuture.runAsync(() -> {
|
CompletableFuture.runAsync(() -> {
|
||||||
|
|
@ -57,16 +63,13 @@ public class RadarRealTimeDataServiceImpl implements RadarRealTimeDataService, I
|
||||||
radarDelMap.put(radar.getId(), "0");
|
radarDelMap.put(radar.getId(), "0");
|
||||||
|
|
||||||
CompletableFuture.runAsync(() -> {
|
CompletableFuture.runAsync(() -> {
|
||||||
|
task(radar, socket);
|
||||||
|
|
||||||
while (StringUtils.equals("0",radarDelMap.get(radar.getId()))) {
|
// try {
|
||||||
|
// Thread.sleep(3000);
|
||||||
task(radar, socket);
|
// } catch (InterruptedException e) {
|
||||||
try {
|
// throw new RuntimeException(e);
|
||||||
Thread.sleep(3000);
|
// }
|
||||||
} catch (InterruptedException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
@ -76,59 +79,144 @@ public class RadarRealTimeDataServiceImpl implements RadarRealTimeDataService, I
|
||||||
}
|
}
|
||||||
|
|
||||||
private void task(SysRadar radar, Socket socket) {
|
private void task(SysRadar radar, Socket socket) {
|
||||||
int count = 0;
|
long noDataStart = System.currentTimeMillis();
|
||||||
int consecutiveZeros = 0;
|
long start = noDataStart;
|
||||||
CompletableFuture.runAsync(() ->{
|
|
||||||
|
|
||||||
});
|
Map<String, List<PrimaryRadarData>> map = new HashMap<>();
|
||||||
Map<String, List<Integer>> pulse4Number = new HashMap<>();
|
|
||||||
try {
|
|
||||||
// socket连接成功返回数据
|
|
||||||
DataResponse data = SocketUtil.getData(socket, radar.getRadarLocation(), radar.getRadarIp());
|
|
||||||
// 天线号字符串转集合
|
|
||||||
List<String> numberList = convertStringToList(radar.getRadarNum());
|
|
||||||
SysDiscern sysDiscern = copyDataToDiscern(data);
|
|
||||||
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);
|
|
||||||
|
|
||||||
primaryRadarData.setRadarLocation(radar.getRadarLocation());
|
while (StringUtils.equals("0", radarDelMap.get(radar.getId()))) {
|
||||||
//判断读取数据中是否携带标签
|
// int count = 0;
|
||||||
if (!"0".equals(modbusResponse.getTagId())) {
|
// int consecutiveZeros = 0;
|
||||||
|
|
||||||
|
|
||||||
// 根据标签去数据库查询标签列表
|
List<PrimaryRadarData> dataList = new ArrayList<>();
|
||||||
sysIdentifier = identifierService.selectIdentifierByTag(tag);
|
try {
|
||||||
//判断数据库查询结果是否有数据
|
// socket连接成功返回数据
|
||||||
if (sysIdentifier != null) {
|
DataResponse data = SocketUtil.getData(socket, radar.getRadarLocation(), radar.getRadarIp());
|
||||||
// 有数据将查询到的标识器配置属性放进原始数据对象
|
long current = System.currentTimeMillis();
|
||||||
primaryRadarData.setLadleNumber(sysIdentifier.getLadleNumber());
|
|
||||||
primaryRadarData.setRadarIp(radar.getRadarIp());
|
// 雷达数据返回封装类赋值
|
||||||
if (modbusResponse.getValue4() != 0) {
|
ModbusResponse modbusResponse = getModbusResponse(data);
|
||||||
// 给雷达识别报表赋值
|
String tag = modbusResponse.getTagId();
|
||||||
sysDiscern.setType(sysIdentifier.getType());
|
// 雷达原始数据对象
|
||||||
sysDiscern.setRadarLocation(radar.getRadarLocation());
|
PrimaryRadarData primaryRadarData = new PrimaryRadarData();
|
||||||
sysDiscern.setLadleNumber(sysIdentifier.getLadleNumber());
|
// 标识器对象
|
||||||
sysDiscern.setCreateTime(new Date());
|
SysIdentifier sysIdentifier = new SysIdentifier();
|
||||||
|
// 拷贝封装类属性到雷达原始数据对象
|
||||||
|
BeanUtils.copyProperties(modbusResponse, primaryRadarData);
|
||||||
|
primaryRadarData.setRadarIp(radar.getRadarIp());
|
||||||
|
primaryRadarData.setStationCode(radar.getStationCode());
|
||||||
|
primaryRadarData.setRadarLocation(radar.getRadarLocation());
|
||||||
|
//判断读取数据中是否携带标签
|
||||||
|
|
||||||
|
if (!"0".equals(modbusResponse.getTagId())) {
|
||||||
|
// 根据标签去数据库查询标签列表
|
||||||
|
sysIdentifier = identifierService.selectIdentifierByTag(tag);
|
||||||
|
//判断数据库查询结果是否有数据
|
||||||
|
if (sysIdentifier != null) {
|
||||||
|
// 有数据将查询到的标识器配置属性放进原始数据对象
|
||||||
|
primaryRadarData.setLadleNumber(sysIdentifier.getLadleNumber());
|
||||||
|
primaryRadarData.setRadarIp(radar.getRadarIp());
|
||||||
|
primaryRadarData.setType(sysIdentifier.getType().toString());
|
||||||
|
for (int i = 0; i < 20; i++) {
|
||||||
|
dataList.add(primaryRadarData);
|
||||||
}
|
}
|
||||||
|
int count = 0;
|
||||||
|
while (true){
|
||||||
|
map.put(getMapKey(radar), dataList);
|
||||||
|
if (count == 20){
|
||||||
|
Date date = new Date();
|
||||||
|
long milliseconds = date.getTime(); // 获取当前日期的毫秒数
|
||||||
|
long newMilliseconds = milliseconds + (count * 200); // 加上次数乘以200毫秒
|
||||||
|
Date newDate = new Date(newMilliseconds); // 转换成新的 Date 类型
|
||||||
|
|
||||||
|
|
||||||
|
resolveDiscern(radar, primaryRadarData, map ,count,newDate ,date);
|
||||||
|
}
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
// 给雷达识别报表赋值
|
||||||
|
// TsanaRadar tsanaRadar = new TsanaRadar();
|
||||||
|
// tsanaRadar.setRadarCode(null);
|
||||||
|
// tsanaRadar.setLabelCode(null);
|
||||||
|
// tsanaRadar.setLocationIp(sysDiscern.getStationCode().toString());
|
||||||
|
// tsanaRadar.setLabelNum(sysDiscern.getTagId());
|
||||||
|
// tsanaRadar.setTimeBegin((java.sql.Date) sysDiscern.getCreateTime());
|
||||||
|
// tsanaRadar.setTimeEnd((java.sql.Date) sysDiscern.getUpdateTime());
|
||||||
|
// tsanaRadar.setTimeCount(count);
|
||||||
|
//
|
||||||
|
// oracleInsert(tsanaRadar);
|
||||||
|
|
||||||
|
// 没数据返回data.data == null
|
||||||
|
// if (Objects.isNull(data.getData())) {
|
||||||
|
// // 连续5秒没读到数据,结束
|
||||||
|
// if (current - noDataStart >= 5000) {
|
||||||
|
// // todo:存数据
|
||||||
|
// List<PrimaryRadarData> primaryRadarDataList = map.get(getMapKey(radar));
|
||||||
|
//// primaryRadarDataList.stream().filter()
|
||||||
|
// noDataStart = current;
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// // 有数据返回数据
|
||||||
|
// // 有id,且时间>=20000
|
||||||
|
// if (data.getData().get(3) != 0 && current - start >= 20000) {
|
||||||
|
// // todo:存数据
|
||||||
|
//
|
||||||
|
// start = current;
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
//连续10次读取标签号为0
|
||||||
|
|
||||||
// 没有配置过将铁包号置空
|
// 没有配置过将铁包号置空
|
||||||
primaryRadarData.setLadleNumber(null);
|
primaryRadarData.setLadleNumber(null);
|
||||||
primaryRadarData.setRadarIp(radar.getRadarIp());
|
primaryRadarData.setRadarIp(radar.getRadarIp());
|
||||||
}
|
}
|
||||||
CompletableFuture.runAsync(() -> {
|
CompletableFuture.runAsync(() -> {
|
||||||
// primaryRadarDataService.insertPrimaryRadarData(primaryRadarData);
|
// primaryRadarDataService.insertPrimaryRadarData(primaryRadarData);
|
||||||
});
|
});
|
||||||
|
noDataStart = current;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getMapKey(SysRadar radar) {
|
||||||
|
return radar.getRadarIp() + "-" + radar.getRadarNum();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void resolveDiscern(SysRadar radar, PrimaryRadarData primaryRadarData, Map<String, List<PrimaryRadarData>> map , int count,Date newDate ,Date date) {
|
||||||
|
List<PrimaryRadarData> primaryRadarDataList1 = map.get(getMapKey(radar));
|
||||||
|
|
||||||
|
List<PrimaryRadarData> primaryRadarDataList = new ArrayList<>();
|
||||||
|
primaryRadarDataList.add(primaryRadarData);
|
||||||
|
map.put(getMapKey(radar), primaryRadarDataList);
|
||||||
|
List<String> numberList = convertStringToList(radar.getRadarNum());
|
||||||
|
SysDiscern sysDiscern = copyDataToDiscern(primaryRadarData);
|
||||||
|
// 给雷达识别报表赋值
|
||||||
|
sysDiscern.setType(Integer.parseInt(primaryRadarData.getType()));
|
||||||
|
sysDiscern.setRadarLocation(radar.getRadarLocation());
|
||||||
|
sysDiscern.setLadleNumber(primaryRadarData.getLadleNumber());
|
||||||
|
sysDiscern.setCreateTime(date );
|
||||||
|
sysDiscern.setTagId(primaryRadarData.getTagId());
|
||||||
|
sysDiscern.setCount(count);
|
||||||
|
sysDiscern.setUpdateTime(newDate);
|
||||||
|
sysDiscern.setStationCode(radar.getStationCode());
|
||||||
|
discernService.insertDiscern(sysDiscern);
|
||||||
|
// TsanaRadar tsanaRadar = new TsanaRadar();
|
||||||
|
// tsanaRadar.setRadarCode(null);
|
||||||
|
// tsanaRadar.setLabelCode(null);
|
||||||
|
// tsanaRadar.setLocationIp(sysDiscern.getStationCode().toString());
|
||||||
|
// tsanaRadar.setLabelNum(sysDiscern.getTagId());
|
||||||
|
// tsanaRadar.setTimeBegin((java.sql.Date) sysDiscern.getCreateTime());
|
||||||
|
// tsanaRadar.setTimeEnd((java.sql.Date) sysDiscern.getUpdateTime());
|
||||||
|
// tsanaRadar.setTimeCount(count);
|
||||||
|
//
|
||||||
|
// oracleInsert(tsanaRadar);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -139,7 +227,7 @@ public class RadarRealTimeDataServiceImpl implements RadarRealTimeDataService, I
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delRadar(Long id) {
|
public void delRadar(Long id) {
|
||||||
radarDelMap.put(id,"1");
|
radarDelMap.put(id, "1");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -160,11 +248,11 @@ public class RadarRealTimeDataServiceImpl implements RadarRealTimeDataService, I
|
||||||
* @param data
|
* @param data
|
||||||
* @return ModbusResponse
|
* @return ModbusResponse
|
||||||
*/
|
*/
|
||||||
private static SysDiscern copyDataToDiscern(DataResponse data) {
|
private static SysDiscern copyDataToDiscern(PrimaryRadarData data) {
|
||||||
SysDiscern discern = new SysDiscern();
|
SysDiscern discern = new SysDiscern();
|
||||||
discern.setTagId(data.getData().get(3).toString());
|
discern.setTagId(data.getTagId());
|
||||||
discern.setValue4(data.getData().get(7));
|
discern.setValue4(data.getValue4());
|
||||||
discern.setNumber(data.getData().get(11));
|
discern.setNumber(data.getNumber());
|
||||||
return discern;
|
return discern;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -188,4 +276,52 @@ public class RadarRealTimeDataServiceImpl implements RadarRealTimeDataService, I
|
||||||
modbusResponse.setNumber(data.getData().get(11));
|
modbusResponse.setNumber(data.getData().get(11));
|
||||||
return modbusResponse;
|
return modbusResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static void oracleInsert(TsanaRadar tsanaRadar) {
|
||||||
|
Connection connection = null;
|
||||||
|
PreparedStatement preparedStatement = null;
|
||||||
|
try {
|
||||||
|
Class.forName("oracle.jdbc.driver.OracleDriver");
|
||||||
|
|
||||||
|
String url = "jdbc:oracle:thin:@172.16.18.195:1523:xccb";
|
||||||
|
String user = "radartest";
|
||||||
|
String password = "radartest";
|
||||||
|
connection = DriverManager.getConnection(url,user,password);
|
||||||
|
System.out.println(" ============= 连接数据库成功 ==========");
|
||||||
|
// ====================================================雷达编号, 标签编号, 工位代号, 标签号, 开始时间, 结束时间, 读取次数
|
||||||
|
String insertStatement = "INSERT INTO xccb.TS_ANARADAR (RADARCODE, LABELCODE, LOCATIONIP , LABELNUM , TIMEBEGIN , TIMEEND , TIMECOUNT) VALUES (?, ?, ?, ?, ?, ?, ?)";
|
||||||
|
|
||||||
|
preparedStatement = connection.prepareStatement(insertStatement);
|
||||||
|
|
||||||
|
preparedStatement.setString(1,null);
|
||||||
|
preparedStatement.setString(2,null);
|
||||||
|
preparedStatement.setString(3,tsanaRadar.getLocationIp());
|
||||||
|
preparedStatement.setString(4,tsanaRadar.getLabelNum());
|
||||||
|
preparedStatement.setDate(5,tsanaRadar.getTimeBegin());
|
||||||
|
preparedStatement.setDate(6,tsanaRadar.getTimeEnd());
|
||||||
|
preparedStatement.setInt(7,tsanaRadar.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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (connection != null) {
|
||||||
|
try {
|
||||||
|
connection.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<result property="number" column="number" />
|
<result property="number" column="number" />
|
||||||
<result property="radarLocation" column="radar_location" />
|
<result property="radarLocation" column="radar_location" />
|
||||||
<result property="ladleNumber" column="ladle_number" />
|
<result property="ladleNumber" column="ladle_number" />
|
||||||
|
<result property="stationCode" column="station_code" />
|
||||||
<result property="radarIp" column="radar_ip" />
|
<result property="radarIp" column="radar_ip" />
|
||||||
<result property="totalCount" column="total_count" />
|
<result property="totalCount" column="total_count" />
|
||||||
|
<result property="type" column="type" />
|
||||||
<result property="createBy" column="create_by" />
|
<result property="createBy" column="create_by" />
|
||||||
<result property="createTime" column="create_time" />
|
<result property="createTime" column="create_time" />
|
||||||
<result property="updateBy" column="update_by" />
|
<result property="updateBy" column="update_by" />
|
||||||
|
|
@ -28,7 +30,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<select id="selectPrimaryRadarDataList" resultMap="PrimaryRadarDataResult">
|
<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.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
|
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.station_code,p.type,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'
|
where p.del_flag = '0'
|
||||||
<if test="radarLocation != null and radarLocation != ''">
|
<if test="radarLocation != null and radarLocation != ''">
|
||||||
AND p.radar_location like concat('%',#{radarLocation}, '%')
|
AND p.radar_location like concat('%',#{radarLocation}, '%')
|
||||||
|
|
@ -55,7 +57,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
value5,
|
value5,
|
||||||
base_line,
|
base_line,
|
||||||
query_fre,
|
query_fre,
|
||||||
|
station_code,
|
||||||
number,
|
number,
|
||||||
|
type,
|
||||||
<if test="radarLocation != null and radarLocation != ''">radar_location,</if>
|
<if test="radarLocation != null and radarLocation != ''">radar_location,</if>
|
||||||
<if test="ladleNumber != null and ladleNumber != ''">ladle_number,</if>
|
<if test="ladleNumber != null and ladleNumber != ''">ladle_number,</if>
|
||||||
<if test="radarIp != null and radarIp != ''">radar_ip,</if>
|
<if test="radarIp != null and radarIp != ''">radar_ip,</if>
|
||||||
|
|
@ -73,7 +77,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
#{value5},
|
#{value5},
|
||||||
#{baseLine},
|
#{baseLine},
|
||||||
#{queryFre},
|
#{queryFre},
|
||||||
|
#{stationCode},
|
||||||
#{number},
|
#{number},
|
||||||
|
#{type},
|
||||||
<if test="radarLocation != null and radarLocation != ''">#{radarLocation},</if>
|
<if test="radarLocation != null and radarLocation != ''">#{radarLocation},</if>
|
||||||
<if test="ladleNumber != null and ladleNumber != ''">#{ladleNumber},</if>
|
<if test="ladleNumber != null and ladleNumber != ''">#{ladleNumber},</if>
|
||||||
<if test="radarIp != null and radarIp != ''">#{radarIp},</if>
|
<if test="radarIp != null and radarIp != ''">#{radarIp},</if>
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<result property="radarLocation" column="radar_location" />
|
<result property="radarLocation" column="radar_location" />
|
||||||
<result property="count" column="count" />
|
<result property="count" column="count" />
|
||||||
<result property="type" column="type" />
|
<result property="type" column="type" />
|
||||||
|
<result property="stationCode" column="station_code" />
|
||||||
<result property="value4" column="value4" />
|
<result property="value4" column="value4" />
|
||||||
<result property="number" column="number" />
|
<result property="number" column="number" />
|
||||||
<result property="createTime" column="create_time" />
|
<result property="createTime" column="create_time" />
|
||||||
|
|
@ -97,27 +98,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
|
||||||
<insert id="insertDiscern">
|
<insert id="insertDiscern">
|
||||||
insert into sys_discern(
|
insert into sys_discern(
|
||||||
<if test="id != null and id != 0">id,</if>
|
id,
|
||||||
<if test="tagId != null and tagId != ''">tag_id,</if>
|
tag_id,
|
||||||
<if test="ladleNumber != null and ladleNumber != ''">ladle_number,</if>
|
ladle_number,
|
||||||
<if test="radarLocation != null and radarLocation != ''">radar_location,</if>
|
radar_location,
|
||||||
<if test="count != null and count != ''">count,</if>
|
count,
|
||||||
<if test="type != null and type != ''">type,</if>
|
type,
|
||||||
<if test="value4 != null and value4 != ''">value4,</if>
|
value4,
|
||||||
<if test="number != null and number != ''">number,</if>
|
number,
|
||||||
<if test="createTime != null and createTime != ''">create_time,</if>
|
create_time,
|
||||||
<if test="updateTime != null and updateTime != ''">update_time,</if>
|
update_time,
|
||||||
|
station_code
|
||||||
)values(
|
)values(
|
||||||
<if test="id != null and id != 0">#{id},</if>
|
#{id},
|
||||||
<if test="tagId != null and tagId != ''">#{tagId},</if>
|
#{tagId},
|
||||||
<if test="ladleNumber != null and ladleNumber != ''">#{ladleNumber},</if>
|
#{ladleNumber},
|
||||||
<if test="radarLocation != null and radarLocation != ''">#{radarLocation},</if>
|
#{radarLocation},
|
||||||
<if test="count != null and count != ''">#{count},</if>
|
#{count},
|
||||||
<if test="type != null and type != ''">#{type},</if>
|
#{type},
|
||||||
<if test="value4 != null and value4 != ''">#{value4},</if>
|
#{value4},
|
||||||
<if test="number != null and number != ''">#{number},</if>
|
#{number},
|
||||||
<if test="createTime != null" >#{createTime},</if>
|
#{createTime},
|
||||||
<if test="updateTime != null" >#{updateTime},</if>
|
#{updateTime},
|
||||||
|
#{stationCode}
|
||||||
)
|
)
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue