fix(文档拆分): 动态字段查询完善
This commit is contained in:
+4
@@ -36,6 +36,10 @@ public class DocumentSplitCommon {
|
||||
* 模糊匹配
|
||||
*/
|
||||
public static final String CONCAT_LIKE_END = "', '%') ";
|
||||
/**
|
||||
* 包含
|
||||
*/
|
||||
public static final String INSTR_BEGIN = " instr(";
|
||||
/**
|
||||
* and
|
||||
*/
|
||||
|
||||
+17
@@ -17,6 +17,23 @@ import javax.annotation.PostConstruct;
|
||||
@Component
|
||||
public class DateManyConditionImpl extends AbstractConditionBase {
|
||||
|
||||
/**
|
||||
* 实现逻辑,多日期字符串字段(存储时前端从小到大排好序(必须))
|
||||
* 逗号拆分获取首位和末尾日期,来分别匹配是否符合查询参数的两个日期区间
|
||||
* 实现sql参考:(代码拼接中加入了date_format来格式化日期)
|
||||
* select
|
||||
* epr.*
|
||||
* from
|
||||
* event_plan_record epr
|
||||
* where
|
||||
* substring_index('epr.realStartTime', ',', 1) BETWEEN #{startDate} AND #{endDate}
|
||||
* or substring_index('epr.realStartTime', ',', -1) BETWEEN #{startDate} AND #{endDate}
|
||||
* or #{startDate} BETWEEN substring_index('epr.realStartTime', ',', 1) AND substring_index('epr.realStartTime', ',', -1)
|
||||
* or #{endDate} BETWEEN substring_index('epr.realStartTime', ',', 1) AND substring_index('epr.realStartTime', ',', -1)
|
||||
* @param fieldName
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String buildCondition(String fieldName, String value){
|
||||
// 多日期查询
|
||||
|
||||
+11
-8
@@ -7,11 +7,13 @@ import com.jero.modules.laws.documenttool.handler.AbstractConditionBase;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: yjz
|
||||
* @Date: 2023/10/13/17:05
|
||||
* @Description: in查询
|
||||
* @Description: 下拉框查询
|
||||
*/
|
||||
|
||||
@Component
|
||||
@@ -19,16 +21,17 @@ public class InConditionImpl extends AbstractConditionBase {
|
||||
|
||||
@Override
|
||||
public String buildCondition(String fieldName, String value){
|
||||
// in查询
|
||||
// 下拉框查询
|
||||
StringBuilder in = new StringBuilder();
|
||||
in.append(DocumentSplitCommon.AND).append(fieldName).append(DocumentSplitCommon.IN).append("(");
|
||||
for (String s : value.split(",")) {
|
||||
in.append("'").append(s).append("'");
|
||||
if (value.indexOf(s) != value.length() -1){
|
||||
in.append(",");
|
||||
in.append(DocumentSplitCommon.AND).append("((");
|
||||
List<String> list = Arrays.asList(value.split(","));
|
||||
for (String s : list) {
|
||||
in.append(DocumentSplitCommon.INSTR_BEGIN).append(fieldName).append(",").append("'").append(s).append("'").append(")");
|
||||
if (list.indexOf(s) != list.size() -1){
|
||||
in.append(DocumentSplitCommon.OR);
|
||||
}
|
||||
}
|
||||
in.append(")");
|
||||
in.append("))");
|
||||
return in.toString();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user