Commit bb4ba14c by zhangjw

新增事件日志查询条件

parent b0bb8e07
......@@ -4,26 +4,41 @@
<div class="table-page-search-wrapper">
<a-form layout="inline" @keyup.enter.native="searchQuery">
<a-row :gutter="24">
<a-col :md="8" :sm="24">
<a-form-item label="事件类别">
<a-select v-model="queryParam.eventCategory" placeholder="请选择" default-value="VSS">
<a-col :xl="4" :lg="4" :md="5" :sm="24">
<a-form-item label="子系统">
<a-select placeholder="子系统" v-model="queryParam.subsystem">
<a-select-option value="VSS">VSS</a-select-option>
<a-select-option value="EPS">EPS</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :span="4">
<a-form-model-item label="开始时间" prop="createTime">
<j-date v-model="queryParam.createTime" :showTime="true" dateFormat="YYYY-MM-DD HH:mm:ss"/>
</a-form-model-item>
</a-col>
<a-col :span="4">
<a-form-model-item label="结束时间" prop="stopTime" >
<j-date v-model="queryParam.stopTime" :showTime="true" dateFormat="YYYY-MM-DD HH:mm:ss"/>
</a-form-model-item>
</a-col>
<a-col :xl="4" :lg="4" :md="5" :sm="24">
<a-space style="float: left">
<a-button type="primary" @click="searchQuery">查询</a-button>
<a-button type="default" @click="searchReset">重置</a-button>
</a-space>
</a-col>
</a-row>
</a-form>
</div>
<!-- 查询区域-END -->
<!-- 操作按钮区域 -->
<span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
<a-col :md="6" :sm="24">
<a-button type="primary" @click="searchQuery">查询</a-button>
</a-col>
</span>
<!-- <div class="table-operator">-->
<!--&lt;!&ndash; <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>&ndash;&gt;-->
<!--&lt;!&ndash; <a-button type="primary" icon="download" @click="handleExportXls('pm_event_info')">导出</a-button>&ndash;&gt;-->
......@@ -141,9 +156,9 @@ export default {
// }
// },
{
title: '类别',
title: '子系统',
align: "center",
dataIndex: 'eventCategory'
dataIndex: 'subsystem'
},
{
title: '源名称',
......@@ -193,18 +208,18 @@ export default {
{
title: '开始时间',
align: "center",
dataIndex: 'startTime',
customRender: function (text) {
return !text ? "" : (text.length > 10 ? text.substr(0, 20) : text)
}
dataIndex: 'createTime',
// customRender: function (text) {
// return !text ? "" : (text.length > 10 ? text.substr(0, 20) : text)
// }
},
{
title: '结束时间',
align: "center",
dataIndex: 'stopTime',
customRender: function (text) {
return !text ? "" : (text.length > 10 ? text.substr(0, 20) : text)
}
// customRender: function (text) {
// return !text ? "" : (text.length > 10 ? text.substr(0, 20) : text)
// }
},
{
title: '源编号',
......@@ -277,7 +292,7 @@ export default {
getSuperFieldList() {
let fieldList = [];
fieldList.push({type: 'string', value: 'logId', text: '唯一标识一次发生的事件'})
fieldList.push({type: 'string', value: 'eventCategory', text: '事件类别'})
fieldList.push({type: 'string', value: 'subsystem', text: '事件类别'})
fieldList.push({
type: 'int',
value: 'eventState',
......@@ -289,8 +304,8 @@ export default {
fieldList.push({type: 'string', value: 'eventTypeName', text: '事件类型名称'})
fieldList.push({type: 'int', value: 'subSysType', text: '事件所属子系统类型."废弃,事件整改,没有子系统属性"'})
fieldList.push({type: 'string', value: 'eventName', text: '事件名称'})
fieldList.push({type: 'string', value: 'startTime', text: '事件开始时间'})
fieldList.push({type: 'string', value: 'stopTime', text: '事件结束时间'})
fieldList.push({type: 'date', value: 'createTime', text: '事件开始时间'})
fieldList.push({type: 'date', value: 'stopTime', text: '事件结束时间'})
fieldList.push({type: 'string', value: 'sourceIdx', text: '事件源编号'})
fieldList.push({type: 'int', value: 'sourceType', text: '事件源类型'})
fieldList.push({type: 'string', value: 'sourceName', text: '事件源名称'})
......
package org.jeecg.pm.controller.event;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
......@@ -18,6 +19,7 @@ import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.text.SimpleDateFormat;
import java.util.Arrays;
/**
......@@ -50,8 +52,20 @@ public class PmEventInfoController extends JeecgController<PmEventInfo, IPmEvent
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
IPage<PmEventInfo> pageList = pmEventInfoService.page(new Page<PmEventInfo>(pageNo, pageSize), new QueryWrapper<PmEventInfo>().lambda().orderByDesc(PmEventInfo::getStartTime));
return Result.OK(pageList);
final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
final LambdaQueryWrapper<PmEventInfo> pmEventInfoLambdaQueryWrapper = new QueryWrapper<PmEventInfo>()
.lambda()
.eq(pmEventInfo.getSubsystem() != null, PmEventInfo::getSubsystem, pmEventInfo.getSubsystem())
.orderByDesc(PmEventInfo::getCreateTime);
if (pmEventInfo.getCreateTime() != null) { //.apply condition无效, 先这样写
pmEventInfoLambdaQueryWrapper.apply("UNIX_TIMESTAMP(create_time) >= UNIX_TIMESTAMP('" + sdf.format(pmEventInfo.getCreateTime()) + "')");
}
if (pmEventInfo.getStopTime() != null) {
pmEventInfoLambdaQueryWrapper.apply("UNIX_TIMESTAMP(stop_time) <= UNIX_TIMESTAMP('" + sdf.format(pmEventInfo.getStopTime()) + "')");
}
return Result.OK(pmEventInfoService.page(new Page<PmEventInfo>(pageNo, pageSize), pmEventInfoLambdaQueryWrapper));
}
/**
......
......@@ -3,12 +3,14 @@ package org.jeecg.pm.entity.event;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
......@@ -101,19 +103,19 @@ public class PmEventInfo implements Serializable {
/**
* 事件开始时间
*/
@Excel(name = "事件开始时间", width = 15, format = "yyyy-MM-dd")
// @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
// @DateTimeFormat(pattern = "yyyy-MM-dd")
@Excel(name = "事件开始时间", width = 15, format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "事件开始时间")
private String startTime;
private java.util.Date createTime;
/**
* 事件结束时间
*/
@Excel(name = "事件结束时间", width = 15, format = "yyyy-MM-dd")
// @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
// @DateTimeFormat(pattern = "yyyy-MM-dd")
@Excel(name = "事件结束时间", width = 15, format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "事件结束时间")
private String stopTime;
private java.util.Date stopTime;
/**
* 事件源编号
*/
......@@ -168,11 +170,11 @@ public class PmEventInfo implements Serializable {
private String trigInfo;
/**
* 上层事件类型
* 子系统
* VSS: 视频事件
* EPS: 入侵报警事件'
*/
@Excel(name = "VSS: 视频事件 EPS: 入侵报警事件", width = 15)
@ApiModelProperty(value = "VSS: 视频事件 EPS: 入侵报警事件")
private String eventCategory;
private String subsystem;
}
package org.jeecg.pm.mq;
import com.chanjx.utils.StringUtils;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.pm.entity.eps.EventDis;
import org.jeecg.pm.entity.event.PmEventInfo;
......@@ -12,6 +14,8 @@ import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;
import javax.jms.BytesMessage;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Arrays;
/**
......@@ -43,9 +47,9 @@ public class EventMessageListener {
// 壳文件字段,EventDis类为event_dis.proto文件解析而来,CommEventLog类为事件壳文件类
final EventDis.CommEventLog commEventLog = EventDis.CommEventLog.parseFrom(bytes);
final PmEventInfo pmEventInfo = this.recode(commEventLog);
pmEventInfo.setEventCategory(PmEventInfo.VSS);
pmEventInfo.setSubsystem(PmEventInfo.VSS);
pmEventInfoService.saveEvent(pmEventInfo);
log.info("VSS_TOPIC:{}", pmEventInfo);
// log.info("VSS_TOPIC:{}", pmEventInfo);
}
......@@ -55,15 +59,17 @@ public class EventMessageListener {
bytesMessage.readBytes(bytes);
final EventDis.CommEventLog commEventLog = EventDis.CommEventLog.parseFrom(bytes);
final PmEventInfo pmEventInfo = this.recode(commEventLog);
pmEventInfo.setEventCategory(PmEventInfo.EPS);
pmEventInfo.setSubsystem(PmEventInfo.EPS);
pmEventInfoService.saveEvent(pmEventInfo);
log.info("EPS_TOPIC:{}", pmEventInfo);
}
@SneakyThrows
public PmEventInfo recode(EventDis.CommEventLog commEventLog) {
final EventLevel eventLevel = Arrays.asList(EventLevel.values()).stream().filter(level -> level.getLevel().equals(commEventLog.getEventLevel())).findFirst().orElse(EventLevel.UNKNOWN);
final EventState eventState = Arrays.asList(EventState.values()).stream().filter(state -> state.getState().equals(commEventLog.getEventState())).findFirst().orElse(EventState.UNKNOWN);
DateFormat fmt =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return new PmEventInfo()
.setLogId(commEventLog.getLogId())
.setEventState(eventState.getRemark())
......@@ -73,8 +79,8 @@ public class EventMessageListener {
.setEventTypeName(commEventLog.getEventTypeName())
.setSubSysType(commEventLog.getSubSysType())
.setEventName(commEventLog.getEventName())
.setStartTime(commEventLog.getStartTime())
.setStopTime(commEventLog.getStopTime())
.setCreateTime(fmt.parse(commEventLog.getStartTime()))
.setStopTime(StringUtils.isBlank(commEventLog.getStopTime()) ? null :fmt.parse(commEventLog.getStopTime()))
.setSourceIdx(commEventLog.getSourceIdx())
.setSourceType(commEventLog.getSourceType())
.setSourceName(commEventLog.getSourceName())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment