导出设备数据
This commit is contained in:
@ -6,6 +6,7 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fuyuanshen.common.core.utils.file.ImageCompressUtil;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import com.fuyuanshen.common.core.constant.CacheNames;
|
||||
@ -143,7 +144,7 @@ public class SysOssServiceImpl implements ISysOssService, OssService {
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getFileSuffix()), SysOss::getFileSuffix, bo.getFileSuffix());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getUrl()), SysOss::getUrl, bo.getUrl());
|
||||
lqw.between(params.get("beginCreateTime") != null && params.get("endCreateTime") != null,
|
||||
SysOss::getCreateTime, params.get("beginCreateTime"), params.get("endCreateTime"));
|
||||
SysOss::getCreateTime, params.get("beginCreateTime"), params.get("endCreateTime"));
|
||||
lqw.eq(ObjectUtil.isNotNull(bo.getCreateBy()), SysOss::getCreateBy, bo.getCreateBy());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getService()), SysOss::getService, bo.getService());
|
||||
lqw.orderByAsc(SysOss::getOssId);
|
||||
@ -169,7 +170,7 @@ public class SysOssServiceImpl implements ISysOssService, OssService {
|
||||
|
||||
@Override
|
||||
public int updateHashById(long ossId, String fileHash) {
|
||||
return baseMapper.updateHashById(ossId,fileHash);
|
||||
return baseMapper.updateHashById(ossId, fileHash);
|
||||
}
|
||||
|
||||
|
||||
@ -191,6 +192,7 @@ public class SysOssServiceImpl implements ISysOssService, OssService {
|
||||
storage.download(sysOss.getFileName(), response.getOutputStream(), response::setContentLengthLong);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 上传 MultipartFile 到对象存储服务,并保存文件信息到数据库
|
||||
*
|
||||
@ -209,14 +211,22 @@ public class SysOssServiceImpl implements ISysOssService, OssService {
|
||||
OssClient storage = OssFactory.instance();
|
||||
UploadResult uploadResult;
|
||||
try {
|
||||
uploadResult = storage.uploadSuffix(file.getBytes(), suffix, file.getContentType());
|
||||
byte[] imageData = file.getBytes();
|
||||
// 检查是否需要压缩
|
||||
if (ImageCompressUtil.needCompress(imageData)) {
|
||||
// 压缩到100KB以内
|
||||
imageData = ImageCompressUtil.compressImage(imageData);
|
||||
// 使用压缩后的数据
|
||||
}
|
||||
uploadResult = storage.uploadSuffix(imageData, suffix, file.getContentType());
|
||||
} catch (IOException e) {
|
||||
throw new ServiceException(e.getMessage());
|
||||
}
|
||||
// 保存文件信息
|
||||
return buildResultEntity(originalfileName, suffix, storage.getConfigKey(), uploadResult,hash);
|
||||
return buildResultEntity(originalfileName, suffix, storage.getConfigKey(), uploadResult, hash);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 上传 MultipartFile 到对象存储服务,并保存文件信息到数据库
|
||||
*
|
||||
@ -236,7 +246,7 @@ public class SysOssServiceImpl implements ISysOssService, OssService {
|
||||
throw new ServiceException(e.getMessage());
|
||||
}
|
||||
// 保存文件信息
|
||||
return buildResultEntity(originalfileName, suffix, storage.getConfigKey(), uploadResult,null);
|
||||
return buildResultEntity(originalfileName, suffix, storage.getConfigKey(), uploadResult, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -252,11 +262,10 @@ public class SysOssServiceImpl implements ISysOssService, OssService {
|
||||
OssClient storage = OssFactory.instance();
|
||||
UploadResult uploadResult = storage.uploadSuffix(file, suffix);
|
||||
// 保存文件信息
|
||||
return buildResultEntity(originalfileName, suffix, storage.getConfigKey(), uploadResult,null);
|
||||
return buildResultEntity(originalfileName, suffix, storage.getConfigKey(), uploadResult, null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 上传二进制数据到对象存储服务,并保存文件信息到数据库
|
||||
*
|
||||
@ -281,7 +290,7 @@ public class SysOssServiceImpl implements ISysOssService, OssService {
|
||||
uploadResult = storage.uploadSuffix(data, suffix, "image/jpeg"); // 假设是图片类型,可以根据实际需要修改
|
||||
|
||||
// 保存文件信息
|
||||
return buildResultEntity(fileName, suffix, storage.getConfigKey(), uploadResult,null);
|
||||
return buildResultEntity(fileName, suffix, storage.getConfigKey(), uploadResult, null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user