diff --git a/jetlinks-components/common-component/src/main/java/org/jetlinks/community/reactorql/term/FixedTermTypeSupport.java b/jetlinks-components/common-component/src/main/java/org/jetlinks/community/reactorql/term/FixedTermTypeSupport.java index 21928e43e..e4f2ac672 100644 --- a/jetlinks-components/common-component/src/main/java/org/jetlinks/community/reactorql/term/FixedTermTypeSupport.java +++ b/jetlinks-components/common-component/src/main/java/org/jetlinks/community/reactorql/term/FixedTermTypeSupport.java @@ -1,5 +1,6 @@ package org.jetlinks.community.reactorql.term; +import com.google.common.collect.Sets; import lombok.Getter; import org.hswebframework.ezorm.core.param.Term; import org.hswebframework.ezorm.rdb.operator.builder.fragments.NativeSql; @@ -106,14 +107,16 @@ protected void appendFunction(String column, PrepareSqlFragments fragments) { }; private final String text; + private final boolean needValue; private final Set supportTypes; private final String function; - private FixedTermTypeSupport(String text, String function, String... supportTypes) { + FixedTermTypeSupport(String text, String function, String... supportTypes) { this.text = text; this.function = function; - this.supportTypes = new HashSet<>(Arrays.asList(supportTypes)); + this.needValue = true; + this.supportTypes = Sets.newHashSet(supportTypes); } @Override @@ -140,21 +143,18 @@ public SqlFragments createSql(String column, Object value, Term term) { PrepareSqlFragments fragments = PrepareSqlFragments.of(); appendFunction(column, fragments); - if (term.getOptions().contains(OPTIONS_NATIVE_SQL)) { - value = NativeSql.of(String.valueOf(value)); - } - - value = convertValue(value, term); - if (value instanceof NativeSql) { fragments .addSql(((NativeSql) value).getSql()) - .addParameter(((NativeSql) value).getParameters()); - } else { - fragments.addSql("?") - .addParameter(value); + .addParameter(((NativeSql) value).getParameters()) + .addSql(")"); + } else if (needValue) { + value = convertValue(value, term); + fragments + .addSql("?") + .addParameter(value) + .addSql(")"); } - fragments.addSql(")"); return fragments; } diff --git a/jetlinks-components/things-component/src/main/java/org/jetlinks/community/things/metric/AbstractPropertyMetricManager.java b/jetlinks-components/things-component/src/main/java/org/jetlinks/community/things/metric/AbstractPropertyMetricManager.java index aa6af027b..8fb363505 100644 --- a/jetlinks-components/things-component/src/main/java/org/jetlinks/community/things/metric/AbstractPropertyMetricManager.java +++ b/jetlinks-components/things-component/src/main/java/org/jetlinks/community/things/metric/AbstractPropertyMetricManager.java @@ -36,8 +36,7 @@ public Mono getPropertyMetric(ThingId thingId, String property, private Mono loadFromTemplate(ThingId thingId, String property, String metric) { return registry .getThing(thingId.getType(), thingId.getId()) - .flatMap(Thing::getTemplate) - .flatMap(ThingTemplate::getMetadata) + .flatMap(Thing::getMetadata) .flatMap(metadata -> Mono .justOrEmpty( metadata