mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-18 17:38:48 +08:00
查看当前版本和最新版本
This commit is contained in:
parent
5baf139f6b
commit
6cc7de3fb2
@ -101,6 +101,17 @@ public class EqDeviceController extends BaseController {
|
||||
return R.ok(eqEquipmentService.ota(equipmentCode));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看当前版本和最新版本
|
||||
* @param equipmentCode
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/otaVersion")
|
||||
public R<EqVersionBo> otaVersion(String equipmentCode){
|
||||
if (equipmentCode == null) throw new ServiceException("设备编码不能为空");
|
||||
return R.ok(eqEquipmentService.otaVersion(equipmentCode));
|
||||
}
|
||||
|
||||
/**
|
||||
* 控制设备 门 灯光 控制
|
||||
* 传参设备编码
|
||||
|
||||
@ -0,0 +1,35 @@
|
||||
package org.dromara.web.domain.bo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @ClassName : EqVersionBo
|
||||
* @Author : ZZC
|
||||
* @Date : 2024/10/28 18:52
|
||||
* @Discription : 版本信息
|
||||
**/
|
||||
@Data
|
||||
public class EqVersionBo implements Serializable {
|
||||
/**
|
||||
* 是否需要更新
|
||||
*/
|
||||
private boolean isNeedUpdate;
|
||||
/**
|
||||
* 当前版本
|
||||
*/
|
||||
private String currentVersion;
|
||||
/**
|
||||
* 最新版本
|
||||
*/
|
||||
private String latestVersion;
|
||||
/**
|
||||
* 当前版本id
|
||||
*/
|
||||
private String currentVersionId;
|
||||
/**
|
||||
* 最新版本id
|
||||
*/
|
||||
private String latestVersionId;
|
||||
}
|
||||
@ -108,4 +108,5 @@ public interface IEqEquipmentService {
|
||||
EqEquipmentStatisticsVo selectEquipmentStatistic(Integer type, String startTime, String endTime);
|
||||
|
||||
String ota(String equipmentCode);
|
||||
public EqVersionBo otaVersion(String equipmentCode);
|
||||
}
|
||||
|
||||
@ -220,7 +220,7 @@ public class IotService {
|
||||
* @param deviceProfileId
|
||||
* @return
|
||||
*/
|
||||
public DeviceOtaPackages httpOtaPackages(String deviceProfileId){
|
||||
public DeviceOtaPackages httpOtaLastPackages(String deviceProfileId){
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("deviceProfileId",deviceProfileId);
|
||||
String send = getSend(CommonYmlConfig.URL_IOT_ota_otaPackages, map);
|
||||
@ -230,6 +230,19 @@ public class IotService {
|
||||
return deviceDto;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有资源包
|
||||
* @param deviceProfileId
|
||||
* @return
|
||||
*/
|
||||
public List<DeviceOtaPackages> httpOtaPackages(String deviceProfileId){
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("deviceProfileId",deviceProfileId);
|
||||
String send = getSend(CommonYmlConfig.URL_IOT_ota_otaPackages, map);
|
||||
List<DeviceOtaPackages> deviceOtaPackages = JSON.parseArray(send, DeviceOtaPackages.class);
|
||||
return deviceOtaPackages;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询设备凭证
|
||||
* @param deviceId
|
||||
|
||||
@ -397,7 +397,7 @@ public class EqEquipmentServiceImpl implements IEqEquipmentService {
|
||||
DeviceDto.DeviceProfileId deviceProfileId = deviceDto.getDeviceProfileId();
|
||||
String profileIdId = deviceProfileId.getId();//获取配置id
|
||||
//2.查询OTA资源包
|
||||
DeviceOtaPackages deviceOtaPackages = iotService.httpOtaPackages(profileIdId);
|
||||
DeviceOtaPackages deviceOtaPackages = iotService.httpOtaLastPackages(profileIdId);
|
||||
//3.查询设备凭证
|
||||
DeviceCredentials deviceCredentials = iotService.httpCredentials(equipmentCode);
|
||||
String assesToken = deviceCredentials.getCredentialsId();
|
||||
@ -407,6 +407,39 @@ public class EqEquipmentServiceImpl implements IEqEquipmentService {
|
||||
return iotService.httpPostUpdateOta(assesToken,deviceDto);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EqVersionBo otaVersion(String equipmentCode) {
|
||||
EqVersionBo eqVersionBo = new EqVersionBo();
|
||||
//1.从iot平台设置用户绑定 并获取设备信息
|
||||
DeviceDto deviceDto = iotService.httpDeviceGetSend(equipmentCode);
|
||||
DeviceDto.DeviceProfileId deviceProfileId = deviceDto.getDeviceProfileId();
|
||||
String profileIdId = deviceProfileId.getId();//获取配置id
|
||||
//2.查询OTA资源包
|
||||
// DeviceOtaPackages deviceOtaPackages = iotService.httpOtaLastPackages(profileIdId);
|
||||
List<DeviceOtaPackages> list = iotService.httpOtaPackages(profileIdId);
|
||||
DeviceOtaPackages lastOtaPackage = list.get(0);
|
||||
DeviceOtaPackages currentOtaPackage = null;
|
||||
//设备包版本id
|
||||
String currentPackageId = deviceDto.getFirmwareId().getId();
|
||||
String lastPackageId = lastOtaPackage.getId().getId();
|
||||
for (DeviceOtaPackages deviceOtaPackages : list) {
|
||||
if (deviceOtaPackages.getId().getId().equals(currentPackageId))
|
||||
currentOtaPackage = deviceOtaPackages;
|
||||
}
|
||||
if (currentOtaPackage == null) throw new RuntimeException("当前设备版本不存在");
|
||||
if (currentPackageId.equals(lastPackageId)){
|
||||
eqVersionBo.setNeedUpdate(false);
|
||||
eqVersionBo.setCurrentVersionId(currentPackageId);
|
||||
eqVersionBo.setCurrentVersion(currentOtaPackage.getVersion());
|
||||
}else {
|
||||
eqVersionBo.setNeedUpdate(true);
|
||||
eqVersionBo.setCurrentVersionId(currentPackageId);
|
||||
eqVersionBo.setCurrentVersion(currentOtaPackage.getVersion());
|
||||
eqVersionBo.setLatestVersionId(lastPackageId);
|
||||
eqVersionBo.setLatestVersion(lastOtaPackage.getVersion());
|
||||
}
|
||||
return eqVersionBo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查要查询的userId 是否为分享给当前用户的userId
|
||||
|
||||
Loading…
Reference in New Issue
Block a user