周俊杰 1 year ago
parent
commit
a5cbd9f071
  1. 2
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/config/lucene/LuceneAppender.java
  2. 73
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/config/lucene/Searcher.java
  3. 45
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/task/AutoClearLuceneData.java
  4. 2
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/record/service/dao/mapper/SysInteractRecordMapper.xml
  5. 17
      lms/nladmin-ui/src/views/wms/pdm/workerorder/index.vue

2
lms/nladmin-system/nlsso-server/src/main/java/org/nl/config/lucene/LuceneAppender.java

@ -25,7 +25,7 @@ import java.util.Map;
public class LuceneAppender extends AppenderBase<ILoggingEvent> {
private Directory index;
private IndexWriter indexWriter;
public static IndexWriter indexWriter;
@Override

73
lms/nladmin-system/nlsso-server/src/main/java/org/nl/config/lucene/Searcher.java

@ -7,9 +7,8 @@ import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
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.document.LongPoint;
import org.apache.lucene.index.*;
import org.apache.lucene.queryparser.classic.QueryParser;
import org.apache.lucene.search.*;
import org.apache.lucene.store.Directory;
@ -17,11 +16,14 @@ import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.util.BytesRef;
import org.wltea.analyzer.lucene.IKAnalyzer;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.Map;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
import java.util.*;
/**
* lucene查询器
@ -138,19 +140,48 @@ public class Searcher {
}
}
public static void main(String[] args) {
String indexDir = "D:\\lucene\\index";
//查询这个字符串
JSONObject whereJson = new JSONObject();
whereJson.put("size", "500");
whereJson.put("page", "1");
whereJson.put("message", "请求方法参数");
// whereJson.put(LogMessageConstant.FIELD_TRACEID, "13244183367577216");
try {
search(indexDir, whereJson);
} catch (Exception e) {
e.printStackTrace();
}
public static void main(String[] args) throws IOException, ParseException {
// String indexDir = "D:\\lucene\\index";
// //查询这个字符串
// JSONObject whereJson = new JSONObject();
// whereJson.put("size", "500");
// whereJson.put("page", "1");
// whereJson.put("message", "请求方法参数");
//// whereJson.put(LogMessageConstant.FIELD_TRACEID, "13244183367577216");
//
// try {
// search(indexDir, whereJson);
// } catch (Exception e) {
// e.printStackTrace();
// }
// 删除
// Directory directory = FSDirectory.open(Paths.get("D:\\lucene\\index"));
// IndexWriterConfig config = new IndexWriterConfig();
// IndexWriter writer = new IndexWriter(directory, config);
//
// String timestampAsString = "2023-10-25 14:36:12";
// SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// Date date = dateFormat.parse(timestampAsString);
// long unixTimestamp = date.getTime(); // 获取Unix时间戳
//
// Query query = LongPoint.newRangeQuery("time", 0L, unixTimestamp);
// writer.deleteDocuments(query);
//
// writer.commit();
// writer.close();
// 获取当前时间
LocalDateTime now = LocalDateTime.now();
// 减去七天
LocalDateTime sevenDaysAgo = now.minus(7, ChronoUnit.DAYS);
// 转换为 Date 类型
Date sevenDaysAgoDate = Date.from(sevenDaysAgo.atZone(ZoneId.systemDefault()).toInstant());
// 获取时间戳
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
Date date = dateFormat.parse(String.valueOf(sevenDaysAgo));
long timestamp = date.getTime();
System.out.println(now);
System.out.println(sevenDaysAgo);
System.out.println(sevenDaysAgoDate);
System.out.println(timestamp);
}
}

45
lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/task/AutoClearLuceneData.java

@ -0,0 +1,45 @@
package org.nl.system.service.quartz.task;
import lombok.extern.slf4j.Slf4j;
import org.apache.lucene.document.LongPoint;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.search.Query;
import org.nl.config.lucene.LuceneAppender;
import org.nl.system.service.param.ISysParamService;
import org.nl.system.service.param.dao.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.Date;
/**
* @Author: lyd
* @Description: 自动删除lucene日志
* @Date: 2023/10/26
*/
@Slf4j
@Component
public class AutoClearLuceneData {
@Autowired
private ISysParamService paramService;
public void run() throws ParseException, IOException {
Param log_day = paramService.findByCode("log_day");
IndexWriter writer = LuceneAppender.indexWriter;
// 获取当前时间
LocalDateTime now = LocalDateTime.now();
// 减去七天
LocalDateTime sevenDaysAgo = now.minus(Long.parseLong(log_day.getValue()), ChronoUnit.DAYS);
// 获取时间戳
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
Date date = dateFormat.parse(String.valueOf(sevenDaysAgo));
long unixTimestamp = date.getTime(); // 获取Unix时间戳
Query query = LongPoint.newRangeQuery("time", 0L, unixTimestamp);
writer.deleteDocuments(query);
writer.commit();
}
}

2
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/record/service/dao/mapper/SysInteractRecordMapper.xml

@ -7,6 +7,6 @@
WHERE record_time <![CDATA[<=]]> DATE_SUB(NOW(), INTERVAL #{day} DAY);
</delete>
<delete id="deleteByRows">
CALL DeleteRowsIfNeeded(#{maxRowsToKeep}, #{maxRowsToDelete});
CALL DeleteRowsIfNeeded(#{maxRowsToKeep}, #{maxRowsToDelete})
</delete>
</mapper>

17
lms/nladmin-ui/src/views/wms/pdm/workerorder/index.vue

@ -1,5 +1,5 @@
<template>
<div class="app-container">
<div v-loading.fullscreen.lock="fullscreenLoading" class="app-container">
<!--工具栏-->
<div class="head-container">
<div v-if="crud.props.searchToggle">
@ -123,10 +123,10 @@
<el-form-item label="物料规格">
<el-input v-model="form.material_spec" style="width: 240px;" disabled />
</el-form-item>
<el-form-item label="计划数量" prop="plan_qty" >
<el-form-item label="计划数量" prop="plan_qty">
<el-input-number
:disabled="form.region_code === 'FJ'"
v-model.number="form.plan_qty"
:disabled="form.region_code === 'FJ'"
:min="0"
style="width: 240px;"
/>
@ -485,7 +485,8 @@ const defaultForm = {
custer_no: null,
pack_method: null,
order_subnum: 0,
guadansum: 0
guadansum: 0,
show: false
}
export default {
name: 'PdmBdWorkorder',
@ -538,6 +539,7 @@ export default {
regionCodeParam: null,
materialDialog: false,
orderDialog: false,
fullscreenLoading: false,
materialCode: null,
flag: 1
}
@ -640,9 +642,14 @@ export default {
},
//
submits(row) {
this.fullscreenLoading = true
crudPdmBdWorkorder.submits(row).then(res => {
this.crud.notify('下发成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
this.crud.toQuery()
}).catch(() => {
this.fullscreenLoading = false
}).finally(() => {
this.fullscreenLoading = false
})
},
synchronize() {
@ -652,6 +659,8 @@ export default {
this.crud.notify('同步成功!', CRUD.NOTIFICATION_TYPE.SUCCESS)
}).catch(() => {
this.fullscreenLoading = false
}).finally(() => {
this.fullscreenLoading = false
})
}
}

Loading…
Cancel
Save