diff --git a/tongran-auth/src/main/resources/bootstrap.yml b/tongran-auth/src/main/resources/bootstrap.yml
index 9cf0ca2..6236ee2 100644
--- a/tongran-auth/src/main/resources/bootstrap.yml
+++ b/tongran-auth/src/main/resources/bootstrap.yml
@@ -23,7 +23,7 @@ spring:
server-addr: 172.16.15.52:8848
# server-addr: 172.16.15.103:8848
# namespace: public
- namespace: saas-local
+ namespace: saas-prod
username: nacos
password: nacos
# 配置文件格式
diff --git a/tongran-gateway/src/main/resources/bootstrap.yml b/tongran-gateway/src/main/resources/bootstrap.yml
index 67041f1..cd517df 100644
--- a/tongran-gateway/src/main/resources/bootstrap.yml
+++ b/tongran-gateway/src/main/resources/bootstrap.yml
@@ -23,7 +23,7 @@ spring:
server-addr: 172.16.15.52:8848
# server-addr: 172.16.15.103:8848
# namespace: public
- namespace: saas-local
+ namespace: saas-prod
username: nacos
password: nacos
# 配置文件格式
diff --git a/tongran-modules/tongran-job/src/main/java/com/tongran/job/config/ScheduleConfig.java b/tongran-modules/tongran-job/src/main/java/com/tongran/job/config/ScheduleConfig.java
index a5d3451..e0c58b0 100644
--- a/tongran-modules/tongran-job/src/main/java/com/tongran/job/config/ScheduleConfig.java
+++ b/tongran-modules/tongran-job/src/main/java/com/tongran/job/config/ScheduleConfig.java
@@ -22,7 +22,7 @@
//
// // quartz参数
// Properties prop = new Properties();
-// prop.put("org.quartz.scheduler.instanceName", "RuoyiScheduler");
+// prop.put("org.quartz.scheduler.instanceName", "TongRanScheduler");
// prop.put("org.quartz.scheduler.instanceId", "AUTO");
// // 线程池配置
// prop.put("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool");
@@ -42,7 +42,7 @@
// prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_");
// factory.setQuartzProperties(prop);
//
-// factory.setSchedulerName("RuoyiScheduler");
+// factory.setSchedulerName("TongRanScheduler");
// // 延时启动
// factory.setStartupDelay(1);
// factory.setApplicationContextSchedulerContextKey("applicationContextKey");
diff --git a/tongran-modules/tongran-mtragent/pom.xml b/tongran-modules/tongran-mtragent/pom.xml
index 3e000f0..7b965c6 100644
--- a/tongran-modules/tongran-mtragent/pom.xml
+++ b/tongran-modules/tongran-mtragent/pom.xml
@@ -97,4 +97,20 @@
spring-boot-starter-web
+
+ ${project.artifactId}
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+ repackage
+
+
+
+
+
+
diff --git a/tongran-modules/tongran-mtragent/src/main/java/com/tongran/mtragent/domain/vo/RmMtrPolicyConfigVo.java b/tongran-modules/tongran-mtragent/src/main/java/com/tongran/mtragent/domain/vo/RmMtrPolicyConfigVo.java
new file mode 100644
index 0000000..95cf25f
--- /dev/null
+++ b/tongran-modules/tongran-mtragent/src/main/java/com/tongran/mtragent/domain/vo/RmMtrPolicyConfigVo.java
@@ -0,0 +1,31 @@
+package com.tongran.mtragent.domain.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * mtr探测策略配置对象 rm_mtr_policy_config
+ *
+ * @author gyt
+ * @date 2025-11-18
+ */
+@Data
+public class RmMtrPolicyConfigVo
+{
+ /** 开始时间 */
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ private Date startTime;
+
+ /** 结束时间 */
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ private Date endTime;
+
+ /** 探测频率(秒) */
+ private Long probeFrequency;
+ /** clientId和ip对应集合 */
+ private Map> clientIdToIpsMap;
+}
diff --git a/tongran-modules/tongran-mtragent/src/main/java/com/tongran/mtragent/handler/MessageHandler.java b/tongran-modules/tongran-mtragent/src/main/java/com/tongran/mtragent/handler/MessageHandler.java
index 534ea4e..26138cb 100644
--- a/tongran-modules/tongran-mtragent/src/main/java/com/tongran/mtragent/handler/MessageHandler.java
+++ b/tongran-modules/tongran-mtragent/src/main/java/com/tongran/mtragent/handler/MessageHandler.java
@@ -27,8 +27,10 @@ import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.math.BigDecimal;
+import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.function.Consumer;
+import java.util.stream.Collectors;
/**
* 设备消息处理器
@@ -229,12 +231,18 @@ public class MessageHandler {
if(!interfaces.isEmpty()) {
RegisterMsgVo registerMsgVo = interfaces.get(0);
String mtrClientId = registerMsgVo.getClientId();
- List mtrPolicyConfigList = rmMtrPolicyConfigService.getPoliciesForMtrClient(mtrClientId);
- if(mtrPolicyConfigList == null){
- mtrPolicyConfigList = new ArrayList<>();
- }
+ List mtrPolicyConfigList = Optional.ofNullable(rmMtrPolicyConfigService.getPoliciesForMtrClient(mtrClientId))
+ .orElse(new ArrayList<>());
+
+ List rmMtrPolicyConfigVoList = mtrPolicyConfigList.stream()
+ .map(policy -> {
+ RmMtrPolicyConfigVo vo = new RmMtrPolicyConfigVo();
+ BeanUtils.copyProperties(policy, vo);
+ return vo;
+ })
+ .collect(Collectors.toList());
// 构建mtrclient消息
- String mtrPolicyListStr = JSONObject.toJSONString(mtrPolicyConfigList);
+ String mtrPolicyListStr = JSONObject.toJSONString(rmMtrPolicyConfigVoList);
PolicyTypeVo policyTypeVo = new PolicyTypeVo();
policyTypeVo.setMtrPolicys(mtrPolicyListStr);
String configJson = JSONObject.toJSONString(policyTypeVo);
@@ -247,9 +255,11 @@ public class MessageHandler {
messageProducer.sendAsyncProducerMessage(
producerMode.getAgentTopic(),
"",
- "",
+ "test",
JSONObject.toJSONString(message)
);
+ int size = message.getData().getBytes(StandardCharsets.UTF_8).length;
+ log.info("消息大小: {} 字节, {} KB", size, size/1024.0);
} catch (Exception e) {
log.error("发送mtr策略失败,mtrClientId: {}", mtrClientId, e);
}
@@ -332,7 +342,7 @@ public class MessageHandler {
// 只有达到3次心跳才执行数据库操作
if (newHeartbeatCount >= 3) {
- log.info("客户端ID: {} 达到{}次心跳,开始执行数据库操作", clientId, newHeartbeatCount);
+ log.debug("客户端ID: {} 达到{}次心跳,开始执行数据库操作", clientId, newHeartbeatCount);
// agent更新结果存储
RmMtrClientRegistration queryMtrClient = new RmMtrClientRegistration();
queryMtrClient.setMtrClientId(clientId);
diff --git a/tongran-modules/tongran-mtragent/src/main/java/com/tongran/mtragent/producer/MessageProducer.java b/tongran-modules/tongran-mtragent/src/main/java/com/tongran/mtragent/producer/MessageProducer.java
index f29ad96..4e42df0 100644
--- a/tongran-modules/tongran-mtragent/src/main/java/com/tongran/mtragent/producer/MessageProducer.java
+++ b/tongran-modules/tongran-mtragent/src/main/java/com/tongran/mtragent/producer/MessageProducer.java
@@ -165,7 +165,7 @@ public class MessageProducer {
try
{
Message msg = new Message(topic,tag,key, value.getBytes(RemotingHelper.DEFAULT_CHARSET));
- System.out.println("生产者发送消息:"+ JSON.toJSONString(value));
+ log.info("生产者发送消息:"+ JSON.toJSONString(value));
//设置消息延迟级别,我这里设置5,对应就是延时一分钟
// "1s 5s 10s 30s 1m 2m 3m 4m 5m 6m 7m 8m 9m 10m 20m 30m 1h 2h"
msg.setDelayTimeLevel(level);
@@ -197,7 +197,7 @@ public class MessageProducer {
try {
//创建一个消息实例,指定主题、标签和消息体。
Message msg = new Message(topic,tag,key, value.getBytes(RemotingHelper.DEFAULT_CHARSET));
- System.out.println("生产者发送消息:"+ JSON.toJSONString(value));
+ log.info("生产者发送消息:"+ JSON.toJSONString(value));
producer.send(msg,new SendCallback() {
// 异步回调的处理
@Override
diff --git a/tongran-modules/tongran-mtragent/src/main/java/com/tongran/mtragent/service/impl/RmMtrClientRegistrationServiceImpl.java b/tongran-modules/tongran-mtragent/src/main/java/com/tongran/mtragent/service/impl/RmMtrClientRegistrationServiceImpl.java
index a89be4d..c9a4add 100644
--- a/tongran-modules/tongran-mtragent/src/main/java/com/tongran/mtragent/service/impl/RmMtrClientRegistrationServiceImpl.java
+++ b/tongran-modules/tongran-mtragent/src/main/java/com/tongran/mtragent/service/impl/RmMtrClientRegistrationServiceImpl.java
@@ -68,7 +68,7 @@ public class RmMtrClientRegistrationServiceImpl implements IRmMtrClientRegistrat
List list = rmMtrClientRegistrationMapper.selectRmMtrClientRegistrationList(rmMtrClientRegistration);
for (RmMtrClientRegistration mtrClientRegistration : list) {
// 处理网卡信息
- setNetworkMsg(rmMtrClientRegistration);
+ setNetworkMsg(mtrClientRegistration);
}
return list;
}
diff --git a/tongran-modules/tongran-mtragent/src/main/java/com/tongran/mtragent/service/impl/RmMtrPolicyConfigServiceImpl.java b/tongran-modules/tongran-mtragent/src/main/java/com/tongran/mtragent/service/impl/RmMtrPolicyConfigServiceImpl.java
index 88769aa..56cb1e0 100644
--- a/tongran-modules/tongran-mtragent/src/main/java/com/tongran/mtragent/service/impl/RmMtrPolicyConfigServiceImpl.java
+++ b/tongran-modules/tongran-mtragent/src/main/java/com/tongran/mtragent/service/impl/RmMtrPolicyConfigServiceImpl.java
@@ -150,6 +150,8 @@ public class RmMtrPolicyConfigServiceImpl implements IRmMtrPolicyConfigService
public int updateRmMtrPolicyConfig(RmMtrPolicyConfig rmMtrPolicyConfig)
{
rmMtrPolicyConfig.setUpdateTime(DateUtils.getNowDate());
+ // 给ip赋值
+ setServerip(rmMtrPolicyConfig);
return rmMtrPolicyConfigMapper.updateRmMtrPolicyConfig(rmMtrPolicyConfig);
}
diff --git a/tongran-modules/tongran-mtragent/src/main/resources/bootstrap.yml b/tongran-modules/tongran-mtragent/src/main/resources/bootstrap.yml
index ab754f2..adf8d9d 100644
--- a/tongran-modules/tongran-mtragent/src/main/resources/bootstrap.yml
+++ b/tongran-modules/tongran-mtragent/src/main/resources/bootstrap.yml
@@ -23,7 +23,7 @@ spring:
server-addr: 172.16.15.52:8848
# server-addr: 172.16.15.103:8848
# namespace: public
- namespace: saas-local
+ namespace: saas-prod
username: nacos
password: nacos
# 配置文件格式
diff --git a/tongran-modules/tongran-system/src/main/java/com/tongran/system/config/TableScheduleConfig.java b/tongran-modules/tongran-system/src/main/java/com/tongran/system/config/TableScheduleConfig.java
index f377e94..4a77dcf 100644
--- a/tongran-modules/tongran-system/src/main/java/com/tongran/system/config/TableScheduleConfig.java
+++ b/tongran-modules/tongran-system/src/main/java/com/tongran/system/config/TableScheduleConfig.java
@@ -58,6 +58,12 @@ public class TableScheduleConfig {
// 每天0点执行 计算95带宽值/日
@Scheduled(cron = "0 4 0 * * ?", zone = "Asia/Shanghai")
public void calculate95BandwidthDaily() {
+ // 获取当月的日期范围
+ LocalDate lastMonth = LocalDate.now(ZoneId.of("Asia/Shanghai"));
+ LocalDate firstDayOfMonth = lastMonth.withDayOfMonth(1);
+ LocalDate lastDayOfMonth = lastMonth.withDayOfMonth(lastMonth.lengthOfMonth());
+ String monthlyStartTime = firstDayOfMonth.atStartOfDay().format(TIME_FORMAT);
+ String monthlyEndTime = lastDayOfMonth.atTime(23, 59, 59).format(TIME_FORMAT);
// 获取昨天的日期范围(北京时间)
LocalDate yesterday = LocalDate.now(ZoneId.of("Asia/Shanghai")).minusDays(1);
String dailyStartTime = yesterday.atStartOfDay().format(TIME_FORMAT); // 00:00:00
@@ -77,7 +83,11 @@ public class TableScheduleConfig {
.thenRun(() -> executeWithLog("交换机带宽1000",
() -> initialSwitchInfoDetailsService.calculateSwitch95BandwidthDaily(initialSwitchInfoDetails, dailyStartTime, dailyEndTime, "1000")))
.thenRun(() -> executeWithLog("交换机带宽1024",
- () -> initialSwitchInfoDetailsService.calculateSwitch95BandwidthDaily(initialSwitchInfoDetails, dailyStartTime, dailyEndTime, "1024")));
+ () -> initialSwitchInfoDetailsService.calculateSwitch95BandwidthDaily(initialSwitchInfoDetails, dailyStartTime, dailyEndTime, "1024")))
+ .thenRun(() -> calculateSwitchMonthlyBandwidth(monthlyStartTime, monthlyEndTime, "1000"))
+ .thenRun(() -> calculateSwitchMonthlyBandwidth(monthlyStartTime, monthlyEndTime, "1024"))
+ .thenRun(() -> calculateSwitchAvgMonthlyBandwidth(monthlyStartTime, monthlyEndTime, "1000"))
+ .thenRun(() -> calculateSwitchAvgMonthlyBandwidth(monthlyStartTime, monthlyEndTime, "1024"));
}
// 每天5点04执行 计算金山95带宽值/日
@Scheduled(cron = "0 4 5 * * ?", zone = "Asia/Shanghai")
diff --git a/tongran-modules/tongran-system/src/main/java/com/tongran/system/domain/RmResourceRegistration.java b/tongran-modules/tongran-system/src/main/java/com/tongran/system/domain/RmResourceRegistration.java
index 39bbea3..81669ed 100644
--- a/tongran-modules/tongran-system/src/main/java/com/tongran/system/domain/RmResourceRegistration.java
+++ b/tongran-modules/tongran-system/src/main/java/com/tongran/system/domain/RmResourceRegistration.java
@@ -5,6 +5,7 @@ import com.tongran.common.core.annotation.Excel;
import com.tongran.common.core.web.domain.BaseEntity;
import lombok.Data;
+import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -224,4 +225,6 @@ public class RmResourceRegistration extends BaseEntity
private boolean businessEmpty;
/** 逻辑节点空标识 */
private boolean logicalNodeEmpty;
+ /** 昨日95值 */
+ private BigDecimal bandwidthResult;
}
\ No newline at end of file
diff --git a/tongran-modules/tongran-system/src/main/java/com/tongran/system/service/impl/EpsNodeBandwidthServiceImpl.java b/tongran-modules/tongran-system/src/main/java/com/tongran/system/service/impl/EpsNodeBandwidthServiceImpl.java
index 99a4a72..a3f4faf 100644
--- a/tongran-modules/tongran-system/src/main/java/com/tongran/system/service/impl/EpsNodeBandwidthServiceImpl.java
+++ b/tongran-modules/tongran-system/src/main/java/com/tongran/system/service/impl/EpsNodeBandwidthServiceImpl.java
@@ -191,8 +191,6 @@ public class EpsNodeBandwidthServiceImpl implements IEpsNodeBandwidthService
// 4. 安全获取求和值
BigDecimal sum95Daily = Optional.ofNullable(calculatedData.getBandwidth95Daily()).orElse(BigDecimal.ZERO);
- BigDecimal sumEffectiveBandwidth95Daily = Optional.ofNullable(calculatedData.getEffectiveBandwidth95Daily()).orElse(BigDecimal.ZERO);
-
// 5. 计算当月天数
LocalDate monthTime;
try {
diff --git a/tongran-modules/tongran-system/src/main/java/com/tongran/system/service/impl/RmResourceRegistrationServiceImpl.java b/tongran-modules/tongran-system/src/main/java/com/tongran/system/service/impl/RmResourceRegistrationServiceImpl.java
index 0b3dadf..c0a9da9 100644
--- a/tongran-modules/tongran-system/src/main/java/com/tongran/system/service/impl/RmResourceRegistrationServiceImpl.java
+++ b/tongran-modules/tongran-system/src/main/java/com/tongran/system/service/impl/RmResourceRegistrationServiceImpl.java
@@ -23,6 +23,8 @@ import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.math.RoundingMode;
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
@@ -68,6 +70,8 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
setNetWorkMsg(rmResourceRegistration);
// set金山machineCode
setMachineMsg(rmResourceRegistration);
+ // set昨日95值
+ setBandwidthYestoday(rmResourceRegistration);
}
return rmResourceRegistration;
}
@@ -93,6 +97,8 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
if(resourceRegistration.getClientId() != null){
// 网卡信息
setNetWorkMsg(resourceRegistration);
+ // set昨日95值
+ setBandwidthYestoday(resourceRegistration);
}
}
if(rmResourceRegistration.getQueryParam() != null && !rmResourceRegistration.getQueryParam().trim().isEmpty()){
@@ -297,6 +303,21 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
registration.setMachineCode(machineMsg.getMachineCode());
}
}
+
+ public void setBandwidthYestoday(RmResourceRegistration registration){
+ // 查询昨日95值
+ String yesterday = LocalDate.now().minusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));;
+ Date yesterdayDate = DateUtils.parseDate(yesterday);
+ EpsNodeBandwidth epsNodeBandwidth = new EpsNodeBandwidth();
+ epsNodeBandwidth.setClientId(registration.getClientId());
+ epsNodeBandwidth.setBandwidthType("1");
+ epsNodeBandwidth.setCreateTime(yesterdayDate);
+ List nodeBandwidthList = epsNodeBandwidthMapper.selectEpsNodeBandwidthList(epsNodeBandwidth);
+ if(nodeBandwidthList != null && !nodeBandwidthList.isEmpty()){
+ EpsNodeBandwidth nodeBandwidth = nodeBandwidthList.get(0);
+ registration.setBandwidthResult(nodeBandwidth.getBandwidthResult());
+ }
+ }
/**
* 新增资源注册
*
diff --git a/tongran-modules/tongran-system/src/main/resources/bootstrap.yml b/tongran-modules/tongran-system/src/main/resources/bootstrap.yml
index d4eb062..00e429b 100644
--- a/tongran-modules/tongran-system/src/main/resources/bootstrap.yml
+++ b/tongran-modules/tongran-system/src/main/resources/bootstrap.yml
@@ -21,7 +21,7 @@ spring:
# 配置中心地址
server-addr: 172.16.15.52:8848
# server-addr: 172.16.15.103:8848
- namespace: saas-local
+ namespace: saas-prod
# namespace: public
username: nacos
password: nacos
diff --git a/tongran-modules/tongran-system/src/main/resources/mapper/system/EpsNodeBandwidthMapper.xml b/tongran-modules/tongran-system/src/main/resources/mapper/system/EpsNodeBandwidthMapper.xml
index 949d70a..194f6eb 100644
--- a/tongran-modules/tongran-system/src/main/resources/mapper/system/EpsNodeBandwidthMapper.xml
+++ b/tongran-modules/tongran-system/src/main/resources/mapper/system/EpsNodeBandwidthMapper.xml
@@ -230,8 +230,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"