|
@@ -27,6 +27,7 @@ import org.thingsboard.server.common.data.id.RuleChainId; |
|
@@ -27,6 +27,7 @@ import org.thingsboard.server.common.data.id.RuleChainId; |
27
|
import org.thingsboard.server.common.data.id.TenantId;
|
27
|
import org.thingsboard.server.common.data.id.TenantId;
|
28
|
import org.thingsboard.server.common.data.yunteng.common.DeleteGroup;
|
28
|
import org.thingsboard.server.common.data.yunteng.common.DeleteGroup;
|
29
|
import org.thingsboard.server.common.data.yunteng.core.exception.ThingsKitException;
|
29
|
import org.thingsboard.server.common.data.yunteng.core.exception.ThingsKitException;
|
|
|
30
|
+import org.thingsboard.server.common.data.yunteng.core.exception.TkDataValidationException;
|
30
|
import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage;
|
31
|
import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage;
|
31
|
import org.thingsboard.server.common.data.yunteng.dto.DeleteDTO;
|
32
|
import org.thingsboard.server.common.data.yunteng.dto.DeleteDTO;
|
32
|
import org.thingsboard.server.common.data.yunteng.dto.DeviceProfileDTO;
|
33
|
import org.thingsboard.server.common.data.yunteng.dto.DeviceProfileDTO;
|
|
@@ -37,8 +38,6 @@ import org.thingsboard.server.common.data.yunteng.enums.TkScriptFunctionType; |
|
@@ -37,8 +38,6 @@ import org.thingsboard.server.common.data.yunteng.enums.TkScriptFunctionType; |
37
|
import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData;
|
38
|
import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData;
|
38
|
import org.thingsboard.server.common.msg.queue.ServiceQueue;
|
39
|
import org.thingsboard.server.common.msg.queue.ServiceQueue;
|
39
|
import org.thingsboard.server.controller.BaseController;
|
40
|
import org.thingsboard.server.controller.BaseController;
|
40
|
-import org.thingsboard.server.dao.exception.DataValidationException;
|
|
|
41
|
-import org.thingsboard.server.dao.yunteng.service.TkDeviceProfileService;
|
|
|
42
|
import org.thingsboard.server.dao.yunteng.service.TkDeviceScriptService;
|
41
|
import org.thingsboard.server.dao.yunteng.service.TkDeviceScriptService;
|
43
|
import org.thingsboard.server.transport.tcp.script.TkScriptInvokeService;
|
42
|
import org.thingsboard.server.transport.tcp.script.TkScriptInvokeService;
|
44
|
|
43
|
|
|
@@ -60,7 +59,6 @@ public class TkDeviceScriptController extends BaseController { |
|
@@ -60,7 +59,6 @@ public class TkDeviceScriptController extends BaseController { |
60
|
private static final JsonParser parser = new JsonParser();
|
59
|
private static final JsonParser parser = new JsonParser();
|
61
|
private static final ObjectMapper objectMapper = new ObjectMapper();
|
60
|
private static final ObjectMapper objectMapper = new ObjectMapper();
|
62
|
private final TkDeviceScriptService scriptService;
|
61
|
private final TkDeviceScriptService scriptService;
|
63
|
- private final TkDeviceProfileService ytDeviceProfileService;
|
|
|
64
|
private final TkScriptInvokeService jsEngine;
|
62
|
private final TkScriptInvokeService jsEngine;
|
65
|
|
63
|
|
66
|
@PostMapping()
|
64
|
@PostMapping()
|
|
@@ -215,18 +213,18 @@ public class TkDeviceScriptController extends BaseController { |
|
@@ -215,18 +213,18 @@ public class TkDeviceScriptController extends BaseController { |
215
|
public ResponseEntity<String> modbus(@RequestBody TkDeviceRpcDTO inputParams)
|
213
|
public ResponseEntity<String> modbus(@RequestBody TkDeviceRpcDTO inputParams)
|
216
|
throws ThingsKitException {
|
214
|
throws ThingsKitException {
|
217
|
if(StringUtils.isEmpty(inputParams.getDeviceCode())){
|
215
|
if(StringUtils.isEmpty(inputParams.getDeviceCode())){
|
218
|
- throw new DataValidationException(String.format(ErrorMessage.NEED_MAIN_PARAMETER.getMessage(),"设备地址码"));
|
216
|
+ throw new TkDataValidationException(String.format(ErrorMessage.NEED_MAIN_PARAMETER.getMessage(),"设备地址码"));
|
219
|
}
|
217
|
}
|
220
|
if(StringUtils.isEmpty(inputParams.getMethod()) || null == inputParams.getCrc() ||
|
218
|
if(StringUtils.isEmpty(inputParams.getMethod()) || null == inputParams.getCrc() ||
|
221
|
null ==inputParams.getRegisterAddress()){
|
219
|
null ==inputParams.getRegisterAddress()){
|
222
|
- throw new DataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage());
|
220
|
+ throw new TkDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage());
|
223
|
}
|
221
|
}
|
224
|
if(null !=inputParams.getRegisterNumber() && null !=inputParams.getRegisterValues() &&
|
222
|
if(null !=inputParams.getRegisterNumber() && null !=inputParams.getRegisterValues() &&
|
225
|
!inputParams.getRegisterValues().isEmpty()){
|
223
|
!inputParams.getRegisterValues().isEmpty()){
|
226
|
List<Integer> registerValues = inputParams.getRegisterValues();
|
224
|
List<Integer> registerValues = inputParams.getRegisterValues();
|
227
|
for (Integer value : registerValues){
|
225
|
for (Integer value : registerValues){
|
228
|
if(null == value){
|
226
|
if(null == value){
|
229
|
- throw new DataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage());
|
227
|
+ throw new TkDataValidationException(ErrorMessage.REGISTER_VALUE_IS_NONE.getMessage());
|
230
|
}
|
228
|
}
|
231
|
}
|
229
|
}
|
232
|
}
|
230
|
}
|