From 2f3d783999935f06228705e75fac26ebf099bf87 Mon Sep 17 00:00:00 2001
From: zhanzhiqin <895896009@qq.com>
Date: 星期五, 15 四月 2022 18:02:14 +0800
Subject: [PATCH] fix

---
 ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightReportDataService.java |   34 +++++++++++++++++++++++++++++++---
 1 files changed, 31 insertions(+), 3 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 54b4d4e..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,15 +5,21 @@
 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;
@@ -23,6 +29,7 @@
 import org.springframework.web.multipart.MultipartFile;
 
 import java.io.File;
+import java.sql.Wrapper;
 import java.util.List;
 
 /**
@@ -68,11 +75,32 @@
      */
     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);
 
@@ -92,8 +120,8 @@
 //        String url = file.getPath().replace(properties.getUploadRootPath(), "");
         String url = fileUploadDto.getFileUrl();
         file.delete();
-       return url;
+        return url;
 
-       // return list;
+        // return list;
     }
 }

--
Gitblit v1.9.3