Browse Source

预警导出-优化导出效果

dev
时子升 1 week ago
parent
commit
8287a45d39
  1. 28
      dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertServiceImpl.java

28
dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertServiceImpl.java

@ -1017,7 +1017,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
throw new RuntimeException("没有可查看的预警数据!"); throw new RuntimeException("没有可查看的预警数据!");
} }
wrapper.eq("t.business_type",1); // wrapper.eq("t.business_type",1);
//根据前端查询条件查询 //根据前端查询条件查询
List<BusinessAlert> alertList = this.baseMapper.exportAlert(wrapper,ptPrefix); List<BusinessAlert> alertList = this.baseMapper.exportAlert(wrapper,ptPrefix);
@ -1052,7 +1052,8 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
businessAlert.setMaxMateSourceImgUrl(MinioUntil.getObjectUrlOne(MinIOConstants.BUCKET_ALERT, businessAlert.getMaxMateSourceImgUrl(), 3600).toString()); businessAlert.setMaxMateSourceImgUrl(MinioUntil.getObjectUrlOne(MinIOConstants.BUCKET_ALERT, businessAlert.getMaxMateSourceImgUrl(), 3600).toString());
businessAlert.setMateSourceImgUrl(MinioUntil.getObjectUrlOne(MinIOConstants.BUCKET_ALERT, businessAlert.getMateSourceImgUrl(), 3600).toString()); businessAlert.setMateSourceImgUrl(MinioUntil.getObjectUrlOne(MinIOConstants.BUCKET_ALERT, businessAlert.getMateSourceImgUrl(), 3600).toString());
}else { }else {
businessAlert.setImages(MinioUntil.getObjectUrlOne(MinIOConstants.BUCKET_ALERT, businessAlert.getImages(), 3600).toString()); //url渲染快(只要不报错),base64模式超级卡慢
businessAlert.setImages(MinioUntil.getObjectUrlOne(MinIOConstants.BUCKET_DKCY, businessAlert.getImages(), 3600).toString()); // 9001/dkcy//ai/report/ > 9001/dkcy/ai/report/
} }
//获取指南针 //获取指南针
@ -1083,6 +1084,17 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
if (bo.getExportType().equalsIgnoreCase("world")){ if (bo.getExportType().equalsIgnoreCase("world")){
/**
* http://114.235.183.147:9001/dkcy//ai/report/29847/xwoKJvrqpp/zDASKjUVlN/events/8UUXN2B00A00SKdlfHClDieQ.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20250614T061025Z&X-Amz-SignedHeaders=host&X-Amz-Credential=wuyuan%40yf%2F20250614%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Expires=3600&X-Amz-Signature=a90766f63fbecebf99fd50fed5ac018458225d5df0f6afee39b5c58b6447b16e
* 特殊字符里有特殊符号图片处理报错 class com.spire.doc.packages.sprghs: The string contains invalid characters
* 先处理 businessType=2的数据
*/
for (BusinessAlert businessAlert : alertList) {
if(ObjectUtil.equals(businessAlert.getBusinessType(),2)){
businessAlert.setImages(imageUrlToBase64(businessAlert.getImages()));
}
}
//生成word //生成word
FreemarkerUtil.renderTplFileToWord("预警导出.docx","alert.ftl",resultMap,response); FreemarkerUtil.renderTplFileToWord("预警导出.docx","alert.ftl",resultMap,response);
} else if (bo.getExportType().equalsIgnoreCase("pdf")) { } else if (bo.getExportType().equalsIgnoreCase("pdf")) {
@ -1094,6 +1106,18 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
} }
} }
// 图片url转base64
public static String imageUrlToBase64(String imageUrl) {
try (InputStream in = new URL(imageUrl).openStream()) {
byte[] bytes = in.readAllBytes();
return Base64.getEncoder().encodeToString(bytes);
} catch (Exception e) {
e.printStackTrace();
return "";
}
}
@Override @Override
public void pushAlert(Long alertId, String deptId, String deptName) { public void pushAlert(Long alertId, String deptId, String deptName) {
BusinessAlert businessAlert= this.getBusinessAlert(alertId); BusinessAlert businessAlert= this.getBusinessAlert(alertId);

Loading…
Cancel
Save