Преглед изворни кода

1.阈值设置,设置了一个基础要素的阈值,状态变为已设置。设置了所有,状态反而变成了部分设置
2.项目报表fileSize计算

lengfaqiang пре 2 година
родитељ
комит
e28f1580a2

+ 29 - 0
slope-common/slope-common-core/src/main/java/com/sckw/core/utils/FileUtils.java

@@ -128,6 +128,35 @@ public class FileUtils {
         return fileInfo;
         return fileInfo;
     }
     }
 
 
+    /**
+     * 获取文件上传大小
+     *
+     * @param size 当前默认使用 kb
+     * @return
+     */
+    public static BigDecimal getFileSize(int size, String type) {
+        BigDecimal bigDecimal = new BigDecimal(NumberConstant.ZERO);
+        if (StringUtils.isBlank(type)) {
+            type = StringConstant.KB;
+        }
+        switch (type) {
+            case "B":
+                bigDecimal = new BigDecimal((double) size);
+                break;
+            case "KB":
+                bigDecimal = new BigDecimal((double) size / 1024);
+                break;
+            case "MB":
+                bigDecimal = new BigDecimal((double) size / 1048576);
+                break;
+            case "GB":
+                bigDecimal = new BigDecimal((double) size / 1073741824);
+                break;
+            default:
+                throw new RuntimeException("file size error");
+        }
+        return bigDecimal.setScale(9, RoundingMode.HALF_UP);
+    }
 
 
     /**
     /**
      * 获取oss 地址前缀
      * 获取oss 地址前缀

+ 1 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ReportService.java

@@ -69,6 +69,7 @@ public class ReportService {
         for (ReportStatementVO reportStatementVO : list) {
         for (ReportStatementVO reportStatementVO : list) {
             reportStatementVO.setReportType(ReportTypeEnum.getDescription(reportStatementVO.getReportType()));
             reportStatementVO.setReportType(ReportTypeEnum.getDescription(reportStatementVO.getReportType()));
             reportStatementVO.setProjectName(map.get(Long.parseLong(reportStatementVO.getProjectId())));
             reportStatementVO.setProjectName(map.get(Long.parseLong(reportStatementVO.getProjectId())));
+            reportStatementVO.setFileSize(reportStatementVO.getFileSize()+"MB");
         }
         }
         return PageRes.build(info, list);
         return PageRes.build(info, list);
     }
     }

+ 1 - 1
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ThresholdService.java

@@ -772,7 +772,7 @@ public class ThresholdService {
 
 
         }
         }
         if (!CollectionUtils.isEmpty(integratedElementList)) {
         if (!CollectionUtils.isEmpty(integratedElementList)) {
-            List<String> collect = basiclElementList.stream().map(DeviceElementDTO::getIntegrationElement).collect(Collectors.toList());
+            List<String> collect = integratedElementList.stream().map(DeviceElementDTO::getIntegrationElement).collect(Collectors.toList());
             if (!CollectionUtils.isEmpty(collect)) {
             if (!CollectionUtils.isEmpty(collect)) {
                 count = count + collect.size();
                 count = count + collect.size();
 //                for (String s : collect) {
 //                for (String s : collect) {

+ 3 - 8
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/task/ReportTemplateTaskService.java

@@ -2,38 +2,32 @@ package com.sckw.slope.detection.service.task;
 
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.sckw.core.model.constant.NumberConstant;
 import com.sckw.core.model.constant.NumberConstant;
-import com.sckw.core.model.enums.DeviceEnum;
 import com.sckw.core.model.enums.DictItemEnum;
 import com.sckw.core.model.enums.DictItemEnum;
 import com.sckw.core.model.enums.ReportTypeEnum;
 import com.sckw.core.model.enums.ReportTypeEnum;
+import com.sckw.core.utils.FileUtils;
 import com.sckw.core.utils.IdWorker;
 import com.sckw.core.utils.IdWorker;
 import com.sckw.excel.annotation.ExcelContext;
 import com.sckw.excel.annotation.ExcelContext;
 import com.sckw.excel.utils.ExcelUtil;
 import com.sckw.excel.utils.ExcelUtil;
 import com.sckw.slope.detection.dao.mysql.KwsDeviceIntegrationMapper;
 import com.sckw.slope.detection.dao.mysql.KwsDeviceIntegrationMapper;
-import com.sckw.slope.detection.dao.mysql.KwsProjectDeviceMapper;
 import com.sckw.slope.detection.dao.mysql.KwsReportDataMapper;
 import com.sckw.slope.detection.dao.mysql.KwsReportDataMapper;
 import com.sckw.slope.detection.dao.mysql.KwsReportTemplateMapper;
 import com.sckw.slope.detection.dao.mysql.KwsReportTemplateMapper;
 import com.sckw.slope.detection.dao.tdengine.SlopeDataMapper;
 import com.sckw.slope.detection.dao.tdengine.SlopeDataMapper;
-import com.sckw.slope.detection.model.dos.mysql.KwsDevice;
 import com.sckw.slope.detection.model.dos.mysql.KwsReportData;
 import com.sckw.slope.detection.model.dos.mysql.KwsReportData;
 import com.sckw.slope.detection.model.dos.mysql.KwsReportTemplate;
 import com.sckw.slope.detection.model.dos.mysql.KwsReportTemplate;
 import com.sckw.slope.detection.model.dos.tdengine.SlopeData;
 import com.sckw.slope.detection.model.dos.tdengine.SlopeData;
-import com.sckw.slope.detection.model.vo.DeviceIntegrationVo;
 import com.sckw.slope.detection.model.vo.DeviceVo;
 import com.sckw.slope.detection.model.vo.DeviceVo;
 import com.sckw.slope.detection.model.vo.excel.TaskReportExportVO;
 import com.sckw.slope.detection.model.vo.excel.TaskReportExportVO;
 import com.sckw.slope.detection.service.CommonService;
 import com.sckw.slope.detection.service.CommonService;
 import jakarta.annotation.Resource;
 import jakarta.annotation.Resource;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.EnableScheduling;
-import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Component;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.CollectionUtils;
 
 
 import java.io.IOException;
 import java.io.IOException;
 import java.math.BigDecimal;
 import java.math.BigDecimal;
-import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URL;
 import java.net.URLConnection;
 import java.net.URLConnection;
 import java.security.MessageDigest;
 import java.security.MessageDigest;
@@ -146,7 +140,8 @@ public class ReportTemplateTaskService {
             report.setCompanyId(kwsReportTemplate.getCompanyId());
             report.setCompanyId(kwsReportTemplate.getCompanyId());
             report.setTemplateId(kwsReportTemplate.getId());
             report.setTemplateId(kwsReportTemplate.getId());
             report.setProjectId(Long.parseLong(kwsReportTemplate.getProjectId()));
             report.setProjectId(Long.parseLong(kwsReportTemplate.getProjectId()));
-            report.setFileSize(new BigDecimal(fileSize));
+            BigDecimal fileSizeNumber = FileUtils.getFileSize(fileSize, "MB");
+            report.setFileSize(fileSizeNumber);
             report.setFileUrl(filePath);
             report.setFileUrl(filePath);
             report.setId(id);
             report.setId(id);
             report.setCreateTime(now);
             report.setCreateTime(now);