Commit f60756e1de0ad1494f8c52962ef6691a5437adf9

Authored by xp.Huang
1 parent 1b720795

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

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