开发庭与科技详情相关接口。

优化PppoE查询接口。
This commit is contained in:
gaoyutao
2025-12-31 17:59:33 +08:00
parent 08680bb46a
commit 4651da4fe4
23 changed files with 200 additions and 33 deletions
@@ -92,6 +92,16 @@ public class InitialBandwidthTrafficController extends BaseController
}
/**
* 服务器详情
* @param initialBandwidthTraffic
* @return
*/
@PostMapping("/serverDetails")
public AjaxResult serverDetails(@RequestBody InitialBandwidthTraffic initialBandwidthTraffic) {
Map<String, Object> map= initialBandwidthTrafficService.serverDetails(initialBandwidthTraffic);
return success(map);
}
/**
* 网络接口基础信息
* @param initialBandwidthTraffic
@@ -91,4 +91,10 @@ public class RmAgentManagementController extends BaseController
{
return toAjax(rmAgentManagementService.addUpdatePolicy(rmAgentManagement));
}
@PostMapping("/isNew")
public AjaxResult isNew(@RequestBody RmAgentManagement rmAgentManagement)
{
RmAgentManagement isNew = rmAgentManagementService.isNew(rmAgentManagement);
return success(isNew);
}
}
@@ -105,4 +105,16 @@ public class RmFrpcConfigManageController extends BaseController
{
return toAjax(rmFrpcConfigManageService.addFrpConnect(rmFrpcConfigManage));
}
/**
* 根据clientid查询frp信息
* @param rmFrpcConfigManage
* @return
*/
@PostMapping("/getFrpMsgByClientId")
public AjaxResult getFrpMsgByClientId(@RequestBody RmFrpcConfigManage rmFrpcConfigManage)
{
RmFrpcConfigManage frpMsg = rmFrpcConfigManageService.getFrpMsgByClientId(rmFrpcConfigManage);
return success(frpMsg);
}
}
@@ -28,10 +28,10 @@ public class RmPppoeConfigMainController extends BaseController
/**
* 获取PPPoE配置主表详细信息
*/
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
@PostMapping("/getPppoeConfigMsg")
public AjaxResult getInfo(@RequestBody RmPppoeConfigMain rmPppoeConfigMain)
{
return success(rmPppoeConfigMainService.selectRmPppoeConfigMainById(id));
return success(rmPppoeConfigMainService.selectRmPppoeConfigMainByClientId(rmPppoeConfigMain));
}
/**
@@ -82,5 +82,7 @@ public class RmAgentManagement extends BaseEntity
private String deployDevice;
/** 管理网公网Ip */
private String managePublicIp;
/** 是否最新 */
private boolean newFlag;
}
@@ -1296,6 +1296,8 @@ public class MessageHandler {
private void updateNetworkInterface(NetworkInfo networkInfo, String clientId,
RmNetworkInterface oldInterfaceMsg, boolean isSingleInterface, boolean isRegister) {
RmNetworkInterface updateData = new RmNetworkInterface();
BeanUtils.copyProperties(oldInterfaceMsg, updateData);
boolean needUpdate = false;
// 逐个字段比较是否需要更新
@@ -1318,14 +1320,6 @@ public class MessageHandler {
if (!StringUtils.equals(networkInfo.getPublicIp(), oldInterfaceMsg.getPublicIp())) {
updateData.setPublicIp(networkInfo.getPublicIp());
needUpdate = true;
// 特殊处理:非注册消息且多网卡时,更新公网IP状态
if (!isSingleInterface && !isRegister) {
updateData.setBindIp("0");
RmResourceRegistrationRemote updateParam = new RmResourceRegistrationRemote();
updateParam.setClientId(clientId);
updateParam.setMultiPublicIpStatus("0");
remoteRevenueConfigService.updateStatusByResource(updateParam, SecurityConstants.INNER);
}
}
if (!StringUtils.equals(networkInfo.getCarrier(), oldInterfaceMsg.getIsp())) {
updateData.setIsp(networkInfo.getCarrier());
@@ -1340,7 +1334,7 @@ public class MessageHandler {
if (needUpdate) {
updateData.setClientId(clientId);
updateData.setMacAddress(oldInterfaceMsg.getMacAddress());
rmNetworkInterfaceService.updateRmNetworkInterfaceByMac(updateData);
rmNetworkInterfaceService.updateNetMsgByMac(updateData);
}
}
}
@@ -1,6 +1,7 @@
package com.tongran.rocketmq.mapper;
import com.tongran.rocketmq.domain.InitialSystemOtherCollectData;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
@@ -74,4 +75,10 @@ public interface InitialSystemOtherCollectDataMapper
* @return
*/
int deleteInitialSystemOtherCollectData(InitialSystemOtherCollectData deleteData);
/**
* 获取总内存
* @param clientId
* @return
*/
String getMemTotalSize(@Param("clientId") String clientId);
}
@@ -61,4 +61,6 @@ public interface RmNetworkInterfaceMapper
public int deleteRmNetworkInterfaceByIds(Long[] ids);
int updateRmNetworkInterfaceByMac(RmNetworkInterface rmNetworkInterface);
int updateNetMsgByMac(RmNetworkInterface rmNetworkInterface);
}
@@ -1,7 +1,9 @@
package com.tongran.rocketmq.mapper;
import java.util.List;
import com.tongran.rocketmq.domain.RmPppoeConfigMain;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* PPPoE配置主表Mapper接口
@@ -17,7 +19,15 @@ public interface RmPppoeConfigMainMapper
* @param id PPPoE配置主表主键
* @return PPPoE配置主表
*/
public RmPppoeConfigMain selectRmPppoeConfigMainById(Long id);
public RmPppoeConfigMain selectRmPppoeConfigMainById(String id);
/**
* 查询PPPoE配置主表
*
* @param clientId PPPoE配置主表唯一标识
* @return PPPoE配置主表
*/
public RmPppoeConfigMain selectRmPppoeConfigMainByClientId(@Param("clientId") String clientId);
/**
* 查询PPPoE配置主表列表
@@ -112,4 +112,11 @@ public interface IInitialBandwidthTrafficService
* @return
*/
List<Map<String, Object>> netBatchTrafficEcharts(InitialBandwidthTraffic initialBandwidthTraffic);
/**
* 服务器详情
* @param initialBandwidthTraffic
* @return
*/
Map<String, Object> serverDetails(InitialBandwidthTraffic initialBandwidthTraffic);
}
@@ -88,4 +88,11 @@ public interface IRmAgentManagementService
* @return
*/
int addUpdatePolicy(RmAgentManagement rmAgentManagement);
/**
* 判断agent是否包含最新连接
* @param rmAgentManagement
* @return
*/
RmAgentManagement isNew(RmAgentManagement rmAgentManagement);
}
@@ -66,4 +66,11 @@ public interface IRmFrpcConfigManageService
* @return
*/
int addFrpConnect(RmFrpcConfigManage rmFrpcConfigManage);
/**
* 根据clientid查询frp信息
* @param rmFrpcConfigManage
* @return
*/
RmFrpcConfigManage getFrpMsgByClientId(RmFrpcConfigManage rmFrpcConfigManage);
}
@@ -51,6 +51,8 @@ public interface IRmNetworkInterfaceService
*/
public int updateRmNetworkInterfaceByMac(RmNetworkInterface rmNetworkInterface);
public int updateNetMsgByMac(RmNetworkInterface rmNetworkInterface);
/**
* 批量删除客户端网络接口信息
*
@@ -1,8 +1,9 @@
package com.tongran.rocketmq.service;
import java.util.List;
import com.tongran.rocketmq.domain.RmPppoeConfigMain;
import java.util.List;
/**
* PPPoE配置主表Service接口
*
@@ -14,10 +15,10 @@ public interface IRmPppoeConfigMainService
/**
* 查询PPPoE配置主表
*
* @param id PPPoE配置主表主键
* @param rmPppoeConfigMain PPPoE配置主表信息
* @return PPPoE配置主表
*/
public RmPppoeConfigMain selectRmPppoeConfigMainById(Long id);
public RmPppoeConfigMain selectRmPppoeConfigMainByClientId(RmPppoeConfigMain rmPppoeConfigMain);
/**
* 查询PPPoE配置主表列表
@@ -1,12 +1,12 @@
package com.tongran.rocketmq.service.impl;
import com.tongran.common.core.utils.DateUtils;
import com.tongran.common.core.utils.EchartsDataUtils;
import com.tongran.common.core.utils.EchartsMoreDataUtils;
import com.tongran.common.core.utils.SpeedUtils;
import com.tongran.common.core.utils.*;
import com.tongran.rocketmq.domain.InitialBandwidthTraffic;
import com.tongran.rocketmq.domain.InitialCpuInfo;
import com.tongran.rocketmq.domain.RmNetworkInterfaceChild;
import com.tongran.rocketmq.mapper.InitialBandwidthTrafficMapper;
import com.tongran.rocketmq.mapper.InitialCpuInfoMapper;
import com.tongran.rocketmq.mapper.InitialSystemOtherCollectDataMapper;
import com.tongran.rocketmq.mapper.RmNetworkInterfaceChildMapper;
import com.tongran.rocketmq.service.IInitialBandwidthTrafficService;
import com.tongran.rocketmq.utils.TableRouterUtil;
@@ -38,6 +38,10 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf
private InitialBandwidthTrafficMapper initialBandwidthTrafficMapper;
@Autowired
private RmNetworkInterfaceChildMapper rmNetworkInterfaceChildMapper;
@Autowired
private InitialSystemOtherCollectDataMapper initialSystemOtherCollectDataMapper;
@Autowired
private InitialCpuInfoMapper initialCpuInfoMapper;
/**
* 查询初始带宽流量
@@ -598,6 +602,26 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf
return resultList;
}
@Override
public Map<String, Object> serverDetails(InitialBandwidthTraffic initialBandwidthTraffic) {
InitialBandwidthTraffic sppedMsg = getNetInterfaceDetailsMsg(initialBandwidthTraffic);
Map<String, Object> resultMap = new HashMap<>();
if(sppedMsg == null){
sppedMsg = new InitialBandwidthTraffic();
}
resultMap.put("speed", sppedMsg.getSpeed());
String memTotalSize = initialSystemOtherCollectDataMapper.getMemTotalSize(initialBandwidthTraffic.getClientId());
resultMap.put("memTotalSize", memTotalSize);
// 获取cpu数量
InitialCpuInfo cpuInfo = initialCpuInfoMapper.getCpuInfoByClientId(initialBandwidthTraffic.getClientId());
if (cpuInfo == null) {
cpuInfo = new InitialCpuInfo();
}
resultMap.put("cpuUti", cpuInfo.getUti());
resultMap.put("cpuCores", cpuInfo.getCores());
return resultMap;
}
/**
* 构建支持子网卡的批量echarts图表数据
* @param initialBandwidthTraffic
@@ -135,6 +135,16 @@ public class InitialSystemOtherCollectDataServiceImpl implements IInitialSystemO
cpuInfo = new InitialCpuInfo();
}
map.put("systemCpuNum", cpuInfo.getNum());
map.put("avg1", cpuInfo.getAvg1());
map.put("avg5", cpuInfo.getAvg5());
map.put("avg15", cpuInfo.getAvg15());
map.put("uti", cpuInfo.getUti());
map.put("normal", cpuInfo.getNormal());
map.put("idle", cpuInfo.getIdle());
map.put("iowait", cpuInfo.getIowait());
map.put("system", cpuInfo.getSystem());
map.put("noresp", cpuInfo.getNoresp());
map.put("user", cpuInfo.getUser());
return map;
}
@@ -202,6 +202,22 @@ public class RmAgentManagementServiceImpl implements IRmAgentManagementService
return 1;
}
@Override
public RmAgentManagement isNew(RmAgentManagement rmAgentManagement) {
RmAgentManagement query = new RmAgentManagement();
query.setClientId(rmAgentManagement.getClientId());
List<RmAgentManagement> managementList = rmAgentManagementMapper.selectRmAgentManagementList(query);
if(managementList != null && !managementList.isEmpty()){
RmAgentManagement agentManagement = managementList.get(0);
String addr = agentManagement.getFileUrl();
if(addr.contains(rmAgentManagement.getAgentVersion())){
agentManagement.setNewFlag(true);
return agentManagement;
}
}
return new RmAgentManagement();
}
/**
* 手动立即更新
* @param rmAgentManagement 更新信息
@@ -214,6 +214,16 @@ public class RmFrpcConfigManageServiceImpl implements IRmFrpcConfigManageService
throw new RuntimeException("该端口范围内无可用端口:" + startRemotePort + "~" + endRemotePort);
}
}
@Override
public RmFrpcConfigManage getFrpMsgByClientId(RmFrpcConfigManage rmFrpcConfigManage) {
List<RmFrpcConfigManage> list = rmFrpcConfigManageMapper.selectRmFrpcConfigManageList(rmFrpcConfigManage);
if(list != null && !list.isEmpty()){
return list.get(0);
}
return new RmFrpcConfigManage();
}
/**
* 获取下一个可用的随机端口
*/
@@ -94,7 +94,11 @@ public class RmNetworkInterfaceServiceImpl implements IRmNetworkInterfaceService
rmNetworkInterface.setUpdateTime(DateUtils.getNowDate());
return rmNetworkInterfaceMapper.updateRmNetworkInterfaceByMac(rmNetworkInterface);
}
@Override
public int updateNetMsgByMac(RmNetworkInterface rmNetworkInterface) {
rmNetworkInterface.setUpdateTime(DateUtils.getNowDate());
return rmNetworkInterfaceMapper.updateNetMsgByMac(rmNetworkInterface);
}
/**
* 批量删除客户端网络接口信息
*
@@ -37,22 +37,19 @@ public class RmPppoeConfigMainServiceImpl implements IRmPppoeConfigMainService
@Autowired
private ProducerMode producerMode;
/**
* 查询PPPoE配置主表
*
* @param id PPPoE配置主表主键
* @return PPPoE配置主表
*/
@Override
public RmPppoeConfigMain selectRmPppoeConfigMainById(Long id)
public RmPppoeConfigMain selectRmPppoeConfigMainByClientId(RmPppoeConfigMain rmPppoeConfigMain)
{
RmPppoeConfigMain rmPppoeConfigMain = rmPppoeConfigMainMapper.selectRmPppoeConfigMainById(id);
RmPppoeConfigMain pppoeConfigMain = rmPppoeConfigMainMapper.selectRmPppoeConfigMainByClientId(rmPppoeConfigMain.getClientId());
if(pppoeConfigMain == null){
pppoeConfigMain = new RmPppoeConfigMain();
}
// 查询子表信息
RmPppoeConfigSub rmPppoeConfigSub = new RmPppoeConfigSub();
rmPppoeConfigSub.setClientId(rmPppoeConfigMain.getClientId());
List<RmPppoeConfigSub> subList = rmPppoeConfigSubMapper.selectRmPppoeConfigSubList(rmPppoeConfigSub);
rmPppoeConfigMain.setSubList(subList);
return rmPppoeConfigMain;
pppoeConfigMain.setSubList(subList);
return pppoeConfigMain;
}
/**
@@ -91,6 +91,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
MAX(CASE WHEN t.collect_type = 'systemBoottimeCollect' THEN t.collect_value END) as systemBoottimeCollect,
MAX(CASE WHEN t.collect_type = 'systemUnameCollect' THEN t.collect_value END) as systemUnameCollect,
MAX(CASE WHEN t.collect_type = 'systemLocaltimeCollect' THEN t.collect_value END) as systemLocaltimeCollect,
MAX(CASE WHEN t.collect_type = 'procNumRunCollect' THEN t.collect_value END) as procNumRunCollect,
MAX(CASE WHEN t.collect_type = 'systemUsersNumCollect' THEN t.collect_value END) as systemUsersNumCollect,
MAX(CASE WHEN t.collect_type = 'systemSwapSizeFreeCollect' THEN t.collect_value END) as systemSwapSizeFreeCollect,
MAX(CASE WHEN t.collect_type = 'systemSwapSizePercentCollect' THEN t.collect_value END) as systemSwapSizePercentCollect,
MAX(CASE WHEN t.collect_type = 'memorySizeAvailableCollect' THEN t.collect_value END) as memorySizeAvailableCollect,
MAX(CASE WHEN t.collect_type = 'memorySizePercentCollect' THEN t.collect_value END) as memorySizePercentCollect,
MAX(CASE WHEN t.collect_type = 'systemUptimeCollect' THEN t.collect_value END) as systemUptimeCollect
FROM `initial_system_other_collect_data` t
INNER JOIN (
@@ -117,4 +123,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</choose>
</where>
</delete>
<select id="getMemTotalSize" parameterType="String" resultType="String">
select
floor(d.collect_value/(1024 * 1024)) as memTotalSize
FROM initial_system_other_collect_data d
INNER JOIN (
SELECT
client_id,
MAX(create_time) as max_time
FROM initial_system_other_collect_data
WHERE collect_type='memorySizeTotalCollect'
AND client_id = #{clientId}
GROUP BY client_id
) latest ON d.client_id = latest.client_id
AND d.create_time = latest.max_time
AND d.collect_type='memorySizeTotalCollect'
</select>
</mapper>
@@ -162,4 +162,18 @@
</trim>
where mac_address = #{macAddress} and client_id = #{clientId}
</update>
<update id="updateNetMsgByMac" parameterType="RmNetworkInterface">
update rm_network_interface
set
isp = #{isp},
province = #{province},
city = #{city},
public_ip = #{publicIp},
interface_name = #{interfaceName},
interface_type = #{interfaceType},
ipv4_address = #{ipv4Address},
ipv6_address = #{ipv6Address},
update_time = #{updateTime}
where mac_address = #{macAddress} and client_id = #{clientId}
</update>
</mapper>
@@ -34,7 +34,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectRmPppoeConfigMainVo"/>
where id = #{id}
</select>
<select id="selectRmPppoeConfigMainByClientId" parameterType="RmPppoeConfigMain" resultMap="RmPppoeConfigMainResult">
<include refid="selectRmPppoeConfigMainVo"/>
where client_id = #{clientId}
</select>
<insert id="insertRmPppoeConfigMain" parameterType="RmPppoeConfigMain" useGeneratedKeys="true" keyProperty="id">
insert into rm_pppoe_config_main
<trim prefix="(" suffix=")" suffixOverrides=",">