导出优化、告警日志方法增加

This commit is contained in:
gaoyutao
2025-11-10 18:17:59 +08:00
parent 4137028deb
commit 80533dc1a3
12 changed files with 602 additions and 105 deletions

View File

@@ -1,5 +1,6 @@
package com.ruoyi.system.controller;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.PageDomain;
@@ -12,6 +13,7 @@ import com.ruoyi.system.service.IEpsBusinessDeployService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
@@ -42,6 +44,20 @@ public class EpsBusinessDeployController extends BaseController
return getDataTable(list);
}
/**
* 导出
* @param response
* @param epsBusinessDeploy
*/
@PostMapping("/export")
public void export(HttpServletResponse response, @RequestBody EpsBusinessDeploy epsBusinessDeploy)
{
List<EpsBusinessDeploy> list = epsBusinessDeployService.selectEpsBusinessDeployList(epsBusinessDeploy);
ExcelUtil<EpsBusinessDeploy> util = new ExcelUtil<EpsBusinessDeploy>(EpsBusinessDeploy.class);
util.showColumn(epsBusinessDeploy.getProperties());
util.exportExcel(response, list, "业务下发管理");
}
/**
* 获取业务下发管理详细信息

View File

@@ -52,7 +52,7 @@ public class EpsTaskStatisticsController extends BaseController
@RequiresPermissions("system:taskStatistics:export")
@Log(title = "业务95值计算任务", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, EpsTaskStatistics epsTaskStatistics)
public void export(HttpServletResponse response, @RequestBody EpsTaskStatistics epsTaskStatistics)
{
List<EpsTaskStatistics> list = epsTaskStatisticsService.selectEpsTaskStatisticsList(epsTaskStatistics);
ExcelUtil<EpsTaskStatistics> util = new ExcelUtil<EpsTaskStatistics>(EpsTaskStatistics.class);

View File

@@ -88,7 +88,7 @@ public class RmResourceRegistration extends BaseEntity
private String registrationStatus;
/** 在线状态 0-离线1-在线 */
@Excel(name = "在线状态")
@Excel(name = "在线状态", readConverterExp = "0=离线,1=在线")
private String onlineStatus;
private String switchOnlineStatus;

View File

