Commit ab4e6483d81049fd4f3b917269520728e04fd7b3

Authored by 云中非
1 parent c97b350d

fix: 新增租户在创建设备配置时,需要扩展产品信息记录

... ... @@ -19,12 +19,15 @@ import com.google.common.util.concurrent.ListenableFuture;
19 19 import lombok.extern.slf4j.Slf4j;
20 20 import org.springframework.beans.factory.annotation.Autowired;
21 21 import org.springframework.stereotype.Service;
  22 +import org.thingsboard.server.common.data.DeviceProfile;
22 23 import org.thingsboard.server.common.data.Tenant;
23 24 import org.thingsboard.server.common.data.TenantInfo;
24 25 import org.thingsboard.server.common.data.TenantProfile;
25 26 import org.thingsboard.server.common.data.id.TenantId;
26 27 import org.thingsboard.server.common.data.page.PageData;
27 28 import org.thingsboard.server.common.data.page.PageLink;
  29 +import org.thingsboard.server.common.data.yunteng.dto.DeviceProfileDTO;
  30 +import org.thingsboard.server.common.data.yunteng.enums.DeviceTypeEnum;
28 31 import org.thingsboard.server.dao.asset.AssetService;
29 32 import org.thingsboard.server.dao.customer.CustomerService;
30 33 import org.thingsboard.server.dao.dashboard.DashboardService;
... ... @@ -42,6 +45,7 @@ import org.thingsboard.server.dao.service.Validator;
42 45 import org.thingsboard.server.dao.usagerecord.ApiUsageStateService;
43 46 import org.thingsboard.server.dao.user.UserService;
44 47 import org.thingsboard.server.dao.widget.WidgetsBundleService;
  48 +import org.thingsboard.server.dao.yunteng.service.YtDeviceProfileService;
45 49
46 50 import static org.thingsboard.server.dao.service.Validator.validateId;
47 51
... ... @@ -99,7 +103,8 @@ public class TenantServiceImpl extends AbstractEntityService implements TenantSe
99 103
100 104 @Autowired
101 105 private DataValidator<Tenant> tenantValidator;
102   -
  106 + @Autowired
  107 + private YtDeviceProfileService ytDeviceProfileService;
103 108 @Override
104 109 public Tenant findTenantById(TenantId tenantId) {
105 110 log.trace("Executing findTenantById [{}]", tenantId);
... ... @@ -132,8 +137,13 @@ public class TenantServiceImpl extends AbstractEntityService implements TenantSe
132 137 tenantValidator.validate(tenant, Tenant::getId);
133 138 Tenant savedTenant = tenantDao.save(tenant.getId(), tenant);
134 139 if (tenant.getId() == null) {
135   - deviceProfileService.createDefaultDeviceProfile(savedTenant.getId());
  140 +
  141 + //Thingskit function
  142 + DeviceProfile deviceProfile = deviceProfileService.createDefaultDeviceProfile(savedTenant.getId());
  143 + DeviceProfileDTO profileDTO = new DeviceProfileDTO(deviceProfile.getName(),deviceProfile.getTenantId(),deviceProfile.getId(), DeviceTypeEnum.DIRECT_CONNECTION);
  144 + ytDeviceProfileService.insertOrUpdate(profileDTO);
136 145 apiUsageStateService.createDefaultApiUsageState(savedTenant.getId(), null);
  146 +
137 147 }
138 148 return savedTenant;
139 149 }
... ...