@@ -0,0 +1,61 @@ | |||
package com.tuoheng.admin.controller.alarmLog; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.baomidou.mybatisplus.core.metadata.IPage; | |||
import com.tuoheng.admin.pojo.request.AlarmLogQuery; | |||
import com.tuoheng.admin.pojo.vo.AlarmLogVo; | |||
import com.tuoheng.admin.service.alarmLog.AlarmLogService; | |||
import com.tuoheng.common.common.BaseController; | |||
import com.tuoheng.common.config.CommonConfig; | |||
import com.tuoheng.common.utils.ExcelUtils; | |||
import com.tuoheng.common.utils.JsonResult; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.GetMapping; | |||
import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RestController; | |||
import javax.validation.Valid; | |||
import java.util.List; | |||
import java.util.UUID; | |||
/** | |||
* @Author: 吴彬 | |||
* @CreateTime: 2023-06-13 13:24 | |||
* @Description: 告警通知 前端控制器 | |||
* @Version: 1.0 | |||
*/ | |||
@RestController | |||
@RequestMapping("/alarmLog") | |||
public class AlarmLogController extends BaseController { | |||
@Autowired | |||
private AlarmLogService alarmLogService; | |||
/** | |||
* 获取告警通知数据列表 | |||
* @param alarmLogQuery 查询条件 | |||
* @return | |||
*/ | |||
@GetMapping("/index") | |||
public JsonResult index(@Valid AlarmLogQuery alarmLogQuery) { | |||
return alarmLogService.queryAlarmLog(alarmLogQuery); | |||
} | |||
/** | |||
* 导出Excel | |||
* | |||
* @param registerInformationQuery 查询参数 | |||
* @return | |||
*/ | |||
@GetMapping("/exportExcel") | |||
public JsonResult exportExcel(@Valid AlarmLogQuery registerInformationQuery) { | |||
JsonResult<IPage<AlarmLogVo>> iPageJsonResult = alarmLogService.queryAlarmLog(registerInformationQuery); | |||
if(ObjectUtil.isEmpty(iPageJsonResult) || iPageJsonResult.getCode() != JsonResult.SUCCESS || ObjectUtil.isEmpty(iPageJsonResult.getData())){ | |||
return JsonResult.error("未查询到数据,请确认查询条件!"); | |||
} | |||
List<AlarmLogVo> alarmLogVos = iPageJsonResult.getData().getRecords(); | |||
ExcelUtils<AlarmLogVo> excelUtils = new ExcelUtils<>(AlarmLogVo.class); | |||
JsonResult jsonResult = excelUtils.exportExcel(alarmLogVos, UUID.randomUUID().toString()); | |||
return JsonResult.success(CommonConfig.localFileURL + jsonResult.getData().toString()); | |||
} | |||
} |
@@ -0,0 +1,38 @@ | |||
package com.tuoheng.admin.pojo.request; | |||
import com.fasterxml.jackson.annotation.JsonFormat; | |||
import com.tuoheng.common.common.BaseQuery; | |||
import lombok.Data; | |||
import org.springframework.format.annotation.DateTimeFormat; | |||
import java.util.Date; | |||
/** | |||
* @Author: 吴彬 | |||
* @CreateTime: 2023-06-13 11:47 | |||
* @Description: 告警通知 query | |||
* @Version: 1.0 | |||
*/ | |||
@Data | |||
public class AlarmLogQuery extends BaseQuery { | |||
/** | |||
* 机场ID | |||
*/ | |||
private String airportId; | |||
/** | |||
* 开始时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
private Date startTime; | |||
/** | |||
* 结束时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
private Date endTime; | |||
} |
@@ -0,0 +1,76 @@ | |||
package com.tuoheng.admin.pojo.vo; | |||
import com.baomidou.mybatisplus.annotation.FieldFill; | |||
import com.baomidou.mybatisplus.annotation.TableField; | |||
import com.fasterxml.jackson.annotation.JsonFormat; | |||
import com.tuoheng.common.annotation.Excel; | |||
import lombok.Data; | |||
import org.springframework.format.annotation.DateTimeFormat; | |||
import java.util.Date; | |||
/** | |||
* @Author: 吴彬 | |||
* @CreateTime: 2023-06-13 11:57 | |||
* @Description: 机场告警记录 VO | |||
* @Version: 1.0 | |||
*/ | |||
@Data | |||
public class AlarmLogVo{ | |||
/** | |||
* 告警ID | |||
*/ | |||
private Integer id; | |||
/** | |||
* 机场ID | |||
*/ | |||
private Integer airportId; | |||
/** | |||
* 机场名称 | |||
*/ | |||
@Excel(name = "告警机场") | |||
private String airportName; | |||
/** | |||
* 控制板ID | |||
*/ | |||
private String edgeId; | |||
/** | |||
* 接收的时间戳 | |||
*/ | |||
private String timestamp; | |||
/** | |||
* 创建时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
@Excel(name = "告警时间", dateFormat = "yyyy-MM-dd HH:mm:ss") | |||
private Date createTime; | |||
/** | |||
* 日志类型(log: 常规日志;error: 错误日志; critical: 紧急日志) | |||
*/ | |||
@Excel(name = "告警类型",readConverterExp = "error=错误日志,critical=紧急日志") | |||
private String type; | |||
/** | |||
* 消息主体 | |||
*/ | |||
@Excel(name = "告警内容") | |||
private String data; | |||
/** | |||
* 告警消息主体 | |||
*/ | |||
private String critical; | |||
/** | |||
* 处理结果 1 : 已处理, 0: 未处理 | |||
*/ | |||
private Integer result; | |||
} |
@@ -0,0 +1,25 @@ | |||
package com.tuoheng.admin.service.alarmLog; | |||
import com.baomidou.mybatisplus.core.metadata.IPage; | |||
import com.tuoheng.admin.pojo.entity.AlarmLog; | |||
import com.tuoheng.admin.pojo.request.AlarmLogQuery; | |||
import com.tuoheng.admin.pojo.vo.AlarmLogVo; | |||
import com.tuoheng.common.common.IBaseService; | |||
import com.tuoheng.common.utils.JsonResult; | |||
/** | |||
* @Author: 吴彬 | |||
* @CreateTime: 2023-06-13 11:51 | |||
* @Description: 告警通知 服务类 | |||
* @Version: 1.0 | |||
*/ | |||
public interface AlarmLogService extends IBaseService<AlarmLog> { | |||
/** | |||
* 查询告警通知分页列表 | |||
* | |||
* @param alarmLogQuery 查询条件 | |||
* @return | |||
*/ | |||
JsonResult<IPage<AlarmLogVo>> queryAlarmLog(AlarmLogQuery alarmLogQuery); | |||
} |
@@ -0,0 +1,41 @@ | |||
package com.tuoheng.admin.service.alarmLog.impl; | |||
import com.baomidou.mybatisplus.core.metadata.IPage; | |||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||
import com.tuoheng.admin.mapper.AlarmLogMapper; | |||
import com.tuoheng.admin.pojo.entity.AlarmLog; | |||
import com.tuoheng.admin.pojo.request.AlarmLogQuery; | |||
import com.tuoheng.admin.pojo.vo.AlarmLogVo; | |||
import com.tuoheng.admin.service.alarmLog.AlarmLogService; | |||
import com.tuoheng.common.common.BaseServiceImpl; | |||
import com.tuoheng.common.utils.JsonResult; | |||
import org.springframework.stereotype.Service; | |||
import javax.annotation.Resource; | |||
/** | |||
* @Author: 吴彬 | |||
* @CreateTime: 2023-06-13 13:18 | |||
* @Description: 告警通知 服务实现类 | |||
* @Version: 1.0 | |||
*/ | |||
@Service | |||
public class AlarmLogServiceImpl extends BaseServiceImpl<AlarmLogMapper, | |||
AlarmLog> implements AlarmLogService { | |||
@Resource | |||
private AlarmLogMapper alarmLogMapper; | |||
/** | |||
* 查询告警通知分页列表 | |||
* @param alarmLogQuery 查询条件 | |||
* @return | |||
*/ | |||
@Override | |||
public JsonResult<IPage<AlarmLogVo>> queryAlarmLog(AlarmLogQuery alarmLogQuery) { | |||
// 分页查询 | |||
IPage<AlarmLogVo> page = new Page<>(alarmLogQuery.getPage(), alarmLogQuery.getLimit()); | |||
IPage<AlarmLogVo> pageData = alarmLogMapper.selectNewPage(page, alarmLogQuery); | |||
return JsonResult.success(pageData); | |||
} | |||
} |
@@ -0,0 +1,43 @@ | |||
<?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.tuoheng.admin.mapper.AlarmLogMapper"> | |||
<resultMap id="alarmLogMap" type="com.tuoheng.admin.pojo.vo.AlarmLogVo"> | |||
<id column="id" property="id"></id> | |||
<result column="airport_id" property="airportId"></result> | |||
<result column="airportName" property="airportName"></result> | |||
<result column="edge_Id" property="edgeId"></result> | |||
<result column="create_time" property="createTime"></result> | |||
<result column="timestamp" property="timestamp"></result> | |||
<result column="type" property="type"></result> | |||
<result column="data" property="data"></result> | |||
<result column="critical" property="critical"></result> | |||
<result column="result" property="result"></result> | |||
</resultMap> | |||
<select id="selectNewPage" parameterType="com.tuoheng.admin.pojo.request.AlarmLogQuery" resultMap="alarmLogMap"> | |||
SELECT | |||
tal.id, | |||
tal.airport_id, | |||
ta.NAME AS airportName, | |||
tal.edge_Id, | |||
tal.create_time, | |||
tal.`timestamp`, | |||
tal.type, | |||
tal.data, | |||
tal.critical, | |||
tal.result | |||
FROM | |||
th_alarm_log tal | |||
LEFT JOIN th_airport ta ON tal.airport_id = ta.id | |||
WHERE tal.mark = 1 | |||
<if test="alarmLogQuery.airportId != null and alarmLogQuery.airportId != ''"> | |||
and tal.airport_id = #{alarmLogQuery.airportId} | |||
</if> | |||
<if test="alarmLogQuery.startTime != null"> | |||
AND #{alarmLogQuery.startTime} <= tal.create_time | |||
</if> | |||
<if test="alarmLogQuery.endTime != null"> | |||
AND tal.create_time <= #{alarmLogQuery.endTime} | |||
</if> | |||
ORDER BY tal.create_time DESC | |||
</select> | |||
</mapper> |