增加:getBusynessKey

This commit is contained in:
tiezx 2025-07-17 13:01:55 +08:00
parent 9ede76e085
commit 3c3a654dbd

View File

@ -2,6 +2,7 @@ package net.ferrum.flowable.utils;
import net.ferrum.common.utils.DateUtils;
import net.ferrum.common.utils.StringUtils;
import net.ferrum.flowable.common.constant.ProcessConstants;
import net.ferrum.flowable.core.domain.ProcessQuery;
import org.flowable.common.engine.api.query.Query;
import org.flowable.common.engine.impl.db.SuspensionState;
@ -78,6 +79,40 @@ public class ProcessUtils {
query.taskCreatedAfter(DateUtils.parseDate(params.get("beginTime")));
query.taskCreatedBefore(DateUtils.parseDate(params.get("endTime")));
}
String sKey = getBusynessKey(process);
if(sKey != null) {
query.processInstanceBusinessKeyLike(sKey);
}
}
private static String getBusynessKey(ProcessQuery process){
String sKey = null;
if (StringUtils.isNotBlank(process.getSpecBatch()) || StringUtils.isNotBlank(process.getSpecName())) {
//批次
if (StringUtils.isNotBlank(process.getSpecBatch())){
sKey = "%" + process.getSpecBatch();
//规格名称
if (StringUtils.isNotBlank(process.getSpecName())) {
sKey += "%" + ProcessConstants.PROCESS_BUSYNESSKEY_ConnString + "%" + process.getSpecName() + "%";
}else{
sKey += "%" + ProcessConstants.PROCESS_BUSYNESSKEY_ConnString + "%";
}
}
else{
if (StringUtils.isNotBlank(process.getSpecName())) {
sKey = "%" + ProcessConstants.PROCESS_BUSYNESSKEY_ConnString + "%" + process.getSpecName() + "%";
}else{
sKey = "%" + ProcessConstants.PROCESS_BUSYNESSKEY_ConnString + "%";
}
}
}
return sKey;
}
private static void buildHistoricTaskInstanceSearch(HistoricTaskInstanceQuery query, ProcessQuery process) {
@ -92,6 +127,10 @@ public class ProcessUtils {
query.taskCompletedAfter(DateUtils.parseDate(params.get("beginTime")));
query.taskCompletedBefore(DateUtils.parseDate(params.get("endTime")));
}
String sKey = getBusynessKey(process);
if(sKey != null) {
query.processInstanceBusinessKeyLike(sKey);
}
}
/**
@ -111,19 +150,7 @@ public class ProcessUtils {
}
*/
String sKey = null;
//批次
if (StringUtils.isNotBlank(process.getSpecBatch())) {
sKey = "%" + process.getSpecBatch();
}
//规格名称
if (StringUtils.isNotBlank(process.getSpecName())) {
if(sKey == null){
sKey = "%" + process.getSpecName() + "%";
}else{
sKey += "%" + process.getSpecName() + "%";
}
}
String sKey = getBusynessKey(process);
if(sKey != null) {
query.processInstanceBusinessKeyLike(sKey);
}