Browse Source

fix: lucene、参数

master
李永德 11 months ago
parent
commit
c10bee03c9
  1. 6
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/config/lucene/LogMessageConstant.java
  2. 8
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/config/lucene/LuceneAppender.java
  3. 12
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/config/lucene/Searcher.java
  4. 11
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/controller/lucence/LuceneController.java
  5. 9
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/lucene/LuceneService.java
  6. 26
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/lucene/impl/LuceneServiceImpl.java
  7. 3
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/param/ISysParamService.java
  8. 15
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/param/impl/SysParamServiceImpl.java
  9. 2
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/database/brick/service/impl/MdBaseBrickInfoServiceImpl.java
  10. 6
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java
  11. 2
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/autotask/AutoSaveProductionInfo.java
  12. 2
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/impl/PdmBdWorkorderServiceImpl.java
  13. 3
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task/service/impl/SchBaseTaskServiceImpl.java
  14. 27
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/enums/TagNameEnum.java
  15. 3
      lms/nladmin-system/nlsso-server/src/main/resources/config/application.yml
  16. 2
      lms/nladmin-system/nlsso-server/src/main/resources/logback-spring.xml
  17. 15
      lms/nladmin-ui/src/views/lucene/api/lucene.js
  18. 35
      lms/nladmin-ui/src/views/lucene/index.vue
  19. 19
      lms/nladmin-ui/src/views/system/param/index.vue

6
lms/nladmin-system/nlsso-server/src/main/java/org/nl/config/lucene/LogMessageConstant.java

