提交 28559ec9 authored 作者: kxjia's avatar kxjia

修改 bug

上级 fa289c53
......@@ -8,6 +8,9 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jeecg-module-flowable</artifactId>
<properties>
<flowable.version>7.0.0</flowable.version>
</properties>
<dependencies>
<dependency>
<groupId>org.jeecgframework.boot3</groupId>
......@@ -18,11 +21,37 @@
<artifactId>jeecg-system-biz</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-spring-boot-starter-process</artifactId>
<version>${flowable.version}</version>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-spring-boot-starter</artifactId>
<version>${flowable.version}</version><!-- 根据你的版本调整 -->
</dependency>
<!-- Flowable REST API(如果需要) -->
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-spring-boot-starter-rest</artifactId>
<version>${flowable.version}</version>
</dependency>
<!-- Flowable Spring Security(如果需要安全) -->
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-spring-security</artifactId>
<version>${flowable.version}</version>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-engine</artifactId>
<scope>compile</scope>
<version>6.5.0</version>
<version>${flowable.version}</version>
<exclusions>
<exclusion>
<groupId>org.mybatis</groupId>
......@@ -30,11 +59,7 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-spring-boot-starter-basic</artifactId>
<version>6.5.0</version>
</dependency>
<dependency>
<groupId>org.eweb4j</groupId>
<artifactId>fel</artifactId>
......
......@@ -18,9 +18,9 @@ import org.springframework.stereotype.Service;
*/
@Service
public class FlowCommonService {
@Autowired
@Autowired(required = false)
FlowMyBusinessServiceImpl flowMyBusinessService;
@Autowired
@Autowired(required = false)
FlowInstanceServiceImpl flowInstanceService;
/**
* 初始生成或修改业务与流程的关联信息<br/>
......
......@@ -134,7 +134,7 @@ public class CustomProcessDiagramCanvas extends DefaultProcessDiagramCanvas {
SHELL_TASK_IMAGE = ImageIO.read(ReflectUtil.getResource("org/flowable/icons/shellTask.png", this.customClassLoader));
DMN_TASK_IMAGE = ImageIO.read(ReflectUtil.getResource("org/flowable/icons/dmnTask.png", this.customClassLoader));
CAMEL_TASK_IMAGE = ImageIO.read(ReflectUtil.getResource("org/flowable/icons/camelTask.png", this.customClassLoader));
MULE_TASK_IMAGE = ImageIO.read(ReflectUtil.getResource("org/flowable/icons/muleTask.png", this.customClassLoader));
//MULE_TASK_IMAGE = ImageIO.read(ReflectUtil.getResource("org/flowable/icons/muleTask.png", this.customClassLoader));
HTTP_TASK_IMAGE = ImageIO.read(ReflectUtil.getResource("org/flowable/icons/httpTask.png", this.customClassLoader));
TIMER_IMAGE = ImageIO.read(ReflectUtil.getResource("org/flowable/icons/timer.png", this.customClassLoader));
COMPENSATE_THROW_IMAGE = ImageIO.read(ReflectUtil.getResource("org/flowable/icons/compensate-throw.png", this.customClassLoader));
......
......@@ -34,50 +34,18 @@
<artifactId>jeecg-system-biz</artifactId>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>7.17.10</version> <!-- 使用你的 ES 版本 -->
</dependency>
<!-- 或者 Elasticsearch 8.x -->
<dependency>
<groupId>co.elastic.clients</groupId>
<artifactId>elasticsearch-java</artifactId>
<version>8.12.0</version>
</dependency>
<!-- 还需要基础的 transport 依赖 -->
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-client</artifactId>
<version>7.17.10</version>
</dependency>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>7.17.10</version>
<version>8.12.0</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.elasticsearch.client</groupId>-->
<!-- <artifactId>elasticsearch-rest-high-level-client</artifactId>-->
<!-- <version>7.17.3</version> &lt;!&ndash; Use your Elasticsearch version &ndash;&gt;-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.elasticsearch.client</groupId>-->
<!-- <artifactId>elasticsearch-rest-client</artifactId>-->
<!-- <version>8.12.0</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>co.elastic.clients</groupId>-->
<!-- <artifactId>elasticsearch-java</artifactId>-->
<!-- <version>8.12.0</version>-->
<!-- </dependency>-->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
......@@ -90,10 +58,11 @@
<version>2.1.1</version>
</dependency>
<!-- JSON 处理 -->
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>8.12.0</version>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>2.0.43</version>
</dependency>
<!-- <dependency>-->
......
......@@ -7,11 +7,12 @@ import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.stm.common.service.IStCommonService;
import org.jeecg.modules.stm.common.vo.QueryVo;
import org.jeecg.modules.stm.essearch.stlib.service.IStlibService;
import org.jeecg.modules.stm.problem.service.IStProblemService;
import org.jeecg.modules.stm.stlib.constant.StLibbIndexs;
import org.jeecg.modules.stm.stlib.pojo.EsQueryVo;
import org.jeecg.modules.stm.stlib.pojo.PageResult;
import org.jeecg.modules.stm.stlib.service.IStlibService;
import org.jeecg.modules.stm.risk.event.service.IStRiskEventService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
......
package org.jeecg.modules.stm.stlib.service;
package org.jeecg.modules.stm.essearch.stlib.service;
import org.jeecg.modules.stm.stlib.pojo.PageResult;
import org.jeecg.modules.stm.stlib.pojo.EsQueryVo;
......
package org.jeecg.modules.stm.essearch.stlib.service.impl;
import co.elastic.clients.elasticsearch.ElasticsearchClient;
import co.elastic.clients.elasticsearch.core.SearchRequest;
import co.elastic.clients.elasticsearch.core.SearchResponse;
import co.elastic.clients.elasticsearch._types.query_dsl.*;
import co.elastic.clients.elasticsearch.core.search.Hit;
import co.elastic.clients.elasticsearch.core.search.HighlightField;
import co.elastic.clients.elasticsearch.core.search.TotalHits;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder;
import org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
import org.elasticsearch.search.fetch.subphase.highlight.HighlightField;
import org.jeecg.modules.stm.essearch.stlib.service.IStlibService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.jeecg.modules.stm.stlib.service.IStlibService;
import org.jeecg.modules.stm.stlib.pojo.EsQueryVo;
import org.jeecg.modules.stm.stlib.pojo.PageResult;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
......@@ -30,58 +28,132 @@ import java.util.Map;
public class StlibService implements IStlibService {
@Autowired
private RestHighLevelClient restHighLevelClient;
private ElasticsearchClient elasticsearchClient;
@Override
public PageResult search(EsQueryVo params,int pageNo,int pageSize) {
public PageResult search(EsQueryVo params, int pageNo, int pageSize) {
try {
SearchRequest request = new SearchRequest("mapping_common");
buildBasicQuery(params, request);
request.source().from((pageNo - 1) * pageSize).size(pageSize);
SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
// 构建搜索请求
SearchRequest request = SearchRequest.of(s -> s
.index("mapping_common")
.from((pageNo - 1) * pageSize)
.size(pageSize)
.query(buildBasicQuery(params))
.highlight(h -> h
.fields("name", HighlightField.of(hf -> hf))
)
);
// 执行搜索
SearchResponse<EsQueryVo> response = elasticsearchClient.search(request, EsQueryVo.class);
return handleResponse(response);
} catch (IOException e) {
throw new RuntimeException("搜索数据失败", e);
}
}
private void buildBasicQuery(EsQueryVo params, SearchRequest request) {
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
private Query buildBasicQuery(EsQueryVo params) {
// 构建 Bool 查询
BoolQuery.Builder boolQueryBuilder = new BoolQuery.Builder();
// 添加 term 查询条件
String scType = params.getSctype();
if (StringUtils.isNotBlank(scType)) {
boolQuery.filter(QueryBuilders.termQuery("sctype", scType));
boolQueryBuilder.filter(f -> f
.term(t -> t
.field("sctype")
.value(v -> v.stringValue(scType))
)
);
}
FunctionScoreQueryBuilder functionScoreQuery = QueryBuilders.functionScoreQuery(
boolQuery, // 原始查询,boolQuery
new FunctionScoreQueryBuilder.FilterFunctionBuilder[]{ // function数组
new FunctionScoreQueryBuilder.FilterFunctionBuilder(
QueryBuilders.termQuery("isAD", true), // 过滤条件
ScoreFunctionBuilders.weightFactorFunction(10) // 算分函数
// 构建 Function Score 查询
FunctionScoreQuery.Builder functionScoreBuilder = new FunctionScoreQuery.Builder();
// 设置查询条件
functionScoreBuilder.query(q -> q
.bool(boolQueryBuilder.build())
);
// 添加过滤条件和权重函数
List<FunctionScore> functions = new ArrayList<>();
functions.add(FunctionScore.of(f -> f
.filter(fq -> fq
.term(t -> t
.field("isAD")
.value(v -> v.booleanValue(true))
)
}
)
.weight(10.0)
));
functionScoreBuilder.functions(functions);
// 构建最终的查询
return Query.of(q -> q
.functionScore(functionScoreBuilder.build())
);
request.source().query(functionScoreQuery);
}
private PageResult handleResponse(SearchResponse response) {
SearchHits searchHits = response.getHits();
long total = searchHits.getTotalHits().value;
SearchHit[] hits = searchHits.getHits();
List<EsQueryVo> dataList = new ArrayList<>(hits.length);
for (SearchHit hit : hits) {
String json = hit.getSourceAsString();
EsQueryVo esQueryVo = JSON.parseObject(json, EsQueryVo.class);
Map<String, HighlightField> map = hit.getHighlightFields();
if (map != null && !map.isEmpty()) {
HighlightField highlightField = map.get("name");
if (highlightField != null) {
String hName = highlightField.fragments()[0].toString();
esQueryVo.setName(hName);
private PageResult handleResponse(SearchResponse<EsQueryVo> response) {
TotalHits total = response.hits().total();
long totalHits = total != null ? total.value() : 0;
List<Hit<EsQueryVo>> hits = response.hits().hits();
List<EsQueryVo> dataList = new ArrayList<>(hits.size());
for (Hit<EsQueryVo> hit : hits) {
EsQueryVo esQueryVo = hit.source();
if (esQueryVo == null) {
// 如果 source 为 null,尝试从 JSON 解析
String json = JSON.toJSONString(hit.fields());
esQueryVo = JSON.parseObject(json, EsQueryVo.class);
}
// 处理高亮
Map<String, List<String>> highlightMap = hit.highlight();
if (highlightMap != null && !highlightMap.isEmpty()) {
List<String> nameHighlights = highlightMap.get("name");
if (nameHighlights != null && !nameHighlights.isEmpty()) {
esQueryVo.setName(nameHighlights.get(0));
}
}
dataList.add(esQueryVo);
}
return new PageResult(total, dataList);
return new PageResult(totalHits, dataList);
}
// 如果需要原始的 JSON 处理方式,可以使用以下方法
private PageResult handleResponseWithJson(SearchResponse<Object> response) {
try {
TotalHits total = response.hits().total();
long totalHits = total != null ? total.value() : 0;
List<Hit<Object>> hits = response.hits().hits();
List<EsQueryVo> dataList = new ArrayList<>(hits.size());
for (Hit<Object> hit : hits) {
// 将 source 转换为 JSON 字符串
String json = JSON.toJSONString(hit.source());
EsQueryVo esQueryVo = JSON.parseObject(json, EsQueryVo.class);
// 处理高亮
Map<String, List<String>> highlightMap = hit.highlight();
if (highlightMap != null && !highlightMap.isEmpty()) {
List<String> nameHighlights = highlightMap.get("name");
if (nameHighlights != null && !nameHighlights.isEmpty()) {
esQueryVo.setName(nameHighlights.get(0));
}
}
dataList.add(esQueryVo);
}
return new PageResult(totalHits, dataList);
} catch (Exception e) {
throw new RuntimeException("处理搜索结果失败", e);
}
}
}
}
\ No newline at end of file
......@@ -321,11 +321,14 @@ cas:
prefixUrl: http://cas.example.org:8443/cas
#Mybatis输出sql日志
logging:
file:
name: logs/application.log
level:
org.flowable: error
org.springframework.context.support.PostProcessorRegistrationDelegate: error
org.flywaydb: debug
org.jeecg.modules.system.mapper: info
org.jeecg.modules.demo.test.mapper: info
org.flywaydb: error
org.jeecg.modules.system.mapper: debug
# org.jeecg.modules.demo.test.mapper: info
#swagger
knife4j:
#开启增强配置
......
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">
<!--定义日志文件的存储地址 -->
<property name="LOG_HOME" value="../logs" />
<configuration>
<!-- 使用 Spring Boot 的默认配置 -->
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
<include resource="org/springframework/boot/logging/logback/console-appender.xml"/>
<include resource="org/springframework/boot/logging/logback/file-appender.xml"/>
<!--<property name="COLOR_PATTERN" value="%black(%contextName-) %red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta( %replace(%caller{1}){'\t|Caller.{1}0|\r\n', ''})- %gray(%msg%xEx%n)" />-->
<!-- 控制台输出 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}:%L - %msg%n</pattern>-->
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %highlight(%-5level) %cyan(%logger{50}:%L) - %msg%n</pattern>
</encoder>
</appender>
<!-- 按照每天生成日志文件 -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--日志文件输出的文件名 -->
<FileNamePattern>${LOG_HOME}/jeecgboot-%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<!--日志文件保留天数 -->
<MaxHistory>30</MaxHistory>
<maxFileSize>10MB</maxFileSize>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 -->
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}:%L - %msg%n</pattern>
</encoder>
</appender>
<!-- 生成 error html格式日志开始 -->
<appender name="HTML" class="ch.qos.logback.core.FileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<!--设置日志级别,过滤掉info日志,只输入error日志-->
<level>ERROR</level>
</filter>
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
<layout class="ch.qos.logback.classic.html.HTMLLayout">
<pattern>%p%d%msg%M%F{32}%L</pattern>
</layout>
</encoder>
<file>${LOG_HOME}/error-log.html</file>
</appender>
<!-- 生成 error html格式日志结束 -->
<!-- 每天生成一个html格式的日志开始 -->
<appender name="FILE_HTML" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--日志文件输出的文件名 -->
<FileNamePattern>${LOG_HOME}/jeecgboot-%d{yyyy-MM-dd}.%i.html</FileNamePattern>
<!--日志文件保留天数 -->
<MaxHistory>30</MaxHistory>
<MaxFileSize>10MB</MaxFileSize>
</rollingPolicy>
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
<layout class="ch.qos.logback.classic.html.HTMLLayout">
<pattern>%p%d%msg%M%F{32}%L</pattern>
</layout>
</encoder>
</appender>
<!-- 每天生成一个html格式的日志结束 -->
<!--myibatis log configure -->
<logger name="com.apache.ibatis" level="TRACE" />
<logger name="java.sql.Connection" level="DEBUG" />
<logger name="java.sql.Statement" level="DEBUG" />
<logger name="java.sql.PreparedStatement" level="DEBUG" />
<!-- 日志输出级别 -->
<root level="INFO">
<appender-ref ref="STDOUT" />
<!-- 开发环境关闭日志生成,项目启动快;生产环境请按需打开注释
<appender-ref ref="FILE" />
<appender-ref ref="HTML" />
<appender-ref ref="FILE_HTML" />-->
</root>
<!-- 开发环境:只输出到控制台 -->
<springProfile name="dev">
<root level="INFO">
<appender-ref ref="CONSOLE"/>
</root>
</springProfile>
<!-- 生产环境:输出到控制台和文件 -->
<springProfile name="prod">
<root level="INFO">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
</root>
</springProfile>
</configuration>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论