增加服务器分配负责人功能

This commit is contained in:
gaoyutao
2026-04-07 17:36:39 +08:00
parent 4d39627d96
commit c918523a7a
9 changed files with 133 additions and 33 deletions
@@ -191,5 +191,9 @@ public class RmResourceRegistrationRemote extends BaseEntity
private BigDecimal outboundRate;
/** 公网ip */
private String ip1PublicIp;
/** 负责人手机号 */
private String phone;
/** 负责人名称 */
private String owner;
}
@@ -305,4 +305,13 @@ public class RmResourceRegistrationController extends BaseController
{
return toAjax(rmResourceRegistrationService.bindSwitch(rmResourceRegistration));
}
/**
* 绑定负责人
*/
@Log(title = "绑定负责人", businessType = BusinessType.UPDATE)
@PostMapping("/bindOwner")
public AjaxResult bindOwner(@RequestBody RmResourceRegistration rmResourceRegistration)
{
return toAjax(rmResourceRegistrationService.bindOwner(rmResourceRegistration));
}
}
@@ -1,23 +1,5 @@
package com.tongran.system.controller;
import java.io.IOException;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.tongran.common.core.domain.R;
import com.tongran.common.core.text.Convert;
import com.tongran.common.core.utils.DateUtils;
@@ -36,12 +18,19 @@ import com.tongran.system.api.domain.SysDept;
import com.tongran.system.api.domain.SysRole;
import com.tongran.system.api.domain.SysUser;
import com.tongran.system.api.model.LoginUser;
import com.tongran.system.service.ISysConfigService;
import com.tongran.system.service.ISysDeptService;
import com.tongran.system.service.ISysPermissionService;
import com.tongran.system.service.ISysPostService;
import com.tongran.system.service.ISysRoleService;
import com.tongran.system.service.ISysUserService;
import com.tongran.system.service.*;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
* 用户信息
@@ -84,6 +73,16 @@ public class SysUserController extends BaseController
List<SysUser> list = userService.selectUserList(user);
return getDataTable(list);
}
/**
* 获取所有用户列表
*/
@RequiresPermissions("system:user:list")
@PostMapping("/getAllUserList")
public AjaxResult getAllUserList(@RequestBody SysUser user)
{
List<SysUser> list = userService.selectUserList(user);
return success(list);
}
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
@RequiresPermissions("system:user:export")
@@ -293,4 +293,10 @@ public class RmResourceRegistration extends BaseEntity
private Long[] ids;
/** 批量查询 */
private String clientIds;
/** 负责人手机号 */
@Excel(name = "负责人手机号")
private String phone;
/** 负责人名称 */
@Excel(name = "负责人名称")
private String owner;
}
@@ -75,6 +75,8 @@ public interface RmResourceRegistrationMapper
* @return
*/
Integer updateStatusByResource(RmResourceRegistration rmResourceRegistration);
Integer bindSwitchMsg(RmResourceRegistration rmResourceRegistration);
Integer bindOwnerMsg(RmResourceRegistration rmResourceRegistration);
List<RmResourceRegistration> getRegistrationByIds(String[] ids);
@@ -159,4 +159,6 @@ public interface IRmResourceRegistrationService
RmResourceRegistration selectRmResourceRegistrationByClientId(RmResourceRegistration rmResourceRegistration);
int bindSwitch(RmResourceRegistration rmResourceRegistration);
int bindOwner(RmResourceRegistration rmResourceRegistration);
}
@@ -1486,7 +1486,21 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
updateData.setClientId(clientId);
updateData.setSwitchName(rmResourceRegistration.getSwitchName());
updateData.setSwitchClientId(rmResourceRegistration.getSwitchClientId());
rmResourceRegistrationMapper.updateStatusByResource(updateData);
rmResourceRegistrationMapper.bindSwitchMsg(updateData);
}
return 1;
}
@Override
public int bindOwner(RmResourceRegistration rmResourceRegistration) {
String clientIds = rmResourceRegistration.getDeployDevice();
String[] clientIdArr = clientIds.split("\n");
for (String clientId : clientIdArr) {
RmResourceRegistration updateData = new RmResourceRegistration();
updateData.setClientId(clientId);
updateData.setPhone(rmResourceRegistration.getPhone());
updateData.setOwner(rmResourceRegistration.getOwner());
rmResourceRegistrationMapper.bindOwnerMsg(updateData);
}
return 1;
}
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tongran.system.mapper.RmResourceRegistrationMapper">
<resultMap type="RmResourceRegistration" id="RmResourceRegistrationResult">
@@ -31,10 +31,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="frpcServerAddr" column="frpc_server_addr" />
<result property="switchClientId" column="switch_client_id" />
<result property="switchName" column="switch_name" />
<!-- 新增的 phone 和 owner 字段 -->
<result property="phone" column="phone" />
<result property="owner" column="owner" />
</resultMap>
<sql id="selectRmResourceRegistrationVo">
select id, client_id, hardware_sn, business_name, logical_node_id, multi_public_ip_status, registration_status, online_status, resource_type, agent_version, create_time, update_time, heartbeat_count, heartbeat_interval, onboard_time, remark, create_by, update_by, reported_bandwidth, del_alarm_time, outbound_rate,switch_client_id, switch_name from rm_resource_registration
select id, client_id, hardware_sn, business_name, logical_node_id, multi_public_ip_status, registration_status, online_status, resource_type, agent_version, create_time, update_time, heartbeat_count, heartbeat_interval, onboard_time, remark, create_by, update_by, reported_bandwidth, del_alarm_time, outbound_rate, switch_client_id, switch_name, phone, owner from rm_resource_registration
</sql>
<select id="selectRmResourceRegistrationList" parameterType="RmResourceRegistration" resultMap="RmResourceRegistrationResult">
@@ -54,6 +57,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="heartbeatCount != null "> and heartbeat_count = #{heartbeatCount}</if>
<if test="heartbeatInterval != null "> and heartbeat_interval = #{heartbeatInterval}</if>
<if test="onboardTime != null "> and onboard_time = #{onboardTime}</if>
<!-- 新增 phone 和 owner 的查询条件 -->
<if test="phone != null and phone != ''"> and phone = #{phone}</if>
<if test="owner != null and owner != ''"> and owner like concat('%', #{owner}, '%')</if>
</where>
order by create_time desc
</select>
@@ -80,6 +86,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
a.outbound_rate as outboundRate,
a.switch_client_id as switchClientId,
a.switch_name as switchName,
a.phone as phone,
a.owner as owner,
b.machine_code as machineCode,
(select bandwidth_result from eps_node_bandwidth
where client_id=a.client_id and calculation_mode='1000' and bandwidth_type=1
@@ -111,6 +119,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
a.outbound_rate as outboundRate,
a.switch_client_id as switchClientId,
a.switch_name as switchName,
a.phone as phone,
a.owner as owner,
b.machine_code as machineCode,
(select bandwidth_result from eps_node_bandwidth
where client_id=a.client_id and calculation_mode='1000' and bandwidth_type=1
@@ -118,7 +128,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
from rm_resource_registration a
left join rm_registration_machine b on a.client_id = b.client_id
where a.client_id = #{clientId}
limit 1
limit 1
</select>
<insert id="insertRmResourceRegistration" parameterType="RmResourceRegistration" useGeneratedKeys="true" keyProperty="id">
@@ -146,6 +156,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="outboundRate != null">outbound_rate,</if>
<if test="switchClientId != null">switch_client_id,</if>
<if test="switchName != null">switch_name,</if>
<!-- 新增的 phone 和 owner 字段 -->
<if test="phone != null">phone,</if>
<if test="owner != null">owner,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="clientId != null">#{clientId},</if>
@@ -170,6 +183,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="outboundRate != null">#{outboundRate},</if>
<if test="switchClientId != null">#{switchClientId},</if>
<if test="switchName != null">#{switchName},</if>
<!-- 新增的 phone 和 owner 字段 -->
<if test="phone != null">#{phone},</if>
<if test="owner != null">#{owner},</if>
</trim>
</insert>
@@ -198,6 +214,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="outboundRate != null">outbound_rate = #{outboundRate},</if>
<if test="switchClientId != null">switch_client_id = #{switchClientId},</if>
<if test="switchName != null">switch_name = #{switchName},</if>
<!-- 新增的 phone 和 owner 字段 -->
<if test="phone != null">phone = #{phone},</if>
<if test="owner != null">owner = #{owner},</if>
</trim>
where id = #{id}
</update>
@@ -212,10 +231,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id}
</foreach>
</delete>
<select id="countBySn" parameterType="String">
select count(1) from rm_resource_registration
where hardware_sn = #{hardwareSn}
</select>
<update id="updateStatusByResource" parameterType="RmResourceRegistration">
update rm_resource_registration
<trim prefix="SET" suffixOverrides=",">
@@ -240,6 +261,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="outboundRate != null">outbound_rate = #{outboundRate},</if>
<if test="switchClientId != null">switch_client_id = #{switchClientId},</if>
<if test="switchName != null">switch_name = #{switchName},</if>
<if test="phone != null">phone = #{phone},</if>
<if test="owner != null">owner = #{owner},</if>
</trim>
<where>
<choose>
@@ -255,6 +278,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</choose>
</where>
</update>
<update id="bindSwitchMsg" parameterType="RmResourceRegistration">
update rm_resource_registration
<trim prefix="SET" suffixOverrides=",">
switch_client_id = #{switchClientId},
switch_name = #{switchName},
</trim>
<where>
and client_id = #{clientId}
</where>
</update>
<update id="bindOwnerMsg" parameterType="RmResourceRegistration">
update rm_resource_registration
<trim prefix="SET" suffixOverrides=",">
phone = #{phone},
owner = #{owner},
</trim>
<where>
and client_id = #{clientId}
</where>
</update>
<select id="getRegistrationByIds" parameterType="String" resultMap="RmResourceRegistrationResult">
<include refid="selectRmResourceRegistrationVo"/>
where id in
@@ -270,10 +313,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
order by create_time desc
</select>
<select id="getAllLogicalNodeId" parameterType="RmResourceRegistration" resultType="java.util.Map">
select logical_node_id logicalNodeId from rm_resource_registration where logical_node_id != ''
group by logical_node_id
</select>
<select id="getRegistrationTableInfoList" parameterType="RmResourceRegistration" resultType="RmResourceRegistration">
select
a.id,
@@ -296,19 +341,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
a.outbound_rate as outboundRate,
a.switch_client_id as switchClientId,
a.switch_name as switchName,
a.phone as phone,
a.owner as owner,
b.machine_code as machineCode,
c.frpc_connection_status frpcConnectionStatus,
c.frpc_remote_port frpcRemotePort,
c.frpc_server_addr frpcServerAddr,
(select bandwidth_result from eps_node_bandwidth
where client_id=a.client_id and calculation_mode='1000' and bandwidth_type='1'
AND create_time = DATE(DATE_SUB(NOW(), INTERVAL 1 DAY)) limit 1) as bandwidthResult
where client_id=a.client_id and calculation_mode='1000' and bandwidth_type='1'
AND create_time = DATE(DATE_SUB(NOW(), INTERVAL 1 DAY)) limit 1) as bandwidthResult
from rm_resource_registration a
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>
<if test="delFlag != null"> and a.del_flag = #{delFlag}</if>
<if test="switchClientId != null and switchClientId != ''"> and switch_client_id = #{switchClientId}</if>
<if test="switchClientId != null and switchClientId != ''"> and a.switch_client_id = #{switchClientId}</if>
<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>
@@ -318,6 +365,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="businessName != null and businessName != ''"> and a.business_name like concat('%', #{businessName}, '%')</if>
<if test="logicalNodeId != null and logicalNodeId != ''"> and a.logical_node_id = #{logicalNodeId}</if>
<if test="multiPublicIpStatus != null and multiPublicIpStatus != ''"> and a.multi_public_ip_status = #{multiPublicIpStatus}</if>
<if test="phone != null and phone != ''"> and a.phone = #{phone}</if>
<if test="owner != null and owner != ''"> and a.owner like concat('%', #{owner}, '%')</if>
<if test="businessEmpty"> and a.business_name is null</if>
<if test="logicalNodeEmpty"> and a.logical_node_id is null</if>
<if test="clientIds != null">
@@ -329,6 +378,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
order by a.create_time desc
</select>
<update id="updateRemark" parameterType="RmResourceRegistration">
update rm_resource_registration set remark = #{remark}
where client_id in
@@ -336,6 +386,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{clientId}
</foreach>
</update>
<update id="addRemark" parameterType="RmResourceRegistration">
update rm_resource_registration set remark =
CASE
@@ -347,14 +398,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{clientId}
</foreach>
</update>
<update id="addReportedBandwidth" parameterType="RmResourceRegistration">
update rm_resource_registration set reported_bandwidth = #{reportedBandwidth}
where id =#{id}
</update>
<select id="countChildNetwork" resultType="java.lang.Integer">
select count(1) from rm_network_interface_child
where client_id = #{clientId} and parent_interface = #{interfaceName}
</select>
<select id="getCpuUtil" resultType="RmResourceRegistration">
SELECT
d.client_id as clientId,
@@ -374,6 +428,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
) latest ON d.client_id = latest.client_id
AND d.create_time = latest.latest_time
</select>
<select id="getMemUtil" resultType="RmResourceRegistration">
SELECT
d.client_id as clientId,
@@ -394,22 +449,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND d.create_time = latest.max_time
AND d.collect_type='memoryUtilizationCollect'
</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
CAST(SUBSTRING_INDEX(agent_version, '.', 1) AS UNSIGNED) DESC,
CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(agent_version, '.', 2), '.', -1) AS UNSIGNED) DESC,
CAST(SUBSTRING_INDEX(agent_version, '.', -1) AS UNSIGNED) DESC
limit 1
limit 1
</select>
</mapper>
@@ -2,6 +2,7 @@ package com.tongran.rocketmq.utils;
import com.tongran.common.core.constant.SecurityConstants;
import com.tongran.common.core.domain.R;
import com.tongran.common.core.utils.StringUtils;
import com.tongran.rocketmq.domain.RmAlarmLog;
import com.tongran.rocketmq.domain.RmAlarmPushConfig;
import com.tongran.rocketmq.enums.AlarmTypeEnum;
@@ -44,6 +45,7 @@ public class SendAlarmPushUtil {
RmAlarmLog updateData = new RmAlarmLog();
updateData.setId(rmAlarmLog.getId());
if (alarmConfigList != null && !alarmConfigList.isEmpty()) {
String phone = "";
try {
if(!AlarmTypeEnum.ping丢包率过高.getCode().equals(rmAlarmLog.getAlarmType())){
// 查询服务器信息
@@ -55,6 +57,7 @@ public class SendAlarmPushUtil {
rmAlarmLog.setMgmPublicIp(serverMsg.getIp1PublicIp());
rmAlarmLog.setBusinessName(serverMsg.getBusinessName());
rmAlarmLog.setRemark(serverMsg.getRemark());
phone = serverMsg.getPhone();
}
}
Map<String, Object> alarmMap = new HashMap<>();
@@ -66,6 +69,9 @@ public class SendAlarmPushUtil {
alarmMap.put("标签", rmAlarmLog.getRemark());
alarmMap.put("业务名称", rmAlarmLog.getBusinessName());
for (RmAlarmPushConfig alarmPushConfig : alarmConfigList) {
if(StringUtils.isNoneBlank(phone)){
alarmPushConfig.setContactPhones(phone);
}
if(PushMethodEnum.企业微信.getCode().equals(alarmPushConfig.getPushMethod())){
updateData.setPushFlag(processWeComPush(alarmPushConfig, alarmMap));
}else if(PushMethodEnum.手机短信.getCode().equals(alarmPushConfig.getPushMethod())){