fix: 日志ip地址
This commit is contained in:
@@ -32,6 +32,7 @@ import org.nl.common.utils.StringUtils;
|
||||
import org.nl.common.utils.ThrowableUtil;
|
||||
import org.nl.system.service.logging.ISysLogService;
|
||||
import org.nl.system.service.logging.dao.SysLog;
|
||||
import org.slf4j.MDC;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
@@ -85,8 +86,9 @@ public class LogAspect {
|
||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
HttpServletRequest request = attributes.getRequest();
|
||||
HttpServletResponse response = attributes.getResponse();
|
||||
|
||||
|
||||
// 将ip记录MDC,方便日志追寻
|
||||
String clientIP = request.getRemoteAddr();
|
||||
MDC.put("clientIP", clientIP);
|
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||
Method method = signature.getMethod();
|
||||
// 方法路径
|
||||
|
||||
@@ -65,12 +65,18 @@ public class LuceneAppender extends AppenderBase<ILoggingEvent> {
|
||||
Map<String, String> mdcPropertyMap = event.getMDCPropertyMap();
|
||||
Document doc = new Document();
|
||||
long timeStamp = event.getTimeStamp();
|
||||
|
||||
// 获取本机的IP地址
|
||||
String ipAddress = "-";
|
||||
try {
|
||||
ipAddress = InetAddress.getLocalHost().getHostAddress();
|
||||
} catch (UnknownHostException e) {
|
||||
throw new RuntimeException(e);
|
||||
String clientIpAddress = event.getMDCPropertyMap().get("clientIP");
|
||||
if (ObjectUtil.isNotEmpty(clientIpAddress)) {
|
||||
ipAddress = clientIpAddress;
|
||||
} else {
|
||||
try {
|
||||
ipAddress = InetAddress.getLocalHost().getHostAddress();
|
||||
} catch (UnknownHostException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
String formattedDateTime = DateUtil.format(new java.util.Date(timeStamp), "yyyy-MM-dd HH:mm:ss.SSS");
|
||||
doc.add(new LongPoint(LogMessageConstant.FIELD_SORT_NAME, timeStamp));
|
||||
|
||||
@@ -3,6 +3,7 @@ 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;
|
||||
@@ -56,19 +57,15 @@ public class Searcher {
|
||||
TopDocs docs = null;
|
||||
BooleanQuery.Builder booleanQueryBuilder = new BooleanQuery.Builder();
|
||||
//时间范围查询
|
||||
String startDate = whereJson.getString("begin_time");
|
||||
String endDate = whereJson.getString("end_time");
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(1970, 0, 1);
|
||||
if (startDate == null) {
|
||||
startDate = DateUtil.format(calendar.getTime(), "yyyy-MM-dd HH:mm:ss.SSS");
|
||||
} else {
|
||||
startDate = LuceneIndexWriter.getDate(startDate);
|
||||
}
|
||||
if (endDate == null) {
|
||||
endDate = DateUtil.format(new DateTime(), "yyyy-MM-dd HH:mm:ss.SSS");
|
||||
} else {
|
||||
endDate = LuceneIndexWriter.getDate(endDate);
|
||||
JSONArray createTime = whereJson.getJSONArray("createTime");
|
||||
String startDate = DateUtil.format(calendar.getTime(), "yyyy-MM-dd HH:mm:ss.SSS");
|
||||
String endDate = DateUtil.format(new DateTime(), "yyyy-MM-dd HH:mm:ss.SSS");
|
||||
|
||||
if (createTime != null) {
|
||||
startDate = createTime.getString(0);
|
||||
endDate = createTime.getString(1);
|
||||
}
|
||||
// 字段之间的与或非关系,MUST表示and,MUST_NOT表示not,SHOULD表示or,有几个fields就必须有几个clauses
|
||||
TermRangeQuery termRangeQuery = new TermRangeQuery("timestamp", new BytesRef(startDate),
|
||||
|
||||
@@ -720,6 +720,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
if (list.size() > 0) {
|
||||
PdmBdRequestMaterialRecord record = list.get(0);
|
||||
record.setIs_delete(true);
|
||||
record.setUsed_time(DateUtil.now());
|
||||
requestMaterialRecordService.updateById(record);
|
||||
}
|
||||
// 回传给mes系统
|
||||
|
||||
@@ -12,6 +12,15 @@ import java.io.Serializable;
|
||||
* @author lyd
|
||||
* @description /
|
||||
* @date 2023-07-05
|
||||
* 要料记录标识
|
||||
* 压机编号
|
||||
* 物料
|
||||
* 工单
|
||||
* 叫料时间
|
||||
* 是否上料完成
|
||||
* 上料时间
|
||||
* 是否删除
|
||||
* 下料时间
|
||||
**/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@@ -42,4 +51,6 @@ public class PdmBdRequestMaterialRecord implements Serializable {
|
||||
|
||||
private String update_time;
|
||||
|
||||
private String used_time;
|
||||
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ public class SchBasePointController {
|
||||
|
||||
@GetMapping
|
||||
@Log("查询点位管理")
|
||||
|
||||
//@SaCheckPermission("@el.check('schBasePoint:list')")
|
||||
public ResponseEntity<Object> query(SchBasePointQuery whereJson, PageQuery page) {
|
||||
return new ResponseEntity<>(TableDataInfo.build(schBasePointService.queryAll(whereJson, page)), HttpStatus.OK);
|
||||
|
||||
@@ -71,8 +71,8 @@ https://juejin.cn/post/6844903775631572999
|
||||
<!--开发环境:打印控制台-->
|
||||
<springProfile name="dev">
|
||||
<root level="DEBUG">
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
<appender-ref ref="asyncLuceneAppender"/>
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</root>
|
||||
<logger name="com.baomidou.mybatisplus.core.MybatisConfiguration" level="ERROR" additivity="false">
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
{{ scope.row.is_delete ? '是' : '否'}}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="used_time" label="下料时间" :min-width="flexWidth('used_time',crud.data,'叫料时间')"/>
|
||||
<el-table-column v-permission="[]" label="操作" width="120px" align="center" fixed="right">
|
||||
<template slot-scope="scope">
|
||||
<udOperation
|
||||
|
||||
Reference in New Issue
Block a user