mac代码上传

detached
王宇航 2024-01-29 21:33:35 +08:00
parent 3b1afb5d73
commit 5f7925d721
9 changed files with 117 additions and 73 deletions

View File

@ -60,10 +60,10 @@ public class SysDiscernController extends BaseController {
startPage();
List<PrimaryRadarData> list = primaryRadarDataService.selectRadarTable(primaryRadarData);
list.stream().forEach(primaryRadarData1 -> {
if (StringUtils.isNotEmpty(primaryRadarData1.getLadleNumber())){
if (primaryRadarData1.getLadleNumber().contains("车")){
if (StringUtils.isNotEmpty(primaryRadarData1.getType())){
if (("0").equals(primaryRadarData1.getType())){
primaryRadarData1.setType("车架");
primaryRadarData1.setType("铁包");
} else if (primaryRadarData1.getLadleNumber().contains("铁")) {
primaryRadarData1.setType("铁包");
}else {

View File

@ -57,7 +57,7 @@ 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();
@ -77,51 +77,7 @@ 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();
}
}
}
}

View File

@ -6,9 +6,9 @@ spring:
druid:
# 主库数据源
master:
url: jdbc:mysql://localhost:3306/ry?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
url: jdbc:mysql://39.104.15.118:3306/ry?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: 12345678
password: Orderfood@2022
# 从库数据源
slave:
# 从数据源开关/默认关闭

View File

@ -75,6 +75,8 @@ public class PrimaryRadarData extends BaseEntity
private String ladleNumber;
private String totalCount;
private Integer stationCode;
/**
* ip
*/
@ -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;
}
@ -233,6 +243,7 @@ public class PrimaryRadarData extends BaseEntity
.append("totalCount",getTotalCount())
.append("radarLocation",getRadarLocation())
.append("ladleNumber",getLadleNumber())
.append("stationCode",getStationCode())
.append("radarIp",getRadarIp())
.append("delFlag", getDelFlag())
.append("createBy", getCreateBy())

View File

@ -22,7 +22,7 @@ public class TsanaRadar {
public Integer timeCount;
public TsanaRadar(String radarCode, String labelCode, String locationIp, String labelNum, Date timeBegin, Date timeEnd, Integer timeCount) {
public TsanaRadar() {
this.radarCode = radarCode;
this.labelCode = labelCode;
this.locationIp = locationIp;

View File

@ -3,6 +3,7 @@ package com.ruoyi.system.mapper;
import com.ruoyi.common.core.domain.entity.NormalIdentifier;
import com.ruoyi.common.core.domain.entity.PrimaryRadarData;
import com.ruoyi.common.core.domain.entity.RadarTableVO;
import org.apache.ibatis.annotations.Select;
import java.util.List;
@ -21,6 +22,5 @@ public interface PrimaryRadarDataMapper
int updatePrimaryRadarData(PrimaryRadarData primaryRadarData);
List<PrimaryRadarData> selectPrimaryRadarDataList(PrimaryRadarData primaryRadarData);
List<PrimaryRadarData> selectRadarTable(PrimaryRadarData primaryRadarData);
}

View File

@ -1,9 +1,6 @@
package com.ruoyi.system.service.impl;
import com.ruoyi.common.core.domain.entity.NormalIdentifier;
import com.ruoyi.common.core.domain.entity.PrimaryRadarData;
import com.ruoyi.common.core.domain.entity.RadarTableVO;
import com.ruoyi.common.core.domain.entity.SysRadar;
import com.ruoyi.common.core.domain.entity.*;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.system.mapper.NormalIdentifierMapper;
@ -17,6 +14,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.validation.Validator;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;
import java.util.stream.Collectors;
@ -63,6 +64,12 @@ public class PrimaryRadarDataServiceImpl implements PrimaryRadarDataService
List<PrimaryRadarData> radarTableVOS = primaryRadarDataMapper.selectRadarTable(primaryRadarData);
// TsanaRadar tsanaRadar = new TsanaRadar();
// tsanaRadar.setLocationIp(primaryRadarData.getStationCode().toString());
// oracleInsert(tsanaRadar);
return radarTableVOS;
}
@ -74,4 +81,50 @@ public class PrimaryRadarDataServiceImpl implements PrimaryRadarDataService
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();
}
}
}
}
}

View File

