mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-17 16:36:03 +08:00
上报设备信息可更新设备关联的用户
This commit is contained in:
@@ -64,19 +64,19 @@ public class Product extends BaseEntity
|
||||
}
|
||||
|
||||
/** 状态(1-未发布,2-已发布,不能修改) */
|
||||
@Excel(name = "状态", readConverterExp = "1=-未发布,2-已发布,不能修改")
|
||||
@Excel(name = "状态", readConverterExp = "1==未发布,2=已发布,不能修改")
|
||||
private Integer status;
|
||||
|
||||
/** 设备类型(1-直连设备、2-网关子设备、3-网关设备) */
|
||||
@Excel(name = "设备类型", readConverterExp = "1=-直连设备、2-网关子设备、3-网关设备")
|
||||
@Excel(name = "设备类型", readConverterExp = "1=直连设备、2=网关子设备、3=网关设备")
|
||||
private Integer deviceType;
|
||||
|
||||
/** 联网方式(1-wifi、2-蓝牙、3-wifi+蓝牙) */
|
||||
@Excel(name = "联网方式", readConverterExp = "1=-wifi、2-蓝牙、3-wifi+蓝牙")
|
||||
/** 联网方式(1=-wifi、2-蜂窝(2G/3G/4G/5G)、3-以太网、4-其他) */
|
||||
@Excel(name = "联网方式", readConverterExp = "1=-wifi、2=蜂窝(2G/3G/4G/5G)、3=以太网、4=其他")
|
||||
private Integer networkMethod;
|
||||
|
||||
/** 认证方式(1-账号密码、2-证书、3-Http) */
|
||||
@Excel(name = "认证方式", readConverterExp = "1=-账号密码、2-证书、3-Http")
|
||||
@Excel(name = "认证方式", readConverterExp = "1=账号密码、2=证书、3=Http")
|
||||
private Integer vertificateMethod;
|
||||
|
||||
/** 图片地址 */
|
||||
|
||||
@@ -902,6 +902,7 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int reportDevice(Device device, Device deviceEntity) {
|
||||
// 未采用设备定位则清空定位,定位方式(1=ip自动定位,2=设备定位,3=自定义)
|
||||
if (deviceEntity.getLocationWay() != 2) {
|
||||
@@ -910,11 +911,38 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
}
|
||||
int result = 0;
|
||||
if (deviceEntity != null) {
|
||||
// 更新设备信息
|
||||
// 联网方式为Wifi的需要更新用户信息(1=wifi、2=蜂窝(2G/3G/4G/5G)、3=以太网、4=其他)
|
||||
Product product = productService.selectProductByProductId(deviceEntity.getProductId());
|
||||
if (product.getNetworkMethod() == 1) {
|
||||
if (deviceEntity.getUserId().longValue() != device.getUserId().longValue()) {
|
||||
// 先删除设备的所有用户
|
||||
deviceUserMapper.deleteDeviceUserByDeviceId(new UserIdDeviceIdModel(null, deviceEntity.getDeviceId()));
|
||||
// 添加新的设备用户
|
||||
SysUser sysUser = userService.selectUserById(device.getUserId());
|
||||
DeviceUser deviceUser = new DeviceUser();
|
||||
deviceUser.setUserId(sysUser.getUserId());
|
||||
deviceUser.setUserName(sysUser.getUserName());
|
||||
deviceUser.setPhonenumber(sysUser.getPhonenumber());
|
||||
deviceUser.setDeviceId(deviceEntity.getDeviceId());
|
||||
deviceUser.setDeviceName(deviceEntity.getDeviceName());
|
||||
deviceUser.setTenantId(deviceEntity.getTenantId());
|
||||
deviceUser.setTenantName(deviceEntity.getTenantName());
|
||||
deviceUser.setIsOwner(1);
|
||||
deviceUser.setCreateTime(DateUtils.getNowDate());
|
||||
deviceUserMapper.insertDeviceUser(deviceUser);
|
||||
// 更新设备用户信息
|
||||
device.setUserId(device.getUserId());
|
||||
device.setUserName(sysUser.getUserName());
|
||||
}
|
||||
}else{
|
||||
// 其他联网设备不更新用户信息
|
||||
device.setUserId(null);
|
||||
}
|
||||
device.setUpdateTime(DateUtils.getNowDate());
|
||||
if (deviceEntity.getActiveTime() == null || deviceEntity.getActiveTime().equals("")) {
|
||||
device.setActiveTime(DateUtils.getNowDate());
|
||||
}
|
||||
// 不更新物模型
|
||||
device.setThingsModelValue(null);
|
||||
result = deviceMapper.updateDeviceBySerialNumber(device);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user