...
|
...
|
@@ -36,11 +36,14 @@ import org.thingsboard.server.common.data.EntityInfo; |
36
|
36
|
import org.thingsboard.server.common.data.StringUtils;
|
37
|
37
|
import org.thingsboard.server.common.data.exception.ThingsboardException;
|
38
|
38
|
import org.thingsboard.server.common.data.id.DeviceProfileId;
|
|
39
|
+import org.thingsboard.server.common.data.id.RuleChainId;
|
39
|
40
|
import org.thingsboard.server.common.data.id.TenantId;
|
40
|
41
|
import org.thingsboard.server.common.data.page.PageData;
|
41
|
42
|
import org.thingsboard.server.common.data.page.PageLink;
|
|
43
|
+import org.thingsboard.server.common.data.yunteng.dto.BatchUpdateDeviceProfileDTO;
|
42
|
44
|
import org.thingsboard.server.dao.resource.ImageService;
|
43
|
45
|
import org.thingsboard.server.dao.timeseries.TimeseriesService;
|
|
46
|
+import org.thingsboard.server.dao.yunteng.service.TkDeviceProfileService;
|
44
|
47
|
import org.thingsboard.server.queue.util.TbCoreComponent;
|
45
|
48
|
import org.thingsboard.server.service.entitiy.device.profile.TbDeviceProfileService;
|
46
|
49
|
import org.thingsboard.server.service.security.model.SecurityUser;
|
...
|
...
|
@@ -82,6 +85,7 @@ public class DeviceProfileController extends BaseController { |
82
|
85
|
|
83
|
86
|
@Autowired
|
84
|
87
|
private TimeseriesService timeseriesService;
|
|
88
|
+ private final TkDeviceProfileService tkDeviceProfileService;
|
85
|
89
|
|
86
|
90
|
@ApiOperation(value = "Get Device Profile (getDeviceProfileById)",
|
87
|
91
|
notes = "Fetch the Device Profile object based on the provided Device Profile Id. " +
|
...
|
...
|
@@ -199,6 +203,25 @@ public class DeviceProfileController extends BaseController { |
199
|
203
|
return tbDeviceProfileService.save(deviceProfile, getCurrentUser());
|
200
|
204
|
}
|
201
|
205
|
|
|
206
|
+ //thingskit
|
|
207
|
+ @ApiOperation(value = "批量更新产品的规则链")
|
|
208
|
+ @PreAuthorize("@check.checkPermissions({'TENANT_ADMIN'},{'api:yt:deviceProfile:batch:update:ruleChain'})")
|
|
209
|
+ @RequestMapping(value = "/batch/change/ruleChain", method = RequestMethod.POST)
|
|
210
|
+ @ResponseBody
|
|
211
|
+ public Boolean batchUpdateDeviceProfileRuleChainId(
|
|
212
|
+ @RequestBody BatchUpdateDeviceProfileDTO dto) throws Exception {
|
|
213
|
+ //校验
|
|
214
|
+ tkDeviceProfileService.checkDeviceProfilesCanChangeRuleChain(dto.getDeviceProfileIds(),getTenantId());
|
|
215
|
+ String ruleChainId = dto.getTargetRuleChainId();
|
|
216
|
+ for (String deviceProfileId :dto.getDeviceProfileIds()){
|
|
217
|
+ DeviceProfile deviceProfile = deviceProfileService.findDeviceProfileById(getTenantId(),new DeviceProfileId(UUID.fromString(deviceProfileId)));
|
|
218
|
+ deviceProfile.setDefaultRuleChainId(new RuleChainId(UUID.fromString(ruleChainId)));
|
|
219
|
+ checkEntity(deviceProfile.getId(), deviceProfile, Resource.DEVICE_PROFILE);
|
|
220
|
+ tbDeviceProfileService.save(deviceProfile, getCurrentUser());
|
|
221
|
+ }
|
|
222
|
+ return true;
|
|
223
|
+ }
|
|
224
|
+
|
202
|
225
|
@ApiOperation(value = "Delete device profile (deleteDeviceProfile)",
|
203
|
226
|
notes = "Deletes the device profile. Referencing non-existing device profile Id will cause an error. " +
|
204
|
227
|
"Can't delete the device profile if it is referenced by existing devices." + TENANT_AUTHORITY_PARAGRAPH,
|
...
|
...
|
|