소스 검색

报表展示计算

lengfaqiang 2 년 전
부모
커밋
a67dcc748d

+ 7 - 2
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ReportService.java

@@ -8,6 +8,7 @@ import com.sckw.core.model.constant.NumberConstant;
 import com.sckw.core.model.enums.MessageLogEnum;
 import com.sckw.core.model.enums.ReportTypeEnum;
 import com.sckw.core.model.page.PageRes;
+import com.sckw.core.utils.FileUtils;
 import com.sckw.core.utils.StringUtils;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.slope.detection.dao.mysql.KwsProjectMapper;
@@ -25,6 +26,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
+import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -61,7 +64,7 @@ public class ReportService {
             return PageRes.build(info, list);
         }
         List<String> collect = list.stream().map(ReportStatementVO::getProjectId).distinct().collect(Collectors.toList());
-        List<KwsProject> kwsProjects = projectMapper.selectListData(collect,null);
+        List<KwsProject> kwsProjects = projectMapper.selectListData(collect, null);
         Map<Long, String> map = new HashMap<>();
         if (!CollectionUtils.isEmpty(kwsProjects)) {
             map = kwsProjects.stream().collect(Collectors.toMap(KwsProject::getId, KwsProject::getName));
@@ -69,7 +72,9 @@ public class ReportService {
         for (ReportStatementVO reportStatementVO : list) {
             reportStatementVO.setReportType(ReportTypeEnum.getDescription(reportStatementVO.getReportType()));
             reportStatementVO.setProjectName(map.get(Long.parseLong(reportStatementVO.getProjectId())));
-            reportStatementVO.setFileSize(reportStatementVO.getFileSize()+"MB");
+            BigDecimal fileSizeNumber = FileUtils.getFileSize(new BigDecimal(reportStatementVO.getFileSize()).intValue(), "KB");
+//            reportStatementVO.setFileSize(reportStatementVO.getFileSize());
+            reportStatementVO.setFileSize(fileSizeNumber.setScale(2, RoundingMode.HALF_UP)+"KB");
         }
         return PageRes.build(info, list);
     }

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

@@ -2,6 +2,7 @@ package com.sckw.slope.detection.service;
 
 import com.alibaba.fastjson2.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.sckw.core.exception.BusinessException;
@@ -360,8 +361,8 @@ public class ThresholdService {
                 kwsThreshold.setItemName(itemName);
                 kwsThreshold.setMountainId(headerData.getMountainId());
                 //计算设置状态  便于select
-                String setting = checkAndSettings(configurationDTO, headerData);
-                kwsThreshold.setSetting(setting);
+//                String setting = checkAndSettings(configurationDTO, headerData);
+//                kwsThreshold.setSetting(setting);
                 kwsThreshold.setLevel(Integer.valueOf(thresholdBean.getLevel()));
                 kwsThreshold.setMax(String.valueOf(thresholdBean.getMax()));
                 kwsThreshold.setMin(String.valueOf(thresholdBean.getMin()));
@@ -378,8 +379,8 @@ public class ThresholdService {
             } else {
                 selected.setLevel(Integer.valueOf(thresholdBean.getLevel()));
                 //计算设置状态  便于select
-                String setting = checkAndSettings(configurationDTO, headerData);
-                selected.setSetting(setting);
+//                String setting = checkAndSettings(configurationDTO, headerData);
+//                selected.setSetting(setting);
                 selected.setMax(String.valueOf(thresholdBean.getMax()));
                 selected.setMin(String.valueOf(thresholdBean.getMin()));
                 selected.setPhones(phones);
@@ -390,6 +391,12 @@ public class ThresholdService {
                 thresholdRepository.saveOrUpdate(selected);
             }
         }
+        //计算设置状态  便于select
+        String setting = checkAndSettings(configurationDTO, headerData);
+        thresholdMapper.update(null,
+                new LambdaUpdateWrapper<KwsThreshold>()
+                .eq(KwsThreshold::getDeviceId,configurationDTO.getDeviceId())
+                        .set(KwsThreshold::getSetting,setting));
         Map<String, SystemDict> dict = commonService.getDictByDictCode(DictEnum.MODEL_PART);
         KwsProject project = projectMapper.selectOne(new LambdaQueryWrapper<KwsProject>()
                 .eq(KwsProject::getId, Long.parseLong(projectId)));

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

@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.sckw.core.model.constant.NumberConstant;
 import com.sckw.core.model.enums.DictItemEnum;
 import com.sckw.core.model.enums.ReportTypeEnum;
-import com.sckw.core.utils.FileUtils;
 import com.sckw.core.utils.IdWorker;
 import com.sckw.excel.annotation.ExcelContext;
 import com.sckw.excel.utils.ExcelUtil;
@@ -140,8 +139,7 @@ public class ReportTemplateTaskService {
             report.setCompanyId(kwsReportTemplate.getCompanyId());
             report.setTemplateId(kwsReportTemplate.getId());
             report.setProjectId(Long.parseLong(kwsReportTemplate.getProjectId()));
-            BigDecimal fileSizeNumber = FileUtils.getFileSize(fileSize, "MB");
-            report.setFileSize(fileSizeNumber);
+            report.setFileSize(new BigDecimal(fileSize));
             report.setFileUrl(filePath);
             report.setId(id);
             report.setCreateTime(now);