Merge branch 'master' of http://121.40.234.130:8899/root/rl_mg
This commit is contained in:
@@ -333,6 +333,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
|||||||
agv_message = conveyorPressStationDeviceDriver.getDevice_code() + message;
|
agv_message = conveyorPressStationDeviceDriver.getDevice_code() + message;
|
||||||
logService.deviceExecuteLog(device_code, "", "", message);
|
logService.deviceExecuteLog(device_code, "", "", message);
|
||||||
log.info("{},{}", device_code,message);
|
log.info("{},{}", device_code,message);
|
||||||
|
log.info("模式为{} 光电信号{} 取放信号{}",conveyorPressStationDeviceDriver.getMode(),conveyorPressStationDeviceDriver.getMove(),conveyorPressStationDeviceDriver.getIo_action());
|
||||||
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
|
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -585,6 +586,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
|||||||
agv_message = conveyorPressStationDeviceDriver.getDevice_code() + message;
|
agv_message = conveyorPressStationDeviceDriver.getDevice_code() + message;
|
||||||
logService.deviceExecuteLog(device_code, "", "", message);
|
logService.deviceExecuteLog(device_code, "", "", message);
|
||||||
log.info("{},{}", device_code,message);
|
log.info("{},{}", device_code,message);
|
||||||
|
log.info("模式为{} 光电信号{} 取放信号{}",conveyorPressStationDeviceDriver.getMode(),conveyorPressStationDeviceDriver.getMove(),conveyorPressStationDeviceDriver.getIo_action());
|
||||||
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
|
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -857,6 +859,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
|||||||
agv_message = conveyorPressStationDeviceDriver.getDevice_code() + message;
|
agv_message = conveyorPressStationDeviceDriver.getDevice_code() + message;
|
||||||
logService.deviceExecuteLog(device_code, "", "", message);
|
logService.deviceExecuteLog(device_code, "", "", message);
|
||||||
log.info("{},{}", device_code,message);
|
log.info("{},{}", device_code,message);
|
||||||
|
log.info("模式为{} 光电信号{} 取放信号{}",conveyorPressStationDeviceDriver.getMode(),conveyorPressStationDeviceDriver.getMove(),conveyorPressStationDeviceDriver.getIo_action());
|
||||||
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
|
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1114,6 +1117,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
|||||||
agv_message = conveyorPressStationDeviceDriver.getDevice_code() + message;
|
agv_message = conveyorPressStationDeviceDriver.getDevice_code() + message;
|
||||||
logService.deviceExecuteLog(device_code, "", "", message);
|
logService.deviceExecuteLog(device_code, "", "", message);
|
||||||
log.info("{},{}", device_code,message);
|
log.info("{},{}", device_code,message);
|
||||||
|
log.info("模式为{} 光电信号{} 取放信号{}",conveyorPressStationDeviceDriver.getMode(),conveyorPressStationDeviceDriver.getMove(),conveyorPressStationDeviceDriver.getIo_action());
|
||||||
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
|
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public interface OpcDeviceDriver extends DeviceDriver {
|
|||||||
|
|
||||||
//设备扩展表【acs_device_extra】
|
//设备扩展表【acs_device_extra】
|
||||||
WQLObject extraTab = WQLObject.getWQLObject("acs_device_extra");
|
WQLObject extraTab = WQLObject.getWQLObject("acs_device_extra");
|
||||||
JSONArray arr = extraTab.query("filed_type='02' and device_id = '" + this.getDevice().getDevice_id() + "'").getResultJSONArray(0);
|
JSONArray arr = extraTab.query(" (filed_type='02' or filed_type='03' )and device_id = '" + this.getDevice().getDevice_id() + "'").getResultJSONArray(0);
|
||||||
for (int i = 0; i < arr.size(); i++) {
|
for (int i = 0; i < arr.size(); i++) {
|
||||||
JSONObject json = arr.getJSONObject(i);
|
JSONObject json = arr.getJSONObject(i);
|
||||||
OpcItemDto dto = new OpcItemDto();
|
OpcItemDto dto = new OpcItemDto();
|
||||||
|
|||||||
@@ -458,6 +458,7 @@ public class ConveyorBarcodeDeviceDriver extends AbstractOpcDeviceDriver impleme
|
|||||||
jo.put("isOnline", isonline);
|
jo.put("isOnline", isonline);
|
||||||
jo.put("hasGoods", hasGoods);
|
jo.put("hasGoods", hasGoods);
|
||||||
jo.put("message", message);
|
jo.put("message", message);
|
||||||
|
jo.put("requireSucess",requireSucess);
|
||||||
return jo;
|
return jo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import org.nl.acs.opc.DeviceAppService;
|
|||||||
import org.nl.acs.order.service.ProduceshiftorderService;
|
import org.nl.acs.order.service.ProduceshiftorderService;
|
||||||
import org.nl.acs.route.service.RouteLineService;
|
import org.nl.acs.route.service.RouteLineService;
|
||||||
import org.nl.acs.task.service.TaskService;
|
import org.nl.acs.task.service.TaskService;
|
||||||
|
import org.nl.modules.lucene.enums.LogTypeEnum;
|
||||||
import org.nl.modules.lucene.service.LuceneExecuteLogService;
|
import org.nl.modules.lucene.service.LuceneExecuteLogService;
|
||||||
import org.nl.modules.lucene.service.dto.LuceneLogDto;
|
import org.nl.modules.lucene.service.dto.LuceneLogDto;
|
||||||
import org.nl.modules.wql.util.SpringContextHolder;
|
import org.nl.modules.wql.util.SpringContextHolder;
|
||||||
@@ -898,8 +899,15 @@ public class LnshPalletizingManipulatorSiteDeviceDriver extends AbstractOpcDevic
|
|||||||
|
|
||||||
ApplyTaskResponse resp = JSON.toJavaObject(JSONObject.parseObject(acsToWmsService.applyTask(request)),ApplyTaskResponse.class);
|
ApplyTaskResponse resp = JSON.toJavaObject(JSONObject.parseObject(acsToWmsService.applyTask(request)),ApplyTaskResponse.class);
|
||||||
message = RequestMethodEnum.getName("apply_take_full_vehicle") + "apply_take_full_vehicle 接口请求LMS...";
|
message = RequestMethodEnum.getName("apply_take_full_vehicle") + "apply_take_full_vehicle 接口请求LMS...";
|
||||||
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message + "参数:" + JSON.toJSONString(request)));
|
LuceneLogDto dto = new LuceneLogDto();
|
||||||
|
dto.setDevice_code(this.device_code);
|
||||||
|
dto.setLogType(LogTypeEnum.DEVICE_LOG.getDesc());
|
||||||
|
dto.setRemark(JSON.toJSONString(request));
|
||||||
|
lucene.deviceExecuteLog(dto);
|
||||||
|
// lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message + "参数:" + JSON.toJSONString(request)));
|
||||||
|
// log.info("{}",JSON.toJSONString(dto));
|
||||||
|
|
||||||
|
// log.info("{}",JSON.toJSONString(new LuceneLogDto(this.device_code, message + "参数:" + JSON.toJSONString(request))));
|
||||||
if (resp.getCode() == 200) {
|
if (resp.getCode() == 200) {
|
||||||
this.writing(200);
|
this.writing(200);
|
||||||
this.setRequireSucess(true);
|
this.setRequireSucess(true);
|
||||||
@@ -1200,7 +1208,6 @@ public class LnshPalletizingManipulatorSiteDeviceDriver extends AbstractOpcDevic
|
|||||||
ReadUtil.write(itemMap, server);
|
ReadUtil.write(itemMap, server);
|
||||||
ReadUtil.write(itemMap, server);
|
ReadUtil.write(itemMap, server);
|
||||||
server.disconnect();
|
server.disconnect();
|
||||||
logServer.deviceExecuteLog(this.device_code, "", "", "to_command 写入 " + command);
|
|
||||||
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, "to_command 写入 " + command));
|
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, "to_command 写入 " + command));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,19 +35,19 @@ public class LmsUtil {
|
|||||||
}
|
}
|
||||||
String liKu_wcs_url = paramService.findByCode("wmsurl").getValue();
|
String liKu_wcs_url = paramService.findByCode("wmsurl").getValue();
|
||||||
try {
|
try {
|
||||||
log.info("请求LMS参数:{}", JSON.toJSONString(requestParam));
|
// log.info("请求LMS参数:{}", JSON.toJSONString(requestParam));
|
||||||
String body = HttpRequest
|
String body = HttpRequest
|
||||||
.post(liKu_wcs_url + api).setConnectionTimeout(3000)
|
.post(liKu_wcs_url + api).setConnectionTimeout(3000)
|
||||||
.body(JSON.toJSONString(requestParam))
|
.body(JSON.toJSONString(requestParam))
|
||||||
.execute()
|
.execute()
|
||||||
.body();
|
.body();
|
||||||
log.info("请求LMS参数返回参数:{}", body);
|
// log.info("请求LMS参数返回参数:{}", body);
|
||||||
return body;
|
return body;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
JSONObject result = new JSONObject();
|
JSONObject result = new JSONObject();
|
||||||
result.put("code", "500");
|
result.put("code", "500");
|
||||||
result.put("message", e.getMessage());
|
result.put("message", e.getMessage());
|
||||||
log.info("请求LMS异常返回参数:{}", String.valueOf(result));
|
// log.info("请求LMS异常返回参数:{}", String.valueOf(result));
|
||||||
return String.valueOf(result);
|
return String.valueOf(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -276,14 +276,13 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
|||||||
resp.setMessage("请求成功");
|
resp.setMessage("请求成功");
|
||||||
log.info("createFromWms - 返回参数 {}", JSON.toJSON(resp));
|
log.info("createFromWms - 返回参数 {}", JSON.toJSON(resp));
|
||||||
|
|
||||||
// LuceneLogDto logDto = LuceneLogDto.builder()
|
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||||
// .device_code("LMSTOACS")
|
.requestparam(JSON.toJSON(resp).toString())
|
||||||
// .requestparam(JSON.toJSON(resp).toString())
|
.responseparam(JSON.toJSON(resp).toString())
|
||||||
// .responseparam(JSON.toJSON(resp).toString())
|
.status_code(String.valueOf(resp.getCode()))
|
||||||
// .status_code(String.valueOf(resp.getCode()))
|
.method(tasks.getRequest_medthod_code())
|
||||||
// .method(tasks.getRequest_medthod_code())
|
.build();
|
||||||
// .build();
|
lucene.interfaceExecuteLog(logDto);
|
||||||
// lucene.interfaceExecuteLog(logDto);
|
|
||||||
return (JSONObject) JSON.toJSON(resp);
|
return (JSONObject) JSON.toJSON(resp);
|
||||||
} finally {
|
} finally {
|
||||||
MDC.remove(log_file_type);
|
MDC.remove(log_file_type);
|
||||||
@@ -550,6 +549,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
|||||||
lnshSplitManipulatorDeviceDriver.writing(100);
|
lnshSplitManipulatorDeviceDriver.writing(100);
|
||||||
is_flag = true;
|
is_flag = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//下发成功后,写入工单信息表记录
|
//下发成功后,写入工单信息表记录
|
||||||
|
|
||||||
// ProduceshiftorderDto dto = new ProduceshiftorderDto();
|
// ProduceshiftorderDto dto = new ProduceshiftorderDto();
|
||||||
@@ -578,9 +578,14 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
|||||||
resp.setRequestNo(request_no);
|
resp.setRequestNo(request_no);
|
||||||
resp.setResponseDate(AgvUtil.getDate());
|
resp.setResponseDate(AgvUtil.getDate());
|
||||||
resp.setMessage("请求成功");
|
resp.setMessage("请求成功");
|
||||||
log.info("createOrder - 返回参数 {}", JSON.toJSON(resp));
|
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||||
|
.requestparam(JSON.toJSON(resp).toString())
|
||||||
|
.responseparam(JSON.toJSON(resp).toString())
|
||||||
|
.status_code(String.valueOf(resp.getCode()))
|
||||||
|
.method(orders.getRequest_medthod_code())
|
||||||
|
.build();
|
||||||
|
lucene.interfaceExecuteLog(logDto);
|
||||||
return (JSONObject) JSON.toJSON(resp);
|
return (JSONObject) JSON.toJSON(resp);
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
MDC.remove(log_file_type);
|
MDC.remove(log_file_type);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,12 @@ package org.nl.acs.opc;
|
|||||||
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 cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.nl.acs.udw.UnifiedDataAccessor;
|
import org.nl.acs.udw.UnifiedDataAccessor;
|
||||||
import org.nl.acs.udw.UnifiedDataAccessorFactory;
|
import org.nl.acs.udw.UnifiedDataAccessorFactory;
|
||||||
import org.nl.acs.udw.UnifiedDataAppService;
|
import org.nl.acs.udw.UnifiedDataAppService;
|
||||||
|
import org.nl.modules.lucene.enums.LogTypeEnum;
|
||||||
import org.nl.modules.lucene.service.LuceneExecuteLogService;
|
import org.nl.modules.lucene.service.LuceneExecuteLogService;
|
||||||
import org.nl.modules.lucene.service.dto.LuceneLogDto;
|
import org.nl.modules.lucene.service.dto.LuceneLogDto;
|
||||||
import org.nl.modules.wql.util.SpringContextHolder;
|
import org.nl.modules.wql.util.SpringContextHolder;
|
||||||
@@ -118,7 +120,7 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC
|
|||||||
try {
|
try {
|
||||||
Item item = group.addItem(string);
|
Item item = group.addItem(string);
|
||||||
itemsMap.put(string, item);
|
itemsMap.put(string, item);
|
||||||
log.trace("添加成功 {}", string);
|
// log.trace("添加成功 {}", string);
|
||||||
} catch (Exception var26) {
|
} catch (Exception var26) {
|
||||||
err_message.append(string + ":" + var26.getMessage());
|
err_message.append(string + ":" + var26.getMessage());
|
||||||
if (!is_error) {
|
if (!is_error) {
|
||||||
@@ -130,7 +132,7 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC
|
|||||||
String tag;
|
String tag;
|
||||||
if (is_error) {
|
if (is_error) {
|
||||||
tag = err_message.toString();
|
tag = err_message.toString();
|
||||||
log.warn("{}:{}", OpcConfig.resource_code, tag);
|
// log.warn("{}:{}", OpcConfig.resource_code, tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!OpcStartTag.is_run) {
|
if (!OpcStartTag.is_run) {
|
||||||
@@ -152,18 +154,18 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC
|
|||||||
while (DeviceOpcSynchronizeAutoRun.isRun) {
|
while (DeviceOpcSynchronizeAutoRun.isRun) {
|
||||||
long begin = System.currentTimeMillis();
|
long begin = System.currentTimeMillis();
|
||||||
if (log.isTraceEnabled()) {
|
if (log.isTraceEnabled()) {
|
||||||
log.trace("{} 开始记时{}", tag, DateUtil.now());
|
// log.trace("{} 开始记时{}", tag, DateUtil.now());
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<Item, ItemState> itemStatus = group.read(true, (Item[]) itemsMap.values().toArray(new Item[0]));
|
Map<Item, ItemState> itemStatus = group.read(true, (Item[]) itemsMap.values().toArray(new Item[0]));
|
||||||
long end = System.currentTimeMillis();
|
long end = System.currentTimeMillis();
|
||||||
long duration = end - begin;
|
long duration = end - begin;
|
||||||
if (log.isTraceEnabled()) {
|
if (log.isTraceEnabled()) {
|
||||||
log.trace("{} 读取耗时:{}", tag, duration);
|
// log.trace("{} 读取耗时:{}", tag, duration);
|
||||||
}
|
}
|
||||||
if (duration > 1000L) {
|
if (duration > 1000L) {
|
||||||
if (!time_out) {
|
if (!time_out) {
|
||||||
log.warn("{} 读取超时 : {}", tag, duration);
|
// log.warn("{} 读取超时 : {}", tag, duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
time_out = true;
|
time_out = true;
|
||||||
@@ -186,7 +188,7 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC
|
|||||||
String itemId = item.getId();
|
String itemId = item.getId();
|
||||||
Object his = accessor_value.getValue(itemId);
|
Object his = accessor_value.getValue(itemId);
|
||||||
if (!ObjectUtl.isEquals(itemState.getQuality(), QualityTypeValue.OPC_QUALITY_GOOD) && his != null) {
|
if (!ObjectUtl.isEquals(itemState.getQuality(), QualityTypeValue.OPC_QUALITY_GOOD) && his != null) {
|
||||||
log.warn("opc 值不健康 item: {}, 状态: {}", itemId, itemState.getQuality());
|
// log.warn("opc 值不健康 item: {}, 状态: {}", itemId, itemState.getQuality());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!UnifiedDataAppService.isEquals(value, his)) {
|
if (!UnifiedDataAppService.isEquals(value, his)) {
|
||||||
@@ -218,29 +220,28 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC
|
|||||||
if (log.isWarnEnabled()) {
|
if (log.isWarnEnabled()) {
|
||||||
log.warn("{} 所有内容都为空, all_null:{} ,暂定{}s", tag, all_null, 5000 + random);
|
log.warn("{} 所有内容都为空, all_null:{} ,暂定{}s", tag, all_null, 5000 + random);
|
||||||
}
|
}
|
||||||
|
ThreadUtl.sleep((long) ((new Random()).nextInt(3) + 1) * 1000);
|
||||||
ThreadUtl.sleep((long) (5000 + random));
|
break start;
|
||||||
} else if (this.all_null < 6) {
|
} else if (this.all_null < 6) {
|
||||||
if (log.isWarnEnabled()) {
|
if (log.isWarnEnabled()) {
|
||||||
log.warn(tag + "重新创建server");
|
log.warn(tag + "重新创建server");
|
||||||
log.warn("{} 所有内容都为空, all_null:{} ,暂定{}s", tag, all_null, 30000 + random);
|
log.warn("{} 所有内容都为空, all_null:{} ,暂定{}s", tag, all_null, 30000 + random);
|
||||||
}
|
}
|
||||||
// ThreadUtl.sleep((long) (30000 + random));
|
|
||||||
ThreadUtl.sleep((long) ((new Random()).nextInt(3) + 1) * 1000);
|
ThreadUtl.sleep((long) ((new Random()).nextInt(3) + 1) * 1000);
|
||||||
break start;
|
break start;
|
||||||
} else if (this.all_null < 12) {
|
} else if (this.all_null < 12) {
|
||||||
if (log.isWarnEnabled()) {
|
if (log.isWarnEnabled()) {
|
||||||
log.warn("{} 所有内容都为空, all_null:{} ,暂定{}ms", tag, all_null, '\uea60' + random);
|
// log.warn("{} 所有内容都为空, all_null:{} ,暂定{}ms", tag, all_null, '\uea60' + random);
|
||||||
}
|
}
|
||||||
|
ThreadUtl.sleep((long) ((new Random()).nextInt(3) + 1) * 1000);
|
||||||
|
break start;
|
||||||
|
|
||||||
ThreadUtl.sleep((long) ('\uea60' + random));
|
|
||||||
} else {
|
} else {
|
||||||
if (log.isWarnEnabled()) {
|
if (log.isWarnEnabled()) {
|
||||||
log.warn("{} 所有内容都为空, all_null:{} ,暂定{}ms", tag, all_null, 120000 + random);
|
// log.warn("{} 所有内容都为空, all_null:{} ,暂定{}ms", tag, all_null, 120000 + random);
|
||||||
}
|
}
|
||||||
|
// ThreadUtl.sleep((long) ((new Random()).nextInt(3) + 1) * 1000);
|
||||||
ThreadUtl.sleep((long) (120000 + random));
|
// break start;
|
||||||
|
|
||||||
}
|
}
|
||||||
++this.all_null;
|
++this.all_null;
|
||||||
} else {
|
} else {
|
||||||
@@ -351,7 +352,7 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC
|
|||||||
this.server = null;
|
this.server = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
log.warn("opc server {} {}", this.getOpcGroupID(), connected ? "connected" : "disconnected");
|
// log.warn("opc server {} {}", this.getOpcGroupID(), connected ? "connected" : "disconnected");
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getOpcGroupID() {
|
private String getOpcGroupID() {
|
||||||
@@ -381,7 +382,7 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC
|
|||||||
// } else if (log.isInfoEnabled()) {
|
// } else if (log.isInfoEnabled()) {
|
||||||
// log.info("Item {} new value: {}, Timestamp: {}, Quality: {}", new Object[]{itemId, itemState.getValue(), itemState.getTimestamp().getTime(), itemState.getQuality()});
|
// log.info("Item {} new value: {}, Timestamp: {}, Quality: {}", new Object[]{itemId, itemState.getValue(), itemState.getTimestamp().getTime(), itemState.getQuality()});
|
||||||
// }
|
// }
|
||||||
log.trace("Item {} new value: {}, Timestamp: {}", new Object[]{itemId, itemState.getValue(), itemState.getTimestamp().getTime()});
|
// log.trace("Item {} new value: {}, Timestamp: {}", new Object[]{itemId, itemState.getValue(), itemState.getTimestamp().getTime()});
|
||||||
|
|
||||||
OpcItemDto itemDto = this.getItem(itemId);
|
OpcItemDto itemDto = this.getItem(itemId);
|
||||||
// if (Boolean.TRUE.equals(itemDto.getNeed_log())) {
|
// if (Boolean.TRUE.equals(itemDto.getNeed_log())) {
|
||||||
@@ -397,6 +398,8 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC
|
|||||||
|
|
||||||
private void logItemChanged(String itemId, UnifiedDataAccessor accessor_value, Object value, OpcItemDto itemDto) {
|
private void logItemChanged(String itemId, UnifiedDataAccessor accessor_value, Object value, OpcItemDto itemDto) {
|
||||||
Object his = accessor_value.getValue(itemId);
|
Object his = accessor_value.getValue(itemId);
|
||||||
|
itemDto.setHis_item_value(his);
|
||||||
|
itemDto.setItem_value(value);
|
||||||
List<String> relate_items = itemDto.getRelate_items();
|
List<String> relate_items = itemDto.getRelate_items();
|
||||||
if (relate_items != null && !relate_items.isEmpty()) {
|
if (relate_items != null && !relate_items.isEmpty()) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
@@ -407,24 +410,22 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC
|
|||||||
Object obj = accessor_value.getValue(relate);
|
Object obj = accessor_value.getValue(relate);
|
||||||
sb.append("key:" + relate + "value:" + obj + ";");
|
sb.append("key:" + relate + "value:" + obj + ";");
|
||||||
}
|
}
|
||||||
log.info("设备:{}信号{}变更从{}->{};信号快照:{}", new Object[]{itemDto.getDevice_code(), itemId, his, value, sb});
|
|
||||||
// 存在上次点位值为null情况 则不记录日志
|
|
||||||
if (!itemDto.getItem_code().endsWith("heartbeat") && !itemDto.getItem_code().endsWith("time")) {
|
if (!itemDto.getItem_code().endsWith("heartbeat") && !itemDto.getItem_code().endsWith("time")) {
|
||||||
if((ObjectUtil.equal(his,"null") || ObjectUtil.isEmpty(his)) || (ObjectUtil.equal(value,"null") || ObjectUtil.isEmpty(value)) ){
|
// 存在上次点位值为null情况 则不记录日志
|
||||||
//lucene.deviceExecuteLog(new LuceneLogDto(itemDto.getOpc_server_code(), itemDto.getOpc_plc_code(), itemDto.getDevice_code(), itemDto.getItem_code().substring(itemDto.getItem_code().lastIndexOf(".") + 1), String.valueOf(his), String.valueOf(value)));
|
LuceneLogDto luceneLogDto = new LuceneLogDto(itemDto.getOpc_server_code(), itemDto.getOpc_plc_code(), itemDto.getDevice_code(), itemDto.getItem_code().substring(itemDto.getItem_code().lastIndexOf(".") + 1),
|
||||||
} else {
|
String.valueOf(itemDto.getHis_item_value()), String.valueOf(itemDto.getItem_value()));
|
||||||
lucene.deviceExecuteLog(new LuceneLogDto(itemDto.getOpc_server_code(), itemDto.getOpc_plc_code(), itemDto.getDevice_code(), itemDto.getItem_code().substring(itemDto.getItem_code().lastIndexOf(".") + 1), String.valueOf(his), String.valueOf(value)));
|
luceneLogDto.setLogType(LogTypeEnum.DEVICE_LOG.getDesc());
|
||||||
}
|
log.info("{}", JSON.toJSONString(luceneLogDto));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.info("设备:{}信号{}变更从{}->{};信号快照:{}", new Object[]{itemDto.getDevice_code(), itemId, his, value});
|
// log.info("设备:{}信号{}变更从{}->{};信号快照:{}", new Object[]{itemDto.getDevice_code(), itemId, his, value});
|
||||||
// 存在上次点位值为null情况 则不记录日志
|
// 存在上次点位值为null情况 则不记录日志
|
||||||
if (!itemDto.getItem_code().endsWith("heartbeat") && !itemDto.getItem_code().endsWith("time")) {
|
if (!itemDto.getItem_code().endsWith("heartbeat") && !itemDto.getItem_code().endsWith("time")) {
|
||||||
if((ObjectUtil.equal(his,"null") || ObjectUtil.isEmpty(his)) || (ObjectUtil.equal(value,"null") || ObjectUtil.isEmpty(value)) ){
|
LuceneLogDto luceneLogDto = new LuceneLogDto(itemDto.getOpc_server_code(), itemDto.getOpc_plc_code(), itemDto.getDevice_code(), itemDto.getItem_code().substring(itemDto.getItem_code().lastIndexOf(".") + 1),
|
||||||
//lucene.deviceExecuteLog(new LuceneLogDto(itemDto.getOpc_server_code(), itemDto.getOpc_plc_code(), itemDto.getDevice_code(), itemDto.getItem_code().substring(itemDto.getItem_code().lastIndexOf(".") + 1), String.valueOf(his), String.valueOf(value)));
|
String.valueOf(itemDto.getHis_item_value()), String.valueOf(itemDto.getItem_value()));
|
||||||
} else {
|
luceneLogDto.setLogType(LogTypeEnum.DEVICE_LOG.getDesc());
|
||||||
lucene.deviceExecuteLog(new LuceneLogDto(itemDto.getOpc_server_code(), itemDto.getOpc_plc_code(), itemDto.getDevice_code(), itemDto.getItem_code().substring(itemDto.getItem_code().lastIndexOf(".") + 1), String.valueOf(his), String.valueOf(value)));
|
log.info("{}", JSON.toJSONString(luceneLogDto));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ public class OpcItemDto {
|
|||||||
private String opc_plc_code;
|
private String opc_plc_code;
|
||||||
private String item_code;
|
private String item_code;
|
||||||
private Object item_value;
|
private Object item_value;
|
||||||
|
private Object his_item_value;
|
||||||
private Boolean need_log = Boolean.valueOf(false);
|
private Boolean need_log = Boolean.valueOf(false);
|
||||||
private List<String> relate_items = new ArrayList();
|
private List<String> relate_items = new ArrayList();
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package org.nl.modules.lucene.common;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: lyd
|
||||||
|
* @Description: 定义lucene相关常量
|
||||||
|
* @Date: 2023/8/25
|
||||||
|
*/
|
||||||
|
public class LogMessageConstant {
|
||||||
|
/** 级别 */
|
||||||
|
public final static String FIELD_LEVEL = "level";
|
||||||
|
/** 时间 */
|
||||||
|
public final static String FIELD_TIMESTAMP = "timestamp";
|
||||||
|
/** 类的限定名 */
|
||||||
|
public final static String FIELD_CLASS_NAME = "logger";
|
||||||
|
/** 线程名 */
|
||||||
|
public final static String FIELD_THREAD = "thread";
|
||||||
|
/** 日志内容 */
|
||||||
|
public final static String FIELD_MESSAGE = "message";
|
||||||
|
public final static String FIELD_TRACEID = "tlogTraceId";
|
||||||
|
// 定义颜色值
|
||||||
|
/** 文本颜色:黑色 */
|
||||||
|
public final static String COLOR_BLACK = "\u001B[30m";
|
||||||
|
/** 文本颜色:红色 */
|
||||||
|
public final static String COLOR_RED = "\u001B[31m";
|
||||||
|
/** 文本颜色:绿色 */
|
||||||
|
public final static String COLOR_GREEN = "\u001B[32m";
|
||||||
|
/** 文本颜色:黄色 */
|
||||||
|
public final static String COLOR_YELLOW = "\u001B[33m";
|
||||||
|
/** 文本颜色:蓝色 */
|
||||||
|
public final static String COLOR_BLUE = "\u001B[34m";
|
||||||
|
/** 文本颜色:品红色 */
|
||||||
|
public final static String COLOR_MAGENTA = "\u001B[35m";
|
||||||
|
/** 文本颜色:青色 */
|
||||||
|
public final static String COLOR_CYAN = "\u001B[36m";
|
||||||
|
/** 文本颜色:白色 */
|
||||||
|
public final static String COLOR_WHITE = "\u001B[37m";
|
||||||
|
/** 文本颜色重置 */
|
||||||
|
public final static String COLOR_RESET = "\u001B[0m";
|
||||||
|
/** 背景颜色:黄色 */
|
||||||
|
public final static String BACKGROUND_YELLOW = "\u001B[43m";
|
||||||
|
|
||||||
|
/** 索引路径 */
|
||||||
|
public final static String INDEX_DIR = "D:\\lucene\\index";
|
||||||
|
}
|
||||||
@@ -0,0 +1,123 @@
|
|||||||
|
package org.nl.modules.lucene.common;
|
||||||
|
/**
|
||||||
|
* @author ldjun
|
||||||
|
* @version 1.0
|
||||||
|
* @date 2023年08月24日 13:00
|
||||||
|
* @desc desc
|
||||||
|
*/
|
||||||
|
|
||||||
|
import ch.qos.logback.classic.spi.ILoggingEvent;
|
||||||
|
import ch.qos.logback.core.AppenderBase;
|
||||||
|
import cn.hutool.core.date.DateTime;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import org.apache.lucene.analysis.Analyzer;
|
||||||
|
import org.apache.lucene.document.*;
|
||||||
|
import org.apache.lucene.index.IndexWriter;
|
||||||
|
import org.apache.lucene.index.IndexWriterConfig;
|
||||||
|
import org.apache.lucene.store.Directory;
|
||||||
|
import org.apache.lucene.store.FSDirectory;
|
||||||
|
import org.nl.acs.opc.OpcItemDto;
|
||||||
|
import org.nl.modules.lucene.enums.LogTypeEnum;
|
||||||
|
import org.nl.modules.lucene.service.LuceneExecuteLogService;
|
||||||
|
import org.nl.modules.lucene.service.dto.LuceneLogDto;
|
||||||
|
import org.nl.modules.wql.util.SpringContextHolder;
|
||||||
|
import org.wltea.analyzer.lucene.IKAnalyzer;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class LuceneAppender extends AppenderBase<ILoggingEvent> {
|
||||||
|
|
||||||
|
private Directory index;
|
||||||
|
private IndexWriter indexWriter;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start() {
|
||||||
|
super.start();
|
||||||
|
try {
|
||||||
|
index = FSDirectory.open(Paths.get(LogMessageConstant.INDEX_DIR));
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化 Lucene 索引
|
||||||
|
Analyzer analyzer = new IKAnalyzer();
|
||||||
|
IndexWriterConfig config = new IndexWriterConfig(analyzer);
|
||||||
|
try {
|
||||||
|
indexWriter = new IndexWriter(index, config);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void append(ILoggingEvent event) {
|
||||||
|
String message = event.getFormattedMessage();
|
||||||
|
try {
|
||||||
|
LuceneLogDto luceneLogDto = JSONObject.parseObject(message, LuceneLogDto.class);
|
||||||
|
|
||||||
|
// LuceneLogDto luceneLogDto = new LuceneLogDto(itemDto.getOpc_server_code(), itemDto.getOpc_plc_code(), itemDto.getDevice_code(), itemDto.getItem_code().substring(itemDto.getItem_code().lastIndexOf(".") + 1),
|
||||||
|
// String.valueOf(itemDto.getHis_item_value()), String.valueOf(itemDto.getItem_value()));
|
||||||
|
// luceneLogDto.setLogType(LogTypeEnum.DEVICE_LOG.getDesc());
|
||||||
|
//IndexWriter indexWriter = LuceneIndexWriter.getIndexWriter();
|
||||||
|
//创建一个Document对象
|
||||||
|
Document document = new Document();
|
||||||
|
try {
|
||||||
|
//记录索引开始时间
|
||||||
|
long startTime = System.currentTimeMillis();
|
||||||
|
//向document对象中添加域。
|
||||||
|
if (ObjectUtil.isNotEmpty(luceneLogDto.getDevice_code())) {
|
||||||
|
document.add(new StringField("device_code", luceneLogDto.getDevice_code(), Field.Store.YES));
|
||||||
|
// document.add(new TextField("device_code", luceneLogDto.getDevice_code(), Field.Store.YES));
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotEmpty(luceneLogDto.getContent())) {
|
||||||
|
document.add(new StringField("fieldContent", luceneLogDto.getContent(), Field.Store.YES));
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotEmpty(luceneLogDto.getMethod())) {
|
||||||
|
document.add(new StringField("method", luceneLogDto.getMethod(), Field.Store.YES));
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotEmpty(luceneLogDto.getStatus_code())) {
|
||||||
|
document.add(new StringField("status_code", luceneLogDto.getStatus_code(), Field.Store.YES));
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotEmpty(luceneLogDto.getRequestparam())) {
|
||||||
|
document.add(new StringField("requestparam", luceneLogDto.getRequestparam(), Field.Store.YES));
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotEmpty(luceneLogDto.getResponseparam())) {
|
||||||
|
document.add(new StringField("responseparam", luceneLogDto.getResponseparam(), Field.Store.YES));
|
||||||
|
}
|
||||||
|
document.add(new StringField("logType", luceneLogDto.getLogType(), Field.Store.YES));
|
||||||
|
document.add(new StringField("logTime", DateUtil.format(new DateTime(), "yyyy-MM-dd HH:mm:ss.SSS"), Field.Store.YES));
|
||||||
|
document.add(new NumericDocValuesField("logTime",System.currentTimeMillis()));//排序
|
||||||
|
//记录索引结束时间
|
||||||
|
long endTime = System.currentTimeMillis();
|
||||||
|
// log.info("建立索引共耗时{}毫秒", endTime - startTime);
|
||||||
|
|
||||||
|
try {
|
||||||
|
indexWriter.addDocument(document);
|
||||||
|
indexWriter.commit();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (Exception e){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stop() {
|
||||||
|
super.stop();
|
||||||
|
try {
|
||||||
|
indexWriter.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,45 +16,45 @@ import java.text.SimpleDateFormat;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
public class LuceneIndexWriter {
|
public class LuceneIndexWriter {
|
||||||
private static IndexWriter indexWriter;
|
// private static IndexWriter indexWriter;
|
||||||
|
//
|
||||||
static {
|
// static {
|
||||||
try {
|
// try {
|
||||||
Directory directory = FSDirectory.open(new File(UrlConfig.luceneUrl).toPath());
|
// Directory directory = FSDirectory.open(new File(UrlConfig.luceneUrl).toPath());
|
||||||
IndexWriterConfig config = new IndexWriterConfig(new IKAnalyzer());
|
// IndexWriterConfig config = new IndexWriterConfig(new IKAnalyzer());
|
||||||
indexWriter = new IndexWriter(directory, config);
|
// indexWriter = new IndexWriter(directory, config);
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
}
|
// }
|
||||||
/**当当前线程结束时,自动关闭IndexWriter,使用Runtime对象*/
|
// /**当当前线程结束时,自动关闭IndexWriter,使用Runtime对象*/
|
||||||
Runtime.getRuntime().addShutdownHook(new Thread(){
|
// Runtime.getRuntime().addShutdownHook(new Thread(){
|
||||||
@Override
|
// @Override
|
||||||
public void run() {
|
// public void run() {
|
||||||
try {
|
// try {
|
||||||
closeIndexWriter();
|
// closeIndexWriter();
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
/**在线程结束时,自动关闭IndexWriter*/
|
// /**在线程结束时,自动关闭IndexWriter*/
|
||||||
public static IndexWriter getIndexWriter() {
|
// public static IndexWriter getIndexWriter() {
|
||||||
return indexWriter;
|
// return indexWriter;
|
||||||
}
|
// }
|
||||||
/**关闭IndexWriter
|
// /**关闭IndexWriter
|
||||||
* @throws IOException
|
// * @throws IOException
|
||||||
* @throws CorruptIndexException */
|
// * @throws CorruptIndexException */
|
||||||
public static void closeIndexWriter() throws Exception {
|
// public static void closeIndexWriter() throws Exception {
|
||||||
if(indexWriter != null) {
|
// if(indexWriter != null) {
|
||||||
indexWriter.close();
|
// indexWriter.close();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public static void main(String[] args) throws IOException {
|
// public static void main(String[] args) throws IOException {
|
||||||
indexWriter.deleteAll();
|
// indexWriter.deleteAll();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public static String getDate(String timeString) throws ParseException {
|
public static String getDate(String timeString) throws ParseException {
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX");//时间格式
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX");//时间格式
|
||||||
Date date = sdf.parse(timeString);
|
Date date = sdf.parse(timeString);
|
||||||
@@ -62,5 +62,4 @@ public class LuceneIndexWriter {
|
|||||||
return timeString;
|
return timeString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ public class Searcher {
|
|||||||
//构建IndexSearcher
|
//构建IndexSearcher
|
||||||
IndexSearcher searcher = new IndexSearcher(reader);
|
IndexSearcher searcher = new IndexSearcher(reader);
|
||||||
//标准分词器,会自动去掉空格啊,is a the等单词
|
//标准分词器,会自动去掉空格啊,is a the等单词
|
||||||
|
Analyzer analyzer = new IKAnalyzer(true);
|
||||||
// Analyzer analyzer = new StandardAnalyzer();
|
// Analyzer analyzer = new StandardAnalyzer();
|
||||||
// Analyzer analyzer = new IKAnalyzer(false);
|
// Analyzer analyzer = new IKAnalyzer(false);
|
||||||
//查询解析器
|
//查询解析器
|
||||||
@@ -49,7 +50,7 @@ public class Searcher {
|
|||||||
int start = pageNum * pageSize;// 当前页的起始条数
|
int start = pageNum * pageSize;// 当前页的起始条数
|
||||||
int end = start + pageSize;// 当前页的结束条数(不能包含)
|
int end = start + pageSize;// 当前页的结束条数(不能包含)
|
||||||
// 创建排序对象,需要排序字段SortField,参数:字段的名称、字段的类型、是否反转如果是false,升序。true降序
|
// 创建排序对象,需要排序字段SortField,参数:字段的名称、字段的类型、是否反转如果是false,升序。true降序
|
||||||
Sort sort = new Sort(new SortField("logTime", SortField.Type.DOC,true));
|
Sort sort = new Sort(new SortField("logTime", SortField.Type.LONG,true));
|
||||||
|
|
||||||
TopDocs docs = null;
|
TopDocs docs = null;
|
||||||
BooleanQuery.Builder booleanQueryBuilder = new BooleanQuery.Builder();
|
BooleanQuery.Builder booleanQueryBuilder = new BooleanQuery.Builder();
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package org.nl.modules.lucene.service.impl;
|
|||||||
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.JSON;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -35,57 +36,57 @@ public class LuceneExecuteLogServiceImpl implements LuceneExecuteLogService {
|
|||||||
String now = DateUtil.now();
|
String now = DateUtil.now();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SneakyThrows
|
|
||||||
@Override
|
@Override
|
||||||
public void deviceExecuteLog(LuceneLogDto luceneLogDto) {
|
public void deviceExecuteLog(LuceneLogDto luceneLogDto) {
|
||||||
luceneLogDto.setLogType(LogTypeEnum.DEVICE_LOG.getDesc());
|
luceneLogDto.setLogType(LogTypeEnum.DEVICE_LOG.getDesc());
|
||||||
addIndex(luceneLogDto);
|
log.info("{}", JSON.toJSONString(luceneLogDto));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void interfaceExecuteLog(LuceneLogDto luceneLogDto) {
|
public void interfaceExecuteLog(LuceneLogDto luceneLogDto) {
|
||||||
luceneLogDto.setLogType(LogTypeEnum.INTERFACE_LOG.getDesc());
|
luceneLogDto.setLogType(LogTypeEnum.INTERFACE_LOG.getDesc());
|
||||||
addIndex(luceneLogDto);
|
// addIndex(luceneLogDto);
|
||||||
|
log.info("{}", JSON.toJSONString(luceneLogDto));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addIndex(LuceneLogDto luceneLogDto) {
|
private void addIndex(LuceneLogDto luceneLogDto) {
|
||||||
IndexWriter indexWriter = LuceneIndexWriter.getIndexWriter();
|
// IndexWriter indexWriter = LuceneIndexWriter.getIndexWriter();
|
||||||
//创建一个Document对象
|
// //创建一个Document对象
|
||||||
Document document = new Document();
|
// Document document = new Document();
|
||||||
try {
|
// try {
|
||||||
//记录索引开始时间
|
// //记录索引开始时间
|
||||||
long startTime = System.currentTimeMillis();
|
// long startTime = System.currentTimeMillis();
|
||||||
//向document对象中添加域。
|
// //向document对象中添加域。
|
||||||
if (ObjectUtil.isNotEmpty(luceneLogDto.getDevice_code())) {
|
// if (ObjectUtil.isNotEmpty(luceneLogDto.getDevice_code())) {
|
||||||
document.add(new StringField("device_code", luceneLogDto.getDevice_code(), Field.Store.YES));
|
// document.add(new StringField("device_code", luceneLogDto.getDevice_code(), Field.Store.YES));
|
||||||
// document.add(new TextField("device_code", luceneLogDto.getDevice_code(), Field.Store.YES));
|
//// document.add(new TextField("device_code", luceneLogDto.getDevice_code(), Field.Store.YES));
|
||||||
}
|
// }
|
||||||
if (ObjectUtil.isNotEmpty(luceneLogDto.getContent())) {
|
// if (ObjectUtil.isNotEmpty(luceneLogDto.getContent())) {
|
||||||
document.add(new StringField("fieldContent", luceneLogDto.getContent(), Field.Store.YES));
|
// document.add(new StringField("fieldContent", luceneLogDto.getContent(), Field.Store.YES));
|
||||||
}
|
// }
|
||||||
if (ObjectUtil.isNotEmpty(luceneLogDto.getMethod())) {
|
// if (ObjectUtil.isNotEmpty(luceneLogDto.getMethod())) {
|
||||||
document.add(new StringField("method", luceneLogDto.getMethod(), Field.Store.YES));
|
// document.add(new StringField("method", luceneLogDto.getMethod(), Field.Store.YES));
|
||||||
}
|
// }
|
||||||
if (ObjectUtil.isNotEmpty(luceneLogDto.getStatus_code())) {
|
// if (ObjectUtil.isNotEmpty(luceneLogDto.getStatus_code())) {
|
||||||
document.add(new StringField("status_code", luceneLogDto.getStatus_code(), Field.Store.YES));
|
// document.add(new StringField("status_code", luceneLogDto.getStatus_code(), Field.Store.YES));
|
||||||
}
|
// }
|
||||||
if (ObjectUtil.isNotEmpty(luceneLogDto.getRequestparam())) {
|
// if (ObjectUtil.isNotEmpty(luceneLogDto.getRequestparam())) {
|
||||||
document.add(new StringField("requestparam", luceneLogDto.getRequestparam(), Field.Store.YES));
|
// document.add(new StringField("requestparam", luceneLogDto.getRequestparam(), Field.Store.YES));
|
||||||
}
|
// }
|
||||||
if (ObjectUtil.isNotEmpty(luceneLogDto.getResponseparam())) {
|
// if (ObjectUtil.isNotEmpty(luceneLogDto.getResponseparam())) {
|
||||||
document.add(new StringField("responseparam", luceneLogDto.getResponseparam(), Field.Store.YES));
|
// document.add(new StringField("responseparam", luceneLogDto.getResponseparam(), Field.Store.YES));
|
||||||
}
|
// }
|
||||||
document.add(new StringField("logType", luceneLogDto.getLogType(), Field.Store.YES));
|
// document.add(new StringField("logType", luceneLogDto.getLogType(), Field.Store.YES));
|
||||||
document.add(new StringField("logTime", DateUtil.format(new DateTime(), "yyyy-MM-dd HH:mm:ss.SSS"), Field.Store.YES));
|
// document.add(new StringField("logTime", DateUtil.format(new DateTime(), "yyyy-MM-dd HH:mm:ss.SSS"), Field.Store.YES));
|
||||||
indexWriter.addDocument(document);
|
// indexWriter.addDocument(document);
|
||||||
//记录索引结束时间
|
// //记录索引结束时间
|
||||||
long endTime = System.currentTimeMillis();
|
// long endTime = System.currentTimeMillis();
|
||||||
log.info("建立索引共耗时{}毫秒", endTime - startTime);
|
// log.info("建立索引共耗时{}毫秒", endTime - startTime);
|
||||||
indexWriter.commit();
|
// indexWriter.commit();
|
||||||
MDC.put("DEVICECODE", luceneLogDto.getDevice_code());
|
// MDC.put("DEVICECODE", luceneLogDto.getDevice_code());
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
// log.error(e.getMessage(), e);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ spring:
|
|||||||
druid:
|
druid:
|
||||||
db-type: com.alibaba.druid.pool.DruidDataSource
|
db-type: com.alibaba.druid.pool.DruidDataSource
|
||||||
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
|
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
|
||||||
url: jdbc:log4jdbc:mysql://${DB_HOST:10.93.41.198}:${DB_PORT:3306}/${DB_NAME:rl_mg_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
|
# url: jdbc:log4jdbc:mysql://${DB_HOST:10.93.41.198}:${DB_PORT:3306}/${DB_NAME:rl_mg_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
|
||||||
# url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.81.252}:${DB_PORT:3306}/${DB_NAME:rl_mg_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
|
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:rl_mg_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
|
||||||
username: ${DB_USER:root}
|
username: ${DB_USER:root}
|
||||||
password: ${DB_PWD:123456}
|
password: ${DB_PWD:123456}
|
||||||
# 初始连接数
|
# 初始连接数
|
||||||
@@ -127,7 +127,7 @@ file:
|
|||||||
avatarMaxSize: 5
|
avatarMaxSize: 5
|
||||||
logging:
|
logging:
|
||||||
file:
|
file:
|
||||||
path: C:\log\wms
|
path: C:\log\ACS
|
||||||
config: classpath:logback-spring.xml
|
config: classpath:logback-spring.xml
|
||||||
lucene:
|
lucene:
|
||||||
index:
|
index:
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ spring:
|
|||||||
druid:
|
druid:
|
||||||
db-type: com.alibaba.druid.pool.DruidDataSource
|
db-type: com.alibaba.druid.pool.DruidDataSource
|
||||||
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
|
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
|
||||||
url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.4.210}:${DB_PORT:3306}/${DB_NAME:acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
|
# url: jdbc:log4jdbc:mysql://${DB_HOST:10.93.41.198}:${DB_PORT:3306}/${DB_NAME:rl_mg_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
|
||||||
|
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:rl_mg_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
|
||||||
username: ${DB_USER:root}
|
username: ${DB_USER:root}
|
||||||
password: ${DB_PWD:123456}
|
password: ${DB_PWD:123456}
|
||||||
# 初始连接数
|
# 初始连接数
|
||||||
@@ -52,7 +53,7 @@ spring:
|
|||||||
multi-statement-allow: true
|
multi-statement-allow: true
|
||||||
redis:
|
redis:
|
||||||
#数据库索引
|
#数据库索引
|
||||||
database: ${REDIS_DB:2}
|
database: ${REDIS_DB:15}
|
||||||
host: ${REDIS_HOST:127.0.0.1}
|
host: ${REDIS_HOST:127.0.0.1}
|
||||||
port: ${REDIS_PORT:6379}
|
port: ${REDIS_PORT:6379}
|
||||||
password: ${REDIS_PWD:}
|
password: ${REDIS_PWD:}
|
||||||
@@ -126,7 +127,7 @@ file:
|
|||||||
avatarMaxSize: 5
|
avatarMaxSize: 5
|
||||||
logging:
|
logging:
|
||||||
file:
|
file:
|
||||||
path: D:\log\acs
|
path: C:\log\ACS
|
||||||
config: classpath:logback-spring.xml
|
config: classpath:logback-spring.xml
|
||||||
lucene:
|
lucene:
|
||||||
index:
|
index:
|
||||||
@@ -153,5 +154,5 @@ sa-token:
|
|||||||
token-prefix: Bearer
|
token-prefix: Bearer
|
||||||
|
|
||||||
loki:
|
loki:
|
||||||
url: http://192.168.4.210:3100/loki/api/v1
|
url: http://localhost:3100/loki/api/v1
|
||||||
systemName: acs
|
systemName: acs
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ spring:
|
|||||||
freemarker:
|
freemarker:
|
||||||
check-template-location: false
|
check-template-location: false
|
||||||
profiles:
|
profiles:
|
||||||
active: dev
|
active: prod
|
||||||
jackson:
|
jackson:
|
||||||
time-zone: GMT+8
|
time-zone: GMT+8
|
||||||
data:
|
data:
|
||||||
@@ -44,7 +44,7 @@ rsa:
|
|||||||
private_key: MIIBUwIBADANBgkqhkiG9w0BAQEFAASCAT0wggE5AgEAAkEA0vfvyTdGJkdbHkB8mp0f3FE0GYP3AYPaJF7jUd1M0XxFSE2ceK3k2kw20YvQ09NJKk+OMjWQl9WitG9pB6tSCQIDAQABAkA2SimBrWC2/wvauBuYqjCFwLvYiRYqZKThUS3MZlebXJiLB+Ue/gUifAAKIg1avttUZsHBHrop4qfJCwAI0+YRAiEA+W3NK/RaXtnRqmoUUkb59zsZUBLpvZgQPfj1MhyHDz0CIQDYhsAhPJ3mgS64NbUZmGWuuNKp5coY2GIj/zYDMJp6vQIgUueLFXv/eZ1ekgz2Oi67MNCk5jeTF2BurZqNLR3MSmUCIFT3Q6uHMtsB9Eha4u7hS31tj1UWE+D+ADzp59MGnoftAiBeHT7gDMuqeJHPL4b+kC+gzV4FGTfhR9q3tTbklZkD2A==
|
private_key: MIIBUwIBADANBgkqhkiG9w0BAQEFAASCAT0wggE5AgEAAkEA0vfvyTdGJkdbHkB8mp0f3FE0GYP3AYPaJF7jUd1M0XxFSE2ceK3k2kw20YvQ09NJKk+OMjWQl9WitG9pB6tSCQIDAQABAkA2SimBrWC2/wvauBuYqjCFwLvYiRYqZKThUS3MZlebXJiLB+Ue/gUifAAKIg1avttUZsHBHrop4qfJCwAI0+YRAiEA+W3NK/RaXtnRqmoUUkb59zsZUBLpvZgQPfj1MhyHDz0CIQDYhsAhPJ3mgS64NbUZmGWuuNKp5coY2GIj/zYDMJp6vQIgUueLFXv/eZ1ekgz2Oi67MNCk5jeTF2BurZqNLR3MSmUCIFT3Q6uHMtsB9Eha4u7hS31tj1UWE+D+ADzp59MGnoftAiBeHT7gDMuqeJHPL4b+kC+gzV4FGTfhR9q3tTbklZkD2A==
|
||||||
logging:
|
logging:
|
||||||
file:
|
file:
|
||||||
path: C:\log\wms
|
path: C:\log\ACS
|
||||||
config: classpath:logback-spring.xml
|
config: classpath:logback-spring.xml
|
||||||
# sa-token白名单配置
|
# sa-token白名单配置
|
||||||
security:
|
security:
|
||||||
|
|||||||
@@ -23,12 +23,19 @@
|
|||||||
|
|
||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
|
<appender name="luceneAppender" class="org.nl.modules.lucene.common.LuceneAppender" />
|
||||||
|
<appender name="asyncLuceneAppender" class="ch.qos.logback.classic.AsyncAppender">
|
||||||
|
<appender-ref ref="luceneAppender" />
|
||||||
|
<!-- 设置队列大小,根据您的需求调整 -->
|
||||||
|
<queueSize>512</queueSize>
|
||||||
|
</appender>
|
||||||
<!-- <logger name="org.nl.start.Init" level="info" additivity="false">
|
<!-- <logger name="org.nl.start.Init" level="info" additivity="false">
|
||||||
<appender-ref ref="FILE3"/>
|
<appender-ref ref="FILE3"/>
|
||||||
</logger>-->
|
</logger>-->
|
||||||
|
|
||||||
<!-- 打印sql -->
|
<!-- 打印sql -->
|
||||||
<logger name="org.nl.modules.lucene.service.impl.LuceneExecuteLogServiceImpl" level="info" additivity="false">
|
<logger name="org.nl.modules.lucene.service.impl.LuceneExecuteLogServiceImpl" level="info" additivity="true">
|
||||||
<appender-ref ref="FILE_LUCENE"/>
|
<appender-ref ref="FILE_LUCENE"/>
|
||||||
|
<appender-ref ref="asyncLuceneAppender"/>
|
||||||
</logger>
|
</logger>
|
||||||
</included>
|
</included>
|
||||||
|
|||||||
@@ -57,10 +57,17 @@ https://juejin.cn/post/6844903775631572999
|
|||||||
<!--异步到文件-->
|
<!--异步到文件-->
|
||||||
<appender name="asyncFileAppender" class="ch.qos.logback.classic.AsyncAppender">
|
<appender name="asyncFileAppender" class="ch.qos.logback.classic.AsyncAppender">
|
||||||
<discardingThreshold>0</discardingThreshold>
|
<discardingThreshold>0</discardingThreshold>
|
||||||
<queueSize>500</queueSize>
|
<queueSize>200</queueSize>
|
||||||
<appender-ref ref="FILE"/>
|
<appender-ref ref="FILE"/>
|
||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
|
<appender name="luceneAppender" class="org.nl.modules.lucene.common.LuceneAppender" />
|
||||||
|
<appender name="asyncLuceneAppender" class="ch.qos.logback.classic.AsyncAppender">
|
||||||
|
<appender-ref ref="luceneAppender" />
|
||||||
|
<!-- 设置队列大小,根据您的需求调整 -->
|
||||||
|
<queueSize>512</queueSize>
|
||||||
|
</appender>
|
||||||
|
|
||||||
<!--添加loki-->
|
<!--添加loki-->
|
||||||
<appender name="lokiAppender" class="com.github.loki4j.logback.Loki4jAppender">
|
<appender name="lokiAppender" class="com.github.loki4j.logback.Loki4jAppender">
|
||||||
<batchTimeoutMs>1000</batchTimeoutMs>
|
<batchTimeoutMs>1000</batchTimeoutMs>
|
||||||
@@ -85,10 +92,12 @@ https://juejin.cn/post/6844903775631572999
|
|||||||
<appender-ref ref="CONSOLE"/>
|
<appender-ref ref="CONSOLE"/>
|
||||||
<appender-ref ref="lokiAppender"/>
|
<appender-ref ref="lokiAppender"/>
|
||||||
<appender-ref ref="asyncFileAppender"/>
|
<appender-ref ref="asyncFileAppender"/>
|
||||||
|
<appender-ref ref="asyncLuceneAppender"/>
|
||||||
</root>
|
</root>
|
||||||
<!--logmanage -->
|
<!--logmanage -->
|
||||||
<logger name="org.nl.acs.log.service.impl.DeviceExecuteLogServiceImpl" level="info" additivity="false">
|
<logger name="org.nl.acs.log.service.impl.DeviceExecuteLogServiceImpl" level="info" additivity="false">
|
||||||
<appender-ref ref="lokiAppender" />
|
<appender-ref ref="lokiAppender" />
|
||||||
|
<appender-ref ref="asyncLuceneAppender"/>
|
||||||
</logger>
|
</logger>
|
||||||
<logger name="jdbc.resultsettable" level="ERROR" additivity="false">
|
<logger name="jdbc.resultsettable" level="ERROR" additivity="false">
|
||||||
<appender-ref ref="CONSOLE"/>
|
<appender-ref ref="CONSOLE"/>
|
||||||
@@ -137,10 +146,12 @@ https://juejin.cn/post/6844903775631572999
|
|||||||
<root level="info">
|
<root level="info">
|
||||||
<appender-ref ref="asyncFileAppender"/>
|
<appender-ref ref="asyncFileAppender"/>
|
||||||
<appender-ref ref="lokiAppender" />
|
<appender-ref ref="lokiAppender" />
|
||||||
|
<appender-ref ref="asyncLuceneAppender"/>
|
||||||
</root>
|
</root>
|
||||||
<logger name="org.nl.acs.log.service.impl.DeviceExecuteLogServiceImpl" level="info" additivity="false">
|
<logger name="org.nl.acs.log.service.impl.DeviceExecuteLogServiceImpl" level="info" additivity="false">
|
||||||
<appender-ref ref="asyncFileAppender"/>
|
<appender-ref ref="asyncFileAppender"/>
|
||||||
<appender-ref ref="lokiAppender" />
|
<appender-ref ref="lokiAppender" />
|
||||||
|
<appender-ref ref="asyncLuceneAppender"/>
|
||||||
</logger>
|
</logger>
|
||||||
<logger name="jdbc.resultsettable" level="ERROR" additivity="false">
|
<logger name="jdbc.resultsettable" level="ERROR" additivity="false">
|
||||||
<appender-ref ref="asyncFileAppender"/>
|
<appender-ref ref="asyncFileAppender"/>
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ https://juejin.cn/post/6844903775631572999
|
|||||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
<encoder>
|
<encoder>
|
||||||
<pattern>${log.pattern}</pattern>
|
<pattern>${log.pattern}</pattern>
|
||||||
<charset>${log.charset}</charset>
|
<!-- <charset>${log.charset}</charset>-->
|
||||||
</encoder>
|
</encoder>
|
||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
:visible.sync="visible"
|
:visible.sync="visible"
|
||||||
:modal-append-to-body="false"
|
:modal-append-to-body="false"
|
||||||
:append-to-body="true"
|
:append-to-body="true"
|
||||||
width="40%">
|
width="60%">
|
||||||
<div style="margin-top: 5px">
|
<div style="margin-top: 5px">
|
||||||
<el-descriptions class="margin-top" :column="3" border>
|
<el-descriptions class="margin-top" :column="3" border>
|
||||||
<el-descriptions-item>
|
<el-descriptions-item>
|
||||||
|
|||||||
Reference in New Issue
Block a user