diff --git a/iot-common-core/pom.xml b/iot-common-core/pom.xml
index 5f61357..7380466 100755
--- a/iot-common-core/pom.xml
+++ b/iot-common-core/pom.xml
@@ -6,7 +6,7 @@
iot-iita-core
cc.iotkit
- 1.0.0
+ 1.0.1
iot-common-core
diff --git a/iot-common-core/src/main/java/cc/iotkit/common/enums/ThingDataType.java b/iot-common-core/src/main/java/cc/iotkit/common/enums/ThingDataType.java
new file mode 100755
index 0000000..2ee5faf
--- /dev/null
+++ b/iot-common-core/src/main/java/cc/iotkit/common/enums/ThingDataType.java
@@ -0,0 +1,43 @@
+package cc.iotkit.common.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * 物模型数据类型
+ *
+ * @author sjg
+ */
+@Getter
+@AllArgsConstructor
+public enum ThingDataType {
+ /**
+ * int 整数
+ */
+ INT("int32", "整数"),
+ /**
+ * 小数
+ */
+ FLOAT("float", "小数"),
+ /**
+ * 布尔
+ */
+ BOOL("bool", "布尔"),
+ /**
+ * 枚举
+ */
+ ENUM("enum", "枚举"),
+ /**
+ * 文本字符
+ */
+ TEXT("text", "文本字符"),
+ /**
+ * 日期
+ */
+ DATE("date", "时间戳"),
+ ;
+
+ private final String code;
+ private final String info;
+
+}
diff --git a/iot-common-core/src/main/java/cc/iotkit/common/utils/JsonUtils.java b/iot-common-core/src/main/java/cc/iotkit/common/utils/JsonUtils.java
index 244f5d6..9fb850c 100755
--- a/iot-common-core/src/main/java/cc/iotkit/common/utils/JsonUtils.java
+++ b/iot-common-core/src/main/java/cc/iotkit/common/utils/JsonUtils.java
@@ -1,6 +1,5 @@
package cc.iotkit.common.utils;
-import cn.hutool.core.exceptions.UtilException;
import cn.hutool.core.lang.Dict;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.PrimitiveArrayUtil;
@@ -28,7 +27,7 @@ public class JsonUtils {
static {
try {
OBJECT_MAPPER = SpringUtils.getBean(ObjectMapper.class);
- } catch (UtilException e) {
+ } catch (Exception e) {
OBJECT_MAPPER = new ObjectMapper();
}
}
diff --git a/iot-common-doc/pom.xml b/iot-common-doc/pom.xml
index 807471e..d8c6a96 100755
--- a/iot-common-doc/pom.xml
+++ b/iot-common-doc/pom.xml
@@ -5,7 +5,7 @@
iot-iita-core
cc.iotkit
- 1.0.0
+ 1.0.1
4.0.0
diff --git a/iot-common-excel/pom.xml b/iot-common-excel/pom.xml
index ed700c1..745d62e 100755
--- a/iot-common-excel/pom.xml
+++ b/iot-common-excel/pom.xml
@@ -5,7 +5,7 @@
iot-iita-core
cc.iotkit
- 1.0.0
+ 1.0.1
4.0.0
diff --git a/iot-common-log/pom.xml b/iot-common-log/pom.xml
index 03f6646..6692feb 100755
--- a/iot-common-log/pom.xml
+++ b/iot-common-log/pom.xml
@@ -5,7 +5,7 @@
iot-iita-core
cc.iotkit
- 1.0.0
+ 1.0.1
4.0.0
diff --git a/iot-common-oss/pom.xml b/iot-common-oss/pom.xml
index 4109be1..2ca2521 100755
--- a/iot-common-oss/pom.xml
+++ b/iot-common-oss/pom.xml
@@ -5,7 +5,7 @@
iot-iita-core
cc.iotkit
- 1.0.0
+ 1.0.1
4.0.0
diff --git a/iot-common-redis/pom.xml b/iot-common-redis/pom.xml
index 0961750..897c50b 100755
--- a/iot-common-redis/pom.xml
+++ b/iot-common-redis/pom.xml
@@ -5,7 +5,7 @@
iot-iita-core
cc.iotkit
- 1.0.0
+ 1.0.1
4.0.0
diff --git a/iot-common-satoken/pom.xml b/iot-common-satoken/pom.xml
index b7b19a1..2f9e6f2 100755
--- a/iot-common-satoken/pom.xml
+++ b/iot-common-satoken/pom.xml
@@ -5,7 +5,7 @@
iot-iita-core
cc.iotkit
- 1.0.0
+ 1.0.1
4.0.0
diff --git a/iot-common-tenant/pom.xml b/iot-common-tenant/pom.xml
index e62d761..85ee084 100755
--- a/iot-common-tenant/pom.xml
+++ b/iot-common-tenant/pom.xml
@@ -5,7 +5,7 @@
iot-iita-core
cc.iotkit
- 1.0.0
+ 1.0.1
4.0.0
diff --git a/iot-common-thing/pom.xml b/iot-common-thing/pom.xml
index 9046d96..cd64446 100755
--- a/iot-common-thing/pom.xml
+++ b/iot-common-thing/pom.xml
@@ -5,7 +5,7 @@
iot-iita-core
cc.iotkit
- 1.0.0
+ 1.0.1
4.0.0
diff --git a/iot-common-web/pom.xml b/iot-common-web/pom.xml
index 6cd38f8..e141faa 100755
--- a/iot-common-web/pom.xml
+++ b/iot-common-web/pom.xml
@@ -5,7 +5,7 @@
iot-iita-core
cc.iotkit
- 1.0.0
+ 1.0.1
4.0.0
diff --git a/iot-common-websocket/pom.xml b/iot-common-websocket/pom.xml
index efd086c..ec7dc71 100755
--- a/iot-common-websocket/pom.xml
+++ b/iot-common-websocket/pom.xml
@@ -5,7 +5,7 @@
iot-iita-core
cc.iotkit
- 1.0.0
+ 1.0.1
4.0.0
diff --git a/iot-message-bus/iot-message-core/pom.xml b/iot-message-bus/iot-message-core/pom.xml
index ab7cceb..abf505b 100755
--- a/iot-message-bus/iot-message-core/pom.xml
+++ b/iot-message-bus/iot-message-core/pom.xml
@@ -5,7 +5,7 @@
iot-message-bus
cc.iotkit
- 1.0.0
+ 1.0.1
4.0.0
diff --git a/iot-message-bus/iot-message-event-bus/pom.xml b/iot-message-bus/iot-message-event-bus/pom.xml
index 6405b2b..1a34eb4 100755
--- a/iot-message-bus/iot-message-event-bus/pom.xml
+++ b/iot-message-bus/iot-message-event-bus/pom.xml
@@ -5,7 +5,7 @@
iot-message-bus
cc.iotkit
- 1.0.0
+ 1.0.1
4.0.0
diff --git a/iot-message-bus/iot-message-rocketmq/pom.xml b/iot-message-bus/iot-message-rocketmq/pom.xml
index 45820c4..213dffc 100755
--- a/iot-message-bus/iot-message-rocketmq/pom.xml
+++ b/iot-message-bus/iot-message-rocketmq/pom.xml
@@ -5,7 +5,7 @@
iot-message-bus
cc.iotkit
- 1.0.0
+ 1.0.1
4.0.0
diff --git a/iot-message-bus/pom.xml b/iot-message-bus/pom.xml
index a44c8ad..9fd5c82 100755
--- a/iot-message-bus/pom.xml
+++ b/iot-message-bus/pom.xml
@@ -5,7 +5,7 @@
iot-iita-core
cc.iotkit
- 1.0.0
+ 1.0.1
4.0.0
pom
diff --git a/iot-script-engine/pom.xml b/iot-script-engine/pom.xml
index 3b6adfb..c2da2b0 100755
--- a/iot-script-engine/pom.xml
+++ b/iot-script-engine/pom.xml
@@ -6,7 +6,7 @@
iot-iita-core
cc.iotkit
- 1.0.0
+ 1.0.1
iot-script-engine
diff --git a/iot-script-engine/src/main/java/cc/iotkit/script/IScriptEngine.java b/iot-script-engine/src/main/java/cc/iotkit/script/IScriptEngine.java
index 5161bbe..90eaffe 100755
--- a/iot-script-engine/src/main/java/cc/iotkit/script/IScriptEngine.java
+++ b/iot-script-engine/src/main/java/cc/iotkit/script/IScriptEngine.java
@@ -12,4 +12,6 @@ public interface IScriptEngine {
T invokeMethod(TypeReference type, String methodName, Object... args);
+ String invokeMethod(String methodName, String args);
+
}
diff --git a/iot-script-engine/src/main/java/cc/iotkit/script/JavaScriptEngine.java b/iot-script-engine/src/main/java/cc/iotkit/script/JavaScriptEngine.java
index 5982af0..7ac1f64 100755
--- a/iot-script-engine/src/main/java/cc/iotkit/script/JavaScriptEngine.java
+++ b/iot-script-engine/src/main/java/cc/iotkit/script/JavaScriptEngine.java
@@ -54,12 +54,9 @@ public class JavaScriptEngine implements IScriptEngine {
@Override
public T invokeMethod(TypeReference type, String methodName, Object... args) {
Value member = jsScript.getMember("invoke");
-
StringBuilder sbArgs = formatArgs(args);
-
//通过调用invoke方法将目标方法返回结果转成json
Value rst = member.execute(methodName, args);
-
String json = rst.asString();
log.info("invoke script={}, args={}, result={}", methodName, sbArgs, json);
@@ -67,10 +64,23 @@ public class JavaScriptEngine implements IScriptEngine {
if (json == null || "null".equals(json)) {
return null;
}
-
return JsonUtils.parseObject(json, type);
}
+ @Override
+ public String invokeMethod(String methodName, String args) {
+ Value member = jsScript.getMember("invoke");
+ //通过调用invoke方法将目标方法返回结果转成json
+ Value rst = member.execute(methodName, JsonUtils.parseArray(args, Object.class));
+ String json = rst.asString();
+ log.info("invoke script={}, args={}, result={}", methodName, args, json);
+ //没有返回值
+ if (json == null || "null".equals(json)) {
+ return null;
+ }
+ return json;
+ }
+
private static StringBuilder formatArgs(Object[] args) {
StringBuilder sbArgs = new StringBuilder("[");
//将入参转成json
diff --git a/iot-script-engine/src/main/java/cc/iotkit/script/ScriptEngineFactory.java b/iot-script-engine/src/main/java/cc/iotkit/script/ScriptEngineFactory.java
index 0aa6375..f431102 100755
--- a/iot-script-engine/src/main/java/cc/iotkit/script/ScriptEngineFactory.java
+++ b/iot-script-engine/src/main/java/cc/iotkit/script/ScriptEngineFactory.java
@@ -36,6 +36,11 @@ public class ScriptEngineFactory {
public T invokeMethod(TypeReference type, String methodName, Object... args) {
return null;
}
+
+ @Override
+ public String invokeMethod(String methodName, String args) {
+ return null;
+ }
};
case "js":
default:
@@ -43,4 +48,10 @@ public class ScriptEngineFactory {
}
}
+ public static IScriptEngine getJsEngine(String script) {
+ JavaScriptEngine scriptEngine = new JavaScriptEngine();
+ scriptEngine.setScript(script);
+ return scriptEngine;
+ }
+
}
diff --git a/pom.xml b/pom.xml
index fdeff7e..3ccd34b 100755
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
cc.iotkit
iot-iita-core
- 1.0.0
+ 1.0.1
pom