mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-18 17:38:48 +08:00
wifi单独修改 ota升级 多语言优化等
This commit is contained in:
parent
c84fcee9ba
commit
fb0c6fc2fc
@ -23,6 +23,10 @@ public class CommonYmlConfig {
|
||||
public static String URL_IOT_DEVICE = "设备信息";
|
||||
public static String URL_IOT_DEVICE_BY_NAME = "设备名称查询设备信息";
|
||||
|
||||
public static String URL_IOT_ota_otaPackages = "查询ota升级包";
|
||||
public static String URL_IOT_ota_credentials = "获取凭证";
|
||||
public static String URL_IOT_ota_updateOta = "更新ota";
|
||||
|
||||
public String username = "";
|
||||
public String password = "";
|
||||
|
||||
@ -33,6 +37,10 @@ public class CommonYmlConfig {
|
||||
public String device = "";
|
||||
public String deviceByName = "";
|
||||
|
||||
public String otaPackages = "";
|
||||
public String credentials = "";
|
||||
public String updateOta = "";
|
||||
|
||||
@Value("${iot.username}")
|
||||
public String setUsername(String username) {
|
||||
return URL_IOT_USERNAME = username;
|
||||
@ -73,4 +81,18 @@ public class CommonYmlConfig {
|
||||
}
|
||||
|
||||
|
||||
@Value("${iot.url.otaPackages}")
|
||||
public String setOtaPackages(String otaPackages) {
|
||||
return URL_IOT_ota_otaPackages = otaPackages;
|
||||
}
|
||||
|
||||
@Value("${iot.url.credentials}")
|
||||
public String setCredentials(String credentials) {
|
||||
return URL_IOT_ota_credentials = credentials;
|
||||
}
|
||||
|
||||
@Value("${iot.url.updateOta}")
|
||||
public String setUpdateOta(String updateOta) {
|
||||
return URL_IOT_ota_updateOta = updateOta;
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,9 +93,14 @@ public class EqDeviceController extends BaseController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 控制设备 门 灯光 控制
|
||||
* 传参设备编码
|
||||
* ota升级到最新版本
|
||||
*/
|
||||
@GetMapping("/ota")
|
||||
public R<String> ota(String equipmentCode){
|
||||
if (equipmentCode == null) throw new ServiceException("设备编码不能为空");
|
||||
return R.ok(eqEquipmentService.ota(equipmentCode));
|
||||
}
|
||||
|
||||
@GetMapping("/operate")
|
||||
public R<String> operate(EqDeviceCmdBo bo){
|
||||
if (bo.getEquipmentCode() == null) throw new ServiceException("设备编码不能为空");
|
||||
|
||||
@ -83,7 +83,11 @@ public class EqTextController extends BaseController {
|
||||
MessageUtils.message("login.name2"),
|
||||
MessageUtils.message("login.name3"),
|
||||
MessageUtils.message("login.name4"),
|
||||
MessageUtils.message("login.name5")
|
||||
MessageUtils.message("login.name5"),
|
||||
MessageUtils.message("login.name6"),
|
||||
MessageUtils.message("login.name7"),
|
||||
MessageUtils.message("login.name8"),
|
||||
MessageUtils.message("login.name9")
|
||||
));
|
||||
|
||||
//《注册》register
|
||||
@ -130,7 +134,10 @@ public class EqTextController extends BaseController {
|
||||
MessageUtils.message("warningClose.name4"),
|
||||
MessageUtils.message("warningClose.name5"),
|
||||
MessageUtils.message("warningClose.name6"),
|
||||
MessageUtils.message("warningClose.name7")
|
||||
MessageUtils.message("warningClose.name7"),
|
||||
MessageUtils.message("warningClose.name8"),
|
||||
MessageUtils.message("warningClose.name9"),
|
||||
MessageUtils.message("warningClose.name10")
|
||||
));
|
||||
|
||||
//《添加设备》add
|
||||
@ -180,7 +187,14 @@ public class EqTextController extends BaseController {
|
||||
MessageUtils.message("detail.name19"),
|
||||
MessageUtils.message("detail.name20"),
|
||||
MessageUtils.message("detail.name21"),
|
||||
MessageUtils.message("detail.name22")
|
||||
MessageUtils.message("detail.name22"),
|
||||
MessageUtils.message("detail.name23"),
|
||||
MessageUtils.message("detail.name24"),
|
||||
MessageUtils.message("detail.name25"),
|
||||
MessageUtils.message("detail.name26"),
|
||||
MessageUtils.message("detail.name27"),
|
||||
MessageUtils.message("detail.name28"),
|
||||
MessageUtils.message("detail.name29")
|
||||
));
|
||||
|
||||
//《倒计时设置》countdown
|
||||
@ -226,7 +240,8 @@ public class EqTextController extends BaseController {
|
||||
MessageUtils.message("clearcode.name2"),
|
||||
MessageUtils.message("clearcode.name3"),
|
||||
MessageUtils.message("clearcode.name4"),
|
||||
MessageUtils.message("clearcode.name5")
|
||||
MessageUtils.message("clearcode.name5"),
|
||||
MessageUtils.message("clearcode.name6")
|
||||
));
|
||||
|
||||
//《设备掉线详情》offDetail
|
||||
@ -259,7 +274,14 @@ public class EqTextController extends BaseController {
|
||||
MessageUtils.message("set.name19"),
|
||||
MessageUtils.message("set.name20"),
|
||||
MessageUtils.message("set.name21"),
|
||||
MessageUtils.message("set.name22")
|
||||
MessageUtils.message("set.name22"),
|
||||
MessageUtils.message("set.name23"),
|
||||
MessageUtils.message("set.name24"),
|
||||
MessageUtils.message("set.name25"),
|
||||
MessageUtils.message("set.name26"),
|
||||
MessageUtils.message("set.name27"),
|
||||
MessageUtils.message("set.name28"),
|
||||
MessageUtils.message("set.name29")
|
||||
));
|
||||
|
||||
//《通用》setCommon
|
||||
@ -538,7 +560,8 @@ public class EqTextController extends BaseController {
|
||||
MessageUtils.message("ble.name69"),
|
||||
MessageUtils.message("ble.name70"),
|
||||
MessageUtils.message("ble.name71"),
|
||||
MessageUtils.message("ble.name72")
|
||||
MessageUtils.message("ble.name72"),
|
||||
MessageUtils.message("ble.name73")
|
||||
));
|
||||
|
||||
return R.ok(result);
|
||||
|
||||
@ -40,6 +40,6 @@ public class DeviceCtlCmd {
|
||||
|
||||
public static final String RFControllorPair = "URC+ECTAS=GarageDoor,RFControllorPair,{},{},\r\n";
|
||||
public static final String RFControllorErase = "URC+ECTAS=GarageDoor,RFControllorErase,{},{},\r\n";
|
||||
|
||||
public static final String wifiDefault = "wifiDefault\r\n";//wifi默认值 随意填写
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,37 @@
|
||||
package org.dromara.web.device.iot;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @ClassName : DeviceCredentials
|
||||
* @Author : ZZC
|
||||
* @Date : 2024/10/23 1:19
|
||||
* @Description :
|
||||
**/
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class DeviceCredentials implements Serializable {
|
||||
|
||||
private IdDTO id;
|
||||
private Long createdTime;
|
||||
private DeviceIdDTO deviceId;
|
||||
private String credentialsType;
|
||||
private String credentialsId;
|
||||
private Object credentialsValue;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class IdDTO {
|
||||
private String id;
|
||||
}
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class DeviceIdDTO {
|
||||
private String entityType;
|
||||
private String id;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,61 @@
|
||||
package org.dromara.web.device.iot;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @ClassName : DeviceOtaPackages
|
||||
* @Author : ZZC
|
||||
* @Date : 2024/10/23 1:09
|
||||
* @Description : 设备更新包
|
||||
**/
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class DeviceOtaPackages implements Serializable {
|
||||
|
||||
private IdDTO id;
|
||||
private Long createdTime;
|
||||
private AdditionalInfoDTO additionalInfo;
|
||||
private TenantIdDTO tenantId;
|
||||
private DeviceProfileIdDTO deviceProfileId;
|
||||
private String type;
|
||||
private String title;
|
||||
private String version;
|
||||
private String tag;
|
||||
private Object url;
|
||||
private Boolean hasData;
|
||||
private String fileName;
|
||||
private String contentType;
|
||||
private String checksumAlgorithm;
|
||||
private String checksum;
|
||||
private Integer dataSize;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class IdDTO {
|
||||
private String entityType;
|
||||
private String id;
|
||||
}
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class AdditionalInfoDTO {
|
||||
private String description;
|
||||
}
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class TenantIdDTO {
|
||||
private String entityType;
|
||||
private String id;
|
||||
}
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class DeviceProfileIdDTO {
|
||||
private String entityType;
|
||||
private String id;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
package org.dromara.web.device.iot;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @ClassName : DeviceCtlDto
|
||||
* @Author : ZZC
|
||||
* @Date : 2024/7/25 11:21
|
||||
* @Discription : 控制入参
|
||||
**/
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class DeviceWifiCtlDto implements Serializable {
|
||||
|
||||
private String method = "setGpio";
|
||||
private Params params;
|
||||
private Boolean persistent = false;
|
||||
private Integer timeout = 5000;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class Params {
|
||||
private String wifireset;
|
||||
}
|
||||
}
|
||||
@ -41,6 +41,7 @@ public class EqDeviceCmdBo implements Serializable {
|
||||
* 8.关灯
|
||||
* 9对码
|
||||
* 10.清码
|
||||
* 20.支持单独修改wifi
|
||||
*/
|
||||
private int operateType;
|
||||
/**
|
||||
|
||||
@ -106,4 +106,6 @@ public interface IEqEquipmentService {
|
||||
* @return
|
||||
*/
|
||||
EqEquipmentStatisticsVo selectEquipmentStatistic(Integer type, String startTime, String endTime);
|
||||
|
||||
String ota(String equipmentCode);
|
||||
}
|
||||
|
||||
@ -16,6 +16,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@ -50,6 +51,22 @@ public class IotService {
|
||||
return postSendWithParam(CommonYmlConfig.URL_IOT_OPERATE, paramMap, JSON.toJSONString(dto));
|
||||
}
|
||||
|
||||
/**
|
||||
* 单独修改wifi
|
||||
* @param deviceCode
|
||||
* @param cmd
|
||||
* @return
|
||||
*/
|
||||
public String httpCtlPostWifiSend(String deviceCode,String cmd){
|
||||
DeviceWifiCtlDto dto = new DeviceWifiCtlDto();
|
||||
DeviceWifiCtlDto.Params params = new DeviceWifiCtlDto.Params();
|
||||
params.setWifireset(cmd);
|
||||
dto.setParams(params);
|
||||
Map<String, String> paramMap = new HashMap<>();
|
||||
paramMap.put("deviceId",deviceCode);
|
||||
return postSendWithParam(CommonYmlConfig.URL_IOT_OPERATE, paramMap, JSON.toJSONString(dto));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备信息
|
||||
* @param deviceCode
|
||||
@ -197,6 +214,48 @@ public class IotService {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取最新资源包
|
||||
* @param deviceProfileId
|
||||
* @return
|
||||
*/
|
||||
public 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);
|
||||
DeviceOtaPackages deviceDto = deviceOtaPackages.get(0);
|
||||
if (deviceDto.getId()==null) throw new RuntimeException(MessageUtils.message("message.fault.device.notfound"));
|
||||
return deviceDto;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询设备凭证
|
||||
* @param deviceId
|
||||
* @return
|
||||
*/
|
||||
public DeviceCredentials httpCredentials(String deviceId){
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("deviceId",deviceId);
|
||||
String send = getSend(CommonYmlConfig.URL_IOT_ota_credentials, map);
|
||||
JSONObject jsonObject = JSON.parseObject(send);
|
||||
DeviceCredentials deviceDto = jsonObject.toJavaObject(DeviceCredentials.class);
|
||||
if (deviceDto.getId()==null) throw new RuntimeException(MessageUtils.message("message.fault.device.notfound"));
|
||||
return deviceDto;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询设备凭证
|
||||
*/
|
||||
public String httpPostUpdateOta(String accessToken,DeviceDto dto){
|
||||
Map<String, String> paramMap = new HashMap<>();
|
||||
paramMap.put("accessToken",accessToken);
|
||||
return postSendWithParam(CommonYmlConfig.URL_IOT_ota_updateOta, paramMap, JSON.toJSONString(dto));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getToken() {
|
||||
String token = tokenCache.getIfPresent("token");
|
||||
if (token == null){
|
||||
|
||||
@ -210,11 +210,17 @@ public class EqEquipmentServiceImpl implements IEqEquipmentService {
|
||||
case 8: cmd = DeviceCtlCmd.LightSwitch_false; break;//照明灯开关 关
|
||||
case 9: cmd = DeviceCtlCmd.RFControllorPair; break;//对码
|
||||
case 10: cmd = DeviceCtlCmd.RFControllorErase; break;//清码
|
||||
case 20: cmd = DeviceCtlCmd.wifiDefault; break;//wifi单独修改
|
||||
default:
|
||||
return "指令类型错误";
|
||||
}
|
||||
//增加操作次数 更新到设备表中
|
||||
return iotService.httpCtlPostSend(bo.getEquipmentCode(),cmd);
|
||||
if (operateType == 20){
|
||||
return iotService.httpCtlPostWifiSend(bo.getEquipmentCode(),cmd);
|
||||
}else {
|
||||
return iotService.httpCtlPostSend(bo.getEquipmentCode(),cmd);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -384,7 +390,22 @@ public class EqEquipmentServiceImpl implements IEqEquipmentService {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String ota(String equipmentCode) {
|
||||
//1.从iot平台设置用户绑定 并获取设备信息
|
||||
DeviceDto deviceDto = iotService.httpDeviceGetSend(equipmentCode);
|
||||
DeviceDto.DeviceProfileId deviceProfileId = deviceDto.getDeviceProfileId();
|
||||
String profileIdId = deviceProfileId.getId();//获取配置id
|
||||
//2.查询OTA资源包
|
||||
DeviceOtaPackages deviceOtaPackages = iotService.httpOtaPackages(profileIdId);
|
||||
//3.查询设备凭证
|
||||
DeviceCredentials deviceCredentials = iotService.httpCredentials(equipmentCode);
|
||||
String assesToken = deviceCredentials.getCredentialsId();
|
||||
//4拿到凭证修改设备 使用获取设备信息的类信息作为参数
|
||||
deviceDto.getFirmwareId().setId(deviceOtaPackages.getId().getId());//设置升级包id
|
||||
|
||||
return iotService.httpPostUpdateOta(assesToken,deviceDto);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@ -267,6 +267,9 @@ iot:
|
||||
operate: /api/plugins/rpc/oneway/{deviceId}
|
||||
device: /api/device/{deviceId}
|
||||
deviceByName: /api/tenant/devices?deviceName={deviceName}
|
||||
otaPackages: /api/otaPackages/{deviceProfileId}/FIRMWARE?pageSize=10&page=0
|
||||
credentials: /api/device/{deviceId}/credentials
|
||||
updateOta: /api/device?accessToken={accessToken}
|
||||
|
||||
# 个推
|
||||
getui:
|
||||
|
||||
@ -266,3 +266,7 @@ iot:
|
||||
telemetry: /api/plugins/telemetry/{entityType}/{entityId}/values/timeseries
|
||||
operate: /api/plugins/rpc/oneway/{deviceId}
|
||||
device: /api/device/{deviceId}
|
||||
deviceByName: /api/tenant/devices?deviceName={deviceName}
|
||||
otaPackages: /api/otaPackages/{deviceProfileId}/FIRMWARE?pageSize=10&page=0
|
||||
credentials: /api/device/{deviceId}/credentials
|
||||
updateOta: /api/device?accessToken={accessToken}
|
||||
|
||||
@ -268,3 +268,7 @@ iot:
|
||||
telemetry: /api/plugins/telemetry/{entityType}/{entityId}/values/timeseries
|
||||
operate: /api/plugins/rpc/oneway/{deviceId}
|
||||
device: /api/device/{deviceId}
|
||||
deviceByName: /api/tenant/devices?deviceName={deviceName}
|
||||
otaPackages: /api/otaPackages/{deviceProfileId}/FIRMWARE?pageSize=10&page=0
|
||||
credentials: /api/device/{deviceId}/credentials
|
||||
updateOta: /api/device?accessToken={accessToken}
|
||||
|
||||
@ -113,6 +113,7 @@ login.name5=支持邮箱登录
|
||||
login.name6=服务协议
|
||||
login.name7=隐私协议
|
||||
login.name8=忘记密码
|
||||
login.name9=请先阅读并签署《服务协议》和《隐私协议》
|
||||
##《注册》register
|
||||
register.name0=注册
|
||||
register.name1=注册账号
|
||||
@ -148,6 +149,9 @@ warningClose.name4=分钟了,请记得关门
|
||||
warningClose.name5=关门
|
||||
warningClose.name6=我知道了
|
||||
warningClose.name7=是否关门?
|
||||
warningClose.name8=关门中……
|
||||
warningClose.name9=开门中……
|
||||
warningClose.name10=已暂停
|
||||
##《添加设备》add
|
||||
add.name0=添加设备
|
||||
add.name1=请输入设备编码
|
||||
@ -192,6 +196,7 @@ detail.name25=半开门管理
|
||||
detail.name26=设备分享
|
||||
detail.name27=分钟
|
||||
detail.name28=小时
|
||||
detail.name29=半门高度设置
|
||||
##《倒计时设置》countdown
|
||||
countdown.name0=倒计时设置
|
||||
countdown.name1=取消
|
||||
@ -249,7 +254,7 @@ set.name11=自动关门
|
||||
set.name12=打开此功能,当门开到最大时,在设置的倒计时时间内,门没有被控制,则在倒计时结束后,门会自动关闭。
|
||||
set.name13=自动关门时间设置
|
||||
set.name14=运行次数
|
||||
set.name15=WiFi网络
|
||||
set.name15=更换WiFi
|
||||
set.name16=时区
|
||||
set.name17=设备型号
|
||||
set.name18=序列号
|
||||
@ -258,6 +263,12 @@ set.name20=MCU版本
|
||||
set.name21=删除设备
|
||||
set.name22=启动自动开门功能,需要先打开红外保护感应功能
|
||||
set.name23=设备删除成功,正在跳转首页……
|
||||
set.name24=设备版本号
|
||||
set.name25=确认升级
|
||||
set.name26=更换WiFi
|
||||
set.name27=已连接WiFi
|
||||
set.name28=当前设备版本号
|
||||
set.name29=发现设备新版本
|
||||
|
||||
##《通用》setCommon
|
||||
setCommon.detail=详情
|
||||
@ -462,7 +473,7 @@ ble.name38=连接蓝牙成功!
|
||||
ble.name39=连接蓝牙失败!可尝试重新搜索,重启蓝牙,或重启应用!
|
||||
ble.name40=蓝牙连接断开!
|
||||
ble.name41=未知错误!尝试手动重启蓝牙,或重启应用!
|
||||
ble.name42=配网成功!
|
||||
ble.name42=配网成功,设备正在初始化,请等待3s……
|
||||
ble.name43=密码错误,重新尝试!
|
||||
ble.name44=无法找到网络,重新尝试!
|
||||
ble.name45=设备断开连接,重新尝试!
|
||||
@ -493,6 +504,7 @@ ble.name69=观察:显示器显示“A”,此时设备开始配网;
|
||||
ble.name70=5.在APP上对设备进行配网,直至配网完成;
|
||||
ble.name71=观察:配网完成后显示器显示“11”,设备进入待机装填;
|
||||
ble.name72=返回首页
|
||||
ble.name73=设备初始化成功,是否修改设备密码?
|
||||
|
||||
email.name0=登录验证码
|
||||
email.name1=您本次验证码为
|
||||
|
||||
Loading…
Reference in New Issue
Block a user