@@ -0,0 +1,105 @@
package com.ruoyi.rocketmq.controller;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.rocketmq.domain.RmAlarmLog;
import com.ruoyi.rocketmq.service.IRmAlarmLogService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;
/**
* 客户端告警信息Controller
*
* @author gyt
* @date 2025-11-10
*/
@RestController
@RequestMapping("/alarmLog")
public class RmAlarmLogController extends BaseController
{
@Autowired
private IRmAlarmLogService rmAlarmLogService;
/**
* 查询客户端告警信息列表
*/
@RequiresPermissions("rocketmq:alarmLog:list")
@GetMapping("/list")
public TableDataInfo list(RmAlarmLog rmAlarmLog)
{
startPage();
List<RmAlarmLog> list = rmAlarmLogService.selectRmAlarmLogList(rmAlarmLog);
return getDataTable(list);
}
/**
* 导出客户端告警信息列表
*/
@RequiresPermissions("rocketmq:alarmLog:export")
@Log(title = "客户端告警信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, RmAlarmLog rmAlarmLog)
{
List<RmAlarmLog> list = rmAlarmLogService.selectRmAlarmLogList(rmAlarmLog);
ExcelUtil<RmAlarmLog> util = new ExcelUtil<RmAlarmLog>(RmAlarmLog.class);
util.exportExcel(response, list, "客户端告警信息数据");
}
/**
* 获取客户端告警信息详细信息
*/
@RequiresPermissions("rocketmq:alarmLog:query")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(rmAlarmLogService.selectRmAlarmLogById(id));
}
/**
* 新增客户端告警信息
*/
@RequiresPermissions("rocketmq:alarmLog:add")
@Log(title = "客户端告警信息", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody RmAlarmLog rmAlarmLog)
{
return toAjax(rmAlarmLogService.insertRmAlarmLog(rmAlarmLog));
}
/**
* 修改客户端告警信息
*/
@RequiresPermissions("rocketmq:alarmLog:edit")
@Log(title = "客户端告警信息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody RmAlarmLog rmAlarmLog)
{
return toAjax(rmAlarmLogService.updateRmAlarmLog(rmAlarmLog));
}
/**
* 删除客户端告警信息
*/
@RequiresPermissions("rocketmq:alarmLog:remove")
@Log(title = "客户端告警信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(rmAlarmLogService.deleteRmAlarmLogByIds(ids));
}
}

View File

@@ -52,10 +52,11 @@ public class RmDeploymentPolicyController extends BaseController
@RequiresPermissions("rocketmq:policy:export")
@Log(title = "服务器脚本策略", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, RmDeploymentPolicy rmDeploymentPolicy)
public void export(HttpServletResponse response, @RequestBody RmDeploymentPolicy rmDeploymentPolicy)
{
List<RmDeploymentPolicy> list = rmDeploymentPolicyService.selectRmDeploymentPolicyList(rmDeploymentPolicy);
ExcelUtil<RmDeploymentPolicy> util = new ExcelUtil<RmDeploymentPolicy>(RmDeploymentPolicy.class);
util.showColumn(rmDeploymentPolicy.getProperties());
util.exportExcel(response, list, "服务器脚本策略数据");
}

View File

@@ -0,0 +1,119 @@
package com.ruoyi.rocketmq.domain;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.web.domain.BaseEntity;
/**
* 客户端告警信息对象 rm_alarm_log
*
* @author gyt
* @date 2025-11-10
*/
public class RmAlarmLog extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键ID */
private Long id;
/** 客户端ID */
@Excel(name = "客户端ID")
private String clientId;
/** 告警时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "告警时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date alarmTime;
/** 管理网-公网IP */
@Excel(name = "管理网-公网IP")
private String mgmPublicIp;
/** 告警类型 */
@Excel(name = "告警类型")
private String alarmType;
/** 告警内容 */
@Excel(name = "告警内容")
private String alarmContent;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setClientId(String clientId)
{
this.clientId = clientId;
}
public String getClientId()
{
return clientId;
}
public void setAlarmTime(Date alarmTime)
{
this.alarmTime = alarmTime;
}
public Date getAlarmTime()
{
return alarmTime;
}
public void setMgmPublicIp(String mgmPublicIp)
{
this.mgmPublicIp = mgmPublicIp;
}
public String getMgmPublicIp()
{
return mgmPublicIp;
}
public void setAlarmType(String alarmType)
{
this.alarmType = alarmType;
}
public String getAlarmType()
{
return alarmType;
}
public void setAlarmContent(String alarmContent)
{
this.alarmContent = alarmContent;
}
public String getAlarmContent()
{
return alarmContent;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("clientId", getClientId())
.append("alarmTime", getAlarmTime())
.append("mgmPublicIp", getMgmPublicIp())
.append("alarmType", getAlarmType())
.append("alarmContent", getAlarmContent())
.append("createTime", getCreateTime())
.append("updateTime", getUpdateTime())
.append("createBy", getCreateBy())
.append("updateBy", getUpdateBy())
.toString();
}
}

View File

