Commit f60756e1de0ad1494f8c52962ef6691a5437adf9

Authored by xp.Huang
1 parent 1b720795

perf: 在编辑模式下设置设备、产品的固件、软件升级

... ... @@ -538,6 +538,12 @@ public class TkDeviceController extends BaseController {
538 538 tbDevice.setName(deviceDTO.getName());
539 539 tbDevice.setCreatedTime(LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli());
540 540 tbDevice.setTenantId(tenantId);
  541 + tbDevice.setFirmwareId(
  542 + StringUtils.isEmpty(deviceDTO.getFirmwareId()) ? null :
  543 + new OtaPackageId(UUID.fromString(deviceDTO.getFirmwareId())));
  544 + tbDevice.setSoftwareId(
  545 + StringUtils.isEmpty(deviceDTO.getSoftwareId()) ? null :
  546 + new OtaPackageId(UUID.fromString(deviceDTO.getSoftwareId())));
541 547 return tbDevice;
542 548 }
543 549
... ...
... ... @@ -14,6 +14,7 @@ import org.thingsboard.server.common.data.audit.ActionType;
14 14 import org.thingsboard.server.common.data.edge.EdgeEventActionType;
15 15 import org.thingsboard.server.common.data.exception.ThingsboardException;
16 16 import org.thingsboard.server.common.data.id.DeviceProfileId;
  17 +import org.thingsboard.server.common.data.id.OtaPackageId;
17 18 import org.thingsboard.server.common.data.id.RuleChainId;
18 19 import org.thingsboard.server.common.data.id.TenantId;
19 20 import org.thingsboard.server.common.data.plugin.ComponentLifecycleEvent;
... ... @@ -257,6 +258,12 @@ public class TkDeviceProfileController extends BaseController {
257 258
258 259 tbDeviceProfile.setProfileData(
259 260 buildDeviceProfileData(transportType, deviceProfileDTO.getProfileData()));
  261 + tbDeviceProfile.setFirmwareId(
  262 + StringUtils.isEmpty(deviceProfileDTO.getFirmwareId()) ? null :
  263 + new OtaPackageId(UUID.fromString(deviceProfileDTO.getFirmwareId())));
  264 + tbDeviceProfile.setSoftwareId(
  265 + StringUtils.isEmpty(deviceProfileDTO.getSoftwareId()) ? null :
  266 + new OtaPackageId(UUID.fromString(deviceProfileDTO.getSoftwareId())));
260 267 return tbDeviceProfile;
261 268 }
262 269 }
... ...
... ... @@ -128,4 +128,10 @@ public class DeviceDTO extends TenantDTO {
128 128
129 129 @ApiModelProperty(value = "是否收藏:0否1是")
130 130 private Integer isCollect;
  131 +
  132 + @ApiModelProperty(value = "OTA升级固件ID")
  133 + private String firmwareId;
  134 +
  135 + @ApiModelProperty(value = "OTA升级软件ID")
  136 + private String softwareId;
131 137 }
... ...
... ... @@ -88,6 +88,12 @@ public class DeviceProfileDTO extends BaseDTO {
88 88 @ApiModelProperty(value = "品类名称")
89 89 private String categoryName;
90 90
  91 + @ApiModelProperty(value = "OTA升级固件ID")
  92 + private String firmwareId;
  93 +
  94 + @ApiModelProperty(value = "OTA升级软件ID")
  95 + private String softwareId;
  96 +
91 97 public DeviceProfileDTO() {}
92 98
93 99 public DeviceProfileDTO(
... ...
... ... @@ -44,6 +44,8 @@
44 44 <result property="gatewayAlias" column="gateway_alias"/>
45 45 <result property="isCollect" column="isCollect"/>
46 46 <result property="transportType" column="transport_type"/>
  47 + <result property="firmwareId" column="firmware_id"/>
  48 + <result property="softwareId" column="software_id"/>
47 49 <association property="deviceProfile"
48 50 javaType="org.thingsboard.server.common.data.yunteng.dto.DeviceProfileDTO">
49 51 <result property="name" column="profile_name"/>
... ... @@ -94,7 +96,8 @@
94 96 </sql>
95 97 <select id="getDevicePage" resultMap="deviceMap">
96 98 SELECT
97   - <include refid="pageColumns"/>,d.customer_id::TEXT AS customer_id,cus.title AS customer_name,cus.additional_info AS customer_additional_info
  99 + <include refid="pageColumns"/>,d.customer_id::TEXT AS customer_id,cus.title AS customer_name,cus.additional_info AS customer_additional_info,
  100 + d.firmware_id,d.software_id
98 101 FROM tk_device ifd
99 102 LEFT JOIN device_profile ifdp ON ifd.profile_id = ifdp.id::TEXT
100 103 LEFT JOIN tk_organization io ON io.id = ifd.organization_id
... ...
... ... @@ -23,6 +23,8 @@
23 23 <result property="type" column="type"/>
24 24 <result property="categoryId" column="category_id"/>
25 25 <result property="categoryName" column="categoryName"/>
  26 + <result property="firmwareId" column="firmware_id"/>
  27 + <result property="softwareId" column="software_id"/>
26 28 </resultMap>
27 29
28 30
... ... @@ -60,7 +62,7 @@
60 62
61 63 <select id="selectDetail" resultMap="detail">
62 64 SELECT
63   - <include refid="basicColumns"/>
  65 + <include refid="basicColumns"/>,base.firmware_id,base.software_id
64 66 FROM device_profile base
65 67 LEFT JOIN tk_device_profile iot ON iot.tb_profile_id = base.id::TEXT
66 68 <where>
... ...