es集成,去掉loki
This commit is contained in:
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);
|
||||
@@ -50,8 +47,8 @@ public class LmsToMesServiceImpl implements LmsToMesService {
|
||||
String UserName = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("MES_USERNAME").getValue();
|
||||
String Password = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("MES_PASSWORD").getValue();
|
||||
|
||||
param.put("UserName",UserName);
|
||||
param.put("Password",Password);
|
||||
param.put("UserName", UserName);
|
||||
param.put("Password", Password);
|
||||
|
||||
// String url = acsUrl + api;
|
||||
String url = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("MES_URL").getValue();
|
||||
@@ -65,13 +62,13 @@ public class LmsToMesServiceImpl implements LmsToMesService {
|
||||
log.info("momRollFoilWeighing接口输出参数为:-------------------" + result.toString());
|
||||
|
||||
String RTYPE = result.getString("RTYPE");
|
||||
if (RTYPE.equals("E")){
|
||||
if (RTYPE.equals("E")) {
|
||||
throw new BadRequestException(result.getString("RTMSG"));
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new BadRequestException("MES提示错误:"+e.getMessage());
|
||||
throw new BadRequestException("MES提示错误:" + e.getMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -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());
|
||||
@@ -108,13 +105,13 @@ public class LmsToMesServiceImpl implements LmsToMesService {
|
||||
log.info("momRollBakeInBound接口输出参数为:-------------------" + result.toString());
|
||||
|
||||
String RTYPE = result.getString("RTYPE");
|
||||
if (RTYPE.equals("E")){
|
||||
if (RTYPE.equals("E")) {
|
||||
throw new BadRequestException(result.getString("RTMSG"));
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new BadRequestException("MES提示错误:"+e.getMessage());
|
||||
throw new BadRequestException("MES提示错误:" + e.getMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -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());
|
||||
@@ -140,8 +137,8 @@ public class LmsToMesServiceImpl implements LmsToMesService {
|
||||
|
||||
String UserName = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("MES_USERNAME").getValue();
|
||||
String Password = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("MES_PASSWORD").getValue();
|
||||
param.put("UserName",UserName);
|
||||
param.put("Password",Password);
|
||||
param.put("UserName", UserName);
|
||||
param.put("Password", Password);
|
||||
|
||||
// String url = acsUrl + api;
|
||||
String url = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("MES_URL").getValue();
|
||||
@@ -155,13 +152,13 @@ public class LmsToMesServiceImpl implements LmsToMesService {
|
||||
log.info("momRollBakeOutBound接口输出参数为:-------------------" + result.toString());
|
||||
|
||||
String RTYPE = result.getString("RTYPE");
|
||||
if (RTYPE.equals("E")){
|
||||
if (RTYPE.equals("E")) {
|
||||
throw new BadRequestException(result.getString("RTMSG"));
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new BadRequestException("MES提示错误:"+e.getMessage());
|
||||
throw new BadRequestException("MES提示错误:" + e.getMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -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());
|
||||
@@ -199,13 +196,13 @@ public class LmsToMesServiceImpl implements LmsToMesService {
|
||||
|
||||
|
||||
String RTYPE = result.getString("RTYPE");
|
||||
if (RTYPE.equals("E")){
|
||||
if (RTYPE.equals("E")) {
|
||||
throw new BadRequestException(result.getString("RTMSG"));
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new BadRequestException("MES提示错误:"+e.getMessage());
|
||||
throw new BadRequestException("MES提示错误:" + e.getMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -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());
|
||||
@@ -249,13 +246,13 @@ public class LmsToMesServiceImpl implements LmsToMesService {
|
||||
log.info("airSwellWithPaperTubeAssComplete接口输出参数为:-------------------" + result.toString());
|
||||
|
||||
String RTYPE = result.getString("RTYPE");
|
||||
if (RTYPE.equals("E")){
|
||||
if (RTYPE.equals("E")) {
|
||||
throw new BadRequestException(result.getString("RTMSG"));
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new BadRequestException("MES提示错误:"+e.getMessage());
|
||||
throw new BadRequestException("MES提示错误:" + e.getMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -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,19 +280,18 @@ public class LmsToMesServiceImpl implements LmsToMesService {
|
||||
String warehouse = param.getString("warehouse");
|
||||
|
||||
|
||||
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("iContainerName",container_name);
|
||||
jo.put("iisSourceRollDeliveryComplete",1);
|
||||
jo.put("PackageBoxSN",package_box_sn);
|
||||
jo.put("iWarehouse",warehouse);
|
||||
jo.put("iisAirSwellAssComplete","");
|
||||
jo.put("iisAirSwellDeliveryComplete","");
|
||||
jo.put("iContainerName", container_name);
|
||||
jo.put("iisSourceRollDeliveryComplete", 1);
|
||||
jo.put("PackageBoxSN", package_box_sn);
|
||||
jo.put("iWarehouse", warehouse);
|
||||
jo.put("iisAirSwellAssComplete", "");
|
||||
jo.put("iisAirSwellDeliveryComplete", "");
|
||||
|
||||
String UserName = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("MES_USERNAME").getValue();
|
||||
String Password = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("MES_PASSWORD").getValue();
|
||||
jo.put("UserName",UserName);
|
||||
jo.put("Password",Password);
|
||||
jo.put("UserName", UserName);
|
||||
jo.put("Password", Password);
|
||||
|
||||
// String url = acsUrl + api;
|
||||
String url = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("MES_URL").getValue();
|
||||
@@ -310,13 +306,13 @@ public class LmsToMesServiceImpl implements LmsToMesService {
|
||||
|
||||
|
||||
String RTYPE = result.getString("RTYPE");
|
||||
if (RTYPE.equals("E")){
|
||||
if (RTYPE.equals("E")) {
|
||||
throw new BadRequestException(result.getString("RTMSG"));
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new BadRequestException("MES提示错误:"+e.getMessage());
|
||||
throw new BadRequestException("MES提示错误:" + e.getMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -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());
|
||||
@@ -361,13 +357,13 @@ public class LmsToMesServiceImpl implements LmsToMesService {
|
||||
|
||||
|
||||
String RTYPE = result.getString("RTYPE");
|
||||
if (RTYPE.equals("E")){
|
||||
if (RTYPE.equals("E")) {
|
||||
throw new BadRequestException(result.getString("RTMSG"));
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new BadRequestException("MES提示错误:"+e.getMessage());
|
||||
throw new BadRequestException("MES提示错误:" + e.getMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -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());
|
||||
@@ -401,8 +397,8 @@ public class LmsToMesServiceImpl implements LmsToMesService {
|
||||
|
||||
String UserName = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("MES_USERNAME").getValue();
|
||||
String Password = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("MES_PASSWORD").getValue();
|
||||
jo.put("UserName",UserName);
|
||||
jo.put("Password",Password);
|
||||
jo.put("UserName", UserName);
|
||||
jo.put("Password", Password);
|
||||
|
||||
// String url = acsUrl + api;
|
||||
String url = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("MES_URL").getValue();
|
||||
@@ -417,13 +413,13 @@ public class LmsToMesServiceImpl implements LmsToMesService {
|
||||
|
||||
|
||||
String RTYPE = result.getString("RTYPE");
|
||||
if (RTYPE.equals("E")){
|
||||
if (RTYPE.equals("E")) {
|
||||
throw new BadRequestException(result.getString("RTMSG"));
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new BadRequestException("MES提示错误:"+e.getMessage());
|
||||
throw new BadRequestException("MES提示错误:" + e.getMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -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());
|
||||
@@ -460,13 +456,13 @@ public class LmsToMesServiceImpl implements LmsToMesService {
|
||||
|
||||
|
||||
String RTYPE = result.getString("RTYPE");
|
||||
if (RTYPE.equals("E")){
|
||||
if (RTYPE.equals("E")) {
|
||||
throw new BadRequestException(result.getString("RTMSG"));
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new BadRequestException("MES提示错误:"+e.getMessage());
|
||||
throw new BadRequestException("MES提示错误:" + e.getMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -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());
|
||||
@@ -496,8 +492,8 @@ public class LmsToMesServiceImpl implements LmsToMesService {
|
||||
|
||||
String UserName = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("MES_USERNAME").getValue();
|
||||
String Password = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("MES_PASSWORD").getValue();
|
||||
param.put("UserName",UserName);
|
||||
param.put("Password",Password);
|
||||
param.put("UserName", UserName);
|
||||
param.put("Password", Password);
|
||||
|
||||
try {
|
||||
String resultMsg = HttpRequest.post(url)
|
||||
@@ -508,13 +504,13 @@ public class LmsToMesServiceImpl implements LmsToMesService {
|
||||
|
||||
|
||||
String RTYPE = result.getString("RTYPE");
|
||||
if (RTYPE.equals("E")){
|
||||
if (RTYPE.equals("E")) {
|
||||
throw new BadRequestException(result.getString("RTMSG"));
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new BadRequestException("MES提示错误:"+e.getMessage());
|
||||
throw new BadRequestException("MES提示错误:" + e.getMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -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());
|
||||
@@ -544,8 +540,8 @@ public class LmsToMesServiceImpl implements LmsToMesService {
|
||||
|
||||
String UserName = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("MES_USERNAME").getValue();
|
||||
String Password = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("MES_PASSWORD").getValue();
|
||||
param.put("UserName",UserName);
|
||||
param.put("Password",Password);
|
||||
param.put("UserName", UserName);
|
||||
param.put("Password", Password);
|
||||
|
||||
try {
|
||||
String resultMsg = HttpRequest.post(url)
|
||||
@@ -556,13 +552,13 @@ public class LmsToMesServiceImpl implements LmsToMesService {
|
||||
|
||||
|
||||
String RTYPE = result.getString("RTYPE");
|
||||
if (RTYPE.equals("E")){
|
||||
if (RTYPE.equals("E")) {
|
||||
throw new BadRequestException(result.getString("RTMSG"));
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new BadRequestException("MES提示错误:"+e.getMessage());
|
||||
throw new BadRequestException("MES提示错误:" + e.getMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
/*
|
||||
@@ -58,8 +55,8 @@ public class LmsToSapServiceImpl implements LmsToSapService {
|
||||
String api = "";
|
||||
url = url + "/sap/center/wms/004";
|
||||
try {
|
||||
String resultMsg = HttpRequest.post(url).header("TOKEN",token)
|
||||
.header("sap-client",sap_client)
|
||||
String resultMsg = HttpRequest.post(url).header("TOKEN", token)
|
||||
.header("sap-client", sap_client)
|
||||
.body(String.valueOf(jo))
|
||||
.execute().body();
|
||||
result = JSONObject.parseObject(resultMsg);
|
||||
@@ -72,13 +69,13 @@ public class LmsToSapServiceImpl implements LmsToSapService {
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new BadRequestException("SAP提示错误:"+e.getMessage());
|
||||
throw new BadRequestException("SAP提示错误:" + e.getMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@LokiLog(type = LokiLogType.LMS_TO_SAP)
|
||||
|
||||
@Override
|
||||
public JSONObject returnMoveDtl(JSONObject jo) {
|
||||
/*
|
||||
@@ -123,8 +120,8 @@ public class LmsToSapServiceImpl implements LmsToSapService {
|
||||
String api = "/sap/center/wms/005";
|
||||
url = url + api;
|
||||
try {
|
||||
String resultMsg = HttpRequest.post(url).header("TOKEN",token)
|
||||
.header("sap-client",sap_client)
|
||||
String resultMsg = HttpRequest.post(url).header("TOKEN", token)
|
||||
.header("sap-client", sap_client)
|
||||
.body(String.valueOf(jo))
|
||||
.execute().body();
|
||||
result = JSONObject.parseObject(resultMsg);
|
||||
@@ -136,7 +133,7 @@ public class LmsToSapServiceImpl implements LmsToSapService {
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new BadRequestException("SAP提示错误:"+e.getMessage());
|
||||
throw new BadRequestException("SAP提示错误:" + e.getMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
@@ -51,33 +49,33 @@ public class SapToLmsServiceImpl implements SapToLmsService {
|
||||
WQLObject.getWQLObject("md_me_materialbaseext").update(row);
|
||||
}
|
||||
|
||||
JSONObject base_jo = WQLObject.getWQLObject("md_me_materialbase").query("material_code = '"+MATNR+"'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(base_jo)){
|
||||
JSONObject base_jo = WQLObject.getWQLObject("md_me_materialbase").query("material_code = '" + MATNR + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(base_jo)) {
|
||||
JSONObject mater_base_jo = new JSONObject();
|
||||
mater_base_jo.put("material_id",IdUtil.getSnowflake(1,1).nextId());
|
||||
mater_base_jo.put("material_code",MATNR);
|
||||
mater_base_jo.put("material_name",MATNR01);
|
||||
JSONObject unit = WQLObject.getWQLObject("md_pb_measureunit").query("unit_code = '"+MEINS+"'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(unit)){
|
||||
mater_base_jo.put("material_id", IdUtil.getSnowflake(1, 1).nextId());
|
||||
mater_base_jo.put("material_code", MATNR);
|
||||
mater_base_jo.put("material_name", MATNR01);
|
||||
JSONObject unit = WQLObject.getWQLObject("md_pb_measureunit").query("unit_code = '" + MEINS + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(unit)) {
|
||||
throw new BadRequestException("未查询到相关计量单位,请进行维护!");
|
||||
}
|
||||
mater_base_jo.put("base_unit_id",unit.getString("measure_unit_id"));
|
||||
mater_base_jo.put("base_unit_id", unit.getString("measure_unit_id"));
|
||||
mater_base_jo.put("create_id", "1");
|
||||
mater_base_jo.put("create_name", "管理员");
|
||||
mater_base_jo.put("create_time", DateUtil.now());
|
||||
mater_base_jo.put("update_optid", "1");
|
||||
mater_base_jo.put("update_optname", "管理员");
|
||||
mater_base_jo.put("update_time", DateUtil.now());
|
||||
mater_base_jo.put("is_used","1");
|
||||
mater_base_jo.put("is_delete","0");
|
||||
mater_base_jo.put("is_used", "1");
|
||||
mater_base_jo.put("is_delete", "0");
|
||||
WQLObject.getWQLObject("md_me_materialbase").insert(mater_base_jo);
|
||||
}else {
|
||||
base_jo.put("material_name",MATNR01);
|
||||
JSONObject unit = WQLObject.getWQLObject("md_pb_measureunit").query("unit_code = '"+MEINS+"'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(unit)){
|
||||
} else {
|
||||
base_jo.put("material_name", MATNR01);
|
||||
JSONObject unit = WQLObject.getWQLObject("md_pb_measureunit").query("unit_code = '" + MEINS + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(unit)) {
|
||||
throw new BadRequestException("未查询到相关计量单位,请进行维护!");
|
||||
}
|
||||
base_jo.put("base_unit_id",unit.getString("measure_unit_id"));
|
||||
base_jo.put("base_unit_id", unit.getString("measure_unit_id"));
|
||||
base_jo.put("update_optid", "1");
|
||||
base_jo.put("update_optname", "管理员");
|
||||
base_jo.put("update_time", DateUtil.now());
|
||||
@@ -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());
|
||||
@@ -168,7 +166,7 @@ public class SapToLmsServiceImpl implements SapToLmsService {
|
||||
jsonMst.put("consignee", json.getString("NAMEM")); // 收货单位
|
||||
jsonMst.put("receiptaddress", json.getString("ADRNRS")); // 收货地址
|
||||
/*jsonMst.put("remark",json.getString("LGORT"));//库位*/
|
||||
|
||||
|
||||
|
||||
// 明细
|
||||
JSONObject jsonMater = materTab.query("material_code = '" + json.getString("MATNR") + "'").uniqueResult(0);
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user