From 94e5f420b8559ad63dec70d3bc9b3fd7d3666a75 Mon Sep 17 00:00:00 2001 From: xiezw Date: Thu, 26 Sep 2024 17:01:33 +0800 Subject: [PATCH] =?UTF-8?q?20240926-=E7=94=A8=E9=87=8F=E5=92=8C=E8=B4=B9?= =?UTF-8?q?=E7=94=A8=E6=8A=A5=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../peakvalley/controller/PeakValleyController.java | 6 ++++-- .../excel/PricePeakValleyDosageUsageAndCostExcel.java | 9 +++++---- .../excel/PricePeakValleyUsageAndCostExcel.java | 2 +- .../peakvalley/service/impl/PeakValleyServiceImpl.java | 4 ++-- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/modules/report-analysis/src/main/java/com/thing/carbon/peakvalley/controller/PeakValleyController.java b/modules/report-analysis/src/main/java/com/thing/carbon/peakvalley/controller/PeakValleyController.java index 6f74628..6bb6cb1 100644 --- a/modules/report-analysis/src/main/java/com/thing/carbon/peakvalley/controller/PeakValleyController.java +++ b/modules/report-analysis/src/main/java/com/thing/carbon/peakvalley/controller/PeakValleyController.java @@ -8,6 +8,7 @@ import com.thing.carbon.energyrepory.dto.PeakValleyDosageReq; import com.thing.carbon.peakvalley.dto.*; import com.thing.carbon.peakvalley.excel.*; import com.thing.carbon.peakvalley.service.PeakValleyService; +import com.thing.common.core.enumeration.AttributeTypeEnum; import com.thing.common.core.utils.excel.ExcelUtils; import com.thing.common.core.utils.export.ExcelEntityGenerator; import com.thing.common.core.web.response.Result; @@ -200,10 +201,11 @@ public class PeakValleyController { List> dataCollection = ExcelEntityGenerator.generateDataCollection(new ArrayList<>(excelDataList)); // 计算合并区域 List regions = PricePeakValleyUsageAndCostExcel.calculateMergeRegion(excelDataList); - Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(null, "峰平谷尖用量和费用报表"), excelExportEntities, dataCollection); + + Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(null, param.getDateStr()+"能源用量和费用报表"), excelExportEntities, dataCollection); regions.forEach(workbook.getSheetAt(0)::addMergedRegion); // 导出 - ExcelUtils.downLoadExcel("峰平谷尖用量和费用报表.xls", response, workbook); + ExcelUtils.downLoadExcel(param.getDateStr()+"能源用量和费用报表.xls", response, workbook); } } diff --git a/modules/report-analysis/src/main/java/com/thing/carbon/peakvalley/excel/PricePeakValleyDosageUsageAndCostExcel.java b/modules/report-analysis/src/main/java/com/thing/carbon/peakvalley/excel/PricePeakValleyDosageUsageAndCostExcel.java index 870c916..8ff0d27 100644 --- a/modules/report-analysis/src/main/java/com/thing/carbon/peakvalley/excel/PricePeakValleyDosageUsageAndCostExcel.java +++ b/modules/report-analysis/src/main/java/com/thing/carbon/peakvalley/excel/PricePeakValleyDosageUsageAndCostExcel.java @@ -81,9 +81,10 @@ public class PricePeakValleyDosageUsageAndCostExcel { excel.setHh(hh); excel.setDd(dd); } - excel.setVal1(dosageReq.getDosage()); - excel.setVal2(dosageReq.getTotalPrice()); - excel.setVal3(dosageReq.getDosageRatio()); + excel.setVal1(Objects.nonNull(dosageReq.getDosage()) ? dosageReq.getDosage().setScale(2,BigDecimal.ROUND_HALF_UP) : null ); + excel.setVal2(Objects.nonNull(dosageReq.getTotalPrice()) ? dosageReq.getTotalPrice().setScale(2,BigDecimal.ROUND_HALF_UP) : null ); + excel.setVal3(Objects.nonNull(dosageReq.getDosageRatio()) ? dosageReq.getDosageRatio().setScale(2,BigDecimal.ROUND_HALF_UP) : null ); + excel.setVal1Export(Objects.nonNull(excel.getVal1()) ? excel.getVal1().toString() : "--"); excel.setVal2Export(Objects.nonNull(excel.getVal2()) ? excel.getVal2().toString() : "--"); excel.setVal3Export(Objects.nonNull(excel.getVal3()) ? excel.getVal3().toString() : "--"); @@ -186,7 +187,7 @@ public class PricePeakValleyDosageUsageAndCostExcel { } private String getTitle3(){ - return "用量占比"; + return "用量占比(%)"; } private String getTitle(){ diff --git a/modules/report-analysis/src/main/java/com/thing/carbon/peakvalley/excel/PricePeakValleyUsageAndCostExcel.java b/modules/report-analysis/src/main/java/com/thing/carbon/peakvalley/excel/PricePeakValleyUsageAndCostExcel.java index 62de0a4..3a1fda6 100644 --- a/modules/report-analysis/src/main/java/com/thing/carbon/peakvalley/excel/PricePeakValleyUsageAndCostExcel.java +++ b/modules/report-analysis/src/main/java/com/thing/carbon/peakvalley/excel/PricePeakValleyUsageAndCostExcel.java @@ -30,7 +30,7 @@ public class PricePeakValleyUsageAndCostExcel { private String allDosage; @CustomExcel(name = "总价",orderNum=5) private String totalPrice; - @CustomExcel(name = "用量占比",orderNum=6) + @CustomExcel(name = "用量占比(%)",orderNum=6) private String realityRatio; @CustomExcelCollection private List peakValleyDosageReqs; diff --git a/modules/report-analysis/src/main/java/com/thing/carbon/peakvalley/service/impl/PeakValleyServiceImpl.java b/modules/report-analysis/src/main/java/com/thing/carbon/peakvalley/service/impl/PeakValleyServiceImpl.java index e350bee..ee4ea13 100644 --- a/modules/report-analysis/src/main/java/com/thing/carbon/peakvalley/service/impl/PeakValleyServiceImpl.java +++ b/modules/report-analysis/src/main/java/com/thing/carbon/peakvalley/service/impl/PeakValleyServiceImpl.java @@ -836,10 +836,10 @@ public class PeakValleyServiceImpl implements PeakValleyService { } } if (t.getDosage()!=null &&totalUsage!=null && totalUsage.compareTo(BigDecimal.ZERO)!=0 ){ - t.setDosageRatio(t.getDosage().divide(totalUsage,2,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100))); + t.setDosageRatio(t.getDosage().divide(totalUsage,4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100))); } if (t.getTotalPrice()!=null &&totalCost!=null && totalCost.compareTo(BigDecimal.ZERO)!=0 ){ - t.setTotalPriceRatio(t.getTotalPrice().divide(totalCost,2,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100))); + t.setTotalPriceRatio(t.getTotalPrice().divide(totalCost,4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100))); } }); if(dataType.equals("week")){