|
@@ -269,7 +269,7 @@ public class DeviceGatewayImpl implements DeviceGateway {
|
|
}
|
|
}
|
|
|
|
|
|
// 记录操作日志
|
|
// 记录操作日志
|
|
- logService.saveLog(Long.valueOf(devId),OprLogType.UNBLIND_DEVICE.getCode(), logContent);
|
|
|
|
|
|
+ logService.saveLog(Long.valueOf(devId), OprLogType.UNBLIND_DEVICE.getCode(), logContent);
|
|
return updateFlag;
|
|
return updateFlag;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -298,7 +298,7 @@ public class DeviceGatewayImpl implements DeviceGateway {
|
|
devInfo.setActiveTime(LocalDateTime.now());
|
|
devInfo.setActiveTime(LocalDateTime.now());
|
|
devInfoService.updateById(devInfo);
|
|
devInfoService.updateById(devInfo);
|
|
|
|
|
|
- logService.saveLog(devInfo.getDevId(),OprLogType.BIND_DEVICE.getCode(), String.format("用户 %d 绑定设备 %s", request.getUserId(), request.getClientId()));
|
|
|
|
|
|
+ logService.saveLog(devInfo.getDevId(), OprLogType.BIND_DEVICE.getCode(), String.format("用户 %d 绑定设备 %s", request.getUserId(), request.getClientId()));
|
|
|
|
|
|
//5.返回绑定结果和设备主键id
|
|
//5.返回绑定结果和设备主键id
|
|
DeviceDTO result = new DeviceDTO();
|
|
DeviceDTO result = new DeviceDTO();
|
|
@@ -326,9 +326,6 @@ public class DeviceGatewayImpl implements DeviceGateway {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
@Override
|
|
@Override
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
public Boolean handleEvent(Long eventListId) {
|
|
public Boolean handleEvent(Long eventListId) {
|
|
@@ -387,7 +384,7 @@ public class DeviceGatewayImpl implements DeviceGateway {
|
|
throw new BizException(ErrorEnum.DEVICE_IS_NOT_EXIST.getErrorCode(), ErrorEnum.DEVICE_IS_NOT_EXIST.getErrorMessage());
|
|
throw new BizException(ErrorEnum.DEVICE_IS_NOT_EXIST.getErrorCode(), ErrorEnum.DEVICE_IS_NOT_EXIST.getErrorMessage());
|
|
}
|
|
}
|
|
|
|
|
|
- logService.saveLog(devInfo.getDevId(),OprLogType.UPDATE_DEVICE.getCode(), devInfo);
|
|
|
|
|
|
+ logService.saveLog(devInfo.getDevId(), OprLogType.UPDATE_DEVICE.getCode(), devInfo);
|
|
|
|
|
|
//2.更新数据
|
|
//2.更新数据
|
|
devInfo.setTenantId(params.getTenantId());
|
|
devInfo.setTenantId(params.getTenantId());
|
|
@@ -468,7 +465,7 @@ public class DeviceGatewayImpl implements DeviceGateway {
|
|
throw new BizException(ErrorEnum.DEVICE_UPDATE_FAIL.getErrorCode(), ErrorEnum.DEVICE_UPDATE_FAIL.getErrorMessage());
|
|
throw new BizException(ErrorEnum.DEVICE_UPDATE_FAIL.getErrorCode(), ErrorEnum.DEVICE_UPDATE_FAIL.getErrorMessage());
|
|
}
|
|
}
|
|
|
|
|
|
- logService.saveLog(devInfo.getDevId(),OprLogType.UPDATE_DEVICE.getCode(), params);
|
|
|
|
|
|
+ logService.saveLog(devInfo.getDevId(), OprLogType.UPDATE_DEVICE.getCode(), params);
|
|
|
|
|
|
//5.通过MQTT把信息参数发送到设备
|
|
//5.通过MQTT把信息参数发送到设备
|
|
mqttSend.sendDeviceParamsToMqtt(devInfo.getClientId(), params);
|
|
mqttSend.sendDeviceParamsToMqtt(devInfo.getClientId(), params);
|
|
@@ -489,15 +486,6 @@ public class DeviceGatewayImpl implements DeviceGateway {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- // 辅助方法:如果值为null则设置默认值
|
|
|
|
- private <T> void setIfNull(java.util.function.Supplier<T> getter,
|
|
|
|
- java.util.function.Supplier<T> defaultValueSupplier,
|
|
|
|
- java.util.function.Consumer<T> setter) {
|
|
|
|
- if (getter.get() == null) {
|
|
|
|
- setter.accept(defaultValueSupplier.get());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
@Override
|
|
@Override
|
|
public Boolean updateDeviceLocation(DeviceLocationParams params) {
|
|
public Boolean updateDeviceLocation(DeviceLocationParams params) {
|
|
|
|
|
|
@@ -548,7 +536,7 @@ public class DeviceGatewayImpl implements DeviceGateway {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- @Transactional
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
public Boolean statusLight(StatusLightParams params) {
|
|
public Boolean statusLight(StatusLightParams params) {
|
|
//1.校验设备是否存在
|
|
//1.校验设备是否存在
|
|
DevInfo devInfo = devInfoService.getById(params.getDevId());
|
|
DevInfo devInfo = devInfoService.getById(params.getDevId());
|
|
@@ -611,6 +599,7 @@ public class DeviceGatewayImpl implements DeviceGateway {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
public Boolean saveRoom(RoomParam param) {
|
|
public Boolean saveRoom(RoomParam param) {
|
|
|
|
|
|
//查询设备信息
|
|
//查询设备信息
|
|
@@ -645,7 +634,7 @@ public class DeviceGatewayImpl implements DeviceGateway {
|
|
}
|
|
}
|
|
|
|
|
|
// 记录操作日志
|
|
// 记录操作日志
|
|
- logService.saveLog(param.getDevId(),OprLogType.UPDATE_ROOM.getCode(), param);
|
|
|
|
|
|
+ logService.saveLog(param.getDevId(), OprLogType.UPDATE_ROOM.getCode(), param);
|
|
|
|
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -801,7 +790,7 @@ public class DeviceGatewayImpl implements DeviceGateway {
|
|
devShareService.removeById(devShare);
|
|
devShareService.removeById(devShare);
|
|
|
|
|
|
//3.取消分享记录到日志
|
|
//3.取消分享记录到日志
|
|
- logService.saveLog(devShare.getDevId(),OprLogType.CANCEL_SHARE.getCode(), shareId);
|
|
|
|
|
|
+ logService.saveLog(devShare.getDevId(), OprLogType.CANCEL_SHARE.getCode(), shareId);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -820,7 +809,7 @@ public class DeviceGatewayImpl implements DeviceGateway {
|
|
devShareService.updateById(devShare);
|
|
devShareService.updateById(devShare);
|
|
|
|
|
|
//3.记录操作日志
|
|
//3.记录操作日志
|
|
- logService.saveLog(devShare.getDevId(),OprLogType.UPDATE_DEVICE_SHARE_PERMISSION.getCode(), param);
|
|
|
|
|
|
+ logService.saveLog(devShare.getDevId(), OprLogType.UPDATE_DEVICE_SHARE_PERMISSION.getCode(), param);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -1107,14 +1096,18 @@ public class DeviceGatewayImpl implements DeviceGateway {
|
|
// 6.遍历设备分享表
|
|
// 6.遍历设备分享表
|
|
if (!devShareList.isEmpty()) {
|
|
if (!devShareList.isEmpty()) {
|
|
devShareList.forEach(devShare -> {
|
|
devShareList.forEach(devShare -> {
|
|
- if (Objects.equals(devShare.getSharerUserId(), userInfo.getUserId())) {
|
|
|
|
|
|
+ if (Objects.equals(devShare.getSharedUserId(), userInfo.getUserId())) {
|
|
devShare.setIsDeleted(BasePO.DeleteFlag.DELETED); // 软删除
|
|
devShare.setIsDeleted(BasePO.DeleteFlag.DELETED); // 软删除
|
|
|
|
+ devShare.setUpdateTime(LocalDateTime.now());
|
|
|
|
+ devShareService.removeById(devShare);
|
|
} else {
|
|
} else {
|
|
- devShare.setSharerUserId(userInfo.getUserId()); // 更新分享者用户
|
|
|
|
|
|
+ devShare.setSharerUserId(userInfo.getUserId()); // 更新分享者用户
|
|
|
|
+ devShare.setSharerPhone(param.getPhone());
|
|
|
|
+ devShare.setUpdateTime(LocalDateTime.now());
|
|
|
|
+ devShareService.updateById(devShare);
|
|
}
|
|
}
|
|
- devShare.setUpdateTime(LocalDateTime.now()); // 更新修改时间
|
|
|
|
});
|
|
});
|
|
- devShareService.updateBatchById(devShareList); // 批量更新设备分享记录
|
|
|
|
|
|
+ // 批量更新设备分享记录
|
|
}
|
|
}
|
|
// 7.更新设备信息(设备归属转移)
|
|
// 7.更新设备信息(设备归属转移)
|
|
devInfo.setUpdateTime(LocalDateTime.now()); // 更新修改时间
|
|
devInfo.setUpdateTime(LocalDateTime.now()); // 更新修改时间
|
|
@@ -1126,8 +1119,9 @@ public class DeviceGatewayImpl implements DeviceGateway {
|
|
String fwhOpenId = wxRelation.getFwhOpenId();
|
|
String fwhOpenId = wxRelation.getFwhOpenId();
|
|
mqttSend.sendDeviceTransferMsg(devInfo, userInfo, fwhOpenId);
|
|
mqttSend.sendDeviceTransferMsg(devInfo, userInfo, fwhOpenId);
|
|
log.info("设备转移服务号推送目标对象成功,clientId {},目标对象phone {}", devInfo.getClientId(), userInfo.getPhone());
|
|
log.info("设备转移服务号推送目标对象成功,clientId {},目标对象phone {}", devInfo.getClientId(), userInfo.getPhone());
|
|
|
|
+ } else {
|
|
|
|
+ log.info("设备转移服务号推送目标对象失败,目标对象服务号openId为空");
|
|
}
|
|
}
|
|
- log.info("设备转移服务号推送目标对象失败,目标对象服务号openId为空");
|
|
|
|
|
|
|
|
// 9.记录操作日志
|
|
// 9.记录操作日志
|
|
String logContent = String.format(
|
|
String logContent = String.format(
|
|
@@ -1137,7 +1131,7 @@ public class DeviceGatewayImpl implements DeviceGateway {
|
|
devInfo.getDevId(), // 转移的设备id
|
|
devInfo.getDevId(), // 转移的设备id
|
|
userInfo.getUserId() // 转移后的用户id
|
|
userInfo.getUserId() // 转移后的用户id
|
|
);
|
|
);
|
|
- logService.saveLog(param.getDevId(),OprLogType.DEVICE_TRANSFER.getCode(), logContent);
|
|
|
|
|
|
+ logService.saveLog(param.getDevId(), OprLogType.DEVICE_TRANSFER.getCode(), logContent);
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|