@ -9,15 +9,15 @@ public class LogMessageConstant {
/**
* 标签
*/
public final static String LABEL = "label";
public final static String FIELD_LABEL = "label";
/**
* 时间
*/
public final static String SORT_NAME = "time";
public final static String FIELD_SORT_NAME = "time";
/**
* IP
*/
public final static String IP = "ip";
public final static String FIELD_IP = "ip";
/**
* 级别
*/

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

@ -73,17 +73,17 @@ public class LuceneAppender extends AppenderBase<ILoggingEvent> {
throw new RuntimeException(e);
}
String formattedDateTime = DateUtil.format(new java.util.Date(timeStamp), "yyyy-MM-dd HH:mm:ss.SSS");
doc.add(new LongPoint(LogMessageConstant.SORT_NAME, timeStamp));
doc.add(new NumericDocValuesField(LogMessageConstant.SORT_NAME, timeStamp));
doc.add(new LongPoint(LogMessageConstant.FIELD_SORT_NAME, timeStamp));
doc.add(new NumericDocValuesField(LogMessageConstant.FIELD_SORT_NAME, timeStamp));
doc.add(new StringField(LogMessageConstant.FIELD_LEVEL, event.getLevel().toString(), Field.Store.YES));
doc.add(new StringField(LogMessageConstant.FIELD_TIMESTAMP, formattedDateTime, Field.Store.YES));
doc.add(new StoredField(LogMessageConstant.FIELD_CLASS_NAME, event.getLoggerName()));
doc.add(new StoredField(LogMessageConstant.IP, ipAddress));
doc.add(new StoredField(LogMessageConstant.FIELD_IP, ipAddress));
doc.add(new StoredField(LogMessageConstant.FIELD_THREAD, event.getThreadName()));
if (ObjectUtil.isNotEmpty(mdcPropertyMap) && ObjectUtil.isNotEmpty(mdcPropertyMap.get(LogMessageConstant.FIELD_TRACEID))) {
String traceId = mdcPropertyMap.get(LogMessageConstant.FIELD_TRACEID);
doc.add(new StringField(LogMessageConstant.FIELD_TRACEID, traceId, Field.Store.YES));
doc.add(new StringField(LogMessageConstant.LABEL, ObjectUtil.isNotEmpty(mdcPropertyMap.get("tag_name"))
doc.add(new StringField(LogMessageConstant.FIELD_LABEL, ObjectUtil.isNotEmpty(mdcPropertyMap.get("tag_name"))
? mdcPropertyMap.get("tag_name") : "-", Field.Store.YES));
} else {
// 定义正则表达式,匹配17位数字

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

@ -51,7 +51,7 @@ public class Searcher {
// 当前页的结束条数(不能包含)
int end = start + pageSize;
// 创建排序对象,需要排序字段SortField,参数:字段的名称、字段的类型、是否反转如果是false,升序。true降序
Sort sort = new Sort(new SortField(LogMessageConstant.SORT_NAME, SortField.Type.LONG, true));
Sort sort = new Sort(new SortField(LogMessageConstant.FIELD_SORT_NAME, SortField.Type.LONG, true));
TopDocs docs = null;
BooleanQuery.Builder booleanQueryBuilder = new BooleanQuery.Builder();
@ -86,6 +86,12 @@ public class Searcher {
whereJson.getString(LogMessageConstant.FIELD_TRACEID).trim()));
booleanQueryBuilder.add(termQuery, BooleanClause.Occur.MUST);
}
if (ObjectUtil.isNotEmpty(whereJson.get(LogMessageConstant.FIELD_LABEL))) {
//查询解析器
TermQuery termQuery = new TermQuery(new Term(LogMessageConstant.FIELD_LABEL,
whereJson.getString(LogMessageConstant.FIELD_LABEL).trim()));
booleanQueryBuilder.add(termQuery, BooleanClause.Occur.MUST);
}
if (ObjectUtil.isNotEmpty(whereJson.get(LogMessageConstant.FIELD_LEVEL))) {
//查询解析器
TermQuery termQuery = new TermQuery(new Term(LogMessageConstant.FIELD_LEVEL,
@ -101,9 +107,9 @@ public class Searcher {
for (ScoreDoc scoreDoc : scoreDocs) {
Document doc = reader.document(scoreDoc.doc);
String logInfo = LogMessageConstant.COLOR_CYAN + doc.get(LogMessageConstant.LABEL) +
String logInfo = LogMessageConstant.COLOR_CYAN + doc.get(LogMessageConstant.FIELD_LABEL) +
LogMessageConstant.COLOR_RESET + " - " +
LogMessageConstant.COLOR_BLUE + doc.get(LogMessageConstant.IP) +
LogMessageConstant.COLOR_BLUE + doc.get(LogMessageConstant.FIELD_IP) +
LogMessageConstant.COLOR_RESET + " - " +
LogMessageConstant.COLOR_YELLOW + doc.get(LogMessageConstant.FIELD_TRACEID) +
LogMessageConstant.COLOR_RESET + " - " +

11
lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/controller/lucence/LuceneController.java

@ -29,4 +29,15 @@ public class LuceneController {
public ResponseEntity<Object> get(@RequestBody JSONObject whereJson) {
return new ResponseEntity<>(luceneService.getAll(whereJson), HttpStatus.OK);
}
@PostMapping("/getTagName")
public ResponseEntity<Object> getTagName() {
return new ResponseEntity<>(luceneService.getTagName(), HttpStatus.OK);
}
@PostMapping("/deleteAllLog")
public ResponseEntity<Object> deleteAllLog() {
luceneService.deleteAllLog();
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
}

9
lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/lucene/LuceneService.java

@ -2,6 +2,7 @@ package org.nl.system.service.lucene;
import com.alibaba.fastjson.JSONObject;
import java.util.List;
import java.util.Map;
/**
@ -18,4 +19,12 @@ public interface LuceneService {
* @return Map<String, Object>
*/
Map<String, Object> getAll(JSONObject whereJson);
/**
* 获取枚举的标签名称
* @return
*/
List<String> getTagName();
void deleteAllLog();
}

26
lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/lucene/impl/LuceneServiceImpl.java

@ -3,12 +3,19 @@ package org.nl.system.service.lucene.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.nl.config.lucene.LuceneAppender;
import org.nl.config.lucene.Searcher;
import org.nl.system.service.lucene.LuceneService;
import org.nl.wms.sch.task_manage.enums.TagNameEnum;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -39,4 +46,23 @@ public class LuceneServiceImpl implements LuceneService {
return jo;
}
@Override
public List<String> getTagName() {
List<String> res = new ArrayList<>();
for (TagNameEnum nameEnum : TagNameEnum.values()) {
res.add(nameEnum.getTag());
}
return res;
}
@SneakyThrows
@Override
public void deleteAllLog() {
IndexWriter writer = LuceneAppender.indexWriter;
// 创建一个匹配所有文档的查询
MatchAllDocsQuery query = new MatchAllDocsQuery();
writer.deleteDocuments(query);
writer.commit();
}
}

3
lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/param/ISysParamService.java

@ -1,5 +1,6 @@
package org.nl.system.service.param;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import org.nl.common.domain.query.PageQuery;
@ -25,7 +26,7 @@ public interface ISysParamService extends IService<Param> {
* @param page 分页信息
* @return
*/
Page<Param> queryPage(Map whereJson, PageQuery page);
IPage<Param> queryPage(Map whereJson, PageQuery page);
/**
* 创建参数

15
lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/param/impl/SysParamServiceImpl.java

@ -9,6 +9,7 @@ import com.alicp.jetcache.anno.CacheUpdate;
import com.alicp.jetcache.anno.Cached;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
@ -42,11 +43,15 @@ public class SysParamServiceImpl extends ServiceImpl<SysParamMapper, Param> impl
private SysParamMapper paramMapper;
@Override
public Page<Param> queryPage(Map whereJson, PageQuery page) {
QueryWrapper<Param> queryWrapper = new QueryWrapper<>();
queryWrapper.orderBy(true, true, "create_time");
Page<Param> paramPage = paramMapper.selectPage(page.build(), queryWrapper);
return paramPage;
public IPage<Param> queryPage(Map whereJson, PageQuery page) {
String code = ObjectUtil.isNotEmpty(whereJson.get("code"))
? whereJson.get("code").toString() : null;
IPage<Param> pages = new Page<>(page.getPage() + 1, page.getSize());
LambdaQueryWrapper<Param> lam = new QueryWrapper<Param>().lambda();
lam.like(ObjectUtil.isNotEmpty(code), Param::getCode, code)
.orderByAsc(Param::getCreate_time);
paramMapper.selectPage(pages, lam);
return pages;
}
@Override

2
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/database/brick/service/impl/MdBaseBrickInfoServiceImpl.java

@ -17,6 +17,7 @@ import org.nl.wms.ext.mes.service.WmsToMesService;
import org.nl.wms.pdm.workorder.service.IPdmBdWorkorderService;
import org.nl.wms.pdm.workorder.service.dao.PdmBdWorkorder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import java.util.Map;
@ -29,6 +30,7 @@ import java.util.Set;
**/
@Slf4j
@Service
@Lazy
public class MdBaseBrickInfoServiceImpl extends ServiceImpl<MdBaseBrickInfoMapper, MdBaseBrickInfo> implements IMdBaseBrickInfoService {
@Autowired

6
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java

@ -703,10 +703,10 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
taskResponse.setMessage("静置完成");
taskResponse.setWeight(one.getMaterial_weight().toString());
taskResponse.setMudBatch(one.getPcsn());
// 泥料数据删除
// todo: 泥料数据删除
List<PdmBdRequestMaterialRecord> list = requestMaterialRecordService.list(new LambdaQueryWrapper<PdmBdRequestMaterialRecord>()
.eq(PdmBdRequestMaterialRecord::getDevice_code, productionTask.getPoint_code())
.eq(PdmBdRequestMaterialRecord::getWorkorder_id, productionTask.getWorkorder_code())
.eq(PdmBdRequestMaterialRecord::getDevice_code, yjDeviceCode)
.eq(ObjectUtil.isNotEmpty(productionTask), PdmBdRequestMaterialRecord::getWorkorder_id, productionTask.getWorkorder_code())
.eq(PdmBdRequestMaterialRecord::getIs_delete, false)
.eq(PdmBdRequestMaterialRecord::getIs_finish, true)
.orderByAsc(PdmBdRequestMaterialRecord::getCreate_time));

2
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/autotask/AutoSaveProductionInfo.java

@ -11,6 +11,7 @@ import org.nl.wms.ext.mes.service.dto.MesSemiProductionInfo;
import org.nl.wms.sch.task_manage.GeneralDefinition;
import org.nl.wms.sch.task_manage.enums.NoticeTypeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
@ -25,6 +26,7 @@ import java.util.concurrent.atomic.AtomicInteger;
@Slf4j
@Component
@Order(value = 1)
@Lazy
public class AutoSaveProductionInfo {
@Autowired
private WmsToMesService wmsToMesService;

2
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/impl/PdmBdWorkorderServiceImpl.java

@ -39,6 +39,7 @@ import org.nl.wms.sch.task_manage.enums.WorkOrderStatusEnum;
import org.nl.wms.util.CommonUtils;
import org.nl.wms.util.TaskUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -54,6 +55,7 @@ import java.util.Set;
**/
@Slf4j
@Service
@Lazy
public class PdmBdWorkorderServiceImpl extends ServiceImpl<PdmBdWorkorderMapper, PdmBdWorkorder> implements IPdmBdWorkorderService {
@Autowired

3
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task/service/impl/SchBaseTaskServiceImpl.java

@ -154,7 +154,8 @@ public class SchBaseTaskServiceImpl extends ServiceImpl<SchBaseTaskMapper, SchBa
LambdaQueryWrapper<SchBaseTask> lam = new LambdaQueryWrapper<>();
lam.eq(SchBaseTask::getConfig_code, config_code)
.eq(SchBaseTask::getTask_status, status.getCode())
.ne(SchBaseTask::getIs_delete, true);
.ne(SchBaseTask::getIs_delete, true)
.orderByAsc(SchBaseTask::getCreate_time);
List<SchBaseTask> schBaseTasks = schBaseTaskMapper.selectList(lam);
return schBaseTasks;

27
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/enums/TagNameEnum.java

@ -0,0 +1,27 @@
package org.nl.wms.sch.task_manage.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @Author: lyd
* @Description: 日志标签枚举
* @Date: 2023/12/28
*/
@Getter
@AllArgsConstructor
public enum TagNameEnum {
/**
* LMS系统
*/
LMS("LMS系统"),
/**
* 物料同步
*/
MATERIAL_SYNCHRONIZATION("物料同步"),
/**
* 标记符号
*/
MARK_SYMBOL("-");
private final String tag;
}

3
lms/nladmin-system/nlsso-server/src/main/resources/config/application.yml

@ -58,7 +58,6 @@ spring:
enabled: true # 是否启用 dynamictp,默认true
enabledBanner: false # 是否启用 控制台banner,默认true
enabledCollect: true # 是否开启监控指标采集,默认true
enabled-banner: false
collectorTypes: logging,test_collect # 监控数据采集器类型(logging | micrometer | internal_logging),默认micrometer
logPath: C:\log\lms # 监控日志数据路径,默认 ${user.home}/logs,采集类型非logging不用配置
monitorInterval: 8
@ -67,7 +66,7 @@ spring:
corePoolSize: 100
maximumPoolSize: 200
keepAliveTime: 60
runTimeout: 200
runTimeout: 10000
queueTimeout: 100
notifyItems: # 报警项,不配置自动会按默认值配置(变更通知、容量报警、活性报警、拒绝报警、任务超时报警)
- type: change

2
lms/nladmin-system/nlsso-server/src/main/resources/logback-spring.xml

@ -71,9 +71,9 @@ https://juejin.cn/post/6844903775631572999
<!--开发环境:打印控制台-->
<springProfile name="dev">
<root level="DEBUG">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="asyncFileAppender"/>
<appender-ref ref="asyncLuceneAppender"/>
<appender-ref ref="CONSOLE"/>
</root>
<logger name="com.baomidou.mybatisplus.core.MybatisConfiguration" level="ERROR" additivity="false">
<appender-ref ref="asyncLuceneAppender"/>

15
lms/nladmin-ui/src/views/lucene/api/lucene.js

@ -8,6 +8,19 @@ export function getLogData(param) {
})
}
export function getTagName() {
return request({
url: 'api/lucene/getTagName',
method: 'post'
})
}
export function deleteAllLog() {
return request({
url: 'api/lucene/deleteAllLog',
method: 'post'
})
}
export function labelsValues() {
return request({
url: 'api/loki/labels/values',
@ -15,4 +28,4 @@ export function labelsValues() {
})
}
export default { getLogData, labelsValues }
export default { getLogData, labelsValues, getTagName, deleteAllLog }

35
lms/nladmin-ui/src/views/lucene/index.vue

@ -8,13 +8,28 @@
label-width="90px"
label-suffix=":"
>
<el-form-item label="标签名">
<el-select
v-model="query.label"
clearable
size="mini"
placeholder="标签名"
style="width: 240px;"
>
<el-option
v-for="item in tagList"
:label="item"
:value="item"
/>
</el-select>
</el-form-item>
<el-form-item label="日志级别">
<el-select
v-model="query.level"
clearable
size="mini"
placeholder="日志级别"
class="filter-item"
style="width: 240px;"
>
<el-option
v-for="item in levelOptions"
@ -29,6 +44,7 @@
clearable
size="mini"
placeholder="日志内容"
style="width: 240px;"
/>
</el-form-item>
<el-form-item label="链路ID">
@ -37,6 +53,7 @@
clearable
size="mini"
placeholder="请输入链路ID"
style="width: 240px;"
/>
</el-form-item>
<el-form-item label="时间">
@ -52,6 +69,9 @@
<el-button type="primary" size="mini" @click="queryData">
查询
</el-button>
<el-button size="mini" type="danger" @click="toDeleteLog">
删除
</el-button>
</el-form-item>
</el-form>
</div>
@ -80,6 +100,7 @@
<script>
import luceneOperation from '@/views/lucene/api/lucene'
import { default as AnsiUp } from 'ansi_up'
import CRUD from '@crud/crud'
export default {
name: 'LuceneLog',
data() {
@ -104,6 +125,7 @@ export default {
}],
rules: {},
logs: [],
tagList: [],
query: {
tlogTraceId: '',
message: '',
@ -116,8 +138,19 @@ export default {
},
created() {
this.queryData()
this.getTagList()
},
methods: {
toDeleteLog() {
luceneOperation.deleteAllLog().then(res => {
this.crud.notify('删除成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
})
},
getTagList() {
luceneOperation.getTagName().then(res => {
this.tagList = res
})
},
handleSizeChange(val) {
this.query.size = val
this.queryData()

19
lms/nladmin-ui/src/views/system/param/index.vue

@ -2,6 +2,25 @@
<div class="app-container">
<!--工具栏-->
<div class="head-container">
<div v-if="crud.props.searchToggle">
<el-form
:inline="true"
class="demo-form-inline"
label-position="right"
label-width="80px"
label-suffix=":"
>
<el-form-item label="参数编码">
<el-input
v-model="query.code"
clearable
style="width: 240px"
placeholder="参数编码"
/>
</el-form-item>
<rrOperation />
</el-form>
</div>
<!--如果想在工具栏加入更多按钮可以使用插槽方式 slot = 'left' or 'right'-->
<crudOperation :permission="permission" />
<!--表单组件-->

Loading…
Cancel
Save