设备分享3
This commit is contained in:
@ -5,7 +5,6 @@ import cn.hutool.core.util.RandomUtil;
|
||||
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.service.AppDeviceShareService;
|
||||
import com.fuyuanshen.app.service.IAppDeviceShareService;
|
||||
import com.fuyuanshen.common.core.constant.Constants;
|
||||
import com.fuyuanshen.common.core.domain.R;
|
||||
@ -16,6 +15,7 @@ import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import com.fuyuanshen.common.ratelimiter.annotation.RateLimiter;
|
||||
import com.fuyuanshen.common.redis.utils.RedisUtils;
|
||||
import com.fuyuanshen.common.web.core.BaseController;
|
||||
import com.fuyuanshen.web.service.DeviceShareService;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
@ -45,7 +45,7 @@ public class AppDeviceShareController extends BaseController {
|
||||
|
||||
private final IAppDeviceShareService deviceShareService;
|
||||
|
||||
private final AppDeviceShareService appDeviceShareService;
|
||||
private final DeviceShareService appDeviceShareService;
|
||||
|
||||
/**
|
||||
* 分享管理列表
|
||||
|
@ -52,7 +52,7 @@ public class AppDeviceBJQController extends BaseController {
|
||||
* 发送信息
|
||||
*/
|
||||
@PostMapping(value = "/sendMessage")
|
||||
@FunctionAccessBatcAnnotation("sendMessage")
|
||||
@FunctionAccessBatcAnnotation(value = "sendMessage", timeOut = 30, batchMaxTimeOut = 40)
|
||||
public R<Void> sendMessage(@RequestBody AppDeviceSendMsgBo bo) {
|
||||
return toAjax(appDeviceService.sendMessage(bo));
|
||||
}
|
||||
@ -61,7 +61,7 @@ public class AppDeviceBJQController extends BaseController {
|
||||
* 发送报警信息
|
||||
*/
|
||||
@PostMapping(value = "/sendAlarmMessage")
|
||||
// @FunctionAccessBatcAnnotation("sendAlarmMessage")
|
||||
@FunctionAccessBatcAnnotation(value = "sendAlarmMessage", timeOut = 5, batchMaxTimeOut = 10)
|
||||
public R<Void> sendAlarmMessage(@RequestBody AppDeviceSendMsgBo bo) {
|
||||
return toAjax(appDeviceService.sendAlarmMessage(bo));
|
||||
}
|
||||
|
@ -1,8 +1,7 @@
|
||||
package com.fuyuanshen.app.service;
|
||||
package com.fuyuanshen.web.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;
|
||||
@ -14,11 +13,8 @@ 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.Constants;
|
||||
import com.fuyuanshen.common.core.constant.GlobalConstants;
|
||||
import com.fuyuanshen.common.core.exception.ServiceException;
|
||||
import com.fuyuanshen.common.core.exception.user.CaptchaExpireException;
|
||||
import com.fuyuanshen.common.core.utils.MessageUtils;
|
||||
import com.fuyuanshen.common.core.utils.StringUtils;
|
||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
@ -44,7 +40,7 @@ import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.*;
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
@Service
|
||||
public class AppDeviceShareService {
|
||||
public class DeviceShareService {
|
||||
|
||||
private final AppDeviceShareMapper appDeviceShareMapper;
|
||||
|
||||
@ -60,7 +56,7 @@ public class AppDeviceShareService {
|
||||
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);
|
||||
records.forEach(DeviceShareService::buildDeviceStatus);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
@ -231,7 +227,7 @@ public class AppDeviceShareService {
|
||||
IPage<AppDeviceShareVo> result = appDeviceShareMapper.otherDeviceShareList(bo, page);
|
||||
List<AppDeviceShareVo> records = result.getRecords();
|
||||
|
||||
records.forEach(AppDeviceShareService::buildDeviceStatus);
|
||||
records.forEach(DeviceShareService::buildDeviceStatus);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
@ -64,6 +64,9 @@ public class DeviceBJQBizService {
|
||||
if (device == null) {
|
||||
throw new ServiceException("设备不存在" + deviceId);
|
||||
}
|
||||
if(getDeviceStatus(device.getDeviceImei())){
|
||||
throw new ServiceException(device.getDeviceName()+",设备已断开连接");
|
||||
}
|
||||
try {
|
||||
ClassPathResource resource = new ClassPathResource("image/background.png");
|
||||
InputStream inputStream = resource.getInputStream();
|
||||
@ -139,6 +142,7 @@ public class DeviceBJQBizService {
|
||||
if (device == null) {
|
||||
throw new RuntimeException("请先将设备入库!!!");
|
||||
}
|
||||
|
||||
AppDeviceDetailVo vo = new AppDeviceDetailVo();
|
||||
vo.setDeviceId(device.getId());
|
||||
vo.setDeviceName(device.getDeviceName());
|
||||
@ -213,7 +217,9 @@ public class DeviceBJQBizService {
|
||||
if (deviceObj == null) {
|
||||
throw new RuntimeException("请先将设备入库!!!");
|
||||
}
|
||||
|
||||
if(getDeviceStatus(deviceObj.getDeviceImei())){
|
||||
throw new ServiceException(deviceObj.getDeviceName()+",设备已断开连接");
|
||||
}
|
||||
QueryWrapper<AppPersonnelInfo> qw = new QueryWrapper<AppPersonnelInfo>()
|
||||
.eq("device_id", deviceId);
|
||||
List<AppPersonnelInfoVo> appPersonnelInfoVos = appPersonnelInfoMapper.selectVoList(qw);
|
||||
@ -258,6 +264,9 @@ public class DeviceBJQBizService {
|
||||
if (device == null) {
|
||||
throw new ServiceException("设备不存在");
|
||||
}
|
||||
if(getDeviceStatus(device.getDeviceImei())){
|
||||
throw new ServiceException(device.getDeviceName()+",设备已断开连接");
|
||||
}
|
||||
MultipartFile file = bo.getFile();
|
||||
|
||||
byte[] largeData = ImageToCArrayConverter.convertImageToCArray(file.getInputStream(), 160, 80, 25600);
|
||||
@ -307,6 +316,9 @@ public class DeviceBJQBizService {
|
||||
if(device == null){
|
||||
throw new ServiceException("设备不存在");
|
||||
}
|
||||
if(getDeviceStatus(device.getDeviceImei())){
|
||||
throw new ServiceException(device.getDeviceName()+",设备已断开连接");
|
||||
}
|
||||
Integer instructValue = Integer.parseInt(params.getInstructValue());
|
||||
ArrayList<Integer> intData = new ArrayList<>();
|
||||
intData.add(1);
|
||||
@ -334,6 +346,9 @@ public class DeviceBJQBizService {
|
||||
if(device == null){
|
||||
throw new ServiceException("设备不存在");
|
||||
}
|
||||
if(getDeviceStatus(device.getDeviceImei())){
|
||||
throw new ServiceException(device.getDeviceName()+",设备已断开连接");
|
||||
}
|
||||
String instructValue = params.getInstructValue();
|
||||
ArrayList<Integer> intData = new ArrayList<>();
|
||||
intData.add(5);
|
||||
@ -368,6 +383,9 @@ public class DeviceBJQBizService {
|
||||
if(device == null){
|
||||
throw new ServiceException("设备不存在");
|
||||
}
|
||||
if(getDeviceStatus(device.getDeviceImei())){
|
||||
throw new ServiceException(device.getDeviceName()+",设备已断开连接");
|
||||
}
|
||||
Integer instructValue = Integer.parseInt(params.getInstructValue());
|
||||
ArrayList<Integer> intData = new ArrayList<>();
|
||||
intData.add(4);
|
||||
@ -407,13 +425,17 @@ public class DeviceBJQBizService {
|
||||
if (deviceIds == null || deviceIds.isEmpty()) {
|
||||
throw new ServiceException("请选择设备");
|
||||
}
|
||||
|
||||
for (Long deviceId : deviceIds) {
|
||||
Device device = deviceMapper.selectById(deviceId);
|
||||
if (device == null) {
|
||||
throw new ServiceException("设备不存在" + deviceId);
|
||||
}
|
||||
|
||||
if(getDeviceStatus(device.getDeviceImei())){
|
||||
throw new ServiceException(device.getDeviceName()+",设备已断开连接");
|
||||
}
|
||||
try {
|
||||
|
||||
ArrayList<Integer> intData = new ArrayList<>();
|
||||
intData.add(7);
|
||||
intData.add(Integer.parseInt(bo.getInstructValue()));
|
||||
@ -444,4 +466,9 @@ public class DeviceBJQBizService {
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
private boolean getDeviceStatus(String deviceImei) {
|
||||
String deviceOnlineStatusRedisKey = GlobalConstants.GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX+ deviceImei + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX ;
|
||||
return StringUtils.isBlank(deviceOnlineStatusRedisKey);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user