Commit 48ffe9968ca3f76b7022123972e96816f80ecdd3
Merge branch 'ljl1216' into 'master'
fix: 设备相关 See merge request huang/thingsboard3.3.2!16
Showing
6 changed files
with
32 additions
and
11 deletions
... | ... | @@ -31,7 +31,7 @@ public class DeviceProfileDTO extends TenantDTO { |
31 | 31 | @NotEmpty(message = "传输协议不能为空或者空字符串", groups = AddGroup.class) |
32 | 32 | @ApiModelProperty(value = "传输协议", required = true) |
33 | 33 | @NotEmpty(message = "传输协议不能为空或者二空字符串") |
34 | - private DeviceTransportType transportType; | |
34 | + private String transportType; | |
35 | 35 | /** |
36 | 36 | * TB的设备配置文件 |
37 | 37 | */ |
... | ... | @@ -58,7 +58,7 @@ public class DeviceProfileDTO extends TenantDTO { |
58 | 58 | setCreateTime(LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneOffset.UTC)); |
59 | 59 | this.name = name; |
60 | 60 | this.description = description; |
61 | - this.transportType = transportType; | |
61 | + this.transportType = transportType.name(); | |
62 | 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 | 68 | this.name = name; |
69 | 69 | this.description = description; |
70 | 70 | this.convertJs = convertJs; |
71 | - this.transportType = transportType; | |
71 | + this.transportType = transportType.name(); | |
72 | 72 | this.defaultRuleChainId = defaultRuleChainId.toString(); |
73 | 73 | this.profileData = profileData; |
74 | 74 | } | ... | ... |
... | ... | @@ -241,12 +241,7 @@ public class YtDeviceServiceImpl extends AbstractBaseService<DeviceMapper, YtDev |
241 | 241 | @Override |
242 | 242 | public Optional<DeviceDTO> getDevice(String tenantId,String id) { |
243 | 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 | 247 | @Override | ... | ... |
... | ... | @@ -15,4 +15,6 @@ public interface DeviceMapper extends BaseMapper<YtDevice> { |
15 | 15 | |
16 | 16 | IPage<DeviceDTO> getDevicePage( |
17 | 17 | IPage<?> page, @Param("queryMap") Map<String, Object> queryMap); |
18 | + | |
19 | + DeviceDTO selectDetail(@Param("tenantId") String tenantId,@Param("id") String id); | |
18 | 20 | } | ... | ... |
... | ... | @@ -21,22 +21,26 @@ |
21 | 21 | <result property="updateTime" column="update_time"/> |
22 | 22 | <result property="creator" column="creator"/> |
23 | 23 | <result property="updater" column="updater"/> |
24 | + <result property="description" column="description"/> | |
24 | 25 | <result property="organizationId" column="organization_id"/> |
25 | 26 | <association property="deviceProfile" javaType="org.thingsboard.server.common.data.yunteng.dto.DeviceProfileDTO"> |
26 | 27 | <result property="name" column="profile_name"/> |
28 | + <result property="transportType" column="transport_type"/> | |
27 | 29 | </association> |
28 | 30 | <association property="organizationDTO" javaType="org.thingsboard.server.common.data.yunteng.dto.OrganizationDTO"> |
29 | 31 | <result property="name" column="organization_name"/> |
30 | 32 | </association> |
31 | 33 | </resultMap> |
32 | 34 | <sql id="columns"> |
33 | - 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 | |
34 | 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, |
35 | 37 | ifd.updater,ifd.organization_id,ifd,alarm_status |
38 | + ,ifdp.name AS profile_name,ifdp.transport_type | |
39 | + ,io.name AS organization_name | |
36 | 40 | </sql> |
37 | 41 | <select id="getDevicePage" resultMap="deviceMap"> |
38 | 42 | SELECT |
39 | - <include refid="columns"/>,ifdp.name AS profile_name,io.name AS organization_name | |
43 | + <include refid="columns"/> | |
40 | 44 | FROM iotfs_device ifd |
41 | 45 | LEFT JOIN device_profile ifdp ON ifd.profile_id = CAST (ifdp.id AS VARCHAR) |
42 | 46 | LEFT JOIN iotfs_organization io ON io.id = ifd.organization_id |
... | ... | @@ -67,4 +71,22 @@ |
67 | 71 | </if> |
68 | 72 | </where> |
69 | 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> | |
70 | 92 | </mapper> | ... | ... |