diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/poi/excel/handler/CustomerTitleHandler.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/poi/excel/handler/CustomerTitleHandler.java new file mode 100644 index 0000000000..fe575e54b8 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/poi/excel/handler/CustomerTitleHandler.java @@ -0,0 +1,61 @@ +package com.epmet.commons.tools.utils.poi.excel.handler; + +import com.alibaba.excel.metadata.Head; +import com.alibaba.excel.metadata.data.CellData; +import com.alibaba.excel.metadata.data.WriteCellData; +import com.alibaba.excel.write.handler.CellWriteHandler; +import com.alibaba.excel.write.metadata.holder.WriteSheetHolder; +import com.alibaba.excel.write.metadata.holder.WriteTableHolder; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellType; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.util.CellRangeAddress; +import org.springframework.util.PropertyPlaceholderHelper; + +import java.util.List; +import java.util.Properties; + +/** + * desc:标头策略 + * + */ +public class CustomerTitleHandler implements CellWriteHandler { + private String title = "xixihaha"; + PropertyPlaceholderHelper placeholderHelper = new PropertyPlaceholderHelper("${", "}"); + public CustomerTitleHandler(String title) { + this.title = title; + } + /*public CustomerTitleHandler(String title) { + this.title = "nihao s"; + }*/ + @Override + public void beforeCellCreate(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder,Row row, Head head, Integer integer, Integer integer1, Boolean aBoolean) { + if (head != null) { + List headNameList = head.getHeadNameList(); + if (CollectionUtils.isNotEmpty(headNameList)) { + Properties properties = new Properties(); + properties.setProperty("title", title); + headNameList.set(1, placeholderHelper.replacePlaceholders(headNameList.get(1), properties)); + } + } + } + @Override + public void afterCellCreate(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, + Cell cell, Head head, Integer integer, Boolean aBoolean) { + + } + + @Override + public void afterCellDataConverted(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, + WriteCellData cellData, Cell cell, Head head, Integer integer, Boolean aBoolean) { + + } + + @Override + public void afterCellDispose(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, + List> list, Cell cell, Head head, Integer integer, Boolean aBoolean) { + + } +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcollect/result/HistoryScoreDetailResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcollect/result/HistoryScoreDetailResultDTO.java index 35981cc764..546ac9c4e6 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcollect/result/HistoryScoreDetailResultDTO.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcollect/result/HistoryScoreDetailResultDTO.java @@ -44,6 +44,11 @@ public class HistoryScoreDetailResultDTO implements Serializable { */ private Date endTime; + /** + * 时间区间 + */ + private String time; + /** * 发布时间 */ diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenPyHistoryScoreController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenPyHistoryScoreController.java index db203c81c9..56a1a2f853 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenPyHistoryScoreController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenPyHistoryScoreController.java @@ -2,6 +2,7 @@ package com.epmet.controller; import com.alibaba.excel.EasyExcel; import com.alibaba.excel.ExcelWriter; +import com.alibaba.excel.support.ExcelTypeEnum; import com.alibaba.excel.write.metadata.WriteSheet; import com.alibaba.fastjson.JSON; import com.epmet.commons.tools.annotation.LoginUser; @@ -111,8 +112,8 @@ public class ScreenPyHistoryScoreController { formDTO.setPageSize(NumConstant.FIVE_HUNDRED); try { String fileName = "历史得分" + DateUtils.format(new Date()) + ".xlsx"; - excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel(fileName, response), HistoryScoreDetailExcel.class).build(); - //String title= "11月-12月"; + excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel(fileName, response), HistoryScoreDetailExcel.class).excelType(ExcelTypeEnum.XLSX).build(); + PageData data = null; List list = null; do { @@ -120,9 +121,8 @@ public class ScreenPyHistoryScoreController { for (HistoryScoreDetailResultDTO d : data.getList()){ list = ConvertUtils.sourceToTarget(d.getDetailList(), HistoryScoreDetailExcel.class); - //一跳一条记录一个sheet页 - WriteSheet writeSheet = EasyExcel.writerSheet(d.getTitle()).registerWriteHandler(new FreezeAndFilter()).build(); - //WriteSheet writeSheet = EasyExcel.writerSheet(d.getTitle()).registerWriteHandler(new CustomerTitleHandler(title)).build(); + //一条主表记录一个sheet页 + WriteSheet writeSheet = EasyExcel.writerSheet(d.getTitle()).registerWriteHandler(new CustomerTitleHandler(d.getTime())).build(); excelWriter.write(list, writeSheet); } formDTO.setPageNo(formDTO.getPageNo() + NumConstant.ONE); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/excel/HistoryScoreDetailExcel.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/excel/HistoryScoreDetailExcel.java index c4e519cd00..6ed3d58446 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/excel/HistoryScoreDetailExcel.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/excel/HistoryScoreDetailExcel.java @@ -2,6 +2,7 @@ package com.epmet.excel; import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.write.style.ColumnWidth; +import com.alibaba.excel.annotation.write.style.ContentRowHeight; import com.alibaba.excel.annotation.write.style.HeadStyle; import com.alibaba.excel.enums.poi.FillPatternTypeEnum; import lombok.Data; @@ -19,35 +20,44 @@ import java.math.BigDecimal; public class HistoryScoreDetailExcel implements Serializable { private static final long serialVersionUID = -12110233388005838L; - @ExcelProperty(value = "下级单位") + //@ExcelProperty(value = "下级单位") + @ExcelProperty(value = {"平阴县街道(镇)政法能力得分排行", "${title}", "下级单位"}) @ColumnWidth(15) + @HeadStyle(fillPatternType = FillPatternTypeEnum.SOLID_FOREGROUND, fillForegroundColor = 44) private String agencyName; - @ExcelProperty(value = "网格活跃度") + //@ExcelProperty(value = "网格活跃度") + @ExcelProperty(value = {"平阴县街道(镇)政法能力得分排行", "${title}", "网格活跃度"}) @ColumnWidth(15) private BigDecimal wghyd; - @ExcelProperty(value = "事件赋值得分") + //@ExcelProperty(value = "事件赋值得分") + @ExcelProperty(value = {"平阴县街道(镇)政法能力得分排行", "${title}", "事件赋值得分"}) @ColumnWidth(20) private BigDecimal sjff; - @ExcelProperty(value = "雪亮工程") + //@ExcelProperty(value = "雪亮工程") + @ExcelProperty(value = {"平阴县街道(镇)政法能力得分排行", "${title}", "雪亮工程"}) @ColumnWidth(15) private BigDecimal xlgc; - @ExcelProperty(value = "日核周调") + //@ExcelProperty(value = "日核周调") + @ExcelProperty(value = {"平阴县街道(镇)政法能力得分排行", "${title}", "日核周调"}) @ColumnWidth(15) private BigDecimal rhzt; - @ExcelProperty(value = "亮点工作") + //@ExcelProperty(value = "亮点工作") + @ExcelProperty(value = {"平阴县街道(镇)政法能力得分排行", "${title}", "亮点工作"}) @ColumnWidth(15) private BigDecimal ldgz; - @ExcelProperty(value = "其他工作") + //@ExcelProperty(value = "其他工作") + @ExcelProperty(value = {"平阴县街道(镇)政法能力得分排行", "${title}", "其他工作"}) @ColumnWidth(15) private BigDecimal qtgz; - @ExcelProperty(value = "能力得分") + //@ExcelProperty(value = "能力得分") + @ExcelProperty(value = {"平阴县街道(镇)政法能力得分排行", "${title}", "能力得分"}) @ColumnWidth(15) private BigDecimal nldf; diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/ScreenPyHistoryScoreDetailDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/ScreenPyHistoryScoreDetailDao.xml index 2f7462a6d4..bd238aabfe 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/ScreenPyHistoryScoreDetailDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/ScreenPyHistoryScoreDetailDao.xml @@ -18,13 +18,15 @@ +