From f78a9e03ae3f455a85dfd4d8a258dc0fbbb9e694 Mon Sep 17 00:00:00 2001
From: zhanzhiqin <895896009@qq.com>
Date: 星期三, 20 四月 2022 15:39:36 +0800
Subject: [PATCH] fix
---
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightReportDataService.java | 48 ++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 42 insertions(+), 6 deletions(-)
diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightReportDataService.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightReportDataService.java
index dfe8f31..f26d49c 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightReportDataService.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightReportDataService.java
@@ -5,21 +5,31 @@
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.pagehelper.PageHelper;
+import com.sandu.common.execption.BusinessException;
+import com.sandu.common.file.FileUploadDto;
import com.sandu.common.file.config.FileProperties;
+import com.sandu.common.file.impl.AliOssFileServiceImpl;
import com.sandu.common.service.impl.BaseServiceImpl;
import com.sandu.common.util.ResUtils;
+import com.sandu.common.util.SpringContextHolder;
import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5LightHeartbeatReportInnerFrame;
+import com.sandu.ximon.admin.security.SecurityUtils;
import com.sandu.ximon.dao.bo.LightReportDataBo;
import com.sandu.ximon.dao.domain.LightReportData;
+import com.sandu.ximon.dao.domain.Pole;
+import com.sandu.ximon.dao.domain.PoleBinding;
import com.sandu.ximon.dao.mapper.LightReportDataMapper;
import lombok.AllArgsConstructor;
import lombok.SneakyThrows;
import org.springframework.beans.BeanUtils;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
import java.io.File;
+import java.sql.Wrapper;
import java.util.List;
/**
@@ -32,6 +42,7 @@
public class LightReportDataService extends BaseServiceImpl<LightReportDataMapper, LightReportData> {
private final FileProperties properties;
+ private final AliOssFileServiceImpl fileService;
/**
* 淇濆瓨涓婃姤鐨勭伅蹇冭烦鏁版嵁
@@ -64,15 +75,36 @@
*/
public List<LightReportDataBo> listReportData(int pageNo, int pageSize, String keyword, String deviceCode) {
PageHelper.startPage(pageNo, pageSize);
- return baseMapper.listReportData(keyword, deviceCode);
+ //涓簄ull鐨勮瘽鏄秴绠�
+ if (SecurityUtils.getClientId() == null) {
+ return baseMapper.listReportData(keyword, deviceCode);
+ } else {
+ return baseMapper.listReportDataByUserid(keyword, deviceCode, SecurityUtils.getUserId());
+ }
}
@SneakyThrows
public String exportList(int pageNo, int pageSize, String keyword, String deviceCode) {
+
+ if (SecurityUtils.getClientId() != null) {
+ PoleBinding one = SpringContextHolder.getBean(PoleBindingService.class).getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getDeviceCode, deviceCode)
+ .eq(PoleBinding::getDeviceType, 0));
+ if (one == null) {
+ throw new BusinessException("鏈壘鍒扮粦瀹氬叧绯伙紒");
+ } else {
+ Pole pole = SpringContextHolder.getBean(PoleService.class).getOne(Wrappers.lambdaQuery(Pole.class).eq(Pole::getUserId, SecurityUtils.getUserId()).or(w -> {
+ w.eq(Pole::getClientId, SecurityUtils.getUserId());
+ }));
+ if (pole == null) {
+ throw new BusinessException("缁戝畾鍏崇郴涓嶆纭紒");
+ }
+ }
+ }
+
PageHelper.startPage(pageNo, pageSize);
List<LightReportDataBo> list = baseMapper.listReportData(keyword, deviceCode);
- File file = new File(properties.getUploadRootPath() + "export" + File.separator + RandomUtil.randomString(12) + ".xlsx");
+ File file = new File("./" + RandomUtil.randomString(12) + ".xlsx");
// File file = new File(properties.getUploadRootPath() + "export" + File.separator + RandomUtil.randomString(12) + ".xlsx");
// ClassPathResource cpr = new ClassPathResource("public/exportOrder.xlsx");
// FileUtil.mkParentDirs(file);
@@ -82,10 +114,14 @@
// excelWriter.fill(list, writeSheet);
// excelWriter.finish();
- EasyExcel.write(file, LightReportDataBo.class).sheet("妯℃澘").doWrite(list);
- String url = file.getPath().replace(properties.getUploadRootPath(), "");
- return ResUtils.addPrefix(url);
+ EasyExcel.write(file, LightReportDataBo.class).sheet("妯$増").doWrite(list);
- // return list;
+ FileUploadDto fileUploadDto = fileService.uploadFile(file);
+// String url = file.getPath().replace(properties.getUploadRootPath(), "");
+ String url = fileUploadDto.getFileUrl();
+ file.delete();
+ return url;
+
+ // return list;
}
}
--
Gitblit v1.9.3