...
|
...
|
@@ -38,6 +38,7 @@ import org.thingsboard.server.common.data.yunteng.dto.TkDeviceScriptDTO; |
38
|
38
|
import org.thingsboard.server.common.data.yunteng.enums.OrderTypeEnum;
|
39
|
39
|
import org.thingsboard.server.common.data.yunteng.utils.tools.YtPageData;
|
40
|
40
|
import org.thingsboard.server.common.msg.queue.ServiceQueue;
|
|
41
|
+import org.thingsboard.server.common.yunteng.script.YtScriptFactory;
|
41
|
42
|
import org.thingsboard.server.common.yunteng.script.YtScriptInvokeService;
|
42
|
43
|
import org.thingsboard.server.common.yunteng.script.YtScriptType;
|
43
|
44
|
import org.thingsboard.server.controller.BaseController;
|
...
|
...
|
@@ -73,16 +74,7 @@ public class TkDeviceScriptController extends BaseController { |
73
|
74
|
String tenantId = getCurrentUser().getCurrentTenantId();
|
74
|
75
|
scriptDTO.setTenantId(tenantId);
|
75
|
76
|
scriptService.validateFormdata(scriptDTO, created);
|
76
|
|
- /** 业务流程 1/3.编辑时同步刷新相关的设备配置 2/3.处理TB业务逻辑 3/3.处理业务平台的业务逻辑 */
|
77
|
|
- if (!created) {
|
78
|
|
- List<DeviceProfileDTO> usedProfiles = ytDeviceProfileService.findDeviceProfile(tenantId, id);
|
79
|
|
- for (DeviceProfileDTO profile : usedProfiles) {
|
80
|
|
- DeviceProfile tbDeviceProfile =
|
81
|
|
- buildTbDeviceProfileFromDeviceProfileDTO(
|
82
|
|
- profile, scriptDTO.getTenantId(), scriptDTO.getConvertJs());
|
83
|
|
- updateTbDeviceProfile(tbDeviceProfile);
|
84
|
|
- }
|
85
|
|
- }
|
|
77
|
+
|
86
|
78
|
|
87
|
79
|
String creator = getCurrentUser().getCurrentUserId();
|
88
|
80
|
scriptDTO.setCreator(creator);
|
...
|
...
|
@@ -96,9 +88,31 @@ public class TkDeviceScriptController extends BaseController { |
96
|
88
|
public ResponseEntity<Boolean> updateScriptStatus(
|
97
|
89
|
@PathVariable("id") String id, @PathVariable("status") Integer status)
|
98
|
90
|
throws ThingsboardException {
|
|
91
|
+ /** 业务流程 1/3.编辑时同步刷新相关的设备配置 2/3.处理TB业务逻辑 3/3.处理业务平台的业务逻辑 */
|
|
92
|
+ String tenantId = getCurrentUser().getCurrentTenantId();
|
|
93
|
+ TkDeviceScriptDTO scriptDTO = scriptService.getDeviceScript(tenantId,id).get();
|
|
94
|
+ if(scriptDTO ==null || scriptDTO.getStatus().equals(status)){
|
|
95
|
+ return ResponseEntity.ok(false);
|
|
96
|
+ }
|
|
97
|
+ String convertJs = YtScriptFactory.INCLUD_ORIGINAL_DATA;
|
|
98
|
+
|
|
99
|
+ if(1 == scriptDTO.getStatus()){
|
|
100
|
+ if(scriptDTO.isSaveOriginalData()){
|
|
101
|
+ convertJs += scriptDTO.getConvertJs();
|
|
102
|
+ }else{
|
|
103
|
+ convertJs = scriptDTO.getConvertJs();
|
|
104
|
+ }
|
99
|
105
|
|
100
|
|
- return ResponseEntity.ok(
|
101
|
|
- scriptService.updateScriptStatus(getCurrentUser().getCurrentTenantId(), id, status));
|
|
106
|
+ }
|
|
107
|
+ List<DeviceProfileDTO> usedProfiles = ytDeviceProfileService.findDeviceProfile(tenantId, id);
|
|
108
|
+ for (DeviceProfileDTO profile : usedProfiles) {
|
|
109
|
+ DeviceProfile tbDeviceProfile =
|
|
110
|
+ buildTbDeviceProfileFromDeviceProfileDTO(
|
|
111
|
+ profile, tenantId, convertJs);
|
|
112
|
+ updateTbDeviceProfile(tbDeviceProfile);
|
|
113
|
+ }
|
|
114
|
+ scriptService.updateScriptStatus(tenantId, id, status);
|
|
115
|
+ return ResponseEntity.ok(true);
|
102
|
116
|
}
|
103
|
117
|
|
104
|
118
|
/**
|
...
|
...
|
|