win代码上传
parent
3b1afb5d73
commit
f81d48c84b
|
|
@ -57,8 +57,6 @@ public class RadarStatusController {
|
|||
public TableDataInfo list(@RequestBody SysRadar sysRadar) {
|
||||
TableDataInfo rspData = new TableDataInfo();
|
||||
List<SysRadar> radarList = service.selectRadarList(sysRadar);
|
||||
// oracleInsert(tsanaRadarList);
|
||||
|
||||
|
||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||
if (null == pageDomain.getPageNum() || null == pageDomain.getPageSize()) {
|
||||
|
|
@ -77,51 +75,6 @@ public class RadarStatusController {
|
|||
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.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
|
@ -77,7 +78,9 @@ public class SysRadarController extends BaseController {
|
|||
radar.setCreateBy(getLoginName());
|
||||
int result = radarService.insertRadar(radar);
|
||||
List<SysRadar> sysRadars = radarService.selectRadarList(new SysRadar());
|
||||
radarRealTimeDataService.addRadar(sysRadars);
|
||||
CompletableFuture.runAsync(()->{
|
||||
radarRealTimeDataService.addRadar(sysRadars);
|
||||
});
|
||||
return toAjax(result);
|
||||
}
|
||||
|
||||
|
|
@ -109,7 +112,9 @@ public class SysRadarController extends BaseController {
|
|||
@ResponseBody
|
||||
public AjaxResult remove(String ids) {
|
||||
int result = radarService.deleteRadarByIds(ids);
|
||||
radarRealTimeDataService.delRadar(Long.valueOf(ids));
|
||||
CompletableFuture.runAsync(()->{
|
||||
radarRealTimeDataService.delRadar(Long.valueOf(ids));
|
||||
});
|
||||
return toAjax(result);
|
||||
}
|
||||
|
||||
|
|
@ -143,7 +148,9 @@ public class SysRadarController extends BaseController {
|
|||
ExcelUtil<RadarExcel> util = new ExcelUtil<RadarExcel>(RadarExcel.class);
|
||||
List<RadarExcel> radarList = util.importExcel(file.getInputStream());
|
||||
String message = radarService.importData(radarList, updateSupport);
|
||||
radarRealTimeDataService.addRadar(radarService.selectRadarList(new SysRadar()));
|
||||
CompletableFuture.runAsync(()->{
|
||||
radarRealTimeDataService.addRadar(radarService.selectRadarList(new SysRadar()));
|
||||
});
|
||||
return AjaxResult.success(message);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -83,6 +83,8 @@ public class PrimaryRadarData extends BaseEntity
|
|||
/** 删除标志(0代表存在 2代表删除) */
|
||||
private String delFlag;
|
||||
|
||||
private Integer stationCode;
|
||||
|
||||
private String type;
|
||||
|
||||
public String getType() {
|
||||
|
|
@ -208,6 +210,14 @@ public class PrimaryRadarData extends BaseEntity
|
|||
this.totalCount = totalCount;
|
||||
}
|
||||
|
||||
public Integer getStationCode() {
|
||||
return stationCode;
|
||||
}
|
||||
|
||||
public void setStationCode(Integer stationCode) {
|
||||
this.stationCode = stationCode;
|
||||
}
|
||||
|
||||
public String getDelFlag() {
|
||||
return delFlag;
|
||||
}
|
||||
|
|
@ -232,6 +242,7 @@ public class PrimaryRadarData extends BaseEntity
|
|||
.append("type",getType())
|
||||
.append("totalCount",getTotalCount())
|
||||
.append("radarLocation",getRadarLocation())
|
||||
.append("stationCode",getStationCode())
|
||||
.append("ladleNumber",getLadleNumber())
|
||||
.append("radarIp",getRadarIp())
|
||||
.append("delFlag", getDelFlag())
|
||||
|
|
|
|||
|
|
@ -65,6 +65,8 @@ public class SysDiscern extends BaseEntity
|
|||
*/
|
||||
private Date updateTime;
|
||||
|
||||
private Integer stationCode;
|
||||
|
||||
public SysDiscern() {
|
||||
}
|
||||
|
||||
|
|
@ -132,6 +134,14 @@ public class SysDiscern extends BaseEntity
|
|||
this.type = type;
|
||||
}
|
||||
|
||||
public Integer getStationCode() {
|
||||
return stationCode;
|
||||
}
|
||||
|
||||
public void setStationCode(Integer stationCode) {
|
||||
this.stationCode = stationCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
|
|
@ -161,6 +171,7 @@ public class SysDiscern extends BaseEntity
|
|||
.append("number",getNumber())
|
||||
.append("type",getType())
|
||||
.append("count",getCount())
|
||||
.append("stationCode",getStationCode())
|
||||
.append("radarLocation",getRadarLocation())
|
||||
.append("ladleNumber",getLadleNumber())
|
||||
.append("createTime", getCreateTime())
|
||||
|
|
|
|||
|
|
@ -21,6 +21,10 @@ public class TsanaRadar {
|
|||
|
||||
public Integer timeCount;
|
||||
|
||||
public TsanaRadar(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
public TsanaRadar(String radarCode, String labelCode, String locationIp, String labelNum, Date timeBegin, Date timeEnd, Integer timeCount) {
|
||||
this.radarCode = radarCode;
|
||||
|
|
|
|||
|
|
@ -19,24 +19,21 @@ public class SocketUtil {
|
|||
dataResponse.setRadarIp(radarIp);
|
||||
dataResponse.setRadarLocation(radarLocation);
|
||||
try {
|
||||
// boolean connected = socket.isConnected();
|
||||
// if (!connected) {
|
||||
//
|
||||
// }else {
|
||||
//
|
||||
// }
|
||||
|
||||
boolean connected = socket.isConnected();
|
||||
if (!connected) {
|
||||
dataResponse.setStatus(0);
|
||||
}else {
|
||||
dataResponse.setStatus(1);
|
||||
}
|
||||
RadarStatusWebSocket.sendToAll(JSON.toJSONString(dataResponse));
|
||||
InputStream inputStream = socket.getInputStream(); // 获取输入流
|
||||
int available = inputStream.available();
|
||||
byte[] buffer = new byte[available];
|
||||
inputStream.read(buffer, 0, available);
|
||||
if (buffer.length!= 0){
|
||||
dataResponse.setStatus(1);
|
||||
}else {
|
||||
|
||||
// System.out.println("雷达:" + radarIp + "===" + radarLocation + ": 连接异常:{}" );
|
||||
dataResponse.setStatus(0);
|
||||
dataResponse.setData(null);
|
||||
}
|
||||
|
||||
|
||||
String hex = new BigInteger(1, buffer).toString(16);
|
||||
|
||||
if (!"0".equals(hex)) {
|
||||
|
|
@ -50,7 +47,6 @@ public class SocketUtil {
|
|||
|
||||
dataResponse.setData(decimal);
|
||||
|
||||
RadarStatusWebSocket.sendToAll(JSON.toJSONString(dataResponse));
|
||||
return dataResponse;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,16 +5,19 @@ import com.ruoyi.common.utils.SocketModel;
|
|||
import com.ruoyi.common.utils.SocketUtil;
|
||||
import com.ruoyi.common.utils.bean.BeanUtils;
|
||||
import com.ruoyi.common.utils.bean.ModbusResponse;
|
||||
import com.ruoyi.system.service.ISysIdentifierService;
|
||||
import com.ruoyi.system.service.ISysRadarService;
|
||||
import com.ruoyi.system.service.PrimaryRadarDataService;
|
||||
import com.ruoyi.system.service.RadarRealTimeDataService;
|
||||
import com.ruoyi.system.service.*;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.RandomUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
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.concurrent.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
|
@ -31,6 +34,9 @@ public class RadarRealTimeDataServiceImpl implements RadarRealTimeDataService, I
|
|||
@Autowired
|
||||
private ISysRadarService service;
|
||||
|
||||
@Autowired
|
||||
private ISysDiscernService discernService;
|
||||
|
||||
public static CopyOnWriteArrayList<String> allRadar = new CopyOnWriteArrayList<>();
|
||||
|
||||
// public static Integer count = 0 ;
|
||||
|
|
@ -38,10 +44,10 @@ public class RadarRealTimeDataServiceImpl implements RadarRealTimeDataService, I
|
|||
// private Integer consecutiveZeros = 0;
|
||||
|
||||
|
||||
private Map<Long,String> radarDelMap = new HashMap<>();
|
||||
private Map<Long, String> radarDelMap = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
public void afterPropertiesSet() {
|
||||
List<SysRadar> radarList = service.selectRadarList(new SysRadar());
|
||||
|
||||
CompletableFuture.runAsync(() -> {
|
||||
|
|
@ -57,16 +63,13 @@ public class RadarRealTimeDataServiceImpl implements RadarRealTimeDataService, I
|
|||
radarDelMap.put(radar.getId(), "0");
|
||||
|
||||
CompletableFuture.runAsync(() -> {
|
||||
task(radar, socket);
|
||||
|
||||
while (StringUtils.equals("0",radarDelMap.get(radar.getId()))) {
|
||||
|
||||
task(radar, socket);
|
||||
try {
|
||||
Thread.sleep(3000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
// try {
|
||||
// Thread.sleep(3000);
|
||||
// } catch (InterruptedException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
@ -76,59 +79,144 @@ public class RadarRealTimeDataServiceImpl implements RadarRealTimeDataService, I
|
|||
}
|
||||
|
||||
private void task(SysRadar radar, Socket socket) {
|
||||
int count = 0;
|
||||
int consecutiveZeros = 0;
|
||||
CompletableFuture.runAsync(() ->{
|
||||
long noDataStart = System.currentTimeMillis();
|
||||
long start = noDataStart;
|
||||
|
||||
});
|
||||
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);
|
||||
Map<String, List<PrimaryRadarData>> map = new HashMap<>();
|
||||
|
||||
primaryRadarData.setRadarLocation(radar.getRadarLocation());
|
||||
//判断读取数据中是否携带标签
|
||||
if (!"0".equals(modbusResponse.getTagId())) {
|
||||
while (StringUtils.equals("0", radarDelMap.get(radar.getId()))) {
|
||||
// int count = 0;
|
||||
// int consecutiveZeros = 0;
|
||||
|
||||
|
||||
// 根据标签去数据库查询标签列表
|
||||
sysIdentifier = identifierService.selectIdentifierByTag(tag);
|
||||
//判断数据库查询结果是否有数据
|
||||
if (sysIdentifier != null) {
|
||||
// 有数据将查询到的标识器配置属性放进原始数据对象
|
||||
primaryRadarData.setLadleNumber(sysIdentifier.getLadleNumber());
|
||||
primaryRadarData.setRadarIp(radar.getRadarIp());
|
||||
if (modbusResponse.getValue4() != 0) {
|
||||
// 给雷达识别报表赋值
|
||||
sysDiscern.setType(sysIdentifier.getType());
|
||||
sysDiscern.setRadarLocation(radar.getRadarLocation());
|
||||
sysDiscern.setLadleNumber(sysIdentifier.getLadleNumber());
|
||||
sysDiscern.setCreateTime(new Date());
|
||||
List<PrimaryRadarData> dataList = new ArrayList<>();
|
||||
try {
|
||||
// socket连接成功返回数据
|
||||
DataResponse data = SocketUtil.getData(socket, radar.getRadarLocation(), radar.getRadarIp());
|
||||
long current = System.currentTimeMillis();
|
||||
|
||||
// 雷达数据返回封装类赋值
|
||||
ModbusResponse modbusResponse = getModbusResponse(data);
|
||||
String tag = modbusResponse.getTagId();
|
||||
// 雷达原始数据对象
|
||||
PrimaryRadarData primaryRadarData = new PrimaryRadarData();
|
||||
// 标识器对象
|
||||
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 {
|
||||
//连续10次读取标签号为0
|
||||
|
||||
// 没有配置过将铁包号置空
|
||||
primaryRadarData.setLadleNumber(null);
|
||||
primaryRadarData.setRadarIp(radar.getRadarIp());
|
||||
}
|
||||
CompletableFuture.runAsync(() -> {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
// primaryRadarDataService.insertPrimaryRadarData(primaryRadarData);
|
||||
});
|
||||
});
|
||||
noDataStart = current;
|
||||
} 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
|
||||
|
|
@ -139,7 +227,7 @@ public class RadarRealTimeDataServiceImpl implements RadarRealTimeDataService, I
|
|||
|
||||
@Override
|
||||
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
|
||||
* @return ModbusResponse
|
||||
*/
|
||||
private static SysDiscern copyDataToDiscern(DataResponse data) {
|
||||
private static SysDiscern copyDataToDiscern(PrimaryRadarData data) {
|
||||
SysDiscern discern = new SysDiscern();
|
||||
discern.setTagId(data.getData().get(3).toString());
|
||||
discern.setValue4(data.getData().get(7));
|
||||
discern.setNumber(data.getData().get(11));
|
||||
discern.setTagId(data.getTagId());
|
||||
discern.setValue4(data.getValue4());
|
||||
discern.setNumber(data.getNumber());
|
||||
return discern;
|
||||
}
|
||||
|
||||
|
|
@ -188,4 +276,52 @@ public class RadarRealTimeDataServiceImpl implements RadarRealTimeDataService, I
|
|||
modbusResponse.setNumber(data.getData().get(11));
|
||||
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="radarLocation" column="radar_location" />
|
||||
<result property="ladleNumber" column="ladle_number" />
|
||||
<result property="stationCode" column="station_code" />
|
||||
<result property="radarIp" column="radar_ip" />
|
||||
<result property="totalCount" column="total_count" />
|
||||
<result property="type" column="type" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
|
|
@ -28,7 +30,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.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'
|
||||
<if test="radarLocation != null and radarLocation != ''">
|
||||
AND p.radar_location like concat('%',#{radarLocation}, '%')
|
||||
|
|
@ -55,7 +57,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
value5,
|
||||
base_line,
|
||||
query_fre,
|
||||
station_code,
|
||||
number,
|
||||
type,
|
||||
<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>
|
||||
|
|
@ -73,7 +77,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
#{value5},
|
||||
#{baseLine},
|
||||
#{queryFre},
|
||||
#{stationCode},
|
||||
#{number},
|
||||
#{type},
|
||||
<if test="radarLocation != null and radarLocation != ''">#{radarLocation},</if>
|
||||
<if test="ladleNumber != null and ladleNumber != ''">#{ladleNumber},</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="count" column="count" />
|
||||
<result property="type" column="type" />
|
||||
<result property="stationCode" column="station_code" />
|
||||
<result property="value4" column="value4" />
|
||||
<result property="number" column="number" />
|
||||
<result property="createTime" column="create_time" />
|
||||
|
|
@ -97,27 +98,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
|
||||
<insert id="insertDiscern">
|
||||
insert into sys_discern(
|
||||
<if test="id != null and id != 0">id,</if>
|
||||
<if test="tagId != null and tagId != ''">tag_id,</if>
|
||||
<if test="ladleNumber != null and ladleNumber != ''">ladle_number,</if>
|
||||
<if test="radarLocation != null and radarLocation != ''">radar_location,</if>
|
||||
<if test="count != null and count != ''">count,</if>
|
||||
<if test="type != null and type != ''">type,</if>
|
||||
<if test="value4 != null and value4 != ''">value4,</if>
|
||||
<if test="number != null and number != ''">number,</if>
|
||||
<if test="createTime != null and createTime != ''">create_time,</if>
|
||||
<if test="updateTime != null and updateTime != ''">update_time,</if>
|
||||
id,
|
||||
tag_id,
|
||||
ladle_number,
|
||||
radar_location,
|
||||
count,
|
||||
type,
|
||||
value4,
|
||||
number,
|
||||
create_time,
|
||||
update_time,
|
||||
station_code
|
||||
)values(
|
||||
<if test="id != null and id != 0">#{id},</if>
|
||||
<if test="tagId != null and tagId != ''">#{tagId},</if>
|
||||
<if test="ladleNumber != null and ladleNumber != ''">#{ladleNumber},</if>
|
||||
<if test="radarLocation != null and radarLocation != ''">#{radarLocation},</if>
|
||||
<if test="count != null and count != ''">#{count},</if>
|
||||
<if test="type != null and type != ''">#{type},</if>
|
||||
<if test="value4 != null and value4 != ''">#{value4},</if>
|
||||
<if test="number != null and number != ''">#{number},</if>
|
||||
<if test="createTime != null" >#{createTime},</if>
|
||||
<if test="updateTime != null" >#{updateTime},</if>
|
||||
#{id},
|
||||
#{tagId},
|
||||
#{ladleNumber},
|
||||
#{radarLocation},
|
||||
#{count},
|
||||
#{type},
|
||||
#{value4},
|
||||
#{number},
|
||||
#{createTime},
|
||||
#{updateTime},
|
||||
#{stationCode}
|
||||
)
|
||||
</insert>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue