Commit 96d7b661 by zhangjw

完善保存事件日志逻辑

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