Compare commits
9 Commits
395b2957c1
...
jingquan
Author | SHA1 | Date | |
---|---|---|---|
fcbde4322d | |||
832234269d | |||
7e87971c0b | |||
ebd8668178 | |||
5e3307d2b0 | |||
040e44984e | |||
f7a82ef138 | |||
91f787eec7 | |||
870f94b2d4 |
@ -5,6 +5,7 @@ import cn.hutool.core.util.RandomUtil;
|
|||||||
import com.fuyuanshen.app.domain.bo.AppDeviceShareBo;
|
import com.fuyuanshen.app.domain.bo.AppDeviceShareBo;
|
||||||
import com.fuyuanshen.app.domain.vo.AppDeviceShareDetailVo;
|
import com.fuyuanshen.app.domain.vo.AppDeviceShareDetailVo;
|
||||||
import com.fuyuanshen.app.domain.vo.AppDeviceShareVo;
|
import com.fuyuanshen.app.domain.vo.AppDeviceShareVo;
|
||||||
|
import com.fuyuanshen.app.service.AppDeviceShareService;
|
||||||
import com.fuyuanshen.app.service.IAppDeviceShareService;
|
import com.fuyuanshen.app.service.IAppDeviceShareService;
|
||||||
import com.fuyuanshen.common.core.constant.Constants;
|
import com.fuyuanshen.common.core.constant.Constants;
|
||||||
import com.fuyuanshen.common.core.domain.R;
|
import com.fuyuanshen.common.core.domain.R;
|
||||||
@ -45,7 +46,7 @@ public class AppDeviceShareController extends BaseController {
|
|||||||
|
|
||||||
private final IAppDeviceShareService deviceShareService;
|
private final IAppDeviceShareService deviceShareService;
|
||||||
|
|
||||||
private final DeviceShareService appDeviceShareService;
|
private final AppDeviceShareService appDeviceShareService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分享管理列表
|
* 分享管理列表
|
||||||
|
@ -0,0 +1,119 @@
|
|||||||
|
package com.fuyuanshen.app.controller.device;
|
||||||
|
|
||||||
|
import com.fuyuanshen.app.domain.bo.AppPersonnelInfoBo;
|
||||||
|
import com.fuyuanshen.app.domain.dto.AppDeviceLogoUploadDto;
|
||||||
|
import com.fuyuanshen.app.domain.dto.DeviceInstructDto;
|
||||||
|
import com.fuyuanshen.app.domain.vo.AppDeviceDetailVo;
|
||||||
|
import com.fuyuanshen.common.core.domain.R;
|
||||||
|
import com.fuyuanshen.common.core.validate.AddGroup;
|
||||||
|
import com.fuyuanshen.common.ratelimiter.annotation.FunctionAccessAnnotation;
|
||||||
|
import com.fuyuanshen.common.ratelimiter.annotation.FunctionAccessBatcAnnotation;
|
||||||
|
import com.fuyuanshen.common.web.core.BaseController;
|
||||||
|
import com.fuyuanshen.equipment.domain.dto.AppDeviceSendMsgBo;
|
||||||
|
import com.fuyuanshen.web.service.device.DeviceBJQBizService;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HBY210设备控制类
|
||||||
|
*/
|
||||||
|
@Validated
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/app/hby/device")
|
||||||
|
public class AppDeviceHBYController extends BaseController {
|
||||||
|
|
||||||
|
private final DeviceBJQBizService appDeviceService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取设备详细信息
|
||||||
|
*
|
||||||
|
* @param id 主键
|
||||||
|
*/
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
public R<AppDeviceDetailVo> getInfo(@NotNull(message = "主键不能为空")
|
||||||
|
@PathVariable Long id) {
|
||||||
|
return R.ok(appDeviceService.getInfo(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 人员信息登记
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/registerPersonInfo")
|
||||||
|
// @FunctionAccessAnnotation("registerPersonInfo")
|
||||||
|
public R<Void> registerPersonInfo(@Validated(AddGroup.class) @RequestBody AppPersonnelInfoBo bo) {
|
||||||
|
return toAjax(appDeviceService.registerPersonInfo(bo));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送信息
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/sendMessage")
|
||||||
|
@FunctionAccessBatcAnnotation(value = "sendMessage", timeOut = 30, batchMaxTimeOut = 40)
|
||||||
|
public R<Void> sendMessage(@RequestBody AppDeviceSendMsgBo bo) {
|
||||||
|
return toAjax(appDeviceService.sendMessage(bo));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送报警信息
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/sendAlarmMessage")
|
||||||
|
@FunctionAccessBatcAnnotation(value = "sendAlarmMessage", timeOut = 5, batchMaxTimeOut = 10)
|
||||||
|
public R<Void> sendAlarmMessage(@RequestBody AppDeviceSendMsgBo bo) {
|
||||||
|
return toAjax(appDeviceService.sendAlarmMessage(bo));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传设备logo图片
|
||||||
|
*/
|
||||||
|
@PostMapping("/uploadLogo")
|
||||||
|
@FunctionAccessAnnotation("uploadLogo")
|
||||||
|
public R<Void> upload(@Validated @ModelAttribute AppDeviceLogoUploadDto bo) {
|
||||||
|
|
||||||
|
MultipartFile file = bo.getFile();
|
||||||
|
if(file.getSize()>1024*1024*2){
|
||||||
|
return R.warn("图片不能大于2M");
|
||||||
|
}
|
||||||
|
appDeviceService.uploadDeviceLogo(bo);
|
||||||
|
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 灯光模式
|
||||||
|
* 0(关灯),1(强光模式),2(弱光模式), 3(爆闪模式), 4(泛光模式)
|
||||||
|
*/
|
||||||
|
// @FunctionAccessAnnotation("lightModeSettings")
|
||||||
|
@PostMapping("/lightModeSettings")
|
||||||
|
public R<Void> lightModeSettings(@RequestBody DeviceInstructDto params) {
|
||||||
|
// params 转 JSONObject
|
||||||
|
appDeviceService.lightModeSettings(params);
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 灯光亮度设置
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
// @FunctionAccessAnnotation("lightBrightnessSettings")
|
||||||
|
@PostMapping("/lightBrightnessSettings")
|
||||||
|
public R<Void> lightBrightnessSettings(@RequestBody DeviceInstructDto params) {
|
||||||
|
appDeviceService.lightBrightnessSettings(params);
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 激光模式设置
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@PostMapping("/laserModeSettings")
|
||||||
|
// @FunctionAccessAnnotation("laserModeSettings")
|
||||||
|
public R<Void> laserModeSettings(@RequestBody DeviceInstructDto params) {
|
||||||
|
appDeviceService.laserModeSettings(params);
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,262 @@
|
|||||||
|
package com.fuyuanshen.app.service;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
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;
|
||||||
|
import com.fuyuanshen.app.domain.bo.AppDeviceShareBo;
|
||||||
|
import com.fuyuanshen.app.domain.vo.AppDeviceShareDetailVo;
|
||||||
|
import com.fuyuanshen.app.domain.vo.AppDeviceShareVo;
|
||||||
|
import com.fuyuanshen.app.domain.vo.AppPersonnelInfoVo;
|
||||||
|
import com.fuyuanshen.app.mapper.AppDeviceShareMapper;
|
||||||
|
import com.fuyuanshen.app.mapper.AppPersonnelInfoMapper;
|
||||||
|
import com.fuyuanshen.common.core.constant.GlobalConstants;
|
||||||
|
import com.fuyuanshen.common.core.exception.ServiceException;
|
||||||
|
import com.fuyuanshen.common.core.utils.StringUtils;
|
||||||
|
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||||
|
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||||
|
import com.fuyuanshen.common.redis.utils.RedisUtils;
|
||||||
|
import com.fuyuanshen.common.satoken.utils.AppLoginHelper;
|
||||||
|
import com.fuyuanshen.equipment.domain.Device;
|
||||||
|
import com.fuyuanshen.equipment.domain.DeviceType;
|
||||||
|
import com.fuyuanshen.equipment.mapper.DeviceMapper;
|
||||||
|
import com.fuyuanshen.equipment.mapper.DeviceTypeMapper;
|
||||||
|
import com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.fuyuanshen.common.core.constant.GlobalConstants.GLOBAL_REDIS_KEY;
|
||||||
|
import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.*;
|
||||||
|
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class AppDeviceShareService {
|
||||||
|
|
||||||
|
private final AppDeviceShareMapper appDeviceShareMapper;
|
||||||
|
|
||||||
|
private final DeviceMapper deviceMapper;
|
||||||
|
|
||||||
|
private final DeviceTypeMapper deviceTypeMapper;
|
||||||
|
|
||||||
|
private final AppPersonnelInfoMapper appPersonnelInfoMapper;
|
||||||
|
|
||||||
|
public TableDataInfo<AppDeviceShareVo> queryPageList(AppDeviceShareBo bo, PageQuery pageQuery) {
|
||||||
|
Long userId = AppLoginHelper.getUserId();
|
||||||
|
bo.setCreateBy(userId);
|
||||||
|
Page<AppDeviceShareVo> page = new Page<>(pageQuery.getPageNum(), pageQuery.getPageSize());
|
||||||
|
Page<AppDeviceShareVo> result = appDeviceShareMapper.selectAppDeviceShareList(bo, page);
|
||||||
|
List<AppDeviceShareVo> records = result.getRecords();
|
||||||
|
records.forEach(AppDeviceShareService::buildDeviceStatus);
|
||||||
|
return TableDataInfo.build(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TableDataInfo<AppDeviceShareVo> queryWebPageList(AppDeviceShareBo bo, PageQuery pageQuery) {
|
||||||
|
// Long userId = AppLoginHelper.getUserId();
|
||||||
|
// bo.setCreateBy(userId);
|
||||||
|
Page<AppDeviceShareVo> page = new Page<>(pageQuery.getPageNum(), pageQuery.getPageSize());
|
||||||
|
Page<AppDeviceShareVo> result = appDeviceShareMapper.selectWebDeviceShareList(bo, page);
|
||||||
|
List<AppDeviceShareVo> records = result.getRecords();
|
||||||
|
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)) {
|
||||||
|
|
||||||
|
item.setOnlineStatus(1);
|
||||||
|
} else {
|
||||||
|
item.setOnlineStatus(0);
|
||||||
|
}
|
||||||
|
String deviceStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + item.getDeviceImei() + DEVICE_STATUS_KEY_PREFIX);
|
||||||
|
// 获取电量
|
||||||
|
if (StringUtils.isNotBlank(deviceStatus)) {
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(deviceStatus);
|
||||||
|
item.setBattery(jsonObject.getString("batteryPercentage"));
|
||||||
|
} else {
|
||||||
|
item.setBattery("0");
|
||||||
|
}
|
||||||
|
|
||||||
|
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)) {
|
||||||
|
item.setAlarmStatus(alarmStatus);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public AppDeviceShareDetailVo getInfo(Long id) {
|
||||||
|
|
||||||
|
LambdaQueryWrapper<AppDeviceShare> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(AppDeviceShare::getId, id);
|
||||||
|
List<AppDeviceShareVo> appDeviceShareVos = appDeviceShareMapper.selectVoList(queryWrapper);
|
||||||
|
if (appDeviceShareVos == null || appDeviceShareVos.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
AppDeviceShareVo shareVo = appDeviceShareVos.get(0);
|
||||||
|
AppDeviceShareDetailVo shareDetailVo = new AppDeviceShareDetailVo();
|
||||||
|
shareDetailVo.setId(shareVo.getId());
|
||||||
|
shareDetailVo.setDeviceId(shareVo.getDeviceId());
|
||||||
|
shareDetailVo.setPhonenumber(shareVo.getPhonenumber());
|
||||||
|
shareDetailVo.setPermission(shareVo.getPermission());
|
||||||
|
|
||||||
|
Device device = deviceMapper.selectById(shareVo.getDeviceId());
|
||||||
|
shareDetailVo.setDeviceName(device.getDeviceName());
|
||||||
|
shareDetailVo.setDeviceImei(device.getDeviceImei());
|
||||||
|
shareDetailVo.setDeviceMac(device.getDeviceMac());
|
||||||
|
|
||||||
|
DeviceType deviceType = deviceTypeMapper.selectById(device.getDeviceType());
|
||||||
|
if (deviceType != null) {
|
||||||
|
shareDetailVo.setCommunicationMode(Integer.valueOf(deviceType.getCommunicationMode()));
|
||||||
|
}
|
||||||
|
shareDetailVo.setDevicePic(device.getDevicePic());
|
||||||
|
shareDetailVo.setTypeName(deviceType.getTypeName());
|
||||||
|
shareDetailVo.setBluetoothName(device.getBluetoothName());
|
||||||
|
shareDetailVo.setDeviceStatus(device.getDeviceStatus());
|
||||||
|
shareDetailVo.setSendMsg(device.getSendMsg());
|
||||||
|
|
||||||
|
LambdaQueryWrapper<AppPersonnelInfo> qw = new LambdaQueryWrapper<>();
|
||||||
|
qw.eq(AppPersonnelInfo::getDeviceId, device.getId());
|
||||||
|
List<AppPersonnelInfoVo> appPersonnelInfoVos = appPersonnelInfoMapper.selectVoList(qw);
|
||||||
|
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"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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)) {
|
||||||
|
shareDetailVo.setLightBrightness(lightBrightness);
|
||||||
|
}
|
||||||
|
|
||||||
|
return shareDetailVo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验短信验证码
|
||||||
|
*/
|
||||||
|
private boolean validateSmsCode(String tenantId, String phonenumber, String smsCode) {
|
||||||
|
String code = RedisUtils.getCacheObject(GlobalConstants.DEVICE_SHARE_CODES_KEY + phonenumber);
|
||||||
|
if (StringUtils.isBlank(code)) {
|
||||||
|
throw new ServiceException("验证码失效");
|
||||||
|
}
|
||||||
|
return code.equals(smsCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int deviceShare(AppDeviceShareBo bo) {
|
||||||
|
boolean flag = validateSmsCode(AppLoginHelper.getTenantId(), bo.getPhonenumber(), bo.getSmsCode());
|
||||||
|
if (!flag) {
|
||||||
|
throw new ServiceException("验证码错误");
|
||||||
|
}
|
||||||
|
|
||||||
|
Device device = deviceMapper.selectById(bo.getDeviceId());
|
||||||
|
if (device == null) {
|
||||||
|
throw new ServiceException("设备不存在");
|
||||||
|
}
|
||||||
|
Long userId = AppLoginHelper.getUserId();
|
||||||
|
LambdaQueryWrapper<AppDeviceShare> lqw = new LambdaQueryWrapper<>();
|
||||||
|
lqw.eq(AppDeviceShare::getDeviceId, bo.getDeviceId());
|
||||||
|
lqw.eq(AppDeviceShare::getPhonenumber, bo.getPhonenumber());
|
||||||
|
Long count = appDeviceShareMapper.selectCount(lqw);
|
||||||
|
if (count > 0) {
|
||||||
|
|
||||||
|
UpdateWrapper<AppDeviceShare> uw = new UpdateWrapper<>();
|
||||||
|
uw.eq("device_id", bo.getDeviceId());
|
||||||
|
uw.eq("phonenumber", bo.getPhonenumber());
|
||||||
|
uw.set("permission", bo.getPermission());
|
||||||
|
uw.set("update_by", userId);
|
||||||
|
uw.set("update_time", new Date());
|
||||||
|
|
||||||
|
return appDeviceShareMapper.update(uw);
|
||||||
|
} else {
|
||||||
|
AppDeviceShare appDeviceShare = new AppDeviceShare();
|
||||||
|
appDeviceShare.setDeviceId(bo.getDeviceId());
|
||||||
|
appDeviceShare.setPhonenumber(bo.getPhonenumber());
|
||||||
|
appDeviceShare.setPermission(bo.getPermission());
|
||||||
|
appDeviceShare.setCreateBy(userId);
|
||||||
|
return appDeviceShareMapper.insert(appDeviceShare);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询设备分享列表(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(AppDeviceShareService::buildDeviceStatus);
|
||||||
|
return TableDataInfo.build(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,6 +1,8 @@
|
|||||||
package com.fuyuanshen.global.queue;
|
package com.fuyuanshen.global.queue;
|
||||||
|
|
||||||
|
import com.fuyuanshen.common.core.constant.GlobalConstants;
|
||||||
|
|
||||||
public class MqttMessageQueueConstants {
|
public class MqttMessageQueueConstants {
|
||||||
public static final String MQTT_MESSAGE_QUEUE_KEY = "mqtt:message:queue";
|
public static final String MQTT_MESSAGE_QUEUE_KEY = GlobalConstants.GLOBAL_REDIS_KEY + "mqtt:message:queue";
|
||||||
public static final String MQTT_MESSAGE_DEDUP_KEY = "mqtt:message:dedup";
|
public static final String MQTT_MESSAGE_DEDUP_KEY = GlobalConstants.GLOBAL_REDIS_KEY + "mqtt:message:dedup";
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ public class DeviceChargeDischargeController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 查询设备充放电记录列表
|
* 查询设备充放电记录列表
|
||||||
*/
|
*/
|
||||||
@SaCheckPermission("equipment:chargeDischarge:list")
|
// @SaCheckPermission("equipment:chargeDischarge:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo<DeviceChargeDischargeVo> list(DeviceChargeDischargeBo bo, PageQuery pageQuery) {
|
public TableDataInfo<DeviceChargeDischargeVo> list(DeviceChargeDischargeBo bo, PageQuery pageQuery) {
|
||||||
return deviceChargeDischargeService.queryPageList(bo, pageQuery);
|
return deviceChargeDischargeService.queryPageList(bo, pageQuery);
|
||||||
@ -48,7 +48,7 @@ public class DeviceChargeDischargeController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 设备充放电记录列表
|
* 设备充放电记录列表
|
||||||
*/
|
*/
|
||||||
@SaCheckPermission("equipment:chargeDischarge:export")
|
// @SaCheckPermission("equipment:chargeDischarge:export")
|
||||||
@Log(title = "设备充放电记录", businessType = BusinessType.EXPORT)
|
@Log(title = "设备充放电记录", businessType = BusinessType.EXPORT)
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(DeviceChargeDischargeBo bo, HttpServletResponse response) {
|
public void export(DeviceChargeDischargeBo bo, HttpServletResponse response) {
|
||||||
@ -61,7 +61,7 @@ public class DeviceChargeDischargeController extends BaseController {
|
|||||||
*
|
*
|
||||||
* @param id 主键
|
* @param id 主键
|
||||||
*/
|
*/
|
||||||
@SaCheckPermission("equipment:chargeDischarge:query")
|
// @SaCheckPermission("equipment:chargeDischarge:query")
|
||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
public R<DeviceChargeDischargeVo> getInfo(@NotNull(message = "主键不能为空")
|
public R<DeviceChargeDischargeVo> getInfo(@NotNull(message = "主键不能为空")
|
||||||
@PathVariable Long id) {
|
@PathVariable Long id) {
|
||||||
@ -71,7 +71,7 @@ public class DeviceChargeDischargeController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 新增设备充放电记录
|
* 新增设备充放电记录
|
||||||
*/
|
*/
|
||||||
@SaCheckPermission("equipment:chargeDischarge:add")
|
// @SaCheckPermission("equipment:chargeDischarge:add")
|
||||||
@Log(title = "设备充放电记录", businessType = BusinessType.INSERT)
|
@Log(title = "设备充放电记录", businessType = BusinessType.INSERT)
|
||||||
@RepeatSubmit()
|
@RepeatSubmit()
|
||||||
@PostMapping()
|
@PostMapping()
|
||||||
@ -82,7 +82,7 @@ public class DeviceChargeDischargeController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 修改设备充放电记录
|
* 修改设备充放电记录
|
||||||
*/
|
*/
|
||||||
@SaCheckPermission("equipment:chargeDischarge:edit")
|
// @SaCheckPermission("equipment:chargeDischarge:edit")
|
||||||
@Log(title = "设备充放电记录", businessType = BusinessType.UPDATE)
|
@Log(title = "设备充放电记录", businessType = BusinessType.UPDATE)
|
||||||
@RepeatSubmit()
|
@RepeatSubmit()
|
||||||
@PutMapping()
|
@PutMapping()
|
||||||
@ -95,11 +95,13 @@ public class DeviceChargeDischargeController extends BaseController {
|
|||||||
*
|
*
|
||||||
* @param ids 主键串
|
* @param ids 主键串
|
||||||
*/
|
*/
|
||||||
@SaCheckPermission("equipment:chargeDischarge:remove")
|
// @SaCheckPermission("equipment:chargeDischarge:remove")
|
||||||
@Log(title = "设备充放电记录", businessType = BusinessType.DELETE)
|
@Log(title = "设备充放电记录", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{ids}")
|
@DeleteMapping("/{ids}")
|
||||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||||
@PathVariable Long[] ids) {
|
@PathVariable Long[] ids) {
|
||||||
return toAjax(deviceChargeDischargeService.deleteWithValidByIds(List.of(ids), true));
|
return toAjax(deviceChargeDischargeService.deleteWithValidByIds(List.of(ids), true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ import static com.fuyuanshen.common.core.constant.GlobalConstants.DEVICE_SHARE_C
|
|||||||
@RequestMapping("api/equipment/share")
|
@RequestMapping("api/equipment/share")
|
||||||
public class DeviceShareController extends BaseController {
|
public class DeviceShareController extends BaseController {
|
||||||
|
|
||||||
private final DeviceShareService appDeviceShareService;
|
private final DeviceShareService deviceShareService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -48,7 +48,7 @@ public class DeviceShareController extends BaseController {
|
|||||||
*/
|
*/
|
||||||
@GetMapping("/deviceShareList")
|
@GetMapping("/deviceShareList")
|
||||||
public TableDataInfo<AppDeviceShareVo> list(AppDeviceShareBo bo, PageQuery pageQuery) {
|
public TableDataInfo<AppDeviceShareVo> list(AppDeviceShareBo bo, PageQuery pageQuery) {
|
||||||
return appDeviceShareService.queryWebPageList(bo, pageQuery);
|
return deviceShareService.queryWebPageList(bo, pageQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -58,7 +58,16 @@ public class DeviceShareController extends BaseController {
|
|||||||
@RepeatSubmit()
|
@RepeatSubmit()
|
||||||
@PostMapping("/deviceShare")
|
@PostMapping("/deviceShare")
|
||||||
public R<Void> deviceShare(@Validated(AddGroup.class) @RequestBody AppDeviceShareBo bo) {
|
public R<Void> deviceShare(@Validated(AddGroup.class) @RequestBody AppDeviceShareBo bo) {
|
||||||
return toAjax(appDeviceShareService.deviceShare(bo));
|
return toAjax(deviceShareService.deviceShare(bo));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 权限管理
|
||||||
|
*/
|
||||||
|
@RepeatSubmit()
|
||||||
|
@PostMapping("/permission")
|
||||||
|
public R<Void> permission(@Validated(AddGroup.class) @RequestBody AppDeviceShareBo bo) {
|
||||||
|
return toAjax(deviceShareService.deviceShare(bo));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -69,7 +78,7 @@ public class DeviceShareController extends BaseController {
|
|||||||
@DeleteMapping("/{ids}")
|
@DeleteMapping("/{ids}")
|
||||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||||
@PathVariable Long[] ids) {
|
@PathVariable Long[] ids) {
|
||||||
return toAjax(appDeviceShareService.remove(ids));
|
return toAjax(deviceShareService.remove(ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,13 +61,15 @@ public class HomePageController {
|
|||||||
/**
|
/**
|
||||||
* 获取设备使用数据
|
* 获取设备使用数据
|
||||||
*
|
*
|
||||||
* @param deviceId 设备ID
|
* @param deviceTypeId 设备ID (可选)
|
||||||
* @param range 时间范围 1:半年 2:一年
|
* @param range 时间范围 1:半年 2:一年
|
||||||
* @return 每月使用数据列表
|
* @return 每月使用数据列表
|
||||||
*/
|
*/
|
||||||
@GetMapping("/getEquipmentUsageData/{deviceId}/{range}")
|
@GetMapping("/getEquipmentUsageData/{range}")
|
||||||
public R<List<Map<String, Object>>> getEquipmentUsageData(@PathVariable Long deviceId, @PathVariable Integer range) {
|
public R<List<Map<String, Object>>> getEquipmentUsageData(@PathVariable Integer range,
|
||||||
return R.ok(deviceService.getEquipmentUsageData(deviceId, range));
|
@RequestParam(required = false) Long deviceTypeId) {
|
||||||
|
return R.ok(deviceService.getEquipmentUsageData(deviceTypeId, range));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,8 @@ package com.fuyuanshen.web.controller.device;
|
|||||||
|
|
||||||
import com.fuyuanshen.app.domain.AppPersonnelInfoRecords;
|
import com.fuyuanshen.app.domain.AppPersonnelInfoRecords;
|
||||||
import com.fuyuanshen.common.core.domain.R;
|
import com.fuyuanshen.common.core.domain.R;
|
||||||
|
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||||
|
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||||
import com.fuyuanshen.common.web.core.BaseController;
|
import com.fuyuanshen.common.web.core.BaseController;
|
||||||
import com.fuyuanshen.equipment.domain.DeviceLog;
|
import com.fuyuanshen.equipment.domain.DeviceLog;
|
||||||
import com.fuyuanshen.equipment.domain.vo.DeviceAlarmVo;
|
import com.fuyuanshen.equipment.domain.vo.DeviceAlarmVo;
|
||||||
@ -65,7 +67,7 @@ public class WEBDeviceController extends BaseController {
|
|||||||
* @param deviceId
|
* @param deviceId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Operation(summary = "设备详情")
|
@Operation(summary = "设备用户详情")
|
||||||
@GetMapping(value = "/getDeviceUser/{deviceId}")
|
@GetMapping(value = "/getDeviceUser/{deviceId}")
|
||||||
public R<List<AppPersonnelInfoRecords>> getDeviceUser(@PathVariable Long deviceId) {
|
public R<List<AppPersonnelInfoRecords>> getDeviceUser(@PathVariable Long deviceId) {
|
||||||
List<AppPersonnelInfoRecords> device = deviceService.getDeviceUser(deviceId);
|
List<AppPersonnelInfoRecords> device = deviceService.getDeviceUser(deviceId);
|
||||||
@ -77,13 +79,18 @@ public class WEBDeviceController extends BaseController {
|
|||||||
* 设备操作记录
|
* 设备操作记录
|
||||||
*
|
*
|
||||||
* @param deviceId
|
* @param deviceId
|
||||||
|
* @param startTime 开始时间
|
||||||
|
* @param endTime 结束时间
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Operation(summary = "设备操作记录")
|
@Operation(summary = "设备操作记录")
|
||||||
@GetMapping(value = "/getOperationRecord/{deviceId}")
|
@GetMapping(value = "/getOperationRecord/{deviceId}")
|
||||||
public R<List<DeviceLog>> getOperationRecord(@PathVariable Long deviceId) {
|
public TableDataInfo<DeviceLog> getOperationRecord(@PathVariable Long deviceId,
|
||||||
List<DeviceLog> device = deviceService.getOperationRecord(deviceId);
|
@RequestParam(required = false) String startTime,
|
||||||
return R.ok(device);
|
@RequestParam(required = false) String endTime,
|
||||||
|
PageQuery pageQuery) {
|
||||||
|
TableDataInfo<DeviceLog> device = deviceService.getOperationRecord(deviceId, startTime, endTime,pageQuery);
|
||||||
|
return device;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -91,13 +98,17 @@ public class WEBDeviceController extends BaseController {
|
|||||||
* 设备告警记录
|
* 设备告警记录
|
||||||
*
|
*
|
||||||
* @param deviceId
|
* @param deviceId
|
||||||
|
* @param startTime 开始时间
|
||||||
|
* @param endTime 结束时间
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Operation(summary = "设备告警记录")
|
@Operation(summary = "设备告警记录")
|
||||||
@GetMapping(value = "/getAlarmRecord/{deviceId}")
|
@GetMapping(value = "/getAlarmRecord/{deviceId}")
|
||||||
public R<List<DeviceAlarmVo>> getAlarmRecord(@PathVariable Long deviceId) {
|
public TableDataInfo<DeviceAlarmVo> getAlarmRecord(@PathVariable Long deviceId,
|
||||||
List<DeviceAlarmVo> device = deviceService.getAlarmRecord(deviceId);
|
@RequestParam(required = false) String startTime,
|
||||||
return R.ok(device);
|
@RequestParam(required = false) String endTime,
|
||||||
|
PageQuery pageQuery) {
|
||||||
|
return deviceService.getAlarmRecord(deviceId, startTime, endTime, pageQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,15 +2,18 @@ package com.fuyuanshen.web.service;
|
|||||||
|
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
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.conditions.update.UpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.fuyuanshen.app.domain.AppDeviceBindRecord;
|
||||||
import com.fuyuanshen.app.domain.AppDeviceShare;
|
import com.fuyuanshen.app.domain.AppDeviceShare;
|
||||||
import com.fuyuanshen.app.domain.AppPersonnelInfo;
|
import com.fuyuanshen.app.domain.AppPersonnelInfo;
|
||||||
import com.fuyuanshen.app.domain.bo.AppDeviceShareBo;
|
import com.fuyuanshen.app.domain.bo.AppDeviceShareBo;
|
||||||
import com.fuyuanshen.app.domain.vo.AppDeviceShareDetailVo;
|
import com.fuyuanshen.app.domain.vo.AppDeviceShareDetailVo;
|
||||||
import com.fuyuanshen.app.domain.vo.AppDeviceShareVo;
|
import com.fuyuanshen.app.domain.vo.AppDeviceShareVo;
|
||||||
import com.fuyuanshen.app.domain.vo.AppPersonnelInfoVo;
|
import com.fuyuanshen.app.domain.vo.AppPersonnelInfoVo;
|
||||||
|
import com.fuyuanshen.app.mapper.AppDeviceBindRecordMapper;
|
||||||
import com.fuyuanshen.app.mapper.AppDeviceShareMapper;
|
import com.fuyuanshen.app.mapper.AppDeviceShareMapper;
|
||||||
import com.fuyuanshen.app.mapper.AppPersonnelInfoMapper;
|
import com.fuyuanshen.app.mapper.AppPersonnelInfoMapper;
|
||||||
import com.fuyuanshen.common.core.constant.GlobalConstants;
|
import com.fuyuanshen.common.core.constant.GlobalConstants;
|
||||||
@ -50,6 +53,8 @@ public class DeviceShareService {
|
|||||||
|
|
||||||
private final AppPersonnelInfoMapper appPersonnelInfoMapper;
|
private final AppPersonnelInfoMapper appPersonnelInfoMapper;
|
||||||
|
|
||||||
|
private final AppDeviceBindRecordMapper appDeviceBindRecordMapper;
|
||||||
|
|
||||||
public TableDataInfo<AppDeviceShareVo> queryPageList(AppDeviceShareBo bo, PageQuery pageQuery) {
|
public TableDataInfo<AppDeviceShareVo> queryPageList(AppDeviceShareBo bo, PageQuery pageQuery) {
|
||||||
Long userId = AppLoginHelper.getUserId();
|
Long userId = AppLoginHelper.getUserId();
|
||||||
bo.setCreateBy(userId);
|
bo.setCreateBy(userId);
|
||||||
@ -185,7 +190,7 @@ public class DeviceShareService {
|
|||||||
/**
|
/**
|
||||||
* 校验短信验证码
|
* 校验短信验证码
|
||||||
*/
|
*/
|
||||||
private boolean validateSmsCode(String tenantId, String phonenumber, String smsCode) {
|
private boolean validateSmsCode(String phonenumber, String smsCode) {
|
||||||
String code = RedisUtils.getCacheObject(GlobalConstants.DEVICE_SHARE_CODES_KEY + phonenumber);
|
String code = RedisUtils.getCacheObject(GlobalConstants.DEVICE_SHARE_CODES_KEY + phonenumber);
|
||||||
if (StringUtils.isBlank(code)) {
|
if (StringUtils.isBlank(code)) {
|
||||||
throw new ServiceException("验证码失效");
|
throw new ServiceException("验证码失效");
|
||||||
@ -194,16 +199,21 @@ public class DeviceShareService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int deviceShare(AppDeviceShareBo bo) {
|
public int deviceShare(AppDeviceShareBo bo) {
|
||||||
boolean flag = validateSmsCode(AppLoginHelper.getTenantId(), bo.getPhonenumber(), bo.getSmsCode());
|
|
||||||
if (!flag) {
|
|
||||||
throw new ServiceException("验证码错误");
|
|
||||||
}
|
|
||||||
|
|
||||||
Device device = deviceMapper.selectById(bo.getDeviceId());
|
Device device = deviceMapper.selectById(bo.getDeviceId());
|
||||||
if (device == null) {
|
if (device == null) {
|
||||||
throw new ServiceException("设备不存在");
|
throw new ServiceException("设备不存在");
|
||||||
}
|
}
|
||||||
Long userId = AppLoginHelper.getUserId();
|
|
||||||
|
boolean flag = validateSmsCode( bo.getPhonenumber(), bo.getSmsCode());
|
||||||
|
if (!flag) {
|
||||||
|
throw new ServiceException("验证码错误");
|
||||||
|
}
|
||||||
|
|
||||||
|
LambdaQueryWrapper<AppDeviceBindRecord> qw = new LambdaQueryWrapper<>();
|
||||||
|
qw.eq(AppDeviceBindRecord::getDeviceId, bo.getDeviceId());
|
||||||
|
AppDeviceBindRecord bindRecord = appDeviceBindRecordMapper.selectOne(qw);
|
||||||
|
Long userId = bindRecord.getBindingUserId();
|
||||||
|
|
||||||
LambdaQueryWrapper<AppDeviceShare> lqw = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<AppDeviceShare> lqw = new LambdaQueryWrapper<>();
|
||||||
lqw.eq(AppDeviceShare::getDeviceId, bo.getDeviceId());
|
lqw.eq(AppDeviceShare::getDeviceId, bo.getDeviceId());
|
||||||
lqw.eq(AppDeviceShare::getPhonenumber, bo.getPhonenumber());
|
lqw.eq(AppDeviceShare::getPhonenumber, bo.getPhonenumber());
|
||||||
|
@ -53,16 +53,21 @@ public interface WEBDeviceService extends IService<Device> {
|
|||||||
* 设备操作记录
|
* 设备操作记录
|
||||||
*
|
*
|
||||||
* @param deviceId
|
* @param deviceId
|
||||||
|
* @param startTime 开始时间
|
||||||
|
* @param endTime 结束时间
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<DeviceLog> getOperationRecord(Long deviceId);
|
TableDataInfo<DeviceLog> getOperationRecord(Long deviceId, String startTime, String endTime, PageQuery pageQuery);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备告警记录
|
* 设备告警记录
|
||||||
*
|
*
|
||||||
* @param deviceId
|
* @param deviceId
|
||||||
|
* @param startTime 开始时间
|
||||||
|
* @param endTime 结束时间
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<DeviceAlarmVo> getAlarmRecord(Long deviceId);
|
TableDataInfo<DeviceAlarmVo> getAlarmRecord(Long deviceId, String startTime, String endTime, PageQuery pageQuery);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,20 @@
|
|||||||
package com.fuyuanshen.web.service.impl;
|
package com.fuyuanshen.web.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.fuyuanshen.app.domain.AppDeviceBindRecord;
|
import com.fuyuanshen.app.domain.AppDeviceBindRecord;
|
||||||
import com.fuyuanshen.app.domain.AppDeviceShare;
|
import com.fuyuanshen.app.domain.AppDeviceShare;
|
||||||
import com.fuyuanshen.app.domain.AppPersonnelInfoRecords;
|
import com.fuyuanshen.app.domain.AppPersonnelInfoRecords;
|
||||||
import com.fuyuanshen.app.domain.vo.AppDeviceShareVo;
|
|
||||||
import com.fuyuanshen.app.mapper.AppDeviceBindRecordMapper;
|
import com.fuyuanshen.app.mapper.AppDeviceBindRecordMapper;
|
||||||
import com.fuyuanshen.app.mapper.AppDeviceShareMapper;
|
import com.fuyuanshen.app.mapper.AppDeviceShareMapper;
|
||||||
import com.fuyuanshen.app.mapper.AppPersonnelInfoRecordsMapper;
|
import com.fuyuanshen.app.mapper.AppPersonnelInfoRecordsMapper;
|
||||||
|
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||||
|
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||||
import com.fuyuanshen.equipment.domain.Device;
|
import com.fuyuanshen.equipment.domain.Device;
|
||||||
import com.fuyuanshen.equipment.domain.DeviceAlarm;
|
import com.fuyuanshen.equipment.domain.DeviceAlarm;
|
||||||
import com.fuyuanshen.equipment.domain.DeviceAssignments;
|
import com.fuyuanshen.equipment.domain.DeviceAssignments;
|
||||||
@ -23,7 +27,6 @@ import com.fuyuanshen.equipment.mapper.DeviceAssignmentsMapper;
|
|||||||
import com.fuyuanshen.equipment.mapper.DeviceLogMapper;
|
import com.fuyuanshen.equipment.mapper.DeviceLogMapper;
|
||||||
import com.fuyuanshen.equipment.mapper.DeviceMapper;
|
import com.fuyuanshen.equipment.mapper.DeviceMapper;
|
||||||
import com.fuyuanshen.web.service.WEBDeviceService;
|
import com.fuyuanshen.web.service.WEBDeviceService;
|
||||||
import com.fuyuanshen.web.service.device.DeviceBizService;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -129,11 +132,19 @@ public class WEBDeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impl
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<DeviceLog> getOperationRecord(Long deviceId) {
|
public TableDataInfo<DeviceLog> getOperationRecord(Long deviceId, String startTime, String endTime, PageQuery pageQuery) {
|
||||||
List<DeviceLog> logList = deviceLogMapper.selectList(
|
Page<DeviceLog> page = pageQuery.build();
|
||||||
new QueryWrapper<DeviceLog>().eq("device_id", deviceId)
|
QueryWrapper<DeviceLog> queryWrapper = new QueryWrapper<DeviceLog>().eq("device_id", deviceId);
|
||||||
.orderByDesc("create_time"));
|
|
||||||
return logList;
|
if (StrUtil.isNotEmpty(startTime)) {
|
||||||
|
queryWrapper.ge("create_time", startTime);
|
||||||
|
}
|
||||||
|
if (StrUtil.isNotEmpty(endTime)) {
|
||||||
|
queryWrapper.le("create_time", endTime);
|
||||||
|
}
|
||||||
|
queryWrapper.orderByDesc("create_time");
|
||||||
|
IPage<DeviceLog> logList = deviceLogMapper.selectPage(page, queryWrapper);
|
||||||
|
return TableDataInfo.build(logList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -144,13 +155,23 @@ public class WEBDeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impl
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<DeviceAlarmVo> getAlarmRecord(Long deviceId) {
|
public TableDataInfo getAlarmRecord(Long deviceId, String startTime, String endTime, PageQuery pageQuery) {
|
||||||
List<DeviceAlarm> alarmList = deviceAlarmMapper.selectList(
|
Page<DeviceAlarm> page = pageQuery.build();
|
||||||
new QueryWrapper<DeviceAlarm>().eq("device_id", deviceId)
|
QueryWrapper<DeviceAlarm> queryWrapper = new QueryWrapper<DeviceAlarm>().eq("device_id", deviceId);
|
||||||
.orderByDesc("create_time"));
|
|
||||||
List<DeviceAlarmVo> deviceAlarmVoList = BeanUtil.copyToList(alarmList, DeviceAlarmVo.class);
|
if (StrUtil.isNotEmpty(startTime)) {
|
||||||
return deviceAlarmVoList;
|
queryWrapper.ge("start_time", startTime);
|
||||||
|
}
|
||||||
|
if (StrUtil.isNotEmpty(endTime)) {
|
||||||
|
queryWrapper.le("start_time", endTime);
|
||||||
|
}
|
||||||
|
queryWrapper.orderByDesc("start_time");
|
||||||
|
IPage<DeviceAlarm> alarmPage = deviceAlarmMapper.selectPage(page, queryWrapper);
|
||||||
|
|
||||||
|
// List<DeviceAlarmVo> deviceAlarmVoList = BeanUtil.copyToList(alarmPage.getRecords(), DeviceAlarmVo.class);
|
||||||
|
return TableDataInfo.build(alarmPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@
|
|||||||
<if test="bo.shareUser != null">
|
<if test="bo.shareUser != null">
|
||||||
and u.user_name = #{bo.shareUser}
|
and u.user_name = #{bo.shareUser}
|
||||||
</if>
|
</if>
|
||||||
<if test="criteria.shareStartTime != null and criteria.hareEndTime != null">
|
<if test="bo.shareStartTime != null and bo.hareEndTime != null">
|
||||||
and ad.create_time between #{bo.shareStartTime} and #{bo.shareEndTime}
|
and ad.create_time between #{bo.shareStartTime} and #{bo.shareEndTime}
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
|
@ -4,7 +4,9 @@ import com.fuyuanshen.common.tenant.core.TenantEntity;
|
|||||||
import com.baomidou.mybatisplus.annotation.*;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
@ -63,7 +65,6 @@ public class DeviceAlarm extends TenantEntity {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 经度
|
* 经度
|
||||||
|
|
||||||
*/
|
*/
|
||||||
private Long longitude;
|
private Long longitude;
|
||||||
|
|
||||||
@ -90,7 +91,7 @@ public class DeviceAlarm extends TenantEntity {
|
|||||||
/**
|
/**
|
||||||
* 报警持续时间
|
* 报警持续时间
|
||||||
*/
|
*/
|
||||||
private Long durationTime;
|
private String durationTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 0已处理,1未处理
|
* 0已处理,1未处理
|
||||||
|
@ -21,6 +21,18 @@ public class AlarmInformationVo {
|
|||||||
*/
|
*/
|
||||||
private Integer processingAlarm = 0;
|
private Integer processingAlarm = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 今日报警总数
|
||||||
|
*/
|
||||||
|
private Integer alarmsTotalToday = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 今日总处理报警
|
||||||
|
*/
|
||||||
|
private Integer processingAlarmToday = 0;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 强制报警
|
* 强制报警
|
||||||
*/
|
*/
|
||||||
|
@ -26,4 +26,24 @@ public class EquipmentClassificationVo {
|
|||||||
*/
|
*/
|
||||||
private Integer devices4GAndBluetooth = 0;
|
private Integer devices4GAndBluetooth = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备总数
|
||||||
|
*/
|
||||||
|
private Integer total;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算设备总数
|
||||||
|
*
|
||||||
|
* @return 设备总数
|
||||||
|
*/
|
||||||
|
public Integer getTotal() {
|
||||||
|
if (total == null) {
|
||||||
|
total = (equipment4G == null ? 0 : equipment4G) +
|
||||||
|
(deviceBluetooth == null ? 0 : deviceBluetooth) +
|
||||||
|
(devices4GAndBluetooth == null ? 0 : devices4GAndBluetooth);
|
||||||
|
}
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -99,11 +99,11 @@ public interface DeviceMapper extends BaseMapper<Device> {
|
|||||||
/**
|
/**
|
||||||
* 获取设备使用数据
|
* 获取设备使用数据
|
||||||
*
|
*
|
||||||
* @param deviceId 设备ID
|
* @param deviceTypeId 设备ID
|
||||||
* @param range 时间范围 1:半年 2:一年
|
* @param range 时间范围 1:半年 2:一年
|
||||||
* @return 每月使用数据列表
|
* @return 每月使用数据列表
|
||||||
*/
|
*/
|
||||||
List<Map<String, Object>> getEquipmentUsageData(Long deviceId, Integer range);
|
List<Map<String, Object>> getEquipmentUsageData(@Param("deviceTypeId") Long deviceTypeId, @Param("range") Integer range);
|
||||||
|
|
||||||
// 在DeviceMapper.java中添加方法
|
// 在DeviceMapper.java中添加方法
|
||||||
int getUsageDataForMonth(@Param("deviceId") Long deviceId,
|
int getUsageDataForMonth(@Param("deviceId") Long deviceId,
|
||||||
|
@ -139,9 +139,9 @@ public interface DeviceService extends IService<Device> {
|
|||||||
/**
|
/**
|
||||||
* 获取设备使用数据
|
* 获取设备使用数据
|
||||||
*
|
*
|
||||||
* @param deviceId
|
* @param deviceTypeId
|
||||||
* @param range
|
* @param range
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<Map<String, Object>> getEquipmentUsageData(Long deviceId, Integer range);
|
List<Map<String, Object>> getEquipmentUsageData(Long deviceTypeId, Integer range);
|
||||||
}
|
}
|
||||||
|
@ -630,6 +630,7 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
|||||||
@Override
|
@Override
|
||||||
public EquipmentClassificationVo getEquipmentClassification() {
|
public EquipmentClassificationVo getEquipmentClassification() {
|
||||||
EquipmentClassificationVo equipmentClassification = deviceMapper.getEquipmentClassification();
|
EquipmentClassificationVo equipmentClassification = deviceMapper.getEquipmentClassification();
|
||||||
|
equipmentClassification.getTotal();
|
||||||
return equipmentClassification;
|
return equipmentClassification;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -648,13 +649,13 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
|||||||
/**
|
/**
|
||||||
* 获取设备使用数据
|
* 获取设备使用数据
|
||||||
*
|
*
|
||||||
* @param deviceId 设备ID
|
* @param deviceTypeId 设备ID
|
||||||
* @param range 时间范围 1:半年 2:一年
|
* @param range 时间范围 1:半年 2:一年
|
||||||
* @return 每月使用数据列表
|
* @return 每月使用数据列表
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Map<String, Object>> getEquipmentUsageData(Long deviceId, Integer range) {
|
public List<Map<String, Object>> getEquipmentUsageData(Long deviceTypeId, Integer range) {
|
||||||
List<Map<String, Object>> equipmentUsageData = deviceMapper.getEquipmentUsageData(deviceId, range);
|
List<Map<String, Object>> equipmentUsageData = deviceMapper.getEquipmentUsageData(deviceTypeId, range);
|
||||||
return equipmentUsageData;
|
return equipmentUsageData;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -321,11 +321,11 @@
|
|||||||
<!-- 获取数据总览 -->
|
<!-- 获取数据总览 -->
|
||||||
<select id="getDataOverview" resultType="com.fuyuanshen.equipment.domain.vo.DataOverviewVo">
|
<select id="getDataOverview" resultType="com.fuyuanshen.equipment.domain.vo.DataOverviewVo">
|
||||||
SELECT (SELECT COUNT(1) FROM device) AS devicesNumber,
|
SELECT (SELECT COUNT(1) FROM device) AS devicesNumber,
|
||||||
(SELECT COUNT(1) FROM device WHERE device_status = 1) AS equipmentOnline,
|
(SELECT COUNT(1) FROM device WHERE online_status = 1) AS equipmentOnline,
|
||||||
(SELECT COUNT(1) FROM device WHERE DATE (create_time) = CURDATE()) AS bindingNew, (
|
(SELECT COUNT(1) FROM device WHERE DATE (create_time) = CURDATE() AND binding_status = 1 ) AS bindingNew, (
|
||||||
SELECT COUNT (1)
|
SELECT COUNT (1)
|
||||||
FROM device
|
FROM device
|
||||||
WHERE device_status = 2) AS equipmentAbnormal
|
WHERE online_status = 2) AS equipmentAbnormal
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 获取设备分类 -->
|
<!-- 获取设备分类 -->
|
||||||
@ -347,30 +347,38 @@
|
|||||||
|
|
||||||
<!-- 获取告警信息 -->
|
<!-- 获取告警信息 -->
|
||||||
<select id="getAlarmInformation" resultType="com.fuyuanshen.equipment.domain.vo.AlarmInformationVo">
|
<select id="getAlarmInformation" resultType="com.fuyuanshen.equipment.domain.vo.AlarmInformationVo">
|
||||||
SELECT (SELECT COUNT(1) FROM device_alarm WHERE treatment_state = 0 AND DATE (create_time) = CURDATE()) AS alarmsTotal, (
|
SELECT (SELECT COUNT(1) FROM device_alarm WHERE treatment_state = 0) AS alarmsTotal
|
||||||
|
, (SELECT COUNT(1)
|
||||||
|
FROM device_alarm
|
||||||
|
WHERE treatment_state = 0) AS processingAlarm
|
||||||
|
, (SELECT COUNT(1)
|
||||||
|
FROM device_alarm
|
||||||
|
WHERE treatment_state = 0 AND
|
||||||
|
DATE (create_time) = CURDATE()) AS alarmsTotalToday
|
||||||
|
, (
|
||||||
SELECT COUNT (1)
|
SELECT COUNT (1)
|
||||||
FROM device_alarm
|
FROM device_alarm
|
||||||
WHERE treatment_state = 0
|
WHERE treatment_state = 0
|
||||||
AND DATE (create_time) = CURDATE()) AS processingAlarm
|
AND DATE (create_time) = CURDATE()) AS processingAlarmToday
|
||||||
, (
|
, (
|
||||||
SELECT COUNT (1)
|
SELECT COUNT (1)
|
||||||
FROM device_alarm
|
FROM device_alarm
|
||||||
WHERE device_action = 0
|
WHERE device_action = 0
|
||||||
AND DATE (create_time) = CURDATE()) AS alarmForced
|
) AS alarmForced
|
||||||
, (
|
, (
|
||||||
SELECT COUNT (1)
|
SELECT COUNT (1)
|
||||||
FROM device_alarm
|
FROM device_alarm
|
||||||
WHERE device_action = 1
|
WHERE device_action = 1
|
||||||
AND DATE (create_time) = CURDATE()) AS intrusionImpact
|
) AS intrusionImpact
|
||||||
, (
|
, (
|
||||||
SELECT COUNT (1)
|
SELECT COUNT (1)
|
||||||
FROM device_alarm
|
FROM device_alarm
|
||||||
WHERE device_action = 2
|
WHERE device_action = 2
|
||||||
AND DATE (create_time) = CURDATE()) AS alarmManual
|
) AS alarmManual
|
||||||
, (
|
, (
|
||||||
SELECT COUNT (1)
|
SELECT COUNT (1)
|
||||||
FROM device_alarm
|
FROM device_alarm
|
||||||
WHERE device_action = 3 AND DATE (create_time) = CURDATE()) AS fenceElectronic
|
WHERE device_action = 3) AS fenceElectronic
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@ -391,11 +399,15 @@
|
|||||||
FROM device_log dl
|
FROM device_log dl
|
||||||
LEFT JOIN device d ON dl.device_id = d.id
|
LEFT JOIN device d ON dl.device_id = d.id
|
||||||
LEFT JOIN device_type dt ON d.device_type = dt.id
|
LEFT JOIN device_type dt ON d.device_type = dt.id
|
||||||
WHERE dt.id = #{deviceId}
|
<where>
|
||||||
|
<if test="deviceTypeId != null">
|
||||||
|
dt.id = #{deviceTypeId}
|
||||||
|
</if>
|
||||||
AND (
|
AND (
|
||||||
(#{range} = 1 AND dl.create_time >= DATE_SUB(NOW(), INTERVAL 6 MONTH)) OR
|
(#{range} = 1 AND dl.create_time >= DATE_SUB(NOW(), INTERVAL 6 MONTH)) OR
|
||||||
(#{range} = 2 AND dl.create_time >= DATE_SUB(NOW(), INTERVAL 12 MONTH))
|
(#{range} = 2 AND dl.create_time >= DATE_SUB(NOW(), INTERVAL 12 MONTH))
|
||||||
)
|
)
|
||||||
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getUsageDataForMonth" resultType="java.lang.Integer">
|
<select id="getUsageDataForMonth" resultType="java.lang.Integer">
|
||||||
|
Reference in New Issue
Block a user