Commit c01b2f57 authored by 赵啸非's avatar 赵啸非

前端页面添加

parent b86d8606
......@@ -3,30 +3,38 @@
-- ----------------------------
DROP TABLE IF EXISTS `mortals_xhx_access_log`;
CREATE TABLE mortals_xhx_access_log(
`id` bigint(20) AUTO_INCREMENT COMMENT '主键ID,主键,自增长',
`traceID` varchar(64) COMMENT '追踪Id',
`id` bigint(20) NOT NULL COMMENT '主键ID',
`traceID` varchar(64) COMMENT 'TraceId',
`pspanId` int(9) COMMENT '父服务调用id',
`spanId` int(9) COMMENT '当前服务跨度Id',
`appName` varchar(64) COMMENT '应用名称',
`hostName` varchar(64) COMMENT '实例IP',
`targetServer` varchar(64) COMMENT '目标服务',
`logLevel` varchar(64) COMMENT '日志等级',
`requestIp` varchar(64) COMMENT '请求者IP',
`method` varchar(64) COMMENT '请求方式',
`schema` varchar(64) COMMENT '协议',
`ua` varchar(64) COMMENT '用户浏览器UA',
`uri` varchar(64) COMMENT '请求URI',
`requestParam` text COMMENT '请求参数,json序列化',
`response` text COMMENT '响应结果',
`logTime` datetime COMMENT '日志产生时间',
`duration` int(4) COMMENT '持续时间,单位毫秒',
`requestData` varchar(2048) COMMENT '请求参数,json序列化',
`responseData` mediumtext COMMENT '响应结果,',
`logTime` datetime NOT NULL COMMENT '日志产生时间',
`requestTime` datetime COMMENT '请求时间',
`responseTime` datetime COMMENT '响应时间',
`duration` bigint(20) COMMENT '持续时间,单位毫秒',
`createUserId` bigint(20) NOT NULL COMMENT '创建用户',
`createTime` datetime NOT NULL COMMENT '创建时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='访问日志';
-- ----------------------------
-- 业务日志表
-- ----------------------------
DROP TABLE IF EXISTS `mortals_xhx_biz_log`;
CREATE TABLE mortals_xhx_biz_log(
`id` bigint(20) AUTO_INCREMENT COMMENT '主键ID,主键,自增长',
`id` bigint(20) COMMENT '主键ID',
`traceID` varchar(64) COMMENT '追踪Id',
`appName` varchar(64) COMMENT '应用名称',
`hostName` varchar(64) COMMENT '实例IP',
......@@ -47,7 +55,7 @@ PRIMARY KEY (`id`)
-- ----------------------------
DROP TABLE IF EXISTS `mortals_xhx_error_log`;
CREATE TABLE mortals_xhx_error_log(
`id` bigint(20) AUTO_INCREMENT COMMENT '主键ID,主键,自增长',
`id` bigint(20) COMMENT '主键ID',
`traceID` varchar(64) COMMENT '追踪Id',
`serverType` varchar(64) COMMENT '服务类型,webOS,android,IOS,服务后端',
`appName` varchar(64) COMMENT '应用名称',
......@@ -67,13 +75,13 @@ PRIMARY KEY (`id`)
-- ----------------------------
DROP TABLE IF EXISTS `mortals_xhx_operate_log`;
CREATE TABLE mortals_xhx_operate_log(
`id` bigint(20) AUTO_INCREMENT COMMENT '序号,主键,自增长',
`id` bigint(20) COMMENT '主键ID',
`platformMark` varchar(50) COMMENT '平台标识',
`userId` bigint(20) COMMENT '用户id',
`userName` varchar(50) COMMENT '用户名称',
`loginName` varchar(50) COMMENT '用户登录名',
`requestUrl` varchar(200) COMMENT '请求地址',
`content` varchar(2000) COMMENT '操作内容,记录操作具体信息,如修改前修改或的数据',
`content` varchar(2048) COMMENT '操作内容,记录操作具体信息,如修改前修改或的数据',
`ip` varchar(30) COMMENT '操作IP地址',
`logDate` datetime COMMENT '操作时间',
`operType` tinyint(2) COMMENT '操作类型,0:新增,1:修改,2:删除',
......
# 服务平台
版本 | 创建时间 | 作者 | 备注信息
---|---|---|---
v1.0|2022-01-20|zxfei| 接口文档
## 数据类型
类型名称|类型描述|参考样例
---|---|---
String |字符串|A、a、ab
Integer|数字类型|1、12、-1
Long|长整型数字|1、12、-1
date|时间类型,单位纳秒数字|167988745573
BigDecimal|小数类型|545.256
object|对象类型|{"name":"zhang3"}
arrays|数组类型|[{"name":"zhang3"},{"name":"zhang2"}]
## 系统服务
### 登录
**请求URL:** login/login
**请求方式:** POST
**内容类型:** application/json;charset=utf-8
**简要描述:** 用户登录
**请求参数:**
参数名称|类型|备注|必填|其它
---|---|---|---|---
loginName|String|用户名称|是|-
password|String|用户密码|是|-
securityCode|String|校验码|是|-
**请求样例:**
```
{
"loginName":"zhang3",
"password":"123456",
"securityCode":"5455"
}
```
**响应参数:**
参数名称 |参数类型|备注|其它
---|---|---|---
code|Integer|结果码(-1.失败,1.成功)|-
msg|String|消息|-
**响应消息样例:**
```
{
"msg":"登录成功",
"code":1,
"data":{
}
}
```
### 登出
**请求URL:** login/logout
**请求方式:** POST
**内容类型:** application/json;charset=utf-8
**简要描述:** 用户退出注销
**请求参数:**
参数名称|类型|备注|必填|其它
---|---|---|---|---
**请求样例:**
```
```
**响应参数:**
参数名称 |参数类型|备注|其它
---|---|---|---
code|Integer|结果码(-1.失败,1.成功)|-
msg|String|消息|-
**响应消息样例:**
```
```
### 修改密码
**请求URL:** user/change/password
**请求方式:** POST
**内容类型:** application/json;charset=utf-8
**简要描述:** 用户修改密码
**请求参数:**
参数名称|类型|备注|必填|其它
---|---|---|---|---
loginName|String|用户名称|是|-
oldPwd|String|用户加密后密码|是|-
newPwd|String|用户加密后新密码|是|-
**请求样例:**
```
{
"loginName":"zhang3",
"oldPwd":"123456",
"newPwd":"5455"
}
```
**响应参数:**
参数名称 |参数类型|备注|其它
---|---|---|---
code|Integer|结果码(-1.失败,1.成功)|-
msg|String|消息|-
**响应消息样例:**
```
{
"msg":"修改密码成功",
"code":1,
"data":{}
}
```
### 获取验证码
**请求URL:** securitycode/createCode
**请求方式:** GET
**内容类型:** image/gif
**简要描述:** 用户退出注销
**请求参数:**
参数名称|类型|备注|必填|其它
---|---|---|---|---
**请求样例:**
```
```
**响应参数:**
**响应消息样例:**
```
```
### 上传附件
**请求URL:** file/commonupload
**请求方式:** POST
**内容类型:** multipart/form-data
**简要描述:** 用户上传附件
**请求参数:**
参数名称|类型|备注|必填|其它
---|---|---|---|---
file|multipart|附件|是|-
prePath|String|附件存放相对路径|否|不填时候默认为/file/fileupload
**请求样例:**
```
http://127.0.0.1/file/commonupload?prePath=/file/fileupload
Content-Type: multipart/form-data; boundary=WebAppBoundary
--WebAppBoundary
Content-Disposition: form-data; name="file"; filename="1.excel"
Content-Type: multipart/form-data
```
**响应参数:**
**响应消息样例:**
```
```
## 访问日志
### 查询访问日志列表
**请求URL:** access/log/list
**请求方式:** POST
**内容类型:** application/json;charset=utf-8
**简要描述:** 查询访问日志
**请求参数:**
参数名称|类型|必填|描述
:---|:---|:---|:------
page|Integer|否|当前页
size|Integer|否|每页条数,值为-1,查询所有记录
**请求样例:**
```
{
"page":1,
"size":10
}
```
**响应参数:**
参数名称|参数类型|描述
:---|:---|:------
code|Integer|结果码(-1.失败,1.成功)
msg|String|消息
data|object|数据对象
 per_page|Integer|每页条数
 total|Integer|总条数
 last_page|Integer|总页数
 current_page|Integer|当前页
 data|array|结果集列表|数组
  id|Long|主键ID
  traceID|String|TraceId
  pspanId|Integer|父服务调用id
  spanId|Integer|当前服务跨度Id
  appName|String|应用名称
  hostName|String|实例IP
  targetServer|String|目标服务
  logLevel|String|日志等级
  requestIp|String|请求者IP
  method|String|请求方式
  schema|String|协议
  ua|String|用户浏览器UA
  uri|String|请求URI
  requestData|String|请求参数,json序列化
  responseData|String|响应结果,
  logTime|Date|日志产生时间
  requestTime|Date|请求时间
  responseTime|Date|响应时间
  duration|Long|持续时间,单位毫秒
  createUserId|Long|创建用户
  createTime|Date|创建时间
dict|object|字典对象
**响应消息样例:**
```
{
"code":1,
"data":{
}
}
```
### 查看访问日志
**请求URL:** access/log/info
**请求方式:** GET
**内容类型:** application/json;charset=utf-8
**简要描述:** 查看访问日志,返回实例详细信息
**请求参数:**
参数名称|类型|必填|描述
:---|:---|:---|:------
id|Long|是|ID
**请求样例:**
```
http://localhost/access/log/info?id=549
```
**响应参数:**
参数名称 |参数类型|描述
:---|:---|:-------
code|Integer|结果码(-1.失败,1.成功)
msg|String|消息
data|object|数据对象
 id|Long|主键ID
 traceID|String|TraceId
 pspanId|Integer|父服务调用id
 spanId|Integer|当前服务跨度Id
 appName|String|应用名称
 hostName|String|实例IP
 targetServer|String|目标服务
 logLevel|String|日志等级
 requestIp|String|请求者IP
 method|String|请求方式
 schema|String|协议
 ua|String|用户浏览器UA
 uri|String|请求URI
 requestData|String|请求参数,json序列化
 responseData|String|响应结果,
 logTime|Date|日志产生时间
 requestTime|Date|请求时间
 responseTime|Date|响应时间
 duration|Long|持续时间,单位毫秒
 createUserId|Long|创建用户
 createTime|Date|创建时间
dict|object|字典对象
**响应消息样例:**
```
{
"code": 1,
"data": {
"id":7635,
"traceID":"0tj24m",
"pspanId":1924,
"spanId":5615,
"appName":"ntxdiz",
"hostName":"u7esz1",
"targetServer":"rlj8lh",
"logLevel":"hzemsx",
"requestIp":"cme1cq",
"method":"6eosdt",
"schema":"yjlki4",
"ua":"nl06uh",
"uri":"hsuwg5",
"requestData":"16s8fd",
"responseData":"pi1iud",
"logTime":"2022-08-19",
"requestTime":"2022-08-19",
"responseTime":"2022-08-19",
"duration":1396,
"createUserId":6560,
"createTime":"2022-08-19"
}
}
```
### 保存更新访问日志
**请求URL:** access/log/save
**请求方式:** POST
**内容类型:** application/json;charset=utf-8
**简要描述:** 保存或更新访问日志:id为空时为新增保存,否则为更新提交
**请求参数:**
参数名称|类型|必填|描述
:---|:---|:---|:-------
id|Long|否|主键ID
logTime|Date|是|日志产生时间
createUserId|Long|否|创建用户
createTime|Date|否|创建时间
**请求样例:**
```
{
"traceID":"k3wjwl",
"pspanId":6376,
"spanId":6876,
"appName":"i7shif",
"hostName":"2ukyl7",
"targetServer":"v43pht",
"logLevel":"wndrrh",
"requestIp":"tlyvvh",
"method":"b83dee",
"schema":"hwpd56",
"ua":"d52vor",
"uri":"c5te0l",
"requestData":"uwtl25",
"responseData":"81900k",
"logTime":"2022-08-19",
"requestTime":"2022-08-19",
"responseTime":"2022-08-19",
"duration":7934,
}
```
**响应参数:**
参数名称 |参数类型|描述
:---|:---|:------
code|Integer|结果码(-1.失败,1.成功)
msg|String|消息
data|object|数据对象
 id|Long|保存后主键id
 entity|object|保存更新实体
  id|Long|主键ID
  traceID|String|TraceId
  pspanId|Integer|父服务调用id
  spanId|Integer|当前服务跨度Id
  appName|String|应用名称
  hostName|String|实例IP
  targetServer|String|目标服务
  logLevel|String|日志等级
  requestIp|String|请求者IP
  method|String|请求方式
  schema|String|协议
  ua|String|用户浏览器UA
  uri|String|请求URI
  requestData|String|请求参数,json序列化
  responseData|String|响应结果,
  logTime|Date|日志产生时间
  requestTime|Date|请求时间
  responseTime|Date|响应时间
  duration|Long|持续时间,单位毫秒
  createUserId|Long|创建用户
  createTime|Date|创建时间
**响应消息样例:**
```
{
"msg":"新增模块成功",
"code":1,
"data":{}
}
}
```
### 删除访问日志
**请求URL:** access/log/delete
**请求方式:** GET
**内容类型:** application/json;charset=utf-8
**简要描述:** 删除访问日志
**请求参数:**
参数名称|类型|必填|描述
:---|:---|:---|:------
id|String|是|数组
**请求样例:**
```
http://localhost:8080/access/log/delete?id=1&id=2'
```
**响应参数:**
参数名称 |参数类型|备注|其它
---|---|---|---
code|Integer|结果码(-1.失败,1.成功)|-
msg|String|消息|-
**响应消息样例:**
```
{
"code":1,
"msg":"成功"
}
```
## 字典附录
......@@ -5,7 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title>设备管理平台</title>
<title>日志管理平台</title>
<link rel="stylesheet" href="https://unpkg.com/element-ui@2.15.5/lib/theme-chalk/index.css">
</head>
<body>
......
......@@ -5,7 +5,7 @@ import cookie from './cookie';
import httpErrorHandler from './httpErrorHandler';
const instance = axios.create({
baseURL: '/m',
baseURL: '/logservice',
headers: {
post: {
'Content-Type': 'application/json;charset=UTF-8',
......
......@@ -57,6 +57,11 @@ export default {
type: Number,
default: 12,
},
rows: {
type: Number,
default: 2,
},
// 字段类型: text,password,textarea,select,radio,checkbox,date,datetime
type: {
type: String,
......
......@@ -9,7 +9,7 @@
<i class="el-icon-menu" @click='showMobileMenu=!showMobileMenu'> </i>
<router-link to="/">
<img src="../assets/images/logo.png" style="margin-bottom:5px" height="40" alt="">
<b style="color:white;font-size:18px;">&nbsp;&nbsp;&nbsp; AIOT智慧边缘物联网系统 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b>
<b style="color:white;font-size:18px;">&nbsp;&nbsp;&nbsp; 日志管理系统 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b>
</router-link>
</div>
......
......@@ -40,10 +40,10 @@ const router = new Router({
...restBuilder('task', 'system/task'), // 系统管理--任务管理
...restBuilder('access', 'access'), //链路访问日志
...restBuilder('biz', 'biz'), //业务日志
...restBuilder('biz', 'biz'), //异常日志
...restBuilder('operate', 'operate'), //操作日志
...restBuilder('access/log', 'access/log'), //链路访问日志
...restBuilder('biz/log', 'biz/log'), //业务日志
...restBuilder('error/log', 'error/log'), //异常日志
...restBuilder('operate/log', 'operate/log'), //操作日志
//以下为基础路由配置
......
<template>
<div class="page page-home homeIndex" style="min-height: 100vh">
<el-row :gutter="10">
<el-row
style="margin-left: 50px; margin-right: 50px"
type="flex"
justify="end"
:gutter="10"
>
<el-button type="text" size="mini"
>数据更新:{{ formatterDate(statData.updateTime) }} 2分钟后自动更新</el-button
>
<el-button
icon="el-icon-refresh"
size="mini"
@click="syncDeviceStat"
type="text"
>手动刷新</el-button
>
</el-row>
<el-card style="margin-left: 50px; margin-right: 50px; margin-top: 10px">
<el-row
:gutter="20"
style="height: 80px; align-items: center; margin-top: 10px"
>
<el-col :span="3">
<el-row type="flex" justify="center">
<span style="font-size: 20px"
><b>{{ statData.deviceTotalCount }}</b></span
></el-row
>
<el-row type="flex" justify="center">
<span style="font-size: 12px"
><span style="color: #6182f6">昨日 </span
><span
v-bind:class="{
success: statData.deviceAddCount >= 0,
warn: statData.deviceAddCount < 0,
}"
>{{
statData.deviceAddCount >= 0
? "+" + statData.deviceAddCount
: "-" + statData.deviceAddCount
}}</span
></span
></el-row
>
<el-row type="flex" justify="center">
<i class="el-icon-mobile customIcon"> 设备总数</i>
</el-row>
</el-col>
<el-col :span="3">
<el-row type="flex" justify="center"
><span style="font-size: 20px"
><b>{{ statData.siteTotalCount }}</b></span
></el-row
>
<el-row type="flex" justify="center">
<span style="font-size: 12px"
><span style="color: #6182f6">昨日 </span
><span
v-bind:class="{
success: statData.siteAddCount >= 0,
warn: statData.siteAddCount < 0,
}"
>{{
statData.siteAddCount >= 0
? "+" + statData.siteAddCount
: "-" + statData.siteAddCount
}}</span
></span
></el-row
>
<el-row type="flex" justify="center">
<i class="el-icon-place customIcon"> 监控站点数</i>
</el-row>
</el-col>
<el-col :span="3">
<el-row type="flex" justify="center"
><span style="font-size: 20px"
><b>{{ statData.deviceOnlineCount }}</b></span
></el-row
>
<el-row type="flex" justify="center">
<span style="font-size: 12px"
><span style="color: #6182f6">上线率 </span
><span
v-bind:class="{ success: statData.deviceOnlineRatio >= 0 }"
>{{ statData.deviceOnlineRatio * 100 }}%</span
></span
></el-row
>
<el-row type="flex" justify="center">
<i class="el-icon-data-line customIcon"> 在线设备</i>
</el-row>
</el-col>
<el-col :span="3">
<el-row type="flex" justify="center"
><span style="font-size: 20px"
><b>{{ statData.deviceOfflineCount }}</b></span
></el-row
>
<el-row type="flex" justify="center">
<span style="font-size: 12px"
><span style="color: #6182f6">离线率 </span
><span v-bind:class="{ warn: statData.deviceOfflineRatio >= 0 }"
>{{ statData.deviceOfflineRatio * 100 }}%</span
></span
></el-row
>
<el-row type="flex" justify="center">
<i class="el-icon-data-board customIcon"> 离线设备</i>
</el-row>
</el-col>
<el-col :span="3">
<el-row type="flex" justify="center"
><span style="font-size: 20px"
><b>{{ statData.deviceStopRatio }}</b></span
></el-row
>
<el-row type="flex" justify="center">
<span style="font-size: 12px"
><span style="color: #6182f6">停用率 </span
><span v-bind:class="{ warn: statData.deviceStopRatio >= 0 }"
>{{ statData.deviceStopRatio * 100 }}%</span
></span
></el-row
>
<el-row type="flex" justify="center">
<i class="el-icon-data-board customIcon">停用设备</i>
</el-row>
</el-col>
<el-col :span="3">
<el-row type="flex" justify="center"
><span style="font-size: 20px"
><b>{{ statData.alarmTotalCount }}</b></span
></el-row
>
<el-row type="flex" justify="center">
<span style="font-size: 12px"
><span style="color: #6182f6">昨日 </span
><span
v-bind:class="{
success: statData.alarmAddCount >= 0,
warn: statData.alarmAddCount < 0,
}"
>{{
statData.alarmAddCount >= 0
? "+" + statData.alarmAddCount
: "-" + statData.alarmAddCount
}}</span
></span
></el-row
>
<el-row type="flex" justify="center">
<i class="el-icon-data-board customIcon"> 今日告警次数</i>
</el-row>
</el-col>
<el-col :span="3">
<el-row type="flex" justify="center"
><span style="font-size: 20px"
><b>{{ statData.pushTotalCount }}</b></span
></el-row
>
<el-row type="flex" justify="center">
<span style="font-size: 12px"
><span style="color: #6182f6">昨日 </span
><span
v-bind:class="{
success: statData.pushAddCount >= 0,
warn: statData.pushAddCount < 0,
}"
>{{
statData.pushAddCount >= 0
? "+" + statData.pushAddCount
: "-" + statData.pushAddCount
}}</span
></span
></el-row
>
<el-row type="flex" justify="center">
<i class="el-icon-data-board customIcon"> 今日消息推送</i>
</el-row>
</el-col>
<el-col :span="3" type="flex" style="height: 100%">
<el-row type="flex" style="margin-top: 6px" justify="center"
><span style="font-size: 13px"
><span style="color: #6182f6">今日下发命令 </span>
<b>{{ statData.uploadMessageTotalCount }}</b></span
></el-row
>
<el-row type="flex" style="margin-top: 6px" justify="center"
><span style="font-size: 13px"
><span style="color: #6182f6">今日下发命令 </span>
<b>{{ statData.downloadMessageTotalCount }}</b></span
></el-row
>
<el-row type="flex" justify="center">
<i class="el-icon-data-board customIcon"> 数据获取</i>
</el-row>
</el-col>
</el-row>
</el-card>
</el-row>
<el-row
style="margin-left: 35px; margin-right: 35px; margin-top: 15px"
:gutter="20"
>
<el-col :span="12">
<el-card class="box-card">
<div id="deviceTotal" style="width: 100%; height: 300px"></div>
</el-card>
</el-col>
<el-col :span="12">
<el-card class="box-card">
<div id="deviceStat" style="width: 100%; height: 300px"></div>
</el-card>
</el-col>
</el-row>
<el-row
style="margin-left: 35px; margin-right: 35px; margin-top: 10px"
:gutter="20"
>
<el-col :span="12">
<el-card class="box-card">
<div id="deviceAlarm" style="width: 100%; height: 300px"></div>
</el-card>
</el-col>
<el-col :span="12">
<el-card class="box-card">
<div id="devicePush" style="width: 100%; height: 300px"></div>
</el-card>
</el-col>
</el-row>
</div>
</template>
......@@ -252,517 +15,18 @@ export default {
this.timer = setInterval(this.syncDeviceStat, 1000 * 120);
},
beforeDestroy() {
clearInterval(this.timer);
},
created() {
let today = new Date();
let query = {
year: today.getFullYear(),
month: today.getMonth() + 1,
day: today.getDate(),
};
//查询今日设备统计
this.loading = true;
this.$post("/device/stat/list", query)
.then((res) => {
if (res.code == 1) {
this.statData = res.data.data[0];
}
this.loading = false;
})
.catch((error) => {
this.$message.error(error.message);
});
//默认查询15天数据
let beforeday = new Date(today);
beforeday.setDate(beforeday.getDate() - 15);
this.findDeviceTotalStat(beforeday);
this.findDeviceStat(beforeday);
this.findDeviceAlarm(beforeday);
this.findDevicePush(beforeday);
},
methods: {
syncDeviceStat() {
this.$post("/device/stat/syncDeviceStat", {})
.then((res) => {
if (res.code == 1) {
this.statData = res.data.data[0];
} else {
this.$message.error(res.msg);
}
})
.catch((error) => {
this.$message.error(error.message);
});
},
findDeviceTotalStat(beforeday) {
let query = { createTimeStart: this.formatterDate(beforeday) };
this.$post("/device/stat/list", query)
.then((res) => {
if (res.code == 1) {
console.log("res", res);
this.statArrayData = res.data.data;
this.beforeday = this.statArrayData.map((i) => {
let daystr = i.month + "-" + i.day;
return daystr;
});
this.deviceTotalyData = this.statArrayData.map((i) => {
return i.deviceTotalCount;
});
this.deviceOnlineyData = this.statArrayData.map((i) => {
return i.deviceOnlineRatio;
});
this.$nextTick(() => {
this.myEcharts();
});
}
this.loading = false;
})
.catch((error) => {
this.$message.error(error.message);
});
},
findDeviceStat(beforeday) {
let query = { createTimeStart: this.formatterDate(beforeday) };
this.$post("/device/stat/list", query)
.then((res) => {
if (res.code == 1) {
this.statArrayData = res.data.data;
this.beforeDeviceStatday = this.statArrayData.map((i) => {
let daystr = i.month + "-" + i.day;
return daystr;
});
this.deviceStatOnlineyData = this.statArrayData.map((i) => {
return i.deviceOnlineRatio;
});
this.deviceStatOfflineyData = this.statArrayData.map((i) => {
return i.deviceOfflineRatio;
});
this.$nextTick(() => {
this.deviceStatEcharts();
});
}
this.loading = false;
})
.catch((error) => {
this.$message.error(error.message);
});
},
findDeviceAlarm(beforeday) {
let query = { createTimeStart: this.formatterDate(beforeday) };
this.$post("/device/stat/list", query)
.then((res) => {
if (res.code == 1) {
this.statArrayData = res.data.data;
this.beforeDeviceAlarmday = this.statArrayData.map((i) => {
let daystr = i.month + "-" + i.day;
return daystr;
});
this.deviceAlarmyData = this.statArrayData.map((i) => {
return i.alarmTotalCount;
});
this.$nextTick(() => {
this.deviceAlarmEcharts();
});
}
this.loading = false;
})
.catch((error) => {
this.$message.error(error.message);
});
},
findDevicePush(beforeday) {
let query = { createTimeStart: this.formatterDate(beforeday) };
this.$post("/device/stat/list", query)
.then((res) => {
if (res.code == 1) {
this.statArrayData = res.data.data;
this.beforeDevicePushday = this.statArrayData.map((i) => {
let daystr = i.month + "-" + i.day;
return daystr;
});
this.devicePushyData = this.statArrayData.map((i) => {
return i.pushTotalCount;
});
this.$nextTick(() => {
this.devicePushEcharts();
});
}
this.loading = false;
})
.catch((error) => {
this.$message.error(error.message);
});
},
formatterDate(time) {
let date = new Date(Number(time));
let Y = date.getFullYear() + "-";
let M =
(date.getMonth() + 1 < 10
? "0" + (date.getMonth() + 1)
: date.getMonth() + 1) + "-";
let D = this.panLeft(date.getDate()) + " ";
let h = this.panLeft(date.getHours()) + ":";
let m = this.panLeft(date.getMinutes()) + ":";
let s = this.panLeft(date.getSeconds());
return Y + M + D + h + m + s;
},
getYear(time) {
let date = new Date(Number(time));
let Y = date.getFullYear() + "-";
let M =
(date.getMonth() + 1 < 10
? "0" + (date.getMonth() + 1)
: date.getMonth() + 1) + "-";
let D = this.panLeft(date.getDate()) + " ";
let h = this.panLeft(date.getHours()) + ":";
let m = this.panLeft(date.getMinutes()) + ":";
let s = this.panLeft(date.getSeconds());
return Y + M + D + h + m + s;
},
panLeft(num) {
return num < 10 ? "0" + num : num;
},
myEcharts() {
// 基于准备好的dom,初始化echarts实例
var deviceTotalChart = this.$echarts.init(
document.getElementById("deviceTotal")
);
let option = {
title: {
text: "设备数据",
subtext: "",
x: "center",
},
tooltip: {
trigger: "axis",
axisPointer: {
type: "cross",
label: {
backgroundColor: "#6a7985",
},
},
},
legend: {
orient: "horizontal",
x: "left",
y: "top",
data: ["设备总量", "在线趋势"],
},
xAxis: {
name: "",
type: "category",
data: this.beforeday,
},
yAxis: [
{
name: "设备总量",
type: "value",
// min: 0, // 配置 Y 轴刻度最小值
max: 400, // 配置 Y 轴刻度最大值
// splitNumber: 7, // 配置 Y 轴数值间隔
},
{
name: "在线率",
type: "value",
// min: 0, // 配置 Y 轴刻度最小值
max: 1, // 配置 Y 轴刻度最大值
//splitNumber: 7, // 配置 Y 轴数值间隔
},
],
series: [
// 多组折线图数据
{
name: "设备总量",
data: this.deviceTotalyData,
type: "bar",
barWidth: 22, // 设置柱状图的宽度
},
{
name: "在线趋势",
yAxisIndex: 1,
data: this.deviceOnlineyData,
type: "line",
},
],
color: ["#3366CC", "#008000"],
};
// 使用刚指定的配置项和数据显示图表。
deviceTotalChart.setOption(option);
},
deviceStatEcharts() {
var deviceStatChart = this.$echarts.init(
document.getElementById("deviceStat")
);
let deviceStatOption = {
title: {
text: "设备状态",
},
tooltip: {
trigger: "axis",
axisPointer: {
type: "cross",
label: {
backgroundColor: "#6a7985",
},
},
},
legend: {
data: ["在线率", "离线率"],
},
grid: {
left: "3%",
right: "4%",
bottom: "3%",
containLabel: true,
},
xAxis: [
{
type: "category",
boundaryGap: false,
data: this.beforeDeviceStatday,
},
],
yAxis: [
{
type: "value",
max: 1,
},
],
series: [
{
name: "在线率",
type: "line",
stack: "online",
smooth: true,
lineStyle: {
width: 0,
},
showSymbol: false,
areaStyle: {
opacity: 0.8,
color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [
{
offset: 0,
color: "rgb(128, 255, 165)",
},
{
offset: 1,
color: "rgb(1, 191, 236)",
},
]),
},
emphasis: {
focus: "series",
},
data: this.deviceStatOnlineyData,
},
{
name: "离线率",
type: "line",
stack: "offline",
smooth: true,
lineStyle: {
width: 0,
color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [
{
offset: 0,
color: "rgb(255,99,71)",
},
{
offset: 1,
color: "rgb(255, 0, 0)",
},
]),
},
showSymbol: false,
areaStyle: {
opacity: 0.8,
},
emphasis: {
focus: "series",
},
data: this.deviceStatOfflineyData,
},
],
};
deviceStatChart.setOption(deviceStatOption);
},
deviceAlarmEcharts() {
var chart = this.$echarts.init(document.getElementById("deviceAlarm"));
let option = {
title: {
text: "设备告警趋势",
},
tooltip: {
trigger: "axis",
axisPointer: {
type: "cross",
label: {
backgroundColor: "#6a7985",
},
},
},
legend: {
data: ["告警次数"],
},
grid: {
left: "3%",
right: "4%",
bottom: "3%",
containLabel: true,
},
xAxis: [
{
type: "category",
boundaryGap: false,
data: this.beforeDeviceAlarmday,
},
],
yAxis: [
{
type: "value",
},
],
series: [
{
name: "告警次数",
type: "line",
stack: "Total",
smooth: true,
lineStyle: {
width: 0,
},
showSymbol: false,
areaStyle: {
opacity: 0.8,
color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [
{
offset: 0,
color: "rgb(55, 162, 255)",
},
{
offset: 1,
color: "rgb(116, 21, 219)",
},
]),
},
emphasis: {
focus: "series",
},
data: this.deviceAlarmyData,
},
],
};
chart.setOption(option);
},
devicePushEcharts() {
var chart = this.$echarts.init(document.getElementById("devicePush"));
let option = {
title: {
text: "设备消息推送趋势",
},
tooltip: {
trigger: "axis",
axisPointer: {
type: "cross",
label: {
backgroundColor: "#6a7985",
},
},
},
legend: {
data: ["告警次数"],
},
grid: {
left: "3%",
right: "4%",
bottom: "3%",
containLabel: true,
},
xAxis: [
{
type: "category",
data: this.beforeDevicePushday,
},
],
yAxis: [
{
type: "value",
},
],
series: [
{
name: "告警次数",
type: "line",
smooth: true,
data: this.devicePushyData,
},
],
};
chart.setOption(option);
},
},
data() {
return {
timer: "",
loading: false,
indexStatInfo: {},
recordListLoading: false,
statData: {},
dayProjectList: [],
pendList: [],
beforeday: [],
beforeDeviceStatday: [],
beforePushday: [],
beforeAlarmday: [],
deviceTotalyData: [],
deviceOnlineyData: [],
deviceStatOnlineyData: [],
deviceStatOfflineyData: [],
deviceAlarmyData: [],
devicePushyData: [],
weekPerDay: {
xData: [],
yData: [],
},
dict: {},
value: new Date(),
};
},
};
......@@ -781,7 +45,7 @@ export default {
color: dodgerblue;
}
.homeIndex {
/* .homeIndex {
display: inline-block;
position: relative;
}
......@@ -793,6 +57,6 @@ export default {
width: 100%;
height: 35%;
background: #1848c8;
}
} */
</style>
......@@ -4,25 +4,25 @@
:title="title"
:visible.sync="open"
:direction="direction"
size="50%">
size="70%">
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
<el-row>
<Field label="追踪Id" prop="traceID" v-model="form.traceID" placeholder="请输入追踪Id"/>
<Field label="应用名称" prop="appName" v-model="form.appName" placeholder="请输入应用名称"/>
<Field label="实例IP" prop="hostName" v-model="form.hostName" placeholder="请输入实例IP"/>
<Field label="日志等级" prop="logLevel" v-model="form.logLevel" placeholder="请输入日志等级"/>
<Field label="请求者IP" prop="requestIp" v-model="form.requestIp" placeholder="请输入请求者IP"/>
<Field label="请求方式" prop="method" v-model="form.method" placeholder="请输入请求方式"/>
<Field label="用户浏览器UA" prop="ua" v-model="form.ua" placeholder="请输入用户浏览器UA"/>
<Field label="请求URI" prop="uri" v-model="form.uri" placeholder="请输入请求URI"/>
<Field label="请求参数,json序列化" prop="requestParam" v-model="form.requestParam" type="textarea" placeholder="请输入请求参数,json序列化"/>
<Field label="响应结果" prop="response" v-model="form.response" type="textarea" placeholder="请输入响应结果"/>
<Field label="日志产生时间" prop="logTime" v-model="form.logTime" type="date" />
<Field label="持续时间,单位毫秒" prop="duration" v-model="form.duration" placeholder="请输入持续时间,单位毫秒"/>
<Field label="日志时间" prop="logTime" v-model="form.logTime" type="date" />
<Field label="持续时间" prop="duration" v-model="form.duration+'ms'" placeholder="请输入持续时间,单位毫秒"/>
<Field label="请求参数" :span="22" prop="requestData" v-model="form.requestData" type="textarea" placeholder="请输入请求参数,json序列化"/>
<Field label="响应结果" :span="22" prop="responseData" v-model="form.responseData" rows=6 type="textarea" placeholder="请输入响应结果"/>
</el-row>
<form-buttons @submit='submitForm' noCancelBtn />
</el-form>
</el-drawer>
......@@ -41,6 +41,7 @@
},
data() {
return {
row:6,
// 遮罩层
loading: true,
// 弹出层标题
......
<template>
<div class="page">
<LayoutTable :data="tableData" :config="tableConfig">
<LayoutTable :data="tableData" notAdd notDel :config="tableConfig">
</LayoutTable>
......@@ -60,26 +60,40 @@
},
],
columns: [
{type: "selection", width: 60},
{type: "index",label: "序号",width: 50},
{label: "追踪Id", prop: "traceID"},
{type: "index",label: "序号",width: 50,align:"center"},
{label: "TraceID", prop: "traceID"},
{label: "spanId", prop: "spanId",width: 70},
{label: "pspanId", prop: "pspanId",width: 70},
{label: "请求方式", prop: "method",width: 70},
{label: "当前服务", prop: "appName"},
{label: "目标服务", prop: "targetServer"},
{label: "应用名称", prop: "appName"},
{label: "请求方式", prop: "method"},
{label: "请求URI", prop: "uri"},
{label: "日志产生时间", prop: "logTime", formatter: this.formatterDate},
{label: "请求参数", prop: "requestData"},
{label: "日志时间", prop: "logTime", formatter: this.formatterDate},
{label: "持续时间,单位毫秒", prop: "duration",formatter: this.formatter},
{label: "持续时间", prop: "duration",width:70, formatter: row => {
return (
<span>{row.duration}ms</span>
)}},
{
label: "操作",
width: 240,
width: 120,
formatter: row => {
return (
<table-buttons noAdd row={row} onEdit={this.toEdit} onView={this.toView} onDel={this.toDel} />
<table-buttons noAdd noEdit noDel row={row} onEdit={this.toEdit} onView={this.toView} onDel={this.toDel} />
);
}
}
......
<template>
<div class="page">
<LayoutTable :data="tableData" :config="tableConfig">
<LayoutTable :data="tableData" notAdd notDel :config="tableConfig">
</LayoutTable>
......@@ -84,10 +84,10 @@
},
],
columns: [
{type: "selection", width: 60},
{type: "index",label: "序号",width: 50},
{label: "追踪Id", prop: "traceID"},
{label: "TraceID", prop: "traceID"},
{label: "应用名称", prop: "appName"},
......@@ -102,10 +102,10 @@
{label: "日志产生时间", prop: "logTime", formatter: this.formatterDate},
{
label: "操作",
width: 240,
width: 120,
formatter: row => {
return (
<table-buttons noAdd row={row} onEdit={this.toEdit} onView={this.toView} onDel={this.toDel} />
<table-buttons noAdd noDel noEdit row={row} onEdit={this.toEdit} onView={this.toView} onDel={this.toDel} />
);
}
}
......
<template>
<div class="page">
<LayoutTable :data="tableData" :config="tableConfig">
<LayoutTable :data="tableData" notAdd notDel :config="tableConfig">
</LayoutTable>
......@@ -43,7 +43,7 @@
{
name: "traceID",
type: "text",
label: "追踪Id",
label: "TraceID",
fuzzy: true
},
{
......@@ -66,12 +66,12 @@
},
],
columns: [
{type: "selection", width: 60},
{type: "index",label: "序号",width: 50},
{label: "追踪Id", prop: "traceID"},
{type: "index",label: "序号",width: 50 ,align:"center"},
{label: "服务类型,webOS,android,IOS,服务后端", prop: "serverType"},
{label: "TraceID", prop: "traceID"},
{label: "服务类型", prop: "serverType"},
{label: "应用名称", prop: "appName"},
......@@ -83,7 +83,7 @@
width: 240,
formatter: row => {
return (
<table-buttons noAdd row={row} onEdit={this.toEdit} onView={this.toView} onDel={this.toDel} />
<table-buttons noAdd noDel noEdit row={row} onEdit={this.toEdit} onView={this.toView} onDel={this.toDel} />
);
}
}
......
......@@ -4,7 +4,7 @@
<div class="page page-login flex flex-v">
<div class="form-wrap flex flex-1">
<el-form @submit.prevent='onSubmit' ref="form" :model="form" label-width="80px" size="small">
<h1>设备管理平台</h1>
<h1>日志管理平台</h1>
<el-form-item label="用户名">
<el-input v-model="form.loginName"></el-input>
</el-form-item>
......@@ -20,64 +20,6 @@
<div class="footer">
登陆 &copy; <a href="">信宏翔网络科技有限公司</a> 出品
</div>
<!-- <Map ref="map1" :markersData="originData" @choose="getDetailData" /> -->
<!-- <el-card :body-style="{ padding: '5px' }" style="width: 300px">
<el-row type="flex" class="row-bg" justify="space-around">
<span style="font-size: 18px"><b>高新区政务服务中心</b></span>
<el-button type="text" size="mini" class="button">查看详情</el-button>
</el-row>
<el-divider></el-divider>
<el-row type="flex" justify="space-around">
<el-col :span="4">
<span style="font-size: 13px"><b>100</b></span
><br />
<span style="font-size: 12px">设备总数</span>
</el-col>
<el-col :span="4">
<span style="font-size: 13px"><b>100</b></span
><br />
<span style="font-size: 12px">在线</span>
</el-col>
<el-col :span="4">
<span style="font-size: 13px"><b>100</b></span
><br />
<span style="font-size: 12px">离线</span>
</el-col>
<el-col :span="4">
<span style="font-size: 13px"><b>100</b></span
><br />
<span style="font-size: 12px">停用</span>
</el-col>
<el-col :span="4">
<span style="font-size: 13px"><b>100</b></span
><br />
<span style="font-size: 12px">待激活</span>
</el-col>
</el-row>
<el-divider></el-divider>
<el-descriptions :column="1" size="small">
<el-descriptions-item label="站点编码"
>kooriookami</el-descriptions-item
>
<el-descriptions-item label="站点地址"
>18100000000</el-descriptions-item
>
<el-descriptions-item
label="联系人"
:labelStyle="{ 'text-align': 'right', width: '50px' }"
>苏州市</el-descriptions-item
>
<el-descriptions-item label="联系电话">
<el-tag size="small">学校</el-tag>
</el-descriptions-item>
<el-descriptions-item label="创建时间"
>江苏省苏州市吴中区吴中大道 1188 号</el-descriptions-item
>
</el-descriptions>
</el-card> -->
</div>
</template>
......
<template>
<div class="page">
<LayoutTable :data="tableData" :config="tableConfig">
<LayoutTable :data="tableData" notAdd notDel :config="tableConfig">
</LayoutTable>
......@@ -54,8 +54,8 @@
},
],
columns: [
{type: "selection", width: 60},
{type: "index",label: "序号",width: 50},
{type: "index",label: "序号",align:"center",width: 50},
{label: "平台标识", prop: "platformMark"},
......@@ -65,17 +65,17 @@
{label: "请求地址", prop: "requestUrl"},
{label: "操作内容,记录操作具体信息,如修改前修改或的数据", prop: "content"},
{label: "操作内容", prop: "content"},
{label: "操作IP地址", prop: "ip"},
{label: "操作时间", prop: "logDate", formatter: this.formatterDate},
{
label: "操作",
width: 240,
width: 120,
formatter: row => {
return (
<table-buttons noAdd row={row} onEdit={this.toEdit} onView={this.toView} onDel={this.toDel} />
<table-buttons noAdd noEdit noDel row={row} onEdit={this.toEdit} onView={this.toView} onDel={this.toDel} />
);
}
}
......
......@@ -16,7 +16,7 @@ module.exports = {
port: 8086,
hot: true,//自动保存
proxy: {
'/m': {
'/logservice': {
target: 'http://127.0.0.1:18225',
changeOrigin: true,
secure: false,
......
......@@ -32,11 +32,11 @@
<profiles.redis.username></profiles.redis.username>
<profiles.redis.password>hotel@2020</profiles.redis.password>
<profiles.redis.database>8</profiles.redis.database>
<profiles.rabbitmq.host>192.168.0.251</profiles.rabbitmq.host>
<profiles.rabbitmq.host>192.168.0.98</profiles.rabbitmq.host>
<profiles.rabbitmq.port>5672</profiles.rabbitmq.port>
<profiles.rabbitmq.username>taxi_mq</profiles.rabbitmq.username>
<profiles.rabbitmq.password>admin@2020</profiles.rabbitmq.password>
<profiles.rabbitmq.virtualhost>/test</profiles.rabbitmq.virtualhost>
<profiles.rabbitmq.virtualhost>/</profiles.rabbitmq.virtualhost>
<profiles.rabbitmq.exchange></profiles.rabbitmq.exchange>
<profiles.filepath>/mortals/data</profiles.filepath>
<profiles.log.level>DEBUG</profiles.log.level>
......@@ -113,6 +113,12 @@
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- 实现对 RabbitMQ 的自动化配置 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
......@@ -157,8 +163,8 @@
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
......
package com.mortals.xhx.base.framework.config;
import com.mortals.xhx.common.key.QueueKey;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.AsyncRabbitTemplate;
import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.boot.autoconfigure.amqp.SimpleRabbitListenerContainerFactoryConfigurer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.HashMap;
import java.util.Map;
@Configuration
public class RabbitConfig {
public Integer messageTtl = 86400000;
public Map<String, Object> args = new HashMap<>();
// 创建 Queue
@Bean
public Queue accessLogQueue() {
args.put("x-message-ttl", messageTtl);
return new Queue(QueueKey.ACCESS_LOG_QUEUE, // Queue 名字
true, // durable: 是否持久化
false, // exclusive: 是否排它
false,
args); // autoDelete: 是否自动删除
}
@Bean
public Queue bizLogQueue() {
args.put("x-message-ttl", messageTtl);
return new Queue(QueueKey.BIZ_LOG_QUEUE, // Queue 名字
true, // durable: 是否持久化
false, // exclusive: 是否排它
false, args); // autoDelete: 是否自动删除
}
@Bean
public Queue errorLogQueue() {
return new Queue(QueueKey.ERROR_LOG_QUEUE, // Queue 名字
true, // durable: 是否持久化
false, // exclusive: 是否排它
false, args); // autoDelete: 是否自动删除
}
@Bean
public Queue operationLogQueue() {
return new Queue(QueueKey.OPERATION_LOG_QUEUE, // Queue 名字
true, // durable: 是否持久化
false, // exclusive: 是否排它
false, args); // autoDelete: 是否自动删除
}
// 创建 Direct Exchange
@Bean
public DirectExchange exchange() {
return new DirectExchange(QueueKey.EXCHANGE,
true, // durable: 是否持久化
false); // exclusive: 是否排它
}
// 创建 Binding
@Bean
public Binding accessBinding() {
return BindingBuilder.bind(accessLogQueue()).to(exchange()).with(QueueKey.ACCESS_LOG_QUEUE);
}
@Bean
public Binding bizBinding() {
return BindingBuilder.bind(bizLogQueue()).to(exchange()).with(QueueKey.BIZ_LOG_QUEUE);
}
@Bean
public Binding errorBinding() {
return BindingBuilder.bind(errorLogQueue()).to(exchange()).with(QueueKey.ERROR_LOG_QUEUE);
}
@Bean
public Binding operBinding() {
return BindingBuilder.bind(operationLogQueue()).to(exchange()).with(QueueKey.OPERATION_LOG_QUEUE);
}
@Bean(name = "consumerBatchContainerFactory")
public SimpleRabbitListenerContainerFactory consumerBatchContainerFactory(
SimpleRabbitListenerContainerFactoryConfigurer configurer, ConnectionFactory connectionFactory) {
// 创建 SimpleRabbitListenerContainerFactory 对象
SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
configurer.configure(factory, connectionFactory);
// 额外添加批量消费的属性
factory.setBatchListener(true);
factory.setBatchSize(10);
factory.setReceiveTimeout(5 * 1000L);
factory.setConsumerBatchEnabled(true);
return factory;
}
//修改系列和与反序列化转换器
@Bean
public MessageConverter messageConverter() {
return new Jackson2JsonMessageConverter();
}
@Bean
public AsyncRabbitTemplate asyncRabbitTemplate(RabbitTemplate rabbitTemplate) {
AsyncRabbitTemplate asyncRabbitTemplate = new AsyncRabbitTemplate(rabbitTemplate);
asyncRabbitTemplate.setReceiveTimeout(10000);
return asyncRabbitTemplate;
}
}
package com.mortals.xhx.base.framework.listener;
import cn.hutool.core.util.IdUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.mortals.xhx.common.key.QueueKey;
import com.mortals.xhx.common.pdu.access.AccessLogPdu;
import com.mortals.xhx.module.access.model.AccessLogEntity;
import com.mortals.xhx.module.access.service.AccessLogService;
import com.mortals.xhx.module.biz.model.BizLogEntity;
import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.impl.AMQImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.amqp.RabbitProperties;
import org.springframework.messaging.handler.annotation.Headers;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Component;
import java.nio.charset.StandardCharsets;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* rabbitmq 访问日志消息消费类
*
* @author: zxfei
* @date: 2022/8/17 20:45
* @description:
**/
@Slf4j
@Component
@RabbitListener(queues = QueueKey.ACCESS_LOG_QUEUE,
containerFactory = "consumerBatchContainerFactory")
public class AccessMessageConsumerListener {
@Autowired
private AccessLogService accessLogService;
@RabbitHandler
public void onMessage(@Payload List<String> messages, Channel channel) throws Exception {
log.info("[onMessage][线程编号:{} 消息数量:{}]", Thread.currentThread().getId(), messages.size());
// messages.forEach(entity -> {
// entity.setId(IdUtil.getSnowflake(0, 1).nextId());
// entity.setCreateUserId(1L);
// entity.setCreateTime(new Date());
// });
// accessLogService.save(messages);
List<AccessLogEntity> collect = messages.stream().map(message -> {
try {
//String json = JSONUtil.formatJsonStr(new String(message, StandardCharsets.UTF_8));
AccessLogEntity entity = JSON.parseObject(message, AccessLogEntity.class);
entity.setId(IdUtil.getSnowflake(0, 1).nextId());
entity.setCreateUserId(1L);
entity.setCreateTime(new Date());
return entity;
}catch (Exception e){
log.info("反序列化异常",e);
return null;
}
}).filter(f->f!=null).collect(Collectors.toList());
// collect.forEach(accessLogEntity -> accessLogService.save(accessLogEntity));
accessLogService.save(collect);
}
public static void main(String[] args) {
String json="{\n" +
" \"appName\":\"smart-gateway\",\n" +
" \"deleted\":0,\n" +
" \"duration\":12,\n" +
" \"hostName\":\"172.17.0.1\",\n" +
" \"logLevel\":\"INFO\",\n" +
" \"logTime\":1661239155832,\n" +
" \"method\":\"POST\",\n" +
" \"pspanId\":0,\n" +
" \"requestData\":\"\",\n" +
" \"requestIp\":\"192.168.0.217\",\n" +
" \"requestTime\":1661239155832,\n" +
" \"responseData\":\"\",\n" +
" \"responseTime\":1661239155844,\n" +
" \"schemaData\":\"http\",\n" +
" \"spanId\":1,\n" +
" \"targetServer\":\"base-manager\",\n" +
" \"traceID\":\"63047f73dacc9d863249b7c5\",\n" +
" \"ua\":\"\",\n" +
" \"uri\":\"/base/business/list\"\n" +
"}";
System.out.println(json);
AccessLogEntity accessLogEntity = new AccessLogEntity();
accessLogEntity.setRequestData(json);
System.out.println(JSON.toJSONString(accessLogEntity));
JSONObject jsonObject = new JSONObject();
jsonObject.put("111",json);
System.out.println(JSON.toJSONString(jsonObject));
System.out.println(JSONUtil.formatJsonStr(JSON.toJSONString(jsonObject)));
}
}
package com.mortals.xhx.base.framework.listener;
import com.alibaba.fastjson.JSON;
import com.mortals.xhx.common.key.QueueKey;
import com.mortals.xhx.module.access.model.AccessLogEntity;
import com.mortals.xhx.module.access.service.AccessLogService;
import com.mortals.xhx.module.biz.model.BizLogEntity;
import com.mortals.xhx.module.biz.service.BizLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* rabbitmq 业务日志消息消费类
*
* @author: zxfei
* @date: 2022/8/17 20:45
* @description:
**/
@Slf4j
@Component
@RabbitListener(queues = QueueKey.BIZ_LOG_QUEUE,
containerFactory = "consumerBatchContainerFactory")
public class BizMessageConsumerListener {
@Autowired
private BizLogService bizLogService;
@RabbitHandler
public void onMessage(List<String> messages) {
log.info("[onMessage][线程编号:{} 消息数量:{}]", Thread.currentThread().getId(), messages.size());
List<BizLogEntity> collect = messages.stream().map(str -> {
BizLogEntity entity = JSON.parseObject(str, BizLogEntity.class);
entity.setCreateUserId(1L);
entity.setCreateTime(new Date());
return entity;
}).collect(Collectors.toList());
bizLogService.save(collect);
}
}
package com.mortals.xhx.base.framework.listener;
import com.alibaba.fastjson.JSON;
import com.mortals.xhx.common.key.QueueKey;
import com.mortals.xhx.module.access.model.AccessLogEntity;
import com.mortals.xhx.module.biz.model.BizLogEntity;
import com.mortals.xhx.module.biz.service.BizLogService;
import com.mortals.xhx.module.error.model.ErrorLogEntity;
import com.mortals.xhx.module.error.service.ErrorLogService;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.Headers;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* rabbitmq 异常日志消息消费类
*
* @author: zxfei
* @date: 2022/8/17 20:45
* @description:
**/
@Slf4j
@Component
@RabbitListener(queues = QueueKey.ERROR_LOG_QUEUE,
containerFactory = "consumerBatchContainerFactory")
public class ErrorMessageConsumerListener {
@Autowired
private ErrorLogService errorLogService;
@RabbitHandler
public void onMessage(List<String> messages) throws Exception {
log.info("[onMessage][线程编号:{} 消息数量:{}]", Thread.currentThread().getId(), messages.size());
List<ErrorLogEntity> collect = messages.stream().map(str -> {
ErrorLogEntity entity = JSON.parseObject(str, ErrorLogEntity.class);
entity.setCreateUserId(1L);
entity.setCreateTime(new Date());
return entity;
}).collect(Collectors.toList());
errorLogService.save(collect);
}
}
package com.mortals.xhx.base.framework.listener;
import cn.hutool.core.util.IdUtil;
import com.alibaba.fastjson.JSON;
import com.mortals.xhx.common.key.QueueKey;
import com.mortals.xhx.module.error.model.ErrorLogEntity;
import com.mortals.xhx.module.error.service.ErrorLogService;
import com.mortals.xhx.module.operate.model.OperateLogEntity;
import com.mortals.xhx.module.operate.service.OperateLogService;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.Headers;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* rabbitmq 操作日志消息消费类
*
* @author: zxfei
* @date: 2022/8/17 20:45
* @description:
**/
@Slf4j
@Component
@RabbitListener(queues = QueueKey.OPERATION_LOG_QUEUE,
containerFactory = "consumerBatchContainerFactory")
public class OperateMessageConsumerListener {
@Autowired
private OperateLogService operateLogService;
@RabbitHandler
public void onMessage(@Payload List<String> messages, Channel channel) throws Exception {
log.info("[OperateLog onMessage][线程编号:{} 消息数量:{}]", Thread.currentThread().getId(), messages.size());
List<OperateLogEntity> collect = messages.stream().map(str -> {
OperateLogEntity entity = JSON.parseObject(str, OperateLogEntity.class);
entity.setId(IdUtil.getSnowflake(0, 1).nextId());
entity.setCreateUserId(1L);
entity.setCreateTime(new Date());
return entity;
}).collect(Collectors.toList());
operateLogService.save(collect);
}
}
package com.mortals.xhx.common.key;
/**
* rabbit 队列key定义
*/
public class QueueKey {
public static final String ACCESS_LOG_QUEUE = "ACCESS_LOG_QUEUE";
public static final String BIZ_LOG_QUEUE = "BIZ_LOG_QUEUE";
public static final String ERROR_LOG_QUEUE = "ERROR_LOG_QUEUE";
public static final String OPERATION_LOG_QUEUE = "OPERATION_LOG_QUEUE";
public static final String EXCHANGE = "LOG";
public static final String ROUTING_KEY = "LOG_ROUTING_KEY";
}
......@@ -8,19 +8,27 @@ import com.mortals.framework.annotation.Excel;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.access.model.vo.AccessLogVo;
/**
* 访问日志实体对象
*
* @author zxfei
* @date 2022-08-17
*/
* 访问日志实体对象
*
* @author zxfei
* @date 2022-08-22
*/
public class AccessLogEntity extends AccessLogVo {
private static final long serialVersionUID = 1L;
/**
* 追踪Id
* TraceId
*/
private String traceID;
/**
* 父服务调用id
*/
private Integer pspanId;
/**
* 当前服务跨度Id
*/
private Integer spanId;
/**
* 应用名称
*/
......@@ -29,6 +37,10 @@ public class AccessLogEntity extends AccessLogVo {
* 实例IP
*/
private String hostName;
/**
* 目标服务
*/
private String targetServer;
/**
* 日志等级
*/
......@@ -52,37 +64,77 @@ public class AccessLogEntity extends AccessLogVo {
/**
* 请求参数,json序列化
*/
private String requestParam;
private String requestData;
/**
* 响应结果
* 响应结果,
*/
private String response;
private String responseData;
/**
* 日志产生时间
*/
private Date logTime;
/**
* 请求时间
*/
private Date requestTime;
/**
* 响应时间
*/
private Date responseTime;
/**
* 持续时间,单位毫秒
*/
private Integer duration;
private Long duration;
/**
* 协议
*/
private String schemaData;
public AccessLogEntity(){}
/**
* 获取 追踪Id
* 获取 TraceId
* @return String
*/
public String getTraceID(){
return traceID;
}
/**
* 设置 追踪Id
* 设置 TraceId
* @param traceID
*/
public void setTraceID(String traceID){
this.traceID = traceID;
}
/**
* 获取 父服务调用id
* @return Integer
*/
public Integer getPspanId(){
return pspanId;
}
/**
* 设置 父服务调用id
* @param pspanId
*/
public void setPspanId(Integer pspanId){
this.pspanId = pspanId;
}
/**
* 获取 当前服务跨度Id
* @return Integer
*/
public Integer getSpanId(){
return spanId;
}
/**
* 设置 当前服务跨度Id
* @param spanId
*/
public void setSpanId(Integer spanId){
this.spanId = spanId;
}
/**
* 获取 应用名称
* @return String
......@@ -111,6 +163,20 @@ public class AccessLogEntity extends AccessLogVo {
public void setHostName(String hostName){
this.hostName = hostName;
}
/**
* 获取 目标服务
* @return String
*/
public String getTargetServer(){
return targetServer;
}
/**
* 设置 目标服务
* @param targetServer
*/
public void setTargetServer(String targetServer){
this.targetServer = targetServer;
}
/**
* 获取 日志等级
* @return String
......@@ -185,29 +251,29 @@ public class AccessLogEntity extends AccessLogVo {
* 获取 请求参数,json序列化
* @return String
*/
public String getRequestParam(){
return requestParam;
public String getRequestData(){
return requestData;
}
/**
* 设置 请求参数,json序列化
* @param requestParam
* @param requestData
*/
public void setRequestParam(String requestParam){
this.requestParam = requestParam;
public void setRequestData(String requestData){
this.requestData = requestData;
}
/**
* 获取 响应结果
* 获取 响应结果,
* @return String
*/
public String getResponse(){
return response;
public String getResponseData(){
return responseData;
}
/**
* 设置 响应结果
* @param response
* 设置 响应结果,
* @param responseData
*/
public void setResponse(String response){
this.response = response;
public void setResponseData(String responseData){
this.responseData = responseData;
}
/**
* 获取 日志产生时间
......@@ -223,20 +289,62 @@ public class AccessLogEntity extends AccessLogVo {
public void setLogTime(Date logTime){
this.logTime = logTime;
}
/**
* 获取 请求时间
* @return Date
*/
public Date getRequestTime(){
return requestTime;
}
/**
* 设置 请求时间
* @param requestTime
*/
public void setRequestTime(Date requestTime){
this.requestTime = requestTime;
}
/**
* 获取 响应时间
* @return Date
*/
public Date getResponseTime(){
return responseTime;
}
/**
* 设置 响应时间
* @param responseTime
*/
public void setResponseTime(Date responseTime){
this.responseTime = responseTime;
}
/**
* 获取 持续时间,单位毫秒
* @return Integer
* @return Long
*/
public Integer getDuration(){
public Long getDuration(){
return duration;
}
/**
* 设置 持续时间,单位毫秒
* @param duration
*/
public void setDuration(Integer duration){
public void setDuration(Long duration){
this.duration = duration;
}
/**
* 获取 协议
* @return String
*/
public String getSchemaData(){
return schemaData;
}
/**
* 设置 协议
* @param schemaData
*/
public void setSchemaData(String schemaData){
this.schemaData = schemaData;
}
......@@ -260,17 +368,23 @@ public class AccessLogEntity extends AccessLogVo {
public String toString(){
StringBuilder sb = new StringBuilder("");
sb.append(",traceID:").append(getTraceID());
sb.append(",pspanId:").append(getPspanId());
sb.append(",spanId:").append(getSpanId());
sb.append(",appName:").append(getAppName());
sb.append(",hostName:").append(getHostName());
sb.append(",targetServer:").append(getTargetServer());
sb.append(",logLevel:").append(getLogLevel());
sb.append(",requestIp:").append(getRequestIp());
sb.append(",method:").append(getMethod());
sb.append(",ua:").append(getUa());
sb.append(",uri:").append(getUri());
sb.append(",requestParam:").append(getRequestParam());
sb.append(",response:").append(getResponse());
sb.append(",requestData:").append(getRequestData());
sb.append(",responseData:").append(getResponseData());
sb.append(",logTime:").append(getLogTime());
sb.append(",requestTime:").append(getRequestTime());
sb.append(",responseTime:").append(getResponseTime());
sb.append(",duration:").append(getDuration());
sb.append(",schemaData:").append(getSchemaData());
return sb.toString();
}
......@@ -278,11 +392,17 @@ public class AccessLogEntity extends AccessLogVo {
this.traceID = "";
this.pspanId = 0;
this.spanId = null;
this.appName = "";
this.hostName = "";
this.logLevel = "";
this.targetServer = "";
this.logLevel = "INFO";
this.requestIp = "";
......@@ -292,12 +412,18 @@ public class AccessLogEntity extends AccessLogVo {
this.uri = "";
this.requestParam = "";
this.requestData = "";
this.response = "";
this.responseData = "";
this.logTime = null;
this.requestTime = null;
this.responseTime = null;
this.duration = null;
this.schemaData = "http";
}
}
\ No newline at end of file
......@@ -4,33 +4,60 @@ import java.util.Date;
import java.util.List;
import com.mortals.xhx.module.access.model.AccessLogEntity;
/**
* 访问日志查询对象
*
* @author zxfei
* @date 2022-08-17
*/
* 访问日志查询对象
*
* @author zxfei
* @date 2022-08-22
*/
public class AccessLogQuery extends AccessLogEntity {
/** 开始 主键ID,主键,自增长 */
/** 开始 主键ID */
private Long idStart;
/** 结束 主键ID,主键,自增长 */
/** 结束 主键ID */
private Long idEnd;
/** 增加 主键ID,主键,自增长 */
/** 增加 主键ID */
private Long idIncrement;
/** 主键ID,主键,自增长列表 */
/** 主键ID列表 */
private List <Long> idList;
/** 追踪Id */
/** TraceId */
private List<String> traceIDList;
/** 开始 父服务调用id */
private Integer pspanIdStart;
/** 结束 父服务调用id */
private Integer pspanIdEnd;
/** 增加 父服务调用id */
private Integer pspanIdIncrement;
/** 父服务调用id列表 */
private List <Integer> pspanIdList;
/** 开始 当前服务跨度Id */
private Integer spanIdStart;
/** 结束 当前服务跨度Id */
private Integer spanIdEnd;
/** 增加 当前服务跨度Id */
private Integer spanIdIncrement;
/** 当前服务跨度Id列表 */
private List <Integer> spanIdList;
/** 应用名称 */
private List<String> appNameList;
/** 实例IP */
private List<String> hostNameList;
/** 目标服务 */
private List<String> targetServerList;
/** 日志等级 */
private List<String> logLevelList;
......@@ -47,10 +74,10 @@ public class AccessLogQuery extends AccessLogEntity {
private List<String> uriList;
/** 请求参数,json序列化 */
private List<String> requestParamList;
private List<String> requestDataList;
/** 响应结果 */
private List<String> responseList;
/** 响应结果, */
private List<String> responseDataList;
/** 开始 日志产生时间 */
private String logTimeStart;
......@@ -58,17 +85,29 @@ public class AccessLogQuery extends AccessLogEntity {
/** 结束 日志产生时间 */
private String logTimeEnd;
/** 开始 请求时间 */
private String requestTimeStart;
/** 结束 请求时间 */
private String requestTimeEnd;
/** 开始 响应时间 */
private String responseTimeStart;
/** 结束 响应时间 */
private String responseTimeEnd;
/** 开始 持续时间,单位毫秒 */
private Integer durationStart;
private Long durationStart;
/** 结束 持续时间,单位毫秒 */
private Integer durationEnd;
private Long durationEnd;
/** 增加 持续时间,单位毫秒 */
private Integer durationIncrement;
private Long durationIncrement;
/** 持续时间,单位毫秒列表 */
private List <Integer> durationList;
private List <Long> durationList;
/** 开始 创建用户 */
private Long createUserIdStart;
......@@ -88,6 +127,9 @@ public class AccessLogQuery extends AccessLogEntity {
/** 结束 创建时间 */
private String createTimeEnd;
/** 协议 */
private List<String> schemaDataList;
/** OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4) */
private List<AccessLogQuery> orConditionList;
......@@ -97,7 +139,7 @@ public class AccessLogQuery extends AccessLogEntity {
public AccessLogQuery(){}
/**
* 获取 开始 主键ID,主键,自增长
* 获取 开始 主键ID
* @return idStart
*/
public Long getIdStart(){
......@@ -105,7 +147,7 @@ public class AccessLogQuery extends AccessLogEntity {
}
/**
* 设置 开始 主键ID,主键,自增长
* 设置 开始 主键ID
* @param idStart
*/
public void setIdStart(Long idStart){
......@@ -113,7 +155,7 @@ public class AccessLogQuery extends AccessLogEntity {
}
/**
* 获取 结束 主键ID,主键,自增长
* 获取 结束 主键ID
* @return $idEnd
*/
public Long getIdEnd(){
......@@ -121,7 +163,7 @@ public class AccessLogQuery extends AccessLogEntity {
}
/**
* 设置 结束 主键ID,主键,自增长
* 设置 结束 主键ID
* @param idEnd
*/
public void setIdEnd(Long idEnd){
......@@ -129,7 +171,7 @@ public class AccessLogQuery extends AccessLogEntity {
}
/**
* 获取 增加 主键ID,主键,自增长
* 获取 增加 主键ID
* @return idIncrement
*/
public Long getIdIncrement(){
......@@ -137,7 +179,7 @@ public class AccessLogQuery extends AccessLogEntity {
}
/**
* 设置 增加 主键ID,主键,自增长
* 设置 增加 主键ID
* @param idIncrement
*/
public void setIdIncrement(Long idIncrement){
......@@ -145,7 +187,7 @@ public class AccessLogQuery extends AccessLogEntity {
}
/**
* 获取 主键ID,主键,自增长
* 获取 主键ID
* @return idList
*/
public List<Long> getIdList(){
......@@ -153,7 +195,7 @@ public class AccessLogQuery extends AccessLogEntity {
}
/**
* 设置 主键ID,主键,自增长
* 设置 主键ID
* @param idList
*/
public void setIdList(List<Long> idList){
......@@ -161,7 +203,7 @@ public class AccessLogQuery extends AccessLogEntity {
}
/**
* 获取 追踪Id
* 获取 TraceId
* @return traceIDList
*/
public List<String> getTraceIDList(){
......@@ -169,12 +211,140 @@ public class AccessLogQuery extends AccessLogEntity {
}
/**
* 设置 追踪Id
* 设置 TraceId
* @param traceIDList
*/
public void setTraceIDList(List<String> traceIDList){
this.traceIDList = traceIDList;
}
/**
* 获取 开始 父服务调用id
* @return pspanIdStart
*/
public Integer getPspanIdStart(){
return this.pspanIdStart;
}
/**
* 设置 开始 父服务调用id
* @param pspanIdStart
*/
public void setPspanIdStart(Integer pspanIdStart){
this.pspanIdStart = pspanIdStart;
}
/**
* 获取 结束 父服务调用id
* @return $pspanIdEnd
*/
public Integer getPspanIdEnd(){
return this.pspanIdEnd;
}
/**
* 设置 结束 父服务调用id
* @param pspanIdEnd
*/
public void setPspanIdEnd(Integer pspanIdEnd){
this.pspanIdEnd = pspanIdEnd;
}
/**
* 获取 增加 父服务调用id
* @return pspanIdIncrement
*/
public Integer getPspanIdIncrement(){
return this.pspanIdIncrement;
}
/**
* 设置 增加 父服务调用id
* @param pspanIdIncrement
*/
public void setPspanIdIncrement(Integer pspanIdIncrement){
this.pspanIdIncrement = pspanIdIncrement;
}
/**
* 获取 父服务调用id
* @return pspanIdList
*/
public List<Integer> getPspanIdList(){
return this.pspanIdList;
}
/**
* 设置 父服务调用id
* @param pspanIdList
*/
public void setPspanIdList(List<Integer> pspanIdList){
this.pspanIdList = pspanIdList;
}
/**
* 获取 开始 当前服务跨度Id
* @return spanIdStart
*/
public Integer getSpanIdStart(){
return this.spanIdStart;
}
/**
* 设置 开始 当前服务跨度Id
* @param spanIdStart
*/
public void setSpanIdStart(Integer spanIdStart){
this.spanIdStart = spanIdStart;
}
/**
* 获取 结束 当前服务跨度Id
* @return $spanIdEnd
*/
public Integer getSpanIdEnd(){
return this.spanIdEnd;
}
/**
* 设置 结束 当前服务跨度Id
* @param spanIdEnd
*/
public void setSpanIdEnd(Integer spanIdEnd){
this.spanIdEnd = spanIdEnd;
}
/**
* 获取 增加 当前服务跨度Id
* @return spanIdIncrement
*/
public Integer getSpanIdIncrement(){
return this.spanIdIncrement;
}
/**
* 设置 增加 当前服务跨度Id
* @param spanIdIncrement
*/
public void setSpanIdIncrement(Integer spanIdIncrement){
this.spanIdIncrement = spanIdIncrement;
}
/**
* 获取 当前服务跨度Id
* @return spanIdList
*/
public List<Integer> getSpanIdList(){
return this.spanIdList;
}
/**
* 设置 当前服务跨度Id
* @param spanIdList
*/
public void setSpanIdList(List<Integer> spanIdList){
this.spanIdList = spanIdList;
}
/**
* 获取 应用名称
* @return appNameList
......@@ -205,6 +375,21 @@ public class AccessLogQuery extends AccessLogEntity {
public void setHostNameList(List<String> hostNameList){
this.hostNameList = hostNameList;
}
/**
* 获取 目标服务
* @return targetServerList
*/
public List<String> getTargetServerList(){
return this.targetServerList;
}
/**
* 设置 目标服务
* @param targetServerList
*/
public void setTargetServerList(List<String> targetServerList){
this.targetServerList = targetServerList;
}
/**
* 获取 日志等级
* @return logLevelList
......@@ -282,33 +467,33 @@ public class AccessLogQuery extends AccessLogEntity {
}
/**
* 获取 请求参数,json序列化
* @return requestParamList
* @return requestDataList
*/
public List<String> getRequestParamList(){
return this.requestParamList;
public List<String> getRequestDataList(){
return this.requestDataList;
}
/**
* 设置 请求参数,json序列化
* @param requestParamList
* @param requestDataList
*/
public void setRequestParamList(List<String> requestParamList){
this.requestParamList = requestParamList;
public void setRequestDataList(List<String> requestDataList){
this.requestDataList = requestDataList;
}
/**
* 获取 响应结果
* @return responseList
* 获取 响应结果,
* @return responseDataList
*/
public List<String> getResponseList(){
return this.responseList;
public List<String> getResponseDataList(){
return this.responseDataList;
}
/**
* 设置 响应结果
* @param responseList
* 设置 响应结果,
* @param responseDataList
*/
public void setResponseList(List<String> responseList){
this.responseList = responseList;
public void setResponseDataList(List<String> responseDataList){
this.responseDataList = responseDataList;
}
/**
* 获取 开始 日志产生时间
......@@ -342,11 +527,75 @@ public class AccessLogQuery extends AccessLogEntity {
this.logTimeEnd = logTimeEnd;
}
/**
* 获取 开始 请求时间
* @return requestTimeStart
*/
public String getRequestTimeStart(){
return this.requestTimeStart;
}
/**
* 设置 开始 请求时间
* @param requestTimeStart
*/
public void setRequestTimeStart(String requestTimeStart){
this.requestTimeStart = requestTimeStart;
}
/**
* 获取 结束 请求时间
* @return requestTimeEnd
*/
public String getRequestTimeEnd(){
return this.requestTimeEnd;
}
/**
* 设置 结束 请求时间
* @param requestTimeEnd
*/
public void setRequestTimeEnd(String requestTimeEnd){
this.requestTimeEnd = requestTimeEnd;
}
/**
* 获取 开始 响应时间
* @return responseTimeStart
*/
public String getResponseTimeStart(){
return this.responseTimeStart;
}
/**
* 设置 开始 响应时间
* @param responseTimeStart
*/
public void setResponseTimeStart(String responseTimeStart){
this.responseTimeStart = responseTimeStart;
}
/**
* 获取 结束 响应时间
* @return responseTimeEnd
*/
public String getResponseTimeEnd(){
return this.responseTimeEnd;
}
/**
* 设置 结束 响应时间
* @param responseTimeEnd
*/
public void setResponseTimeEnd(String responseTimeEnd){
this.responseTimeEnd = responseTimeEnd;
}
/**
* 获取 开始 持续时间,单位毫秒
* @return durationStart
*/
public Integer getDurationStart(){
public Long getDurationStart(){
return this.durationStart;
}
......@@ -354,7 +603,7 @@ public class AccessLogQuery extends AccessLogEntity {
* 设置 开始 持续时间,单位毫秒
* @param durationStart
*/
public void setDurationStart(Integer durationStart){
public void setDurationStart(Long durationStart){
this.durationStart = durationStart;
}
......@@ -362,7 +611,7 @@ public class AccessLogQuery extends AccessLogEntity {
* 获取 结束 持续时间,单位毫秒
* @return $durationEnd
*/
public Integer getDurationEnd(){
public Long getDurationEnd(){
return this.durationEnd;
}
......@@ -370,7 +619,7 @@ public class AccessLogQuery extends AccessLogEntity {
* 设置 结束 持续时间,单位毫秒
* @param durationEnd
*/
public void setDurationEnd(Integer durationEnd){
public void setDurationEnd(Long durationEnd){
this.durationEnd = durationEnd;
}
......@@ -378,7 +627,7 @@ public class AccessLogQuery extends AccessLogEntity {
* 获取 增加 持续时间,单位毫秒
* @return durationIncrement
*/
public Integer getDurationIncrement(){
public Long getDurationIncrement(){
return this.durationIncrement;
}
......@@ -386,7 +635,7 @@ public class AccessLogQuery extends AccessLogEntity {
* 设置 增加 持续时间,单位毫秒
* @param durationIncrement
*/
public void setDurationIncrement(Integer durationIncrement){
public void setDurationIncrement(Long durationIncrement){
this.durationIncrement = durationIncrement;
}
......@@ -394,7 +643,7 @@ public class AccessLogQuery extends AccessLogEntity {
* 获取 持续时间,单位毫秒
* @return durationList
*/
public List<Integer> getDurationList(){
public List<Long> getDurationList(){
return this.durationList;
}
......@@ -402,7 +651,7 @@ public class AccessLogQuery extends AccessLogEntity {
* 设置 持续时间,单位毫秒
* @param durationList
*/
public void setDurationList(List<Integer> durationList){
public void setDurationList(List<Long> durationList){
this.durationList = durationList;
}
......@@ -503,7 +752,22 @@ public class AccessLogQuery extends AccessLogEntity {
}
/**
* 设置 主键ID,主键,自增长
* 获取 协议
* @return schemaDataList
*/
public List<String> getSchemaDataList(){
return this.schemaDataList;
}
/**
* 设置 协议
* @param schemaDataList
*/
public void setSchemaDataList(List<String> schemaDataList){
this.schemaDataList = schemaDataList;
}
/**
* 设置 主键ID
* @param id
*/
public AccessLogQuery id(Long id){
......@@ -512,7 +776,7 @@ public class AccessLogQuery extends AccessLogEntity {
}
/**
* 设置 开始 主键ID,主键,自增长
* 设置 开始 主键ID
* @param idStart
*/
public AccessLogQuery idStart(Long idStart){
......@@ -521,7 +785,7 @@ public class AccessLogQuery extends AccessLogEntity {
}
/**
* 设置 结束 主键ID,主键,自增长
* 设置 结束 主键ID
* @param idEnd
*/
public AccessLogQuery idEnd(Long idEnd){
......@@ -530,7 +794,7 @@ public class AccessLogQuery extends AccessLogEntity {
}
/**
* 设置 增加 主键ID,主键,自增长
* 设置 增加 主键ID
* @param idIncrement
*/
public AccessLogQuery idIncrement(Long idIncrement){
......@@ -539,7 +803,7 @@ public class AccessLogQuery extends AccessLogEntity {
}
/**
* 设置 主键ID,主键,自增长
* 设置 主键ID
* @param idList
*/
public AccessLogQuery idList(List<Long> idList){
......@@ -549,7 +813,7 @@ public class AccessLogQuery extends AccessLogEntity {
/**
* 设置 追踪Id
* 设置 TraceId
* @param traceID
*/
public AccessLogQuery traceID(String traceID){
......@@ -558,7 +822,7 @@ public class AccessLogQuery extends AccessLogEntity {
}
/**
* 设置 追踪Id
* 设置 TraceId
* @param traceIDList
*/
public AccessLogQuery traceIDList(List<String> traceIDList){
......@@ -566,6 +830,96 @@ public class AccessLogQuery extends AccessLogEntity {
return this;
}
/**
* 设置 父服务调用id
* @param pspanId
*/
public AccessLogQuery pspanId(Integer pspanId){
setPspanId(pspanId);
return this;
}
/**
* 设置 开始 父服务调用id
* @param pspanIdStart
*/
public AccessLogQuery pspanIdStart(Integer pspanIdStart){
this.pspanIdStart = pspanIdStart;
return this;
}
/**
* 设置 结束 父服务调用id
* @param pspanIdEnd
*/
public AccessLogQuery pspanIdEnd(Integer pspanIdEnd){
this.pspanIdEnd = pspanIdEnd;
return this;
}
/**
* 设置 增加 父服务调用id
* @param pspanIdIncrement
*/
public AccessLogQuery pspanIdIncrement(Integer pspanIdIncrement){
this.pspanIdIncrement = pspanIdIncrement;
return this;
}
/**
* 设置 父服务调用id
* @param pspanIdList
*/
public AccessLogQuery pspanIdList(List<Integer> pspanIdList){
this.pspanIdList = pspanIdList;
return this;
}
/**
* 设置 当前服务跨度Id
* @param spanId
*/
public AccessLogQuery spanId(Integer spanId){
setSpanId(spanId);
return this;
}
/**
* 设置 开始 当前服务跨度Id
* @param spanIdStart
*/
public AccessLogQuery spanIdStart(Integer spanIdStart){
this.spanIdStart = spanIdStart;
return this;
}
/**
* 设置 结束 当前服务跨度Id
* @param spanIdEnd
*/
public AccessLogQuery spanIdEnd(Integer spanIdEnd){
this.spanIdEnd = spanIdEnd;
return this;
}
/**
* 设置 增加 当前服务跨度Id
* @param spanIdIncrement
*/
public AccessLogQuery spanIdIncrement(Integer spanIdIncrement){
this.spanIdIncrement = spanIdIncrement;
return this;
}
/**
* 设置 当前服务跨度Id
* @param spanIdList
*/
public AccessLogQuery spanIdList(List<Integer> spanIdList){
this.spanIdList = spanIdList;
return this;
}
/**
* 设置 应用名称
......@@ -605,6 +959,25 @@ public class AccessLogQuery extends AccessLogEntity {
}
/**
* 设置 目标服务
* @param targetServer
*/
public AccessLogQuery targetServer(String targetServer){
setTargetServer(targetServer);
return this;
}
/**
* 设置 目标服务
* @param targetServerList
*/
public AccessLogQuery targetServerList(List<String> targetServerList){
this.targetServerList = targetServerList;
return this;
}
/**
* 设置 日志等级
* @param logLevel
......@@ -702,47 +1075,49 @@ public class AccessLogQuery extends AccessLogEntity {
/**
* 设置 请求参数,json序列化
* @param requestParam
* @param requestData
*/
public AccessLogQuery requestParam(String requestParam){
setRequestParam(requestParam);
public AccessLogQuery requestData(String requestData){
setRequestData(requestData);
return this;
}
/**
* 设置 请求参数,json序列化
* @param requestParamList
* @param requestDataList
*/
public AccessLogQuery requestParamList(List<String> requestParamList){
this.requestParamList = requestParamList;
public AccessLogQuery requestDataList(List<String> requestDataList){
this.requestDataList = requestDataList;
return this;
}
/**
* 设置 响应结果
* @param response
* 设置 响应结果,
* @param responseData
*/
public AccessLogQuery response(String response){
setResponse(response);
public AccessLogQuery responseData(String responseData){
setResponseData(responseData);
return this;
}
/**
* 设置 响应结果
* @param responseList
* 设置 响应结果,
* @param responseDataList
*/
public AccessLogQuery responseList(List<String> responseList){
this.responseList = responseList;
public AccessLogQuery responseDataList(List<String> responseDataList){
this.responseDataList = responseDataList;
return this;
}
/**
* 设置 持续时间,单位毫秒
* @param duration
*/
public AccessLogQuery duration(Integer duration){
public AccessLogQuery duration(Long duration){
setDuration(duration);
return this;
}
......@@ -751,7 +1126,7 @@ public class AccessLogQuery extends AccessLogEntity {
* 设置 开始 持续时间,单位毫秒
* @param durationStart
*/
public AccessLogQuery durationStart(Integer durationStart){
public AccessLogQuery durationStart(Long durationStart){
this.durationStart = durationStart;
return this;
}
......@@ -760,7 +1135,7 @@ public class AccessLogQuery extends AccessLogEntity {
* 设置 结束 持续时间,单位毫秒
* @param durationEnd
*/
public AccessLogQuery durationEnd(Integer durationEnd){
public AccessLogQuery durationEnd(Long durationEnd){
this.durationEnd = durationEnd;
return this;
}
......@@ -769,7 +1144,7 @@ public class AccessLogQuery extends AccessLogEntity {
* 设置 增加 持续时间,单位毫秒
* @param durationIncrement
*/
public AccessLogQuery durationIncrement(Integer durationIncrement){
public AccessLogQuery durationIncrement(Long durationIncrement){
this.durationIncrement = durationIncrement;
return this;
}
......@@ -778,7 +1153,7 @@ public class AccessLogQuery extends AccessLogEntity {
* 设置 持续时间,单位毫秒
* @param durationList
*/
public AccessLogQuery durationList(List<Integer> durationList){
public AccessLogQuery durationList(List<Long> durationList){
this.durationList = durationList;
return this;
}
......@@ -829,6 +1204,25 @@ public class AccessLogQuery extends AccessLogEntity {
}
/**
* 设置 协议
* @param schemaData
*/
public AccessLogQuery schemaData(String schemaData){
setSchemaData(schemaData);
return this;
}
/**
* 设置 协议
* @param schemaDataList
*/
public AccessLogQuery schemaDataList(List<String> schemaDataList){
this.schemaDataList = schemaDataList;
return this;
}
/**
* 获取 OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4)
* @return orConditionList
......
......@@ -7,7 +7,7 @@ import java.util.List;
* 访问日志视图对象
*
* @author zxfei
* @date 2022-08-17
* @date 2022-08-19
*/
public class AccessLogVo extends BaseEntityLong {
......
package com.mortals.xhx.module.access.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.exception.AppException;
......@@ -6,6 +9,9 @@ import com.mortals.framework.model.Context;
import com.mortals.xhx.module.access.dao.AccessLogDao;
import com.mortals.xhx.module.access.model.AccessLogEntity;
import com.mortals.xhx.module.access.service.AccessLogService;
import java.util.Date;
/**
* AccessLogService
* 访问日志 service实现
......@@ -15,5 +21,26 @@ import com.mortals.xhx.module.access.service.AccessLogService;
*/
@Service("accessLogService")
public class AccessLogServiceImpl extends AbstractCRUDServiceImpl<AccessLogDao, AccessLogEntity, Long> implements AccessLogService {
@Override
public AccessLogEntity get(Long key, Context context) throws AppException {
AccessLogEntity accessLogEntity = new AccessLogEntity();
Snowflake snowflake = IdUtil.getSnowflake(0, 1);
long generateDateTime = snowflake.getGenerateDateTime(key);
accessLogEntity.setCreateTime(new Date(generateDateTime));
return this.getDao().get(key,accessLogEntity);
//return super.get(key, context);
}
public static void main(String[] args) {
Snowflake snowflake = IdUtil.getSnowflake(0, 1);
long id = snowflake.nextId();
System.out.println(id);
long generateDateTime = snowflake.getGenerateDateTime(id);
System.out.println(DateUtil.date(generateDateTime).toString());
}
}
\ No newline at end of file
package com.mortals.xhx.module.access.web;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.OrderCol;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -13,12 +15,10 @@ import com.mortals.xhx.module.access.model.AccessLogEntity;
import com.mortals.xhx.module.access.service.AccessLogService;
import org.apache.commons.lang3.ArrayUtils;
import com.mortals.framework.util.StringUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject;
import java.util.Arrays;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import static com.mortals.framework.ap.SysConstains.*;
......@@ -46,4 +46,19 @@ public class AccessLogController extends BaseCRUDJsonBodyMappingController<Acces
}
@Override
protected void doListBefore(AccessLogEntity query, Map<String, Object> model, Context context) throws AppException {
List<OrderCol> orderColList = new ArrayList<>();
orderColList.add(new OrderCol("createTime", OrderCol.DESCENDING));
query.setOrderColList(orderColList);
super.doListBefore(query, model, context);
}
@Override
public String view(Long id) {
return super.view(id);
}
}
\ No newline at end of file
package com.mortals.xhx.module.biz.service.impl;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import com.mortals.xhx.module.access.model.AccessLogEntity;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.exception.AppException;
......@@ -6,6 +9,9 @@ import com.mortals.framework.model.Context;
import com.mortals.xhx.module.biz.dao.BizLogDao;
import com.mortals.xhx.module.biz.model.BizLogEntity;
import com.mortals.xhx.module.biz.service.BizLogService;
import java.util.Date;
/**
* BizLogService
* 业务日志 service实现
......@@ -16,4 +22,12 @@ import com.mortals.xhx.module.biz.service.BizLogService;
@Service("bizLogService")
public class BizLogServiceImpl extends AbstractCRUDServiceImpl<BizLogDao, BizLogEntity, Long> implements BizLogService {
@Override
public BizLogEntity get(Long key, Context context) throws AppException {
BizLogEntity bizLogEntity = new BizLogEntity();
Snowflake snowflake = IdUtil.getSnowflake(0, 1);
long generateDateTime = snowflake.getGenerateDateTime(key);
bizLogEntity.setCreateTime(new Date(generateDateTime));
return this.getDao().get(key,bizLogEntity);
}
}
\ No newline at end of file
package com.mortals.xhx.module.biz.web;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.OrderCol;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -13,12 +15,10 @@ import com.mortals.xhx.module.biz.model.BizLogEntity;
import com.mortals.xhx.module.biz.service.BizLogService;
import org.apache.commons.lang3.ArrayUtils;
import com.mortals.framework.util.StringUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject;
import java.util.Arrays;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import static com.mortals.framework.ap.SysConstains.*;
......@@ -46,4 +46,12 @@ public class BizLogController extends BaseCRUDJsonBodyMappingController<BizLogSe
}
@Override
protected void doListBefore(BizLogEntity query, Map<String, Object> model, Context context) throws AppException {
List<OrderCol> orderColList = new ArrayList<>();
orderColList.add(new OrderCol("createTime", OrderCol.DESCENDING));
query.setOrderColList(orderColList);
super.doListBefore(query, model, context);
}
}
\ No newline at end of file
......@@ -48,4 +48,6 @@ public class ErrorLogDaoImpl extends SubmeterDaoImpl<ErrorLogEntity,Long> implem
}
package com.mortals.xhx.module.error.service.impl;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import com.mortals.xhx.module.biz.model.BizLogEntity;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.exception.AppException;
......@@ -6,6 +9,9 @@ import com.mortals.framework.model.Context;
import com.mortals.xhx.module.error.dao.ErrorLogDao;
import com.mortals.xhx.module.error.model.ErrorLogEntity;
import com.mortals.xhx.module.error.service.ErrorLogService;
import java.util.Date;
/**
* ErrorLogService
* 异常日志 service实现
......@@ -16,4 +22,12 @@ import com.mortals.xhx.module.error.service.ErrorLogService;
@Service("errorLogService")
public class ErrorLogServiceImpl extends AbstractCRUDServiceImpl<ErrorLogDao, ErrorLogEntity, Long> implements ErrorLogService {
@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
package com.mortals.xhx.module.error.web;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.OrderCol;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -13,12 +15,10 @@ import com.mortals.xhx.module.error.model.ErrorLogEntity;
import com.mortals.xhx.module.error.service.ErrorLogService;
import org.apache.commons.lang3.ArrayUtils;
import com.mortals.framework.util.StringUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject;
import java.util.Arrays;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import static com.mortals.framework.ap.SysConstains.*;
......@@ -46,4 +46,12 @@ public class ErrorLogController extends BaseCRUDJsonBodyMappingController<ErrorL
}
@Override
protected void doListBefore(ErrorLogEntity query, Map<String, Object> model, Context context) throws AppException {
List<OrderCol> orderColList = new ArrayList<>();
orderColList.add(new OrderCol("createTime", OrderCol.DESCENDING));
query.setOrderColList(orderColList);
super.doListBefore(query, model, context);
}
}
\ No newline at end of file
package com.mortals.xhx.module.operate.service.impl;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import com.mortals.xhx.module.error.model.ErrorLogEntity;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.exception.AppException;
......@@ -6,6 +9,9 @@ import com.mortals.framework.model.Context;
import com.mortals.xhx.module.operate.dao.OperateLogDao;
import com.mortals.xhx.module.operate.model.OperateLogEntity;
import com.mortals.xhx.module.operate.service.OperateLogService;
import java.util.Date;
/**
* OperateLogService
* 平台用户操作日志业务 service实现
......@@ -16,4 +22,12 @@ import com.mortals.xhx.module.operate.service.OperateLogService;
@Service("operateLogService")
public class OperateLogServiceImpl extends AbstractCRUDServiceImpl<OperateLogDao, OperateLogEntity, Long> implements OperateLogService {
@Override
public OperateLogEntity get(Long key, Context context) throws AppException {
OperateLogEntity operateLogEntity = new OperateLogEntity();
Snowflake snowflake = IdUtil.getSnowflake(0, 1);
long generateDateTime = snowflake.getGenerateDateTime(key);
operateLogEntity.setCreateTime(new Date(generateDateTime));
return this.getDao().get(key,operateLogEntity);
}
}
\ No newline at end of file
package com.mortals.xhx.module.operate.web;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.OrderCol;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -13,12 +15,10 @@ import com.mortals.xhx.module.operate.model.OperateLogEntity;
import com.mortals.xhx.module.operate.service.OperateLogService;
import org.apache.commons.lang3.ArrayUtils;
import com.mortals.framework.util.StringUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject;
import java.util.Arrays;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import static com.mortals.framework.ap.SysConstains.*;
......@@ -46,5 +46,11 @@ public class OperateLogController extends BaseCRUDJsonBodyMappingController<Oper
super.init(model, context);
}
@Override
protected void doListBefore(OperateLogEntity query, Map<String, Object> model, Context context) throws AppException {
List<OrderCol> orderColList = new ArrayList<>();
orderColList.add(new OrderCol("createTime", OrderCol.DESCENDING));
query.setOrderColList(orderColList);
super.doListBefore(query, model, context);
}
}
\ No newline at end of file
server:
port: @profiles.server.port@
servlet:
context-path: /m
context-path: /logservice
spring:
application:
name: device-manager
name: log-manager
profiles:
active: @profiles.active@
servlet:
......@@ -17,11 +17,6 @@ spring:
default-property-inclusion: NON_NULL
# time-zone: GMT+8
# date-format: yyyy-MM-dd HH:mm:ss
security:
enable: true
user:
name: admin
password: 1
redis:
host: @profiles.redis.uri@
port: @profiles.redis.port@
......@@ -54,6 +49,7 @@ spring:
port: @profiles.rabbitmq.port@
username: @profiles.rabbitmq.username@
password: @profiles.rabbitmq.password@
virtualHost: @profiles.rabbitmq.virtualhost@
dao:
exceptiontranslation:
enabled: false
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"mybatis-3-mapper.dtd">
"mybatis-3-mapper.dtd">
<mapper namespace="com.mortals.xhx.module.access.dao.ibatis.AccessLogDaoImpl">
<!-- 字段和属性映射 -->
<resultMap type="AccessLogEntity" id="AccessLogEntity-Map">
<id property="id" column="id" />
<result property="traceID" column="traceID" />
<result property="pspanId" column="pspanId" />
<result property="spanId" column="spanId" />
<result property="appName" column="appName" />
<result property="hostName" column="hostName" />
<result property="targetServer" column="targetServer" />
<result property="logLevel" column="logLevel" />
<result property="requestIp" column="requestIp" />
<result property="method" column="method" />
<result property="ua" column="ua" />
<result property="uri" column="uri" />
<result property="requestParam" column="requestParam" />
<result property="response" column="response" />
<result property="requestData" column="requestData" />
<result property="responseData" column="responseData" />
<result property="logTime" column="logTime" />
<result property="requestTime" column="requestTime" />
<result property="responseTime" column="responseTime" />
<result property="duration" column="duration" />
<result property="createUserId" column="createUserId" />
<result property="createTime" column="createTime" />
<result property="schemaData" column="schemaData" />
</resultMap>
<update id="createTable" parameterType="paramDto">
CREATE TABLE `${tableName}`(
`id` bigint(20) AUTO_INCREMENT COMMENT '主键ID,主键,自增长',
`traceID` varchar(64) COMMENT '追踪Id',
`id` bigint(20) NOT NULL COMMENT '主键ID',
`traceID` varchar(64) COMMENT 'TraceId',
`pspanId` int(9) COMMENT '父服务调用id',
`spanId` int(9) COMMENT '当前服务跨度Id',
`appName` varchar(64) COMMENT '应用名称',
`hostName` varchar(64) COMMENT '实例IP',
`targetServer` varchar(64) COMMENT '目标服务',
`logLevel` varchar(64) COMMENT '日志等级',
`requestIp` varchar(64) COMMENT '请求者IP',
`method` varchar(64) COMMENT '请求方式',
`ua` varchar(64) COMMENT '用户浏览器UA',
`ua` varchar(256) COMMENT '用户浏览器UA',
`uri` varchar(64) COMMENT '请求URI',
`requestParam` text COMMENT '请求参数,json序列化',
`response` text COMMENT '响应结果',
`logTime` datetime COMMENT '日志产生时间',
`duration` int(4) COMMENT '持续时间,单位毫秒',
`requestData` varchar(2048) COMMENT '请求参数,json序列化',
`responseData` mediumtext COMMENT '响应结果,',
`logTime` datetime NOT NULL COMMENT '日志产生时间',
`requestTime` datetime COMMENT '请求时间',
`responseTime` datetime COMMENT '响应时间',
`duration` bigint(20) COMMENT '持续时间,单位毫秒',
`createUserId` bigint(20) NOT NULL COMMENT '创建用户',
`createTime` datetime NOT NULL COMMENT '创建时间',
`schemaData` varchar(64) COMMENT '协议',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='访问日志';
</update>
......@@ -53,12 +65,21 @@
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('traceID') or colPickMode == 1 and data.containsKey('traceID')))">
a.traceID,
</if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('pspanId') or colPickMode == 1 and data.containsKey('pspanId')))">
a.pspanId,
</if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('spanId') or colPickMode == 1 and data.containsKey('spanId')))">
a.spanId,
</if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('appName') or colPickMode == 1 and data.containsKey('appName')))">
a.appName,
</if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('hostName') or colPickMode == 1 and data.containsKey('hostName')))">
a.hostName,
</if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('targetServer') or colPickMode == 1 and data.containsKey('targetServer')))">
a.targetServer,
</if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('logLevel') or colPickMode == 1 and data.containsKey('logLevel')))">
a.logLevel,
</if>
......@@ -74,15 +95,21 @@
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('uri') or colPickMode == 1 and data.containsKey('uri')))">
a.uri,
</if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('requestParam') or colPickMode == 1 and data.containsKey('requestParam')))">
a.requestParam,
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('requestData') or colPickMode == 1 and data.containsKey('requestData')))">
a.requestData,
</if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('response') or colPickMode == 1 and data.containsKey('response')))">
a.response,
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('responseData') or colPickMode == 1 and data.containsKey('responseData')))">
a.responseData,
</if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('logTime') or colPickMode == 1 and data.containsKey('logTime')))">
a.logTime,
</if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('requestTime') or colPickMode == 1 and data.containsKey('requestTime')))">
a.requestTime,
</if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('responseTime') or colPickMode == 1 and data.containsKey('responseTime')))">
a.responseTime,
</if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('duration') or colPickMode == 1 and data.containsKey('duration')))">
a.duration,
</if>
......@@ -92,23 +119,26 @@
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('createTime') or colPickMode == 1 and data.containsKey('createTime')))">
a.createTime,
</if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('schemaData') or colPickMode == 1 and data.containsKey('schemaData')))">
a.schemaData,
</if>
</trim>
</sql>
<!-- 新增 区分主键自增加还是业务插入 -->
<insert id="insert" parameterType="AccessLogEntity" useGeneratedKeys="true" keyProperty="id">
<insert id="insert" parameterType="AccessLogEntity" >
insert into `${tableName}`
(traceID,appName,hostName,logLevel,requestIp,method,ua,uri,requestParam,response,logTime,duration,createUserId,createTime)
(id,traceID,pspanId,spanId,appName,hostName,targetServer,logLevel,requestIp,method,ua,uri,requestData,responseData,logTime,requestTime,responseTime,duration,createUserId,createTime,schemaData)
VALUES
(#{traceID},#{appName},#{hostName},#{logLevel},#{requestIp},#{method},#{ua},#{uri},#{requestParam},#{response},#{logTime},#{duration},#{createUserId},#{createTime})
(#{id},#{traceID},#{pspanId},#{spanId},#{appName},#{hostName},#{targetServer},#{logLevel},#{requestIp},#{method},#{ua},#{uri},#{requestData},#{responseData},#{logTime},#{requestTime},#{responseTime},#{duration},#{createUserId},#{createTime},#{schemaData})
</insert>
<!-- 批量新增 -->
<insert id="insertBatch" parameterType="paramDto">
insert into `${tableName}`
(traceID,appName,hostName,logLevel,requestIp,method,ua,uri,requestParam,response,logTime,duration,createUserId,createTime)
(id,traceID,pspanId,spanId,appName,hostName,targetServer,logLevel,requestIp,method,ua,uri,requestData,responseData,logTime,requestTime,responseTime,duration,createUserId,createTime,schemaData)
VALUES
<foreach collection="data.dataList" item="item" index="index" separator="," >
(#{item.traceID},#{item.appName},#{item.hostName},#{item.logLevel},#{item.requestIp},#{item.method},#{item.ua},#{item.uri},#{item.requestParam},#{item.response},#{item.logTime},#{item.duration},#{item.createUserId},#{item.createTime})
(#{item.id},#{item.traceID},#{item.pspanId},#{item.spanId},#{item.appName},#{item.hostName},#{item.targetServer},#{item.logLevel},#{item.requestIp},#{item.method},#{item.ua},#{item.uri},#{item.requestData},#{item.responseData},#{item.logTime},#{item.requestTime},#{item.responseTime},#{item.duration},#{item.createUserId},#{item.createTime},#{item.schemaData})
</foreach>
</insert>
......@@ -121,12 +151,27 @@
<if test="(colPickMode==0 and data.containsKey('traceID')) or (colPickMode==1 and !data.containsKey('traceID'))">
a.traceID=#{data.traceID},
</if>
<if test="(colPickMode==0 and data.containsKey('pspanId')) or (colPickMode==1 and !data.containsKey('pspanId'))">
a.pspanId=#{data.pspanId},
</if>
<if test="(colPickMode==0 and data.containsKey('pspanIdIncrement')) or (colPickMode==1 and !data.containsKey('pspanIdIncrement'))">
a.pspanId=ifnull(a.pspanId,0) + #{data.pspanIdIncrement},
</if>
<if test="(colPickMode==0 and data.containsKey('spanId')) or (colPickMode==1 and !data.containsKey('spanId'))">
a.spanId=#{data.spanId},
</if>
<if test="(colPickMode==0 and data.containsKey('spanIdIncrement')) or (colPickMode==1 and !data.containsKey('spanIdIncrement'))">
a.spanId=ifnull(a.spanId,0) + #{data.spanIdIncrement},
</if>
<if test="(colPickMode==0 and data.containsKey('appName')) or (colPickMode==1 and !data.containsKey('appName'))">
a.appName=#{data.appName},
</if>
<if test="(colPickMode==0 and data.containsKey('hostName')) or (colPickMode==1 and !data.containsKey('hostName'))">
a.hostName=#{data.hostName},
</if>
<if test="(colPickMode==0 and data.containsKey('targetServer')) or (colPickMode==1 and !data.containsKey('targetServer'))">
a.targetServer=#{data.targetServer},
</if>
<if test="(colPickMode==0 and data.containsKey('logLevel')) or (colPickMode==1 and !data.containsKey('logLevel'))">
a.logLevel=#{data.logLevel},
</if>
......@@ -142,15 +187,21 @@
<if test="(colPickMode==0 and data.containsKey('uri')) or (colPickMode==1 and !data.containsKey('uri'))">
a.uri=#{data.uri},
</if>
<if test="(colPickMode==0 and data.containsKey('requestParam')) or (colPickMode==1 and !data.containsKey('requestParam'))">
a.requestParam=#{data.requestParam},
<if test="(colPickMode==0 and data.containsKey('requestData')) or (colPickMode==1 and !data.containsKey('requestData'))">
a.requestData=#{data.requestData},
</if>
<if test="(colPickMode==0 and data.containsKey('response')) or (colPickMode==1 and !data.containsKey('response'))">
a.response=#{data.response},
<if test="(colPickMode==0 and data.containsKey('responseData')) or (colPickMode==1 and !data.containsKey('responseData'))">
a.responseData=#{data.responseData},
</if>
<if test="(colPickMode==0 and data.containsKey('logTime')) or (colPickMode==1 and !data.containsKey('logTime'))">
a.logTime=#{data.logTime},
</if>
<if test="(colPickMode==0 and data.containsKey('requestTime')) or (colPickMode==1 and !data.containsKey('requestTime'))">
a.requestTime=#{data.requestTime},
</if>
<if test="(colPickMode==0 and data.containsKey('responseTime')) or (colPickMode==1 and !data.containsKey('responseTime'))">
a.responseTime=#{data.responseTime},
</if>
<if test="(colPickMode==0 and data.containsKey('duration')) or (colPickMode==1 and !data.containsKey('duration'))">
a.duration=#{data.duration},
</if>
......@@ -166,6 +217,9 @@
<if test="(colPickMode==0 and data.containsKey('createTime')) or (colPickMode==1 and !data.containsKey('createTime'))">
a.createTime=#{data.createTime},
</if>
<if test="(colPickMode==0 and data.containsKey('schemaData')) or (colPickMode==1 and !data.containsKey('schemaData'))">
a.schemaData=#{data.schemaData},
</if>
</trim>
<trim suffixOverrides="where" suffix="">
where
......@@ -185,6 +239,30 @@
</if>
</foreach>
</trim>
<trim prefix="pspanId=(case" suffix="ELSE pspanId end),">
<foreach collection="data.dataList" item="item" index="index" separator="" >
<choose>
<when test="(colPickMode==0 and item.containsKey('pspanId')) or (colPickMode==1 and !item.containsKey('pspanId'))">
when a.id=#{item.id} then #{item.pspanId}
</when>
<when test="(colPickMode==0 and item.containsKey('pspanIdIncrement')) or (colPickMode==1 and !item.containsKey('pspanIdIncrement'))">
when a.id=#{item.id} then ifnull(a.pspanId,0) + #{item.pspanIdIncrement}
</when>
</choose>
</foreach>
</trim>
<trim prefix="spanId=(case" suffix="ELSE spanId end),">
<foreach collection="data.dataList" item="item" index="index" separator="" >
<choose>
<when test="(colPickMode==0 and item.containsKey('spanId')) or (colPickMode==1 and !item.containsKey('spanId'))">
when a.id=#{item.id} then #{item.spanId}
</when>
<when test="(colPickMode==0 and item.containsKey('spanIdIncrement')) or (colPickMode==1 and !item.containsKey('spanIdIncrement'))">
when a.id=#{item.id} then ifnull(a.spanId,0) + #{item.spanIdIncrement}
</when>
</choose>
</foreach>
</trim>
<trim prefix="appName=(case" suffix="ELSE appName end),">
<foreach collection="data.dataList" item="item" index="index" separator="" >
<if test="(colPickMode==0 and item.containsKey('appName')) or (colPickMode==1 and !item.containsKey('appName'))">
......@@ -199,6 +277,13 @@
</if>
</foreach>
</trim>
<trim prefix="targetServer=(case" suffix="ELSE targetServer end),">
<foreach collection="data.dataList" item="item" index="index" separator="" >
<if test="(colPickMode==0 and item.containsKey('targetServer')) or (colPickMode==1 and !item.containsKey('targetServer'))">
when a.id=#{item.id} then #{item.targetServer}
</if>
</foreach>
</trim>
<trim prefix="logLevel=(case" suffix="ELSE logLevel end),">
<foreach collection="data.dataList" item="item" index="index" separator="" >
<if test="(colPickMode==0 and item.containsKey('logLevel')) or (colPickMode==1 and !item.containsKey('logLevel'))">
......@@ -234,17 +319,17 @@
</if>
</foreach>
</trim>
<trim prefix="requestParam=(case" suffix="ELSE requestParam end),">
<trim prefix="requestData=(case" suffix="ELSE requestData end),">
<foreach collection="data.dataList" item="item" index="index" separator="" >
<if test="(colPickMode==0 and item.containsKey('requestParam')) or (colPickMode==1 and !item.containsKey('requestParam'))">
when a.id=#{item.id} then #{item.requestParam}
<if test="(colPickMode==0 and item.containsKey('requestData')) or (colPickMode==1 and !item.containsKey('requestData'))">
when a.id=#{item.id} then #{item.requestData}
</if>
</foreach>
</trim>
<trim prefix="response=(case" suffix="ELSE response end),">
<trim prefix="responseData=(case" suffix="ELSE responseData end),">
<foreach collection="data.dataList" item="item" index="index" separator="" >
<if test="(colPickMode==0 and item.containsKey('response')) or (colPickMode==1 and !item.containsKey('response'))">
when a.id=#{item.id} then #{item.response}
<if test="(colPickMode==0 and item.containsKey('responseData')) or (colPickMode==1 and !item.containsKey('responseData'))">
when a.id=#{item.id} then #{item.responseData}
</if>
</foreach>
</trim>
......@@ -255,6 +340,20 @@
</if>
</foreach>
</trim>
<trim prefix="requestTime=(case" suffix="ELSE requestTime end),">
<foreach collection="data.dataList" item="item" index="index" separator="" >
<if test="(colPickMode==0 and item.containsKey('requestTime')) or (colPickMode==1 and !item.containsKey('requestTime'))">
when a.id=#{item.id} then #{item.requestTime}
</if>
</foreach>
</trim>
<trim prefix="responseTime=(case" suffix="ELSE responseTime end),">
<foreach collection="data.dataList" item="item" index="index" separator="" >
<if test="(colPickMode==0 and item.containsKey('responseTime')) or (colPickMode==1 and !item.containsKey('responseTime'))">
when a.id=#{item.id} then #{item.responseTime}
</if>
</foreach>
</trim>
<trim prefix="duration=(case" suffix="ELSE duration end),">
<foreach collection="data.dataList" item="item" index="index" separator="" >
<choose>
......@@ -286,6 +385,13 @@
</if>
</foreach>
</trim>
<trim prefix="schemaData=(case" suffix="ELSE schemaData end),">
<foreach collection="data.dataList" item="item" index="index" separator="" >
<if test="(colPickMode==0 and item.containsKey('schemaData')) or (colPickMode==1 and !item.containsKey('schemaData'))">
when a.id=#{item.id} then #{item.schemaData}
</if>
</foreach>
</trim>
</trim>
where id in
<foreach collection="data.dataList" item="item" index="index" open="(" separator="," close=")">
......@@ -423,6 +529,48 @@
#{item}
</foreach>
</if>
<if test="conditionParamRef.containsKey('pspanId')">
<if test="conditionParamRef.pspanId != null ">
${_conditionType_} a.pspanId = #{${_conditionParam_}.pspanId}
</if>
<if test="conditionParamRef.pspanId == null">
${_conditionType_} a.pspanId is null
</if>
</if>
<if test="conditionParamRef.containsKey('pspanIdList')">
${_conditionType_} a.pspanId in
<foreach collection="conditionParamRef.pspanIdList" open="(" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
</if>
<if test="conditionParamRef.containsKey('pspanIdStart') and conditionParamRef.pspanIdStart != null">
${_conditionType_} a.pspanId <![CDATA[ >= ]]> #{${_conditionParam_}.pspanIdStart}
</if>
<if test="conditionParamRef.containsKey('pspanIdEnd') and conditionParamRef.pspanIdEnd != null">
${_conditionType_} a.pspanId <![CDATA[ <= ]]> #{${_conditionParam_}.pspanIdEnd}
</if>
<if test="conditionParamRef.containsKey('spanId')">
<if test="conditionParamRef.spanId != null ">
${_conditionType_} a.spanId = #{${_conditionParam_}.spanId}
</if>
<if test="conditionParamRef.spanId == null">
${_conditionType_} a.spanId is null
</if>
</if>
<if test="conditionParamRef.containsKey('spanIdList')">
${_conditionType_} a.spanId in
<foreach collection="conditionParamRef.spanIdList" open="(" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
</if>
<if test="conditionParamRef.containsKey('spanIdStart') and conditionParamRef.spanIdStart != null">
${_conditionType_} a.spanId <![CDATA[ >= ]]> #{${_conditionParam_}.spanIdStart}
</if>
<if test="conditionParamRef.containsKey('spanIdEnd') and conditionParamRef.spanIdEnd != null">
${_conditionType_} a.spanId <![CDATA[ <= ]]> #{${_conditionParam_}.spanIdEnd}
</if>
<if test="conditionParamRef.containsKey('appName')">
<if test="conditionParamRef.appName != null and conditionParamRef.appName != ''">
......@@ -454,6 +602,21 @@
</foreach>
</if>
<if test="conditionParamRef.containsKey('targetServer')">
<if test="conditionParamRef.targetServer != null and conditionParamRef.targetServer != ''">
${_conditionType_} a.targetServer like #{${_conditionParam_}.targetServer}
</if>
<if test="conditionParamRef.targetServer == null">
${_conditionType_} a.targetServer is null
</if>
</if>
<if test="conditionParamRef.containsKey('targetServerList')">
${_conditionType_} a.targetServer in
<foreach collection="conditionParamRef.targetServerList" open="(" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
</if>
<if test="conditionParamRef.containsKey('logLevel')">
<if test="conditionParamRef.logLevel != null and conditionParamRef.logLevel != ''">
${_conditionType_} a.logLevel like #{${_conditionParam_}.logLevel}
......@@ -529,32 +692,32 @@
</foreach>
</if>
<if test="conditionParamRef.containsKey('requestParam')">
<if test="conditionParamRef.requestParam != null and conditionParamRef.requestParam != ''">
${_conditionType_} a.requestParam like #{${_conditionParam_}.requestParam}
<if test="conditionParamRef.containsKey('requestData')">
<if test="conditionParamRef.requestData != null and conditionParamRef.requestData != ''">
${_conditionType_} a.requestData like #{${_conditionParam_}.requestData}
</if>
<if test="conditionParamRef.requestParam == null">
${_conditionType_} a.requestParam is null
<if test="conditionParamRef.requestData == null">
${_conditionType_} a.requestData is null
</if>
</if>
<if test="conditionParamRef.containsKey('requestParamList')">
${_conditionType_} a.requestParam in
<foreach collection="conditionParamRef.requestParamList" open="(" close=")" index="index" item="item" separator=",">
<if test="conditionParamRef.containsKey('requestDataList')">
${_conditionType_} a.requestData in
<foreach collection="conditionParamRef.requestDataList" open="(" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
</if>
<if test="conditionParamRef.containsKey('response')">
<if test="conditionParamRef.response != null and conditionParamRef.response != ''">
${_conditionType_} a.response like #{${_conditionParam_}.response}
<if test="conditionParamRef.containsKey('responseData')">
<if test="conditionParamRef.responseData != null and conditionParamRef.responseData != ''">
${_conditionType_} a.responseData like #{${_conditionParam_}.responseData}
</if>
<if test="conditionParamRef.response == null">
${_conditionType_} a.response is null
<if test="conditionParamRef.responseData == null">
${_conditionType_} a.responseData is null
</if>
</if>
<if test="conditionParamRef.containsKey('responseList')">
${_conditionType_} a.response in
<foreach collection="conditionParamRef.responseList" open="(" close=")" index="index" item="item" separator=",">
<if test="conditionParamRef.containsKey('responseDataList')">
${_conditionType_} a.responseData in
<foreach collection="conditionParamRef.responseDataList" open="(" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
</if>
......@@ -573,6 +736,36 @@
<if test="conditionParamRef.containsKey('logTimeEnd') and conditionParamRef.logTimeEnd != null and conditionParamRef.logTimeEnd!=''">
${_conditionType_} a.logTime <![CDATA[ <= ]]> STR_TO_DATE(left(concat(#{${_conditionParam_}.logTimeEnd},' 23:59:59'),19),'%Y-%m-%d %k:%i:%s')
</if>
<if test="conditionParamRef.containsKey('requestTime')">
<if test="conditionParamRef.requestTime != null ">
${_conditionType_} a.requestTime = #{${_conditionParam_}.requestTime}
</if>
<if test="conditionParamRef.requestTime == null">
${_conditionType_} a.requestTime is null
</if>
</if>
<if test="conditionParamRef.containsKey('requestTimeStart') and conditionParamRef.requestTimeStart != null and conditionParamRef.requestTimeStart!=''">
${_conditionType_} a.requestTime <![CDATA[ >= ]]> STR_TO_DATE(left(concat(#{${_conditionParam_}.requestTimeStart},' 00:00:00'),19),'%Y-%m-%d %k:%i:%s')
</if>
<if test="conditionParamRef.containsKey('requestTimeEnd') and conditionParamRef.requestTimeEnd != null and conditionParamRef.requestTimeEnd!=''">
${_conditionType_} a.requestTime <![CDATA[ <= ]]> STR_TO_DATE(left(concat(#{${_conditionParam_}.requestTimeEnd},' 23:59:59'),19),'%Y-%m-%d %k:%i:%s')
</if>
<if test="conditionParamRef.containsKey('responseTime')">
<if test="conditionParamRef.responseTime != null ">
${_conditionType_} a.responseTime = #{${_conditionParam_}.responseTime}
</if>
<if test="conditionParamRef.responseTime == null">
${_conditionType_} a.responseTime is null
</if>
</if>
<if test="conditionParamRef.containsKey('responseTimeStart') and conditionParamRef.responseTimeStart != null and conditionParamRef.responseTimeStart!=''">
${_conditionType_} a.responseTime <![CDATA[ >= ]]> STR_TO_DATE(left(concat(#{${_conditionParam_}.responseTimeStart},' 00:00:00'),19),'%Y-%m-%d %k:%i:%s')
</if>
<if test="conditionParamRef.containsKey('responseTimeEnd') and conditionParamRef.responseTimeEnd != null and conditionParamRef.responseTimeEnd!=''">
${_conditionType_} a.responseTime <![CDATA[ <= ]]> STR_TO_DATE(left(concat(#{${_conditionParam_}.responseTimeEnd},' 23:59:59'),19),'%Y-%m-%d %k:%i:%s')
</if>
<if test="conditionParamRef.containsKey('duration')">
<if test="conditionParamRef.duration != null ">
${_conditionType_} a.duration = #{${_conditionParam_}.duration}
......@@ -630,6 +823,21 @@
<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')
</if>
<if test="conditionParamRef.containsKey('schemaData')">
<if test="conditionParamRef.schemaData != null and conditionParamRef.schemaData != ''">
${_conditionType_} a.schemaData like #{${_conditionParam_}.schemaData}
</if>
<if test="conditionParamRef.schemaData == null">
${_conditionType_} a.schemaData is null
</if>
</if>
<if test="conditionParamRef.containsKey('schemaDataList')">
${_conditionType_} a.schemaData in
<foreach collection="conditionParamRef.schemaDataList" open="(" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
</if>
</sql>
<sql id="_orderCols_">
<if test="orderColList != null and !orderColList.isEmpty()">
......@@ -653,6 +861,16 @@
<if test='orderCol.traceID != null and "DESC".equalsIgnoreCase(orderCol.traceID)'>DESC</if>
,
</if>
<if test="orderCol.containsKey('pspanId')">
a.pspanId
<if test='orderCol.pspanId != null and "DESC".equalsIgnoreCase(orderCol.pspanId)'>DESC</if>
,
</if>
<if test="orderCol.containsKey('spanId')">
a.spanId
<if test='orderCol.spanId != null and "DESC".equalsIgnoreCase(orderCol.spanId)'>DESC</if>
,
</if>
<if test="orderCol.containsKey('appName')">
a.appName
<if test='orderCol.appName != null and "DESC".equalsIgnoreCase(orderCol.appName)'>DESC</if>
......@@ -663,6 +881,11 @@
<if test='orderCol.hostName != null and "DESC".equalsIgnoreCase(orderCol.hostName)'>DESC</if>
,
</if>
<if test="orderCol.containsKey('targetServer')">
a.targetServer
<if test='orderCol.targetServer != null and "DESC".equalsIgnoreCase(orderCol.targetServer)'>DESC</if>
,
</if>
<if test="orderCol.containsKey('logLevel')">
a.logLevel
<if test='orderCol.logLevel != null and "DESC".equalsIgnoreCase(orderCol.logLevel)'>DESC</if>
......@@ -688,14 +911,14 @@
<if test='orderCol.uri != null and "DESC".equalsIgnoreCase(orderCol.uri)'>DESC</if>
,
</if>
<if test="orderCol.containsKey('requestParam')">
a.requestParam
<if test='orderCol.requestParam != null and "DESC".equalsIgnoreCase(orderCol.requestParam)'>DESC</if>
<if test="orderCol.containsKey('requestData')">
a.requestData
<if test='orderCol.requestData != null and "DESC".equalsIgnoreCase(orderCol.requestData)'>DESC</if>
,
</if>
<if test="orderCol.containsKey('response')">
a.response
<if test='orderCol.response != null and "DESC".equalsIgnoreCase(orderCol.response)'>DESC</if>
<if test="orderCol.containsKey('responseData')">
a.responseData
<if test='orderCol.responseData != null and "DESC".equalsIgnoreCase(orderCol.responseData)'>DESC</if>
,
</if>
<if test="orderCol.containsKey('logTime')">
......@@ -703,6 +926,16 @@
<if test='orderCol.logTime != null and "DESC".equalsIgnoreCase(orderCol.logTime)'>DESC</if>
,
</if>
<if test="orderCol.containsKey('requestTime')">
a.requestTime
<if test='orderCol.requestTime != null and "DESC".equalsIgnoreCase(orderCol.requestTime)'>DESC</if>
,
</if>
<if test="orderCol.containsKey('responseTime')">
a.responseTime
<if test='orderCol.responseTime != null and "DESC".equalsIgnoreCase(orderCol.responseTime)'>DESC</if>
,
</if>
<if test="orderCol.containsKey('duration')">
a.duration
<if test='orderCol.duration != null and "DESC".equalsIgnoreCase(orderCol.duration)'>DESC</if>
......@@ -718,6 +951,11 @@
<if test='orderCol.createTime != null and "DESC".equalsIgnoreCase(orderCol.createTime)'>DESC</if>
,
</if>
<if test="orderCol.containsKey('schemaData')">
a.schemaData
<if test='orderCol.schemaData != null and "DESC".equalsIgnoreCase(orderCol.schemaData)'>DESC</if>
,
</if>
</trim>
</if>
</sql>
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"mybatis-3-mapper.dtd">
"mybatis-3-mapper.dtd">
<mapper namespace="com.mortals.xhx.module.operate.dao.ibatis.OperateLogDaoImpl">
<!-- 字段和属性映射 -->
......@@ -22,13 +22,13 @@
<update id="createTable" parameterType="paramDto">
CREATE TABLE `${tableName}`(
`id` bigint(20) AUTO_INCREMENT COMMENT '序号,主键,自增长',
`id` bigint(20) COMMENT '主键ID',
`platformMark` varchar(50) COMMENT '平台标识',
`userId` bigint(20) COMMENT '用户id',
`userName` varchar(50) COMMENT '用户名称',
`loginName` varchar(50) COMMENT '用户登录名',
`requestUrl` varchar(200) COMMENT '请求地址',
`content` varchar(2000) COMMENT '操作内容,记录操作具体信息,如修改前修改或的数据',
`content` varchar(2048) COMMENT '操作内容,记录操作具体信息,如修改前修改或的数据',
`ip` varchar(30) COMMENT '操作IP地址',
`logDate` datetime COMMENT '操作时间',
`operType` tinyint(2) COMMENT '操作类型,0:新增,1:修改,2:删除',
......@@ -80,20 +80,20 @@
</trim>
</sql>
<!-- 新增 区分主键自增加还是业务插入 -->
<insert id="insert" parameterType="OperateLogEntity" useGeneratedKeys="true" keyProperty="id">
<insert id="insert" parameterType="OperateLogEntity" >
insert into `${tableName}`
(platformMark,userId,userName,loginName,requestUrl,content,ip,logDate,operType,createUserId,createTime)
(id,platformMark,userId,userName,loginName,requestUrl,content,ip,logDate,operType,createUserId,createTime)
VALUES
(#{platformMark},#{userId},#{userName},#{loginName},#{requestUrl},#{content},#{ip},#{logDate},#{operType},#{createUserId},#{createTime})
(#{id},#{platformMark},#{userId},#{userName},#{loginName},#{requestUrl},#{content},#{ip},#{logDate},#{operType},#{createUserId},#{createTime})
</insert>
<!-- 批量新增 -->
<insert id="insertBatch" parameterType="paramDto">
insert into `${tableName}`
(platformMark,userId,userName,loginName,requestUrl,content,ip,logDate,operType,createUserId,createTime)
(id,platformMark,userId,userName,loginName,requestUrl,content,ip,logDate,operType,createUserId,createTime)
VALUES
<foreach collection="data.dataList" item="item" index="index" separator="," >
(#{item.platformMark},#{item.userId},#{item.userName},#{item.loginName},#{item.requestUrl},#{item.content},#{item.ip},#{item.logDate},#{item.operType},#{item.createUserId},#{item.createTime})
(#{item.id},#{item.platformMark},#{item.userId},#{item.userName},#{item.loginName},#{item.requestUrl},#{item.content},#{item.ip},#{item.logDate},#{item.operType},#{item.createUserId},#{item.createTime})
</foreach>
</insert>
......
package producer;
import cn.hutool.core.util.IdUtil;
import com.mortals.xhx.ManagerApplication;
import com.mortals.xhx.base.system.message.MessageProducer;
import com.mortals.xhx.module.biz.model.BizLogEntity;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.Date;
import java.util.concurrent.CountDownLatch;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = ManagerApplication.class)
@Slf4j
public class ProducerTest {
@Autowired
private MessageProducer producer;
@Test
public void testSyncSend() {
//for (int i)
while (true){
BizLogEntity bizLogEntity = new BizLogEntity();
bizLogEntity.initAttrValue();
bizLogEntity.setTraceID(IdUtil.fastSimpleUUID());
bizLogEntity.setLogTime(new Date());
producer.syncBizSend(bizLogEntity);
log.info("[testSyncSend][发送编号:[{}] 发送成功]", bizLogEntity.getTraceID());
}
}
}
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