es集成,去掉loki
This commit is contained in:
Binary file not shown.
@@ -3,7 +3,7 @@ window.g = {
|
||||
VUE_APP_BASE_API: 'http://127.0.0.1:8010'
|
||||
},
|
||||
prod: {
|
||||
VUE_APP_BASE_API: 'http://10.1.3.90:8011'
|
||||
VUE_APP_BASE_API: 'http://127.0.0.1:8010'
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,29 @@
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.elasticsearch.client</groupId>
|
||||
<artifactId>elasticsearch-rest-high-level-client</artifactId>
|
||||
<version>7.6.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.elasticsearch.client</groupId>
|
||||
<artifactId>elasticsearch-rest-client</artifactId>
|
||||
<version>7.6.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.elasticsearch</groupId>
|
||||
<artifactId>elasticsearch</artifactId>
|
||||
<version>7.6.1</version>
|
||||
</dependency>
|
||||
<!-- logback appender日志-->
|
||||
<dependency>
|
||||
<groupId>com.internetitem</groupId>
|
||||
<artifactId>logback-elasticsearch-appender</artifactId>
|
||||
<version>1.6</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.reflections</groupId>
|
||||
<artifactId>reflections</artifactId>
|
||||
|
||||
104
lms/nladmin-system/src/main/java/org/nl/ElasticSearchTest.java
Normal file
104
lms/nladmin-system/src/main/java/org/nl/ElasticSearchTest.java
Normal file
@@ -0,0 +1,104 @@
|
||||
package org.nl;
|
||||
|
||||
|
||||
import org.apache.http.HttpHost;
|
||||
import org.elasticsearch.action.get.GetRequest;
|
||||
import org.elasticsearch.action.get.GetResponse;
|
||||
import org.elasticsearch.action.search.SearchRequest;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.client.RequestOptions;
|
||||
import org.elasticsearch.client.RestClient;
|
||||
import org.elasticsearch.client.RestHighLevelClient;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.index.query.BoolQueryBuilder;
|
||||
import org.elasticsearch.index.query.MatchQueryBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.index.query.RangeQueryBuilder;
|
||||
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class ElasticSearchTest {
|
||||
|
||||
public final String ES_URL = "127.0.0.1";
|
||||
|
||||
public final int ES_PORT = 9200;
|
||||
|
||||
|
||||
public static RestHighLevelClient getClientConnection() {
|
||||
|
||||
RestHighLevelClient client = new RestHighLevelClient(
|
||||
RestClient.builder(
|
||||
new HttpHost("localhost", 9200, "http")
|
||||
)
|
||||
);
|
||||
|
||||
return client;
|
||||
}
|
||||
|
||||
public static void searchById() throws IOException {
|
||||
RestHighLevelClient client = getClientConnection();
|
||||
GetRequest getRequest = new GetRequest("gateway_log", "DceJqGwBqlIig5BB05Z-");
|
||||
GetResponse getResponse = client.get(getRequest, RequestOptions.DEFAULT);
|
||||
System.out.println(getResponse.getSourceAsString());
|
||||
client.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-search.html
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void paginationSearch() throws IOException {
|
||||
|
||||
SearchRequest searchRequest = new SearchRequest();
|
||||
SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
|
||||
sourceBuilder.query(QueryBuilders.matchPhraseQuery("eventType", "WAN_ONOFF"));
|
||||
sourceBuilder.from(0);
|
||||
sourceBuilder.size(1);
|
||||
sourceBuilder.timeout(new TimeValue(1000));
|
||||
sourceBuilder.trackTotalHits(true);
|
||||
searchRequest.source(sourceBuilder);
|
||||
|
||||
|
||||
RestHighLevelClient client = getClientConnection();
|
||||
SearchResponse response = client.search(new SearchRequest("gateway_log")
|
||||
.source(sourceBuilder), RequestOptions.DEFAULT);
|
||||
|
||||
System.out.println(response.toString());
|
||||
client.close();
|
||||
}
|
||||
|
||||
public static void paginationSearch2() throws IOException {
|
||||
RestHighLevelClient client = getClientConnection();
|
||||
|
||||
|
||||
BoolQueryBuilder boolQuery = new BoolQueryBuilder();
|
||||
|
||||
RangeQueryBuilder rangeQuery= QueryBuilders.rangeQuery("count").gte(8);
|
||||
boolQuery.filter(rangeQuery);
|
||||
|
||||
MatchQueryBuilder matchQuery = new MatchQueryBuilder("eventType", "WAN_ONOFF");
|
||||
boolQuery.must(matchQuery);
|
||||
|
||||
SearchResponse response = client.search(new SearchRequest("gateway_log")
|
||||
.source(new SearchSourceBuilder()
|
||||
.query(boolQuery)
|
||||
.from(0)
|
||||
.size(2)
|
||||
.trackTotalHits(true)
|
||||
), RequestOptions.DEFAULT);
|
||||
|
||||
System.out.println(response.getHits().getTotalHits());
|
||||
System.out.println(response.toString());
|
||||
client.close();
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
//searchById();
|
||||
//paginationSearch();
|
||||
paginationSearch2();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package org.nl.modules.logging.rest;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.nl.modules.logging.service.EsLogService;
|
||||
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.RestController;
|
||||
|
||||
/**
|
||||
* @author ldjun
|
||||
* @version 1.0
|
||||
* @date 2023年01月29日 18:55
|
||||
* @desc desc
|
||||
*/
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/api/esLog")
|
||||
public class EsLogController {
|
||||
private final EsLogService esLogService;
|
||||
|
||||
@GetMapping("/labels")
|
||||
@ApiOperation("获取标签")
|
||||
public ResponseEntity<Object> labelsValues() {
|
||||
return new ResponseEntity<>(esLogService.getLabelsValues(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package org.nl.modules.logging.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
|
||||
/**
|
||||
* @author ldjun
|
||||
* @version 1.0
|
||||
* @date 2023年02月07日 14:34
|
||||
* @desc desc
|
||||
*/
|
||||
public interface EsLogService {
|
||||
/**
|
||||
* 获取labels和values树
|
||||
* @return
|
||||
*/
|
||||
JSONArray getLabelsValues();
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package org.nl.modules.logging.service.impl;
|
||||
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.nl.modules.logging.service.EsLogService;
|
||||
import org.nl.wms.ext.acs.service.impl.AcsToWmsServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author ldjun
|
||||
* @version 1.0
|
||||
* @date 2023年02月07日 14:35
|
||||
* @desc desc
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class EsLogServiceImpl implements EsLogService {
|
||||
@Override
|
||||
public JSONArray getLabelsValues() {
|
||||
/**
|
||||
* [{
|
||||
* label:
|
||||
* value:
|
||||
* children:[{
|
||||
* label
|
||||
* value
|
||||
* }]
|
||||
* }]
|
||||
*/
|
||||
//获取所有索引
|
||||
// String url = "http://47.111.78.178:27017/_cat/indices";
|
||||
|
||||
String url = "http://47.111.78.178:27017/_aliases";
|
||||
String resultMsg = HttpRequest.get(url)
|
||||
.execute().body();
|
||||
|
||||
JSONObject jsonObject = JSON.parseObject(resultMsg);
|
||||
|
||||
JSONArray arr = new JSONArray();
|
||||
|
||||
for (Map.Entry entry : jsonObject.entrySet()) {
|
||||
System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue());
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("label", entry.getKey());
|
||||
json.put("Value", entry.getValue());
|
||||
arr.add(json);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// String url = "http://47.111.78.178:27017/_cat/indices";
|
||||
String url = "http://47.111.78.178:27017/_aliases";
|
||||
String resultMsg = HttpRequest.get(url)
|
||||
.execute().body();
|
||||
|
||||
JSONObject jsonObject = JSON.parseObject(resultMsg);
|
||||
|
||||
JSONArray arr = new JSONArray();
|
||||
|
||||
for (Map.Entry entry : jsonObject.entrySet()) {
|
||||
System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue());
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("label", entry.getKey());
|
||||
json.put("Value", entry.getValue());
|
||||
arr.add(json);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -12,8 +12,6 @@ import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.modules.wql.WQL;
|
||||
import org.nl.wms.ext.crm.service.CrmToLmsService;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.wms.log.LokiLog;
|
||||
import org.nl.wms.log.LokiLogType;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -23,7 +21,7 @@ import java.util.HashMap;
|
||||
@Slf4j
|
||||
public class CrmToLmsServiceImpl implements CrmToLmsService {
|
||||
|
||||
@LokiLog(type = LokiLogType.CRM_TO_LMS)
|
||||
|
||||
@Override
|
||||
public JSONObject getCustomerInfo(JSONObject row) {
|
||||
|
||||
@@ -94,7 +92,7 @@ public class CrmToLmsServiceImpl implements CrmToLmsService {
|
||||
return result;
|
||||
}
|
||||
|
||||
@LokiLog(type = LokiLogType.CRM_TO_LMS)
|
||||
|
||||
@Override
|
||||
public JSONObject getCPIvtInfo(JSONObject jo) {
|
||||
log.info("getCPIvtInfo输入参数为:----------------------" + jo.toString());
|
||||
|
||||
@@ -8,12 +8,9 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.nl.system.service.param.impl.SysParamServiceImpl;
|
||||
import org.nl.wms.ext.mes.service.LmsToMesService;
|
||||
import org.nl.wms.log.LokiLog;
|
||||
import org.nl.wms.log.LokiLogType;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -32,7 +29,7 @@ public class LmsToMesServiceImpl implements LmsToMesService {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@LokiLog(type = LokiLogType.LMS_TO_MES)
|
||||
|
||||
@Override
|
||||
public JSONObject momRollFoilWeighing(JSONObject param) {
|
||||
log.info("momRollFoilWeighing接口输入参数为:-------------------" + param);
|
||||
@@ -81,7 +78,7 @@ public class LmsToMesServiceImpl implements LmsToMesService {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@LokiLog(type = LokiLogType.LMS_TO_MES)
|
||||
|
||||
@Override
|
||||
public JSONObject momRollBakeInBound(JSONObject param) {
|
||||
log.info("momRollBakeInBound接口输入参数为:-------------------" + param.toString());
|
||||
@@ -124,7 +121,7 @@ public class LmsToMesServiceImpl implements LmsToMesService {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@LokiLog(type = LokiLogType.LMS_TO_MES)
|
||||
|
||||
@Override
|
||||
public JSONObject momRollBakeOutBound(JSONObject param) {
|
||||
log.info("momRollBakeOutBound接口输入参数为:-------------------" + param.toString());
|
||||
@@ -171,7 +168,7 @@ public class LmsToMesServiceImpl implements LmsToMesService {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@LokiLog(type = LokiLogType.LMS_TO_MES)
|
||||
|
||||
@Override
|
||||
public JSONObject momRollSemiFGInboundComplete(JSONObject param) {
|
||||
log.info("momRollSemiFGInboundComplete接口输入参数为:-------------------" + param.toString());
|
||||
@@ -215,7 +212,7 @@ public class LmsToMesServiceImpl implements LmsToMesService {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@LokiLog(type = LokiLogType.LMS_TO_MES)
|
||||
|
||||
@Override
|
||||
public JSONObject airSwellWithPaperTubeAssComplete(JSONObject param) {
|
||||
log.info("airSwellWithPaperTubeAssComplete接口输入参数为:-------------------" + param.toString());
|
||||
@@ -265,7 +262,7 @@ public class LmsToMesServiceImpl implements LmsToMesService {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@LokiLog(type = LokiLogType.LMS_TO_MES)
|
||||
|
||||
@Override
|
||||
public JSONObject cutPlanMomRollDeliveryComplete(JSONObject param) {
|
||||
log.info("cutPlanMomRollDeliveryComplete接口输入参数为:-------------------" + param.toString());
|
||||
@@ -283,7 +280,6 @@ public class LmsToMesServiceImpl implements LmsToMesService {
|
||||
String warehouse = param.getString("warehouse");
|
||||
|
||||
|
||||
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("iContainerName", container_name);
|
||||
jo.put("iisSourceRollDeliveryComplete", 1);
|
||||
@@ -326,7 +322,7 @@ public class LmsToMesServiceImpl implements LmsToMesService {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@LokiLog(type = LokiLogType.LMS_TO_MES)
|
||||
|
||||
@Override
|
||||
public JSONObject airSwellWithPaperTubeAssArrival(JSONObject param) {
|
||||
log.info("airSwellWithPaperTubeAssArrival接口输入参数为:-------------------" + param.toString());
|
||||
@@ -377,7 +373,7 @@ public class LmsToMesServiceImpl implements LmsToMesService {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@LokiLog(type = LokiLogType.LMS_TO_MES)
|
||||
|
||||
@Override
|
||||
public JSONObject childRollFGInboundComplete(JSONObject param) {
|
||||
log.info("childRollFGInboundComplete接口输入参数为:-------------------" + param.toString());
|
||||
@@ -433,7 +429,7 @@ public class LmsToMesServiceImpl implements LmsToMesService {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@LokiLog(type = LokiLogType.LMS_TO_MES)
|
||||
|
||||
@Override
|
||||
public JSONObject childRollFGOutboundComplete(JSONObject param) {
|
||||
log.info("childRollFGOutboundComplete接口输入参数为:-------------------" + param.toString());
|
||||
@@ -476,7 +472,7 @@ public class LmsToMesServiceImpl implements LmsToMesService {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@LokiLog(type = LokiLogType.LMS_TO_MES)
|
||||
|
||||
@Override
|
||||
public JSONObject lmsUnPackage(JSONObject param) {
|
||||
log.info("LMSUnPackakge接口输入参数为:-------------------" + param.toString());
|
||||
@@ -524,7 +520,7 @@ public class LmsToMesServiceImpl implements LmsToMesService {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@LokiLog(type = LokiLogType.LMS_TO_MES)
|
||||
|
||||
@Override
|
||||
public JSONObject lmsPackage(JSONObject param) {
|
||||
log.info("LMSPackakge接口输入参数为:-------------------" + param.toString());
|
||||
|
||||
@@ -19,8 +19,6 @@ import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.nl.system.service.param.impl.SysParamServiceImpl;
|
||||
import org.nl.wms.ext.acs.service.impl.WmsToAcsServiceImpl;
|
||||
import org.nl.wms.ext.mes.service.MesToLmsService;
|
||||
import org.nl.wms.log.LokiLog;
|
||||
import org.nl.wms.log.LokiLogType;
|
||||
import org.nl.wms.pda.mps.service.InService;
|
||||
import org.nl.wms.pda.mps.service.OutService;
|
||||
import org.nl.wms.pda.mps.service.impl.BakingServiceImpl;
|
||||
@@ -30,7 +28,6 @@ import org.nl.wms.st.inbill.service.CheckOutBillService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
|
||||
@Service
|
||||
|
||||
@@ -7,12 +7,9 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.nl.system.service.param.impl.SysParamServiceImpl;
|
||||
import org.nl.wms.ext.sap.service.LmsToSapService;
|
||||
import org.nl.wms.log.LokiLog;
|
||||
import org.nl.wms.log.LokiLogType;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -21,7 +18,7 @@ import org.springframework.stereotype.Service;
|
||||
@Slf4j
|
||||
public class LmsToSapServiceImpl implements LmsToSapService {
|
||||
|
||||
@LokiLog(type = LokiLogType.LMS_TO_SAP)
|
||||
|
||||
@Override
|
||||
public JSONObject returnDelivery(JSONObject jo) {
|
||||
/*
|
||||
@@ -78,7 +75,7 @@ public class LmsToSapServiceImpl implements LmsToSapService {
|
||||
}
|
||||
}
|
||||
|
||||
@LokiLog(type = LokiLogType.LMS_TO_SAP)
|
||||
|
||||
@Override
|
||||
public JSONObject returnMoveDtl(JSONObject jo) {
|
||||
/*
|
||||
|
||||
@@ -11,8 +11,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.wms.ext.sap.service.SapToLmsService;
|
||||
import org.nl.wms.log.LokiLog;
|
||||
import org.nl.wms.log.LokiLogType;
|
||||
import org.nl.wms.st.inbill.service.CheckOutBillService;
|
||||
import org.nl.wms.st.inbill.service.RawAssistIStorService;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -29,7 +27,7 @@ public class SapToLmsServiceImpl implements SapToLmsService {
|
||||
|
||||
private final RawAssistIStorService rawAssistIStorService;
|
||||
|
||||
@LokiLog(type = LokiLogType.SAP_TO_LMS)
|
||||
|
||||
@Override
|
||||
public JSONObject getMaterialInfo(JSONObject jo) {
|
||||
JSONArray rows = jo.getJSONArray("DATAS");
|
||||
@@ -96,7 +94,7 @@ public class SapToLmsServiceImpl implements SapToLmsService {
|
||||
return result;
|
||||
}
|
||||
|
||||
@LokiLog(type = LokiLogType.SAP_TO_LMS)
|
||||
|
||||
@Override
|
||||
public JSONObject getDeliveryInfo(JSONObject jo) {
|
||||
log.info("getDeliveryInfo的输入参数为:------------------------" + jo.toString());
|
||||
@@ -298,7 +296,7 @@ public class SapToLmsServiceImpl implements SapToLmsService {
|
||||
return result;
|
||||
}
|
||||
|
||||
@LokiLog(type = LokiLogType.SAP_TO_LMS)
|
||||
|
||||
@Override
|
||||
public JSONObject getReturnDeliveryInfo(JSONObject jo) {
|
||||
/**
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
package org.nl.wms.log;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @author: lyd
|
||||
* @description: 自定义日志注解,用作LOKI日志分类
|
||||
* @Date: 2022/10/10
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ ElementType.METHOD})
|
||||
@Documented
|
||||
public @interface LokiLog {
|
||||
LokiLogType type() default LokiLogType.DEFAULT;
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
package org.nl.wms.log;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.Signature;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.slf4j.MDC;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
|
||||
/**
|
||||
* @author: lyd
|
||||
* @description: 自定义日志切面:https://cloud.tencent.com/developer/article/1655923
|
||||
* @Date: 2022/10/10
|
||||
*/
|
||||
@Aspect
|
||||
@Slf4j
|
||||
@Component
|
||||
public class LokiLogAspect {
|
||||
/**
|
||||
* 切到所有OperatorLog注解修饰的方法
|
||||
*/
|
||||
@Pointcut("@annotation(org.nl.wms.log.LokiLog)")
|
||||
public void operatorLog() {
|
||||
// 空方法
|
||||
}
|
||||
|
||||
/**
|
||||
* 利用@Around环绕增强
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Around("operatorLog()")
|
||||
public Object around(ProceedingJoinPoint pjp) throws Throwable {
|
||||
// ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
// HttpServletRequest request = attributes.getRequest();
|
||||
// HttpServletResponse response = attributes.getResponse();
|
||||
|
||||
Signature signature = pjp.getSignature();
|
||||
MethodSignature methodSignature = (MethodSignature) signature;
|
||||
Method method = methodSignature.getMethod();
|
||||
LokiLog lokiLog = method.getAnnotation(LokiLog.class);
|
||||
|
||||
// 获取描述信息
|
||||
LokiLogType logType = lokiLog.type();
|
||||
|
||||
MDC.put("log_file_type", logType.getDesc());
|
||||
log.info("输入参数:" + JSONObject.toJSONString(pjp.getArgs()));
|
||||
|
||||
Object proceed = pjp.proceed();
|
||||
|
||||
log.info("返回参数:" + JSONObject.toJSONString(proceed));
|
||||
MDC.remove("log_file_type");
|
||||
return proceed;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package org.nl.wms.log;
|
||||
|
||||
/**
|
||||
* @author: lyd
|
||||
* @description:
|
||||
* @Date: 2022/10/11
|
||||
*/
|
||||
public enum LokiLogType {
|
||||
DEFAULT("默认"),
|
||||
LMS_TO_MES("LMS请求MES"),
|
||||
MES_TO_LMS("MES请求LMS"),
|
||||
LMS_TO_CRM("LMS请求CRM"),
|
||||
CRM_TO_LMS("CRM请求LMS"),
|
||||
LMS_TO_SAP("LMS请求SAP"),
|
||||
SAP_TO_LMS("SAP请求LMS"),
|
||||
LMS_TO_ACS("LMS请求ACS"),
|
||||
ACS_TO_LMS("ACS请求LMS");
|
||||
|
||||
private String desc;
|
||||
|
||||
LokiLogType(String desc) {
|
||||
this.desc=desc;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
}
|
||||
@@ -117,5 +117,7 @@ mybatis-plus:
|
||||
global-config:
|
||||
db-config:
|
||||
id-type: INPUT
|
||||
|
||||
|
||||
management:
|
||||
health:
|
||||
elasticsearch:
|
||||
enabled: false #取消对elasticsearch的检查 https://www.codeleading.com/article/60643988608/
|
||||
|
||||
@@ -47,6 +47,60 @@ https://juejin.cn/post/6844903775631572999
|
||||
|
||||
</appender>
|
||||
|
||||
|
||||
<appender name="esLogAppender" class="com.internetitem.logback.elasticsearch.ElasticsearchAppender">
|
||||
<url>http://47.111.78.178:27017/_bulk</url>
|
||||
<index>logs-%date{yyyy-MM-dd}</index>
|
||||
<type>tester</type>
|
||||
<loggerName>es-logger</loggerName> <!-- optional -->
|
||||
<errorLoggerName>es-error-logger</errorLoggerName> <!-- optional -->
|
||||
<connectTimeout>30000</connectTimeout> <!-- optional (in ms, default 30000) -->
|
||||
<errorsToStderr>false</errorsToStderr> <!-- optional (default false) -->
|
||||
<includeCallerData>false</includeCallerData> <!-- optional (default false) -->
|
||||
<logsToStderr>false</logsToStderr> <!-- optional (default false) -->
|
||||
<maxQueueSize>104857600</maxQueueSize> <!-- optional (default 104857600) -->
|
||||
<maxRetries>3</maxRetries> <!-- optional (default 3) -->
|
||||
<readTimeout>30000</readTimeout> <!-- optional (in ms, default 30000) -->
|
||||
<sleepTime>250</sleepTime> <!-- optional (in ms, default 250) -->
|
||||
<rawJsonMessage>false</rawJsonMessage> <!-- optional (default false) -->
|
||||
<includeMdc>false</includeMdc> <!-- optional (default false) -->
|
||||
<maxMessageSize>20000</maxMessageSize> <!-- optional (default -1 -->
|
||||
<!-- <authentication class="com.internetitem.logback.elasticsearch.config.BasicAuthentication" /> <!– optional –>-->
|
||||
<properties>
|
||||
<property>
|
||||
<name>host</name>
|
||||
<value>${HOSTNAME}</value>
|
||||
<allowEmpty>false</allowEmpty>
|
||||
</property>
|
||||
<property>
|
||||
<name>severity</name>
|
||||
<value>%level</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>thread</name>
|
||||
<value>%thread</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>stacktrace</name>
|
||||
<value>%ex</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>logger</name>
|
||||
<value>%logger</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>traceId</name>
|
||||
<value>%X{traceId}</value>
|
||||
</property>
|
||||
</properties>
|
||||
<headers>
|
||||
<header>
|
||||
<name>Content-Type</name>
|
||||
<value>application/json</value>
|
||||
</header>
|
||||
</headers>
|
||||
</appender>
|
||||
|
||||
<appender name="ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||
<level>error</level>
|
||||
@@ -80,6 +134,7 @@ https://juejin.cn/post/6844903775631572999
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
<appender-ref ref="ERROR" />
|
||||
<appender-ref ref="esLogAppender" />
|
||||
</root>
|
||||
<logger name="org.springframework" level="ERROR" additivity="false">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
@@ -123,9 +178,9 @@ https://juejin.cn/post/6844903775631572999
|
||||
<!--生产环境:打印控制台和输出到文件-->
|
||||
<springProfile name="prod">
|
||||
<root level="debug">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
<appender-ref ref="ERROR" />
|
||||
<appender-ref ref="esLogAppender" />
|
||||
</root>
|
||||
<logger name="org.springframework" level="ERROR" additivity="false">
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
|
||||
@@ -10,7 +10,7 @@ export function getLogData(param) {
|
||||
|
||||
export function labelsValues() {
|
||||
return request({
|
||||
url: 'api/loki/labels/values',
|
||||
url: 'api/esLog/labels',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<div class="app-container">
|
||||
<div class="head-container">
|
||||
<!--工具栏-->
|
||||
<el-form :inline="true" class="demo-form-inline" label-suffix=":" label-width="80px">
|
||||
<el-form :inline="true" class="demo-form-inline" label-suffix=":" label-width="90px">
|
||||
<el-form-item label="日志标签">
|
||||
<el-cascader
|
||||
v-model="labelAndValue"
|
||||
|
||||
@@ -111,7 +111,7 @@
|
||||
style="width: 100%;"
|
||||
@selection-change="crud.selectionChangeHandler"
|
||||
>
|
||||
<el-table-column prop="task_code" label="任务编码" min-width="100" show-overflow-tooltip />
|
||||
<el-table-column prop="task_code" label="任务编码" min-width="150" show-overflow-tooltip />
|
||||
<el-table-column prop="task_type_name" label="任务类型" min-width="150" show-overflow-tooltip />
|
||||
<el-table-column prop="task_status_name" label="任务状态" width="95px" :formatter="formatTaskStatusName" />
|
||||
<el-table-column prop="point_code1" label="取货点1" width="100" show-overflow-tooltip />
|
||||
|
||||
Reference in New Issue
Block a user