服务器管理添加标签功能。

优化mtr探测结果存储。
This commit is contained in:
gaoyutao
2025-11-25 18:18:51 +08:00
parent a0b0b57110
commit afbf1eead0
24 changed files with 265 additions and 548 deletions
@@ -13,9 +13,8 @@ spring:
cloud:
nacos:
discovery:
server-addr: 172.16.15.52:8848
# 服务注册地址
# server-addr: 172.16.15.103:8848
server-addr: ${spring.cloud.nacos.config.server-addr}
namespace: ${spring.cloud.nacos.config.namespace}
username: ${spring.cloud.nacos.config.username}
password: ${spring.cloud.nacos.config.password}
@@ -23,8 +22,8 @@ spring:
# 配置中心地址
server-addr: 172.16.15.52:8848
# server-addr: 172.16.15.103:8848
namespace: public
# namespace: saas-local
# namespace: public
namespace: saas-local
username: nacos
password: nacos
# 配置文件格式
@@ -13,9 +13,8 @@ spring:
cloud:
nacos:
discovery:
server-addr: 172.16.15.52:8848
# 服务注册地址
# server-addr: 172.16.15.103:8848
server-addr: ${spring.cloud.nacos.config.server-addr}
namespace: ${spring.cloud.nacos.config.namespace}
username: ${spring.cloud.nacos.config.username}
password: ${spring.cloud.nacos.config.password}
@@ -23,8 +22,8 @@ spring:
# 配置中心地址
server-addr: 172.16.15.52:8848
# server-addr: 172.16.15.103:8848
namespace: public
# namespace: saas-local
# namespace: public
namespace: saas-local
username: nacos
password: nacos
# 配置文件格式
@@ -14,17 +14,16 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 172.16.15.52:8848
# server-addr: 172.16.15.103:8848
server-addr: ${spring.cloud.nacos.config.server-addr}
namespace: ${spring.cloud.nacos.config.namespace}
username: ${spring.cloud.nacos.config.username}
password: ${spring.cloud.nacos.config.password}
config:
# 配置中心地址
server-addr: 172.16.15.52:8848
# server-addr: 172.16.15.103:8848
namespace: public
# namespace: saas-local
# server-addr: 172.16.15.52:8848
server-addr: 172.16.15.103:8848
# namespace: public
namespace: saas-prod
username: nacos
password: nacos
# 配置文件格式
@@ -114,13 +114,13 @@ public class RmMtrClientRegistrationController extends BaseController
return success(list);
}
/**
* 查询MTR客户端注册列表
* 查询所有标识
*/
@RequiresPermissions("mtragent:mtrClientRegistration:list")
@PostMapping("/getAllLogicalNode")
public AjaxResult getAllLogicalNode(@RequestBody RmMtrClientRegistration rmMtrClientRegistration)
@GetMapping("/getAllLogicalNode")
public AjaxResult getAllLogicalNode()
{
List<RmMtrClientRegistration> list = rmMtrClientRegistrationService.getAllLogicalNode(rmMtrClientRegistration);
List<RmMtrClientRegistration> list = rmMtrClientRegistrationService.getAllLogicalNode();
return success(list);
}
/**
@@ -1,9 +1,8 @@
package com.tongran.mtragent.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.tongran.common.core.annotation.Excel;
import com.tongran.common.core.web.domain.BaseEntity;
import lombok.Data;
/**
* mtr探测丢包clinetId记录对象 all_mtr_client
@@ -11,6 +10,7 @@ import com.tongran.common.core.web.domain.BaseEntity;
* @author gyt
* @date 2025-11-24
*/
@Data
public class AllMtrClient extends BaseEntity
{
private static final long serialVersionUID = 1L;
@@ -29,58 +29,7 @@ public class AllMtrClient extends BaseEntity
/** 公网IP地址 */
@Excel(name = "公网IP地址")
private String publicIp;
/** 失败标志 0成功 1失败 */
private Integer failFlag;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setMtrClientId(String mtrClientId)
{
this.mtrClientId = mtrClientId;
}
public String getMtrClientId()
{
return mtrClientId;
}
public void setClientId(String clientId)
{
this.clientId = clientId;
}
public String getClientId()
{
return clientId;
}
public void setPublicIp(String publicIp)
{
this.publicIp = publicIp;
}
public String getPublicIp()
{
return publicIp;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("mtrClientId", getMtrClientId())
.append("clientId", getClientId())
.append("publicIp", getPublicIp())
.append("createTime", getCreateTime())
.append("updateTime", getUpdateTime())
.append("createBy", getCreateBy())
.append("updateBy", getUpdateBy())
.toString();
}
}
@@ -89,4 +89,6 @@ public class RmMtrClientRegistration extends BaseEntity
private String networkInfo;
/** 部署设备 */
private String mtrClientIds;
/** 多条件 */
private String queryName;
}
@@ -93,7 +93,6 @@ public class MessageHandler {
List<RmMtrProbeResult> rmMtrProbeResultList = new ArrayList<>();
List<AllMtrClient> allMtrClientList = new ArrayList<>();
for (MtrResultVo mtrResultVo : mtrResultVoList) {
if(mtrResultVo.getFinalLossPercent() != -1.0){
// 时间戳转换
long timestamp = mtrResultVo.getTimestamp();
long millis = timestamp * 1000;
@@ -107,13 +106,19 @@ public class MessageHandler {
rmMtrProbeResultList.add(rmMtrProbeResult);
AllMtrClient allMtrClient = new AllMtrClient();
BeanUtils.copyProperties(rmMtrProbeResult, allMtrClient);
allMtrClientList.add(allMtrClient);
if(mtrResultVo.getFinalLossPercent() == -1.0){
allMtrClient.setFailFlag(1);
}else{
log.debug("探测失败,失败原因:{}", mtrResultVo.getErrorMsg());
allMtrClient.setFailFlag(0);
}
allMtrClientList.add(allMtrClient);
}
RmMtrProbeResult insertData = new RmMtrProbeResult();
insertData.setList(rmMtrProbeResultList);
if(rmMtrProbeResultList.isEmpty()){
log.warn("探测失败,原因可能为mtr命令没安装");
return;
}
// 结果批量入库
rmMtrProbeResultService.batchInsertRmMtrProbeResult(insertData);
// 记录下发策略的clientId
@@ -70,10 +70,9 @@ public interface IRmMtrClientRegistrationService
/**
* 获取所有标识
* @param rmMtrClientRegistration
* @return
*/
List<RmMtrClientRegistration> getAllLogicalNode(RmMtrClientRegistration rmMtrClientRegistration);
List<RmMtrClientRegistration> getAllLogicalNode();
/**
* 根据mtrClientId查询包含的clientId
* @param rmMtrClientRegistration
@@ -215,8 +215,8 @@ public class RmMtrClientRegistrationServiceImpl implements IRmMtrClientRegistrat
}
@Override
public List<RmMtrClientRegistration> getAllLogicalNode(RmMtrClientRegistration rmMtrClientRegistration) {
List<RmMtrClientRegistration> list = rmMtrClientRegistrationMapper.getAllLogicalNode(rmMtrClientRegistration);
public List<RmMtrClientRegistration> getAllLogicalNode() {
List<RmMtrClientRegistration> list = rmMtrClientRegistrationMapper.getAllLogicalNode(new RmMtrClientRegistration());
return list;
}
@@ -23,8 +23,8 @@ spring:
# 配置中心地址
server-addr: 172.16.15.52:8848
# server-addr: 172.16.15.103:8848
namespace: public
# namespace: saas-local
# namespace: public
namespace: saas-local
username: nacos
password: nacos
# 配置文件格式
@@ -9,6 +9,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="mtrClientId" column="mtr_client_id" />
<result property="clientId" column="client_id" />
<result property="publicIp" column="public_ip" />
<result property="failFlag" column="fail_flag" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="createBy" column="create_by" />
@@ -16,7 +17,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectAllMtrClientVo">
select id, mtr_client_id, client_id, public_ip, create_time, update_time, create_by, update_by from all_mtr_client
select id, mtr_client_id, client_id, public_ip, fail_flag, create_time, update_time, create_by, update_by from all_mtr_client
</sql>
<select id="selectAllMtrClientList" parameterType="AllMtrClient" resultMap="AllMtrClientResult">
@@ -25,6 +26,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="mtrClientId != null and mtrClientId != ''"> and mtr_client_id = #{mtrClientId}</if>
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
<if test="publicIp != null and publicIp != ''"> and public_ip = #{publicIp}</if>
<if test="failFlag != null "> and fail_flag = #{failFlag}</if>
</where>
</select>
@@ -39,6 +41,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="mtrClientId != null and mtrClientId != ''">mtr_client_id,</if>
<if test="clientId != null and clientId != ''">client_id,</if>
<if test="publicIp != null and publicIp != ''">public_ip,</if>
<if test="failFlag != null">fail_flag,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="createBy != null">create_by,</if>
@@ -48,6 +51,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="mtrClientId != null and mtrClientId != ''">#{mtrClientId},</if>
<if test="clientId != null and clientId != ''">#{clientId},</if>
<if test="publicIp != null and publicIp != ''">#{publicIp},</if>
<if test="failFlag != null">#{failFlag},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="createBy != null">#{createBy},</if>
@@ -61,6 +65,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="mtrClientId != null and mtrClientId != ''">mtr_client_id = #{mtrClientId},</if>
<if test="clientId != null and clientId != ''">client_id = #{clientId},</if>
<if test="publicIp != null and publicIp != ''">public_ip = #{publicIp},</if>
<if test="failFlag != null">fail_flag = #{failFlag},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
@@ -81,12 +86,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<insert id="batchInsertAllMtrClient" parameterType="java.util.List">
insert into all_mtr_client
(mtr_client_id, client_id, public_ip, create_by, update_by)
(mtr_client_id, client_id, public_ip, fail_flag, create_by, update_by)
values
<foreach collection="list" item="item" separator=",">
(#{item.mtrClientId}, #{item.clientId}, #{item.publicIp}, #{item.createBy}, #{item.updateBy})
(#{item.mtrClientId}, #{item.clientId}, #{item.publicIp}, #{item.failFlag}, #{item.createBy}, #{item.updateBy})
</foreach>
ON DUPLICATE KEY UPDATE
public_ip = IF(VALUES(public_ip) != public_ip, VALUES(public_ip), public_ip)
public_ip = IF(NOT VALUES(public_ip) &lt;=&gt; public_ip, VALUES(public_ip), public_ip),
fail_flag = IF(NOT VALUES(fail_flag) &lt;=&gt; fail_flag, VALUES(fail_flag), fail_flag)
</insert>
</mapper>
@@ -51,6 +51,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="lastUpdateResult != null and lastUpdateResult != ''"> and last_update_result = #{lastUpdateResult}</if>
<if test="lastUpdateTime != null "> and last_update_time = #{lastUpdateTime}</if>
<if test="networkInfo != null and networkInfo != ''"> and network_info = #{networkInfo}</if>
<!-- 新增:多条件查询,queryName可能是mtr_client_id或关联表的client_id -->
<if test="queryName != null and queryName != ''">
and (
mtr_client_id like concat('%',#{queryName},'%')
or mtr_client_id in (
select distinct mtr_client_id from all_mtr_client
where client_id like concat('%',#{queryName},'%')
)
)
</if>
</where>
order by create_time desc
</select>
@@ -85,7 +85,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</delete>
<insert id="batchInsertRmMtrProbeResult" parameterType="RmMtrProbeResult">
INSERT INTO ${tableName}
INSERT IGNORE INTO ${tableName}
(
mtr_client_id,
client_id,
@@ -8,7 +8,6 @@ import com.tongran.common.core.web.page.PageDomain;
import com.tongran.common.core.web.page.TableDataInfo;
import com.tongran.common.log.annotation.Log;
import com.tongran.common.log.enums.BusinessType;
import com.tongran.common.security.annotation.InnerAuth;
import com.tongran.common.security.annotation.RequiresPermissions;
import com.tongran.system.domain.EpsServerRevenueConfig;
import com.tongran.system.service.IEpsServerRevenueConfigService;
@@ -75,7 +74,7 @@ public class EpsServerRevenueConfigController extends BaseController
/**
* 流量相关数据入库
*/
@InnerAuth
// @InnerAuth
@PostMapping("/autoSaveServiceTrafficData")
public R<String> autoSaveServiceTrafficData(@RequestBody EpsServerRevenueConfig epsServerRevenueConfig)
{
@@ -108,28 +108,6 @@ public class RmResourceRegistrationController extends BaseController
return toAjax(rmResourceRegistrationService.register(rmResourceRegistration));
}
/**
* 查询所有资源名称(包含设备使用)
* @return 资源注册集合
*/
@RequiresPermissions("system:group:list")
@GetMapping("/selectAllResourceName")
public List<Map> selectAllResourceName()
{
List<Map> list = rmResourceRegistrationService.selectAllResourceName();
return list;
}
/**
* 查询所有资源名称
* @return 资源注册集合
*/
@RequiresPermissions("system:group:list")
@PostMapping("/selectAllResourceNameByType")
public List<Map> selectAllResourceNameByType(@RequestBody RmResourceRegistration rmResourceRegistration)
{
List<Map> list = rmResourceRegistrationService.selectAllResourceNameByType(rmResourceRegistration);
return list;
}
/**
* 检测到服务器离线,修改状态为离线
@@ -249,5 +227,25 @@ public class RmResourceRegistrationController extends BaseController
}
return success(list);
}
/**
* 添加标签
*/
@RequiresPermissions("system:registration:edit")
@Log(title = "添加服务器标签", businessType = BusinessType.UPDATE)
@PostMapping("/addRemark")
public AjaxResult addRemark(@RequestBody RmResourceRegistration rmResourceRegistration)
{
return toAjax(rmResourceRegistrationService.addRemark(rmResourceRegistration));
}
/**
* 添加标签
*/
@RequiresPermissions("system:registration:edit")
@Log(title = "添加服务器标签", businessType = BusinessType.UPDATE)
@PostMapping("/updateRemark")
public AjaxResult updateRemark(@RequestBody RmResourceRegistration rmResourceRegistration)
{
return toAjax(rmResourceRegistrationService.updateRemark(rmResourceRegistration));
}
}
@@ -1,15 +1,7 @@
package com.tongran.system.controller;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.tongran.common.core.constant.CacheConstants;
import com.tongran.common.core.utils.StringUtils;
import com.tongran.common.core.web.controller.BaseController;
@@ -22,6 +14,13 @@ import com.tongran.common.security.annotation.RequiresPermissions;
import com.tongran.system.api.model.LoginUser;
import com.tongran.system.domain.SysUserOnline;
import com.tongran.system.service.ISysUserOnlineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
/**
* 在线用户监控
@@ -46,7 +45,12 @@ public class SysUserOnlineController extends BaseController
List<SysUserOnline> userOnlineList = new ArrayList<SysUserOnline>();
for (String key : keys)
{
LoginUser user = redisService.getCacheObject(key);
// 修复:安全地获取LoginUser对象
LoginUser user = getLoginUserFromCache(key);
if (user == null) {
continue; // 跳过无效的用户数据
}
if (StringUtils.isNotEmpty(ipaddr) && StringUtils.isNotEmpty(userName))
{
userOnlineList.add(userOnlineService.selectOnlineByInfo(ipaddr, userName, user));
@@ -69,6 +73,36 @@ public class SysUserOnlineController extends BaseController
return getDataTable(userOnlineList);
}
/**
* 安全地从缓存中获取LoginUser对象
*/
private LoginUser getLoginUserFromCache(String key) {
try {
Object userObj = redisService.getCacheObject(key);
if (userObj == null) {
return null;
}
// 类型安全转换
if (userObj instanceof LoginUser) {
return (LoginUser) userObj;
}
// 处理JSONObject情况
else if (userObj instanceof JSONObject) {
return ((JSONObject) userObj).toJavaObject(LoginUser.class);
}
// 处理JSON字符串情况
else if (userObj instanceof String) {
return JSON.parseObject((String) userObj, LoginUser.class);
}
return null;
} catch (Exception e) {
return null;
}
}
/**
* 强退用户
*/
@@ -34,89 +34,19 @@ public class RmResourceRegistration extends BaseEntity
/** 资源类型
* 1 服务器,2 交换机*/
private String resourceType;
/** 资源名称 */
private String resourceName;
/** IP地址 */
private String ipAddress;
/** 端口1.162(SNMP),2.其他 */
private String resourcePort;
/**其他端口名称 */
private String otherPortName;
/** agent版本 */
@Excel(name = "agent版本")
private String agentVersion;
/** 协议 1.TCP,2.UDP */
private String protocol;
/** SNMP探测 0=否,1=是 */
private String snmpDetect;
/** 版本(1.SNMPv2,2.SNMPv3) */
private String resourceVersion;
/** 读写权限(1.RW,2.ReadOnly) */
private String rwPermission;
/** 团体名称 */
private String teamName;
/** SNMP采集地址 */
private String snmpCollectAddr;
/** SNMP采集端口 */
private String snmpCollectPort;
/** 安全级别(1.authPriv、2.authNoPriv3.noAuthNoPriv) */
private String securityLevel;
/** 加密方式 1.md5,2.SHA */
private String encryption;
/** 用户名 */
private String resourceUserName;
/** 密码 */
private String resourcePwd;
/** 注册状态 0-未注册,1-已注册 */
private String registrationStatus;
/** 在线状态 0-离线,1-在线 */
@Excel(name = "在线状态", readConverterExp = "0=离线,1=在线")
private String onlineStatus;
private String switchOnlineStatus;
/** 描述 */
private String description;
/** 设备业务客户id */
private Long customerId;
/** 设备业务客户名称 */
private String customerName;
/** 业务号 */
private String serviceNumber;
/** 创建人id */
private Long creatorId;
/** 创建人名称 */
private String creatorName;
/** 修改人id */
private Long updaterId;
/** 修改人名称 */
private String updaterName;
/** 监控项 */
private String monitorItems;
@@ -126,20 +56,6 @@ public class RmResourceRegistration extends BaseEntity
/** 查询名称 */
private String queryName;
/**
* 运营商
*/
private String operator;
/**
* 省
*/
private String province;
/**
* 公网IP
*/
private String publicIp;
/**
* 业务名称
@@ -61,22 +61,12 @@ public interface RmResourceRegistrationMapper
*/
public int deleteRmResourceRegistrationByIds(Long[] ids);
/**
* 查询所有资源名称([包含设备]功能使用)
* @return 资源注册集合
*/
public List<Map> selectAllResourceName();
/**
* 查询是否有此设备
* @param hardwareSn 资源sn
* @return 结果
*/
public int countBySn(String hardwareSn);
/**
* 查询所有资源名称
* @return 资源注册集合
*/
public List<Map> selectAllResourceNameByType(RmResourceRegistration resourceRegistration);
/**
* 检测到服务器离线,修改状态为离线
@@ -106,4 +96,18 @@ public interface RmResourceRegistrationMapper
* @return
*/
List<RmResourceRegistration> getRegistrationTableInfoList(RmResourceRegistration rmResourceRegistration);
/**
* 添加服务器标签
* @param rmResourceRegistration
* @return
*/
int addRemark(RmResourceRegistration rmResourceRegistration);
/**
* 修改服务器标签
* @param rmResourceRegistration
* @return
*/
int updateRemark(RmResourceRegistration rmResourceRegistration);
}
@@ -74,16 +74,6 @@ public interface IRmResourceRegistrationService
*/
public int deleteRmResourceRegistrationById(Long id);
/**
* 查询所有资源名称(包含设备使用)
* @return 资源注册集合
*/
public List<Map> selectAllResourceName();
/**
* 查询所有资源名称
* @return 资源注册集合
*/
public List<Map> selectAllResourceNameByType(RmResourceRegistration resourceRegistration);
/**
* 检测到服务器离线,修改状态为离线
* @param rmResourceRegistration
@@ -128,4 +118,18 @@ public interface IRmResourceRegistrationService
* @return
*/
int bindBusinessByClientIds(RmResourceRegistration rmResourceRegistration);
/**
* 添加标签
* @param rmResourceRegistration
* @return
*/
int addRemark(RmResourceRegistration rmResourceRegistration);
/**
* 修改标签
* @param rmResourceRegistration
* @return
*/
int updateRemark(RmResourceRegistration rmResourceRegistration);
}
@@ -3,7 +3,6 @@ package com.tongran.system.service.impl;
import com.github.pagehelper.PageInfo;
import com.tongran.common.core.domain.R;
import com.tongran.common.core.utils.*;
import com.tongran.common.core.web.page.PageDomain;
import com.tongran.system.domain.*;
import com.tongran.system.enums.ReviewEnum;
import com.tongran.system.mapper.*;
@@ -27,8 +26,6 @@ import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import static com.tongran.common.core.utils.PageUtils.startPage;
/**
* 交换机监控信息Service业务层处理
*
@@ -1063,10 +1060,6 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
// 查询流量信息
initialSwitchInfoDetails.setClientIds(clientIds);
initialSwitchInfoDetails.setInterfaceNames(interfaceNames);
PageDomain pageDomain = new PageDomain();
pageDomain.setPageNum(initialSwitchInfoDetails.getPageNum());
pageDomain.setPageSize(initialSwitchInfoDetails.getPageSize());
startPage(pageDomain);
List<InitialSwitchInfoDetails> list = getSwitchTrafficDetailsMsgSharding(initialSwitchInfoDetails);
PageInfo pageInfo = PaginationUtil.paginate(list, initialSwitchInfoDetails.getPageNum(), initialSwitchInfoDetails.getPageSize());
return pageInfo;
@@ -306,8 +306,7 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
@Override
public int insertRmResourceRegistration(RmResourceRegistration rmResourceRegistration)
{
rmResourceRegistration.setCreatorId(SecurityUtils.getUserId());
rmResourceRegistration.setCreatorName(SecurityUtils.getUsername());
rmResourceRegistration.setCreateBy(SecurityUtils.getUsername());
rmResourceRegistration.setCreateTime(DateUtils.getNowDate());
// 查询此硬件sn是否已存在
int exits = rmResourceRegistrationMapper.countBySn(rmResourceRegistration.getHardwareSn());
@@ -327,8 +326,7 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
public int updateRmResourceRegistration(RmResourceRegistration rmResourceRegistration)
{
rmResourceRegistration.setUpdateTime(DateUtils.getNowDate());
rmResourceRegistration.setUpdaterId(SecurityUtils.getUserId());
rmResourceRegistration.setUpdaterName(SecurityUtils.getUsername());
rmResourceRegistration.setUpdateBy(SecurityUtils.getUsername());
// 拿到需要修改的id
Long id = rmResourceRegistration.getId();
// 根据id查询sn信息
@@ -380,16 +378,12 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
if ("1".equals(rmResourceRegistration.getRegistrationStatus())){
// 拿到需要修改的资源名称
String resourceName = rmResourceRegistration.getResourceName();
// 拿到需要修改的描述
String description = rmResourceRegistration.getDescription();
// 初始化
rmResourceRegistration = new RmResourceRegistration();
// id赋值
rmResourceRegistration.setId(id);
// 可修改资源名称
rmResourceRegistration.setResourceName(resourceName);
// 可修改描述
rmResourceRegistration.setDescription(description);
}
return rmResourceRegistrationMapper.updateRmResourceRegistration(rmResourceRegistration);
@@ -405,8 +399,7 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
public int register(RmResourceRegistration rmResourceRegistration) {
// 设置更新信息
rmResourceRegistration.setUpdateTime(DateUtils.getNowDate());
rmResourceRegistration.setUpdaterId(SecurityUtils.getUserId());
rmResourceRegistration.setUpdaterName(SecurityUtils.getUsername());
rmResourceRegistration.setUpdateBy(SecurityUtils.getUsername());
// 处理服务器资源注册
if ("1".equals(rmResourceRegistration.getResourceType())) {
@@ -428,7 +421,6 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
config.setNodeName(registration.getResourceName());
config.setCreateTime(DateUtils.getNowDate());
config.setRegistrationStatus(registration.getRegistrationStatus());
config.setServerIp(registration.getIpAddress());
EpsServerRevenueConfig existing = epsServerRevenueConfigMapper.countBySn(config.getHardwareSn());
if (existing != null) {
@@ -459,18 +451,6 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
*/
private ResourceVo createResourceVo(RmResourceRegistration registration) {
ResourceVo resourceVo = new ResourceVo();
resourceVo.setClientIp(registration.getIpAddress());
resourceVo.setClientPort(Integer.valueOf(registration.getResourcePort()));
if (!"1".equals(registration.getResourceType())) {
if("1".equals(registration.getSnmpDetect())){
Map<String, String> switchMap = new HashMap<>();
switchMap.put("community", registration.getTeamName());
switchMap.put("ip", registration.getSnmpCollectAddr());
switchMap.put("port", registration.getSnmpCollectPort());
resourceVo.setSwitchBoard(JSONObject.toJSONString(switchMap));
}
}
return resourceVo;
}
@@ -506,16 +486,6 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
{
return rmResourceRegistrationMapper.deleteRmResourceRegistrationById(id);
}
@Override
public List<Map> selectAllResourceName()
{
return rmResourceRegistrationMapper.selectAllResourceName();
}
@Override
public List<Map> selectAllResourceNameByType(RmResourceRegistration resourceRegistration)
{
return rmResourceRegistrationMapper.selectAllResourceNameByType(resourceRegistration);
}
/**
* 检测到服务器离线,修改状态为离线
@@ -826,5 +796,17 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
return 1;
}
@Override
public int addRemark(RmResourceRegistration rmResourceRegistration) {
rmResourceRegistration.setDeployDevice(rmResourceRegistration.getDeployDevice().replace("\n",","));
int rows = rmResourceRegistrationMapper.addRemark(rmResourceRegistration);
return rows;
}
@Override
public int updateRemark(RmResourceRegistration rmResourceRegistration) {
rmResourceRegistration.setDeployDevice(rmResourceRegistration.getDeployDevice().replace("\n",","));
int rows = rmResourceRegistrationMapper.updateRemark(rmResourceRegistration);
return rows;
}
}
@@ -13,9 +13,7 @@ spring:
cloud:
nacos:
discovery:
server-addr: 172.16.15.52:8848
# 服务注册地址
# server-addr: 172.16.15.103:8848
server-addr: ${spring.cloud.nacos.config.server-addr}
namespace: ${spring.cloud.nacos.config.namespace}
username: ${spring.cloud.nacos.config.username}
password: ${spring.cloud.nacos.config.password}
@@ -24,8 +22,7 @@ spring:
# 配置中心地址
# server-addr: 172.16.15.103:8848
# namespace: public
namespace: public
# namespace: saas-local
namespace: saas-local
username: nacos
password: nacos
# 配置文件格式
@@ -6,99 +6,44 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="RmResourceRegistration" id="RmResourceRegistrationResult">
<result property="id" column="id" />
<result property="hardwareSn" column="hardware_sn" />
<result property="resourceType" column="resource_type" />
<result property="resourceName" column="resource_name" />
<result property="ipAddress" column="ip_address" />
<result property="resourcePort" column="resource_port" />
<result property="otherPortName" column="other_port_name" />
<result property="agentVersion" column="agent_version" />
<result property="protocol" column="protocol" />
<result property="resourceVersion" column="resource_version" />
<result property="rwPermission" column="rw_permission" />
<result property="snmpDetect" column="snmp_detect" />
<result property="teamName" column="team_name" />
<result property="snmpCollectAddr" column="snmp_collect_addr" />
<result property="snmpCollectPort" column="snmp_collect_port" />
<result property="securityLevel" column="security_level" />
<result property="encryption" column="encryption" />
<result property="resourceUserName" column="resource_user_name" />
<result property="resourcePwd" column="resource_pwd" />
<result property="registrationStatus" column="registration_status" />
<result property="onlineStatus" column="online_status" />
<result property="switchOnlineStatus" column="switch_online_status" />
<result property="description" column="description" />
<result property="customerId" column="customer_id" />
<result property="customerName" column="customer_name" />
<result property="serviceNumber" column="service_number" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="creatorId" column="creator_id" />
<result property="creatorName" column="creator_name" />
<result property="updaterId" column="updater_id" />
<result property="updaterName" column="updater_name" />
<result property="clientId" column="client_id" />
<result property="operator" column="operator" />
<result property="province" column="province" />
<result property="publicIp" column="public_ip" />
<result property="hardwareSn" column="hardware_sn" />
<result property="businessName" column="business_name" />
<result property="logicalNodeId" column="logical_node_id" />
<result property="multiPublicIpStatus" column="multi_public_ip_status" />
<result property="registrationStatus" column="registration_status" />
<result property="onlineStatus" column="online_status" />
<result property="resourceType" column="resource_type" />
<result property="agentVersion" column="agent_version" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="heartbeatCount" column="heartbeat_count" />
<result property="heartbeatInterval" column="heartbeat_interval" />
<result property="onboardTime" column="onboard_time" />
<result property="remark" column="remark" />
<result property="createBy" column="create_by" />
<result property="updateBy" column="update_by" />
</resultMap>
<sql id="selectRmResourceRegistrationVo">
select id, hardware_sn, resource_type, resource_name, ip_address, resource_port, other_port_name,
agent_version, protocol, resource_version, rw_permission, snmp_detect, team_name, snmp_collect_addr,
snmp_collect_port, security_level, encryption, resource_user_name, resource_pwd, registration_status,
online_status, switch_online_status, description, customer_id, customer_name, service_number,
create_time, update_time, creator_id, creator_name, updater_id, updater_name, client_id, operator,
province, public_ip, business_name, logical_node_id, multi_public_ip_status, heartbeat_count,
heartbeat_interval, onboard_time 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 from rm_resource_registration
</sql>
<select id="selectRmResourceRegistrationList" parameterType="RmResourceRegistration" resultMap="RmResourceRegistrationResult">
<include refid="selectRmResourceRegistrationVo"/>
<where>
<if test="hardwareSn != null and hardwareSn != ''"> and hardware_sn = #{hardwareSn}</if>
<if test="resourceType != null and resourceType != ''"> and resource_type = #{resourceType}</if>
<if test="resourceName != null and resourceName != ''"> and resource_name like concat('%', #{resourceName}, '%')</if>
<if test="ipAddress != null and ipAddress != ''"> and ip_address = #{ipAddress}</if>
<if test="resourcePort != null and resourcePort != ''"> and resource_port = #{resourcePort}</if>
<if test="otherPortName != null and otherPortName != ''"> and other_port_name like concat('%', #{otherPortName}, '%')</if>
<if test="agentVersion != null and agentVersion != ''"> and agent_version = #{agentVersion}</if>
<if test="protocol != null and protocol != ''"> and protocol = #{protocol}</if>
<if test="resourceVersion != null and resourceVersion != ''"> and resource_version = #{resourceVersion}</if>
<if test="rwPermission != null and rwPermission != ''"> and rw_permission = #{rwPermission}</if>
<if test="snmpDetect != null and snmpDetect != ''"> and snmp_detect = #{snmpDetect}</if>
<if test="teamName != null and teamName != ''"> and team_name like concat('%', #{teamName}, '%')</if>
<if test="snmpCollectAddr != null and snmpCollectAddr != ''"> and snmp_collect_addr = #{snmpCollectAddr}</if>
<if test="snmpCollectPort != null "> and snmp_collect_port = #{snmpCollectPort}</if>
<if test="securityLevel != null and securityLevel != ''"> and security_level = #{securityLevel}</if>
<if test="encryption != null and encryption != ''"> and encryption = #{encryption}</if>
<if test="resourceUserName != null and resourceUserName != ''"> and resource_user_name like concat('%', #{resourceUserName}, '%')</if>
<if test="resourcePwd != null and resourcePwd != ''"> and resource_pwd = #{resourcePwd}</if>
<if test="registrationStatus != null and registrationStatus != ''"> and registration_status = #{registrationStatus}</if>
<if test="onlineStatus != null and onlineStatus != ''"> and online_status = #{onlineStatus}</if>
<if test="switchOnlineStatus != null and switchOnlineStatus != ''"> and switch_online_status = #{switchOnlineStatus}</if>
<if test="description != null and description != ''"> and description = #{description}</if>
<if test="customerId != null "> and customer_id = #{customerId}</if>
<if test="customerName != null and customerName != ''"> and customer_name like concat('%', #{customerName}, '%')</if>
<if test="serviceNumber != null and serviceNumber != ''"> and service_number = #{serviceNumber}</if>
<if test="creatorId != null "> and creator_id = #{creatorId}</if>
<if test="creatorName != null and creatorName != ''"> and creator_name like concat('%', #{creatorName}, '%')</if>
<if test="updaterId != null "> and updater_id = #{updaterId}</if>
<if test="updaterName != null and updaterName != ''"> and updater_name like concat('%', #{updaterName}, '%')</if>
<if test="queryName != null and queryName != ''"> and (hardware_sn = #{queryName} or resource_name like concat('%', #{queryName}, '%')) </if>
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
<if test="operator != null and operator != ''"> and operator = #{operator}</if>
<if test="province != null and province != ''"> and province = #{province}</if>
<if test="publicIp != null and publicIp != ''"> and public_ip = #{publicIp}</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>
<if test="logicalNodeId != null and logicalNodeId != ''"> and logical_node_id = #{logicalNodeId}</if>
<if test="multiPublicIpStatus != null and multiPublicIpStatus != ''"> and multi_public_ip_status = #{multiPublicIpStatus}</if>
<if test="registrationStatus != null and registrationStatus != ''"> and registration_status = #{registrationStatus}</if>
<if test="onlineStatus != null and onlineStatus != ''"> and online_status = #{onlineStatus}</if>
<if test="resourceType != null and resourceType != ''"> and resource_type = #{resourceType}</if>
<if test="agentVersion != null and agentVersion != ''"> and agent_version = #{agentVersion}</if>
<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>
</where>
order by create_time desc
</select>
@@ -111,137 +56,65 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertRmResourceRegistration" parameterType="RmResourceRegistration" useGeneratedKeys="true" keyProperty="id">
insert into rm_resource_registration
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="hardwareSn != null">hardware_sn,</if>
<if test="resourceType != null">resource_type,</if>
<if test="resourceName != null">resource_name,</if>
<if test="ipAddress != null">ip_address,</if>
<if test="resourcePort != null">resource_port,</if>
<if test="otherPortName != null">other_port_name,</if>
<if test="agentVersion != null">agent_version,</if>
<if test="protocol != null">protocol,</if>
<if test="resourceVersion != null">resource_version,</if>
<if test="rwPermission != null">rw_permission,</if>
<if test="snmpDetect != null">snmp_detect,</if>
<if test="teamName != null">team_name,</if>
<if test="snmpCollectAddr != null">snmp_collect_addr,</if>
<if test="snmpCollectPort != null">snmp_collect_port,</if>
<if test="securityLevel != null">security_level,</if>
<if test="encryption != null">encryption,</if>
<if test="resourceUserName != null">resource_user_name,</if>
<if test="resourcePwd != null">resource_pwd,</if>
<if test="registrationStatus != null">registration_status,</if>
<if test="onlineStatus != null">online_status,</if>
<if test="switchOnlineStatus != null">switch_online_status,</if>
<if test="description != null">description,</if>
<if test="customerId != null">customer_id,</if>
<if test="customerName != null">customer_name,</if>
<if test="serviceNumber != null">service_number,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="creatorId != null">creator_id,</if>
<if test="creatorName != null">creator_name,</if>
<if test="updaterId != null">updater_id,</if>
<if test="updaterName != null">updater_name,</if>
<if test="clientId != null">client_id,</if>
<if test="operator != null">operator,</if>
<if test="province != null">province,</if>
<if test="publicIp != null">public_ip,</if>
<if test="hardwareSn != null">hardware_sn,</if>
<if test="businessName != null">business_name,</if>
<if test="logicalNodeId != null">logical_node_id,</if>
<if test="multiPublicIpStatus != null">multi_public_ip_status,</if>
<if test="registrationStatus != null">registration_status,</if>
<if test="onlineStatus != null">online_status,</if>
<if test="resourceType != null">resource_type,</if>
<if test="agentVersion != null">agent_version,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="heartbeatCount != null">heartbeat_count,</if>
<if test="heartbeatInterval != null">heartbeat_interval,</if>
<if test="onboardTime != null">onboard_time,</if>
<if test="remark != null">remark,</if>
<if test="createBy != null">create_by,</if>
<if test="updateBy != null">update_by,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="hardwareSn != null">#{hardwareSn},</if>
<if test="resourceType != null">#{resourceType},</if>
<if test="resourceName != null">#{resourceName},</if>
<if test="ipAddress != null">#{ipAddress},</if>
<if test="resourcePort != null">#{resourcePort},</if>
<if test="otherPortName != null">#{otherPortName},</if>
<if test="agentVersion != null">#{agentVersion},</if>
<if test="protocol != null">#{protocol},</if>
<if test="resourceVersion != null">#{resourceVersion},</if>
<if test="rwPermission != null">#{rwPermission},</if>
<if test="snmpDetect != null">#{snmpDetect},</if>
<if test="teamName != null">#{teamName},</if>
<if test="snmpCollectAddr != null">#{snmpCollectAddr},</if>
<if test="snmpCollectPort != null">#{snmpCollectPort},</if>
<if test="securityLevel != null">#{securityLevel},</if>
<if test="encryption != null">#{encryption},</if>
<if test="resourceUserName != null">#{resourceUserName},</if>
<if test="resourcePwd != null">#{resourcePwd},</if>
<if test="registrationStatus != null">#{registrationStatus},</if>
<if test="onlineStatus != null">#{onlineStatus},</if>
<if test="switchOnlineStatus != null">#{switchOnlineStatus},</if>
<if test="description != null">#{description},</if>
<if test="customerId != null">#{customerId},</if>
<if test="customerName != null">#{customerName},</if>
<if test="serviceNumber != null">#{serviceNumber},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="creatorId != null">#{creatorId},</if>
<if test="creatorName != null">#{creatorName},</if>
<if test="updaterId != null">#{updaterId},</if>
<if test="updaterName != null">#{updaterName},</if>
<if test="clientId != null">#{clientId},</if>
<if test="operator != null">#{operator},</if>
<if test="province != null">#{province},</if>
<if test="publicIp != null">#{publicIp},</if>
<if test="hardwareSn != null">#{hardwareSn},</if>
<if test="businessName != null">#{businessName},</if>
<if test="logicalNodeId != null">#{logicalNodeId},</if>
<if test="multiPublicIpStatus != null">#{multiPublicIpStatus},</if>
<if test="registrationStatus != null">#{registrationStatus},</if>
<if test="onlineStatus != null">#{onlineStatus},</if>
<if test="resourceType != null">#{resourceType},</if>
<if test="agentVersion != null">#{agentVersion},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="heartbeatCount != null">#{heartbeatCount},</if>
<if test="heartbeatInterval != null">#{heartbeatInterval},</if>
<if test="onboardTime != null">#{onboardTime},</if>
<if test="remark != null">#{remark},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateBy != null">#{updateBy},</if>
</trim>
</insert>
<update id="updateRmResourceRegistration" parameterType="RmResourceRegistration">
update rm_resource_registration
<trim prefix="SET" suffixOverrides=",">
<if test="hardwareSn != null">hardware_sn = #{hardwareSn},</if>
<if test="resourceType != null">resource_type = #{resourceType},</if>
<if test="resourceName != null">resource_name = #{resourceName},</if>
<if test="ipAddress != null">ip_address = #{ipAddress},</if>
<if test="resourcePort != null">resource_port = #{resourcePort},</if>
<if test="otherPortName != null">other_port_name = #{otherPortName},</if>
<if test="agentVersion != null">agent_version = #{agentVersion},</if>
<if test="protocol != null">protocol = #{protocol},</if>
<if test="resourceVersion != null">resource_version = #{resourceVersion},</if>
<if test="rwPermission != null">rw_permission = #{rwPermission},</if>
<if test="snmpDetect != null">snmp_detect = #{snmpDetect},</if>
<if test="teamName != null">team_name = #{teamName},</if>
<if test="snmpCollectAddr != null">snmp_collect_addr = #{snmpCollectAddr},</if>
<if test="snmpCollectPort != null">snmp_collect_port = #{snmpCollectPort},</if>
<if test="securityLevel != null">security_level = #{securityLevel},</if>
<if test="encryption != null">encryption = #{encryption},</if>
<if test="resourceUserName != null">resource_user_name = #{resourceUserName},</if>
<if test="resourcePwd != null">resource_pwd = #{resourcePwd},</if>
<if test="registrationStatus != null">registration_status = #{registrationStatus},</if>
<if test="onlineStatus != null">online_status = #{onlineStatus},</if>
<if test="switchOnlineStatus != null">switch_online_status = #{switchOnlineStatus},</if>
<if test="description != null">description = #{description},</if>
<if test="customerId != null">customer_id = #{customerId},</if>
<if test="customerName != null">customer_name = #{customerName},</if>
<if test="serviceNumber != null">service_number = #{serviceNumber},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="creatorId != null">creator_id = #{creatorId},</if>
<if test="creatorName != null">creator_name = #{creatorName},</if>
<if test="updaterId != null">updater_id = #{updaterId},</if>
<if test="updaterName != null">updater_name = #{updaterName},</if>
<if test="clientId != null">client_id = #{clientId},</if>
<if test="operator != null">operator = #{operator},</if>
<if test="province != null">province = #{province},</if>
<if test="publicIp != null">public_ip = #{publicIp},</if>
<if test="hardwareSn != null">hardware_sn = #{hardwareSn},</if>
<if test="businessName != null">business_name = #{businessName},</if>
<if test="logicalNodeId != null">logical_node_id = #{logicalNodeId},</if>
<if test="multiPublicIpStatus != null">multi_public_ip_status = #{multiPublicIpStatus},</if>
<if test="registrationStatus != null">registration_status = #{registrationStatus},</if>
<if test="onlineStatus != null">online_status = #{onlineStatus},</if>
<if test="resourceType != null">resource_type = #{resourceType},</if>
<if test="agentVersion != null">agent_version = #{agentVersion},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="heartbeatCount != null">heartbeat_count = #{heartbeatCount},</if>
<if test="heartbeatInterval != null">heartbeat_interval = #{heartbeatInterval},</if>
<if test="onboardTime != null">onboard_time = #{onboardTime},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
</trim>
where id = #{id}
</update>
@@ -256,52 +129,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id}
</foreach>
</delete>
<!-- 查询所有资源名称(包含设备使用)-->
<select id="selectAllResourceName" resultType="java.util.Map">
select id id,resource_name resourceName from rm_resource_registration
<where>
and registration_status = 1
</where>
group by id
</select>
<!-- 查询所有资源名称-->
<select id="selectAllResourceNameByType" parameterType="RmResourceRegistration" resultType="java.util.Map">
SELECT
resource_name AS resourceName,
CASE
WHEN resource_type = '1' THEN ip_address
WHEN resource_type = '2' THEN snmp_collect_addr
END AS ipAddress,
hardware_sn AS hardwareSn
FROM rm_resource_registration
<where>
and registration_status = 1
<if test="hardwareSn != null and hardwareSn != ''"> and hardware_sn = #{hardwareSn}</if>
<if test="resourceType != null and resourceType != ''"> and resource_type = #{resourceType}</if>
<if test="resourceName != null and resourceName != ''"> and resource_name like concat('%', #{resourceName}, '%')</if>
<if test="ipAddress != null and ipAddress != ''"> and ip_address = #{ipAddress}</if>
<if test="resourcePort != null and resourcePort != ''"> and resource_port = #{resourcePort}</if>
<if test="otherPortName != null and otherPortName != ''"> and other_port_name = #{otherPortName}</if>
<if test="protocol != null and protocol != ''"> and protocol = #{protocol}</if>
<if test="resourceVersion != null and resourceVersion != ''"> and resource_version = #{resourceVersion}</if>
<if test="rwPermission != null and rwPermission != ''"> and rw_permission = #{rwPermission}</if>
<if test="securityLevel != null and securityLevel != ''"> and security_level = #{securityLevel}</if>
<if test="encryption != null and encryption != ''"> and encryption = #{encryption}</if>
<if test="resourceUserName != null and resourceUserName != ''"> and resource_user_name = #{resourceUserName}</if>
<if test="resourcePwd != null and resourcePwd != ''"> and resource_pwd = #{resourcePwd}</if>
<if test="registrationStatus != null and registrationStatus != ''"> and registration_status = #{registrationStatus}</if>
<if test="onlineStatus != null and onlineStatus != ''"> and online_status = #{onlineStatus}</if>
<if test="description != null and description != ''"> and description = #{description}</if>
<if test="customerId != null "> and customer_id = #{customerId}</if>
<if test="customerName != null and customerName != ''"> and customer_name like concat('%', #{customerName}, '%')</if>
<if test="serviceNumber != null and serviceNumber != ''"> and service_number = #{serviceNumber}</if>
<if test="creatorId != null "> and creator_id = #{creatorId}</if>
<if test="creatorName != null and creatorName != ''"> and creator_name like concat('%', #{creatorName}, '%')</if>
<if test="updaterId != null "> and updater_id = #{updaterId}</if>
<if test="updaterName != null and updaterName != ''"> and updater_name like concat('%', #{updaterName}, '%')</if>
</where>
group by resource_name
</select>
<select id="countBySn" parameterType="String">
select count(1) from rm_resource_registration
where hardware_sn = #{hardwareSn}
@@ -309,46 +136,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="updateStatusByResource" parameterType="RmResourceRegistration">
update rm_resource_registration
<trim prefix="SET" suffixOverrides=",">
<if test="resourceType != null">resource_type = #{resourceType},</if>
<if test="resourceName != null">resource_name = #{resourceName},</if>
<if test="ipAddress != null">ip_address = #{ipAddress},</if>
<if test="resourcePort != null">resource_port = #{resourcePort},</if>
<if test="otherPortName != null">other_port_name = #{otherPortName},</if>
<if test="agentVersion != null">agent_version = #{agentVersion},</if>
<if test="protocol != null">protocol = #{protocol},</if>
<if test="resourceVersion != null">resource_version = #{resourceVersion},</if>
<if test="rwPermission != null">rw_permission = #{rwPermission},</if>
<if test="snmpDetect != null">snmp_detect = #{snmpDetect},</if>
<if test="teamName != null">team_name = #{teamName},</if>
<if test="snmpCollectAddr != null">snmp_collect_addr = #{snmpCollectAddr},</if>
<if test="snmpCollectPort != null">snmp_collect_port = #{snmpCollectPort},</if>
<if test="securityLevel != null">security_level = #{securityLevel},</if>
<if test="encryption != null">encryption = #{encryption},</if>
<if test="resourceUserName != null">resource_user_name = #{resourceUserName},</if>
<if test="resourcePwd != null">resource_pwd = #{resourcePwd},</if>
<if test="registrationStatus != null">registration_status = #{registrationStatus},</if>
<if test="onlineStatus != null">online_status = #{onlineStatus},</if>
<if test="switchOnlineStatus != null">switch_online_status = #{switchOnlineStatus},</if>
<if test="description != null">description = #{description},</if>
<if test="customerId != null">customer_id = #{customerId},</if>
<if test="customerName != null">customer_name = #{customerName},</if>
<if test="serviceNumber != null">service_number = #{serviceNumber},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="creatorId != null">creator_id = #{creatorId},</if>
<if test="creatorName != null">creator_name = #{creatorName},</if>
<if test="updaterId != null">updater_id = #{updaterId},</if>
<if test="updaterName != null">updater_name = #{updaterName},</if>
<if test="clientId != null">client_id = #{clientId},</if>
<if test="operator != null">operator = #{operator},</if>
<if test="province != null">province = #{province},</if>
<if test="publicIp != null">public_ip = #{publicIp},</if>
<if test="hardwareSn != null">hardware_sn = #{hardwareSn},</if>
<if test="businessName != null">business_name = #{businessName},</if>
<if test="logicalNodeId != null">logical_node_id = #{logicalNodeId},</if>
<if test="multiPublicIpStatus != null">multi_public_ip_status = #{multiPublicIpStatus},</if>
<if test="registrationStatus != null">registration_status = #{registrationStatus},</if>
<if test="onlineStatus != null">online_status = #{onlineStatus},</if>
<if test="resourceType != null">resource_type = #{resourceType},</if>
<if test="agentVersion != null">agent_version = #{agentVersion},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="heartbeatCount != null">heartbeat_count = #{heartbeatCount},</if>
<if test="heartbeatInterval != null">heartbeat_interval = #{heartbeatInterval},</if>
<if test="onboardTime != null">onboard_time = #{onboardTime},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
</trim>
<where>
<choose>
@@ -399,6 +203,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
a.heartbeat_count as heartbeatCount,
a.heartbeat_interval as heartbeatInterval,
a.onboard_time as onboardTime,
a.remark as remark,
b.machine_code as machineCode
from rm_resource_registration a
left join rm_registration_machine b on a.client_id = b.client_id
@@ -417,4 +222,22 @@ 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
<foreach collection="deployDevice.split(',')" item="clientId" open="(" separator="," close=")">
#{clientId}
</foreach>
</update>
<update id="addRemark" parameterType="RmResourceRegistration">
update rm_resource_registration set remark =
CASE
WHEN remark IS NULL OR remark = '' THEN #{remark}
ELSE CONCAT(remark, ',', #{remark})
END
where client_id in
<foreach collection="deployDevice.split(',')" item="clientId" open="(" separator="," close=")">
#{clientId}
</foreach>
</update>
</mapper>
@@ -14,8 +14,7 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 172.16.15.52:8848
# server-addr: 172.16.15.103:8848
server-addr: ${spring.cloud.nacos.config.server-addr}
namespace: ${spring.cloud.nacos.config.namespace}
username: ${spring.cloud.nacos.config.username}
password: ${spring.cloud.nacos.config.password}
@@ -23,8 +22,8 @@ spring:
# 配置中心地址
server-addr: 172.16.15.52:8848
# server-addr: 172.16.15.103:8848
# namespace: saas-local
namespace: public
namespace: saas-local
# namespace: public
username: nacos
password: nacos
# 配置文件格式