@@ -1,11 +1,11 @@
package com.ruoyi.rocketmq.domain;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.web.domain.BaseEntity;
import lombok.Data;
import java.util.Date;
/**
* 告警记录对象 rm_alarm_record
@@ -13,6 +13,7 @@ import com.ruoyi.common.core.web.domain.BaseEntity;
* @author gyt
* @date 2025-09-12
*/
@Data
public class RmAlarmRecord extends BaseEntity
{
private static final long serialVersionUID = 1L;
@@ -33,8 +34,8 @@ public class RmAlarmRecord extends BaseEntity
private String sourceIp;
/** 告警发生时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "告警发生时间", width = 30, dateFormat = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "告警发生时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date occurTime;
/** 告警详细内容 */
@@ -49,101 +50,4 @@ public class RmAlarmRecord extends BaseEntity
@Excel(name = "状态0-未处理1-已处理")
private String status;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setClientId(String clientId)
{
this.clientId = clientId;
}
public String getClientId()
{
return clientId;
}
public void setResourceName(String resourceName)
{
this.resourceName = resourceName;
}
public String getResourceName()
{
return resourceName;
}
public void setSourceIp(String sourceIp)
{
this.sourceIp = sourceIp;
}
public String getSourceIp()
{
return sourceIp;
}
public void setOccurTime(Date occurTime)
{
this.occurTime = occurTime;
}
public Date getOccurTime()
{
return occurTime;
}
public void setContent(String content)
{
this.content = content;
}
public String getContent()
{
return content;
}
public void setRepeatCount(Long repeatCount)
{
this.repeatCount = repeatCount;
}
public Long getRepeatCount()
{
return repeatCount;
}
public void setStatus(String status)
{
this.status = status;
}
public String getStatus()
{
return status;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("clientId", getClientId())
.append("resourceName", getResourceName())
.append("sourceIp", getSourceIp())
.append("occurTime", getOccurTime())
.append("content", getContent())
.append("repeatCount", getRepeatCount())
.append("status", getStatus())
.append("createTime", getCreateTime())
.append("updateTime", getUpdateTime())
.append("createBy", getCreateBy())
.append("updateBy", getUpdateBy())
.toString();
}
}

View File

