增加服务器下架处理,
服务器详情增加agent最新版本、cpu核数、内存字段。 开发pppoe主表及子表CRUD
This commit is contained in:
+10
@@ -272,4 +272,14 @@ public class RmResourceRegistrationController extends BaseController
|
||||
return toAjax(rmResourceRegistrationService.removeAlarmFlag(rmResourceRegistration));
|
||||
}
|
||||
|
||||
/**
|
||||
* 下架
|
||||
*/
|
||||
@Log(title = "下架", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/removeServer")
|
||||
public AjaxResult removeServer(@RequestBody RmResourceRegistration rmResourceRegistration)
|
||||
{
|
||||
return toAjax(rmResourceRegistrationService.removeServer(rmResourceRegistration.getIds()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+10
@@ -259,8 +259,12 @@ public class RmResourceRegistration extends BaseEntity
|
||||
private Integer bandwidthResultSort;
|
||||
/** cpu利用率 */
|
||||
private BigDecimal cpuUtil;
|
||||
/** cpu核数 */
|
||||
private BigDecimal cpuCores;
|
||||
/** 内存使用率 */
|
||||
private BigDecimal memUtil;
|
||||
/** 总内存 */
|
||||
private Integer memTotalSize;
|
||||
/** 是否告警 */
|
||||
private boolean alarmFlag;
|
||||
/** 取消告警时间 */
|
||||
@@ -272,4 +276,10 @@ public class RmResourceRegistration extends BaseEntity
|
||||
private String frpcRemotePort;
|
||||
/** FRPC服务器地址 */
|
||||
private String frpcServerAddr;
|
||||
/** 下架标识(0未下架、1下架) */
|
||||
private Integer delFlag;
|
||||
/** agent最新版本号 */
|
||||
private String maxAgentVersion;
|
||||
/** id集合 */
|
||||
private Long[] ids;
|
||||
}
|
||||
+4
@@ -128,4 +128,8 @@ public interface RmResourceRegistrationMapper
|
||||
List<RmResourceRegistration> getMemUtil(@Param("clientIdsStr") String clientIdsStr);
|
||||
|
||||
int removeAlarmFlag(RmResourceRegistration rmResourceRegistration);
|
||||
|
||||
int removeServer(Long[] ids);
|
||||
|
||||
RmResourceRegistration getMaxAgentVersion();
|
||||
}
|
||||
|
||||
+7
@@ -146,4 +146,11 @@ public interface IRmResourceRegistrationService
|
||||
* @return
|
||||
*/
|
||||
int removeAlarmFlag(RmResourceRegistration rmResourceRegistration);
|
||||
|
||||
/**
|
||||
* 下架
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
int removeServer(Long[] ids);
|
||||
}
|
||||
|
||||
+24
-23
@@ -513,17 +513,6 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 回退到单条查询
|
||||
*/
|
||||
private void fallbackSetNetworkInfo(List<RmResourceRegistration> pageList) {
|
||||
log.warn("批量查询失败,回退到单条查询");
|
||||
for (RmResourceRegistration registration : pageList) {
|
||||
if (registration.getClientId() != null) {
|
||||
setNetWorkMsg(registration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 网卡信息赋值
|
||||
@@ -535,11 +524,18 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
||||
List<RmResourceRegistration> cpuUtilList = rmResourceRegistrationMapper.getCpuUtil(clientId);
|
||||
// 根据clientId查询mem利用率
|
||||
List<RmResourceRegistration> memUtilList = rmResourceRegistrationMapper.getMemUtil(clientId);
|
||||
// 查询agent最新版本
|
||||
RmResourceRegistration rmResourceRegistration = rmResourceRegistrationMapper.getMaxAgentVersion();
|
||||
if(cpuUtilList != null && !cpuUtilList.isEmpty()){
|
||||
registration.setCpuUtil(cpuUtilList.get(0).getCpuUtil());
|
||||
registration.setCpuCores(cpuUtilList.get(0).getCpuCores());
|
||||
}
|
||||
if(memUtilList != null && !memUtilList.isEmpty()){
|
||||
registration.setMemUtil(memUtilList.get(0).getMemUtil());
|
||||
registration.setMemTotalSize(memUtilList.get(0).getMemTotalSize());
|
||||
}
|
||||
if(rmResourceRegistration != null){
|
||||
registration.setMaxAgentVersion(rmResourceRegistration.getMaxAgentVersion());
|
||||
}
|
||||
// 根据clientId查询网卡信息
|
||||
RmNetworkInterfaceRemote queryParam = new RmNetworkInterfaceRemote();
|
||||
@@ -1079,17 +1075,18 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
||||
network.setId(Long.parseLong(map.get("id").toString()));
|
||||
network.setBindIp(map.get("status").toString());
|
||||
remoteRocketMqService.bindPublicIp(network, SecurityConstants.INNER);
|
||||
|
||||
// 添加变更记录
|
||||
EpsMethodChangeRecord record = new EpsMethodChangeRecord();
|
||||
record.setClientId(clientId);
|
||||
record.setTrafficPort(map.get("interfaceName").toString());
|
||||
record.setCreateTime(now);
|
||||
record.setUpdateTime(now);
|
||||
record.setUpdateBy(username);
|
||||
record.setCreatBy(username);
|
||||
record.setChangeContent("流量网口设置为" + map.get("interfaceName"));
|
||||
epsMethodChangeRecordMapper.insertEpsMethodChangeRecord(record);
|
||||
if("1".equals(map.get("status").toString()) || "3".equals(map.get("status").toString())){
|
||||
// 添加变更记录
|
||||
EpsMethodChangeRecord record = new EpsMethodChangeRecord();
|
||||
record.setClientId(clientId);
|
||||
record.setTrafficPort(map.get("interfaceName").toString());
|
||||
record.setCreateTime(now);
|
||||
record.setUpdateTime(now);
|
||||
record.setUpdateBy(username);
|
||||
record.setCreatBy(username);
|
||||
record.setChangeContent("流量网口设置为" + map.get("interfaceName"));
|
||||
epsMethodChangeRecordMapper.insertEpsMethodChangeRecord(record);
|
||||
}
|
||||
});
|
||||
|
||||
// 2. 更新注册状态
|
||||
@@ -1255,5 +1252,9 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
||||
int rows = rmResourceRegistrationMapper.removeAlarmFlag(rmResourceRegistration);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int removeServer(Long[] ids)
|
||||
{
|
||||
return rmResourceRegistrationMapper.removeServer(ids);
|
||||
}
|
||||
}
|
||||
|
||||
+18
-4
@@ -37,6 +37,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<select id="selectRmResourceRegistrationList" parameterType="RmResourceRegistration" resultMap="RmResourceRegistrationResult">
|
||||
<include refid="selectRmResourceRegistrationVo"/>
|
||||
<where>
|
||||
and del_flag=0
|
||||
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
|
||||
<if test="hardwareSn != null and hardwareSn != ''"> and hardware_sn = #{hardwareSn}</if>
|
||||
<if test="businessName != null and businessName != ''"> and business_name like concat('%', #{businessName}, '%')</if>
|
||||
@@ -252,6 +253,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
left join rm_registration_machine b on a.client_id = b.client_id
|
||||
left join rm_frpc_config_manage c on a.client_id=c.client_id
|
||||
<where>
|
||||
and a.del_flag=0
|
||||
<if test="hardwareSn != null and hardwareSn != ''"> and a.hardware_sn = #{hardwareSn}</if>
|
||||
<if test="resourceType != null and resourceType != ''"> and a.resource_type = #{resourceType}</if>
|
||||
<if test="agentVersion != null and agentVersion != ''"> and a.agent_version = #{agentVersion}</if>
|
||||
@@ -295,6 +297,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<select id="getCpuUtil" resultType="RmResourceRegistration">
|
||||
SELECT
|
||||
d.client_id as clientId,
|
||||
d.cores as cpuCores,
|
||||
d.uti as cpuUtil
|
||||
FROM initial_cpu_info d
|
||||
INNER JOIN (
|
||||
@@ -311,16 +314,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
AND d.create_time = latest.latest_time
|
||||
</select>
|
||||
<select id="getMemUtil" resultType="RmResourceRegistration">
|
||||
SELECT
|
||||
select
|
||||
d.client_id as clientId,
|
||||
ROUND(d.collect_value, 1) as memUtil
|
||||
max(CASE WHEN d.collect_type = 'memorySizeTotalCollect' THEN floor(d.collect_value/(1024 * 1024)) END) as memTotalSize,
|
||||
max(CASE WHEN d.collect_type = 'memoryUtilizationCollect' THEN ROUND(d.collect_value, 1) END) as memUtil
|
||||
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='memoryUtilizationCollect'
|
||||
WHERE (collect_type='memoryUtilizationCollect' or collect_type='memorySizeTotalCollect')
|
||||
AND client_id in
|
||||
<foreach collection="clientIdsStr.split(',')" item="clientId" open="(" separator="," close=")">
|
||||
#{clientId}
|
||||
@@ -328,10 +332,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
GROUP BY client_id
|
||||
) latest ON d.client_id = latest.client_id
|
||||
AND d.create_time = latest.max_time
|
||||
AND d.collect_type='memoryUtilizationCollect'
|
||||
AND (d.collect_type='memoryUtilizationCollect' or d.collect_type='memorySizeTotalCollect')
|
||||
</select>
|
||||
<update id="removeAlarmFlag" parameterType="RmResourceRegistration">
|
||||
update rm_resource_registration set del_alarm_time = now()
|
||||
where id =#{id}
|
||||
</update>
|
||||
<update id="removeServer" parameterType="String">
|
||||
update rm_resource_registration set del_flag=1 where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
<select id="getMaxAgentVersion" resultType="RmResourceRegistration">
|
||||
select agent_version maxAgentVersion from rm_resource_registration where del_flag=0
|
||||
order by create_time desc limit 1
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user