获取最新策略增加路由信息方法、交换机带宽收益
This commit is contained in:
@@ -140,5 +140,7 @@ public class EpsNodeBandwidth extends BaseEntity
|
|||||||
private List<String> switchNames;
|
private List<String> switchNames;
|
||||||
/** 计算方式 */
|
/** 计算方式 */
|
||||||
private String calculationMode;
|
private String calculationMode;
|
||||||
|
/** 客户端id */
|
||||||
|
private String clientId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,8 @@ public class InitialSwitchInfoDetails extends BaseEntity
|
|||||||
/** 发送流量(bytes/s) */
|
/** 发送流量(bytes/s) */
|
||||||
@Excel(name = "发送流量", readConverterExp = "b=ytes/s")
|
@Excel(name = "发送流量", readConverterExp = "b=ytes/s")
|
||||||
private BigDecimal outSpeed;
|
private BigDecimal outSpeed;
|
||||||
|
/** 发送或接收流量的最大值 */
|
||||||
|
private BigDecimal maxSpeed;
|
||||||
|
|
||||||
/** 交换机名称 */
|
/** 交换机名称 */
|
||||||
@Excel(name = "交换机名称")
|
@Excel(name = "交换机名称")
|
||||||
|
|||||||
@@ -481,11 +481,7 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
|
|||||||
* 计算并保存95带宽值
|
* 计算并保存95带宽值
|
||||||
*/
|
*/
|
||||||
private void calculateAndSave95Bandwidth(List<EpsInitialTrafficData> dataList, String dateTime, String dayOrMonth, String calculationMode) {
|
private void calculateAndSave95Bandwidth(List<EpsInitialTrafficData> dataList, String dateTime, String dayOrMonth, String calculationMode) {
|
||||||
boolean eff = false;
|
|
||||||
if(!dataList.isEmpty()){
|
if(!dataList.isEmpty()){
|
||||||
if(dataList.size()<288){
|
|
||||||
eff = true;
|
|
||||||
}
|
|
||||||
// 1. 提取并转换带宽值
|
// 1. 提取并转换带宽值
|
||||||
List<BigDecimal> speedsInMbps = dataList.stream()
|
List<BigDecimal> speedsInMbps = dataList.stream()
|
||||||
.map(data -> CalculateUtil.parseSpeedToMbps(data.getOutSpeed(), calculationMode))
|
.map(data -> CalculateUtil.parseSpeedToMbps(data.getOutSpeed(), calculationMode))
|
||||||
@@ -498,24 +494,11 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
|
|||||||
// 3. 保存结果
|
// 3. 保存结果
|
||||||
EpsInitialTrafficData epsInitialTrafficData = dataList.get(0);
|
EpsInitialTrafficData epsInitialTrafficData = dataList.get(0);
|
||||||
epsInitialTrafficData.setResourceType("1");
|
epsInitialTrafficData.setResourceType("1");
|
||||||
if("2".equals(epsInitialTrafficData.getRevenueMethod())){
|
if("1".equals(dayOrMonth)){
|
||||||
percentile95 = epsInitialTrafficData.getPackageBandwidth();
|
epsInitialTrafficData.setBandwidthType("1");
|
||||||
epsInitialTrafficData.setBandwidthType("3");
|
}
|
||||||
}else {
|
if("2".equals(dayOrMonth)){
|
||||||
if("1".equals(dayOrMonth)){
|
epsInitialTrafficData.setBandwidthType("2");
|
||||||
if(eff){
|
|
||||||
epsInitialTrafficData.setBandwidthType("5");
|
|
||||||
}else {
|
|
||||||
epsInitialTrafficData.setBandwidthType("1");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if("2".equals(dayOrMonth)){
|
|
||||||
if(eff){
|
|
||||||
epsInitialTrafficData.setBandwidthType("6");
|
|
||||||
}else {
|
|
||||||
epsInitialTrafficData.setBandwidthType("2");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
saveBandwidthResult(epsInitialTrafficData, percentile95, dateTime, calculationMode);
|
saveBandwidthResult(epsInitialTrafficData, percentile95, dateTime, calculationMode);
|
||||||
}
|
}
|
||||||
@@ -583,25 +566,11 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
|
|||||||
// 服务器信息
|
// 服务器信息
|
||||||
EpsInitialTrafficData epsInitialTrafficData = dataList.get(0);
|
EpsInitialTrafficData epsInitialTrafficData = dataList.get(0);
|
||||||
epsInitialTrafficData.setResourceType("1");
|
epsInitialTrafficData.setResourceType("1");
|
||||||
if("2".equals(epsInitialTrafficData.getRevenueMethod())){
|
if("1".equals(dayOrMonth)){
|
||||||
dailyResult = epsInitialTrafficData.getPackageBandwidth();
|
epsInitialTrafficData.setBandwidthType("1");
|
||||||
epsInitialTrafficData.setBandwidthType("3");
|
}
|
||||||
}else{
|
if("2".equals(dayOrMonth)){
|
||||||
if(CalculateUtil.isEff(dataList)){
|
epsInitialTrafficData.setBandwidthType("2");
|
||||||
if("1".equals(dayOrMonth)){
|
|
||||||
epsInitialTrafficData.setBandwidthType("5");
|
|
||||||
}
|
|
||||||
if("2".equals(dayOrMonth)){
|
|
||||||
epsInitialTrafficData.setBandwidthType("6");
|
|
||||||
}
|
|
||||||
}else {
|
|
||||||
if("1".equals(dayOrMonth)){
|
|
||||||
epsInitialTrafficData.setBandwidthType("1");
|
|
||||||
}
|
|
||||||
if("2".equals(dayOrMonth)){
|
|
||||||
epsInitialTrafficData.setBandwidthType("2");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
saveBandwidthResult(epsInitialTrafficData, dailyResult, startTime, calculationMode);
|
saveBandwidthResult(epsInitialTrafficData, dailyResult, startTime, calculationMode);
|
||||||
}
|
}
|
||||||
@@ -612,6 +581,7 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
|
|||||||
BigDecimal result,
|
BigDecimal result,
|
||||||
String dateTime, String calculationMode) {
|
String dateTime, String calculationMode) {
|
||||||
EpsNodeBandwidth bandwidth = new EpsNodeBandwidth();
|
EpsNodeBandwidth bandwidth = new EpsNodeBandwidth();
|
||||||
|
bandwidth.setClientId(data.getClientId());
|
||||||
bandwidth.setHardwareSn(data.getServiceSn());
|
bandwidth.setHardwareSn(data.getServiceSn());
|
||||||
bandwidth.setCalculationMode(calculationMode);
|
bandwidth.setCalculationMode(calculationMode);
|
||||||
bandwidth.setNodeName(data.getNodeName());
|
bandwidth.setNodeName(data.getNodeName());
|
||||||
|
|||||||
@@ -130,11 +130,12 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
|
|||||||
List<InitialSwitchInfoDetails> batchList = new ArrayList<>();
|
List<InitialSwitchInfoDetails> batchList = new ArrayList<>();
|
||||||
if(!dataList.isEmpty()){
|
if(!dataList.isEmpty()){
|
||||||
for (InitialSwitchInfoDetails details : dataList) {
|
for (InitialSwitchInfoDetails details : dataList) {
|
||||||
|
// 取发送或接收流量最大值赋值到maxSpeed
|
||||||
|
calculateMaxSpeed(details);
|
||||||
// id自增
|
// id自增
|
||||||
details.setId(null);
|
details.setId(null);
|
||||||
// 根据接口名称查询交换机信息
|
// 根据接口名称查询交换机信息
|
||||||
String interfaceName = details.getName();
|
String interfaceName = details.getName();
|
||||||
String switchSn = details.getSwitchSn();
|
|
||||||
RmEpsTopologyManagement rmEpsTopologyManagement = new RmEpsTopologyManagement();
|
RmEpsTopologyManagement rmEpsTopologyManagement = new RmEpsTopologyManagement();
|
||||||
rmEpsTopologyManagement.setInterfaceName(interfaceName);
|
rmEpsTopologyManagement.setInterfaceName(interfaceName);
|
||||||
rmEpsTopologyManagement.setSwitchIpAddress(details.getSwitchIp());
|
rmEpsTopologyManagement.setSwitchIpAddress(details.getSwitchIp());
|
||||||
@@ -192,6 +193,34 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 辅助方法
|
||||||
|
* 获取 inSpeed 和 outSpeed 的最大值并设置到 maxSpeed
|
||||||
|
* @param switchInfo 包含速度信息的实体类
|
||||||
|
*/
|
||||||
|
public static void calculateMaxSpeed(InitialSwitchInfoDetails switchInfo) {
|
||||||
|
if (switchInfo == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 获取 inSpeed 和 outSpeed
|
||||||
|
BigDecimal inSpeed = switchInfo.getInSpeed();
|
||||||
|
BigDecimal outSpeed = switchInfo.getOutSpeed();
|
||||||
|
// 处理可能为null的情况
|
||||||
|
if (inSpeed == null && outSpeed == null) {
|
||||||
|
switchInfo.setMaxSpeed(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (inSpeed == null) {
|
||||||
|
switchInfo.setMaxSpeed(outSpeed);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (outSpeed == null) {
|
||||||
|
switchInfo.setMaxSpeed(inSpeed);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 比较并设置最大值
|
||||||
|
switchInfo.setMaxSpeed(inSpeed.compareTo(outSpeed) > 0 ? inSpeed : outSpeed);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 批量处理接口名称
|
* 批量处理接口名称
|
||||||
*/
|
*/
|
||||||
@@ -314,7 +343,7 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
|
|||||||
|
|
||||||
// 遍历处理每个交换机
|
// 遍历处理每个交换机
|
||||||
switchSnList.forEach(interfaceName -> {
|
switchSnList.forEach(interfaceName -> {
|
||||||
queryParam.setSwitchSn(interfaceName.getSwitchSn());
|
queryParam.setClientId(interfaceName.getClientId());
|
||||||
queryParam.setSwitchIp(interfaceName.getSwitchIp());
|
queryParam.setSwitchIp(interfaceName.getSwitchIp());
|
||||||
processSwitchBandwidth(queryParam, dailyStartTime, dailyEndTime, calculationMode);
|
processSwitchBandwidth(queryParam, dailyStartTime, dailyEndTime, calculationMode);
|
||||||
});
|
});
|
||||||
@@ -330,6 +359,7 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
|
|||||||
public void recalculateSwitch95Bandwidth(EpsNodeBandwidth epsNodeBandwidth, String dailyStartTime,
|
public void recalculateSwitch95Bandwidth(EpsNodeBandwidth epsNodeBandwidth, String dailyStartTime,
|
||||||
String dailyEndTime, String calculationMode) {
|
String dailyEndTime, String calculationMode) {
|
||||||
InitialSwitchInfoDetails switchInfoDetails = new InitialSwitchInfoDetails();
|
InitialSwitchInfoDetails switchInfoDetails = new InitialSwitchInfoDetails();
|
||||||
|
switchInfoDetails.setClientId(epsNodeBandwidth.getClientId());
|
||||||
switchInfoDetails.setStartTime(dailyStartTime);
|
switchInfoDetails.setStartTime(dailyStartTime);
|
||||||
switchInfoDetails.setEndTime(dailyEndTime);
|
switchInfoDetails.setEndTime(dailyEndTime);
|
||||||
switchInfoDetails.setSwitchSn(epsNodeBandwidth.getSwitchSn());
|
switchInfoDetails.setSwitchSn(epsNodeBandwidth.getSwitchSn());
|
||||||
@@ -346,9 +376,7 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
|
|||||||
List<BigDecimal> speedsInMbps = dataList.stream()
|
List<BigDecimal> speedsInMbps = dataList.stream()
|
||||||
.map(data -> {
|
.map(data -> {
|
||||||
// 根据 interfaceDeviceType 选择 inSpeed 或 outSpeed
|
// 根据 interfaceDeviceType 选择 inSpeed 或 outSpeed
|
||||||
String speed = "1".equals(data.getInterfaceDeviceType())
|
String speed = data.getMaxSpeed() != null ? data.getMaxSpeed().toString() : BigDecimal.ZERO.toString();
|
||||||
? (data.getInSpeed() != null ? data.getInSpeed().toString() : BigDecimal.ZERO.toString())
|
|
||||||
: (data.getOutSpeed() != null ? data.getOutSpeed().toString() : BigDecimal.ZERO.toString());
|
|
||||||
// 如果 speed 是纯数字,补充单位 "B/S"(Bytes/s)
|
// 如果 speed 是纯数字,补充单位 "B/S"(Bytes/s)
|
||||||
if (speed.matches("^\\d+(\\.\\d+)?$")) {
|
if (speed.matches("^\\d+(\\.\\d+)?$")) {
|
||||||
speed += " B/S";
|
speed += " B/S";
|
||||||
@@ -436,7 +464,7 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
|
|||||||
String dailyEndTime, String calculationMode) {
|
String dailyEndTime, String calculationMode) {
|
||||||
// 根据交换机sn查询连接的服务器sn
|
// 根据交换机sn查询连接的服务器sn
|
||||||
RmEpsTopologyManagement management = new RmEpsTopologyManagement();
|
RmEpsTopologyManagement management = new RmEpsTopologyManagement();
|
||||||
management.setSwitchSn(queryParam.getSwitchSn());
|
management.setClientId(queryParam.getClientId());
|
||||||
management.setSwitchIpAddress(queryParam.getSwitchIp());
|
management.setSwitchIpAddress(queryParam.getSwitchIp());
|
||||||
List<RmEpsTopologyManagement> serverSnList = rmEpsTopologyManagementMapper.selectRmEpsTopologyManagementList(management);
|
List<RmEpsTopologyManagement> serverSnList = rmEpsTopologyManagementMapper.selectRmEpsTopologyManagementList(management);
|
||||||
if(!serverSnList.isEmpty()){
|
if(!serverSnList.isEmpty()){
|
||||||
@@ -444,19 +472,9 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
|
|||||||
queryParam.setName(rmEpsTopologyManagement.getInterfaceName());
|
queryParam.setName(rmEpsTopologyManagement.getInterfaceName());
|
||||||
if("1".equals(rmEpsTopologyManagement.getConnectedDeviceType())){
|
if("1".equals(rmEpsTopologyManagement.getConnectedDeviceType())){
|
||||||
queryParam.setServerSn(rmEpsTopologyManagement.getServerSn());
|
queryParam.setServerSn(rmEpsTopologyManagement.getServerSn());
|
||||||
// 检查交换机连接的服务器是否有业务变更(如果有相关配置)
|
|
||||||
EpsServerRevenueConfig revenueConfig = new EpsServerRevenueConfig();
|
|
||||||
revenueConfig.setHardwareSn(rmEpsTopologyManagement.getServerSn());
|
|
||||||
List<EpsServerRevenueConfig> changedList = epsServerRevenueConfigMapper
|
|
||||||
.selectEpsServerRevenueConfigList(revenueConfig);
|
|
||||||
// 根据业务变更情况选择计算方式
|
// 根据业务变更情况选择计算方式
|
||||||
if (hasTrafficMethodChanged(changedList)) {
|
calculateChangedSwitchBandwidth(queryParam, dailyStartTime, dailyEndTime, calculationMode);
|
||||||
calculateChangedSwitchBandwidth(queryParam, dailyStartTime, dailyEndTime, calculationMode);
|
}else{
|
||||||
} else {
|
|
||||||
calculateNormalSwitchBandwidth(queryParam, dailyStartTime, dailyEndTime, calculationMode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if("2".equals(rmEpsTopologyManagement.getConnectedDeviceType())){
|
|
||||||
queryParam.setServerSn(null);
|
queryParam.setServerSn(null);
|
||||||
calculateNormalSwitchBandwidth(queryParam, dailyStartTime, dailyEndTime, calculationMode);
|
calculateNormalSwitchBandwidth(queryParam, dailyStartTime, dailyEndTime, calculationMode);
|
||||||
}
|
}
|
||||||
@@ -480,7 +498,7 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
|
|||||||
String dailyEndTime, String calculationMode) {
|
String dailyEndTime, String calculationMode) {
|
||||||
// 获取业务变更记录(按时间降序)
|
// 获取业务变更记录(按时间降序)
|
||||||
EpsMethodChangeRecord changeQuery = new EpsMethodChangeRecord();
|
EpsMethodChangeRecord changeQuery = new EpsMethodChangeRecord();
|
||||||
changeQuery.setHardwareSn(queryParam.getServerSn());
|
changeQuery.setClientId(queryParam.getClientId());
|
||||||
changeQuery.setStartTime(dailyStartTime);
|
changeQuery.setStartTime(dailyStartTime);
|
||||||
changeQuery.setEndTime(dailyEndTime);
|
changeQuery.setEndTime(dailyEndTime);
|
||||||
List<EpsMethodChangeRecord> records = epsMethodChangeRecordMapper
|
List<EpsMethodChangeRecord> records = epsMethodChangeRecordMapper
|
||||||
@@ -518,18 +536,12 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
|
|||||||
*/
|
*/
|
||||||
private void calculateAndSaveSwitch95Bandwidth(List<InitialSwitchInfoDetails> dataList, String dateTime,
|
private void calculateAndSaveSwitch95Bandwidth(List<InitialSwitchInfoDetails> dataList, String dateTime,
|
||||||
String dayOrMonth, String calculationMode) {
|
String dayOrMonth, String calculationMode) {
|
||||||
boolean eff = false;
|
|
||||||
if(!dataList.isEmpty()){
|
if(!dataList.isEmpty()){
|
||||||
if(dataList.size()<288){
|
|
||||||
eff = true;
|
|
||||||
}
|
|
||||||
// 1. 提取并转换带宽值
|
// 1. 提取并转换带宽值
|
||||||
List<BigDecimal> speedsInMbps = dataList.stream()
|
List<BigDecimal> speedsInMbps = dataList.stream()
|
||||||
.map(data -> {
|
.map(data -> {
|
||||||
// 根据 interfaceDeviceType 选择 inSpeed 或 outSpeed
|
// 根据 interfaceDeviceType 选择 inSpeed 或 outSpeed
|
||||||
String speed = "1".equals(data.getInterfaceDeviceType())
|
String speed = data.getMaxSpeed() != null ? data.getMaxSpeed().toString() : BigDecimal.ZERO.toString();
|
||||||
? (data.getInSpeed() != null ? data.getInSpeed().toString() : BigDecimal.ZERO.toString())
|
|
||||||
: (data.getOutSpeed() != null ? data.getOutSpeed().toString() : BigDecimal.ZERO.toString());
|
|
||||||
// 如果 speed 是纯数字,补充单位 "B/S"(Bytes/s)
|
// 如果 speed 是纯数字,补充单位 "B/S"(Bytes/s)
|
||||||
if (speed.matches("^\\d+(\\.\\d+)?$")) {
|
if (speed.matches("^\\d+(\\.\\d+)?$")) {
|
||||||
speed += " B/S";
|
speed += " B/S";
|
||||||
@@ -546,18 +558,10 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
|
|||||||
InitialSwitchInfoDetails switchInfo = dataList.get(0);
|
InitialSwitchInfoDetails switchInfo = dataList.get(0);
|
||||||
switchInfo.setResourceType("2");
|
switchInfo.setResourceType("2");
|
||||||
if("1".equals(dayOrMonth)){
|
if("1".equals(dayOrMonth)){
|
||||||
if(eff){
|
switchInfo.setBandwidthType("1");
|
||||||
switchInfo.setBandwidthType("5");
|
|
||||||
}else{
|
|
||||||
switchInfo.setBandwidthType("1");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if("2".equals(dayOrMonth)){
|
if("2".equals(dayOrMonth)){
|
||||||
if(eff){
|
switchInfo.setBandwidthType("2");
|
||||||
switchInfo.setBandwidthType("6");
|
|
||||||
}else{
|
|
||||||
switchInfo.setBandwidthType("2");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
saveSwitchBandwidthResult(switchInfo, percentile95, dateTime, calculationMode);
|
saveSwitchBandwidthResult(switchInfo, percentile95, dateTime, calculationMode);
|
||||||
}
|
}
|
||||||
@@ -608,9 +612,7 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
|
|||||||
List<BigDecimal> speedsInMbps = dataList.stream()
|
List<BigDecimal> speedsInMbps = dataList.stream()
|
||||||
.map(data -> {
|
.map(data -> {
|
||||||
// 根据 interfaceDeviceType 选择 inSpeed 或 outSpeed
|
// 根据 interfaceDeviceType 选择 inSpeed 或 outSpeed
|
||||||
String speed = "1".equals(data.getInterfaceDeviceType())
|
String speed = data.getMaxSpeed() != null ? data.getMaxSpeed().toString() : BigDecimal.ZERO.toString();
|
||||||
? (data.getInSpeed() != null ? data.getInSpeed().toString() : BigDecimal.ZERO.toString())
|
|
||||||
: (data.getOutSpeed() != null ? data.getOutSpeed().toString() : BigDecimal.ZERO.toString());
|
|
||||||
if (speed.matches("^\\d+(\\.\\d+)?$")) {
|
if (speed.matches("^\\d+(\\.\\d+)?$")) {
|
||||||
speed += " B/S";
|
speed += " B/S";
|
||||||
}
|
}
|
||||||
@@ -626,20 +628,11 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
|
|||||||
// 3. 保存结果
|
// 3. 保存结果
|
||||||
InitialSwitchInfoDetails switchInfo = dataList.get(0);
|
InitialSwitchInfoDetails switchInfo = dataList.get(0);
|
||||||
switchInfo.setResourceType("2");
|
switchInfo.setResourceType("2");
|
||||||
if(CalculateUtil.isEff(dataList)){
|
if("1".equals(dayOrMonth)){
|
||||||
if("1".equals(dayOrMonth)){
|
switchInfo.setBandwidthType("1");
|
||||||
switchInfo.setBandwidthType("5");
|
}
|
||||||
}
|
if("2".equals(dayOrMonth)){
|
||||||
if("2".equals(dayOrMonth)){
|
switchInfo.setBandwidthType("2");
|
||||||
switchInfo.setBandwidthType("6");
|
|
||||||
}
|
|
||||||
}else {
|
|
||||||
if("1".equals(dayOrMonth)){
|
|
||||||
switchInfo.setBandwidthType("1");
|
|
||||||
}
|
|
||||||
if("2".equals(dayOrMonth)){
|
|
||||||
switchInfo.setBandwidthType("2");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
saveSwitchBandwidthResult(switchInfo, dailyResult, startTime, calculationMode);
|
saveSwitchBandwidthResult(switchInfo, dailyResult, startTime, calculationMode);
|
||||||
}
|
}
|
||||||
@@ -653,6 +646,7 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
|
|||||||
EpsNodeBandwidth bandwidth = new EpsNodeBandwidth();
|
EpsNodeBandwidth bandwidth = new EpsNodeBandwidth();
|
||||||
bandwidth.setBusinessName(data.getBusinessName());
|
bandwidth.setBusinessName(data.getBusinessName());
|
||||||
bandwidth.setBusinessId(data.getBusinessCode());
|
bandwidth.setBusinessId(data.getBusinessCode());
|
||||||
|
bandwidth.setClientId(data.getClientId());
|
||||||
bandwidth.setHardwareSn(data.getServerSn());
|
bandwidth.setHardwareSn(data.getServerSn());
|
||||||
bandwidth.setCalculationMode(calculationMode);
|
bandwidth.setCalculationMode(calculationMode);
|
||||||
bandwidth.setSwitchSn(data.getSwitchSn());
|
bandwidth.setSwitchSn(data.getSwitchSn());
|
||||||
|
|||||||
@@ -196,7 +196,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</foreach>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<!-- 检查接口名称是否存在 -->
|
|
||||||
<select id="getAllDeviceSn" parameterType="AllInterfaceName" resultType="AllInterfaceName">
|
<select id="getAllDeviceSn" parameterType="AllInterfaceName" resultType="AllInterfaceName">
|
||||||
SELECT
|
SELECT
|
||||||
device_sn AS deviceSn
|
device_sn AS deviceSn
|
||||||
@@ -207,18 +206,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</where>
|
</where>
|
||||||
group by device_sn
|
group by device_sn
|
||||||
</select>
|
</select>
|
||||||
<!-- 检查交换机接口名称是否存在 -->
|
|
||||||
<select id="getAllSwitchSn" parameterType="AllInterfaceName" resultType="AllInterfaceName">
|
<select id="getAllSwitchSn" parameterType="AllInterfaceName" resultType="AllInterfaceName">
|
||||||
SELECT
|
SELECT
|
||||||
switch_sn AS switchSn, switch_ip switchIp
|
client_id AS clientId, switch_ip switchIp
|
||||||
FROM
|
FROM
|
||||||
all_interface_name
|
all_interface_name
|
||||||
<where>
|
<where>
|
||||||
and resource_type = '2' and switch_sn != ''
|
and resource_type = '2' and client_id != ''
|
||||||
</where>
|
</where>
|
||||||
group by switch_sn
|
group by client_id
|
||||||
</select>
|
</select>
|
||||||
<!-- MyBatis Mapper XML配置 -->
|
|
||||||
<update id="batchUpdate" parameterType="java.util.List">
|
<update id="batchUpdate" parameterType="java.util.List">
|
||||||
<foreach collection="list" item="item" index="index" open="" separator=";" close="">
|
<foreach collection="list" item="item" index="index" open="" separator=";" close="">
|
||||||
UPDATE all_interface_name
|
UPDATE all_interface_name
|
||||||
|
|||||||
@@ -35,16 +35,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<result property="businessId" column="business_id" />
|
<result property="businessId" column="business_id" />
|
||||||
<result property="remark1" column="remark1" />
|
<result property="remark1" column="remark1" />
|
||||||
<result property="createDatetime" column="create_datetime" />
|
<result property="createDatetime" column="create_datetime" />
|
||||||
|
<result property="clientId" column="client_id" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectEpsNodeBandwidthVo">
|
<sql id="selectEpsNodeBandwidthVo">
|
||||||
select id, node_name, hardware_sn, calculation_mode, bandwidth_type, bandwidth_result, bandwidth_95_daily, bandwidth_95_monthly, avg_monthly_bandwidth_95, package_bandwidth_daily, machine_flow, customer_id, customer_name, service_number, uplink_switch, create_time, update_time, creator_id, creator_name, switch_sn, interface_name, resource_type, interface_link_device_type, effective_bandwidth_95_daily, effective_bandwidth_95_monthly, effective_avg_monthly_bandwidth_95, business_name, business_id, remark1, create_datetime from eps_node_bandwidth
|
select id, node_name, hardware_sn, calculation_mode, bandwidth_type, bandwidth_result, bandwidth_95_daily,
|
||||||
|
bandwidth_95_monthly, avg_monthly_bandwidth_95, package_bandwidth_daily, machine_flow, customer_id,
|
||||||
|
customer_name, service_number, uplink_switch, create_time, update_time, creator_id, creator_name,
|
||||||
|
switch_sn, interface_name, resource_type, interface_link_device_type, effective_bandwidth_95_daily,
|
||||||
|
effective_bandwidth_95_monthly, effective_avg_monthly_bandwidth_95, business_name, business_id,
|
||||||
|
remark1, create_datetime, client_id from eps_node_bandwidth
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectEpsNodeBandwidthList" parameterType="EpsNodeBandwidth" resultMap="EpsNodeBandwidthResult">
|
<select id="selectEpsNodeBandwidthList" parameterType="EpsNodeBandwidth" resultMap="EpsNodeBandwidthResult">
|
||||||
<include refid="selectEpsNodeBandwidthVo"/>
|
<include refid="selectEpsNodeBandwidthVo"/>
|
||||||
<where>
|
<where>
|
||||||
<if test="nodeName != null and nodeName != ''"> and node_name like concat('%', #{nodeName}, '%')</if>
|
<if test="nodeName != null and nodeName != ''"> and node_name like concat('%', #{nodeName}, '%')</if>
|
||||||
|
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
|
||||||
<if test="hardwareSn != null and hardwareSn != ''"> and hardware_sn = #{hardwareSn}</if>
|
<if test="hardwareSn != null and hardwareSn != ''"> and hardware_sn = #{hardwareSn}</if>
|
||||||
<if test="calculationMode != null and calculationMode != ''"> and calculation_mode = #{calculationMode}</if>
|
<if test="calculationMode != null and calculationMode != ''"> and calculation_mode = #{calculationMode}</if>
|
||||||
<if test="bandwidthType != null and bandwidthType != ''"> and bandwidth_type = #{bandwidthType}</if>
|
<if test="bandwidthType != null and bandwidthType != ''"> and bandwidth_type = #{bandwidthType}</if>
|
||||||
@@ -123,6 +130,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="businessName != null">business_name,</if>
|
<if test="businessName != null">business_name,</if>
|
||||||
<if test="businessId != null">business_id,</if>
|
<if test="businessId != null">business_id,</if>
|
||||||
<if test="remark1 != null">remark1,</if>
|
<if test="remark1 != null">remark1,</if>
|
||||||
|
<if test="clientId != null">client_id,</if>
|
||||||
create_datetime,
|
create_datetime,
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
@@ -153,6 +161,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="businessName != null">#{businessName},</if>
|
<if test="businessName != null">#{businessName},</if>
|
||||||
<if test="businessId != null">#{businessId},</if>
|
<if test="businessId != null">#{businessId},</if>
|
||||||
<if test="remark1 != null">#{remark1},</if>
|
<if test="remark1 != null">#{remark1},</if>
|
||||||
|
<if test="clientId != null">#{clientId},</if>
|
||||||
NOW(),
|
NOW(),
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
@@ -188,6 +197,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="businessId != null">business_id = #{businessId},</if>
|
<if test="businessId != null">business_id = #{businessId},</if>
|
||||||
<if test="remark1 != null">remark1 = #{remark1},</if>
|
<if test="remark1 != null">remark1 = #{remark1},</if>
|
||||||
<if test="createDatetime != null">create_datetime = #{createDatetime},</if>
|
<if test="createDatetime != null">create_datetime = #{createDatetime},</if>
|
||||||
|
<if test="clientId != null">client_id = #{clientId},</if>
|
||||||
</trim>
|
</trim>
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
</update>
|
</update>
|
||||||
@@ -252,6 +262,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="calculationMode != '' and calculationMode != null">
|
<if test="calculationMode != '' and calculationMode != null">
|
||||||
and calculation_mode = #{calculationMode}
|
and calculation_mode = #{calculationMode}
|
||||||
</if>
|
</if>
|
||||||
|
<if test="clientId != '' and clientId != null">
|
||||||
|
and client_id = #{clientId}
|
||||||
|
</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@@ -273,6 +286,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="businessId != '' and businessId != null">
|
<if test="businessId != '' and businessId != null">
|
||||||
and business_id = #{businessId}
|
and business_id = #{businessId}
|
||||||
</if>
|
</if>
|
||||||
|
<if test="clientId != '' and clientId != null">
|
||||||
|
and client_id = #{clientId}
|
||||||
|
</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@@ -291,6 +307,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="businessId != '' and businessId != null">
|
<if test="businessId != '' and businessId != null">
|
||||||
and business_id = #{businessId}
|
and business_id = #{businessId}
|
||||||
</if>
|
</if>
|
||||||
|
<if test="clientId != '' and clientId != null">
|
||||||
|
and client_id = #{clientId}
|
||||||
|
</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -14,6 +14,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<result property="type" column="type" />
|
<result property="type" column="type" />
|
||||||
<result property="inSpeed" column="in_speed" />
|
<result property="inSpeed" column="in_speed" />
|
||||||
<result property="outSpeed" column="out_speed" />
|
<result property="outSpeed" column="out_speed" />
|
||||||
|
<result property="maxSpeed" column="max_speed" />
|
||||||
<result property="switchIp" column="switch_ip" />
|
<result property="switchIp" column="switch_ip" />
|
||||||
<result property="createBy" column="create_by" />
|
<result property="createBy" column="create_by" />
|
||||||
<result property="updateBy" column="update_by" />
|
<result property="updateBy" column="update_by" />
|
||||||
@@ -36,7 +37,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectInitialSwitchInfoDetailsVo">
|
<sql id="selectInitialSwitchInfoDetailsVo">
|
||||||
select id, client_id, name, in_bytes, out_bytes, status, type, in_speed, out_speed, switch_ip, create_by, update_by, create_time, update_time, switch_name, interface_device_type, server_name, server_port, server_sn, switch_sn, business_code, business_name, if_speed, if_in_discards, if_out_discards, if_in_errors, if_out_errors, if_index from initial_switch_info_details
|
select id, client_id, name, in_bytes, out_bytes, status, type, in_speed, out_speed, max_speed, switch_ip, create_by, update_by, create_time, update_time, switch_name, interface_device_type, server_name, server_port, server_sn, switch_sn, business_code, business_name, if_speed, if_in_discards, if_out_discards, if_in_errors, if_out_errors, if_index from initial_switch_info_details
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectInitialSwitchInfoDetailsList" parameterType="InitialSwitchInfoDetails" resultMap="InitialSwitchInfoDetailsResult">
|
<select id="selectInitialSwitchInfoDetailsList" parameterType="InitialSwitchInfoDetails" resultMap="InitialSwitchInfoDetailsResult">
|
||||||
@@ -85,6 +86,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="type != null">type,</if>
|
<if test="type != null">type,</if>
|
||||||
<if test="inSpeed != null">in_speed,</if>
|
<if test="inSpeed != null">in_speed,</if>
|
||||||
<if test="outSpeed != null">out_speed,</if>
|
<if test="outSpeed != null">out_speed,</if>
|
||||||
|
<if test="maxSpeed != null">max_speed,</if>
|
||||||
<if test="switchIp != null">switch_ip,</if>
|
<if test="switchIp != null">switch_ip,</if>
|
||||||
<if test="createBy != null">create_by,</if>
|
<if test="createBy != null">create_by,</if>
|
||||||
<if test="updateBy != null">update_by,</if>
|
<if test="updateBy != null">update_by,</if>
|
||||||
@@ -114,6 +116,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="type != null">#{type},</if>
|
<if test="type != null">#{type},</if>
|
||||||
<if test="inSpeed != null">#{inSpeed},</if>
|
<if test="inSpeed != null">#{inSpeed},</if>
|
||||||
<if test="outSpeed != null">#{outSpeed},</if>
|
<if test="outSpeed != null">#{outSpeed},</if>
|
||||||
|
<if test="maxSpeed != null">#{maxSpeed},</if>
|
||||||
<if test="switchIp != null">#{switchIp},</if>
|
<if test="switchIp != null">#{switchIp},</if>
|
||||||
<if test="createBy != null">#{createBy},</if>
|
<if test="createBy != null">#{createBy},</if>
|
||||||
<if test="updateBy != null">#{updateBy},</if>
|
<if test="updateBy != null">#{updateBy},</if>
|
||||||
@@ -147,6 +150,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="type != null">type = #{type},</if>
|
<if test="type != null">type = #{type},</if>
|
||||||
<if test="inSpeed != null">in_speed = #{inSpeed},</if>
|
<if test="inSpeed != null">in_speed = #{inSpeed},</if>
|
||||||
<if test="outSpeed != null">out_speed = #{outSpeed},</if>
|
<if test="outSpeed != null">out_speed = #{outSpeed},</if>
|
||||||
|
<if test="maxSpeed != null">max_speed = #{maxSpeed},</if>
|
||||||
<if test="switchIp != null">switch_ip = #{switchIp},</if>
|
<if test="switchIp != null">switch_ip = #{switchIp},</if>
|
||||||
<if test="createBy != null">create_by = #{createBy},</if>
|
<if test="createBy != null">create_by = #{createBy},</if>
|
||||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||||
@@ -192,6 +196,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
`type`,
|
`type`,
|
||||||
in_speed AS inSpeed,
|
in_speed AS inSpeed,
|
||||||
out_speed AS outSpeed,
|
out_speed AS outSpeed,
|
||||||
|
max_speed AS maxSpeed,
|
||||||
switch_ip AS switchIp,
|
switch_ip AS switchIp,
|
||||||
if_index AS ifIndex,
|
if_index AS ifIndex,
|
||||||
if_speed AS ifSpeed,
|
if_speed AS ifSpeed,
|
||||||
@@ -224,6 +229,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
`type`,
|
`type`,
|
||||||
in_speed,
|
in_speed,
|
||||||
out_speed,
|
out_speed,
|
||||||
|
max_speed,
|
||||||
switch_ip,
|
switch_ip,
|
||||||
if_index,
|
if_index,
|
||||||
if_speed,
|
if_speed,
|
||||||
@@ -255,6 +261,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
#{item.type},
|
#{item.type},
|
||||||
#{item.inSpeed},
|
#{item.inSpeed},
|
||||||
#{item.outSpeed},
|
#{item.outSpeed},
|
||||||
|
#{item.maxSpeed},
|
||||||
#{item.switchIp},
|
#{item.switchIp},
|
||||||
#{item.ifIndex},
|
#{item.ifIndex},
|
||||||
#{item.ifSpeed},
|
#{item.ifSpeed},
|
||||||
|
|||||||
@@ -60,6 +60,6 @@ public class RmNetworkInterface extends BaseEntity
|
|||||||
/** 绑定ip 1业务IP,2管理ip */
|
/** 绑定ip 1业务IP,2管理ip */
|
||||||
private String bindIp;
|
private String bindIp;
|
||||||
/** 是否为新信息 */
|
/** 是否为新信息 */
|
||||||
private String newFlag;
|
private Integer newFlag;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ public class PolicyTypeVo {
|
|||||||
private String scripts;
|
private String scripts;
|
||||||
/** agent更新信息 */
|
/** agent更新信息 */
|
||||||
private String versions;
|
private String versions;
|
||||||
|
/** 路由信息 */
|
||||||
|
private String routes;
|
||||||
/** 时间戳 */
|
/** 时间戳 */
|
||||||
private Long timestamp = Instant.now().getEpochSecond();
|
private Long timestamp = Instant.now().getEpochSecond();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.ruoyi.rocketmq.domain.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class RspResultVo {
|
||||||
|
/** 脚本策略id */
|
||||||
|
private String scriptId;
|
||||||
|
/** 命令 */
|
||||||
|
private String command;
|
||||||
|
/** 命令执行结果 */
|
||||||
|
private String resOut;
|
||||||
|
}
|
||||||
@@ -8,6 +8,7 @@ import com.ruoyi.common.core.utils.StringUtils;
|
|||||||
import com.ruoyi.rocketmq.domain.*;
|
import com.ruoyi.rocketmq.domain.*;
|
||||||
import com.ruoyi.rocketmq.domain.vo.CollectDataVo;
|
import com.ruoyi.rocketmq.domain.vo.CollectDataVo;
|
||||||
import com.ruoyi.rocketmq.domain.vo.RegisterMsgVo;
|
import com.ruoyi.rocketmq.domain.vo.RegisterMsgVo;
|
||||||
|
import com.ruoyi.rocketmq.domain.vo.RspResultVo;
|
||||||
import com.ruoyi.rocketmq.domain.vo.RspVo;
|
import com.ruoyi.rocketmq.domain.vo.RspVo;
|
||||||
import com.ruoyi.rocketmq.service.*;
|
import com.ruoyi.rocketmq.service.*;
|
||||||
import com.ruoyi.rocketmq.utils.DataProcessUtil;
|
import com.ruoyi.rocketmq.utils.DataProcessUtil;
|
||||||
@@ -91,18 +92,18 @@ public class MessageHandler {
|
|||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void init() {
|
public void init() {
|
||||||
registerHandler(MsgEnum.执行脚本策略应答.getValue(), this::handleScriptRspMessage);
|
registerHandler(MsgEnum.执行脚本策略应答.getValue(), this::handleScriptRspMessage);
|
||||||
// registerHandler(MsgEnum.Agent版本更新应答.getValue(), this::handleAgentUpdateRspMessage);
|
registerHandler(MsgEnum.Agent版本更新应答.getValue(), this::handleAgentUpdateRspMessage);
|
||||||
|
|
||||||
// 其他类型消息可以单独注册处理器
|
// 其他类型消息可以单独注册处理器
|
||||||
registerHandler(MsgEnum.注册.getValue(), this::handleRegisterMessage);
|
registerHandler(MsgEnum.注册.getValue(), this::handleRegisterMessage);
|
||||||
registerHandler(MsgEnum.获取最新策略.getValue(), this::handleNewPolicyMessage);
|
registerHandler(MsgEnum.获取最新策略.getValue(), this::handleNewPolicyMessage);
|
||||||
// registerHandler(MsgEnum.CPU上报.getValue(), this::handleCpuMessage);
|
registerHandler(MsgEnum.CPU上报.getValue(), this::handleCpuMessage);
|
||||||
// registerHandler(MsgEnum.磁盘上报.getValue(), this::handleDiskMessage);
|
registerHandler(MsgEnum.磁盘上报.getValue(), this::handleDiskMessage);
|
||||||
// registerHandler(MsgEnum.容器上报.getValue(), this::handleDockerMessage);
|
registerHandler(MsgEnum.容器上报.getValue(), this::handleDockerMessage);
|
||||||
// registerHandler(MsgEnum.内存上报.getValue(), this::handleMemoryMessage);
|
registerHandler(MsgEnum.内存上报.getValue(), this::handleMemoryMessage);
|
||||||
// registerHandler(MsgEnum.网络上报.getValue(), this::handleNetMessage);
|
registerHandler(MsgEnum.网络上报.getValue(), this::handleNetMessage);
|
||||||
// registerHandler(MsgEnum.挂载上报.getValue(), this::handleMountPointMessage);
|
registerHandler(MsgEnum.挂载上报.getValue(), this::handleMountPointMessage);
|
||||||
// registerHandler(MsgEnum.系统其他上报.getValue(), this::handleOtherSystemMessage);
|
registerHandler(MsgEnum.系统其他上报.getValue(), this::handleOtherSystemMessage);
|
||||||
registerHandler(MsgEnum.心跳上报.getValue(), this::handleHeartbeatMessage);
|
registerHandler(MsgEnum.心跳上报.getValue(), this::handleHeartbeatMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,9 +117,11 @@ public class MessageHandler {
|
|||||||
RegisterMsgVo registerMsgVo = interfaces.get(0);
|
RegisterMsgVo registerMsgVo = interfaces.get(0);
|
||||||
String clientId = registerMsgVo.getClientId();
|
String clientId = registerMsgVo.getClientId();
|
||||||
// 如果未下发监控策略,下发
|
// 如果未下发监控策略,下发
|
||||||
// rmMonitorPolicyService.issuePolicyMsgByClientId(clientId);
|
rmMonitorPolicyService.issuePolicyMsgByClientId(clientId);
|
||||||
// 如果未下发服务器脚本策略,下发
|
// 如果未下发服务器脚本策略,下发
|
||||||
rmDeploymentPolicyService.issueDeployPolicyMsgByClientId(clientId);
|
rmDeploymentPolicyService.issueDeployPolicyMsgByClientId(clientId);
|
||||||
|
// 如果路由有变化,更新路由信息
|
||||||
|
rmNetworkInterfaceService.updateRouteMsg(clientId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,6 +153,7 @@ public class MessageHandler {
|
|||||||
// 查询该网卡信息是否存在
|
// 查询该网卡信息是否存在
|
||||||
RmNetworkInterface queryParam = new RmNetworkInterface();
|
RmNetworkInterface queryParam = new RmNetworkInterface();
|
||||||
queryParam.setMacAddress(networkInfo.getMac());
|
queryParam.setMacAddress(networkInfo.getMac());
|
||||||
|
queryParam.setNewFlag(1);
|
||||||
List<RmNetworkInterface> exits = rmNetworkInterfaceService.selectRmNetworkInterfaceList(queryParam);
|
List<RmNetworkInterface> exits = rmNetworkInterfaceService.selectRmNetworkInterfaceList(queryParam);
|
||||||
if(exits.isEmpty()){
|
if(exits.isEmpty()){
|
||||||
// 保存网卡信息
|
// 保存网卡信息
|
||||||
@@ -169,18 +173,64 @@ public class MessageHandler {
|
|||||||
rmNetworkInterfaceService.insertRmNetworkInterface(insertData);
|
rmNetworkInterfaceService.insertRmNetworkInterface(insertData);
|
||||||
}else{
|
}else{
|
||||||
RmNetworkInterface oldInterfaceMsg = exits.get(0);
|
RmNetworkInterface oldInterfaceMsg = exits.get(0);
|
||||||
if(!StringUtils.equals(networkInfo.getPublicIp(),oldInterfaceMsg.getPublicIp())){
|
if(!StringUtils.equals(networkInfo.getName(),oldInterfaceMsg.getInterfaceName())
|
||||||
|
|| !StringUtils.equals(networkInfo.getGateway(),oldInterfaceMsg.getGateway())){
|
||||||
|
// 查询该网卡信息是否旧数据
|
||||||
|
RmNetworkInterface query = new RmNetworkInterface();
|
||||||
|
query.setMacAddress(networkInfo.getMac());
|
||||||
|
query.setNewFlag(999);
|
||||||
|
List<RmNetworkInterface> oldExits = rmNetworkInterfaceService.selectRmNetworkInterfaceList(queryParam);
|
||||||
|
if(!oldExits.isEmpty()){
|
||||||
|
// 先删除旧数据
|
||||||
|
oldExits.forEach(oldMsg ->{
|
||||||
|
rmNetworkInterfaceService.deleteRmNetworkInterfaceById(oldMsg.getId());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// 先将已存在的改为旧数据
|
||||||
|
RmNetworkInterface oldData = new RmNetworkInterface();
|
||||||
|
oldData.setNewFlag(0);
|
||||||
|
oldData.setMacAddress(networkInfo.getMac());
|
||||||
|
rmNetworkInterfaceService.updateRmNetworkInterfaceByMac(oldData);
|
||||||
|
RmNetworkInterface insertData = new RmNetworkInterface();
|
||||||
|
insertData.setMacAddress(networkInfo.getMac());
|
||||||
|
insertData.setIsp(networkInfo.getCarrier());
|
||||||
|
insertData.setCity(networkInfo.getCity());
|
||||||
|
insertData.setGateway(networkInfo.getGateway());
|
||||||
|
insertData.setInterfaceName(networkInfo.getName());
|
||||||
|
insertData.setIpv4Address(networkInfo.getIpv4());
|
||||||
|
insertData.setMacAddress(networkInfo.getMac());
|
||||||
|
insertData.setProvince(networkInfo.getProvince());
|
||||||
|
insertData.setPublicIp(networkInfo.getPublicIp());
|
||||||
|
rmNetworkInterfaceService.insertRmNetworkInterface(insertData);
|
||||||
|
}else {
|
||||||
RmNetworkInterface updateData = new RmNetworkInterface();
|
RmNetworkInterface updateData = new RmNetworkInterface();
|
||||||
updateData.setMacAddress(networkInfo.getMac());
|
// 检查其他字段是否需要更新
|
||||||
updateData.setIsp(networkInfo.getCarrier());
|
boolean needUpdate = false;
|
||||||
updateData.setCity(networkInfo.getCity());
|
// 逐个字段比较是否需要更新
|
||||||
updateData.setGateway(networkInfo.getGateway());
|
if (!StringUtils.equals(networkInfo.getCity(), oldInterfaceMsg.getCity())) {
|
||||||
updateData.setInterfaceName(networkInfo.getName());
|
updateData.setCity(networkInfo.getCity());
|
||||||
updateData.setIpv4Address(networkInfo.getIpv4());
|
needUpdate = true;
|
||||||
updateData.setMacAddress(networkInfo.getMac());
|
}
|
||||||
updateData.setProvince(networkInfo.getProvince());
|
if (!StringUtils.equals(networkInfo.getIpv4(), oldInterfaceMsg.getIpv4Address())) {
|
||||||
updateData.setPublicIp(networkInfo.getPublicIp());
|
updateData.setIpv4Address(networkInfo.getIpv4());
|
||||||
rmNetworkInterfaceService.updateRmNetworkInterfaceByMac(updateData);
|
needUpdate = true;
|
||||||
|
}
|
||||||
|
if (!StringUtils.equals(networkInfo.getProvince(), oldInterfaceMsg.getProvince())) {
|
||||||
|
updateData.setProvince(networkInfo.getProvince());
|
||||||
|
needUpdate = true;
|
||||||
|
}
|
||||||
|
if (!StringUtils.equals(networkInfo.getPublicIp(), oldInterfaceMsg.getPublicIp())) {
|
||||||
|
updateData.setPublicIp(networkInfo.getPublicIp());
|
||||||
|
needUpdate = true;
|
||||||
|
}
|
||||||
|
if (!StringUtils.equals(networkInfo.getCarrier(), oldInterfaceMsg.getIsp())) {
|
||||||
|
updateData.setIsp(networkInfo.getCarrier());
|
||||||
|
needUpdate = true;
|
||||||
|
}
|
||||||
|
// 只有有字段变化时才执行更新
|
||||||
|
if (needUpdate) {
|
||||||
|
rmNetworkInterfaceService.updateRmNetworkInterfaceByMac(updateData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
@@ -206,25 +256,71 @@ public class MessageHandler {
|
|||||||
rmNetworkInterfaceService.insertRmNetworkInterface(insertData);
|
rmNetworkInterfaceService.insertRmNetworkInterface(insertData);
|
||||||
}else{
|
}else{
|
||||||
RmNetworkInterface oldInterfaceMsg = exits.get(0);
|
RmNetworkInterface oldInterfaceMsg = exits.get(0);
|
||||||
RmNetworkInterface updateData = new RmNetworkInterface();
|
if(!StringUtils.equals(networkInfo.getName(),oldInterfaceMsg.getInterfaceName())
|
||||||
updateData.setMacAddress(networkInfo.getMac());
|
|| !StringUtils.equals(networkInfo.getGateway(),oldInterfaceMsg.getGateway())){
|
||||||
updateData.setIsp(networkInfo.getCarrier());
|
// 查询该网卡信息是否旧数据
|
||||||
updateData.setCity(networkInfo.getCity());
|
RmNetworkInterface query = new RmNetworkInterface();
|
||||||
updateData.setGateway(networkInfo.getGateway());
|
query.setMacAddress(networkInfo.getMac());
|
||||||
updateData.setInterfaceName(networkInfo.getName());
|
query.setNewFlag(999);
|
||||||
updateData.setIpv4Address(networkInfo.getIpv4());
|
List<RmNetworkInterface> oldExits = rmNetworkInterfaceService.selectRmNetworkInterfaceList(queryParam);
|
||||||
updateData.setMacAddress(networkInfo.getMac());
|
if(!oldExits.isEmpty()){
|
||||||
updateData.setProvince(networkInfo.getProvince());
|
// 先删除旧数据
|
||||||
updateData.setPublicIp(networkInfo.getPublicIp());
|
oldExits.forEach(oldMsg ->{
|
||||||
if(!StringUtils.equals(networkInfo.getPublicIp(),oldInterfaceMsg.getPublicIp())){
|
rmNetworkInterfaceService.deleteRmNetworkInterfaceById(oldMsg.getId());
|
||||||
updateData.setBindIp("0");
|
});
|
||||||
// 修改绑定公网ip状态
|
}
|
||||||
RmResourceRegistrationRemote updateParam = new RmResourceRegistrationRemote();
|
// 先将已存在的改为旧数据
|
||||||
updateParam.setClientId(registerMsg.getClientId());
|
RmNetworkInterface oldData = new RmNetworkInterface();
|
||||||
updateParam.setMultiPublicIpStatus("0");
|
oldData.setNewFlag(0);
|
||||||
remoteRevenueConfigService.updateStatusByResource(updateParam, SecurityConstants.INNER);
|
oldData.setMacAddress(networkInfo.getMac());
|
||||||
|
rmNetworkInterfaceService.updateRmNetworkInterfaceByMac(oldData);
|
||||||
|
RmNetworkInterface insertData = new RmNetworkInterface();
|
||||||
|
insertData.setMacAddress(networkInfo.getMac());
|
||||||
|
insertData.setIsp(networkInfo.getCarrier());
|
||||||
|
insertData.setCity(networkInfo.getCity());
|
||||||
|
insertData.setGateway(networkInfo.getGateway());
|
||||||
|
insertData.setInterfaceName(networkInfo.getName());
|
||||||
|
insertData.setIpv4Address(networkInfo.getIpv4());
|
||||||
|
insertData.setMacAddress(networkInfo.getMac());
|
||||||
|
insertData.setProvince(networkInfo.getProvince());
|
||||||
|
insertData.setPublicIp(networkInfo.getPublicIp());
|
||||||
|
rmNetworkInterfaceService.insertRmNetworkInterface(insertData);
|
||||||
|
}else {
|
||||||
|
RmNetworkInterface updateData = new RmNetworkInterface();
|
||||||
|
// 检查其他字段是否需要更新
|
||||||
|
boolean needUpdate = false;
|
||||||
|
// 逐个字段比较是否需要更新
|
||||||
|
if (!StringUtils.equals(networkInfo.getCity(), oldInterfaceMsg.getCity())) {
|
||||||
|
updateData.setCity(networkInfo.getCity());
|
||||||
|
needUpdate = true;
|
||||||
|
}
|
||||||
|
if (!StringUtils.equals(networkInfo.getIpv4(), oldInterfaceMsg.getIpv4Address())) {
|
||||||
|
updateData.setIpv4Address(networkInfo.getIpv4());
|
||||||
|
needUpdate = true;
|
||||||
|
}
|
||||||
|
if (!StringUtils.equals(networkInfo.getProvince(), oldInterfaceMsg.getProvince())) {
|
||||||
|
updateData.setProvince(networkInfo.getProvince());
|
||||||
|
needUpdate = true;
|
||||||
|
}
|
||||||
|
if (!StringUtils.equals(networkInfo.getPublicIp(), oldInterfaceMsg.getPublicIp())) {
|
||||||
|
updateData.setPublicIp(networkInfo.getPublicIp());
|
||||||
|
needUpdate = true;
|
||||||
|
updateData.setBindIp("0");
|
||||||
|
// 修改绑定公网ip状态
|
||||||
|
RmResourceRegistrationRemote updateParam = new RmResourceRegistrationRemote();
|
||||||
|
updateParam.setClientId(registerMsg.getClientId());
|
||||||
|
updateParam.setMultiPublicIpStatus("0");
|
||||||
|
remoteRevenueConfigService.updateStatusByResource(updateParam, SecurityConstants.INNER);
|
||||||
|
}
|
||||||
|
if (!StringUtils.equals(networkInfo.getCarrier(), oldInterfaceMsg.getIsp())) {
|
||||||
|
updateData.setIsp(networkInfo.getCarrier());
|
||||||
|
needUpdate = true;
|
||||||
|
}
|
||||||
|
// 只有有字段变化时才执行更新
|
||||||
|
if (needUpdate) {
|
||||||
|
rmNetworkInterfaceService.updateRmNetworkInterfaceByMac(updateData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
rmNetworkInterfaceService.updateRmNetworkInterfaceByMac(updateData);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -243,13 +339,15 @@ public class MessageHandler {
|
|||||||
RspVo rsp = rspVoList.get(0);
|
RspVo rsp = rspVoList.get(0);
|
||||||
if(rsp.getResCode() == 1){
|
if(rsp.getResCode() == 1){
|
||||||
RmAgentManagement rmAgentManagement = new RmAgentManagement();
|
RmAgentManagement rmAgentManagement = new RmAgentManagement();
|
||||||
rmAgentManagement.setHardwareSn(message.getClientId());
|
rmAgentManagement.setClientId(message.getClientId());
|
||||||
rmAgentManagement.setLastUpdateResult("1");
|
rmAgentManagement.setLastUpdateResult("1");
|
||||||
|
rmAgentManagement.setLastUpdateTime(DateUtils.getNowDate());
|
||||||
rmAgentManagementService.updateRmAgentManagementByHardwareSn(rmAgentManagement);
|
rmAgentManagementService.updateRmAgentManagementByHardwareSn(rmAgentManagement);
|
||||||
}else{
|
}else{
|
||||||
RmAgentManagement rmAgentManagement = new RmAgentManagement();
|
RmAgentManagement rmAgentManagement = new RmAgentManagement();
|
||||||
rmAgentManagement.setHardwareSn(message.getClientId());
|
rmAgentManagement.setClientId(message.getClientId());
|
||||||
rmAgentManagement.setLastUpdateResult("0");
|
rmAgentManagement.setLastUpdateResult("0");
|
||||||
|
rmAgentManagement.setLastUpdateTime(DateUtils.getNowDate());
|
||||||
rmAgentManagementService.updateRmAgentManagementByHardwareSn(rmAgentManagement);
|
rmAgentManagementService.updateRmAgentManagementByHardwareSn(rmAgentManagement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -462,12 +560,29 @@ public class MessageHandler {
|
|||||||
if(!heartbeats.isEmpty()){
|
if(!heartbeats.isEmpty()){
|
||||||
InitialHeartbeatListen heartbeat = heartbeats.get(0);
|
InitialHeartbeatListen heartbeat = heartbeats.get(0);
|
||||||
String clientId = message.getClientId();
|
String clientId = message.getClientId();
|
||||||
|
String version = heartbeat.getVersion();
|
||||||
log.debug("处理心跳消息,客户端ID: {}, 时间: {}", clientId, heartbeat.getTimestamp());
|
log.debug("处理心跳消息,客户端ID: {}, 时间: {}", clientId, heartbeat.getTimestamp());
|
||||||
// 添加逻辑节点标识
|
// 添加逻辑节点标识
|
||||||
RmResourceRegistrationRemote updateData = new RmResourceRegistrationRemote();
|
RmResourceRegistrationRemote updateData = new RmResourceRegistrationRemote();
|
||||||
updateData.setClientId(message.getClientId());
|
updateData.setClientId(message.getClientId());
|
||||||
updateData.setLogicalNodeId(heartbeat.getLogicalNode());
|
updateData.setLogicalNodeId(heartbeat.getLogicalNode());
|
||||||
remoteRevenueConfigService.innerUpdateRegist(updateData, SecurityConstants.INNER);
|
remoteRevenueConfigService.innerUpdateRegist(updateData, SecurityConstants.INNER);
|
||||||
|
// agent更新结果存储
|
||||||
|
RmAgentManagement query = new RmAgentManagement();
|
||||||
|
query.setClientId(clientId);
|
||||||
|
List<RmAgentManagement> agentManagements = rmAgentManagementService.selectRmAgentManagementList(query);
|
||||||
|
if(!agentManagements.isEmpty()){
|
||||||
|
RmAgentManagement rmAgentManagement = agentManagements.get(0);
|
||||||
|
if(!StringUtils.equals(rmAgentManagement.getAgentVersion(), version)){
|
||||||
|
// 存储更新结果
|
||||||
|
RmAgentManagement updateResultData = new RmAgentManagement();
|
||||||
|
updateResultData.setId(rmAgentManagement.getId());
|
||||||
|
updateResultData.setAgentVersion(version);
|
||||||
|
updateResultData.setLastUpdateTime(DateUtils.getNowDate());
|
||||||
|
updateResultData.setLastUpdateResult("1");
|
||||||
|
rmAgentManagementService.updateRmAgentManagementByHardwareSn(updateResultData);
|
||||||
|
}
|
||||||
|
}
|
||||||
// 使用Redis存储状态
|
// 使用Redis存储状态
|
||||||
String statusKey = HEARTBEAT_STATUS_PREFIX + clientId;
|
String statusKey = HEARTBEAT_STATUS_PREFIX + clientId;
|
||||||
String timeKey = HEARTBEAT_TIME_PREFIX + clientId;
|
String timeKey = HEARTBEAT_TIME_PREFIX + clientId;
|
||||||
@@ -659,9 +774,12 @@ public class MessageHandler {
|
|||||||
RmResourceRegistrationRemote resourceMsgData = resourceMsg.getData();
|
RmResourceRegistrationRemote resourceMsgData = resourceMsg.getData();
|
||||||
if(rsp.getResCode() == 1){
|
if(rsp.getResCode() == 1){
|
||||||
if(rsp.getResult() != null){
|
if(rsp.getResult() != null){
|
||||||
|
List<RspResultVo> resultVos = JsonDataParser.parseJsonData(rsp.getResult(), RspResultVo.class);
|
||||||
|
RspResultVo rspResultVo = resultVos.get(0);
|
||||||
// 构建脚本执行结果实体类
|
// 构建脚本执行结果实体类
|
||||||
RmResourceRemote insertData = new RmResourceRemote();
|
RmResourceRemote insertData = new RmResourceRemote();
|
||||||
insertData.setClientId(message.getClientId());
|
insertData.setClientId(message.getClientId());
|
||||||
|
insertData.setScriptId(Long.valueOf(rspResultVo.getScriptId()));
|
||||||
insertData.setResultFlag(1);
|
insertData.setResultFlag(1);
|
||||||
insertData.setDescription(rsp.getResult());
|
insertData.setDescription(rsp.getResult());
|
||||||
insertData.setCreateTime(createTime);
|
insertData.setCreateTime(createTime);
|
||||||
@@ -675,7 +793,10 @@ public class MessageHandler {
|
|||||||
insertData.setClientId(message.getClientId());
|
insertData.setClientId(message.getClientId());
|
||||||
insertData.setResultFlag(0);
|
insertData.setResultFlag(0);
|
||||||
if(rsp.getResult() != null){
|
if(rsp.getResult() != null){
|
||||||
|
List<RspResultVo> resultVos = JsonDataParser.parseJsonData(rsp.getResult(), RspResultVo.class);
|
||||||
|
RspResultVo rspResultVo = resultVos.get(0);
|
||||||
insertData.setDescription(rsp.getResult());
|
insertData.setDescription(rsp.getResult());
|
||||||
|
insertData.setScriptId(Long.valueOf(rspResultVo.getScriptId()));
|
||||||
}
|
}
|
||||||
insertData.setCreateTime(createTime);
|
insertData.setCreateTime(createTime);
|
||||||
// 执行插入sql
|
// 执行插入sql
|
||||||
|
|||||||
@@ -73,4 +73,10 @@ public interface IRmNetworkInterfaceService
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int bindPublicIp(RmNetworkInterface rmNetworkInterface);
|
int bindPublicIp(RmNetworkInterface rmNetworkInterface);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新路由信息
|
||||||
|
* @param clientId
|
||||||
|
*/
|
||||||
|
void updateRouteMsg(String clientId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,6 +125,9 @@ public class InitialDiskInfoServiceImpl implements IInitialDiskInfoService
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public InitialDiskInfo getDistDetailsMsg(InitialDiskInfo initialDiskInfo) {
|
public InitialDiskInfo getDistDetailsMsg(InitialDiskInfo initialDiskInfo) {
|
||||||
|
InitialDiskInfo info = initialDiskInfoMapper.getDistDetailsMsgByClientId(initialDiskInfo);
|
||||||
|
long gbUnit = 1024L * 1024 * 1024;
|
||||||
|
info.setTotal(info.getTotal() / gbUnit);
|
||||||
return initialDiskInfoMapper.getDistDetailsMsgByClientId(initialDiskInfo);
|
return initialDiskInfoMapper.getDistDetailsMsgByClientId(initialDiskInfo);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -101,6 +101,12 @@ public class RmDeploymentPolicyServiceImpl implements IRmDeploymentPolicyService
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
policy.setSucessNum(successList.size());
|
||||||
|
policy.setSucessClientIds(successList);
|
||||||
|
policy.setFailNum(failList.size());
|
||||||
|
policy.setFailClientIds(failList);
|
||||||
|
policy.setOfflineNum(offOnlineList.size());
|
||||||
|
policy.setOfflineClientIds(offOnlineList);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -301,7 +307,7 @@ public class RmDeploymentPolicyServiceImpl implements IRmDeploymentPolicyService
|
|||||||
// 获取策略详情
|
// 获取策略详情
|
||||||
List<RmDeploymentPolicy> policyList = rmDeploymentPolicyMapper.selectRmDeploymentPolicyByClientId(queryParam);
|
List<RmDeploymentPolicy> policyList = rmDeploymentPolicyMapper.selectRmDeploymentPolicyByClientId(queryParam);
|
||||||
if (policyList.isEmpty()) {
|
if (policyList.isEmpty()) {
|
||||||
log.error("无待下发策略,clientId: {}", clientId);
|
log.warn("无待下发策略,clientId: {}", clientId);
|
||||||
return 0;
|
return 0;
|
||||||
}else{
|
}else{
|
||||||
for (RmDeploymentPolicy policy : policyList) {
|
for (RmDeploymentPolicy policy : policyList) {
|
||||||
|
|||||||
@@ -590,11 +590,11 @@ public class RmMonitorPolicyServiceImpl implements IRmMonitorPolicyService
|
|||||||
message.setData(configJson);
|
message.setData(configJson);
|
||||||
message.setDataType(MsgEnum.获取最新策略应答.getValue());
|
message.setDataType(MsgEnum.获取最新策略应答.getValue());
|
||||||
|
|
||||||
messageProducer.sendAsyncProducerMessage(
|
messageProducer.sendDelayMessage(
|
||||||
producerMode.getAgentTopic(),
|
producerMode.getAgentTopic(),
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
JSONObject.toJSONString(message)
|
JSONObject.toJSONString(message),1
|
||||||
);
|
);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("发送设备配置失败,clientId: {}", clientId, e);
|
log.error("发送设备配置失败,clientId: {}", clientId, e);
|
||||||
|
|||||||
@@ -1,13 +1,24 @@
|
|||||||
package com.ruoyi.rocketmq.service.impl;
|
package com.ruoyi.rocketmq.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.ruoyi.common.core.enums.MsgEnum;
|
||||||
import com.ruoyi.common.core.utils.DateUtils;
|
import com.ruoyi.common.core.utils.DateUtils;
|
||||||
|
import com.ruoyi.rocketmq.domain.DeviceMessage;
|
||||||
import com.ruoyi.rocketmq.domain.RmNetworkInterface;
|
import com.ruoyi.rocketmq.domain.RmNetworkInterface;
|
||||||
|
import com.ruoyi.rocketmq.domain.vo.PolicyTypeVo;
|
||||||
import com.ruoyi.rocketmq.mapper.RmNetworkInterfaceMapper;
|
import com.ruoyi.rocketmq.mapper.RmNetworkInterfaceMapper;
|
||||||
|
import com.ruoyi.rocketmq.model.ProducerMode;
|
||||||
|
import com.ruoyi.rocketmq.producer.MessageProducer;
|
||||||
import com.ruoyi.rocketmq.service.IRmNetworkInterfaceService;
|
import com.ruoyi.rocketmq.service.IRmNetworkInterfaceService;
|
||||||
|
import com.ruoyi.system.api.domain.RouteMsg;
|
||||||
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.time.Instant;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 客户端网络接口信息Service业务层处理
|
* 客户端网络接口信息Service业务层处理
|
||||||
@@ -20,6 +31,8 @@ public class RmNetworkInterfaceServiceImpl implements IRmNetworkInterfaceService
|
|||||||
{
|
{
|
||||||
@Autowired
|
@Autowired
|
||||||
private RmNetworkInterfaceMapper rmNetworkInterfaceMapper;
|
private RmNetworkInterfaceMapper rmNetworkInterfaceMapper;
|
||||||
|
@Autowired
|
||||||
|
private ProducerMode producerMode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询客户端网络接口信息
|
* 查询客户端网络接口信息
|
||||||
@@ -110,4 +123,60 @@ public class RmNetworkInterfaceServiceImpl implements IRmNetworkInterfaceService
|
|||||||
public int bindPublicIp(RmNetworkInterface rmNetworkInterface) {
|
public int bindPublicIp(RmNetworkInterface rmNetworkInterface) {
|
||||||
return rmNetworkInterfaceMapper.updateRmNetworkInterface(rmNetworkInterface);
|
return rmNetworkInterfaceMapper.updateRmNetworkInterface(rmNetworkInterface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新路由信息
|
||||||
|
* @param clientId
|
||||||
|
*/
|
||||||
|
public void updateRouteMsg(String clientId){
|
||||||
|
MessageProducer messageProducer = new MessageProducer();
|
||||||
|
// 查询路由是否有变化
|
||||||
|
RmNetworkInterface rmNetworkInterface = new RmNetworkInterface();
|
||||||
|
rmNetworkInterface.setClientId(clientId);
|
||||||
|
rmNetworkInterface.setBindIp("2");
|
||||||
|
List<RmNetworkInterface> networkInterfaces = rmNetworkInterfaceMapper.selectRmNetworkInterfaceList(rmNetworkInterface);
|
||||||
|
if(!networkInterfaces.isEmpty()){
|
||||||
|
List<RmNetworkInterface> oldList = networkInterfaces.stream()
|
||||||
|
.filter(networkInterface -> networkInterface.getNewFlag() == 0)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
if(!oldList.isEmpty()){
|
||||||
|
Map<String, Object> resultMap = new HashMap<>();
|
||||||
|
// 增加静态路由
|
||||||
|
RmNetworkInterface oldMsg = oldList.get(0);
|
||||||
|
RouteMsg oldRouteMsg = new RouteMsg();
|
||||||
|
oldRouteMsg.setGateway(oldMsg.getGateway());
|
||||||
|
oldRouteMsg.setName(oldMsg.getInterfaceName());
|
||||||
|
resultMap.put("delRoute", oldRouteMsg);
|
||||||
|
List<RmNetworkInterface> newList = networkInterfaces.stream()
|
||||||
|
.filter(networkInterface -> networkInterface.getNewFlag() == 1)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
RmNetworkInterface newMsg = newList.get(0);
|
||||||
|
RouteMsg newRouteMsg = new RouteMsg();
|
||||||
|
newRouteMsg.setGateway(newMsg.getGateway());
|
||||||
|
newRouteMsg.setName(newMsg.getInterfaceName());
|
||||||
|
resultMap.put("addRoute", newRouteMsg);
|
||||||
|
resultMap.put("upTime", Instant.now().getEpochSecond());
|
||||||
|
PolicyTypeVo policyTypeVo = new PolicyTypeVo();
|
||||||
|
policyTypeVo.setRoutes(JSONObject.toJSONString(resultMap));
|
||||||
|
String configJson = JSONObject.toJSONString(policyTypeVo);
|
||||||
|
// 构建发送消息
|
||||||
|
DeviceMessage message = new DeviceMessage();
|
||||||
|
message.setClientId(clientId);
|
||||||
|
message.setData(configJson);
|
||||||
|
message.setDataType(MsgEnum.获取最新策略应答.getValue());
|
||||||
|
|
||||||
|
messageProducer.sendAsyncProducerMessage(
|
||||||
|
producerMode.getAgentTopic(),
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
JSONObject.toJSONString(message)
|
||||||
|
);
|
||||||
|
// 更新网卡信息表
|
||||||
|
RmNetworkInterface updateQuery = new RmNetworkInterface();
|
||||||
|
updateQuery.setNewFlag(999);
|
||||||
|
updateQuery.setMacAddress(networkInterfaces.get(0).getMacAddress());
|
||||||
|
rmNetworkInterfaceMapper.updateRmNetworkInterfaceByMac(updateQuery);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -154,6 +154,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<select id="getDockerDetailsMsg" parameterType="InitialDockerInfo" resultMap="InitialDockerInfoResult">
|
<select id="getDockerDetailsMsg" parameterType="InitialDockerInfo" resultMap="InitialDockerInfoResult">
|
||||||
<include refid="selectInitialDockerInfoVo"/>
|
<include refid="selectInitialDockerInfoVo"/>
|
||||||
where client_id = #{clientId} and `id` = #{id}
|
where client_id = #{clientId} and `id` = #{id}
|
||||||
|
order by create_time desc
|
||||||
|
limit 1
|
||||||
</select>
|
</select>
|
||||||
<select id="getAllDockerId" parameterType="String" resultType="java.util.Map">
|
<select id="getAllDockerId" parameterType="String" resultType="java.util.Map">
|
||||||
select id from initial_docker_info
|
select id from initial_docker_info
|
||||||
|
|||||||
@@ -171,6 +171,21 @@
|
|||||||
<if test="createBy != null">create_by = #{createBy},</if>
|
<if test="createBy != null">create_by = #{createBy},</if>
|
||||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||||
</trim>
|
</trim>
|
||||||
where hardware_sn = #{hardwareSn}
|
<where>
|
||||||
|
<choose>
|
||||||
|
<when test="id != null">
|
||||||
|
and id = #{id}
|
||||||
|
</when>
|
||||||
|
<when test="clientId != null and clientId != ''">
|
||||||
|
and client_id = #{clientId}
|
||||||
|
</when>
|
||||||
|
<when test="hardwareSn != null and hardwareSn != ''">
|
||||||
|
and hardware_sn = #{hardwareSn}
|
||||||
|
</when>
|
||||||
|
<otherwise>
|
||||||
|
and 1=0 <!-- 如果没有提供任何条件,则不更新任何记录 -->
|
||||||
|
</otherwise>
|
||||||
|
</choose>
|
||||||
|
</where>
|
||||||
</update>
|
</update>
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -125,7 +125,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="priority != null "> and priority = #{priority}</if>
|
<if test="priority != null "> and priority = #{priority}</if>
|
||||||
<if test="status != null "> and status = #{status}</if>
|
<if test="status != null "> and status = #{status}</if>
|
||||||
<if test="deployDevice != null ">
|
<if test="deployDevice != null ">
|
||||||
FIND_IN_SET(#{deployDevice}, REPLACE(deploy_device, '\n', ',')) > 0
|
and FIND_IN_SET(#{deployDevice}, REPLACE(deploy_device, '\n', ',')) > 0
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
limit 1
|
limit 1
|
||||||
|
|||||||
Reference in New Issue
Block a user