Commit b99b01262a0969e3d34a370ebd8cdf40770d1b05

Authored by 云中非
1 parent c2334588

fix: 设备相关

1.设备详情返回信息完善:设备配置、描述、接入类型
@@ -31,7 +31,7 @@ public class DeviceProfileDTO extends TenantDTO { @@ -31,7 +31,7 @@ public class DeviceProfileDTO extends TenantDTO {
31 @NotEmpty(message = "传输协议不能为空或者空字符串", groups = AddGroup.class) 31 @NotEmpty(message = "传输协议不能为空或者空字符串", groups = AddGroup.class)
32 @ApiModelProperty(value = "传输协议", required = true) 32 @ApiModelProperty(value = "传输协议", required = true)
33 @NotEmpty(message = "传输协议不能为空或者二空字符串") 33 @NotEmpty(message = "传输协议不能为空或者二空字符串")
34 - private DeviceTransportType transportType; 34 + private String transportType;
35 /** 35 /**
36 * TB的设备配置文件 36 * TB的设备配置文件
37 */ 37 */
@@ -58,7 +58,7 @@ public class DeviceProfileDTO extends TenantDTO { @@ -58,7 +58,7 @@ public class DeviceProfileDTO extends TenantDTO {
58 setCreateTime(LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneOffset.UTC)); 58 setCreateTime(LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneOffset.UTC));
59 this.name = name; 59 this.name = name;
60 this.description = description; 60 this.description = description;
61 - this.transportType = transportType; 61 + this.transportType = transportType.name();
62 this.defaultRuleChainId = Optional.ofNullable(defaultRuleChainId).map(chainId -> chainId.toString()).orElse(null); 62 this.defaultRuleChainId = Optional.ofNullable(defaultRuleChainId).map(chainId -> chainId.toString()).orElse(null);
63 } 63 }
64 64
@@ -68,7 +68,7 @@ public class DeviceProfileDTO extends TenantDTO { @@ -68,7 +68,7 @@ public class DeviceProfileDTO extends TenantDTO {
68 this.name = name; 68 this.name = name;
69 this.description = description; 69 this.description = description;
70 this.convertJs = convertJs; 70 this.convertJs = convertJs;
71 - this.transportType = transportType; 71 + this.transportType = transportType.name();
72 this.defaultRuleChainId = defaultRuleChainId.toString(); 72 this.defaultRuleChainId = defaultRuleChainId.toString();
73 this.profileData = profileData; 73 this.profileData = profileData;
74 } 74 }
@@ -241,12 +241,7 @@ public class YtDeviceServiceImpl extends AbstractBaseService<DeviceMapper, YtDev @@ -241,12 +241,7 @@ public class YtDeviceServiceImpl extends AbstractBaseService<DeviceMapper, YtDev
241 @Override 241 @Override
242 public Optional<DeviceDTO> getDevice(String tenantId,String id) { 242 public Optional<DeviceDTO> getDevice(String tenantId,String id) {
243 return Optional.ofNullable( 243 return Optional.ofNullable(
244 - baseMapper.selectOne(  
245 - new QueryWrapper<YtDevice>()  
246 - .lambda()  
247 - .eq(YtDevice::getTenantId, tenantId)  
248 - .eq(YtDevice::getId, id)))  
249 - .map(device -> device.getDTO(DeviceDTO.class)); 244 + baseMapper.selectDetail(tenantId,id));
250 } 245 }
251 246
252 @Override 247 @Override
@@ -15,4 +15,6 @@ public interface DeviceMapper extends BaseMapper<YtDevice> { @@ -15,4 +15,6 @@ public interface DeviceMapper extends BaseMapper<YtDevice> {
15 15
16 IPage<DeviceDTO> getDevicePage( 16 IPage<DeviceDTO> getDevicePage(
17 IPage<?> page, @Param("queryMap") Map<String, Object> queryMap); 17 IPage<?> page, @Param("queryMap") Map<String, Object> queryMap);
  18 +
  19 + DeviceDTO selectDetail(@Param("tenantId") String tenantId,@Param("id") String id);
18 } 20 }
@@ -21,6 +21,7 @@ @@ -21,6 +21,7 @@
21 <result property="updateTime" column="update_time"/> 21 <result property="updateTime" column="update_time"/>
22 <result property="creator" column="creator"/> 22 <result property="creator" column="creator"/>
23 <result property="updater" column="updater"/> 23 <result property="updater" column="updater"/>
  24 + <result property="description" column="description"/>
24 <result property="organizationId" column="organization_id"/> 25 <result property="organizationId" column="organization_id"/>
25 <association property="deviceProfile" javaType="org.thingsboard.server.common.data.yunteng.dto.DeviceProfileDTO"> 26 <association property="deviceProfile" javaType="org.thingsboard.server.common.data.yunteng.dto.DeviceProfileDTO">
26 <result property="name" column="profile_name"/> 27 <result property="name" column="profile_name"/>
@@ -31,7 +32,7 @@ @@ -31,7 +32,7 @@
31 </association> 32 </association>
32 </resultMap> 33 </resultMap>
33 <sql id="columns"> 34 <sql id="columns">
34 - ifd.id,ifd.name,ifd.device_info,ifd.profile_id,ifd.active_time,ifd.device_token,ifd.tenant_id 35 + ifd.id,ifd.name,ifd.device_info,ifd.profile_id,ifd.active_time,ifd.device_token,ifd.tenant_id,ifd.description
35 ,ifd.tb_device_id,ifd.label,ifd.last_connect_time,ifd.device_type,ifd.device_state,ifd.create_time,ifd.update_time,ifd.creator, 36 ,ifd.tb_device_id,ifd.label,ifd.last_connect_time,ifd.device_type,ifd.device_state,ifd.create_time,ifd.update_time,ifd.creator,
36 ifd.updater,ifd.organization_id,ifd,alarm_status 37 ifd.updater,ifd.organization_id,ifd,alarm_status
37 ,ifdp.name AS profile_name,ifdp.transport_type 38 ,ifdp.name AS profile_name,ifdp.transport_type
@@ -70,4 +71,22 @@ @@ -70,4 +71,22 @@
70 </if> 71 </if>
71 </where> 72 </where>
72 </select> 73 </select>
  74 +
  75 +
  76 + <select id="selectDetail" resultMap="deviceMap">
  77 + SELECT
  78 + <include refid="columns"/>
  79 + FROM iotfs_device ifd
  80 + LEFT JOIN device_profile ifdp ON ifd.profile_id = CAST (ifdp.id AS VARCHAR)
  81 + LEFT JOIN iotfs_organization io ON io.id = ifd.organization_id
  82 + <where>
  83 + <if test="tenantId !=null and tenantId !=''">
  84 + AND ifd.tenant_id = #{tenantId}
  85 + </if>
  86 + <if test="id !=null and id !=''">
  87 + AND ifd.id = #{id}
  88 + </if>
  89 +
  90 + </where>
  91 + </select>
73 </mapper> 92 </mapper>