Browse Source

20240926-用量和费用报表

thing_master
xiezw 1 year ago
parent
commit
94e5f420b8
  1. 6
      modules/report-analysis/src/main/java/com/thing/carbon/peakvalley/controller/PeakValleyController.java
  2. 9
      modules/report-analysis/src/main/java/com/thing/carbon/peakvalley/excel/PricePeakValleyDosageUsageAndCostExcel.java
  3. 2
      modules/report-analysis/src/main/java/com/thing/carbon/peakvalley/excel/PricePeakValleyUsageAndCostExcel.java
  4. 4
      modules/report-analysis/src/main/java/com/thing/carbon/peakvalley/service/impl/PeakValleyServiceImpl.java

6
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<Map<String, Object>> dataCollection = ExcelEntityGenerator.generateDataCollection(new ArrayList<>(excelDataList));
// 计算合并区域
List<CellRangeAddress> 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);
}
}

9
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(){

2
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<PricePeakValleyDosageUsageAndCostExcel> peakValleyDosageReqs;

4
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")){

Loading…
Cancel
Save