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