mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-17 16:36:03 +08:00
设备状态同步改进
This commit is contained in:
@@ -274,7 +274,7 @@ public class EmqxService {
|
||||
// 1-未激活,2-禁用,3-在线,4-离线
|
||||
if(device.getStatus()==3){
|
||||
device.setStatus(4);
|
||||
deviceService.updateDevice(device);
|
||||
deviceService.updateDeviceStatus(device);
|
||||
// 发布设备信息
|
||||
publishInfo(device.getProductId(),device.getSerialNumber());
|
||||
}
|
||||
|
||||
@@ -141,12 +141,19 @@ public interface IDeviceService
|
||||
public AjaxResult updateDevice(Device device);
|
||||
|
||||
/**
|
||||
* 更新设备状态
|
||||
* 更新设备状态和定位
|
||||
* @param device 设备
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateDeviceStatusAndLocation(Device device,String ipAddress);
|
||||
|
||||
/**
|
||||
* 更新设备状态
|
||||
* @param device 设备
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateDeviceStatus(Device device);
|
||||
|
||||
/**
|
||||
* 上报设备信息
|
||||
* @param device 设备
|
||||
|
||||
@@ -533,15 +533,6 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
SysUser user = getLoginUser().getUser();
|
||||
device.setNetworkIp(user.getLoginIp());
|
||||
setLocation(user.getLoginIp(),device);
|
||||
// if(device.getLongitude()==null || device.getLongitude().equals("")){
|
||||
// device.setLongitude(BigDecimal.valueOf(116.23-(Math.random()*15)));
|
||||
// }
|
||||
// if(device.getLatitude()==null || device.getLatitude().equals("")){
|
||||
// device.setLatitude(BigDecimal.valueOf(39.54-(Math.random()*15)));
|
||||
// }
|
||||
// if(device.getNetworkAddress()==null || device.getNetworkAddress().equals("")){
|
||||
// device.setNetworkAddress("中国");
|
||||
// }
|
||||
|
||||
deviceMapper.insertDevice(device);
|
||||
// 添加设备用户
|
||||
@@ -783,6 +774,16 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param device 设备状态
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateDeviceStatus(Device device) {
|
||||
return deviceMapper.updateDeviceStatus(device);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据IP获取地址
|
||||
* @param ip
|
||||
|
||||
@@ -224,9 +224,13 @@ public class ToolServiceImpl implements IToolService
|
||||
}
|
||||
String mqttPassword = passwordArray[0];
|
||||
String authCode = passwordArray.length == 2 ? passwordArray[1] : "";
|
||||
// 验证用户名和密码
|
||||
if ((!mqttConfig.getusername().equals(mqttModel.getUserName())) || (!mqttConfig.getpassword().equals(mqttPassword))) {
|
||||
return returnUnauthorized(mqttModel, "设备简单认证,mqtt账号和密码与认证服务器配置不匹配");
|
||||
// 验证用户名
|
||||
if (!mqttModel.getUserName().equals(productModel.getMqttAccount())) {
|
||||
return returnUnauthorized(mqttModel, "设备简单认证,设备mqtt用户名错误");
|
||||
}
|
||||
// 验证密码
|
||||
if (!mqttPassword.equals(productModel.getMqttPassword())) {
|
||||
return returnUnauthorized(mqttModel, "设备简单认证,设备mqtt密码错误");
|
||||
}
|
||||
// 验证授权码
|
||||
if (productModel.getIsAuthorize() == 1) {
|
||||
|
||||
Reference in New Issue
Block a user