forked from dyf/fys-Multi-tenant
控制中心优化2
This commit is contained in:
@ -85,25 +85,7 @@ public class AppDeviceBJQController extends BaseController {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量上传设备logo图片
|
||||
*/
|
||||
@PostMapping("/batchUploadLogo")
|
||||
@FunctionAccessAnnotation("batchUploadLogo")
|
||||
public R<Void> batchUploadLogo(@Validated @ModelAttribute AppDeviceLogoUploadDto bo) {
|
||||
|
||||
List<MultipartFile> files = bo.getFiles();
|
||||
if(files == null || files.isEmpty()){
|
||||
return R.warn("文件不能为空");
|
||||
}
|
||||
MultipartFile file = files.get(0);
|
||||
if(file.getSize()>1024*1024*2){
|
||||
throw new ServiceException("图片不能大于2M");
|
||||
}
|
||||
appDeviceService.batchUploadLogo(bo);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 灯光模式
|
||||
|
||||
@ -16,10 +16,10 @@ public class AppDeviceLogoUploadDto {
|
||||
*/
|
||||
private MultipartFile file;
|
||||
|
||||
/**
|
||||
* 文件
|
||||
*/
|
||||
private List<MultipartFile> files;
|
||||
// /**
|
||||
// * 文件
|
||||
// */
|
||||
// private List<MultipartFile> files;
|
||||
|
||||
|
||||
private List<Long> deviceIds;
|
||||
|
||||
@ -56,7 +56,7 @@ public class ReceiverMessageHandler implements MessageHandler {
|
||||
RedisUtils.offerDeduplicated(queueKey,dedupKey,deviceImei, Duration.ofHours(24));
|
||||
//在线状态
|
||||
String deviceOnlineStatusRedisKey = GlobalConstants.GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX+ deviceImei + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX ;
|
||||
RedisUtils.setCacheObject(deviceOnlineStatusRedisKey, "1", Duration.ofSeconds(303));
|
||||
RedisUtils.setCacheObject(deviceOnlineStatusRedisKey, "1", Duration.ofSeconds(360));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -106,16 +106,22 @@ public class MqttMessageConsumer {
|
||||
// .set("online_status", 1);
|
||||
// deviceMapper.update(updateWrapper);
|
||||
// }
|
||||
QueryWrapper<Device> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("device_imei", message);
|
||||
queryWrapper.eq("online_status", 1);
|
||||
Long count = deviceMapper.selectCount(queryWrapper);
|
||||
if(count == 0){
|
||||
// QueryWrapper<Device> queryWrapper = new QueryWrapper<>();
|
||||
// queryWrapper.eq("device_imei", message);
|
||||
// queryWrapper.eq("online_status", 1);
|
||||
// Long count = deviceMapper.selectCount(queryWrapper);
|
||||
// if(count == 0){
|
||||
// UpdateWrapper<Device> updateWrapper = new UpdateWrapper<>();
|
||||
// updateWrapper.eq("device_imei", message)
|
||||
// .eq("online_status", 0)
|
||||
// .set("online_status", 1);
|
||||
// deviceMapper.update(updateWrapper);
|
||||
// }
|
||||
UpdateWrapper<Device> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.eq("device_imei", message)
|
||||
.eq("online_status", 0)
|
||||
.set("online_status", 1);
|
||||
deviceMapper.update(updateWrapper);
|
||||
}
|
||||
int update = deviceMapper.update(updateWrapper);
|
||||
// 模拟业务处理耗时
|
||||
// Thread.sleep(200);
|
||||
|
||||
|
||||
@ -82,6 +82,22 @@ public class DeviceBJQController extends BaseController {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量上传设备logo图片
|
||||
*/
|
||||
@PostMapping("/batchUploadLogo")
|
||||
@FunctionAccessAnnotation("batchUploadLogo")
|
||||
public R<Void> batchUploadLogo(@Validated @ModelAttribute AppDeviceLogoUploadDto bo) {
|
||||
|
||||
MultipartFile file = bo.getFile();
|
||||
if(file.getSize()>1024*1024*2){
|
||||
return R.warn("图片不能大于2M");
|
||||
}
|
||||
appDeviceService.batchUploadLogo(bo);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 灯光模式
|
||||
* 0(关灯),1(强光模式),2(弱光模式), 3(爆闪模式), 4(泛光模式)
|
||||
|
||||
@ -173,8 +173,11 @@ public class DeviceBJQBizService {
|
||||
}
|
||||
//设备在线状态
|
||||
String onlineStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + device.getDeviceImei()+ DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX);
|
||||
if(StringUtils.isNotBlank(onlineStatus)){
|
||||
//设备在线状态
|
||||
if("1".equals(onlineStatus)){
|
||||
vo.setOnlineStatus(1);
|
||||
}else if("2".equals(onlineStatus)){
|
||||
vo.setOnlineStatus(2);
|
||||
}else{
|
||||
vo.setOnlineStatus(0);
|
||||
}
|
||||
@ -335,7 +338,10 @@ public class DeviceBJQBizService {
|
||||
throw new ServiceException("设备不存在");
|
||||
}
|
||||
if(getDeviceStatus(device.getDeviceImei())){
|
||||
throw new ServiceException(device.getDeviceName()+",设备已断开连接");
|
||||
// throw new ServiceException(device.getDeviceName()+",设备已断开连接");
|
||||
log.info(device.getDeviceName()+",设备已断开连接");
|
||||
recordDeviceLog(device.getId(), device.getDeviceName(), "上传开机画面", device.getDeviceName()+",设备已断开连接", AppLoginHelper.getUserId());
|
||||
return;
|
||||
}
|
||||
MultipartFile file = bo.getFile();
|
||||
|
||||
@ -551,15 +557,15 @@ public class DeviceBJQBizService {
|
||||
public void batchUploadLogo(AppDeviceLogoUploadDto bo) {
|
||||
|
||||
List<Long> deviceIds = bo.getDeviceIds();
|
||||
List<MultipartFile> files = bo.getFiles();
|
||||
MultipartFile file = bo.getFile();
|
||||
if (deviceIds == null || deviceIds.isEmpty()) {
|
||||
throw new ServiceException("请选择设备");
|
||||
}
|
||||
for (int i = 0; i < deviceIds.size(); i++) {
|
||||
for (Long deviceId : deviceIds) {
|
||||
AppDeviceLogoUploadDto dto = new AppDeviceLogoUploadDto();
|
||||
dto.setDeviceId(deviceIds.get(i));
|
||||
dto.setFile(files.get(i));
|
||||
uploadDeviceLogo(bo);
|
||||
dto.setDeviceId(deviceId);
|
||||
dto.setFile(file);
|
||||
uploadDeviceLogo(dto);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@ public class WebDeviceVo implements Serializable {
|
||||
* 0 未绑定
|
||||
* 1 已绑定
|
||||
*/
|
||||
private Integer binding_status;
|
||||
private Integer bindingStatus;
|
||||
|
||||
/**
|
||||
* 绑定时间
|
||||
|
||||
Reference in New Issue
Block a user