app批量上传logo

This commit is contained in:
2025-09-30 17:53:28 +08:00
parent 2cfcea65f1
commit 9afc0222d5
3 changed files with 49 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import com.fuyuanshen.app.domain.dto.AppDeviceLogoUploadDto;
import com.fuyuanshen.app.domain.dto.DeviceInstructDto; import com.fuyuanshen.app.domain.dto.DeviceInstructDto;
import com.fuyuanshen.app.domain.vo.AppDeviceDetailVo; import com.fuyuanshen.app.domain.vo.AppDeviceDetailVo;
import com.fuyuanshen.common.core.domain.R; import com.fuyuanshen.common.core.domain.R;
import com.fuyuanshen.common.core.exception.ServiceException;
import com.fuyuanshen.common.core.validate.AddGroup; import com.fuyuanshen.common.core.validate.AddGroup;
import com.fuyuanshen.common.ratelimiter.annotation.FunctionAccessAnnotation; import com.fuyuanshen.common.ratelimiter.annotation.FunctionAccessAnnotation;
import com.fuyuanshen.common.ratelimiter.annotation.FunctionAccessBatcAnnotation; import com.fuyuanshen.common.ratelimiter.annotation.FunctionAccessBatcAnnotation;
@ -17,6 +18,8 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.util.List;
/** /**
* BJQ6170设备控制类 * BJQ6170设备控制类
*/ */
@ -82,6 +85,26 @@ public class AppDeviceBJQController extends BaseController {
return R.ok(); 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();
}
/** /**
* 灯光模式 * 灯光模式
* 0关灯1强光模式2弱光模式, 3爆闪模式, 4泛光模式 * 0关灯1强光模式2弱光模式, 3爆闪模式, 4泛光模式

View File

@ -3,6 +3,8 @@ package com.fuyuanshen.app.domain.dto;
import lombok.Data; import lombok.Data;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@Data @Data
public class AppDeviceLogoUploadDto { public class AppDeviceLogoUploadDto {
@ -14,5 +16,13 @@ public class AppDeviceLogoUploadDto {
*/ */
private MultipartFile file; private MultipartFile file;
/**
* 文件
*/
private List<MultipartFile> files;
private List<Long> deviceIds;
private Integer chunkSize; private Integer chunkSize;
} }

View File

@ -15,6 +15,7 @@ import com.fuyuanshen.app.domain.vo.AppPersonnelInfoVo;
import com.fuyuanshen.app.mapper.AppPersonnelInfoMapper; import com.fuyuanshen.app.mapper.AppPersonnelInfoMapper;
import com.fuyuanshen.app.mapper.AppPersonnelInfoRecordsMapper; import com.fuyuanshen.app.mapper.AppPersonnelInfoRecordsMapper;
import com.fuyuanshen.common.core.constant.GlobalConstants; import com.fuyuanshen.common.core.constant.GlobalConstants;
import com.fuyuanshen.common.core.domain.R;
import com.fuyuanshen.common.core.exception.ServiceException; import com.fuyuanshen.common.core.exception.ServiceException;
import com.fuyuanshen.common.core.utils.*; import com.fuyuanshen.common.core.utils.*;
import com.fuyuanshen.common.redis.utils.RedisUtils; import com.fuyuanshen.common.redis.utils.RedisUtils;
@ -546,4 +547,19 @@ public class DeviceBJQBizService {
String deviceOnlineStatusRedisKey = GlobalConstants.GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX+ deviceImei + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX ; String deviceOnlineStatusRedisKey = GlobalConstants.GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX+ deviceImei + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX ;
return RedisUtils.getCacheObject(deviceOnlineStatusRedisKey) == null; return RedisUtils.getCacheObject(deviceOnlineStatusRedisKey) == null;
} }
public void batchUploadLogo(AppDeviceLogoUploadDto bo) {
List<Long> deviceIds = bo.getDeviceIds();
List<MultipartFile> files = bo.getFiles();
if (deviceIds == null || deviceIds.isEmpty()) {
throw new ServiceException("请选择设备");
}
for (int i = 0; i < deviceIds.size(); i++) {
AppDeviceLogoUploadDto dto = new AppDeviceLogoUploadDto();
dto.setDeviceId(deviceIds.get(i));
dto.setFile(files.get(i));
uploadDeviceLogo(bo);
}
}
} }