Commit 709888e4 authored by 赵啸非's avatar 赵啸非

异常日志前端展示添加

parent aefa5c7d
...@@ -59,10 +59,10 @@ CREATE TABLE mortals_xhx_error_log( ...@@ -59,10 +59,10 @@ CREATE TABLE mortals_xhx_error_log(
`traceID` varchar(64) COMMENT '追踪Id', `traceID` varchar(64) COMMENT '追踪Id',
`appName` varchar(64) COMMENT '应用名称,宿主客户端运行唯一标识。', `appName` varchar(64) COMMENT '应用名称,宿主客户端运行唯一标识。',
`hostName` varchar(64) COMMENT '主机名', `hostName` varchar(64) COMMENT '主机名',
`message` varchar(256) COMMENT '消息标识,如用户登录异常。', `message` varchar(1024) COMMENT '消息标识,如用户登录异常。',
`platform` varchar(64) COMMENT '当前客户端使用平台(java,php,c#,android,vue,webos,ios,python)', `platform` varchar(64) COMMENT '当前客户端使用平台(java,php,c#,android,vue,webos,ios,python)',
`culprit` varchar(512) COMMENT '主要导致异常函数或方法调用名称', `culprit` varchar(2048) COMMENT '主要导致异常函数或方法调用名称及入参',
`tags` varchar(512) COMMENT '异常事件标记,多个逗号分隔。用以归集异常事件种类。', `tags` varchar(256) COMMENT '异常事件标记,多个逗号分隔。用以归集异常事件种类。',
`level` varchar(64) COMMENT '等级(FATAL,ERROR,WARNING,INFO,DEBUG)', `level` varchar(64) COMMENT '等级(FATAL,ERROR,WARNING,INFO,DEBUG)',
`environment` varchar(1024) COMMENT '客户端运行环境变量信息', `environment` varchar(1024) COMMENT '客户端运行环境变量信息',
`releaseVersion` varchar(64) COMMENT '客户端运行版本信息', `releaseVersion` varchar(64) COMMENT '客户端运行版本信息',
...@@ -75,10 +75,13 @@ CREATE TABLE mortals_xhx_error_log( ...@@ -75,10 +75,13 @@ CREATE TABLE mortals_xhx_error_log(
`logTime` datetime COMMENT '日志时间', `logTime` datetime COMMENT '日志时间',
`createUserId` bigint(20) COMMENT '创建用户', `createUserId` bigint(20) COMMENT '创建用户',
`createTime` datetime NOT NULL COMMENT '创建时间', `createTime` datetime NOT NULL COMMENT '创建时间',
`updateTime` datetime COMMENT '更新时间',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='异常日志'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='异常日志';
-- ---------------------------- -- ----------------------------
-- 平台用户操作日志业务表 -- 平台用户操作日志业务表
-- ---------------------------- -- ----------------------------
......
...@@ -21,8 +21,8 @@ ...@@ -21,8 +21,8 @@
<Field label="线程号" prop="threadNo" v-model="form.threadNo" placeholder="请输入线程号"/> <Field label="线程号" prop="threadNo" v-model="form.threadNo" placeholder="请输入线程号"/>
<Field label="异常事件数量" prop="checkNum" v-model="form.checkNum" placeholder="请输入针对同一个异常事件,数量加1"/> <Field label="异常事件数量" prop="checkNum" v-model="form.checkNum" placeholder="请输入针对同一个异常事件,数量加1"/>
<Field label="日志时间" prop="logTime" v-model="form.logTime" type="date" /> <Field label="日志时间" prop="logTime" v-model="form.logTime" type="date" />
<Field label="异常堆栈信息" :span="24" prop="errorStack" v-model="form.errorStack" rows="6" type="textarea" placeholder="请输入异常堆栈信息"/> <Field label="异常堆栈信息" :span="24" prop="errorStack" v-model="form.errorStack" rows="8" type="textarea" placeholder="请输入异常堆栈信息"/>
<Field label="上下文信息" :span="24" prop="context" v-model="form.context" type="textarea" placeholder="请输入上下文信息,如js中发送异常事件,定位源码中信息。"/> <Field label="上下文信息" :span="24" prop="context" v-model="form.context" type="textarea" rows="6" placeholder="请输入上下文信息,如js中发送异常事件,定位源码中信息。"/>
<Field label="扩展信息" :span="24" prop="extra" v-model="form.extra" type="textarea" placeholder="请输入扩展信息"/> <Field label="扩展信息" :span="24" prop="extra" v-model="form.extra" type="textarea" placeholder="请输入扩展信息"/>
...@@ -34,6 +34,9 @@ ...@@ -34,6 +34,9 @@
<script> <script>
import form from "@/assets/mixins/formdialog"; import form from "@/assets/mixins/formdialog";
// import hljs from "highlight.js/lib/highlight";
// import "highlight.js/styles/github-gist.css";
// hljs.registerLanguage("java", require("highlight.js/lib/languages/java"));
export default { export default {
name: "ErrorLogDetail", name: "ErrorLogDetail",
mixins: [form], mixins: [form],
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
<drawer-show ref="drawerform" @ok="getData" /> <drawer-show ref="drawerform" @ok="getData" />
<drawer-view ref="drawerview" @ok="getData" />
</div> </div>
</template> </template>
...@@ -12,11 +14,13 @@ ...@@ -12,11 +14,13 @@
/** 表单弹出框模式需引入 */ /** 表单弹出框模式需引入 */
import drawerShow from "./drawershow"; import drawerShow from "./drawershow";
import drawerView from "./view";
import table from "@/assets/mixins/table"; import table from "@/assets/mixins/table";
export default { export default {
name: "ErrorLogList", name: "ErrorLogList",
components: { components: {
drawerShow drawerShow,drawerView
}, },
mixins: [table], mixins: [table],
created() { created() {
...@@ -32,7 +36,7 @@ ...@@ -32,7 +36,7 @@
}, },
/** 重写查看方法 */ /** 重写查看方法 */
toView(row) { toView(row) {
this.$refs.drawerform.view(row); this.$refs.drawerview.view(row);
}, },
}, },
...@@ -61,9 +65,9 @@ ...@@ -61,9 +65,9 @@
{label: "应用名称", prop: "appName"}, {label: "应用名称", prop: "appName"},
{label: "主机名", prop: "hostName"}, // {label: "主机名", prop: "hostName"},
{label: "消息标识", prop: "message"}, {label: "消息标识", prop: "message" ,tooltip:"true"},
{label: "当前客户端使用平台", prop: "platform",formatter:this.formatter}, {label: "当前客户端使用平台", prop: "platform",formatter:this.formatter},
......
<template> <template>
<layout-view> <layout-view>
<el-descriptions :title="title" :column="column" :size="size" :colon="false" border> <el-drawer
<template slot="title"> :title="title"
<i class="el-icon-tickets"></i> :visible.sync="open"
基本详细信息 :direction="direction"
</template> size="75%">
<template slot="extra"> <el-descriptions :column="column" :size="size" :colon="false" border>
<el-button type="primary" @click="$router.go(-1)" size="small">返回</el-button> <el-descriptions-item label="TraceId" label-class-name="labelClass" content-class-name="contentClass">
</template>
<el-descriptions-item label="追踪Id" label-class-name="labelClass" content-class-name="contentClass">
{{form.traceID}} {{form.traceID}}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label="应用名称,宿主客户端运行唯一标识。" label-class-name="labelClass" content-class-name="contentClass"> <el-descriptions-item label="应用标识" label-class-name="labelClass" content-class-name="contentClass">
{{form.appName}} {{form.appName}}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label="主机名" label-class-name="labelClass" content-class-name="contentClass"> <!-- <el-descriptions-item label="主机名" label-class-name="labelClass" content-class-name="contentClass">
{{form.hostName}} {{form.hostName}}
</el-descriptions-item> </el-descriptions-item> -->
<el-descriptions-item label="消息标识,如用户登录异常。" label-class-name="labelClass" content-class-name="contentClass"> <el-descriptions-item label="消息标识" label-class-name="labelClass" content-class-name="contentClass">
{{form.message}} {{form.message}}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label="当前客户端使用平台" label-class-name="labelClass" content-class-name="contentClass"> <el-descriptions-item label="所属平台" label-class-name="labelClass" content-class-name="contentClass">
{{ util_formatters("platform", form.platform) }} {{ form.platform }}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label="主要导致异常函数或方法调用名称" label-class-name="labelClass" content-class-name="contentClass"> <el-descriptions-item label="函数调用名称" label-class-name="labelClass" content-class-name="contentClass">
{{form.culprit}} {{form.culprit}}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label="异常事件标记,多个逗号分隔。用以归集异常事件种类。" label-class-name="labelClass" content-class-name="contentClass"> <el-descriptions-item label="异常事件标记" label-class-name="labelClass" content-class-name="contentClass">
{{form.tags}} {{form.tags}}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label="等级" label-class-name="labelClass" content-class-name="contentClass"> <el-descriptions-item label="告警等级" label-class-name="labelClass" content-class-name="contentClass">
{{ util_formatters("level", form.level) }} {{form.level}}
</el-descriptions-item>
<el-descriptions-item label="客户端运行环境变量信息" label-class-name="labelClass" content-class-name="contentClass">
{{form.environment}}
</el-descriptions-item>
<el-descriptions-item label="客户端运行版本信息" label-class-name="labelClass" content-class-name="contentClass">
{{form.releaseVersion}}
</el-descriptions-item>
<el-descriptions-item label="指纹标识,对于相同异常事件归集数量使用。" label-class-name="labelClass" content-class-name="contentClass">
{{form.fingerprint}}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label="线程号" label-class-name="labelClass" content-class-name="contentClass"> <el-descriptions-item label="线程号" label-class-name="labelClass" content-class-name="contentClass">
{{form.threadNo}} {{form.threadNo}}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label="针对同一个异常事件,数量加1" label-class-name="labelClass" content-class-name="contentClass">
{{form.checkNum}}
</el-descriptions-item>
<el-descriptions-item label="异常堆栈信息" label-class-name="labelClass" content-class-name="contentClass"> <el-descriptions-item label="异常堆栈信息" label-class-name="labelClass" content-class-name="contentClass">
{{form.errorStack}} {{form.errorStack}}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label="上下文信息,如js中发送异常事件,定位源码中信息。" label-class-name="labelClass" content-class-name="contentClass"> <el-descriptions-item label="上下文信息" label-class-name="labelClass" content-class-name="contentClass">
{{form.context}} {{form.context}}
</el-descriptions-item>
<el-descriptions-item label="环境变量" label-class-name="labelClass" content-class-name="contentClass">
{{form.environment}}
</el-descriptions-item>
<el-descriptions-item label="版本信息" label-class-name="labelClass" content-class-name="contentClass">
{{form.releaseVersion}}
</el-descriptions-item>
<el-descriptions-item label="指纹标识" label-class-name="labelClass" content-class-name="contentClass">
{{form.fingerprint}}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label="扩展信息" label-class-name="labelClass" content-class-name="contentClass"> <el-descriptions-item label="扩展信息" label-class-name="labelClass" content-class-name="contentClass">
{{form.extra}} {{form.extra}}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label="异常事件数量" label-class-name="labelClass" content-class-name="contentClass">
{{form.checkNum}}
</el-descriptions-item>
<el-descriptions-item label="日志时间" label-class-name="labelClass" content-class-name="contentClass"> <el-descriptions-item label="日志时间" label-class-name="labelClass" content-class-name="contentClass">
{{ util_formatterDate(form.logTime)}} {{form.logTime}}
</el-descriptions-item> </el-descriptions-item>
</el-descriptions> </el-descriptions>
</el-drawer>
</layout-view> </layout-view>
</template> </template>
<script> <script>
import view from "@/assets/mixins/view"; import view from "@/assets/mixins/view";
import formatterDate from "@/assets/utils/index.js";
export default { export default {
mixins: [view], mixins: [view],
components: { components: {
}, },
methods: { methods: {
formatterDate,
/** 查看*/
view(row) {
this.query = { id: row.id };
this.urls.currUrl ="error/log/view";
this.getData();
this.pageInfo.type="view"
this.title = "异常日志详细";
},
/**获取数据后弹框 */
afterRender(data) {
this.open = true;
},
}, },
data() { data() {
return { return {
size:"small", size:"small",
column:2, column:1,
loading: true,
// 弹出层标题
title: "异常日志",
// 是否显示弹出层
open: false,
direction:"rtl",
toString:[ toString:[
], ],
toArrays: [ toArrays: [
], ],
toDate: [ toDate:[
"logTime",
] ],
} }
} }
} }
</script> </script>
<style lang="less"> <style lang="less">
.labelClass{ .labelClass{
width: 200px; width: 250px;
font-size: 13px;
}
.el-descriptions-item__label{
color: #191a1b;
} }
.el-descriptions__body{ .el-descriptions__body{
margin-left: 5px; margin-left: 5px;
margin-right: 5px; margin-right: 5px;
color: #606266; color: #191a1b;
background-color: #FFF; background-color: #FFF;
} }
.contentClass{ .contentClass{
width: 600px; width: 500px;
} }
</style> </style>
\ No newline at end of file
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
{label: "请求地址", prop: "requestUrl"}, {label: "请求地址", prop: "requestUrl"},
{label: "操作内容", prop: "content"}, {label: "操作内容", prop: "content",tooltip:"true"},
{label: "操作IP地址", prop: "ip"}, {label: "操作IP地址", prop: "ip"},
......
...@@ -6,6 +6,7 @@ import com.mortals.xhx.module.access.model.AccessLogEntity; ...@@ -6,6 +6,7 @@ import com.mortals.xhx.module.access.model.AccessLogEntity;
import com.mortals.xhx.module.biz.model.BizLogEntity; import com.mortals.xhx.module.biz.model.BizLogEntity;
import com.mortals.xhx.module.biz.service.BizLogService; import com.mortals.xhx.module.biz.service.BizLogService;
import com.mortals.xhx.module.error.model.ErrorLogEntity; import com.mortals.xhx.module.error.model.ErrorLogEntity;
import com.mortals.xhx.module.error.model.ErrorLogQuery;
import com.mortals.xhx.module.error.service.ErrorLogService; import com.mortals.xhx.module.error.service.ErrorLogService;
import com.rabbitmq.client.Channel; import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -15,6 +16,7 @@ import org.springframework.amqp.support.AmqpHeaders; ...@@ -15,6 +16,7 @@ import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.Headers; import org.springframework.messaging.handler.annotation.Headers;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -41,12 +43,31 @@ public class ErrorMessageConsumerListener { ...@@ -41,12 +43,31 @@ public class ErrorMessageConsumerListener {
public void onMessage(List<String> messages) throws Exception { public void onMessage(List<String> messages) throws Exception {
log.info("[onMessage][线程编号:{} 消息数量:{}]", Thread.currentThread().getId(), messages.size()); log.info("[onMessage][线程编号:{} 消息数量:{}]", Thread.currentThread().getId(), messages.size());
List<ErrorLogEntity> collect = messages.stream().map(str -> { messages.stream().peek(str -> {
ErrorLogEntity entity = JSON.parseObject(str, ErrorLogEntity.class); ErrorLogEntity entity = JSON.parseObject(str, ErrorLogEntity.class);
entity.setCreateUserId(1L); entity.setCreateUserId(1L);
entity.setCreateTime(new Date()); entity.setCreateTime(new Date());
return entity;
}).collect(Collectors.toList()); if (!ObjectUtils.isEmpty(entity.getFingerprint())) {
errorLogService.save(collect); //// TODO: 2022/8/24 指纹匹配
} else {
//比较message platform appname 如果相同 则checknum+1 并更新日志时间
ErrorLogQuery errorLogQuery = new ErrorLogQuery();
errorLogQuery.setAppName(entity.getAppName());
errorLogQuery.setPlatform(entity.getPlatform());
errorLogQuery.setMessage(entity.getMessage());
ErrorLogEntity errorLogEntity = errorLogService.selectOne(errorLogQuery, null);
if (!ObjectUtils.isEmpty(errorLogEntity)) {
errorLogEntity.setCheckNum(errorLogEntity.getCheckNum()+1);
errorLogEntity.setLogTime(entity.getLogTime());
errorLogEntity.setThreadNo(entity.getThreadNo());
errorLogEntity.setUpdateTime(new Date());
errorLogService.update(errorLogEntity);
} else {
errorLogService.save(entity);
}
}
}).count();
} }
} }
package com.mortals.xhx.module.error.dao.ibatis; package com.mortals.xhx.module.error.dao.ibatis;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import com.mortals.xhx.module.error.dao.ErrorLogDao; import com.mortals.xhx.module.error.dao.ErrorLogDao;
import com.mortals.xhx.module.error.model.ErrorLogEntity; import com.mortals.xhx.module.error.model.ErrorLogEntity;
...@@ -48,4 +50,15 @@ public class ErrorLogDaoImpl extends SubmeterDaoImpl<ErrorLogEntity,Long> implem ...@@ -48,4 +50,15 @@ public class ErrorLogDaoImpl extends SubmeterDaoImpl<ErrorLogEntity,Long> implem
@Override
public ErrorLogEntity get(Long id) {
ErrorLogEntity errorLogEntity = new ErrorLogEntity();
Snowflake snowflake = IdUtil.getSnowflake(0, 1);
long generateDateTime = snowflake.getGenerateDateTime(id);
errorLogEntity.setCreateTime(new Date(generateDateTime));
return this.get(id,errorLogEntity);
}
} }
...@@ -8,11 +8,11 @@ import com.mortals.framework.annotation.Excel; ...@@ -8,11 +8,11 @@ import com.mortals.framework.annotation.Excel;
import com.mortals.framework.model.BaseEntityLong; import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.error.model.vo.ErrorLogVo; import com.mortals.xhx.module.error.model.vo.ErrorLogVo;
/** /**
* 异常日志实体对象 * 异常日志实体对象
* *
* @author zxfei * @author zxfei
* @date 2022-08-24 * @date 2022-08-24
*/ */
public class ErrorLogEntity extends ErrorLogVo { public class ErrorLogEntity extends ErrorLogVo {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -38,7 +38,7 @@ public class ErrorLogEntity extends ErrorLogVo { ...@@ -38,7 +38,7 @@ public class ErrorLogEntity extends ErrorLogVo {
*/ */
private String platform; private String platform;
/** /**
* 主要导致异常函数或方法调用名称 * 主要导致异常函数或方法调用名称及入参
*/ */
private String culprit; private String culprit;
/** /**
...@@ -160,14 +160,14 @@ public class ErrorLogEntity extends ErrorLogVo { ...@@ -160,14 +160,14 @@ public class ErrorLogEntity extends ErrorLogVo {
this.platform = platform; this.platform = platform;
} }
/** /**
* 获取 主要导致异常函数或方法调用名称 * 获取 主要导致异常函数或方法调用名称及入参
* @return String * @return String
*/ */
public String getCulprit(){ public String getCulprit(){
return culprit; return culprit;
} }
/** /**
* 设置 主要导致异常函数或方法调用名称 * 设置 主要导致异常函数或方法调用名称及入参
* @param culprit * @param culprit
*/ */
public void setCulprit(String culprit){ public void setCulprit(String culprit){
...@@ -395,7 +395,7 @@ public class ErrorLogEntity extends ErrorLogVo { ...@@ -395,7 +395,7 @@ public class ErrorLogEntity extends ErrorLogVo {
this.threadNo = ""; this.threadNo = "";
this.checkNum = null; this.checkNum = 1;
this.errorStack = ""; this.errorStack = "";
...@@ -403,6 +403,6 @@ public class ErrorLogEntity extends ErrorLogVo { ...@@ -403,6 +403,6 @@ public class ErrorLogEntity extends ErrorLogVo {
this.extra = ""; this.extra = "";
this.logTime = null; this.logTime = new Date();
} }
} }
\ No newline at end of file
...@@ -4,11 +4,11 @@ import java.util.Date; ...@@ -4,11 +4,11 @@ import java.util.Date;
import java.util.List; import java.util.List;
import com.mortals.xhx.module.error.model.ErrorLogEntity; import com.mortals.xhx.module.error.model.ErrorLogEntity;
/** /**
* 异常日志查询对象 * 异常日志查询对象
* *
* @author zxfei * @author zxfei
* @date 2022-08-24 * @date 2022-08-24
*/ */
public class ErrorLogQuery extends ErrorLogEntity { public class ErrorLogQuery extends ErrorLogEntity {
/** 开始 主键ID */ /** 开始 主键ID */
private Long idStart; private Long idStart;
...@@ -37,7 +37,7 @@ public class ErrorLogQuery extends ErrorLogEntity { ...@@ -37,7 +37,7 @@ public class ErrorLogQuery extends ErrorLogEntity {
/** 当前客户端使用平台(java,php,c#,android,vue,webos,ios,python) */ /** 当前客户端使用平台(java,php,c#,android,vue,webos,ios,python) */
private List<String> platformList; private List<String> platformList;
/** 主要导致异常函数或方法调用名称 */ /** 主要导致异常函数或方法调用名称及入参 */
private List<String> culpritList; private List<String> culpritList;
/** 异常事件标记,多个逗号分隔。用以归集异常事件种类。 */ /** 异常事件标记,多个逗号分隔。用以归集异常事件种类。 */
...@@ -103,6 +103,12 @@ public class ErrorLogQuery extends ErrorLogEntity { ...@@ -103,6 +103,12 @@ public class ErrorLogQuery extends ErrorLogEntity {
/** 结束 创建时间 */ /** 结束 创建时间 */
private String createTimeEnd; private String createTimeEnd;
/** 开始 更新时间 */
private String updateTimeStart;
/** 结束 更新时间 */
private String updateTimeEnd;
/** OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4) */ /** OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4) */
private List<ErrorLogQuery> orConditionList; private List<ErrorLogQuery> orConditionList;
...@@ -251,7 +257,7 @@ public class ErrorLogQuery extends ErrorLogEntity { ...@@ -251,7 +257,7 @@ public class ErrorLogQuery extends ErrorLogEntity {
this.platformList = platformList; this.platformList = platformList;
} }
/** /**
* 获取 主要导致异常函数或方法调用名称 * 获取 主要导致异常函数或方法调用名称及入参
* @return culpritList * @return culpritList
*/ */
public List<String> getCulpritList(){ public List<String> getCulpritList(){
...@@ -259,7 +265,7 @@ public class ErrorLogQuery extends ErrorLogEntity { ...@@ -259,7 +265,7 @@ public class ErrorLogQuery extends ErrorLogEntity {
} }
/** /**
* 设置 主要导致异常函数或方法调用名称 * 设置 主要导致异常函数或方法调用名称及入参
* @param culpritList * @param culpritList
*/ */
public void setCulpritList(List<String> culpritList){ public void setCulpritList(List<String> culpritList){
...@@ -592,6 +598,38 @@ public class ErrorLogQuery extends ErrorLogEntity { ...@@ -592,6 +598,38 @@ public class ErrorLogQuery extends ErrorLogEntity {
this.createTimeEnd = createTimeEnd; this.createTimeEnd = createTimeEnd;
} }
/**
* 获取 开始 更新时间
* @return updateTimeStart
*/
public String getUpdateTimeStart(){
return this.updateTimeStart;
}
/**
* 设置 开始 更新时间
* @param updateTimeStart
*/
public void setUpdateTimeStart(String updateTimeStart){
this.updateTimeStart = updateTimeStart;
}
/**
* 获取 结束 更新时间
* @return updateTimeEnd
*/
public String getUpdateTimeEnd(){
return this.updateTimeEnd;
}
/**
* 设置 结束 更新时间
* @param updateTimeEnd
*/
public void setUpdateTimeEnd(String updateTimeEnd){
this.updateTimeEnd = updateTimeEnd;
}
/** /**
* 设置 主键ID * 设置 主键ID
* @param id * @param id
...@@ -734,7 +772,7 @@ public class ErrorLogQuery extends ErrorLogEntity { ...@@ -734,7 +772,7 @@ public class ErrorLogQuery extends ErrorLogEntity {
/** /**
* 设置 主要导致异常函数或方法调用名称 * 设置 主要导致异常函数或方法调用名称及入参
* @param culprit * @param culprit
*/ */
public ErrorLogQuery culprit(String culprit){ public ErrorLogQuery culprit(String culprit){
...@@ -743,7 +781,7 @@ public class ErrorLogQuery extends ErrorLogEntity { ...@@ -743,7 +781,7 @@ public class ErrorLogQuery extends ErrorLogEntity {
} }
/** /**
* 设置 主要导致异常函数或方法调用名称 * 设置 主要导致异常函数或方法调用名称及入参
* @param culpritList * @param culpritList
*/ */
public ErrorLogQuery culpritList(List<String> culpritList){ public ErrorLogQuery culpritList(List<String> culpritList){
...@@ -1014,6 +1052,7 @@ public class ErrorLogQuery extends ErrorLogEntity { ...@@ -1014,6 +1052,7 @@ public class ErrorLogQuery extends ErrorLogEntity {
} }
/** /**
* 获取 OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4) * 获取 OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4)
* @return orConditionList * @return orConditionList
......
...@@ -2,6 +2,7 @@ package com.mortals.xhx.module.error.service.impl; ...@@ -2,6 +2,7 @@ package com.mortals.xhx.module.error.service.impl;
import cn.hutool.core.lang.Snowflake; import cn.hutool.core.lang.Snowflake;
import com.mortals.xhx.module.access.model.AccessLogEntity; import com.mortals.xhx.module.access.model.AccessLogEntity;
import com.mortals.xhx.module.error.model.ErrorLogQuery;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl; import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
...@@ -10,6 +11,7 @@ import com.mortals.xhx.module.error.dao.ErrorLogDao; ...@@ -10,6 +11,7 @@ import com.mortals.xhx.module.error.dao.ErrorLogDao;
import com.mortals.xhx.module.error.model.ErrorLogEntity; import com.mortals.xhx.module.error.model.ErrorLogEntity;
import com.mortals.xhx.module.error.service.ErrorLogService; import com.mortals.xhx.module.error.service.ErrorLogService;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import org.springframework.util.ObjectUtils;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -25,8 +27,16 @@ import java.util.List; ...@@ -25,8 +27,16 @@ import java.util.List;
public class ErrorLogServiceImpl extends AbstractCRUDServiceImpl<ErrorLogDao, ErrorLogEntity, Long> implements ErrorLogService { public class ErrorLogServiceImpl extends AbstractCRUDServiceImpl<ErrorLogDao, ErrorLogEntity, Long> implements ErrorLogService {
@Override @Override
protected void saveBefore(ErrorLogEntity entity, Context context) throws AppException { protected void saveBefore(ErrorLogEntity entity, Context context) throws AppException {
//判断当前是否有重复的
//非系统自增,需这里设置主键 //非系统自增,需这里设置主键
entity.setId(IdUtil.getSnowflake(0, 1).nextId()); entity.setId(IdUtil.getSnowflake(0, 1).nextId());
super.saveBefore(entity, context); super.saveBefore(entity, context);
} }
...@@ -38,12 +48,5 @@ public class ErrorLogServiceImpl extends AbstractCRUDServiceImpl<ErrorLogDao, Er ...@@ -38,12 +48,5 @@ public class ErrorLogServiceImpl extends AbstractCRUDServiceImpl<ErrorLogDao, Er
return super.save(list, context); return super.save(list, context);
} }
@Override
public ErrorLogEntity get(Long key, Context context) throws AppException {
ErrorLogEntity errorLogEntity = new ErrorLogEntity();
Snowflake snowflake = IdUtil.getSnowflake(0, 1);
long generateDateTime = snowflake.getGenerateDateTime(key);
errorLogEntity.setCreateTime(new Date(generateDateTime));
return this.getDao().get(key,errorLogEntity);
}
} }
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"mybatis-3-mapper.dtd"> "mybatis-3-mapper.dtd">
<mapper namespace="com.mortals.xhx.module.error.dao.ibatis.ErrorLogDaoImpl"> <mapper namespace="com.mortals.xhx.module.error.dao.ibatis.ErrorLogDaoImpl">
<!-- 字段和属性映射 --> <!-- 字段和属性映射 -->
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
<result property="logTime" column="logTime" /> <result property="logTime" column="logTime" />
<result property="createUserId" column="createUserId" /> <result property="createUserId" column="createUserId" />
<result property="createTime" column="createTime" /> <result property="createTime" column="createTime" />
<result property="updateTime" column="updateTime" />
</resultMap> </resultMap>
...@@ -34,10 +35,10 @@ ...@@ -34,10 +35,10 @@
`traceID` varchar(64) COMMENT '追踪Id', `traceID` varchar(64) COMMENT '追踪Id',
`appName` varchar(64) COMMENT '应用名称,宿主客户端运行唯一标识。', `appName` varchar(64) COMMENT '应用名称,宿主客户端运行唯一标识。',
`hostName` varchar(64) COMMENT '主机名', `hostName` varchar(64) COMMENT '主机名',
`message` varchar(256) COMMENT '消息标识,如用户登录异常。', `message` varchar(1024) COMMENT '消息标识,如用户登录异常。',
`platform` varchar(64) COMMENT '当前客户端使用平台(java,php,c#,android,vue,webos,ios,python)', `platform` varchar(64) COMMENT '当前客户端使用平台(java,php,c#,android,vue,webos,ios,python)',
`culprit` varchar(512) COMMENT '主要导致异常函数或方法调用名称', `culprit` varchar(2048) COMMENT '主要导致异常函数或方法调用名称及入参',
`tags` varchar(512) COMMENT '异常事件标记,多个逗号分隔。用以归集异常事件种类。', `tags` varchar(256) COMMENT '异常事件标记,多个逗号分隔。用以归集异常事件种类。',
`level` varchar(64) COMMENT '等级(FATAL,ERROR,WARNING,INFO,DEBUG)', `level` varchar(64) COMMENT '等级(FATAL,ERROR,WARNING,INFO,DEBUG)',
`environment` varchar(1024) COMMENT '客户端运行环境变量信息', `environment` varchar(1024) COMMENT '客户端运行环境变量信息',
`releaseVersion` varchar(64) COMMENT '客户端运行版本信息', `releaseVersion` varchar(64) COMMENT '客户端运行版本信息',
...@@ -50,6 +51,7 @@ ...@@ -50,6 +51,7 @@
`logTime` datetime COMMENT '日志时间', `logTime` datetime COMMENT '日志时间',
`createUserId` bigint(20) COMMENT '创建用户', `createUserId` bigint(20) COMMENT '创建用户',
`createTime` datetime NOT NULL COMMENT '创建时间', `createTime` datetime NOT NULL COMMENT '创建时间',
`updateTime` datetime COMMENT '更新时间',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='异常日志'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='异常日志';
</update> </update>
...@@ -117,23 +119,26 @@ ...@@ -117,23 +119,26 @@
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('createTime') or colPickMode == 1 and data.containsKey('createTime')))"> <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('createTime') or colPickMode == 1 and data.containsKey('createTime')))">
a.createTime, a.createTime,
</if> </if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('updateTime') or colPickMode == 1 and data.containsKey('updateTime')))">
a.updateTime,
</if>
</trim> </trim>
</sql> </sql>
<!-- 新增 区分主键自增加还是业务插入 --> <!-- 新增 区分主键自增加还是业务插入 -->
<insert id="insert" parameterType="ErrorLogEntity" > <insert id="insert" parameterType="ErrorLogEntity" >
insert into `${tableName}` insert into `${tableName}`
(id,traceID,appName,hostName,message,platform,culprit,tags,level,environment,releaseVersion,fingerprint,threadNo,checkNum,errorStack,context,extra,logTime,createUserId,createTime) (id,traceID,appName,hostName,message,platform,culprit,tags,level,environment,releaseVersion,fingerprint,threadNo,checkNum,errorStack,context,extra,logTime,createUserId,createTime,updateTime)
VALUES VALUES
(#{id},#{traceID},#{appName},#{hostName},#{message},#{platform},#{culprit},#{tags},#{level},#{environment},#{releaseVersion},#{fingerprint},#{threadNo},#{checkNum},#{errorStack},#{context},#{extra},#{logTime},#{createUserId},#{createTime}) (#{id},#{traceID},#{appName},#{hostName},#{message},#{platform},#{culprit},#{tags},#{level},#{environment},#{releaseVersion},#{fingerprint},#{threadNo},#{checkNum},#{errorStack},#{context},#{extra},#{logTime},#{createUserId},#{createTime},#{updateTime})
</insert> </insert>
<!-- 批量新增 --> <!-- 批量新增 -->
<insert id="insertBatch" parameterType="paramDto"> <insert id="insertBatch" parameterType="paramDto">
insert into `${tableName}` insert into `${tableName}`
(id,traceID,appName,hostName,message,platform,culprit,tags,level,environment,releaseVersion,fingerprint,threadNo,checkNum,errorStack,context,extra,logTime,createUserId,createTime) (id,traceID,appName,hostName,message,platform,culprit,tags,level,environment,releaseVersion,fingerprint,threadNo,checkNum,errorStack,context,extra,logTime,createUserId,createTime,updateTime)
VALUES VALUES
<foreach collection="data.dataList" item="item" index="index" separator="," > <foreach collection="data.dataList" item="item" index="index" separator="," >
(#{item.id},#{item.traceID},#{item.appName},#{item.hostName},#{item.message},#{item.platform},#{item.culprit},#{item.tags},#{item.level},#{item.environment},#{item.releaseVersion},#{item.fingerprint},#{item.threadNo},#{item.checkNum},#{item.errorStack},#{item.context},#{item.extra},#{item.logTime},#{item.createUserId},#{item.createTime}) (#{item.id},#{item.traceID},#{item.appName},#{item.hostName},#{item.message},#{item.platform},#{item.culprit},#{item.tags},#{item.level},#{item.environment},#{item.releaseVersion},#{item.fingerprint},#{item.threadNo},#{item.checkNum},#{item.errorStack},#{item.context},#{item.extra},#{item.logTime},#{item.createUserId},#{item.createTime},#{item.updateTime})
</foreach> </foreach>
</insert> </insert>
...@@ -206,6 +211,9 @@ ...@@ -206,6 +211,9 @@
<if test="(colPickMode==0 and data.containsKey('createTime')) or (colPickMode==1 and !data.containsKey('createTime'))"> <if test="(colPickMode==0 and data.containsKey('createTime')) or (colPickMode==1 and !data.containsKey('createTime'))">
a.createTime=#{data.createTime}, a.createTime=#{data.createTime},
</if> </if>
<if test="(colPickMode==0 and data.containsKey('updateTime')) or (colPickMode==1 and !data.containsKey('updateTime'))">
a.updateTime=#{data.updateTime},
</if>
</trim> </trim>
<trim suffixOverrides="where" suffix=""> <trim suffixOverrides="where" suffix="">
where where
...@@ -361,6 +369,13 @@ ...@@ -361,6 +369,13 @@
</if> </if>
</foreach> </foreach>
</trim> </trim>
<trim prefix="updateTime=(case" suffix="ELSE updateTime end),">
<foreach collection="data.dataList" item="item" index="index" separator="" >
<if test="(colPickMode==0 and item.containsKey('updateTime')) or (colPickMode==1 and !item.containsKey('updateTime'))">
when a.id=#{item.id} then #{item.updateTime}
</if>
</foreach>
</trim>
</trim> </trim>
where id in where id in
<foreach collection="data.dataList" item="item" index="index" open="(" separator="," close=")"> <foreach collection="data.dataList" item="item" index="index" open="(" separator="," close=")">
...@@ -780,6 +795,21 @@ ...@@ -780,6 +795,21 @@
<if test="conditionParamRef.containsKey('createTimeEnd') and conditionParamRef.createTimeEnd != null and conditionParamRef.createTimeEnd!=''"> <if test="conditionParamRef.containsKey('createTimeEnd') and conditionParamRef.createTimeEnd != null and conditionParamRef.createTimeEnd!=''">
${_conditionType_} a.createTime <![CDATA[ <= ]]> STR_TO_DATE(left(concat(#{${_conditionParam_}.createTimeEnd},' 23:59:59'),19),'%Y-%m-%d %k:%i:%s') ${_conditionType_} a.createTime <![CDATA[ <= ]]> STR_TO_DATE(left(concat(#{${_conditionParam_}.createTimeEnd},' 23:59:59'),19),'%Y-%m-%d %k:%i:%s')
</if> </if>
<if test="conditionParamRef.containsKey('updateTime')">
<if test="conditionParamRef.updateTime != null ">
${_conditionType_} a.updateTime = #{${_conditionParam_}.updateTime}
</if>
<if test="conditionParamRef.updateTime == null">
${_conditionType_} a.updateTime is null
</if>
</if>
<if test="conditionParamRef.containsKey('updateTimeStart') and conditionParamRef.updateTimeStart != null and conditionParamRef.updateTimeStart!=''">
${_conditionType_} a.updateTime <![CDATA[ >= ]]> STR_TO_DATE(left(concat(#{${_conditionParam_}.updateTimeStart},' 00:00:00'),19),'%Y-%m-%d %k:%i:%s')
</if>
<if test="conditionParamRef.containsKey('updateTimeEnd') and conditionParamRef.updateTimeEnd != null and conditionParamRef.updateTimeEnd!=''">
${_conditionType_} a.updateTime <![CDATA[ <= ]]> STR_TO_DATE(left(concat(#{${_conditionParam_}.updateTimeEnd},' 23:59:59'),19),'%Y-%m-%d %k:%i:%s')
</if>
</sql> </sql>
<sql id="_orderCols_"> <sql id="_orderCols_">
<if test="orderColList != null and !orderColList.isEmpty()"> <if test="orderColList != null and !orderColList.isEmpty()">
...@@ -893,6 +923,11 @@ ...@@ -893,6 +923,11 @@
<if test='orderCol.createTime != null and "DESC".equalsIgnoreCase(orderCol.createTime)'>DESC</if> <if test='orderCol.createTime != null and "DESC".equalsIgnoreCase(orderCol.createTime)'>DESC</if>
, ,
</if> </if>
<if test="orderCol.containsKey('updateTime')">
a.updateTime
<if test='orderCol.updateTime != null and "DESC".equalsIgnoreCase(orderCol.updateTime)'>DESC</if>
,
</if>
</trim> </trim>
</if> </if>
</sql> </sql>
......
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