diff --git a/acs/nladmin-system/pom.xml b/acs/nladmin-system/pom.xml index e02d8fb..f03c6c2 100644 --- a/acs/nladmin-system/pom.xml +++ b/acs/nladmin-system/pom.xml @@ -30,6 +30,7 @@ 5.9.0 1.9 + 8.2.0 @@ -406,6 +407,59 @@ UserAgentUtils 1.21 + + + + + org.apache.lucene + lucene-core + ${lucene.version} + + + org.apache.lucene + lucene-highlighter + ${lucene.version} + + + org.apache.lucene + lucene-analyzers-common + ${lucene.version} + + + com.github.magese + ik-analyzer + ${lucene.version} + + + + + org.apache.lucene + lucene-analyzers-smartcn + ${lucene.version} + + + + org.apache.lucene + lucene-queryparser + 8.2.0 + + + + org.springframework.boot + nladmin-system + 2.2.10.RELEASE + + + diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java b/acs/nladmin-system/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java index e1fa800..b8bb1dd 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java @@ -14,6 +14,8 @@ import org.nl.acs.instruction.service.impl.InstructionServiceImpl; import org.nl.acs.log.service.DeviceExecuteLogService; import org.nl.acs.opc.Device; import org.nl.acs.opc.DeviceAppService; +import org.nl.modules.lucence.service.LuceneExecuteLogService; +import org.nl.modules.lucence.service.dto.LuceneLogDto; import org.nl.modules.system.service.ParamService; import org.nl.modules.system.service.impl.ParamServiceImpl; import org.nl.modules.wql.util.SpringContextHolder; @@ -53,6 +55,8 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable { ParamService paramService; @Autowired AutoRunService autoRunService; + @Autowired + LuceneExecuteLogService luceneExecuteLogService; public OneNDCSocketConnectionAutoRun() { @@ -215,6 +219,10 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable { log.error("agv连接出现异常:{}", e); logServer.deviceExecuteLog("1", "", "", "agv异常" + e.getMessage()); logServer.deviceExecuteLog("1", "", "", "agv异常" + e); + LuceneLogDto logDto = new LuceneLogDto(); + logDto.setContent("agv异常" + e.getMessage()); + logDto.setDevice_code("1001"); + luceneExecuteLogService.deviceExecuteLog(logDto); if (ObjectUtil.isNotEmpty(s)) { s.close(); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/xg_agv/XgagvDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/xg_agv/XgagvDeviceDriver.java index d95bca2..c8049f7 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/xg_agv/XgagvDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/xg_agv/XgagvDeviceDriver.java @@ -18,6 +18,9 @@ import org.nl.acs.opc.Device; import org.nl.acs.opc.DeviceAppService; import org.nl.acs.route.service.RouteLineService; import org.nl.acs.task.service.TaskService; +import org.nl.modules.logging.DeviceCodeDir; +import org.nl.modules.lucence.service.LuceneExecuteLogService; +import org.nl.modules.lucence.service.dto.LuceneLogDto; import org.nl.modules.wql.util.SpringContextHolder; import org.openscada.opc.lib.da.Server; import org.springframework.beans.factory.annotation.Autowired; @@ -43,7 +46,8 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); @Autowired DeviceAppService deviceAppService = SpringContextHolder.getBean("deviceAppServiceImpl"); - + @Autowired + LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean("luceneExecuteLogServiceImpl");; //车辆ip 0-未知;1-需充电;2-可执行任务;3-充满电 String agv_mode = "0"; @@ -150,6 +154,16 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device drum_run_status = this.itemProtocol.getDrum_run_status(); stop = this.itemProtocol.getStop(); + if (home_relocation != last_home_relocation){ +// DeviceCodeDir deviceCodeDir = new DeviceCodeDir(); +// deviceCodeDir.setPropertyValue(this.device_code); +// log.info("信号{}变更从{}->{}",this.getDevice().getOpc_server_code()+"."+this.getDevice().getOpc_plc_code()+"."+this.device_code+"."+ItemProtocol.to_home_relocation,this.last_home_relocation,this.home_relocation); + LuceneLogDto logDto = new LuceneLogDto(); + logDto.setDevice_code(device_code); + logDto.setContent("信号"+this.getDevice().getOpc_server_code()+"."+this.getDevice().getOpc_plc_code()+"."+this.device_code+"."+ItemProtocol.to_home_relocation+"变更从"+this.last_home_relocation+"->"+this.home_relocation); + luceneExecuteLogService.deviceExecuteLog(logDto); +// last_home_relocation = home_relocation; + } //获取最小电量 if(ObjectUtil.isEmpty(this.getDevice().getExtraValue().get("min_electric"))){ diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_autodoor/ItemProtocol.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_autodoor/ItemProtocol.java new file mode 100644 index 0000000..6303cd7 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_autodoor/ItemProtocol.java @@ -0,0 +1,72 @@ +package org.nl.acs.device_driver.basedriver.standard_autodoor; + +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.device.device_driver.standard_inspect.ItemDto; + +import java.util.ArrayList; +import java.util.List; + +@Slf4j +public class ItemProtocol { + public static String item_heartbeat = "heartbeat"; + public static String item_mode = "mode"; + public static String item_action = "action"; + public static String item_error = "error"; + public static String item_to_command = "to_command"; + + + private StandardAutodoorDeviceDriver driver; + + public ItemProtocol(StandardAutodoorDeviceDriver driver) { + this.driver = driver; + } + + public int getHeartbeat() { + return this.getOpcIntegerValue(item_heartbeat); + } + + public int getMode() { + return this.getOpcIntegerValue(item_mode); + } + + public int getAction() { + return this.getOpcIntegerValue(item_action); + } + + public int getError() { + return this.getOpcIntegerValue(item_error); + } + + public int getToCommand() { + return this.getOpcIntegerValue(item_to_command); + } + + + public int getOpcIntegerValue(String protocol) { + Integer value = this.driver.getIntegeregerValue(protocol); + if (value == null) { + log.error("读取错误!"); + } else { + return value; + } + return 0; + + } + + public static List getReadableItemDtos() { + ArrayList list = new ArrayList(); + list.add(new ItemDto(item_heartbeat, "心跳", "DB51.B0")); + list.add(new ItemDto(item_mode, "工作状态", "DB51.B1", Boolean.valueOf(true))); + list.add(new ItemDto(item_action, "动作信号", "DB51.B2")); + list.add(new ItemDto(item_error, "报警信号", "DB51.B4")); + return list; + } + + public static List getWriteableItemDtos() { + ArrayList list = new ArrayList(); + list.add(new ItemDto(item_to_command, "作业命令", "DB52.W2", Boolean.valueOf(true))); + return list; + } + +} + diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_autodoor/StandardAutodoorDefination.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_autodoor/StandardAutodoorDefination.java new file mode 100644 index 0000000..0025bda --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_autodoor/StandardAutodoorDefination.java @@ -0,0 +1,71 @@ +package org.nl.acs.device_driver.basedriver.standard_autodoor; + +import org.nl.acs.device.device_driver.standard_inspect.ItemDto; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; +import org.nl.acs.opc.Device; +import org.nl.acs.opc.DeviceType; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; + +/** + * 自动门驱动定义 + */ +@Service +public class StandardAutodoorDefination implements OpcDeviceDriverDefination { + @Override + public String getDriverCode() { + return "standard_autodoor"; + } + + @Override + public String getDriverName() { + return "标准版-自动门"; + } + + @Override + public String getDriverDescription() { + return "标准版-自动门"; + } + + @Override + public DeviceDriver getDriverInstance(Device device) { + return (new StandardAutodoorDeviceDriver()).setDevice(device).setDriverDefination(this); + + } + + @Override + public Class getDeviceDriverType() { + return StandardAutodoorDeviceDriver.class; + } + + @Override + public List getFitDeviceTypes() { + List types = new LinkedList(); + types.add(DeviceType.conveyor); + return types; + } + + @Override + public List getReadableItemDtos() { + return getReadableItemDtos2(); + } + + public static List getReadableItemDtos2() { + List list = new ArrayList(); + list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB600.B0")); + list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB600.B1", true)); + list.add(new ItemDto(ItemProtocol.item_action, "动作信号", "DB600.B2")); + list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "DB600.B4")); + return list; + } + + @Override + public List getWriteableItemDtos() { + return ItemProtocol.getWriteableItemDtos(); + } + +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_autodoor/StandardAutodoorDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_autodoor/StandardAutodoorDeviceDriver.java new file mode 100644 index 0000000..8695c6a --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_autodoor/StandardAutodoorDeviceDriver.java @@ -0,0 +1,163 @@ +package org.nl.acs.device_driver.basedriver.standard_autodoor; + +import com.alibaba.fastjson.JSONObject; +import lombok.Data; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.device.device_driver.standard_inspect.ReadUtil; +import org.nl.acs.device.service.DeviceService; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; +import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; +import org.nl.acs.instruction.service.InstructionService; +import org.nl.acs.opc.Device; +import org.nl.acs.route.service.RouteLineService; +import org.nl.acs.task.service.TaskService; +import org.nl.modules.wql.util.SpringContextHolder; +import org.openscada.opc.lib.da.Server; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +/** + * 自动门驱动 + */ +@Slf4j +@Data +@RequiredArgsConstructor +public class StandardAutodoorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver { + protected ItemProtocol itemProtocol = new ItemProtocol(this); + @Autowired + InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); + @Autowired + DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); + @Autowired + RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); + @Autowired + TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); + String container; + String container_type_desc; + String last_container_type_desc; + String last_container; + //放货准备锁 + String putReadyLock = null; + //有货标记 + protected boolean has_goods_tag = false; + String devicecode; + int mode = 0; + int action = 0; + int error = 0; + Boolean iserror = false; + + int move = 0; + int task = 0; + int last_action = 0; + int last_mode = 0; + int last_error = 0; + int last_move = 0; + int last_task = 0; + + boolean hasVehicle = false; + boolean isReady = false; + protected int instruction_num = 0; + protected int instruction_num_truth = 0; + protected boolean hasGoods = false; + boolean isFold = false; + private String assemble_check_tag; + private Boolean sampleMode0; + private Boolean sampleMode3; + private Integer sampleError; + private Boolean sampleOnline; + protected String displayMessage = null; + public int display_message_time_out = 30000; + public Date display_message_time; + protected String current_stage_instruction_message; + protected String last_stage_instruction_message; + Integer heartbeat_tag; + private Date instruction_require_time = new Date(); + private Date instruction_finished_time = new Date(); + + private int instruction_require_time_out; + boolean requireSucess = false; + + private int instruction_finished_time_out; + + int branchProtocol = 0; + + @Override + public Device getDevice() { + return this.device; + } + + + @Override + public void execute() { + String message = null; + + String device_code = this.getDevice().getDevice_code(); + mode = this.itemProtocol.getMode(); + action = this.itemProtocol.getAction(); + error = this.itemProtocol.getError(); + if (mode != last_mode) { + } + if (action != last_action) { + } + if (error != last_error) { + //this.execute_log.setContainer(""); + } + last_action = action; + last_mode = mode; + last_error = error; + //message = StringFormatUtl.format("设备报警:{}", new Object[]{}); + +// String manual_create_task = this.getDevice().getExtraValue().get("manual_create_task").toString(); + + } + + public synchronized String getStatus() { + JSONObject jo = new JSONObject(); + + if (action == 1) { + jo.put("name", this.getDevice().getDevice_code()); + jo.put("status", "OPEN"); + + } else if (action == 2) { + jo.put("name", this.getDevice().getDevice_code()); + jo.put("status", "CLOSE"); + + } else { + jo.put("name", this.getDevice().getDevice_code()); + jo.put("status", "ERROR"); + } + return jo.toString(); + } + + + public void writeing(int command) { + String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + ItemProtocol.item_to_command; + + String opcservcerid = this.getDevice().getOpc_server_id(); + Server server = ReadUtil.getServer(opcservcerid); + Map itemMap = new HashMap(); + itemMap.put(to_command, command); + ReadUtil.write(itemMap, server); + log.info("下发PLC信号:{},{}", to_command, command); + System.out.println("设备:" + devicecode + ",下发PLC信号:" + to_command + ",value:" + command); + + } + + public synchronized void OpenOrClose(String type) { + + //开门 + if ("1".equals(type)) { + writeing(1); + } else { + writeing(2); + } + + } + +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/log/LokiLogAspect.java b/acs/nladmin-system/src/main/java/org/nl/acs/log/LokiLogAspect.java index 7caa9b5..8062e2f 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/log/LokiLogAspect.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/log/LokiLogAspect.java @@ -47,7 +47,7 @@ public class LokiLogAspect { Method method = methodSignature.getMethod(); LokiLog lokiLog = method.getAnnotation(LokiLog.class); // 获取描述信息 - LokiLogType logType = lokiLog.type(); + LokiLogType logType = lokiLog.type(); MDC.put("log_file_type", logType.getDesc()); log.info("输入参数:" + JSONObject.toJSONString(pjp.getArgs())); diff --git a/acs/nladmin-system/src/main/java/org/nl/modules/logging/DeviceCodeDir.java b/acs/nladmin-system/src/main/java/org/nl/modules/logging/DeviceCodeDir.java new file mode 100644 index 0000000..d862214 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/modules/logging/DeviceCodeDir.java @@ -0,0 +1,23 @@ +package org.nl.modules.logging; + +import ch.qos.logback.core.PropertyDefinerBase; +import org.springframework.stereotype.Component; + +// 通过实现logback的PropertyDefinerBase方法,动态定义logback配置中的变量 +@Component +public class DeviceCodeDir extends PropertyDefinerBase { + + String deviceCodeDir = ""; + public void setPropertyValue(String deviceCode) { + deviceCodeDir = deviceCode ; + } + + @Override + public String getPropertyValue() { + if (deviceCodeDir == ""){ + deviceCodeDir = "默认"; + } + return "默认"; + } + +} diff --git a/acs/nladmin-system/src/main/java/org/nl/modules/lucence/common/Indexer.java b/acs/nladmin-system/src/main/java/org/nl/modules/lucence/common/Indexer.java new file mode 100644 index 0000000..6ec30a1 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/modules/lucence/common/Indexer.java @@ -0,0 +1,181 @@ +package org.nl.modules.lucence.common; + +import com.alibaba.fastjson.JSONObject; +import org.apache.commons.io.FileUtils; +import org.apache.lucene.analysis.Analyzer; +import org.apache.lucene.analysis.TokenStream; +import org.apache.lucene.analysis.standard.StandardAnalyzer; +import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; +import org.apache.lucene.document.Document; +import org.apache.lucene.document.Field; +import org.apache.lucene.document.StoredField; +import org.apache.lucene.document.TextField; +import org.apache.lucene.index.CodecReader; +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.springframework.beans.factory.annotation.Value; +import org.wltea.analyzer.core.IKSegmenter; +import org.wltea.analyzer.lucene.IKAnalyzer; + +import java.io.*; +import java.nio.file.Paths; +import java.util.Set; + +/** + * lucene索引器 + */ +public class Indexer { + /** + * 写索引实例 + */ + private IndexWriter writer; + + public IndexWriter getWriter() { + return writer; + } + + /** + * 构造方法,实例化IndexWriter + * @param indexDir + * @throws Exception + */ + public Indexer(String indexDir) throws Exception { + Directory dir = FSDirectory.open(Paths.get(indexDir)); + //标准分词器,会自动去掉空格啊,is a the等单词 +// Analyzer analyzer = new StandardAnalyzer(); + Analyzer analyzer = new IKAnalyzer(); + //将标准分词器配到写索引的配置中 + IndexWriterConfig config = new IndexWriterConfig(analyzer); + //实例化写索引对象 + writer = new IndexWriter(dir, config); + } + + /** + * 索引指定目录下的所有文件 + * @param dataDir + * @return + * @throws Exception + */ + public int indexAll(String dataDir) throws Exception { + // 获取该路径下的所有文件 + File[] files = new File(dataDir).listFiles(); + if (null != files) { + for (File file : files) { + //调用下面的indexFile方法,对每个文件进行索引 + indexFile(file); + } + } + //返回索引的文件数 +// return writer.numDocs(); + return writer.numRamDocs(); + } + + /** + * 索引指定的文件 + * @param file + * @throws Exception + */ + private void indexFile(File file) throws Exception { + System.out.println("索引文件的路径:" + file.getCanonicalPath()); + //调用下面的getDocument方法,获取该文件的document + Document doc = getDocument(file); + //添加索引文档 + //Document doc = json2Doc(jsonDoc); +// Document doc = new Document(); +// doc.add(new TextField("content", jsonDoc, Field.Store.YES)); + Field fieldContent=new TextField("fieldContent", FileUtils.readFileToString(null,"UTF-8"), Field.Store.YES); + + //将doc添加到索引中 + writer.addDocument(doc); + } + + /** + * 获取文档,文档里再设置每个字段,就类似于数据库中的一行记录 + * @param file + * @return + * @throws Exception + */ + private Document getDocument(File file) throws Exception { + Document doc = new Document(); + //开始添加字段 + //添加内容 + doc.add(new TextField("contents", new FileReader(file))); + //添加文件名,并把这个字段存到索引文件里 + doc.add(new TextField("fileName", file.getName(), Field.Store.YES)); + //添加文件路径 + doc.add(new TextField("fullPath", file.getCanonicalPath(), Field.Store.YES)); + return doc; + } + public Document json2Doc(String strDoc) { + Document doc = new Document(); + JSONObject jsonDoc = JSONObject.parseObject(strDoc); + Set keys = jsonDoc.keySet(); + for (String key : keys) { + doc.add(new TextField(key, jsonDoc.getString(key), Field.Store.YES)); + } + return doc; + } + + public void addLogIndex(String msg) throws IOException { + //步骤一:创建Directory对象,用于指定索引库的位置 RAMDirectory内存 + Directory directory = FSDirectory.open(new File("D:\\lucene\\index").toPath()); + //步骤二:创建一个IndexWriter对象,用于写索引 +// Analyzer analyzer = new StandardAnalyzer(); + IndexWriter indexWriter=new IndexWriter(directory,new IndexWriterConfig(new IKAnalyzer(false))); +// indexWriter.deleteAll();//清理所有索引库 +// IndexWriter indexWriter=new IndexWriter(directory,new IndexWriterConfig(new StandardAnalyzer())); + //记录索引开始时间 + long startTime = System.currentTimeMillis(); + //步骤三:读取磁盘中文件,对应每一个文件创建一个文档对象 + Document document = new Document(); +// document.add(new TextField("fieldContent", device_id, Field.Store.YES)); + document.add(new TextField("fieldContent", msg, Field.Store.YES)); + indexWriter.addDocument(document); + //记录索引结束时间 + long endTime = System.currentTimeMillis(); + System.out.println("建立索引"+ "共耗时" + (endTime-startTime) + "毫秒"); + indexWriter.commit(); + //步骤八:关闭资源 + indexWriter.close(); + System.out.println("建立索引成功-----关闭资源"); + } + //系统的日志文件路径 + @Value("${logging.file.path}") + private String logUrl; + + public static void main(String[] args)throws IOException { + //步骤一:创建Directory对象,用于指定索引库的位置 RAMDirectory内存 + Directory directory = FSDirectory.open(new File("D:\\lucene\\index").toPath()); + //步骤二:创建一个IndexWriter对象,用于写索引 +// Analyzer analyzer = new StandardAnalyzer(); + IndexWriter indexWriter=new IndexWriter(directory,new IndexWriterConfig(new IKAnalyzer(false))); + + indexWriter.deleteAll();//清理所有索引库 +// IndexWriter indexWriter=new IndexWriter(directory,new IndexWriterConfig(new StandardAnalyzer())); + //记录索引开始时间 + long startTime = System.currentTimeMillis(); + //步骤三:读取磁盘中文件,对应每一个文件创建一个文档对象 + File file=new File("D:\\testlog"); + //步骤四:获取文件列表 + File[] files = file.listFiles(); + for (File item:files) { + BufferedReader bufferedReader = new BufferedReader(new FileReader(item)); + String strLine = null; + while(null != (strLine = bufferedReader.readLine())){ + Document document = new Document(); +// document.add(new Field()); + document.add(new TextField("fieldContent", strLine, Field.Store.YES)); + indexWriter.addDocument(document); + } + } + //记录索引结束时间 + long endTime = System.currentTimeMillis(); + System.out.println("建立索引"+ "共耗时" + (endTime-startTime) + "毫秒"); + indexWriter.commit(); + //步骤八:关闭资源 + indexWriter.close(); + System.out.println("建立索引成功-----关闭资源"); + } +} diff --git a/acs/nladmin-system/src/main/java/org/nl/modules/lucence/common/LuceneIndexWriter.java b/acs/nladmin-system/src/main/java/org/nl/modules/lucence/common/LuceneIndexWriter.java new file mode 100644 index 0000000..62d81cc --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/modules/lucence/common/LuceneIndexWriter.java @@ -0,0 +1,68 @@ +package org.nl.modules.lucence.common; + +import cn.hutool.core.date.DateUtil; +import org.apache.lucene.index.CorruptIndexException; +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.modules.lucence.config.UrlConfig; +import org.springframework.beans.factory.annotation.Value; +import org.wltea.analyzer.lucene.IKAnalyzer; + +import javax.annotation.PostConstruct; +import java.io.File; +import java.io.IOException; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +public class LuceneIndexWriter { + private static IndexWriter indexWriter; + + static { + try { + Directory directory = FSDirectory.open(new File(UrlConfig.luceneUrl).toPath()); + IndexWriterConfig config = new IndexWriterConfig(new IKAnalyzer()); + indexWriter = new IndexWriter(directory, config); + } catch (Exception e) { + e.printStackTrace(); + } + /**当当前线程结束时,自动关闭IndexWriter,使用Runtime对象*/ + Runtime.getRuntime().addShutdownHook(new Thread(){ + @Override + public void run() { + try { + closeIndexWriter(); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } + /**在线程结束时,自动关闭IndexWriter*/ + public static IndexWriter getIndexWriter() { + return indexWriter; + } + /**关闭IndexWriter + * @throws IOException + * @throws CorruptIndexException */ + public static void closeIndexWriter() throws Exception { + if(indexWriter != null) { + indexWriter.close(); + } + } + + public static String getDate(String timeString) throws ParseException { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX");//时间格式 + Date date = sdf.parse(timeString); + timeString = DateUtil.format(date, "yyyy-MM-dd HH:mm:ss.SSS");//格式化后的时间 + return timeString; + } + + public static void main(String[] args) throws IOException { + indexWriter.deleteAll(); + } + + +} diff --git a/acs/nladmin-system/src/main/java/org/nl/modules/lucence/common/Searcher.java b/acs/nladmin-system/src/main/java/org/nl/modules/lucence/common/Searcher.java new file mode 100644 index 0000000..27d76e3 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/modules/lucence/common/Searcher.java @@ -0,0 +1,129 @@ +package org.nl.modules.lucence.common; + +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUtil; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import org.apache.lucene.analysis.Analyzer; +import org.apache.lucene.document.Document; +import org.apache.lucene.index.DirectoryReader; +import org.apache.lucene.index.IndexReader; +import org.apache.lucene.index.Term; +import org.apache.lucene.util.BytesRef; +import org.nl.modules.lucence.common.LuceneIndexWriter; +import org.apache.lucene.queryparser.classic.QueryParser; +import org.apache.lucene.search.*; +import org.apache.lucene.store.Directory; +import org.apache.lucene.store.FSDirectory; +import org.wltea.analyzer.lucene.IKAnalyzer; + +import java.nio.file.Paths; +import java.util.*; + +/** + * lucene查询器 + */ +public class Searcher { + + public static Map search(String indexDir, String ext,Map whereJson) throws Exception { + //获取要查询的路径,也就是索引所在的位置 + Directory dir = FSDirectory.open(Paths.get(indexDir)); + IndexReader reader = DirectoryReader.open(dir); + //构建IndexSearcher + IndexSearcher searcher = new IndexSearcher(reader); + //标准分词器,会自动去掉空格啊,is a the等单词 +// Analyzer analyzer = new StandardAnalyzer(); + Analyzer analyzer = new IKAnalyzer(false); + //查询解析器 + QueryParser queryParser = new QueryParser("fieldContent", analyzer); + + //记录索引开始时间 + long startTime = System.currentTimeMillis(); + // 实际上Lucene本身不支持分页。因此我们需要自己进行逻辑分页。我们要准备分页参数: + int pageSize = Integer.parseInt(whereJson.get("size").toString());// 每页条数 + int pageNum = Integer.parseInt(whereJson.get("page").toString());// 当前页码 + int start = pageNum * pageSize;// 当前页的起始条数 + int end = start + pageSize;// 当前页的结束条数(不能包含) + // 创建排序对象,需要排序字段SortField,参数:字段的名称、字段的类型、是否反转如果是false,升序。true降序 + Sort sort = new Sort(new SortField("logTime", SortField.Type.DOC,true)); + + TopDocs docs = null; + //通过解析要查询的String,获取查询对象,q为传进来的待查的字符串 + String queryString = ""; + BooleanQuery.Builder booleanQueryBuilder = new BooleanQuery.Builder(); + //时间范围查询 + String startDate = (String) whereJson.get("begin_time"); + String endDate = (String) whereJson.get("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); + } + TermRangeQuery termRangeQuery = new TermRangeQuery("logTime", new BytesRef(startDate), new BytesRef(endDate), true, true); + booleanQueryBuilder.add(termRangeQuery,BooleanClause.Occur.MUST); + //日志类型 + if (whereJson.get("blurry") != null) queryString += "+fieldContent:"+(String) whereJson.get("blurry"); + if (whereJson.get("device_code") != null) queryString += " +device_code:"+(String) whereJson.get("device_code"); + if (whereJson.get("device_code") == null && whereJson.get("blurry") == null) { + WildcardQuery query=new WildcardQuery(new Term("fieldContent","*")); + booleanQueryBuilder.add(query, BooleanClause.Occur.MUST); + docs = searcher.search(booleanQueryBuilder.build(), end,sort); + }else { + Query query = queryParser.parse(queryString); + booleanQueryBuilder.add(query, BooleanClause.Occur.MUST); + docs = searcher.search(booleanQueryBuilder.build(), end,sort); + } + + //记录索引结束时间 + long endTime = System.currentTimeMillis(); + System.out.println("匹配" + queryString + "共耗时" + (endTime-startTime) + "毫秒"); + System.out.println("查询到" + docs.totalHits.value + "条日志文件"); + //取出每条查询结果 + List list = new ArrayList<>(); + //取出每条查询结果 + ScoreDoc[] scoreDocs = docs.scoreDocs; + if (end > docs.totalHits.value) end = (int) docs.totalHits.value; + JSONArray array = new JSONArray(); + JSONObject object = new JSONObject(); + for (int i = start; i < end; i++) { + ScoreDoc scoreDoc = scoreDocs[i]; + Document doc = reader.document(scoreDoc.doc); + object.put("content",doc.get("fieldContent")); + object.put("device_code",doc.get("device_code")); + object.put("logTime",doc.get("logTime")); + if(doc.get("fieldContent") != null) { + array.add(object); + } + } +// System.out.println("查询到" + array.size() + "条记录"); + for(Object logDto:array){ + String st = logDto.toString(); + System.out.println(st); + } + + reader.close(); + JSONObject jo = new JSONObject(); + jo.put("content", array); + jo.put("totalElements", docs.totalHits.value); + return jo; + } + + public static void main(String[] args) { + String indexDir = "D:\\lucene\\index"; + //查询这个字符串 + String q = "07.832"; + Map whereJson = null; + try { + search(indexDir, q,whereJson); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/acs/nladmin-system/src/main/java/org/nl/modules/lucence/config/StaticConfig.java b/acs/nladmin-system/src/main/java/org/nl/modules/lucence/config/StaticConfig.java new file mode 100644 index 0000000..19b9245 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/modules/lucence/config/StaticConfig.java @@ -0,0 +1,22 @@ +package org.nl.modules.lucence.config; + +import org.nl.modules.lucence.common.LuceneIndexWriter; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * @deprecated 设置静态参数初始化 + */ +@Configuration +public class StaticConfig { + //日志索引目录 + @Value("${lucene.index.path}") + private String luceneDir; + + @Bean + public int initStatic() { + UrlConfig.setLuceneUrl(luceneDir); + return 0; + } +} diff --git a/acs/nladmin-system/src/main/java/org/nl/modules/lucence/config/UrlConfig.java b/acs/nladmin-system/src/main/java/org/nl/modules/lucence/config/UrlConfig.java new file mode 100644 index 0000000..e15b3e6 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/modules/lucence/config/UrlConfig.java @@ -0,0 +1,13 @@ +package org.nl.modules.lucence.config; + +public class UrlConfig { + public static String luceneUrl; + + public static String getLuceneUrl() { + return luceneUrl; + } + + public static void setLuceneUrl(String luceneUrl) { + UrlConfig.luceneUrl = luceneUrl; + } +} diff --git a/acs/nladmin-system/src/main/java/org/nl/modules/lucence/rest/LuceneController.java b/acs/nladmin-system/src/main/java/org/nl/modules/lucence/rest/LuceneController.java new file mode 100644 index 0000000..5fc6983 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/modules/lucence/rest/LuceneController.java @@ -0,0 +1,39 @@ +package org.nl.modules.lucence.rest; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.nl.modules.logging.annotation.Log; +import org.nl.modules.lucence.service.LuceneService; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; +import java.util.Map; + + +@RestController +@RequiredArgsConstructor +@Api(tags = "日志检索") +@RequestMapping("/api/lucene") +@Slf4j +public class LuceneController { + + private final LuceneService luceneService; + + @GetMapping("/labels/values") + @ApiOperation("获取标签") + public ResponseEntity labelsValues() { + return new ResponseEntity<>(luceneService.getLabelsValues(), HttpStatus.OK); + } + + + @GetMapping("/getAll") + @Log("日志检索") + @ApiOperation("日志检索") + //@PreAuthorize("@el.check('task:list')") + public ResponseEntity get(@RequestParam Map whereJson, Pageable page) { + return new ResponseEntity<>(luceneService.getAll(whereJson, page), HttpStatus.OK); + } +} diff --git a/acs/nladmin-system/src/main/java/org/nl/modules/lucence/service/LuceneExecuteLogService.java b/acs/nladmin-system/src/main/java/org/nl/modules/lucence/service/LuceneExecuteLogService.java new file mode 100644 index 0000000..19b2dfa --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/modules/lucence/service/LuceneExecuteLogService.java @@ -0,0 +1,39 @@ +package org.nl.modules.lucence.service; + + +import org.nl.modules.lucence.service.dto.LuceneLogDto; + +public interface LuceneExecuteLogService { + /** + * 设备光电变化实时光电信号 + * + * @param device_code 设备编号 + * @param key plc信号 + * @param value plc信号值 + */ + void deviceItemValue(String device_code, String key, String value); + + /** + * 设备执行日志,会保留历史记录 + * + * @param luceneLogDto 日志结果对象 + */ + void deviceExecuteLog(LuceneLogDto luceneLogDto); + + /** + * 接口日志,会保留历史记录 + * + * @param luceneLogDto 日志结果对象 + */ + void interfaceExecuteLog(LuceneLogDto luceneLogDto); + + /** + * 设备执行日志,会保留历史记录 + * + * @param name 日志名称 + * @param message 日志信息 + */ + void extLog(String name, String message); + + +} diff --git a/acs/nladmin-system/src/main/java/org/nl/modules/lucence/service/LuceneService.java b/acs/nladmin-system/src/main/java/org/nl/modules/lucence/service/LuceneService.java new file mode 100644 index 0000000..7bf0da9 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/modules/lucence/service/LuceneService.java @@ -0,0 +1,27 @@ +package org.nl.modules.lucence.service; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import org.nl.modules.logging.service.dto.LogQueryCriteria; +import org.springframework.data.domain.Pageable; + +import java.util.List; +import java.util.Map; + + +public interface LuceneService { + /** + * 获取labels和values树 + * @return + */ + JSONArray getLabelsValues(); + + /** + * 获取数据分页 + * + * @param whereJson 条件 + * @param page 分页参数 + * @return Map + */ + Map getAll(Map whereJson, Pageable page); +} diff --git a/acs/nladmin-system/src/main/java/org/nl/modules/lucence/service/dto/LuceneLogDto.java b/acs/nladmin-system/src/main/java/org/nl/modules/lucence/service/dto/LuceneLogDto.java new file mode 100644 index 0000000..6d7794b --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/modules/lucence/service/dto/LuceneLogDto.java @@ -0,0 +1,65 @@ +package org.nl.modules.lucence.service.dto; + +import lombok.Data; + +@Data +public class LuceneLogDto { + + /* 日志标识 */ + private String log_uuid; + /*日志类型*/ + private String logType; + /*设备编号*/ + private String device_code; + /*内容详情*/ + private String content; + + /* 任务编码 */ + private String task_code; + + /* 指令编码 */ + private String instruct_code; + + /* 任务标识 */ + private String task_id; + + /* 载具号 */ + private String vehicle_code; + + /* 备注 */ + private String remark; + + /* 日志类型 */ + private String log_type; + + /* 方法 */ + private String method; + + /* 请求参数 */ + private String requestparam; + + /* 响应参数 */ + private String responseparam; + + /* 请求地址 */ + private String requesturl; + + /* 状态码 */ + private String status_code; + + /* 是否删除 1:是;0:否 */ + private String is_delete; + + /* 创建者 */ + private String create_by; + + /* 创建时间 YYYY-MM-DD hh:mm:ss */ + private String create_time; + + /* 修改者 */ + private String update_by; + + /* 修改时间 */ + private String update_time; + +} diff --git a/acs/nladmin-system/src/main/java/org/nl/modules/lucence/service/impl/LuceneExecuteLogServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/modules/lucence/service/impl/LuceneExecuteLogServiceImpl.java new file mode 100644 index 0000000..cd11803 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/modules/lucence/service/impl/LuceneExecuteLogServiceImpl.java @@ -0,0 +1,88 @@ +package org.nl.modules.lucence.service.impl; + +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; +import lombok.RequiredArgsConstructor; +import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; +import org.apache.lucene.document.Document; +import org.apache.lucene.document.Field; +import org.apache.lucene.document.StringField; +import org.apache.lucene.document.TextField; +import org.apache.lucene.index.IndexWriter; +import org.nl.modules.lucence.service.LuceneExecuteLogService; +import org.nl.modules.lucence.service.dto.LuceneLogDto; +import org.nl.modules.lucence.common.LuceneIndexWriter; +import org.slf4j.MDC; +import org.springframework.stereotype.Service; + +/** + * @author jlm + * @description 服务实现 + * @date 2023-04-11 + */ +@Service +@RequiredArgsConstructor +@Slf4j +public class LuceneExecuteLogServiceImpl implements LuceneExecuteLogService { + + @Override + public void deviceItemValue(String device_code, String key, String value) { + String now = DateUtil.now(); + } + + @SneakyThrows + @Override + public void deviceExecuteLog(LuceneLogDto luceneLogDto) { + + 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)); + } + if (ObjectUtil.isNotEmpty(luceneLogDto.getContent())) { + document.add(new TextField("fieldContent", luceneLogDto.getContent(), Field.Store.YES)); + } + document.add(new TextField("logType", "deviceLog", 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); + //记录索引结束时间 + long endTime = System.currentTimeMillis(); +// System.out.println("建立索引"+ "共耗时" + (endTime-startTime) + "毫秒"); + indexWriter.commit(); + log.info("{},{}", luceneLogDto.getDevice_code(), luceneLogDto.getContent()); + //步骤八:关闭资源 +// indexWriter.close(); +// System.out.println("建立索引成功-----关闭资源"); + }catch (Exception e) { + e.printStackTrace(); + // 删除所有的索引 +// indexWriter.deleteAll(); + indexWriter.close(); + } + + } + + @Override + public void interfaceExecuteLog(LuceneLogDto luceneLogDto) { + + } + + @Override + public void extLog(String name, String message) { + try { + MDC.put(name, name); + log.info("{}", message); + } catch (Exception e) { + e.printStackTrace(); + } finally { + MDC.remove(name); + } + } +} diff --git a/acs/nladmin-system/src/main/java/org/nl/modules/lucence/service/impl/LuceneServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/modules/lucence/service/impl/LuceneServiceImpl.java new file mode 100644 index 0000000..e99b9b8 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/modules/lucence/service/impl/LuceneServiceImpl.java @@ -0,0 +1,82 @@ +package org.nl.modules.lucence.service.impl; + +import cn.hutool.core.util.CharsetUtil; +import cn.hutool.http.HttpUtil; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import lombok.RequiredArgsConstructor; +import org.nl.modules.lucence.common.Searcher; +import org.nl.modules.lucence.service.LuceneService; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; + +import java.util.Map; + + +@Service +@RequiredArgsConstructor +public class LuceneServiceImpl implements LuceneService { + + @Value("${loki.url}") + private String lokiUrl; + + @Value("${loki.systemName}") + private String systemName; + + //日志索引目录 + @Value("${lucene.index.path}") + private String luceneUrl; + + /** + * 获取labels和values树 + * + * @return + */ + @Override + public JSONArray getLabelsValues() { + JSONArray result = new JSONArray(); + // 获取所有标签 + String labelString = HttpUtil.get(lokiUrl + "/labels", CharsetUtil.CHARSET_UTF_8); + JSONObject parse = (JSONObject) JSONObject.parse(labelString); + JSONArray labels = parse.getJSONArray("data"); + for (int i=0; i getAll(Map whereJson, Pageable page) { + JSONObject jsonObject1 = new JSONObject(); + try { + jsonObject1 = (JSONObject) Searcher.search(luceneUrl, "",whereJson); + } catch (Exception e) { + e.printStackTrace(); + } + JSONArray array = jsonObject1.getJSONArray("content"); + int totalElements = Integer.parseInt(jsonObject1.get("totalElements").toString()); + JSONObject jo = new JSONObject(); + jo.put("content", array); + jo.put("totalElements", totalElements); + return jo; + } + +} diff --git a/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateLuceneIndex.java b/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateLuceneIndex.java new file mode 100644 index 0000000..b0e7266 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateLuceneIndex.java @@ -0,0 +1,85 @@ +package org.nl.modules.quartz.task; + +import lombok.extern.slf4j.Slf4j; +import org.apache.lucene.document.Document; +import org.apache.lucene.document.Field; +import org.apache.lucene.document.TextField; +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.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; +import org.wltea.analyzer.lucene.IKAnalyzer; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; + +/** + *建立lucene索引 + */ +@Slf4j +@Component +public class AutoCreateLuceneIndex { + + //系统的日志文件路径 + @Value("${logging.file.path}") + private String logUrl; + //日志索引目录 + @Value("${lucene.index.path}") + private String luceneUrl; + + public void run() throws Exception { + + try { + //步骤一:创建Directory对象,用于指定索引库的位置 RAMDirectory内存 + Directory directory = FSDirectory.open(new File(luceneUrl).toPath()); +// Directory directory = FSDirectory.open(new File("D:\\lucene\\index").toPath()); + //步骤二:创建一个IndexWriter对象,用于写索引 + IndexWriter indexWriter = new IndexWriter(directory,new IndexWriterConfig(new IKAnalyzer(false))); + indexWriter.deleteAll(); + //记录索引开始时间 + long startTime = System.currentTimeMillis(); + //步骤三:读取磁盘中文件,对应每一个文件创建一个文档对象 +// File file=new File(logUrl); + File file=new File("D:\\testlog"); + //步骤四:获取文件列表 + File[] files = file.listFiles(); + for (File item:files) { + + BufferedReader bufferedReader = new BufferedReader(new FileReader(item)); + String strLine = null; + int lineCount = 1; + //步骤五:获取文件数据 + //步骤六:创建文档对象 + while(null != (strLine = bufferedReader.readLine())){ + Document document = new Document(); + document.add(new TextField("fieldContent", strLine, Field.Store.YES)); + //步骤七:创建索引,将文档对象写入到索引库 + indexWriter.addDocument(document); + } + } + //记录索引结束时间 + long endTime = System.currentTimeMillis(); + System.out.println("建立索引"+ "共耗时" + (endTime-startTime) + "毫秒"); + //步骤八:关闭资源 +// indexWriter.commit(); + indexWriter.close(); + System.out.println("建立索引成功-----关闭资源"); + }catch (Exception e) { +// indexWriter.close(); + e.printStackTrace(); + } + } + public static void main(String[] args) { + AutoCreateLuceneIndex luceneIndex = new AutoCreateLuceneIndex(); + try { + luceneIndex.run(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + +} diff --git a/acs/nladmin-system/src/main/resources/IKAnalyzer.cfg.xml b/acs/nladmin-system/src/main/resources/IKAnalyzer.cfg.xml new file mode 100644 index 0000000..ef0a1cb --- /dev/null +++ b/acs/nladmin-system/src/main/resources/IKAnalyzer.cfg.xml @@ -0,0 +1,9 @@ + + + + IK Analyzer Config + + extend.dic + + stopword.dic + \ No newline at end of file diff --git a/acs/nladmin-system/src/main/resources/config/application-dev.yml b/acs/nladmin-system/src/main/resources/config/application-dev.yml index 639f973..c226248 100644 --- a/acs/nladmin-system/src/main/resources/config/application-dev.yml +++ b/acs/nladmin-system/src/main/resources/config/application-dev.yml @@ -138,6 +138,9 @@ logging: file: path: D:\acs_log config: classpath:logback-spring.xml +lucene: + index: + path: D:\lucene\index # Sa-Token配置 sa-token: @@ -162,3 +165,7 @@ sa-token: loki: url: http://127.0.0.1:3100/loki/api/v1 systemName: acs + +embedded-lucene: + entity-packages: \ + index-path: D:\testlucene \ No newline at end of file diff --git a/acs/nladmin-system/src/main/resources/extend.dic b/acs/nladmin-system/src/main/resources/extend.dic new file mode 100644 index 0000000..3410c21 --- /dev/null +++ b/acs/nladmin-system/src/main/resources/extend.dic @@ -0,0 +1,4 @@ +读取错误 +信号 +thread-2 +646 \ No newline at end of file diff --git a/acs/nladmin-system/src/main/resources/log/XgAgvDeviceDriver.xml b/acs/nladmin-system/src/main/resources/log/XgAgvDeviceDriver.xml new file mode 100644 index 0000000..d2a9062 --- /dev/null +++ b/acs/nladmin-system/src/main/resources/log/XgAgvDeviceDriver.xml @@ -0,0 +1,34 @@ + + + + + + + + + + ${LOG_HOME}/XgAgvDeviceDriver/${DEVICECODE}/%d{yyyy-MM-dd}.%i.log + + 15 + + 200MB + + 2GB + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + ${log.charset} + + + + + + + + + + + diff --git a/acs/nladmin-system/src/main/resources/logback-spring.xml b/acs/nladmin-system/src/main/resources/logback-spring.xml index 15d2500..4f6265b 100644 --- a/acs/nladmin-system/src/main/resources/logback-spring.xml +++ b/acs/nladmin-system/src/main/resources/logback-spring.xml @@ -39,6 +39,7 @@ https://juejin.cn/post/6844903775631572999 + @@ -92,6 +93,7 @@ https://juejin.cn/post/6844903775631572999 + error diff --git a/acs/nladmin-system/src/main/resources/stopword.dic b/acs/nladmin-system/src/main/resources/stopword.dic new file mode 100644 index 0000000..e69de29 diff --git a/acs/nladmin-ui/src/views/monitor/lucene/api/lucene.js b/acs/nladmin-ui/src/views/monitor/lucene/api/lucene.js new file mode 100644 index 0000000..674bb2c --- /dev/null +++ b/acs/nladmin-ui/src/views/monitor/lucene/api/lucene.js @@ -0,0 +1,18 @@ +import request from '@/utils/request' + +export function getLogData(param) { + return request({ + url: 'api/lucene/getAll', + method: 'get', + data: param + }) +} + +export function labelsValues() { + return request({ + url: 'api/loki/labels/values', + method: 'get' + }) +} + +export default { getLogData, labelsValues } diff --git a/acs/nladmin-ui/src/views/monitor/lucene/search.vue b/acs/nladmin-ui/src/views/monitor/lucene/search.vue index bfb9c19..2822e3e 100644 --- a/acs/nladmin-ui/src/views/monitor/lucene/search.vue +++ b/acs/nladmin-ui/src/views/monitor/lucene/search.vue @@ -1,5 +1,13 @@