@ -31,11 +31,10 @@ public class RadarRealTimeDataServiceImpl implements RadarRealTimeDataService, I
@Autowired
private ISysRadarService service;
public static CopyOnWriteArrayList<String> allRadar = new CopyOnWriteArrayList<>();
@Autowired
private ExecutorService executorService = Executors.newFixedThreadPool(10);
// public static Integer count = 0 ;
//
// private Integer consecutiveZeros = 0;
public static CopyOnWriteArrayList<String> allRadar = new CopyOnWriteArrayList<>();
private Map<Long,String> radarDelMap = new HashMap<>();
@ -94,29 +93,40 @@ public class RadarRealTimeDataServiceImpl implements RadarRealTimeDataService, I
String tag = modbusResponse.getTagId();
// 雷达原始数据对象
PrimaryRadarData primaryRadarData = new PrimaryRadarData();
// 标识器对象
SysIdentifier sysIdentifier = new SysIdentifier();
// 拷贝封装类属性到雷达原始数据对象
BeanUtils.copyProperties(modbusResponse, primaryRadarData);
primaryRadarData.setStationCode(radar.getStationCode());
primaryRadarData.setRadarLocation(radar.getRadarLocation());
//判断读取数据中是否携带标签
if (!"0".equals(modbusResponse.getTagId())) {
// 根据标签去数据库查询标签列表
sysIdentifier = identifierService.selectIdentifierByTag(tag);
// 标识器对象
SysIdentifier 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());
SysIdentifier finalSysIdentifier = sysIdentifier;
CompletableFuture.runAsync(() -> {
sysDiscern.setType(finalSysIdentifier.getType());
sysDiscern.setRadarLocation(radar.getRadarLocation());
sysDiscern.setLadleNumber(finalSysIdentifier.getLadleNumber());
sysDiscern.setCreateTime(new Date());
sysDiscern.setNumber(modbusResponse.getNumber());
sysDiscern.setTagId(modbusResponse.getTagId());
sysDiscern.setValue4(modbusResponse.getValue4());
} , executorService);
}
}
} else {
@ -125,7 +135,7 @@ public class RadarRealTimeDataServiceImpl implements RadarRealTimeDataService, I
primaryRadarData.setRadarIp(radar.getRadarIp());
}
CompletableFuture.runAsync(() -> {
// primaryRadarDataService.insertPrimaryRadarData(primaryRadarData);
primaryRadarDataService.insertPrimaryRadarData(primaryRadarData);
});
} catch (Exception e) {
}

View File

@ -18,7 +18,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="radarLocation" column="radar_location" />
<result property="ladleNumber" column="ladle_number" />
<result property="radarIp" column="radar_ip" />
<result property="stationCode" column="station_code" />
<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" />
@ -44,6 +46,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
</select>
<!-- <select id="selectRadarTable" resultMap="PrimaryRadarDataResult">-->
<!-- SELECT radar_location, ladle_number, number, value4, radar_ip, tag_id, create_time, update_time, total_count-->
<!-- FROM (-->
<!-- SELECT radar_location, ladle_number, number, value4, radar_ip, tag_id, create_time, update_time,-->
<!-- COUNT(*) OVER (PARTITION BY radar_location, ladle_number, number, value4, radar_ip, tag_id) AS total_count,-->
<!-- ROW_NUMBER() OVER (PARTITION BY radar_location, ladle_number, number, value4, radar_ip, tag_id-->
<!-- ORDER BY create_time, update_time) AS row_num-->
<!-- FROM sys_primary_radar_data WHERE radar_ip IS NOT NULL AND tag_id != 0-->
<!-- ) subquery-->
<!-- WHERE row_num = 1-->
<!-- </select>-->
<insert id="insertPrimaryRadarData">
insert into sys_primary_radar_data(
<if test="id != null and id != 0">id,</if>
@ -87,13 +101,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectRadarTable" resultMap="PrimaryRadarDataResult">
SELECT radar_location, ladle_number, number, value4, radar_ip, tag_id, create_time, update_time, total_count
SELECT radar_location, ladle_number, number, value4, radar_ip, tag_id,MIN(create_time) OVER () AS create_time,MAX(update_time) OVER () AS update_time, total_count,station_code,type
FROM (
SELECT radar_location, ladle_number, number, value4, radar_ip, tag_id, create_time, update_time,
SELECT radar_location, ladle_number, number, value4, radar_ip, tag_id, create_time, update_time,station_code,type,
COUNT(*) OVER (PARTITION BY radar_location, ladle_number, number, value4, radar_ip, tag_id) AS total_count,
ROW_NUMBER() OVER (PARTITION BY radar_location, ladle_number, number, value4, radar_ip, tag_id
ORDER BY create_time, update_time) AS row_num
FROM sys_primary_radar_data
FROM sys_primary_radar_data WHERE radar_ip IS NOT NULL AND tag_id != 0
) subquery
WHERE row_num = 1
<if test="tagId != null and tagId != ''">