forked from dyf/fys-Multi-tenant
分享管理
This commit is contained in:
@ -60,7 +60,7 @@ public class AppDeviceShareController extends BaseController {
|
||||
*/
|
||||
@GetMapping("/otherDeviceShareList")
|
||||
public TableDataInfo<AppDeviceShareVo> otherDeviceShareList(AppDeviceShareBo bo, PageQuery pageQuery) {
|
||||
return deviceShareService.otherDeviceShareList(bo, pageQuery);
|
||||
return appDeviceShareService.otherDeviceShareList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2,7 +2,9 @@ package com.fuyuanshen.app.service;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fuyuanshen.app.domain.AppDeviceShare;
|
||||
import com.fuyuanshen.app.domain.AppPersonnelInfo;
|
||||
@ -55,17 +57,14 @@ public class AppDeviceShareService {
|
||||
public TableDataInfo<AppDeviceShareVo> queryPageList(AppDeviceShareBo bo, PageQuery pageQuery) {
|
||||
Long userId = AppLoginHelper.getUserId();
|
||||
bo.setCreateBy(userId);
|
||||
LambdaQueryWrapper<AppDeviceShare> lqw = new LambdaQueryWrapper<>();
|
||||
Page<AppDeviceShareVo> result = appDeviceShareMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
Page<AppDeviceShareVo> page = new Page<>(pageQuery.getPageNum(), pageQuery.getPageSize());
|
||||
Page<AppDeviceShareVo> result = appDeviceShareMapper.selectAppDeviceShareList(bo, page);
|
||||
List<AppDeviceShareVo> records = result.getRecords();
|
||||
records.forEach(item-> {
|
||||
Device device = deviceMapper.selectById(item.getDeviceId());
|
||||
if(device != null){
|
||||
item.setDevicePic(device.getDevicePic());
|
||||
item.setDeviceName(device.getDeviceName());
|
||||
item.setDeviceImei(device.getDeviceImei());
|
||||
records.forEach(AppDeviceShareService::buildDeviceStatus);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
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)){
|
||||
@ -94,8 +93,6 @@ public class AppDeviceShareService {
|
||||
if(StringUtils.isNotBlank(alarmStatus)){
|
||||
item.setAlarmStatus(alarmStatus);
|
||||
}
|
||||
});
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
public AppDeviceShareDetailVo getInfo(Long id) {
|
||||
@ -135,7 +132,35 @@ public class AppDeviceShareService {
|
||||
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)){
|
||||
shareDetailVo.setOnlineStatus(1);
|
||||
}else{
|
||||
shareDetailVo.setOnlineStatus(0);
|
||||
}
|
||||
String deviceStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + device.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_STATUS_KEY_PREFIX);
|
||||
// 获取电量
|
||||
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{
|
||||
shareDetailVo.setBatteryPercentage("0");
|
||||
}
|
||||
|
||||
// 获取经度纬度
|
||||
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)){
|
||||
JSONObject jsonObject = JSONObject.parseObject(locationInfo);
|
||||
shareDetailVo.setLongitude(jsonObject.get("longitude").toString());
|
||||
shareDetailVo.setLatitude(jsonObject.get("latitude").toString());
|
||||
shareDetailVo.setAddress((String)jsonObject.get("address"));
|
||||
}
|
||||
return shareDetailVo;
|
||||
}
|
||||
/**
|
||||
@ -186,4 +211,17 @@ public class AppDeviceShareService {
|
||||
public int remove(Long[] ids) {
|
||||
return appDeviceShareMapper.deleteByIds(Arrays.asList(ids));
|
||||
}
|
||||
|
||||
public TableDataInfo<AppDeviceShareVo> otherDeviceShareList(AppDeviceShareBo bo, PageQuery pageQuery) {
|
||||
String username = AppLoginHelper.getUsername();
|
||||
bo.setPhonenumber(username);
|
||||
Page<AppDeviceShareVo> page = new Page<>(pageQuery.getPageNum(), pageQuery.getPageSize());
|
||||
IPage<AppDeviceShareVo> result = appDeviceShareMapper.otherDeviceShareList(bo, page);
|
||||
List<AppDeviceShareVo> records = result.getRecords();
|
||||
|
||||
records.forEach(AppDeviceShareService::buildDeviceStatus);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -104,4 +104,38 @@ public class AppDeviceShareDetailVo implements Serializable {
|
||||
* 发送信息
|
||||
*/
|
||||
private String sendMsg;
|
||||
|
||||
//设备主灯档位
|
||||
private String mainLightMode;
|
||||
|
||||
//激光灯档位
|
||||
private String laserLightMode;
|
||||
|
||||
//电量百分比
|
||||
private String batteryPercentage;
|
||||
|
||||
//充电状态(0没有充电,1正在充电,2为已充满)
|
||||
private String chargeState;
|
||||
|
||||
//电池剩余续航时间200分钟
|
||||
private String batteryRemainingTime;
|
||||
|
||||
/**
|
||||
* 在线状态(0离线,1在线)
|
||||
*/
|
||||
private Integer onlineStatus;
|
||||
|
||||
// 经度
|
||||
private String longitude;
|
||||
|
||||
// 纬度
|
||||
private String latitude;
|
||||
|
||||
// 逆解析地址
|
||||
private String address;
|
||||
|
||||
/**
|
||||
* 告警状态(0解除告警,1告警)
|
||||
*/
|
||||
private String alarmStatus;
|
||||
}
|
||||
|
@ -57,6 +57,12 @@ public class AppDeviceShareVo implements Serializable {
|
||||
@ExcelProperty(value = "手机号")
|
||||
private String phonenumber;
|
||||
|
||||
/**
|
||||
* 他人分享手机号
|
||||
*/
|
||||
@ExcelProperty(value = "手机号")
|
||||
private String otherPhonenumber;
|
||||
|
||||
/**
|
||||
* 功能权限(1:灯光模式;2:激光模式;3:开机画面;4:人员信息登记;5:发送信息;6:产品信息)
|
||||
以逗号分隔
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.fuyuanshen.app.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fuyuanshen.app.domain.AppDeviceShare;
|
||||
@ -16,4 +17,6 @@ import org.apache.ibatis.annotations.Param;
|
||||
*/
|
||||
public interface AppDeviceShareMapper extends BaseMapperPlus<AppDeviceShare, AppDeviceShareVo> {
|
||||
IPage<AppDeviceShareVo> otherDeviceShareList(@Param("bo") AppDeviceShareBo bo, Page<AppDeviceShareVo> page);
|
||||
|
||||
Page<AppDeviceShareVo> selectAppDeviceShareList(@Param("bo") AppDeviceShareBo bo,Page<AppDeviceShareVo> page);
|
||||
}
|
||||
|
@ -5,6 +5,47 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<mapper namespace="com.fuyuanshen.app.mapper.AppDeviceShareMapper">
|
||||
|
||||
<select id="otherDeviceShareList" resultType="com.fuyuanshen.app.domain.vo.AppDeviceShareVo">
|
||||
SELECT * FROM app_device_share a where a.phonenumber = #{bo.phonenumber}
|
||||
select d.device_name, d.device_name,
|
||||
d.device_name,
|
||||
d.device_mac,
|
||||
d.device_sn,
|
||||
d.device_imei,
|
||||
d.device_pic,
|
||||
dt.type_name,
|
||||
dt.communication_mode,
|
||||
d.bluetooth_name,
|
||||
c.binding_time,
|
||||
ad.*,u.user_name otherPhonenumber
|
||||
from
|
||||
app_device_share ad
|
||||
left join device d on ad.device_id = d.id
|
||||
left join app_user u on ad.create_by = u.user_id
|
||||
inner join device_type dt on d.device_type = dt.id
|
||||
inner join app_device_bind_record c on d.id = c.device_id
|
||||
where ad.phonenumber = #{bo.phonenumber}
|
||||
</select>
|
||||
<select id="selectAppDeviceShareList" resultType="com.fuyuanshen.app.domain.vo.AppDeviceShareVo">
|
||||
select d.device_name, d.device_name,
|
||||
d.device_name,
|
||||
d.device_mac,
|
||||
d.device_sn,
|
||||
d.device_imei,
|
||||
d.device_pic,
|
||||
dt.type_name,
|
||||
dt.communication_mode,
|
||||
d.bluetooth_name,
|
||||
c.binding_time,
|
||||
ad.*,u.user_name otherPhonenumber
|
||||
from
|
||||
app_device_share ad
|
||||
left join device d on ad.device_id = d.id
|
||||
left join app_user u on ad.create_by = u.user_id
|
||||
inner join device_type dt on d.device_type = dt.id
|
||||
inner join app_device_bind_record c on d.id = c.device_id
|
||||
|
||||
where ad.create_by = #{bo.createBy}
|
||||
<if test="bo.deviceId != null">
|
||||
and ad.device_id = #{bo.deviceId}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
|
Reference in New Issue
Block a user