|
@@ -3,6 +3,7 @@ package com.persagy.dmp.rwd.digital.utils;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.map.MapUtil;
|
|
|
import cn.hutool.core.util.ArrayUtil;
|
|
|
+import cn.hutool.core.util.BooleanUtil;
|
|
|
import cn.hutool.core.util.ReflectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
@@ -32,6 +33,8 @@ public class ObjectDigitalCriteriaHelper {
|
|
|
|
|
|
|
|
|
public static final Set<String> DIGITAL_FIELDS = ReflectUtil.getFieldMap(ObjectDigital.class).keySet();
|
|
|
+
|
|
|
+ private static final String BIND_FLAG = "$bindFlag";
|
|
|
|
|
|
|
|
|
* 对象查询条件预处理:主要处理infos扩展内容
|
|
@@ -269,9 +272,8 @@ public class ObjectDigitalCriteriaHelper {
|
|
|
}
|
|
|
|
|
|
ObjectNode jsonNode = (ObjectNode) relationCond;
|
|
|
- if(jsonNode.get("valid") == null){
|
|
|
- jsonNode.put("valid",ValidEnum.TRUE.getType());
|
|
|
- relationCond = jsonNode;
|
|
|
+ if(jsonNode.get(BaseEntity.PROP_VALID) == null){
|
|
|
+ jsonNode.put(BaseEntity.PROP_VALID, ValidEnum.TRUE.getType());
|
|
|
}
|
|
|
|
|
|
|
|
@@ -294,14 +296,18 @@ public class ObjectDigitalCriteriaHelper {
|
|
|
criteria.remove(flagKey);
|
|
|
**/
|
|
|
StringBuilder inSql = new StringBuilder("(select "+selectKey+" from dt_relation where 1=1 ");
|
|
|
- addWhereCond(relationCond, inSql, "graphId");
|
|
|
- addWhereCond(relationCond, inSql, "graphCode");
|
|
|
- addWhereCond(relationCond, inSql, "relCode");
|
|
|
- addObjectWhereCond(relationCond, inSql, "valid");
|
|
|
- addWhereCond(relationCond, inSql, whereKey);
|
|
|
+ addWhereCond(jsonNode, inSql, "graphId");
|
|
|
+ addWhereCond(jsonNode, inSql, "graphCode");
|
|
|
+ addWhereCond(jsonNode, inSql, "relCode");
|
|
|
+ addWhereCond(jsonNode, inSql, "valid");
|
|
|
+ addWhereCond(jsonNode, inSql, whereKey);
|
|
|
inSql.append(")");
|
|
|
+
|
|
|
+ Object bindFlag = JsonNodeUtils.getNodeValue(jsonNode.get(BIND_FLAG));
|
|
|
+ boolean notBind = bindFlag != null && bindFlag instanceof Boolean && BooleanUtil.isFalse((Boolean) bindFlag);
|
|
|
+
|
|
|
ObjectNode inObj = criteria.putObject(BaseEntity.PROP_ID);
|
|
|
- inObj.put(QueryOperator.IN_SQL.getIndex(), inSql.toString());
|
|
|
+ inObj.put(notBind?QueryOperator.NOT_IN_SQL.getIndex():QueryOperator.IN_SQL.getIndex(), inSql.toString());
|
|
|
|
|
|
criteria.remove(flagKey);
|
|
|
}
|
|
@@ -313,24 +319,20 @@ public class ObjectDigitalCriteriaHelper {
|
|
|
* @param field 属性名
|
|
|
*/
|
|
|
private static void addWhereCond(JsonNode node, StringBuilder inSql, String field) {
|
|
|
- String value = (String) JsonNodeUtils.getNodeValue(node.get(field));
|
|
|
- if(StrUtil.isNotEmpty(value)) {
|
|
|
- String column = StrUtil.toUnderlineCase(field);
|
|
|
- inSql.append("and " + column + " = '" + value + "' ");
|
|
|
+ Object value = JsonNodeUtils.getNodeValue(node.get(field));
|
|
|
+ if(value == null) {
|
|
|
+ return;
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- * 添加where条件
|
|
|
- * @param node json对象
|
|
|
- * @param inSql in条件
|
|
|
- * @param field 属性名
|
|
|
- */
|
|
|
- private static void addObjectWhereCond(JsonNode node, StringBuilder inSql, String field) {
|
|
|
- Object nodeValue = JsonNodeUtils.getNodeValue(node.get(field));
|
|
|
- if(nodeValue != null) {
|
|
|
- String column = StrUtil.toUnderlineCase(field);
|
|
|
- inSql.append("and " + column + " = " + nodeValue + " ");
|
|
|
+
|
|
|
+ String column = StrUtil.toUnderlineCase(field);
|
|
|
+
|
|
|
+ if(value instanceof String) {
|
|
|
+ String stringValue = (String) value;
|
|
|
+ if(StrUtil.isNotEmpty(stringValue)) {
|
|
|
+ inSql.append("and " + column + " = '" + stringValue + "' ");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ inSql.append("and " + column + " = " + StrUtil.toString(value) + " ");
|
|
|
}
|
|
|
}
|
|
|
|