opt:优化http调用外部日志
This commit is contained in:
@@ -2,6 +2,7 @@ package org.nl.acs.ext.wms.service.impl;
|
||||
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -11,6 +12,7 @@ import org.nl.acs.device.address.service.AddressService;
|
||||
import org.nl.acs.device.address.service.dto.AddressDto;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device.service.impl.DeviceServiceImpl;
|
||||
import org.nl.acs.ext.wms.IpUtil;
|
||||
import org.nl.acs.ext.wms.NdcHttpUtil;
|
||||
import org.nl.acs.ext.wms.UnifiedResponse;
|
||||
import org.nl.acs.ext.wms.service.AcsToNDCService;
|
||||
@@ -74,19 +76,35 @@ public class AcsToNDCServiceImpl implements AcsToNDCService {
|
||||
String wmsurl = paramService.findByCode(AcsConfig.WCSURL).getValue();
|
||||
AddressDto addressDto = addressService.findByCode("applyTaskToWcs");
|
||||
String url = wmsurl + addressDto.getMethods_url();
|
||||
|
||||
LuceneLogDto logDto =
|
||||
LuceneLogDto.builder()
|
||||
.logType("接口日志")
|
||||
.request_url(wmsurl)
|
||||
.request_direction("post")
|
||||
.request_param(JSON.toJSONString(jo))
|
||||
.method(addressDto.getMethods_url())
|
||||
.content("开始请求")
|
||||
.build();
|
||||
luceneExecuteLogService.interfaceExecuteLog(logDto);
|
||||
long start = System.currentTimeMillis();
|
||||
HttpResponse result = HttpRequest.post(url)
|
||||
//表单内容
|
||||
.body(String.valueOf(jo))
|
||||
//超时,毫秒
|
||||
.timeout(20000)
|
||||
.execute();
|
||||
LuceneLogDto logDto1 = LuceneLogDto.builder()
|
||||
.device_code("下发ACS套件")
|
||||
.content("任务号:" + instruction.getTask_code() + ",指令号:" + instruction.getInstruction_code() + ",下发wcs任务序列反馈参数:" + jo)
|
||||
.build();
|
||||
logDto1.setLog_level(4);
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto1);
|
||||
LuceneLogDto logResult =
|
||||
LuceneLogDto.builder()
|
||||
.logType("接口日志")
|
||||
.request_url(wmsurl)
|
||||
.request_direction("post")
|
||||
.request_param(JSON.toJSONString(jo))
|
||||
.method(addressDto.getMethods_url())
|
||||
.response_param(JSON.toJSONString(result))
|
||||
.executeTime(System.currentTimeMillis() - start)
|
||||
.content("响应请求")
|
||||
.build();
|
||||
luceneExecuteLogService.deviceExecuteLog(logResult);
|
||||
log.info("任务号:{},指令号{},状态{},下发agv订单序列反馈:{}", instruction.getTask_code(), instruction.getInstruction_code(), result.getStatus(), result.body());
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public interface LuceneExecuteLogService {
|
||||
*
|
||||
* @param luceneLogDto 日志结果对象
|
||||
*/
|
||||
void interfaceExecuteLog(LuceneLogDto luceneLogDto) throws IOException;
|
||||
void interfaceExecuteLog(LuceneLogDto luceneLogDto);
|
||||
|
||||
/**
|
||||
* 设备执行日志,会保留历史记录
|
||||
|
||||
@@ -42,12 +42,12 @@ public class LuceneExecuteLogServiceImpl implements LuceneExecuteLogService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void interfaceExecuteLog(LuceneLogDto luceneLogDto) throws IOException {
|
||||
public void interfaceExecuteLog(LuceneLogDto luceneLogDto) {
|
||||
luceneLogDto.setLogType(LogTypeEnum.INTERFACE_LOG.getDesc());
|
||||
addIndex(luceneLogDto);
|
||||
}
|
||||
|
||||
private void addIndex(LuceneLogDto luceneLogDto) throws IOException {
|
||||
private void addIndex(LuceneLogDto luceneLogDto) {
|
||||
IndexWriter indexWriter = LuceneIndexWriter.getIndexWriter();
|
||||
//创建一个Document对象
|
||||
Document document = new Document();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
server:
|
||||
port: 8010
|
||||
port: 8011
|
||||
#配置数据源
|
||||
spring:
|
||||
datasource:
|
||||
|
||||
Reference in New Issue
Block a user