@@ -87,6 +87,8 @@ public class MessageHandler {
private IRmDeploymentPolicyService rmDeploymentPolicyService;
@Autowired
private IInitialBandwidthTrafficTempService initialBandwidthTrafficTempService;
@Autowired
private IRmAlarmLogService rmAlarmLogService;
/**
@@ -1079,6 +1081,37 @@ public class MessageHandler {
log.error("插入心跳日志失败", e);
}
}
private void insertAlarmRecords(String clientId){
RmAlarmLog rmAlarmLog = new RmAlarmLog();
// 查询管理网公网ip
RmNetworkInterface rmNetworkInterface = new RmNetworkInterface();
rmNetworkInterface.setClientId(clientId);
rmNetworkInterface.setNewFlag(1);
List<RmNetworkInterface> interfaceList = rmNetworkInterfaceService.selectRmNetworkInterfaceList(rmNetworkInterface);
if(interfaceList != null && !interfaceList.isEmpty()){
interfaceList.stream()
.filter(info -> "2".equals(info.getBindIp()) || "3".equals(info.getBindIp()))
.findFirst()
.ifPresent(networkInterface -> {
rmAlarmLog.setMgmPublicIp(networkInterface.getPublicIp());
});
}
rmAlarmLog.setClientId(clientId);
rmAlarmLog.setAlarmContent(clientId + "下线");
rmAlarmLog.setAlarmTime(DateUtils.getNowDate());
rmAlarmLog.setAlarmType("1");
// 查询此告警是否存在
RmAlarmLog query = new RmAlarmLog();
query.setClientId(clientId);
query.setAlarmType("1");
List<RmAlarmLog> alarmLog = rmAlarmLogService.selectRmAlarmLogList(query);
if(alarmLog != null && !alarmLog.isEmpty()){
rmAlarmLogService.updateRmAlarmLog(rmAlarmLog);
}else{
rmAlarmLogService.insertRmAlarmLog(rmAlarmLog);
}
}
/**
* 应答信息

View File

@@ -0,0 +1,61 @@
package com.ruoyi.rocketmq.mapper;
import java.util.List;
import com.ruoyi.rocketmq.domain.RmAlarmLog;
/**
* 客户端告警信息Mapper接口
*
* @author gyt
* @date 2025-11-10
*/
public interface RmAlarmLogMapper
{
/**
* 查询客户端告警信息
*
* @param id 客户端告警信息主键
* @return 客户端告警信息
*/
public RmAlarmLog selectRmAlarmLogById(Long id);
/**
* 查询客户端告警信息列表
*
* @param rmAlarmLog 客户端告警信息
* @return 客户端告警信息集合
*/
public List<RmAlarmLog> selectRmAlarmLogList(RmAlarmLog rmAlarmLog);
/**
* 新增客户端告警信息
*
* @param rmAlarmLog 客户端告警信息
* @return 结果
*/
public int insertRmAlarmLog(RmAlarmLog rmAlarmLog);
/**
* 修改客户端告警信息
*
* @param rmAlarmLog 客户端告警信息
* @return 结果
*/
public int updateRmAlarmLog(RmAlarmLog rmAlarmLog);
/**
* 删除客户端告警信息
*
* @param id 客户端告警信息主键
* @return 结果
*/
public int deleteRmAlarmLogById(Long id);
/**
* 批量删除客户端告警信息
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteRmAlarmLogByIds(Long[] ids);
}

View File

@@ -0,0 +1,61 @@
package com.ruoyi.rocketmq.service;
import java.util.List;
import com.ruoyi.rocketmq.domain.RmAlarmLog;
/**
* 客户端告警信息Service接口
*
* @author gyt
* @date 2025-11-10
*/
public interface IRmAlarmLogService
{
/**
* 查询客户端告警信息
*
* @param id 客户端告警信息主键
* @return 客户端告警信息
*/
public RmAlarmLog selectRmAlarmLogById(Long id);
/**
* 查询客户端告警信息列表
*
* @param rmAlarmLog 客户端告警信息
* @return 客户端告警信息集合
*/
public List<RmAlarmLog> selectRmAlarmLogList(RmAlarmLog rmAlarmLog);
/**
* 新增客户端告警信息
*
* @param rmAlarmLog 客户端告警信息
* @return 结果
*/
public int insertRmAlarmLog(RmAlarmLog rmAlarmLog);
/**
* 修改客户端告警信息
*
* @param rmAlarmLog 客户端告警信息
* @return 结果
*/
public int updateRmAlarmLog(RmAlarmLog rmAlarmLog);
/**
* 批量删除客户端告警信息
*
* @param ids 需要删除的客户端告警信息主键集合
* @return 结果
*/
public int deleteRmAlarmLogByIds(Long[] ids);
/**
* 删除客户端告警信息信息
*
* @param id 客户端告警信息主键
* @return 结果
*/
public int deleteRmAlarmLogById(Long id);
}

View File

@@ -0,0 +1,96 @@
package com.ruoyi.rocketmq.service.impl;
import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.rocketmq.mapper.RmAlarmLogMapper;
import com.ruoyi.rocketmq.domain.RmAlarmLog;
import com.ruoyi.rocketmq.service.IRmAlarmLogService;
/**
* 客户端告警信息Service业务层处理
*
* @author gyt
* @date 2025-11-10
*/
@Service
public class RmAlarmLogServiceImpl implements IRmAlarmLogService
{
@Autowired
private RmAlarmLogMapper rmAlarmLogMapper;
/**
* 查询客户端告警信息
*
* @param id 客户端告警信息主键
* @return 客户端告警信息
*/
@Override
public RmAlarmLog selectRmAlarmLogById(Long id)
{
return rmAlarmLogMapper.selectRmAlarmLogById(id);
}
/**
* 查询客户端告警信息列表
*
* @param rmAlarmLog 客户端告警信息
* @return 客户端告警信息
*/
@Override
public List<RmAlarmLog> selectRmAlarmLogList(RmAlarmLog rmAlarmLog)
{
return rmAlarmLogMapper.selectRmAlarmLogList(rmAlarmLog);
}
/**
* 新增客户端告警信息
*
* @param rmAlarmLog 客户端告警信息
* @return 结果
*/
@Override
public int insertRmAlarmLog(RmAlarmLog rmAlarmLog)
{
rmAlarmLog.setCreateTime(DateUtils.getNowDate());
return rmAlarmLogMapper.insertRmAlarmLog(rmAlarmLog);
}
/**
* 修改客户端告警信息
*
* @param rmAlarmLog 客户端告警信息
* @return 结果
*/
@Override
public int updateRmAlarmLog(RmAlarmLog rmAlarmLog)
{
rmAlarmLog.setUpdateTime(DateUtils.getNowDate());
return rmAlarmLogMapper.updateRmAlarmLog(rmAlarmLog);
}
/**
* 批量删除客户端告警信息
*
* @param ids 需要删除的客户端告警信息主键
* @return 结果
*/
@Override
public int deleteRmAlarmLogByIds(Long[] ids)
{
return rmAlarmLogMapper.deleteRmAlarmLogByIds(ids);
}
/**
* 删除客户端告警信息信息
*
* @param id 客户端告警信息主键
* @return 结果
*/
@Override
public int deleteRmAlarmLogById(Long id)
{
return rmAlarmLogMapper.deleteRmAlarmLogById(id);
}
}

View File

@@ -0,0 +1,101 @@
<?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">
<mapper namespace="com.ruoyi.rocketmq.mapper.RmAlarmLogMapper">
<resultMap type="RmAlarmLog" id="RmAlarmLogResult">
<result property="id" column="id" />
<result property="clientId" column="client_id" />
<result property="alarmTime" column="alarm_time" />
<result property="mgmPublicIp" column="mgm_public_ip" />
<result property="alarmType" column="alarm_type" />
<result property="alarmContent" column="alarm_content" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="createBy" column="create_by" />
<result property="updateBy" column="update_by" />
</resultMap>
<sql id="selectRmAlarmLogVo">
select id, client_id, alarm_time, mgm_public_ip, alarm_type, alarm_content, create_time, update_time, create_by, update_by from rm_alarm_log
</sql>
<select id="selectRmAlarmLogList" parameterType="RmAlarmLog" resultMap="RmAlarmLogResult">
<include refid="selectRmAlarmLogVo"/>
<where>
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
<if test="alarmTime != null "> and alarm_time = #{alarmTime}</if>
<if test="mgmPublicIp != null and mgmPublicIp != ''"> and mgm_public_ip = #{mgmPublicIp}</if>
<if test="alarmType != null and alarmType != ''"> and alarm_type = #{alarmType}</if>
<if test="alarmContent != null and alarmContent != ''"> and alarm_content = #{alarmContent}</if>
</where>
</select>
<select id="selectRmAlarmLogById" parameterType="Long" resultMap="RmAlarmLogResult">
<include refid="selectRmAlarmLogVo"/>
where id = #{id}
</select>
<insert id="insertRmAlarmLog" parameterType="RmAlarmLog" useGeneratedKeys="true" keyProperty="id">
insert into rm_alarm_log
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="clientId != null and clientId != ''">client_id,</if>
<if test="alarmTime != null">alarm_time,</if>
<if test="mgmPublicIp != null">mgm_public_ip,</if>
<if test="alarmType != null">alarm_type,</if>
<if test="alarmContent != null">alarm_content,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="createBy != null">create_by,</if>
<if test="updateBy != null">update_by,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="clientId != null and clientId != ''">#{clientId},</if>
<if test="alarmTime != null">#{alarmTime},</if>
<if test="mgmPublicIp != null">#{mgmPublicIp},</if>
<if test="alarmType != null">#{alarmType},</if>
<if test="alarmContent != null">#{alarmContent},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateBy != null">#{updateBy},</if>
</trim>
</insert>
<update id="updateRmAlarmLog" parameterType="RmAlarmLog">
update rm_alarm_log
<trim prefix="SET" suffixOverrides=",">
<if test="mgmPublicIp != null">mgm_public_ip = #{mgmPublicIp},</if>
<if test="alarmContent != null">alarm_content = #{alarmContent},</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>
<if test="updateBy != null">update_by = #{updateBy},</if>
</trim>
<where>
<choose>
<when test="id != null">
and id = #[id]
</when>
<when test="clientId != null and alarmType != null">
and client_id = #{clientId} and alarm_type = #{alarmType}
</when>
<otherwise>
and 1=0
</otherwise>
</choose>
</where>
</update>
<delete id="deleteRmAlarmLogById" parameterType="Long">
delete from rm_alarm_log where id = #{id}
</delete>
<delete id="deleteRmAlarmLogByIds" parameterType="String">
delete from rm_alarm_log where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>