...
|
...
|
@@ -23,7 +23,6 @@ import org.thingsboard.server.common.data.DeviceProfileType; |
23
|
23
|
import org.thingsboard.server.common.data.DeviceTransportType;
|
24
|
24
|
import org.thingsboard.server.common.data.exception.ThingsboardException;
|
25
|
25
|
import org.thingsboard.server.common.data.id.DeviceProfileId;
|
26
|
|
-import org.thingsboard.server.common.data.id.EntityId;
|
27
|
26
|
import org.thingsboard.server.common.data.id.RuleChainId;
|
28
|
27
|
import org.thingsboard.server.common.data.id.TenantId;
|
29
|
28
|
import org.thingsboard.server.common.data.yunteng.common.DeleteGroup;
|
...
|
...
|
@@ -36,16 +35,18 @@ import org.thingsboard.server.common.data.yunteng.enums.OrderTypeEnum; |
36
|
35
|
import org.thingsboard.server.common.data.yunteng.enums.TkScriptFunctionType;
|
37
|
36
|
import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData;
|
38
|
37
|
import org.thingsboard.server.common.msg.queue.ServiceQueue;
|
39
|
|
-import org.thingsboard.server.transport.tcp.script.TkScriptInvokeService;
|
40
|
|
-import org.thingsboard.server.transport.tcp.script.TkScriptType;
|
41
|
38
|
import org.thingsboard.server.controller.BaseController;
|
42
|
39
|
import org.thingsboard.server.dao.yunteng.service.TkDeviceProfileService;
|
43
|
40
|
import org.thingsboard.server.dao.yunteng.service.TkDeviceScriptService;
|
|
41
|
+import org.thingsboard.server.transport.tcp.script.TkScriptInvokeService;
|
44
|
42
|
|
45
|
43
|
import java.sql.Timestamp;
|
46
|
44
|
import java.time.LocalDateTime;
|
47
|
45
|
import java.time.ZoneOffset;
|
48
|
|
-import java.util.*;
|
|
46
|
+import java.util.HashMap;
|
|
47
|
+import java.util.List;
|
|
48
|
+import java.util.Map;
|
|
49
|
+import java.util.UUID;
|
49
|
50
|
import java.util.concurrent.TimeUnit;
|
50
|
51
|
|
51
|
52
|
import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.*;
|
...
|
...
|
@@ -174,16 +175,24 @@ public class TkDeviceScriptController extends BaseController { |
174
|
175
|
throws ThingsboardException {
|
175
|
176
|
try {
|
176
|
177
|
String script = inputParams.get("script").asText();
|
|
178
|
+ String scriptType = inputParams.get("type").asText();
|
|
179
|
+ String jsMethod = inputParams.has("method")?inputParams.get("method").asText():"";
|
177
|
180
|
String jsParam = inputParams.get("params").asText();
|
178
|
181
|
|
179
|
182
|
String output = "";
|
180
|
183
|
String errorText = "";
|
181
|
184
|
ScriptEngine engine = null;
|
182
|
185
|
try {
|
183
|
|
- UUID scriptId = jsEngine.eval(null,TkScriptType.TCP_TRANSPORT_SCRIPT, script).get();
|
|
186
|
+ UUID scriptId;
|
|
187
|
+ if(StringUtils.isEmpty(jsMethod)){
|
|
188
|
+ scriptId = jsEngine.eval(null,scriptType, script,jsParam).get();
|
|
189
|
+ }else{
|
|
190
|
+ scriptId = jsEngine.eval(null,scriptType, script,jsMethod,jsParam).get();
|
|
191
|
+ }
|
|
192
|
+
|
184
|
193
|
ListenableFuture<String> result =
|
185
|
194
|
Futures.transformAsync(
|
186
|
|
- jsEngine.invokeFunction(scriptId, jsParam),
|
|
195
|
+ StringUtils.isEmpty(jsMethod)?jsEngine.invokeFunction(scriptId, jsParam):jsEngine.invokeFunction(scriptId, jsMethod,jsParam),
|
187
|
196
|
o -> {
|
188
|
197
|
try {
|
189
|
198
|
JsonElement json = parser.parse(o.toString());
|
...
|
...
|
|