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-离线
|
// 1-未激活,2-禁用,3-在线,4-离线
|
||||||
if(device.getStatus()==3){
|
if(device.getStatus()==3){
|
||||||
device.setStatus(4);
|
device.setStatus(4);
|
||||||
deviceService.updateDevice(device);
|
deviceService.updateDeviceStatus(device);
|
||||||
// 发布设备信息
|
// 发布设备信息
|
||||||
publishInfo(device.getProductId(),device.getSerialNumber());
|
publishInfo(device.getProductId(),device.getSerialNumber());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -141,12 +141,19 @@ public interface IDeviceService
|
|||||||
public AjaxResult updateDevice(Device device);
|
public AjaxResult updateDevice(Device device);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新设备状态
|
* 更新设备状态和定位
|
||||||
* @param device 设备
|
* @param device 设备
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int updateDeviceStatusAndLocation(Device device,String ipAddress);
|
public int updateDeviceStatusAndLocation(Device device,String ipAddress);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新设备状态
|
||||||
|
* @param device 设备
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateDeviceStatus(Device device);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 上报设备信息
|
* 上报设备信息
|
||||||
* @param device 设备
|
* @param device 设备
|
||||||
|
|||||||
@@ -533,15 +533,6 @@ public class DeviceServiceImpl implements IDeviceService {
|
|||||||
SysUser user = getLoginUser().getUser();
|
SysUser user = getLoginUser().getUser();
|
||||||
device.setNetworkIp(user.getLoginIp());
|
device.setNetworkIp(user.getLoginIp());
|
||||||
setLocation(user.getLoginIp(),device);
|
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);
|
deviceMapper.insertDevice(device);
|
||||||
// 添加设备用户
|
// 添加设备用户
|
||||||
@@ -783,6 +774,16 @@ public class DeviceServiceImpl implements IDeviceService {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param device 设备状态
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int updateDeviceStatus(Device device) {
|
||||||
|
return deviceMapper.updateDeviceStatus(device);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据IP获取地址
|
* 根据IP获取地址
|
||||||
* @param ip
|
* @param ip
|
||||||
|
|||||||
@@ -224,9 +224,13 @@ public class ToolServiceImpl implements IToolService
|
|||||||
}
|
}
|
||||||
String mqttPassword = passwordArray[0];
|
String mqttPassword = passwordArray[0];
|
||||||
String authCode = passwordArray.length == 2 ? passwordArray[1] : "";
|
String authCode = passwordArray.length == 2 ? passwordArray[1] : "";
|
||||||
// 验证用户名和密码
|
// 验证用户名
|
||||||
if ((!mqttConfig.getusername().equals(mqttModel.getUserName())) || (!mqttConfig.getpassword().equals(mqttPassword))) {
|
if (!mqttModel.getUserName().equals(productModel.getMqttAccount())) {
|
||||||
return returnUnauthorized(mqttModel, "设备简单认证,mqtt账号和密码与认证服务器配置不匹配");
|
return returnUnauthorized(mqttModel, "设备简单认证,设备mqtt用户名错误");
|
||||||
|
}
|
||||||
|
// 验证密码
|
||||||
|
if (!mqttPassword.equals(productModel.getMqttPassword())) {
|
||||||
|
return returnUnauthorized(mqttModel, "设备简单认证,设备mqtt密码错误");
|
||||||
}
|
}
|
||||||
// 验证授权码
|
// 验证授权码
|
||||||
if (productModel.getIsAuthorize() == 1) {
|
if (productModel.getIsAuthorize() == 1) {
|
||||||
|
|||||||
Reference in New Issue
Block a user