Showing
4 changed files
with
19 additions
and
17 deletions
@@ -17,6 +17,7 @@ import org.thingsboard.server.common.data.exception.ThingsboardException; | @@ -17,6 +17,7 @@ import org.thingsboard.server.common.data.exception.ThingsboardException; | ||
17 | import org.thingsboard.server.common.data.id.TenantId; | 17 | import org.thingsboard.server.common.data.id.TenantId; |
18 | import org.thingsboard.server.common.data.id.UserId; | 18 | import org.thingsboard.server.common.data.id.UserId; |
19 | import org.thingsboard.server.common.data.plugin.ComponentLifecycleEvent; | 19 | import org.thingsboard.server.common.data.plugin.ComponentLifecycleEvent; |
20 | +import org.thingsboard.server.common.data.rule.RuleChain; | ||
20 | import org.thingsboard.server.common.data.yunteng.common.DeleteGroup; | 21 | import org.thingsboard.server.common.data.yunteng.common.DeleteGroup; |
21 | import org.thingsboard.server.common.data.yunteng.common.UpdateGroup; | 22 | import org.thingsboard.server.common.data.yunteng.common.UpdateGroup; |
22 | import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage; | 23 | import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage; |
@@ -25,11 +26,13 @@ import org.thingsboard.server.common.data.yunteng.dto.MenuDTO; | @@ -25,11 +26,13 @@ import org.thingsboard.server.common.data.yunteng.dto.MenuDTO; | ||
25 | import org.thingsboard.server.common.data.yunteng.dto.TenantDTO; | 26 | import org.thingsboard.server.common.data.yunteng.dto.TenantDTO; |
26 | import org.thingsboard.server.common.data.yunteng.dto.UserDTO; | 27 | import org.thingsboard.server.common.data.yunteng.dto.UserDTO; |
27 | import org.thingsboard.server.common.data.yunteng.dto.request.TenantReqDTO; | 28 | import org.thingsboard.server.common.data.yunteng.dto.request.TenantReqDTO; |
29 | +import org.thingsboard.server.common.data.yunteng.enums.DeviceTypeEnum; | ||
28 | import org.thingsboard.server.common.data.yunteng.enums.OrderTypeEnum; | 30 | import org.thingsboard.server.common.data.yunteng.enums.OrderTypeEnum; |
29 | import org.thingsboard.server.common.data.yunteng.utils.i18n.MessageUtils; | 31 | import org.thingsboard.server.common.data.yunteng.utils.i18n.MessageUtils; |
30 | import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData; | 32 | import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData; |
31 | import org.thingsboard.server.controller.BaseController; | 33 | import org.thingsboard.server.controller.BaseController; |
32 | import org.thingsboard.server.dao.exception.DataValidationException; | 34 | import org.thingsboard.server.dao.exception.DataValidationException; |
35 | +import org.thingsboard.server.dao.rule.RuleChainService; | ||
33 | import org.thingsboard.server.dao.tenant.TenantService; | 36 | import org.thingsboard.server.dao.tenant.TenantService; |
34 | import org.thingsboard.server.dao.yunteng.service.MenuService; | 37 | import org.thingsboard.server.dao.yunteng.service.MenuService; |
35 | import org.thingsboard.server.dao.yunteng.service.TkTenantService; | 38 | import org.thingsboard.server.dao.yunteng.service.TkTenantService; |
@@ -65,6 +68,7 @@ public class TkAdminController extends BaseController { | @@ -65,6 +68,7 @@ public class TkAdminController extends BaseController { | ||
65 | private final InstallScripts installScripts; | 68 | private final InstallScripts installScripts; |
66 | private final TbUserService tbUserService; | 69 | private final TbUserService tbUserService; |
67 | private final TbTenantService tbTenantService; | 70 | private final TbTenantService tbTenantService; |
71 | + private final RuleChainService ruleChainService; | ||
68 | 72 | ||
69 | @PostMapping("/tenant") | 73 | @PostMapping("/tenant") |
70 | @Deprecated | 74 | @Deprecated |
@@ -286,6 +290,11 @@ public class TkAdminController extends BaseController { | @@ -286,6 +290,11 @@ public class TkAdminController extends BaseController { | ||
286 | installScripts.createDefaultRuleChains(tbTenant.getId()); | 290 | installScripts.createDefaultRuleChains(tbTenant.getId()); |
287 | installScripts.createDefaultEdgeRuleChains(tbTenant.getId()); | 291 | installScripts.createDefaultEdgeRuleChains(tbTenant.getId()); |
288 | } | 292 | } |
293 | + //Thingskit function | ||
294 | + RuleChain ruleChain =ruleChainService.getRootTenantRuleChain(tbTenant.getId()); | ||
295 | + deviceProfileService.createDeviceProfile(tbTenant.getId(),"默认MQTT网关设备", DeviceTypeEnum.GATEWAY,ruleChain.getId()); | ||
296 | + deviceProfileService.createDeviceProfile(tbTenant.getId(),"默认MQTT直连设备", DeviceTypeEnum.DIRECT_CONNECTION,ruleChain.getId()); | ||
297 | + | ||
289 | tenantProfileCache.evict(tbTenant.getId()); | 298 | tenantProfileCache.evict(tbTenant.getId()); |
290 | tbClusterService.onTenantChange(tbTenant, null); | 299 | tbClusterService.onTenantChange(tbTenant, null); |
291 | tbClusterService.broadcastEntityStateChangeEvent( | 300 | tbClusterService.broadcastEntityStateChangeEvent( |
@@ -20,6 +20,7 @@ import org.thingsboard.server.common.data.DeviceProfile; | @@ -20,6 +20,7 @@ import org.thingsboard.server.common.data.DeviceProfile; | ||
20 | import org.thingsboard.server.common.data.DeviceProfileInfo; | 20 | import org.thingsboard.server.common.data.DeviceProfileInfo; |
21 | import org.thingsboard.server.common.data.EntityInfo; | 21 | import org.thingsboard.server.common.data.EntityInfo; |
22 | import org.thingsboard.server.common.data.id.DeviceProfileId; | 22 | import org.thingsboard.server.common.data.id.DeviceProfileId; |
23 | +import org.thingsboard.server.common.data.id.RuleChainId; | ||
23 | import org.thingsboard.server.common.data.id.TenantId; | 24 | import org.thingsboard.server.common.data.id.TenantId; |
24 | import org.thingsboard.server.common.data.page.PageData; | 25 | import org.thingsboard.server.common.data.page.PageData; |
25 | import org.thingsboard.server.common.data.page.PageLink; | 26 | import org.thingsboard.server.common.data.page.PageLink; |
@@ -57,7 +58,7 @@ public interface DeviceProfileService extends EntityDaoService { | @@ -57,7 +58,7 @@ public interface DeviceProfileService extends EntityDaoService { | ||
57 | DeviceProfile createDefaultDeviceProfile(TenantId tenantId); | 58 | DeviceProfile createDefaultDeviceProfile(TenantId tenantId); |
58 | 59 | ||
59 | //thingskit | 60 | //thingskit |
60 | - DeviceProfile createDeviceProfile(TenantId tenantId, String name, DeviceTypeEnum deviceType); | 61 | + DeviceProfile createDeviceProfile(TenantId tenantId, String name, DeviceTypeEnum deviceType, RuleChainId ruleChainId); |
61 | 62 | ||
62 | ListenableFuture<List<DeviceProfile>> findByDataCombinationIsTrue(); | 63 | ListenableFuture<List<DeviceProfile>> findByDataCombinationIsTrue(); |
63 | 64 |
@@ -37,10 +37,7 @@ import org.thingsboard.server.common.data.device.profile.DefaultDeviceProfileTra | @@ -37,10 +37,7 @@ import org.thingsboard.server.common.data.device.profile.DefaultDeviceProfileTra | ||
37 | import org.thingsboard.server.common.data.device.profile.DeviceProfileData; | 37 | import org.thingsboard.server.common.data.device.profile.DeviceProfileData; |
38 | import org.thingsboard.server.common.data.device.profile.DisabledDeviceProfileProvisionConfiguration; | 38 | import org.thingsboard.server.common.data.device.profile.DisabledDeviceProfileProvisionConfiguration; |
39 | import org.thingsboard.server.common.data.device.profile.X509CertificateChainProvisionConfiguration; | 39 | import org.thingsboard.server.common.data.device.profile.X509CertificateChainProvisionConfiguration; |
40 | -import org.thingsboard.server.common.data.id.DeviceProfileId; | ||
41 | -import org.thingsboard.server.common.data.id.EntityId; | ||
42 | -import org.thingsboard.server.common.data.id.HasId; | ||
43 | -import org.thingsboard.server.common.data.id.TenantId; | 40 | +import org.thingsboard.server.common.data.id.*; |
44 | import org.thingsboard.server.common.data.page.PageData; | 41 | import org.thingsboard.server.common.data.page.PageData; |
45 | import org.thingsboard.server.common.data.page.PageLink; | 42 | import org.thingsboard.server.common.data.page.PageLink; |
46 | import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage; | 43 | import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage; |
@@ -277,7 +274,7 @@ public class DeviceProfileServiceImpl extends AbstractCachedEntityService<Device | @@ -277,7 +274,7 @@ public class DeviceProfileServiceImpl extends AbstractCachedEntityService<Device | ||
277 | DeviceProfile deviceProfile = findDeviceProfileByName(tenantId, name, false); | 274 | DeviceProfile deviceProfile = findDeviceProfileByName(tenantId, name, false); |
278 | if (deviceProfile == null) { | 275 | if (deviceProfile == null) { |
279 | try { | 276 | try { |
280 | - deviceProfile = this.doCreateDefaultDeviceProfile(tenantId, name, name.equals("default"), DeviceTypeEnum.SENSOR); | 277 | + deviceProfile = this.doCreateDefaultDeviceProfile(tenantId, name, name.equals("default"), DeviceTypeEnum.SENSOR,null); |
281 | } catch (DataValidationException e) { | 278 | } catch (DataValidationException e) { |
282 | if (DEVICE_PROFILE_WITH_SUCH_NAME_ALREADY_EXISTS.equals(e.getMessage())) { | 279 | if (DEVICE_PROFILE_WITH_SUCH_NAME_ALREADY_EXISTS.equals(e.getMessage())) { |
283 | deviceProfile = findDeviceProfileByName(tenantId, name, false); | 280 | deviceProfile = findDeviceProfileByName(tenantId, name, false); |
@@ -292,13 +289,13 @@ public class DeviceProfileServiceImpl extends AbstractCachedEntityService<Device | @@ -292,13 +289,13 @@ public class DeviceProfileServiceImpl extends AbstractCachedEntityService<Device | ||
292 | @Override | 289 | @Override |
293 | public DeviceProfile createDefaultDeviceProfile(TenantId tenantId) { | 290 | public DeviceProfile createDefaultDeviceProfile(TenantId tenantId) { |
294 | log.trace("Executing createDefaultDeviceProfile tenantId [{}]", tenantId); | 291 | log.trace("Executing createDefaultDeviceProfile tenantId [{}]", tenantId); |
295 | - return doCreateDefaultDeviceProfile(tenantId, "default", true, DeviceTypeEnum.SENSOR); | 292 | + return doCreateDefaultDeviceProfile(tenantId, "default", true, DeviceTypeEnum.SENSOR,null); |
296 | } | 293 | } |
297 | //thingskit | 294 | //thingskit |
298 | @Override | 295 | @Override |
299 | - public DeviceProfile createDeviceProfile(TenantId tenantId, String name, DeviceTypeEnum deviceType) { | 296 | + public DeviceProfile createDeviceProfile(TenantId tenantId, String name, DeviceTypeEnum deviceType, RuleChainId ruleChainId) { |
300 | log.trace("Executing createDeviceProfile tenantId [{}]", tenantId); | 297 | log.trace("Executing createDeviceProfile tenantId [{}]", tenantId); |
301 | - return doCreateDefaultDeviceProfile(tenantId, name, false,deviceType); | 298 | + return doCreateDefaultDeviceProfile(tenantId, name, false,deviceType,ruleChainId); |
302 | } | 299 | } |
303 | 300 | ||
304 | @Override | 301 | @Override |
@@ -306,7 +303,7 @@ public class DeviceProfileServiceImpl extends AbstractCachedEntityService<Device | @@ -306,7 +303,7 @@ public class DeviceProfileServiceImpl extends AbstractCachedEntityService<Device | ||
306 | return deviceProfileDao.findByDataCombinationIsTrue(); | 303 | return deviceProfileDao.findByDataCombinationIsTrue(); |
307 | } | 304 | } |
308 | 305 | ||
309 | - private DeviceProfile doCreateDefaultDeviceProfile(TenantId tenantId, String profileName, boolean defaultProfile, DeviceTypeEnum deviceType) { | 306 | + private DeviceProfile doCreateDefaultDeviceProfile(TenantId tenantId, String profileName, boolean defaultProfile, DeviceTypeEnum deviceType, RuleChainId ruleChainId) { |
310 | validateId(tenantId, INCORRECT_TENANT_ID + tenantId); | 307 | validateId(tenantId, INCORRECT_TENANT_ID + tenantId); |
311 | DeviceProfile deviceProfile = new DeviceProfile(); | 308 | DeviceProfile deviceProfile = new DeviceProfile(); |
312 | deviceProfile.setTenantId(tenantId); | 309 | deviceProfile.setTenantId(tenantId); |
@@ -319,6 +316,7 @@ public class DeviceProfileServiceImpl extends AbstractCachedEntityService<Device | @@ -319,6 +316,7 @@ public class DeviceProfileServiceImpl extends AbstractCachedEntityService<Device | ||
319 | 316 | ||
320 | //thingsKit:begin | 317 | //thingsKit:begin |
321 | deviceProfile.setDeviceType(deviceType); | 318 | deviceProfile.setDeviceType(deviceType); |
319 | + deviceProfile.setDefaultRuleChainId(ruleChainId); | ||
322 | //thingsKit:end | 320 | //thingsKit:end |
323 | 321 | ||
324 | DeviceProfileData deviceProfileData = new DeviceProfileData(); | 322 | DeviceProfileData deviceProfileData = new DeviceProfileData(); |
@@ -184,7 +184,7 @@ public class TenantServiceImpl extends AbstractCachedEntityService<TenantId, Ten | @@ -184,7 +184,7 @@ public class TenantServiceImpl extends AbstractCachedEntityService<TenantId, Ten | ||
184 | 184 | ||
185 | @Override | 185 | @Override |
186 | @Transactional | 186 | @Transactional |
187 | - public Tenant saveTenant(Tenant tenant) { | 187 | + public Tenant saveTenant(Tenant tenant) { |
188 | log.trace("Executing saveTenant [{}]", tenant); | 188 | log.trace("Executing saveTenant [{}]", tenant); |
189 | tenant.setRegion(DEFAULT_TENANT_REGION); | 189 | tenant.setRegion(DEFAULT_TENANT_REGION); |
190 | if (tenant.getTenantProfileId() == null) { | 190 | if (tenant.getTenantProfileId() == null) { |
@@ -199,12 +199,6 @@ public class TenantServiceImpl extends AbstractCachedEntityService<TenantId, Ten | @@ -199,12 +199,6 @@ public class TenantServiceImpl extends AbstractCachedEntityService<TenantId, Ten | ||
199 | if (tenant.getId() == null) { | 199 | if (tenant.getId() == null) { |
200 | deviceProfileService.createDefaultDeviceProfile(savedTenant.getId()); | 200 | deviceProfileService.createDefaultDeviceProfile(savedTenant.getId()); |
201 | assetProfileService.createDefaultAssetProfile(savedTenant.getId()); | 201 | assetProfileService.createDefaultAssetProfile(savedTenant.getId()); |
202 | - //Thingskit function | ||
203 | - deviceProfileService.createDeviceProfile(savedTenant.getId(),"默认MQTT网关设备", DeviceTypeEnum.GATEWAY); | ||
204 | - deviceProfileService.createDeviceProfile(savedTenant.getId(),"默认MQTT直连设备", DeviceTypeEnum.DIRECT_CONNECTION); | ||
205 | - | ||
206 | - | ||
207 | - | ||
208 | apiUsageStateService.createDefaultApiUsageState(savedTenant.getId(), null); | 202 | apiUsageStateService.createDefaultApiUsageState(savedTenant.getId(), null); |
209 | try { | 203 | try { |
210 | notificationSettingsService.createDefaultNotificationConfigs(savedTenant.getId()); | 204 | notificationSettingsService.createDefaultNotificationConfigs(savedTenant.getId()); |