Browse Source

设备日志更新

master
loujf 3 years ago
parent
commit
55d4320a99
  1. 1
      nladmin-system/src/main/java/org/nl/acs/log/service/impl/LogServerImpl.java
  2. 9
      nladmin-system/src/main/java/org/nl/modules/log/rest/RootLogController.java
  3. 10
      nladmin-system/src/main/java/org/nl/modules/log/service/RootLogService.java
  4. 38
      nladmin-system/src/main/java/org/nl/modules/log/service/impl/RootLogServiceImpl.java
  5. 10
      qd/src/api/log.js
  6. 183
      qd/src/views/log/deviceLog/index.vue

1
nladmin-system/src/main/java/org/nl/acs/log/service/impl/LogServerImpl.java

@ -125,6 +125,7 @@ public class LogServerImpl implements LogServer {
String now = DateUtil.now(); String now = DateUtil.now();
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
json.put("device_code",device_code);
json.put("vehicle_code",vehicle_code); json.put("vehicle_code",vehicle_code);
json.put("inst_code",inst_code); json.put("inst_code",inst_code);
json.put("message",message); json.put("message",message);

9
nladmin-system/src/main/java/org/nl/modules/log/rest/RootLogController.java

@ -13,6 +13,7 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.text.ParseException;
import java.util.Map; import java.util.Map;
/** /**
@ -36,6 +37,14 @@ public class RootLogController {
return new ResponseEntity<>(rootLogService.queryAll(whereJson, page), HttpStatus.OK); return new ResponseEntity<>(rootLogService.queryAll(whereJson, page), HttpStatus.OK);
} }
@GetMapping("/deviceLog")
@Log("查询设备日志")
@ApiOperation("查询设备日志")
//@PreAuthorize("@el.check('log:list')")
public ResponseEntity<Object> queryDeviceLog(@RequestParam Map whereJson, Pageable page) throws ParseException {
return new ResponseEntity<>(rootLogService.queryDeviceLog(whereJson, page), HttpStatus.OK);
}
@PostMapping( "/error") @PostMapping( "/error")
@Log("查询异常详情") @Log("查询异常详情")
@ApiOperation("查询异常详情") @ApiOperation("查询异常详情")

10
nladmin-system/src/main/java/org/nl/modules/log/service/RootLogService.java

@ -2,6 +2,7 @@ package org.nl.modules.log.service;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import java.text.ParseException;
import java.util.Map; import java.util.Map;
/** /**
@ -16,6 +17,15 @@ public interface RootLogService {
*/ */
Map<String,Object> queryAll(Map whereJson, Pageable page); Map<String,Object> queryAll(Map whereJson, Pageable page);
/**
* 查询设备日志
*
* @param whereJson 条件
* @param page 分页参数
* @return Map<String, Object>
*/
Map<String,Object> queryDeviceLog(Map whereJson, Pageable page) throws ParseException;
/** /**
* 查询异常详情 * 查询异常详情
* *

38
nladmin-system/src/main/java/org/nl/modules/log/service/impl/RootLogServiceImpl.java

@ -1,9 +1,11 @@
package org.nl.modules.log.service.impl; package org.nl.modules.log.service.impl;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.nl.acs.device.service.DeviceService;
import org.nl.modules.log.service.RootLogService; import org.nl.modules.log.service.RootLogService;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
@ -27,6 +29,8 @@ public class RootLogServiceImpl implements RootLogService {
private final MongoTemplate mongoTemplate; private final MongoTemplate mongoTemplate;
private final DeviceService deviceService;
@Override @Override
public Map<String, Object> queryAll(Map whereJson, Pageable page){ public Map<String, Object> queryAll(Map whereJson, Pageable page){
String log_type = (String) whereJson.get("log_type"); String log_type = (String) whereJson.get("log_type");
@ -48,6 +52,8 @@ public class RootLogServiceImpl implements RootLogService {
.lte(end_time)); .lte(end_time));
} }
query.with(Sort.by("date"));
//根据条件得到的总条数 //根据条件得到的总条数
long totalSize = mongoTemplate.count(query, Map.class, log_type); long totalSize = mongoTemplate.count(query, Map.class, log_type);
@ -61,6 +67,38 @@ public class RootLogServiceImpl implements RootLogService {
return result; return result;
} }
@Override
public Map<String, Object> queryDeviceLog(Map whereJson, Pageable page){
String device_code = (String) whereJson.get("device_code");
String begin_time = (String) whereJson.get("begin_time");
String end_time = (String) whereJson.get("end_time");
Query query = new Query().with(Sort.by("date"));
if (StrUtil.isEmpty(device_code)) {
JSONArray array = deviceService.selectList();
JSONObject json = array.getJSONObject(0);
device_code = json.getString("device_code");
}
if (StrUtil.isNotEmpty(begin_time) && StrUtil.isNotEmpty(end_time)) {
query.addCriteria(Criteria.where("date")
.gte(begin_time)
.lte(end_time));
}
//根据条件得到的总条数
long totalSize = mongoTemplate.count(query, Map.class, device_code);
//处理分页
query.skip(page.getPageNumber()).limit(page.getPageSize());
List<Map> list = mongoTemplate.find(query,Map.class, device_code);
//封装前端分页查询结果
JSONObject result = new JSONObject();
result.put("content", list);
result.put("totalElements", totalSize);
return result;
}
@Override @Override
public String findError(Map map) { public String findError(Map map) {
String message = (String) map.get("message"); String message = (String) map.get("message");

10
qd/src/api/log.js

@ -25,7 +25,6 @@ export function edit(data) {
} }
export function findError(data) { export function findError(data) {
debugger
return request({ return request({
url: 'api/rootLog/error', url: 'api/rootLog/error',
method: 'post', method: 'post',
@ -33,4 +32,11 @@ export function findError(data) {
}) })
} }
export default { add, edit, del, findError } export function selectDeviceList() {
return request({
url: 'api/device/selectList',
method: 'get'
})
}
export default { add, edit, del, findError, selectDeviceList }

183
qd/src/views/log/deviceLog/index.vue

@ -0,0 +1,183 @@
<template>
<div class="app-container">
<!--工具栏-->
<div class="head-container">
<!--如果想在工具栏加入更多按钮可以使用插槽方式 slot = 'left' or 'right'-->
<div v-if="crud.props.searchToggle">
<!-- &lt;!&ndash; 搜索 &ndash;&gt;-->
<!-- <el-input-->
<!-- v-model="query.blurry"-->
<!-- size="small"-->
<!-- clearable-->
<!-- placeholder="输入任务编码"-->
<!-- style="width: 200px;"-->
<!-- class="filter-item"-->
<!-- @keyup.enter.native="crud.toQuery"-->
<!-- />-->
<el-select
v-model="query.device_code"
clearable
filterable
size="small"
placeholder="日志类型"
class="filter-item"
style="width: 190px"
@change="crud.toQuery"
>
<el-option v-for="item in deviceList" :key="item.device_id" :label="item.device_name" :value="item.device_code" />
</el-select>
<el-date-picker
v-model="query.createTime"
type="datetimerange"
:picker-options="pickerOptions"
class="filter-item"
value-format="yyyy-MM-dd HH:mm:ss"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
align="right"
/>
<rrOperation />
</div>
<crudOperation :permission="permission"/>
<!--表格渲染-->
<el-table
ref="table"
v-loading="crud.loading"
:data="crud.data"
size="small"
style="width: 100%;"
@selection-change="crud.selectionChangeHandler"
>
<el-table-column type="selection" width="55" />
<el-table-column prop="device_code" label="设备编码"/>
<el-table-column prop="create_time" label="创建时间" />
<el-table-column prop="vehicle_code" label="载具号"/>
<el-table-column prop="inst_code" label="指令号" />
<el-table-column prop="message" label="异常详情" width="300"/>
</el-table>
<!--分页组件-->
<pagination />
</div>
</div>
</template>
<script>
import crudLog from '@/api/log'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
import { get } from '@/api/system/dictDetail'
import Search from '@/views/monitor/lucene/search'
const defaultForm = {
_id: null,
thread: null,
level: null,
marker: null,
log_type: null,
source: null,
logger: null,
date: null,
message: null
}
export default {
name: 'Log',
// eslint-disable-next-line vue/no-unused-components
components: { Search, pagination, crudOperation, rrOperation, udOperation },
mixins: [presenter(), header(), form(defaultForm), crud()],
cruds() {
return CRUD({
title: '日志查询',
url: 'api/rootLog/deviceLog',
idField: 'log_uuid',
sort: 'log_uuid,desc',
crudMethod: { ...crudLog },
optShow: {
add: false,
edit: false,
del: false,
download: false,
reset: false
}
})
},
data() {
return {
permission: {
add: ['admin', 'log:add'],
edit: ['admin', 'log:edit'],
del: ['admin', 'log:del']
},
errorInfo: '',
dialog: false,
deviceList: [],
log_levels: [],
rules: {
log_uuid: [
{ required: true, message: '日志标识不能为空', trigger: 'blur' }
],
task_code: [
{ required: true, message: '任务编码不能为空', trigger: 'blur' }
],
task_id: [
{ required: true, message: '任务标识不能为空', trigger: 'blur' }
],
log_type: [
{ required: true, message: '日志类型不能为空', trigger: 'blur' }
],
method: [
{ required: true, message: '方法不能为空', trigger: 'blur' }
],
requestparam: [
{ required: true, message: '请求参数不能为空', trigger: 'blur' }
],
responseparam: [
{ required: true, message: '返回参数不能为空', trigger: 'blur' }
]
}
}
},
created() {
this.$nextTick(() => {
// eslint-disable-next-line no-undef
debugger
crudLog.selectDeviceList().then(data => {
this.deviceList = data
})
//
get('log_level').then(data => {
this.log_levels = data.content
})
})
},
methods: {
//
info(row) {
this.dialog = true
const data = {}
data.message = row.message
data.marker = row.marker
crudLog.findError(data).then(res => {
this.errorInfo = res
})
},
// false
[CRUD.HOOK.beforeRefresh]() {
return true
}
// paramFormate(row, index) {
// return JSON.stringify(row.requestparam)
// },
// paramFormate2(row, index) {
// return JSON.stringify(row.responseparam)
// }
}
}
</script>
<style scoped>
</style>
Loading…
Cancel
Save