查询设备分享列表(web)
This commit is contained in:
@ -43,7 +43,7 @@ import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.*;
|
||||
public class DeviceShareService {
|
||||
|
||||
private final AppDeviceShareMapper appDeviceShareMapper;
|
||||
|
||||
|
||||
private final DeviceMapper deviceMapper;
|
||||
|
||||
private final DeviceTypeMapper deviceTypeMapper;
|
||||
@ -61,32 +61,32 @@ public class DeviceShareService {
|
||||
}
|
||||
|
||||
private static void buildDeviceStatus(AppDeviceShareVo item) {
|
||||
//设备在线状态
|
||||
String onlineStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX+ item.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX);
|
||||
if(StringUtils.isNotBlank(onlineStatus)){
|
||||
// 设备在线状态
|
||||
String onlineStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + item.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX);
|
||||
if (StringUtils.isNotBlank(onlineStatus)) {
|
||||
|
||||
item.setOnlineStatus(1);
|
||||
}else{
|
||||
} else {
|
||||
item.setOnlineStatus(0);
|
||||
}
|
||||
String deviceStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX+ item.getDeviceImei() + DEVICE_STATUS_KEY_PREFIX);
|
||||
String deviceStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + item.getDeviceImei() + DEVICE_STATUS_KEY_PREFIX);
|
||||
// 获取电量
|
||||
if(StringUtils.isNotBlank(deviceStatus)){
|
||||
if (StringUtils.isNotBlank(deviceStatus)) {
|
||||
JSONObject jsonObject = JSONObject.parseObject(deviceStatus);
|
||||
item.setBattery(jsonObject.getString("batteryPercentage"));
|
||||
}else{
|
||||
} else {
|
||||
item.setBattery("0");
|
||||
}
|
||||
|
||||
String location = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY +DEVICE_KEY_PREFIX+ item.getDeviceImei()+ DEVICE_LOCATION_KEY_PREFIX);
|
||||
if(StringUtils.isNotBlank(location)){
|
||||
String location = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + item.getDeviceImei() + DEVICE_LOCATION_KEY_PREFIX);
|
||||
if (StringUtils.isNotBlank(location)) {
|
||||
JSONObject jsonObject = JSONObject.parseObject(location);
|
||||
item.setLatitude(jsonObject.getString("latitude"));
|
||||
item.setLongitude(jsonObject.getString("longitude"));
|
||||
}
|
||||
|
||||
String alarmStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY +DEVICE_KEY_PREFIX+ item.getDeviceImei()+ DEVICE_ALARM_KEY_PREFIX);
|
||||
if(StringUtils.isNotBlank(alarmStatus)){
|
||||
String alarmStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + item.getDeviceImei() + DEVICE_ALARM_KEY_PREFIX);
|
||||
if (StringUtils.isNotBlank(alarmStatus)) {
|
||||
item.setAlarmStatus(alarmStatus);
|
||||
}
|
||||
}
|
||||
@ -96,7 +96,7 @@ public class DeviceShareService {
|
||||
LambdaQueryWrapper<AppDeviceShare> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(AppDeviceShare::getId, id);
|
||||
List<AppDeviceShareVo> appDeviceShareVos = appDeviceShareMapper.selectVoList(queryWrapper);
|
||||
if(appDeviceShareVos==null || appDeviceShareVos.isEmpty()){
|
||||
if (appDeviceShareVos == null || appDeviceShareVos.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -113,7 +113,7 @@ public class DeviceShareService {
|
||||
shareDetailVo.setDeviceMac(device.getDeviceMac());
|
||||
|
||||
DeviceType deviceType = deviceTypeMapper.selectById(device.getDeviceType());
|
||||
if(deviceType!=null){
|
||||
if (deviceType != null) {
|
||||
shareDetailVo.setCommunicationMode(Integer.valueOf(deviceType.getCommunicationMode()));
|
||||
}
|
||||
shareDetailVo.setDevicePic(device.getDevicePic());
|
||||
@ -125,52 +125,53 @@ public class DeviceShareService {
|
||||
LambdaQueryWrapper<AppPersonnelInfo> qw = new LambdaQueryWrapper<>();
|
||||
qw.eq(AppPersonnelInfo::getDeviceId, device.getId());
|
||||
List<AppPersonnelInfoVo> appPersonnelInfoVos = appPersonnelInfoMapper.selectVoList(qw);
|
||||
if(appPersonnelInfoVos!=null && !appPersonnelInfoVos.isEmpty()){
|
||||
if (appPersonnelInfoVos != null && !appPersonnelInfoVos.isEmpty()) {
|
||||
shareDetailVo.setPersonnelInfo(appPersonnelInfoVos.get(0));
|
||||
}
|
||||
//设备在线状态
|
||||
String onlineStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + device.getDeviceImei()+ DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX);
|
||||
if(StringUtils.isNotBlank(onlineStatus)){
|
||||
// 设备在线状态
|
||||
String onlineStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + device.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX);
|
||||
if (StringUtils.isNotBlank(onlineStatus)) {
|
||||
shareDetailVo.setOnlineStatus(1);
|
||||
}else{
|
||||
} else {
|
||||
shareDetailVo.setOnlineStatus(0);
|
||||
}
|
||||
String deviceStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + device.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_STATUS_KEY_PREFIX);
|
||||
String deviceStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + device.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_STATUS_KEY_PREFIX);
|
||||
// 获取电量
|
||||
if(StringUtils.isNotBlank(deviceStatus)){
|
||||
if (StringUtils.isNotBlank(deviceStatus)) {
|
||||
JSONObject jsonObject = JSONObject.parseObject(deviceStatus);
|
||||
shareDetailVo.setMainLightMode(jsonObject.getString("mainLightMode"));
|
||||
shareDetailVo.setLaserLightMode(jsonObject.getString("laserLightMode"));
|
||||
shareDetailVo.setBatteryPercentage(jsonObject.getString("batteryPercentage"));
|
||||
shareDetailVo.setChargeState(jsonObject.getString("chargeState"));
|
||||
shareDetailVo.setBatteryRemainingTime(jsonObject.getString("batteryRemainingTime"));
|
||||
}else{
|
||||
} else {
|
||||
shareDetailVo.setBatteryPercentage("0");
|
||||
}
|
||||
|
||||
// 获取经度纬度
|
||||
String locationKey = GlobalConstants.GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + device.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_LOCATION_KEY_PREFIX;
|
||||
String locationKey = GlobalConstants.GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + device.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_LOCATION_KEY_PREFIX;
|
||||
String locationInfo = RedisUtils.getCacheObject(locationKey);
|
||||
if(StringUtils.isNotBlank(locationInfo)){
|
||||
if (StringUtils.isNotBlank(locationInfo)) {
|
||||
JSONObject jsonObject = JSONObject.parseObject(locationInfo);
|
||||
shareDetailVo.setLongitude(jsonObject.get("longitude").toString());
|
||||
shareDetailVo.setLatitude(jsonObject.get("latitude").toString());
|
||||
shareDetailVo.setAddress((String)jsonObject.get("address"));
|
||||
shareDetailVo.setAddress((String) jsonObject.get("address"));
|
||||
}
|
||||
|
||||
|
||||
String alarmStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY +DEVICE_KEY_PREFIX+ device.getDeviceImei()+ DEVICE_ALARM_KEY_PREFIX);
|
||||
if(StringUtils.isNotBlank(alarmStatus)){
|
||||
String alarmStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + device.getDeviceImei() + DEVICE_ALARM_KEY_PREFIX);
|
||||
if (StringUtils.isNotBlank(alarmStatus)) {
|
||||
shareDetailVo.setAlarmStatus(alarmStatus);
|
||||
}
|
||||
|
||||
String lightBrightness = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY +DEVICE_KEY_PREFIX+ device.getDeviceImei()+ DEVICE_LIGHT_BRIGHTNESS_KEY_PREFIX);
|
||||
if(StringUtils.isNotBlank(lightBrightness)){
|
||||
String lightBrightness = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + device.getDeviceImei() + DEVICE_LIGHT_BRIGHTNESS_KEY_PREFIX);
|
||||
if (StringUtils.isNotBlank(lightBrightness)) {
|
||||
shareDetailVo.setLightBrightness(lightBrightness);
|
||||
}
|
||||
|
||||
return shareDetailVo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验短信验证码
|
||||
*/
|
||||
@ -181,14 +182,15 @@ public class DeviceShareService {
|
||||
}
|
||||
return code.equals(smsCode);
|
||||
}
|
||||
|
||||
public int deviceShare(AppDeviceShareBo bo) {
|
||||
boolean flag = validateSmsCode(AppLoginHelper.getTenantId(), bo.getPhonenumber(), bo.getSmsCode());
|
||||
if(!flag){
|
||||
if (!flag) {
|
||||
throw new ServiceException("验证码错误");
|
||||
}
|
||||
|
||||
Device device = deviceMapper.selectById(bo.getDeviceId());
|
||||
if(device==null){
|
||||
if (device == null) {
|
||||
throw new ServiceException("设备不存在");
|
||||
}
|
||||
Long userId = AppLoginHelper.getUserId();
|
||||
@ -196,7 +198,7 @@ public class DeviceShareService {
|
||||
lqw.eq(AppDeviceShare::getDeviceId, bo.getDeviceId());
|
||||
lqw.eq(AppDeviceShare::getPhonenumber, bo.getPhonenumber());
|
||||
Long count = appDeviceShareMapper.selectCount(lqw);
|
||||
if(count>0){
|
||||
if (count > 0) {
|
||||
|
||||
UpdateWrapper<AppDeviceShare> uw = new UpdateWrapper<>();
|
||||
uw.eq("device_id", bo.getDeviceId());
|
||||
@ -206,7 +208,7 @@ public class DeviceShareService {
|
||||
uw.set("update_time", new Date());
|
||||
|
||||
return appDeviceShareMapper.update(uw);
|
||||
}else {
|
||||
} else {
|
||||
AppDeviceShare appDeviceShare = new AppDeviceShare();
|
||||
appDeviceShare.setDeviceId(bo.getDeviceId());
|
||||
appDeviceShare.setPhonenumber(bo.getPhonenumber());
|
||||
@ -232,4 +234,19 @@ public class DeviceShareService {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询设备分享列表(web)
|
||||
*
|
||||
* @param bo
|
||||
* @param pageQuery
|
||||
* @return
|
||||
*/
|
||||
public TableDataInfo<AppDeviceShareVo> queryWebList(AppDeviceShareBo bo, PageQuery pageQuery) {
|
||||
Page<AppDeviceShareVo> page = new Page<>(pageQuery.getPageNum(), pageQuery.getPageSize());
|
||||
Page<AppDeviceShareVo> result = appDeviceShareMapper.selectWebDeviceShareList(bo, page);
|
||||
List<AppDeviceShareVo> records = result.getRecords();
|
||||
records.forEach(DeviceShareService::buildDeviceStatus);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user