rev: lucene
This commit is contained in:
@@ -4,10 +4,8 @@ import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
|
||||
import com.alicp.jetcache.anno.config.EnableCreateCacheAnnotation;
|
||||
import com.alicp.jetcache.anno.config.EnableMethodCache;
|
||||
import io.github.forezp.distributedlimitcore.annotation.Limit;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.nl.common.annotation.RepeatSubmit;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
@@ -16,16 +14,12 @@ import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactor
|
||||
import org.springframework.boot.web.servlet.ServletComponentScan;
|
||||
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.retry.annotation.Backoff;
|
||||
import org.springframework.retry.annotation.EnableRetry;
|
||||
import org.springframework.retry.annotation.Retryable;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.time.LocalTime;
|
||||
|
||||
/**
|
||||
* 开启审计功能 -> @EnableJpaAuditing
|
||||
* https://www.cnblogs.com/niceyoo/p/10908647.html
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*//*
|
||||
*/
|
||||
|
||||
package org.nl.common.logging.aspect;
|
||||
|
||||
@@ -30,7 +30,8 @@ import org.nl.common.utils.RequestHolder;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.common.utils.StringUtils;
|
||||
import org.nl.common.utils.ThrowableUtil;
|
||||
import org.nl.common.logging.domain.Log;
|
||||
import org.nl.system.service.logging.ISysLogService;
|
||||
import org.nl.system.service.logging.dao.SysLog;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
@@ -46,45 +47,43 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2018-11-24
|
||||
*//*
|
||||
*/
|
||||
|
||||
@Component
|
||||
@Aspect
|
||||
@Slf4j
|
||||
public class LogAspect {
|
||||
|
||||
private final LogService logService;
|
||||
private final ISysLogService logService;
|
||||
|
||||
ThreadLocal<Long> currentTime = new ThreadLocal<>();
|
||||
|
||||
public LogAspect(LogService logService) {
|
||||
public LogAspect(ISysLogService logService) {
|
||||
this.logService = logService;
|
||||
}
|
||||
|
||||
*/
|
||||
/**
|
||||
/**
|
||||
* 配置切入点
|
||||
*//*
|
||||
*/
|
||||
|
||||
@Pointcut("@annotation(org.nl.common.logging.annotation.Log)")
|
||||
public void logPointcut() {
|
||||
// 该方法无方法体,主要为了让同类中其他方法使用此切入点
|
||||
}
|
||||
|
||||
*/
|
||||
/**
|
||||
/**
|
||||
* 配置环绕通知,使用在方法logPointcut()上注册的切入点
|
||||
*
|
||||
* @param joinPoint join point for advice
|
||||
*//*
|
||||
*/
|
||||
|
||||
@Around("logPointcut()")
|
||||
public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable {
|
||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
HttpServletRequest request = attributes.getRequest();
|
||||
HttpServletResponse response = attributes.getResponse();
|
||||
// HttpServletRequest request = RequestHolder.getHttpServletRequest();
|
||||
@@ -94,26 +93,25 @@ public class LogAspect {
|
||||
Method method = signature.getMethod();
|
||||
// 方法路径
|
||||
String methodName = joinPoint.getTarget().getClass().getName() + "." + signature.getName() + "()";
|
||||
String params=getParameter(method, joinPoint.getArgs());
|
||||
String params = getParameter(method, joinPoint.getArgs());
|
||||
|
||||
log.info("请求uri:{}", request.getRequestURI());
|
||||
log.info("请求方法:{}",methodName);
|
||||
log.info("请求方法参数:{}",params);
|
||||
log.info("请求路径:{}", request.getRequestURI());
|
||||
log.info("请求方法:{}", methodName);
|
||||
log.info("请求方法参数:{}", params);
|
||||
|
||||
Object result;
|
||||
currentTime.set(System.currentTimeMillis());
|
||||
result = joinPoint.proceed();
|
||||
Log log = new Log("INFO",System.currentTimeMillis() - currentTime.get());
|
||||
SysLog log = new SysLog("INFO", System.currentTimeMillis() - currentTime.get());
|
||||
currentTime.remove();
|
||||
|
||||
logService.save(getUsername(), StringUtils.getBrowser(request), StringUtils.getIp(request),joinPoint, log);
|
||||
logService.save(getUsername(), StringUtils.getBrowser(request), StringUtils.getIp(request), joinPoint, log);
|
||||
return result;
|
||||
}
|
||||
|
||||
*/
|
||||
/**
|
||||
/**
|
||||
* 根据方法和传入的参数获取请求参数
|
||||
*//*
|
||||
*/
|
||||
|
||||
private String getParameter(Method method, Object[] args) {
|
||||
List<Object> argList = new ArrayList<>();
|
||||
@@ -142,29 +140,28 @@ public class LogAspect {
|
||||
return argList.size() == 1 ? JSONUtil.toJsonStr(argList.get(0)) : JSONUtil.toJsonStr(argList);
|
||||
}
|
||||
|
||||
*/
|
||||
/**
|
||||
|
||||
/**
|
||||
* 配置异常通知
|
||||
*
|
||||
* @param joinPoint join point for advice
|
||||
* @param e exception
|
||||
*//*
|
||||
* @param e exception
|
||||
*/
|
||||
|
||||
@AfterThrowing(pointcut = "logPointcut()", throwing = "e")
|
||||
public void logAfterThrowing(JoinPoint joinPoint, Throwable e) {
|
||||
Log log = new Log("ERROR",System.currentTimeMillis() - currentTime.get());
|
||||
SysLog log = new SysLog("ERROR", System.currentTimeMillis() - currentTime.get());
|
||||
currentTime.remove();
|
||||
log.setExceptionDetail(ThrowableUtil.getStackTrace(e).getBytes());
|
||||
log.setException_detail(ThrowableUtil.getStackTrace(e).getBytes());
|
||||
HttpServletRequest request = RequestHolder.getHttpServletRequest();
|
||||
logService.save(getUsername(), StringUtils.getBrowser(request), StringUtils.getIp(request), (ProceedingJoinPoint)joinPoint, log);
|
||||
logService.save(getUsername(), StringUtils.getBrowser(request), StringUtils.getIp(request), (ProceedingJoinPoint) joinPoint, log);
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
try {
|
||||
return SecurityUtils.getCurrentUsername();
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -2,17 +2,22 @@ package org.nl.config.lucene;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.lucene.analysis.Analyzer;
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.index.DirectoryReader;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.queryparser.classic.QueryParser;
|
||||
import org.apache.lucene.search.*;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.store.FSDirectory;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.nl.system.service.lucene.LogMessageConstant;
|
||||
import org.wltea.analyzer.lucene.IKAnalyzer;
|
||||
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
@@ -26,33 +31,30 @@ import java.util.Map;
|
||||
@Slf4j
|
||||
public class Searcher {
|
||||
|
||||
public static Map<String, Object> search(String indexDir, String ext,Map whereJson) throws Exception {
|
||||
public static Map<String, Object> search(String indexDir, JSONObject whereJson) throws Exception {
|
||||
//获取要查询的路径,也就是索引所在的位置
|
||||
Directory dir = FSDirectory.open(Paths.get(indexDir));
|
||||
IndexReader reader = DirectoryReader.open(dir);
|
||||
//构建IndexSearcher
|
||||
IndexSearcher searcher = new IndexSearcher(reader);
|
||||
//标准分词器,会自动去掉空格啊,is a the等单词
|
||||
// Analyzer analyzer = new StandardAnalyzer();
|
||||
// Analyzer analyzer = new IKAnalyzer(false);
|
||||
//查询解析器
|
||||
// QueryParser queryParser = new QueryParser("fieldContent", analyzer);
|
||||
Analyzer analyzer = new IKAnalyzer(true);
|
||||
|
||||
//记录索引开始时间
|
||||
long startTime = System.currentTimeMillis();
|
||||
// long startTime = System.currentTimeMillis();
|
||||
// 实际上Lucene本身不支持分页。因此我们需要自己进行逻辑分页。我们要准备分页参数:
|
||||
int pageSize = Integer.parseInt(whereJson.get("size").toString());// 每页条数
|
||||
int pageNum = Integer.parseInt(whereJson.get("page").toString());// 当前页码
|
||||
int pageNum = Integer.parseInt(whereJson.get("page").toString()) - 1;// 当前页码
|
||||
int start = pageNum * pageSize;// 当前页的起始条数
|
||||
int end = start + pageSize;// 当前页的结束条数(不能包含)
|
||||
// 创建排序对象,需要排序字段SortField,参数:字段的名称、字段的类型、是否反转如果是false,升序。true降序
|
||||
Sort sort = new Sort(new SortField("logTime", SortField.Type.DOC,true));
|
||||
Sort sort = new Sort(new SortField("timestamp", SortField.Type.DOC,true));
|
||||
|
||||
TopDocs docs = null;
|
||||
BooleanQuery.Builder booleanQueryBuilder = new BooleanQuery.Builder();
|
||||
//时间范围查询
|
||||
String startDate = (String) whereJson.get("begin_time");
|
||||
String endDate = (String) whereJson.get("end_time");
|
||||
String startDate = whereJson.getString("begin_time");
|
||||
String endDate = whereJson.getString("end_time");
|
||||
Calendar calendar=Calendar.getInstance();
|
||||
calendar.set(1970, 0, 1);
|
||||
if (startDate == null){
|
||||
@@ -65,74 +67,71 @@ public class Searcher {
|
||||
} else {
|
||||
endDate = LuceneIndexWriter.getDate(endDate);
|
||||
}
|
||||
TermRangeQuery termRangeQuery = new TermRangeQuery("logTime", new BytesRef(startDate), new BytesRef(endDate), true, true);
|
||||
// 字段之间的与或非关系,MUST表示and,MUST_NOT表示not,SHOULD表示or,有几个fields就必须有几个clauses
|
||||
TermRangeQuery termRangeQuery = new TermRangeQuery("timestamp", new BytesRef(startDate), new BytesRef(endDate), true, true);
|
||||
booleanQueryBuilder.add(termRangeQuery,BooleanClause.Occur.MUST);
|
||||
if (whereJson.get("device_code") != null){
|
||||
Query termQuery = new TermQuery(new Term("device_code", (String) whereJson.get("device_code")));
|
||||
booleanQueryBuilder.add(termQuery,BooleanClause.Occur.MUST);
|
||||
}
|
||||
if (whereJson.get("method") != null){
|
||||
Query termQuery = new TermQuery(new Term("method", (String) whereJson.get("method")));
|
||||
booleanQueryBuilder.add(termQuery,BooleanClause.Occur.MUST);
|
||||
}
|
||||
if (whereJson.get("status_code") != null){
|
||||
Query termQuery = new TermQuery(new Term("status_code", (String) whereJson.get("status_code")));
|
||||
booleanQueryBuilder.add(termQuery,BooleanClause.Occur.MUST);
|
||||
}
|
||||
if (whereJson.get("requestparam") != null){
|
||||
WildcardQuery query = new WildcardQuery(new Term("requestparam", "*"+(String) whereJson.get("requestparam")+"*"));
|
||||
booleanQueryBuilder.add(query,BooleanClause.Occur.MUST);
|
||||
}
|
||||
if (whereJson.get("responseparam") != null){
|
||||
WildcardQuery query = new WildcardQuery(new Term("responseparam", "*"+(String) whereJson.get("responseparam")+"*"));
|
||||
booleanQueryBuilder.add(query,BooleanClause.Occur.MUST);
|
||||
}
|
||||
if (whereJson.get("blurry") != null) {
|
||||
WildcardQuery query = new WildcardQuery(new Term("fieldContent", "*"+(String) whereJson.get("blurry")+"*"));
|
||||
if (ObjectUtil.isNotEmpty(whereJson.get(LogMessageConstant.FIELD_MESSAGE))){
|
||||
//查询解析器
|
||||
QueryParser queryParser = new QueryParser("message", analyzer);
|
||||
Query query = queryParser.parse(whereJson.getString("message"));
|
||||
booleanQueryBuilder.add(query, BooleanClause.Occur.MUST);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(whereJson.get(LogMessageConstant.FIELD_TRACEID))){
|
||||
//查询解析器
|
||||
TermQuery termQuery = new TermQuery(new Term(LogMessageConstant.FIELD_TRACEID,
|
||||
whereJson.get(LogMessageConstant.FIELD_TRACEID).toString().trim()));
|
||||
booleanQueryBuilder.add(termQuery, BooleanClause.Occur.MUST);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(whereJson.get(LogMessageConstant.FIELD_LEVEL))){
|
||||
//查询解析器
|
||||
TermQuery termQuery = new TermQuery(new Term(LogMessageConstant.FIELD_LEVEL,
|
||||
whereJson.get(LogMessageConstant.FIELD_LEVEL).toString()));
|
||||
booleanQueryBuilder.add(termQuery, BooleanClause.Occur.MUST);
|
||||
}
|
||||
docs = searcher.search(booleanQueryBuilder.build(), end,sort);
|
||||
//记录索引时间
|
||||
long endTime = System.currentTimeMillis();
|
||||
log.info("匹配{}共耗时{}毫秒",booleanQueryBuilder.build(),(endTime-startTime));
|
||||
log.info("查询到{}条日志文件", docs.totalHits.value);
|
||||
// long endTime = System.currentTimeMillis();
|
||||
// log.info("匹配{}共耗时{}毫秒",booleanQueryBuilder.build(),(endTime-startTime));
|
||||
// log.info("查询到{}条日志文件", docs.totalHits.value);
|
||||
List<String> list = new ArrayList<>();
|
||||
ScoreDoc[] scoreDocs = docs.scoreDocs;
|
||||
if (end > docs.totalHits.value) end = (int) docs.totalHits.value;
|
||||
JSONArray array = new JSONArray();
|
||||
|
||||
for (int i = start; i < end; i++) {
|
||||
ScoreDoc scoreDoc = scoreDocs[i];
|
||||
Document doc = reader.document(scoreDoc.doc);
|
||||
JSONObject object = new JSONObject();
|
||||
object.put("content",doc.get("fieldContent"));
|
||||
object.put("device_code",doc.get("device_code"));
|
||||
object.put("logTime",doc.get("logTime"));
|
||||
object.put("method",doc.get("method"));
|
||||
object.put("status_code",doc.get("status_code"));
|
||||
object.put("requestparam",doc.get("requestparam"));
|
||||
object.put("responseparam",doc.get("responseparam"));
|
||||
if(doc.get("fieldContent") != null) {
|
||||
array.add(object);
|
||||
}
|
||||
}
|
||||
for(Object logDto:array){
|
||||
log.info(logDto.toString());
|
||||
String logInfo = LogMessageConstant.COLOR_YELLOW + doc.get(LogMessageConstant.FIELD_TRACEID) +
|
||||
LogMessageConstant.COLOR_RESET + " - " +
|
||||
LogMessageConstant.COLOR_RED + doc.get(LogMessageConstant.FIELD_TIMESTAMP) +
|
||||
LogMessageConstant.COLOR_RESET + " - " +
|
||||
LogMessageConstant.COLOR_GREEN + "[" + doc.get(LogMessageConstant.FIELD_THREAD) + "]" +
|
||||
LogMessageConstant.COLOR_RESET + " - " +
|
||||
LogMessageConstant.COLOR_BLACK + doc.get(LogMessageConstant.FIELD_LEVEL) +
|
||||
LogMessageConstant.COLOR_RESET + " - " +
|
||||
LogMessageConstant.COLOR_MAGENTA + doc.get(LogMessageConstant.FIELD_CLASS_NAME) +
|
||||
LogMessageConstant.COLOR_RESET + " - " +
|
||||
LogMessageConstant.COLOR_BLACK + doc.get(LogMessageConstant.FIELD_MESSAGE);
|
||||
// System.out.println(logInfo);
|
||||
list.add(logInfo);
|
||||
}
|
||||
reader.close();
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("content", array);
|
||||
jo.put("content", list);
|
||||
jo.put("totalElements", docs.totalHits.value);
|
||||
return jo;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String indexDir = "D:\\lucene\\index";
|
||||
String indexDir = "D:\\lucene\\debug_log";
|
||||
//查询这个字符串
|
||||
String q = "07.832";
|
||||
Map whereJson = null;
|
||||
JSONObject whereJson = new JSONObject();
|
||||
whereJson.put("size", "500");
|
||||
whereJson.put("page", "0");
|
||||
// whereJson.put("message", "traceId");
|
||||
whereJson.put(LogMessageConstant.FIELD_TRACEID, "13236874421038464");
|
||||
|
||||
try {
|
||||
search(indexDir, q,whereJson);
|
||||
search(indexDir, whereJson);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package org.nl.system.controller.lucence;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -9,10 +12,7 @@ import org.nl.system.service.lucene.LuceneService;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -25,11 +25,11 @@ public class LuceneController {
|
||||
|
||||
private final LuceneService luceneService;
|
||||
|
||||
@GetMapping("/getAll")
|
||||
@PostMapping("/getAll")
|
||||
@Log("日志检索")
|
||||
@ApiOperation("日志检索")
|
||||
//@PreAuthorize("@el.check('task:list')")
|
||||
public ResponseEntity<Object> get(@RequestParam Map whereJson, Pageable page) {
|
||||
return new ResponseEntity<>(luceneService.getAll(whereJson, page), HttpStatus.OK);
|
||||
public ResponseEntity<Object> get(@RequestBody JSONObject whereJson) {
|
||||
return new ResponseEntity<>(luceneService.getAll(whereJson), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,10 @@ package org.nl.system.service.logging;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.system.service.logging.dao.SysLog;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -41,4 +43,15 @@ public interface ISysLogService extends IService<SysLog> {
|
||||
* 删除所有操作日志
|
||||
*/
|
||||
void delAllByInfo();
|
||||
|
||||
/**
|
||||
* 保存日志数据
|
||||
* @param username 用户
|
||||
* @param browser 浏览器
|
||||
* @param ip 请求IP
|
||||
* @param joinPoint /
|
||||
* @param log 日志实体
|
||||
*/
|
||||
@Async
|
||||
void save(String username, String browser, String ip, ProceedingJoinPoint joinPoint, SysLog log);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.time.LocalDateTime;
|
||||
import java.io.Serializable;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -16,6 +17,7 @@ import lombok.EqualsAndHashCode;
|
||||
* @since 2023-05-08
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("sys_log")
|
||||
public class SysLog implements Serializable {
|
||||
@@ -51,5 +53,8 @@ public class SysLog implements Serializable {
|
||||
|
||||
private String create_time;
|
||||
|
||||
|
||||
public SysLog(String logType, Long time) {
|
||||
this.log_type = logType;
|
||||
this.time = time;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,35 @@
|
||||
package org.nl.system.service.logging.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.lang.Dict;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.logging.annotation.Log;
|
||||
import org.nl.common.utils.StringUtils;
|
||||
import org.nl.common.utils.ValidationUtil;
|
||||
import org.nl.system.service.logging.ISysLogService;
|
||||
import org.nl.system.service.logging.dao.SysLog;
|
||||
import org.nl.system.service.logging.dao.mapper.SysLogMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Parameter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -71,4 +86,60 @@ public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> impleme
|
||||
public void delAllByInfo() {
|
||||
logMapper.delete(new LambdaQueryWrapper<SysLog>().eq(SysLog::getLog_type, "INFO"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(String username, String browser, String ip, ProceedingJoinPoint joinPoint, SysLog logDto) {
|
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||
Method method = signature.getMethod();
|
||||
Log aopLog = method.getAnnotation(Log.class);
|
||||
|
||||
// 方法路径
|
||||
String methodName = joinPoint.getTarget().getClass().getName() + "." + signature.getName() + "()";
|
||||
|
||||
// 描述
|
||||
if (logDto != null) {
|
||||
logDto.setDescription(aopLog.value());
|
||||
}
|
||||
assert logDto != null;
|
||||
logDto.setRequest_ip(ip);
|
||||
|
||||
logDto.setAddress(StringUtils.getCityInfo(logDto.getRequest_ip()));
|
||||
logDto.setMethod(methodName);
|
||||
logDto.setUsername(username);
|
||||
logDto.setParams(getParameter(method, joinPoint.getArgs()));
|
||||
logDto.setBrowser(browser);
|
||||
logDto.setLog_id(IdUtil.getSnowflake(1,1).nextIdStr());
|
||||
logDto.setCreate_time(DateUtil.now());
|
||||
logMapper.insert(logDto);
|
||||
}
|
||||
/**
|
||||
* 根据方法和传入的参数获取请求参数
|
||||
*/
|
||||
private String getParameter(Method method, Object[] args) {
|
||||
List<Object> argList = new ArrayList<>();
|
||||
Parameter[] parameters = method.getParameters();
|
||||
for (int i = 0; i < parameters.length; i++) {
|
||||
//将RequestBody注解修饰的参数作为请求参数
|
||||
RequestBody requestBody = parameters[i].getAnnotation(RequestBody.class);
|
||||
if (requestBody != null) {
|
||||
argList.add(args[i]);
|
||||
}
|
||||
//将RequestParam注解修饰的参数作为请求参数
|
||||
RequestParam requestParam = parameters[i].getAnnotation(RequestParam.class);
|
||||
if (requestParam != null) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
String key = parameters[i].getName();
|
||||
if (!StrUtil.isEmpty(requestParam.value())) {
|
||||
key = requestParam.value();
|
||||
}
|
||||
map.put(key, args[i]);
|
||||
argList.add(map);
|
||||
}
|
||||
}
|
||||
if (argList.size() == 0) {
|
||||
return "";
|
||||
}
|
||||
return argList.size() == 1 ? JSONUtil.toJsonStr(argList.get(0)) : JSONUtil.toJsonStr(argList);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package org.nl.system.service.lucene;
|
||||
|
||||
/**
|
||||
* @Author: lyd
|
||||
* @Description: 定义lucene相关常量
|
||||
* @Date: 2023/8/25
|
||||
*/
|
||||
public class LogMessageConstant {
|
||||
/** 级别 */
|
||||
public final static String FIELD_LEVEL = "level";
|
||||
/** 时间 */
|
||||
public final static String FIELD_TIMESTAMP = "timestamp";
|
||||
/** 类的限定名 */
|
||||
public final static String FIELD_CLASS_NAME = "logger";
|
||||
/** 线程名 */
|
||||
public final static String FIELD_THREAD = "thread";
|
||||
/** 日志内容 */
|
||||
public final static String FIELD_MESSAGE = "message";
|
||||
public final static String FIELD_TRACEID = "tlogTraceId";
|
||||
// 定义颜色值
|
||||
/** 文本颜色:黑色 */
|
||||
public final static String COLOR_BLACK = "\u001B[30m";
|
||||
/** 文本颜色:红色 */
|
||||
public final static String COLOR_RED = "\u001B[31m";
|
||||
/** 文本颜色:绿色 */
|
||||
public final static String COLOR_GREEN = "\u001B[32m";
|
||||
/** 文本颜色:黄色 */
|
||||
public final static String COLOR_YELLOW = "\u001B[33m";
|
||||
/** 文本颜色:蓝色 */
|
||||
public final static String COLOR_BLUE = "\u001B[34m";
|
||||
/** 文本颜色:品红色 */
|
||||
public final static String COLOR_MAGENTA = "\u001B[35m";
|
||||
/** 文本颜色:青色 */
|
||||
public final static String COLOR_CYAN = "\u001B[36m";
|
||||
/** 文本颜色:白色 */
|
||||
public final static String COLOR_WHITE = "\u001B[37m";
|
||||
/** 文本颜色重置 */
|
||||
public final static String COLOR_RESET = "\u001B[0m";
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package org.nl.system.service.lucene;
|
||||
|
||||
/**
|
||||
* @author ldjun
|
||||
* @version 1.0
|
||||
* @date 2023年08月24日 13:00
|
||||
* @desc desc
|
||||
*/
|
||||
|
||||
import ch.qos.logback.classic.spi.ILoggingEvent;
|
||||
import ch.qos.logback.core.AppenderBase;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import org.apache.lucene.analysis.Analyzer;
|
||||
import org.apache.lucene.analysis.standard.StandardAnalyzer;
|
||||
import org.apache.lucene.document.*;
|
||||
import org.apache.lucene.index.IndexWriter;
|
||||
import org.apache.lucene.index.IndexWriterConfig;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.store.FSDirectory;
|
||||
import org.wltea.analyzer.lucene.IKAnalyzer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Map;
|
||||
|
||||
public class LuceneAppender extends AppenderBase<ILoggingEvent> {
|
||||
|
||||
private Directory index;
|
||||
private IndexWriter indexWriter;
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
super.start();
|
||||
String indexPath = "D:\\lucene\\debug_log";
|
||||
try {
|
||||
index = FSDirectory.open(Paths.get(indexPath));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// 初始化 Lucene 索引
|
||||
Analyzer analyzer = new IKAnalyzer();
|
||||
IndexWriterConfig config = new IndexWriterConfig(analyzer);
|
||||
try {
|
||||
indexWriter = new IndexWriter(index, config);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void append(ILoggingEvent event) {
|
||||
String message = event.getFormattedMessage();
|
||||
Map<String, String> mdcPropertyMap = event.getMDCPropertyMap();
|
||||
Document doc = new Document();
|
||||
String formattedDateTime = DateUtil.format(new java.util.Date(event.getTimeStamp()), "yyyy-MM-dd HH:mm:ss.SSS");
|
||||
doc.add(new StringField(LogMessageConstant.FIELD_LEVEL, event.getLevel().toString(), Field.Store.YES));
|
||||
doc.add(new StringField(LogMessageConstant.FIELD_TIMESTAMP, formattedDateTime,Field.Store.YES));
|
||||
doc.add(new StoredField(LogMessageConstant.FIELD_CLASS_NAME, event.getLoggerName()));
|
||||
doc.add(new StoredField(LogMessageConstant.FIELD_THREAD, event.getThreadName()));
|
||||
if (ObjectUtil.isNotEmpty(mdcPropertyMap)) {
|
||||
String traceId = mdcPropertyMap.get(LogMessageConstant.FIELD_TRACEID);
|
||||
if (ObjectUtil.isNotEmpty(traceId)) {
|
||||
doc.add(new StringField(LogMessageConstant.FIELD_TRACEID, traceId,Field.Store.YES));
|
||||
} else {
|
||||
doc.add(new StringField(LogMessageConstant.FIELD_TRACEID, "无生成链路ID",Field.Store.YES));
|
||||
}
|
||||
} else {
|
||||
doc.add(new StringField(LogMessageConstant.FIELD_TRACEID, "无生成链路ID",Field.Store.YES));
|
||||
}
|
||||
doc.add(new TextField(LogMessageConstant.FIELD_MESSAGE, message, Field.Store.YES));
|
||||
try {
|
||||
indexWriter.addDocument(doc);
|
||||
indexWriter.commit();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
super.stop();
|
||||
try {
|
||||
indexWriter.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.nl.system.service.lucene;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -15,5 +16,5 @@ public interface LuceneService {
|
||||
* @param page 分页参数
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
Map<String, Object> getAll(Map whereJson, Pageable page);
|
||||
Map<String, Object> getAll(JSONObject whereJson);
|
||||
}
|
||||
|
||||
@@ -25,10 +25,10 @@ public class LuceneServiceImpl implements LuceneService {
|
||||
private String luceneUrl;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getAll(Map whereJson, Pageable page) {
|
||||
public Map<String, Object> getAll(JSONObject whereJson) {
|
||||
JSONObject jo = new JSONObject();
|
||||
try {
|
||||
JSONObject jsonObject = (JSONObject) Searcher.search(luceneUrl, "", whereJson);
|
||||
JSONObject jsonObject = (JSONObject) Searcher.search(luceneUrl, whereJson);
|
||||
JSONArray array = jsonObject.getJSONArray("content");
|
||||
int totalElements = Integer.parseInt(jsonObject.get("totalElements").toString());
|
||||
jo.put("content", array);
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.wms.sch.region.service.ISchBaseRegionService;
|
||||
import org.nl.wms.sch.region.service.dao.mapper.SchBaseRegionMapper;
|
||||
import org.nl.wms.sch.region.service.dao.SchBaseRegion;
|
||||
import org.slf4j.MDC;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -39,6 +40,9 @@ public class SchBaseRegionServiceImpl extends ServiceImpl<SchBaseRegionMapper, S
|
||||
|
||||
@Override
|
||||
public IPage<SchBaseRegion> queryAll(Map whereJson, PageQuery page) {
|
||||
MDC.put("log_type", "region");
|
||||
log.info("区域查询:{}", whereJson);
|
||||
log.error("这是第二个日志");
|
||||
String workshop_code = ObjectUtil.isNotEmpty(whereJson.get("workshop_code")) ? whereJson.get("workshop_code").toString() : null;
|
||||
String blurry = ObjectUtil.isNotEmpty(whereJson.get("blurry")) ? whereJson.get("blurry").toString() : null;
|
||||
Boolean is_has_workder = ObjectUtil.isNotEmpty(whereJson.get("is_has_workder")) ? Boolean.valueOf(whereJson.get("is_has_workder").toString()) : null;
|
||||
@@ -50,6 +54,7 @@ public class SchBaseRegionServiceImpl extends ServiceImpl<SchBaseRegionMapper, S
|
||||
.orderByAsc(SchBaseRegion::getOrder_seq);
|
||||
IPage<SchBaseRegion> pages = new Page<>(page.getPage() + 1, page.getSize());
|
||||
schBaseRegionMapper.selectPage(pages, lam);
|
||||
MDC.remove("log_type");
|
||||
return pages;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.nl.wms.sch.task.service.dao.mapper.SchBaseTaskconfigMapper;
|
||||
import org.nl.wms.sch.task_manage.AbstractTask;
|
||||
import org.nl.wms.sch.task_manage.task.TaskFactory;
|
||||
import org.nl.wms.sch.task_manage.task.core.TaskStatus;
|
||||
import org.slf4j.MDC;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -50,6 +51,9 @@ public class SchBaseTaskServiceImpl extends ServiceImpl<SchBaseTaskMapper, SchBa
|
||||
|
||||
@Override
|
||||
public IPage<SchBaseTask> queryAll(Map whereJson, PageQuery page) {
|
||||
MDC.put("log", "SchBaseTask");
|
||||
log.info("参数:{}", whereJson);
|
||||
MDC.remove("log");
|
||||
String task_code = ObjectUtil.isNotEmpty(whereJson.get("task_code"))
|
||||
? whereJson.get("task_code").toString() : null;
|
||||
String vehicle_code = ObjectUtil.isNotEmpty(whereJson.get("vehicle_code"))
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
|
||||
<properties>
|
||||
<comment>IK Analyzer 扩展配置</comment>
|
||||
<!--用户可以在这里配置自己的扩展字典 -->
|
||||
<entry key="ext_dict">ext.dic;</entry>
|
||||
|
||||
<!--用户可以在这里配置自己的扩展停止词字典-->
|
||||
<entry key="ext_stopwords">stopword.dic;</entry>
|
||||
|
||||
</properties>
|
||||
@@ -111,4 +111,4 @@ mybatis-plus:
|
||||
id-type: INPUT
|
||||
lucene:
|
||||
index:
|
||||
path: D:\lucene\index
|
||||
path: D:\lucene\debug_log
|
||||
|
||||
@@ -47,7 +47,7 @@ https://juejin.cn/post/6844903775631572999
|
||||
</encoder>
|
||||
|
||||
</appender>
|
||||
|
||||
<appender name="luceneAppender" class="org.nl.system.service.lucene.LuceneAppender" />
|
||||
<!--异步到文件-->
|
||||
<appender name="asyncFileAppender" class="ch.qos.logback.classic.AsyncAppender">
|
||||
<discardingThreshold>0</discardingThreshold>
|
||||
@@ -58,6 +58,7 @@ https://juejin.cn/post/6844903775631572999
|
||||
<springProfile name="dev">
|
||||
<root level="debug">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
<appender-ref ref="luceneAppender"/>
|
||||
</root>
|
||||
<logger name="org.springframework" level="ERROR" additivity="false">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
|
||||
1241
nladmin-system/nlsso-server/src/main/resources/stopword.dic
Normal file
1241
nladmin-system/nlsso-server/src/main/resources/stopword.dic
Normal file
File diff suppressed because it is too large
Load Diff
@@ -129,7 +129,8 @@ export default {
|
||||
},
|
||||
initWebSocket() {
|
||||
// const wsUri = (process.env.VUE_APP_WS_API === '/' ? '/' : (process.env.VUE_APP_WS_API + '/')) + 'messageInfo'
|
||||
const wsUri = window.g.prod.VUE_APP_BASE_API.replace('http', 'ws') + '/webSocket/' + 'messageInfo'
|
||||
const wsUri = process.env.VUE_APP_WS_API.replace('http', 'ws') + '/webSocket/' + 'messageInfo'
|
||||
// const wsUri = 'ws://127.0.0.1:8089/ws/webSocket/' + 'messageInfo'
|
||||
this.websock = new WebSocket(wsUri)
|
||||
this.websock.onerror = this.webSocketOnError
|
||||
this.websock.onmessage = this.webSocketOnMessage
|
||||
|
||||
@@ -3,7 +3,7 @@ import request from '@/utils/request'
|
||||
export function getLogData(param) {
|
||||
return request({
|
||||
url: 'api/lucene/getAll',
|
||||
method: 'get',
|
||||
method: 'post',
|
||||
data: param
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,102 +1,140 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<div class="head-container">
|
||||
<Search />
|
||||
<crudOperation />
|
||||
<el-form
|
||||
:inline="true"
|
||||
class="demo-form-inline"
|
||||
label-position="right"
|
||||
label-width="90px"
|
||||
label-suffix=":"
|
||||
>
|
||||
<el-form-item label="日志级别">
|
||||
<el-select
|
||||
v-model="query.level"
|
||||
clearable
|
||||
size="mini"
|
||||
placeholder="日志级别"
|
||||
class="filter-item"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in levelOptions"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="模糊搜索">
|
||||
<el-input
|
||||
v-model="query.message"
|
||||
clearable
|
||||
size="mini"
|
||||
placeholder="日志内容"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="链路ID">
|
||||
<el-input
|
||||
v-model="query.tlogTraceId"
|
||||
clearable
|
||||
size="mini"
|
||||
placeholder="请输入链路ID"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="时间">
|
||||
<el-date-picker
|
||||
v-model="query.createTime"
|
||||
type="datetimerange"
|
||||
range-separator="至"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" size="mini" @click="queryData">
|
||||
查询
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
<!--表格渲染-->
|
||||
<el-table
|
||||
ref="table"
|
||||
v-loading="crud.loading"
|
||||
:data="crud.data"
|
||||
style="width: 100%;"
|
||||
@selection-change="crud.selectionChangeHandler"
|
||||
>
|
||||
<!-- <el-table-column type="selection" width="55"/>-->
|
||||
<!-- <el-table-column v-if="false" prop="id" label="id"/>-->
|
||||
<el-table-column prop="operate" width="50" label="操作" />
|
||||
<el-table-column prop="device_code" label="设备号" />
|
||||
<el-table-column prop="task_code" label="任务编号" />
|
||||
<el-table-column prop="instruct_code" label="指令编号" />
|
||||
<el-table-column prop="method" label="方法" />
|
||||
<el-table-column prop="status_code" label="状态码" />
|
||||
<el-table-column prop="requestparam" label="请求参数" />
|
||||
<el-table-column prop="responseparam" label="返回参数" />
|
||||
<el-table-column prop="logTime" width="170" label="记录时间" />
|
||||
<el-table-column prop="content" width="500" label="内容详情" />
|
||||
|
||||
</el-table>
|
||||
<!--分页组件-->
|
||||
<pagination />
|
||||
<el-card shadow="hover" style="width: 100%" class="log-warpper">
|
||||
<div style="width: 100%">
|
||||
<div v-for="(log, index) in logs" :key="index">
|
||||
<div style="margin-bottom: 5px; font-size: 14px;" v-html="log" />
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
<!-- 分页 -->
|
||||
<el-pagination
|
||||
:page-sizes="[100, 500, 1000]"
|
||||
:page-size.sync="query.size"
|
||||
:total="query.total"
|
||||
:current-page.sync="query.page"
|
||||
style="margin-top: 8px;"
|
||||
layout="total, prev, pager, next, sizes"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Search from './search.vue'
|
||||
import CRUD, { crud, header, presenter } from '@crud/crud'
|
||||
import crudOperation from '@crud/CRUD.operation'
|
||||
import pagination from '@crud/Pagination'
|
||||
|
||||
import luceneOperation from '@/views/lucene/api/lucene'
|
||||
import { default as AnsiUp } from 'ansi_up'
|
||||
export default {
|
||||
name: 'LuceneLog',
|
||||
components: { Search, pagination, crudOperation },
|
||||
mixins: [presenter(), header(), crud()],
|
||||
cruds: function() {
|
||||
return CRUD({
|
||||
title: '系统参数', url: 'api/lucene/getAll', idField: 'id', sort: 'id,desc',
|
||||
queryOnPresenterCreated: true,
|
||||
optShow: {
|
||||
add: false,
|
||||
edit: false,
|
||||
del: false,
|
||||
download: false
|
||||
},
|
||||
page: {
|
||||
size: 40,
|
||||
total: 0,
|
||||
page: 0
|
||||
},
|
||||
query: {
|
||||
createTime: [new Date(new Date().setTime(new Date().getTime() - 3600 * 1000 * 24)), new Date()]
|
||||
}
|
||||
})
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
query: { blurry: '123' },
|
||||
permission: {
|
||||
add: ['admin', 'param:add'],
|
||||
edit: ['admin', 'param:edit'],
|
||||
del: ['admin', 'param:del']
|
||||
},
|
||||
|
||||
rules: {}
|
||||
levelOptions: [{
|
||||
value: 'DEBUG',
|
||||
label: 'DEBUG'
|
||||
}, {
|
||||
value: 'INFO',
|
||||
label: 'INFO'
|
||||
}, {
|
||||
value: 'ERROR',
|
||||
label: 'ERROR'
|
||||
}, {
|
||||
value: 'WARN',
|
||||
label: 'WARN'
|
||||
}],
|
||||
rules: {},
|
||||
logs: [],
|
||||
query: {
|
||||
tlogTraceId: '',
|
||||
message: '',
|
||||
page: 0,
|
||||
size: 100,
|
||||
total: 0,
|
||||
createTime: ''
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.queryData()
|
||||
},
|
||||
methods: {
|
||||
// 钩子:在获取表格数据之前执行,false 则代表不获取数据
|
||||
[CRUD.HOOK.beforeRefresh]() {
|
||||
return true
|
||||
handleSizeChange(val) {
|
||||
this.query.size = val
|
||||
this.queryData()
|
||||
},
|
||||
confirmDelAll() {
|
||||
this.$confirm(`确认清空所有操作日志吗?`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
this.crud.delAllLoading = true
|
||||
delAll('device_execute').then(res => {
|
||||
this.crud.delAllLoading = false
|
||||
this.crud.dleChangePage(1)
|
||||
this.crud.delSuccessNotify()
|
||||
this.crud.toQuery()
|
||||
}).catch(err => {
|
||||
this.crud.delAllLoading = false
|
||||
console.log(err.response.data.message)
|
||||
})
|
||||
}).catch(() => {
|
||||
handleCurrentChange(val) {
|
||||
this.query.page = val
|
||||
this.queryData()
|
||||
},
|
||||
queryData() {
|
||||
luceneOperation.getLogData(this.query).then(res => {
|
||||
var ansi_up = new AnsiUp()
|
||||
// 数据初始化
|
||||
for (const i in res.content) {
|
||||
this.logs[i] = ansi_up.ansi_to_html(res.content[i])
|
||||
}
|
||||
// this.logs = res.content
|
||||
this.query.total = res.totalElements
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,57 +1,24 @@
|
||||
<template>
|
||||
<div v-if="crud.props.searchToggle">
|
||||
<el-input
|
||||
v-model="query.device_code"
|
||||
v-model="query.message"
|
||||
clearable
|
||||
size="small"
|
||||
placeholder="请输入你要搜索的设备号"
|
||||
placeholder="请输入内容"
|
||||
style="width: 200px;"
|
||||
class="filter-item"
|
||||
/>
|
||||
<el-input
|
||||
v-model="query.method"
|
||||
v-model="query.tlogTraceId"
|
||||
clearable
|
||||
size="small"
|
||||
placeholder="请输入你要搜索的方法名"
|
||||
style="width: 200px;"
|
||||
class="filter-item"
|
||||
/>
|
||||
<el-input
|
||||
v-model="query.status_code"
|
||||
clearable
|
||||
size="small"
|
||||
placeholder="请输入你要搜索的状态码"
|
||||
style="width: 200px;"
|
||||
class="filter-item"
|
||||
/>
|
||||
<el-input
|
||||
v-model="query.requestparam"
|
||||
clearable
|
||||
size="small"
|
||||
placeholder="请输入你要搜索的请求参数"
|
||||
style="width: 200px;"
|
||||
class="filter-item"
|
||||
/>
|
||||
<el-input
|
||||
v-model="query.responseparam"
|
||||
clearable
|
||||
size="small"
|
||||
placeholder="请输入你要搜索的返回参数"
|
||||
style="width: 200px;"
|
||||
class="filter-item"
|
||||
/>
|
||||
<el-input
|
||||
v-model="query.blurry"
|
||||
clearable
|
||||
size="small"
|
||||
placeholder="请输入你要搜索的内容详情"
|
||||
placeholder="请输入链路ID"
|
||||
style="width: 200px;"
|
||||
class="filter-item"
|
||||
/>
|
||||
<!--
|
||||
<date-range-picker v-model="query.createTime" class="date-item" />
|
||||
-->
|
||||
|
||||
<el-date-picker
|
||||
v-model="query.createTime"
|
||||
type="datetimerange"
|
||||
|
||||
Reference in New Issue
Block a user