Commit 96d7b661 by zhangjw

完善保存事件日志逻辑

parent 4b5d07ac
......@@ -4,34 +4,52 @@
<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-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-row>
</a-form>
</div>
<!-- 查询区域-END -->
<!-- 操作按钮区域 -->
<div class="table-operator">
<!-- <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>-->
<!-- <a-button type="primary" icon="download" @click="handleExportXls('pm_event_info')">导出</a-button>-->
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
<!-- <a-button type="primary" icon="import">导入</a-button>-->
</a-upload>
<!-- 高级查询区域 -->
<j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>
<!-- <a-dropdown v-if="selectedRowKeys.length > 0">-->
<!-- <a-menu slot="overlay">-->
<!-- <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>-->
<!-- </a-menu>-->
<!-- <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>-->
<!-- </a-dropdown>-->
</div>
<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;-->
<!--&lt;!&ndash; <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">&ndash;&gt;-->
<!--&lt;!&ndash;&lt;!&ndash; <a-button type="primary" icon="import">导入</a-button>&ndash;&gt;&ndash;&gt;-->
<!--&lt;!&ndash; </a-upload>&ndash;&gt;-->
<!-- &lt;!&ndash; 高级查询区域 &ndash;&gt;-->
<!--&lt;!&ndash; <j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>&ndash;&gt;-->
<!--&lt;!&ndash; <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>&ndash;&gt;-->
<!-- <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>-->
<!-- &lt;!&ndash; <a-dropdown v-if="selectedRowKeys.length > 0">&ndash;&gt;-->
<!--&lt;!&ndash; <a-menu slot="overlay">&ndash;&gt;-->
<!-- <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>-->
<!--&lt;!&ndash; </a-menu>&ndash;&gt;-->
<!--&lt;!&ndash; <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>&ndash;&gt;-->
<!--&lt;!&ndash; </a-dropdown>&ndash;&gt;-->
<!-- </div>-->
<!-- table区域-begin -->
<div>
<div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
<i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>
<a style="margin-left: 24px" @click="onClearSelected">清空</a>
</div>
<!-- <div>-->
<!-- <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">-->
<!-- <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项-->
<!-- <a style="margin-left: 24px" @click="onClearSelected">清空</a>-->
<!-- </div>-->
<a-table
ref="table"
......@@ -52,7 +70,8 @@
</template>
<template slot="imgSlot" slot-scope="text">
<span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
<img v-else :src="getImgView(text)" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
<img v-else :src="getImgView(text)" height="25px" alt=""
style="max-width:80px;font-size: 12px;font-style: italic;"/>
</template>
<template slot="fileSlot" slot-scope="text">
<span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
......@@ -67,27 +86,27 @@
</a-button>
</template>
<!-- <span slot="action" slot-scope="text, record">-->
<!-- <a @click="handleEdit(record)">编辑</a>-->
<!-- <span slot="action" slot-scope="text, record">-->
<!-- <a @click="handleEdit(record)">编辑</a>-->
<!-- <a-divider type="vertical" />-->
<!-- <a-dropdown>-->
<!-- <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>-->
<!-- <a-menu slot="overlay">-->
<!-- <a-menu-item>-->
<!-- <a @click="handleDetail(record)">详情</a>-->
<!-- </a-menu-item>-->
<!-- <a-menu-item>-->
<!-- <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">-->
<!-- <a>删除</a>-->
<!-- </a-popconfirm>-->
<!-- </a-menu-item>-->
<!-- </a-menu>-->
<!-- </a-dropdown>-->
<!-- </span>-->
<!-- <a-divider type="vertical" />-->
<!-- <a-dropdown>-->
<!-- <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>-->
<!-- <a-menu slot="overlay">-->
<!-- <a-menu-item>-->
<!-- <a @click="handleDetail(record)">详情</a>-->
<!-- </a-menu-item>-->
<!-- <a-menu-item>-->
<!-- <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">-->
<!-- <a>删除</a>-->
<!-- </a-popconfirm>-->
<!-- </a-menu-item>-->
<!-- </a-menu>-->
<!-- </a-dropdown>-->
<!-- </span>-->
</a-table>
</div>
<!-- </div>-->
<pm-event-info-modal ref="modalForm" @ok="modalFormOk"></pm-event-info-modal>
</a-card>
......@@ -95,65 +114,70 @@
<script>
import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import PmEventInfoModal from './modules/PmEventInfoModal'
import '@/assets/less/TableExpand.less'
import {mixinDevice} from '@/utils/mixin'
import {JeecgListMixin} from '@/mixins/JeecgListMixin'
import PmEventInfoModal from './modules/PmEventInfoModal'
export default {
export default {
name: 'PmEventInfoList',
mixins:[JeecgListMixin, mixinDevice],
mixins: [JeecgListMixin, mixinDevice],
components: {
PmEventInfoModal
},
data () {
data() {
return {
description: 'pm_event_info管理页面',
// 表头
columns: [
// {
// title: '#',
// dataIndex: '',
// key:'rowIndex',
// width:60,
// align:"center",
// customRender:function (t,r,index) {
// return parseInt(index)+1;
// }
// },
{
title: '#',
dataIndex: '',
key:'rowIndex',
width:60,
align:"center",
customRender:function (t,r,index) {
return parseInt(index)+1;
}
title: '类别',
align: "center",
dataIndex: 'eventCategory'
},
{
title:'事件类别',
align:"center",
dataIndex: 'eventCategory'
title: '源名称',
align: "center",
dataIndex: 'sourceName'
},
{
title:'日志ID',
align:"center",
title: '日志ID',
align: "center",
dataIndex: 'logId'
},
{
title:'事件状态',
align:"center",
title: '状态',
align: "center",
dataIndex: 'eventState'
},
{
title:'事件等级',
align:"center",
title: '等级',
align: "center",
dataIndex: 'eventLevel'
},
{
title:'控制中心编号',
align:"center",
title: '控制中心编号',
align: "center",
dataIndex: 'unitIdx'
},
{
title:'事件类型',
align:"center",
title: '类型',
align: "center",
dataIndex: 'eventType'
},
{
title:'事件类型名称',
align:"center",
title: '类型名称',
align: "center",
dataIndex: 'eventTypeName'
},
// {
......@@ -162,49 +186,44 @@
// dataIndex: 'subSysType'
// },
{
title:'事件名称',
align:"center",
title: '名称',
align: "center",
dataIndex: 'eventName'
},
{
title:'事件开始时间',
align:"center",
title: '开始时间',
align: "center",
dataIndex: 'startTime',
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:'事件结束时间',
align:"center",
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:'事件源编号',
align:"center",
title: '源编号',
align: "center",
dataIndex: 'sourceIdx'
},
{
title:'事件源类型',
align:"center",
title: '源类型',
align: "center",
dataIndex: 'sourceType'
},
{
title:'事件源名称',
align:"center",
dataIndex: 'sourceName'
},
{
title:'事件描述信息',
align:"center",
title: '描述信息',
align: "center",
dataIndex: 'logTxt'
},
{
title:'事件源区域编号',
align:"center",
title: '区域编号',
align: "center",
dataIndex: 'regionIdx'
},
......@@ -240,47 +259,51 @@
importExcelUrl: "pm/pmEventInfo/importExcel",
},
dictOptions:{},
superFieldList:[],
dictOptions: {},
superFieldList: [],
}
},
created() {
this.getSuperFieldList();
},
computed: {
importExcelUrl: function(){
importExcelUrl: function () {
return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
},
},
methods: {
initDictConfig(){
initDictConfig() {
},
getSuperFieldList(){
let fieldList=[];
fieldList.push({type:'string',value:'logId',text:'唯一标识一次发生的事件'})
fieldList.push({type:'string',value:'eventCategory',text:'事件类别'})
fieldList.push({type:'int',value:'eventState',text:'0:瞬时事件,保存;1:事件开始,保存;2:事件结束,更新结束时间; 3:事件脉冲,客户端和服务器使用,CMS 不用;4:事件更新,联动结果更新'})
fieldList.push({type:'int',value:'eventLevel',text:'0:普通事件;1:低级报警;2:中级报警;3:高级报警'})
fieldList.push({type:'string',value:'unitIdx',text:'控制中心编号'})
fieldList.push({type:'int',value:'eventType',text:'事件类型'})
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:'string',value:'sourceIdx',text:'事件源编号'})
fieldList.push({type:'int',value:'sourceType',text:'事件源类型'})
fieldList.push({type:'string',value:'sourceName',text:'事件源名称'})
fieldList.push({type:'string',value:'logTxt',text:'事件描述信息'})
fieldList.push({type:'string',value:'regionIdx',text:'事件源区域编号'})
fieldList.push({type:'string',value:'extInfo',text:'事件拓展信息:各个子系统根据子系统的消息结构体定义解析,下文主要介绍事件中此字段含义'})
fieldList.push({type:'string',value:'rsltMsg',text:'事件处理结果:当 event_state 为更新时使用'})
fieldList.push({type:'string',value:'trigInfo',text:'联动信息:目前包含客户端联动、预案'})
getSuperFieldList() {
let fieldList = [];
fieldList.push({type: 'string', value: 'logId', text: '唯一标识一次发生的事件'})
fieldList.push({type: 'string', value: 'eventCategory', text: '事件类别'})
fieldList.push({
type: 'int',
value: 'eventState',
text: '0:瞬时事件,保存;1:事件开始,保存;2:事件结束,更新结束时间; 3:事件脉冲,客户端和服务器使用,CMS 不用;4:事件更新,联动结果更新'
})
fieldList.push({type: 'int', value: 'eventLevel', text: '0:普通事件;1:低级报警;2:中级报警;3:高级报警'})
fieldList.push({type: 'string', value: 'unitIdx', text: '控制中心编号'})
fieldList.push({type: 'int', value: 'eventType', text: '事件类型'})
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: 'string', value: 'sourceIdx', text: '事件源编号'})
fieldList.push({type: 'int', value: 'sourceType', text: '事件源类型'})
fieldList.push({type: 'string', value: 'sourceName', text: '事件源名称'})
fieldList.push({type: 'string', value: 'logTxt', text: '事件描述信息'})
fieldList.push({type: 'string', value: 'regionIdx', text: '事件源区域编号'})
fieldList.push({type: 'string', value: 'extInfo', text: '事件拓展信息:各个子系统根据子系统的消息结构体定义解析,下文主要介绍事件中此字段含义'})
fieldList.push({type: 'string', value: 'rsltMsg', text: '事件处理结果:当 event_state 为更新时使用'})
fieldList.push({type: 'string', value: 'trigInfo', text: '联动信息:目前包含客户端联动、预案'})
this.superFieldList = fieldList
}
}
}
}
</script>
<style scoped>
@import '~@assets/less/common.less';
@import '~@assets/less/common.less';
</style>
\ No newline at end of file
......@@ -59,14 +59,14 @@ public class PmEventInfo implements Serializable {
*/
@Excel(name = "0:瞬时事件,保存;1:事件开始, 保存;2:事件结束,更新结束时间; 3:事件脉冲,客户端和服务器使用, CMS 不用;4:事件更新,联动结果更 新", width = 15)
@ApiModelProperty(value = "0:瞬时事件,保存;1:事件开始, 保存;2:事件结束,更新结束时间; 3:事件脉冲,客户端和服务器使用, CMS 不用;4:事件更新,联动结果更 新")
private Integer eventState;
private String eventState;
/**
* 0:普通事件;1:低级报警;2:中级
* 报警;3:高级报警
*/
@Excel(name = "0:普通事件;1:低级报警;2:中级 报警;3:高级报警", width = 15)
@ApiModelProperty(value = "0:普通事件;1:低级报警;2:中级 报警;3:高级报警")
private Integer eventLevel;
private String eventLevel;
/**
* 控制中心编号
*/
......
package org.jeecg.pm.entity.event.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author: JJww
* @Date:2022/4/6
*/
@Getter
@AllArgsConstructor
public enum EventLevel {
/**
* 普通事件
*/
ORDINARY(0, "普通事件"),
/**
* 低级报警
*/
LOW_LEVEL(1, "低级报警"),
/**
* 中级报警
*/
INTERMEDIATE(2, "中级报警"),
/**
* 高级报警
*/
SENIOR(3, "高级报警"),
UNKNOWN(9, "未知类型");
/**
* 状态码
*/
private final Integer level;
/**
* 状态说明
*/
private final String remark;
}
package org.jeecg.pm.entity.event.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author: JJww
* @Date:2022/4/6
*/
@Getter
@AllArgsConstructor
public enum EventState {
INSTANTANEOUS(0, "瞬时"),
START(1, "开始"),
STOP(2, "结束"),
PULSE(3, "脉冲"),
UPDATE(4, "更新"),
UNKNOWN(9, "未知类型");
/**
* 状态码
*/
private final Integer state;
/**
* 状态说明
*/
private final String remark;
}
package org.jeecg.pm.mq;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.pm.entity.eps.EventDis;
import org.jeecg.pm.entity.event.PmEventInfo;
import org.jeecg.pm.entity.event.enums.EventLevel;
import org.jeecg.pm.entity.event.enums.EventState;
import org.jeecg.pm.service.event.IPmEventInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;
import javax.jms.BytesMessage;
import java.util.Arrays;
/**
* @author: JJww
......@@ -40,12 +42,32 @@ public class EventMessageListener {
bytesMessage.readBytes(bytes);
// 壳文件字段,EventDis类为event_dis.proto文件解析而来,CommEventLog类为事件壳文件类
final EventDis.CommEventLog commEventLog = EventDis.CommEventLog.parseFrom(bytes);
PmEventInfo pmEventInfo = new PmEventInfo()
.setEventCategory(PmEventInfo.VSS)
.setId(IdWorker.getId())
final PmEventInfo pmEventInfo = this.recode(commEventLog);
pmEventInfo.setEventCategory(PmEventInfo.VSS);
pmEventInfoService.saveEvent(pmEventInfo);
log.info("VSS_TOPIC:{}", pmEventInfo);
}
@JmsListener(destination = EPS_TOPIC)
public void epsProcessMessage(BytesMessage bytesMessage) throws Exception {
final byte[] bytes = new byte[(int) bytesMessage.getBodyLength()];
bytesMessage.readBytes(bytes);
final EventDis.CommEventLog commEventLog = EventDis.CommEventLog.parseFrom(bytes);
final PmEventInfo pmEventInfo = this.recode(commEventLog);
pmEventInfo.setEventCategory(PmEventInfo.EPS);
pmEventInfoService.saveEvent(pmEventInfo);
log.info("EPS_TOPIC:{}", pmEventInfo);
}
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);
return new PmEventInfo()
.setLogId(commEventLog.getLogId())
.setEventState(commEventLog.getEventState())
.setEventLevel(commEventLog.getEventLevel())
.setEventState(eventState.getRemark())
.setEventLevel(eventLevel.getRemark())
.setUnitIdx(commEventLog.getUnitIdx())
.setEventType(commEventLog.getEventType())
.setEventTypeName(commEventLog.getEventTypeName())
......@@ -58,20 +80,6 @@ public class EventMessageListener {
.setSourceName(commEventLog.getSourceName())
.setLogTxt(commEventLog.getLogTxt())
.setRegionIdx(commEventLog.getRegionIdx())
.setExtInfo(commEventLog.getExtInfo().toString());
log.info(pmEventInfo.toString());
pmEventInfoService.save(pmEventInfo);
.setExtInfo(commEventLog.getExtInfo().toStringUtf8());
}
@JmsListener(destination = EPS_TOPIC)
public void epsProcessMessage(BytesMessage bytesMessage) throws Exception {
final byte[] bytes = new byte[(int) bytesMessage.getBodyLength()];
bytesMessage.readBytes(bytes);
// 壳文件字段,EventDis类为event_dis.proto文件解析而来,CommEventLog类为事件壳文件类
final EventDis.CommEventLog commEventLog = EventDis.CommEventLog.parseFrom(bytes);
// 扩展字段,此字段为设备上报事件内容,部分事件需要使用pb文件再次解析
System.out.println(commEventLog);
}
}
package org.jeecg.pm.service.event;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.pm.entity.eps.EventDis;
import org.jeecg.pm.entity.event.PmEventInfo;
/**
......@@ -11,4 +12,11 @@ import org.jeecg.pm.entity.event.PmEventInfo;
*/
public interface IPmEventInfoService extends IService<PmEventInfo> {
/**
* 保存事件
* @param pmEventInfo
*/
void saveEvent(PmEventInfo pmEventInfo);
}
package org.jeecg.pm.service.impl.event;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.pm.entity.event.PmEventInfo;
import org.jeecg.pm.mapper.event.PmEventInfoMapper;
import org.jeecg.pm.service.event.IPmEventInfoService;
......@@ -13,7 +16,21 @@ import org.springframework.stereotype.Service;
* @Date: 2022-04-01
* @Version: V1.0
*/
@Slf4j
@Service
public class PmEventInfoServiceImpl extends ServiceImpl<PmEventInfoMapper, PmEventInfo> implements IPmEventInfoService {
@Override
public void saveEvent(PmEventInfo pmEventInfo) {
final PmEventInfo eventInfo = baseMapper.selectOne(new QueryWrapper<PmEventInfo>().lambda().eq(PmEventInfo::getLogId, pmEventInfo.getLogId()));//事件唯一ID
if (eventInfo == null) {
pmEventInfo.setId(IdWorker.getId());
baseMapper.insert(pmEventInfo);
return;
}
eventInfo.setEventLevel(pmEventInfo.getEventLevel()).setEventState(pmEventInfo.getEventState()).setStopTime(pmEventInfo.getStopTime());
baseMapper.updateById(eventInfo);
}
}
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