固件升级完善

This commit is contained in:
kerwincui
2022-06-16 23:41:30 +08:00
parent a574bcc5aa
commit b9f56459d4
6 changed files with 68 additions and 2 deletions

View File

@@ -87,6 +87,17 @@ public class FirmwareController extends BaseController
return AjaxResult.success(firmwareService.selectFirmwareByFirmwareId(firmwareId)); return AjaxResult.success(firmwareService.selectFirmwareByFirmwareId(firmwareId));
} }
/**
* 获取设备最新固件
*/
@ApiOperation("获取设备最新固件")
@PreAuthorize("@ss.hasPermi('iot:firmware:query')")
@GetMapping(value = "/getLatest/{deviceId}")
public AjaxResult getLatest(@PathVariable("deviceId") Long deviceId)
{
return AjaxResult.success(firmwareService.selectLatestFirmware(deviceId));
}
/** /**
* 新增产品固件 * 新增产品固件
*/ */

View File

@@ -43,6 +43,10 @@ public class Firmware extends BaseEntity
@Excel(name = "是否系统通用", readConverterExp = "0=-否1-是") @Excel(name = "是否系统通用", readConverterExp = "0=-否1-是")
private Integer isSys; private Integer isSys;
/** 是否最新版0-否1-是) */
@Excel(name = "是否系统通用", readConverterExp = "0=-否1-是")
private Integer isLatest;
/** 固件版本 */ /** 固件版本 */
@Excel(name = "固件版本") @Excel(name = "固件版本")
private BigDecimal version; private BigDecimal version;
@@ -54,6 +58,14 @@ public class Firmware extends BaseEntity
/** 删除标志0代表存在 2代表删除 */ /** 删除标志0代表存在 2代表删除 */
private String delFlag; private String delFlag;
public Integer getIsLatest() {
return isLatest;
}
public void setIsLatest(Integer isLatest) {
this.isLatest = isLatest;
}
public void setFirmwareId(Long firmwareId) public void setFirmwareId(Long firmwareId)
{ {
this.firmwareId = firmwareId; this.firmwareId = firmwareId;

View File

@@ -21,6 +21,14 @@ public interface FirmwareMapper
*/ */
public Firmware selectFirmwareByFirmwareId(Long firmwareId); public Firmware selectFirmwareByFirmwareId(Long firmwareId);
/**
* 查询设备最新固件
*
* @param deviceId 产品固件主键
* @return 产品固件
*/
public Firmware selectLatestFirmware(Long deviceId);
/** /**
* 查询产品固件列表 * 查询产品固件列表
* *

View File

@@ -19,6 +19,14 @@ public interface IFirmwareService
*/ */
public Firmware selectFirmwareByFirmwareId(Long firmwareId); public Firmware selectFirmwareByFirmwareId(Long firmwareId);
/**
* 查询设备最新固件
*
* @param deviceId 产品固件主键
* @return 产品固件
*/
public Firmware selectLatestFirmware(Long deviceId);
/** /**
* 查询产品固件列表 * 查询产品固件列表
* *

View File

@@ -37,6 +37,18 @@ public class FirmwareServiceImpl implements IFirmwareService
return firmwareMapper.selectFirmwareByFirmwareId(firmwareId); return firmwareMapper.selectFirmwareByFirmwareId(firmwareId);
} }
/**
* 查询设备最新固件
*
* @param deviceId 产品固件主键
* @return 产品固件
*/
@Override
public Firmware selectLatestFirmware(Long deviceId)
{
return firmwareMapper.selectLatestFirmware(deviceId);
}
/** /**
* 查询产品固件列表 * 查询产品固件列表
* *

View File

@@ -12,6 +12,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="tenantId" column="tenant_id" /> <result property="tenantId" column="tenant_id" />
<result property="tenantName" column="tenant_name" /> <result property="tenantName" column="tenant_name" />
<result property="isSys" column="is_sys" /> <result property="isSys" column="is_sys" />
<result property="isLatest" column="is_latest" />
<result property="version" column="version" /> <result property="version" column="version" />
<result property="filePath" column="file_path" /> <result property="filePath" column="file_path" />
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />
@@ -20,7 +21,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap> </resultMap>
<sql id="selectFirmwareVo"> <sql id="selectFirmwareVo">
select firmware_id, firmware_name, product_id, product_name, tenant_id, tenant_name, is_sys, version, file_path, create_time, update_time, remark from iot_firmware select firmware_id, firmware_name, product_id, product_name, tenant_id, tenant_name, is_sys,is_latest, version, file_path, create_time, update_time, remark from iot_firmware
</sql> </sql>
<select id="selectFirmwareList" parameterType="com.ruoyi.iot.domain.Firmware" resultMap="FirmwareResult"> <select id="selectFirmwareList" parameterType="com.ruoyi.iot.domain.Firmware" resultMap="FirmwareResult">
@@ -30,6 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="productName != null and productName != ''"> and product_name like concat('%', #{productName}, '%')</if> <if test="productName != null and productName != ''"> and product_name like concat('%', #{productName}, '%')</if>
<if test="tenantId != null and tenantId != ''"> and tenant_id = #{tenantId}</if> <if test="tenantId != null and tenantId != ''"> and tenant_id = #{tenantId}</if>
<if test="productId != null"> and product_id = #{productId}</if> <if test="productId != null"> and product_id = #{productId}</if>
<if test="isLatest != null"> and is_latest = #{isLatest}</if>
</where> </where>
order by create_time desc order by create_time desc
</select> </select>
@@ -39,6 +41,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where firmware_id = #{firmwareId} where firmware_id = #{firmwareId}
</select> </select>
<select id="selectLatestFirmware" parameterType="Long" resultMap="FirmwareResult">
select f.firmware_id, f.firmware_name, f.product_id, f.product_name, f.tenant_id, f.tenant_name, f.is_sys,f.is_latest, f.version,
f.file_path, f.create_time, f.remark
from iot_device d
left join iot_firmware f on d.product_id = f.product_id
where d.device_id=#{deviceId} and f.is_latest=1
order by f.create_time desc
limit 1
</select>
<insert id="insertFirmware" parameterType="com.ruoyi.iot.domain.Firmware" useGeneratedKeys="true" keyProperty="firmwareId"> <insert id="insertFirmware" parameterType="com.ruoyi.iot.domain.Firmware" useGeneratedKeys="true" keyProperty="firmwareId">
insert into iot_firmware insert into iot_firmware
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -48,6 +60,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="tenantId != null">tenant_id,</if> <if test="tenantId != null">tenant_id,</if>
<if test="tenantName != null and tenantName != ''">tenant_name,</if> <if test="tenantName != null and tenantName != ''">tenant_name,</if>
<if test="isSys != null">is_sys,</if> <if test="isSys != null">is_sys,</if>
<if test="isLatest != null">is_latest,</if>
<if test="version != null">version,</if> <if test="version != null">version,</if>
<if test="filePath != null and filePath != ''">file_path,</if> <if test="filePath != null and filePath != ''">file_path,</if>
<if test="delFlag != null">del_flag,</if> <if test="delFlag != null">del_flag,</if>
@@ -64,6 +77,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="tenantId != null">#{tenantId},</if> <if test="tenantId != null">#{tenantId},</if>
<if test="tenantName != null and tenantName != ''">#{tenantName},</if> <if test="tenantName != null and tenantName != ''">#{tenantName},</if>
<if test="isSys != null">#{isSys},</if> <if test="isSys != null">#{isSys},</if>
<if test="isLatest != null">#{isLatest},</if>
<if test="version != null">#{version},</if> <if test="version != null">#{version},</if>
<if test="filePath != null and filePath != ''">#{filePath},</if> <if test="filePath != null and filePath != ''">#{filePath},</if>
<if test="delFlag != null">#{delFlag},</if> <if test="delFlag != null">#{delFlag},</if>
@@ -84,6 +98,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="tenantId != null">tenant_id = #{tenantId},</if> <if test="tenantId != null">tenant_id = #{tenantId},</if>
<if test="tenantName != null and tenantName != ''">tenant_name = #{tenantName},</if> <if test="tenantName != null and tenantName != ''">tenant_name = #{tenantName},</if>
<if test="isSys != null">is_sys = #{isSys},</if> <if test="isSys != null">is_sys = #{isSys},</if>
<if test="isLatest != null">is_latest = #{isLatest},</if>
<if test="version != null">version = #{version},</if> <if test="version != null">version = #{version},</if>
<if test="filePath != null and filePath != ''">file_path = #{filePath},</if> <if test="filePath != null and filePath != ''">file_path = #{filePath},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if> <if test="delFlag != null">del_flag = #{delFlag},</if>