Browse Source

导出

feature/evaluate
sunyuchao 3 years ago
parent
commit
4446205167
  1. 61
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/poi/excel/handler/CustomerTitleHandler.java
  2. 5
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcollect/result/HistoryScoreDetailResultDTO.java
  3. 10
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenPyHistoryScoreController.java
  4. 26
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/excel/HistoryScoreDetailExcel.java
  5. 4
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/ScreenPyHistoryScoreDetailDao.xml

61
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<String> 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<WriteCellData<?>> list, Cell cell, Head head, Integer integer, Boolean aBoolean) {
}
}

5
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 Date endTime;
/**
* 时间区间
*/
private String time;
/** /**
* 发布时间 * 发布时间
*/ */

10
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.EasyExcel;
import com.alibaba.excel.ExcelWriter; import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.support.ExcelTypeEnum;
import com.alibaba.excel.write.metadata.WriteSheet; import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.annotation.LoginUser;
@ -111,8 +112,8 @@ public class ScreenPyHistoryScoreController {
formDTO.setPageSize(NumConstant.FIVE_HUNDRED); formDTO.setPageSize(NumConstant.FIVE_HUNDRED);
try { try {
String fileName = "历史得分" + DateUtils.format(new Date()) + ".xlsx"; String fileName = "历史得分" + DateUtils.format(new Date()) + ".xlsx";
excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel(fileName, response), HistoryScoreDetailExcel.class).build(); excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel(fileName, response), HistoryScoreDetailExcel.class).excelType(ExcelTypeEnum.XLSX).build();
//String title= "11月-12月";
PageData<HistoryScoreDetailResultDTO> data = null; PageData<HistoryScoreDetailResultDTO> data = null;
List<HistoryScoreDetailExcel> list = null; List<HistoryScoreDetailExcel> list = null;
do { do {
@ -120,9 +121,8 @@ public class ScreenPyHistoryScoreController {
for (HistoryScoreDetailResultDTO d : data.getList()){ for (HistoryScoreDetailResultDTO d : data.getList()){
list = ConvertUtils.sourceToTarget(d.getDetailList(), HistoryScoreDetailExcel.class); list = ConvertUtils.sourceToTarget(d.getDetailList(), HistoryScoreDetailExcel.class);
//一跳一条记录一个sheet页 //一条主表记录一个sheet页
WriteSheet writeSheet = EasyExcel.writerSheet(d.getTitle()).registerWriteHandler(new FreezeAndFilter()).build(); WriteSheet writeSheet = EasyExcel.writerSheet(d.getTitle()).registerWriteHandler(new CustomerTitleHandler(d.getTime())).build();
//WriteSheet writeSheet = EasyExcel.writerSheet(d.getTitle()).registerWriteHandler(new CustomerTitleHandler(title)).build();
excelWriter.write(list, writeSheet); excelWriter.write(list, writeSheet);
} }
formDTO.setPageNo(formDTO.getPageNo() + NumConstant.ONE); formDTO.setPageNo(formDTO.getPageNo() + NumConstant.ONE);

26
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.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth; 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.annotation.write.style.HeadStyle;
import com.alibaba.excel.enums.poi.FillPatternTypeEnum; import com.alibaba.excel.enums.poi.FillPatternTypeEnum;
import lombok.Data; import lombok.Data;
@ -19,35 +20,44 @@ import java.math.BigDecimal;
public class HistoryScoreDetailExcel implements Serializable { public class HistoryScoreDetailExcel implements Serializable {
private static final long serialVersionUID = -12110233388005838L; private static final long serialVersionUID = -12110233388005838L;
@ExcelProperty(value = "下级单位") //@ExcelProperty(value = "下级单位")
@ExcelProperty(value = {"平阴县街道(镇)政法能力得分排行", "${title}", "下级单位"})
@ColumnWidth(15) @ColumnWidth(15)
@HeadStyle(fillPatternType = FillPatternTypeEnum.SOLID_FOREGROUND, fillForegroundColor = 44)
private String agencyName; private String agencyName;
@ExcelProperty(value = "网格活跃度") //@ExcelProperty(value = "网格活跃度")
@ExcelProperty(value = {"平阴县街道(镇)政法能力得分排行", "${title}", "网格活跃度"})
@ColumnWidth(15) @ColumnWidth(15)
private BigDecimal wghyd; private BigDecimal wghyd;
@ExcelProperty(value = "事件赋值得分") //@ExcelProperty(value = "事件赋值得分")
@ExcelProperty(value = {"平阴县街道(镇)政法能力得分排行", "${title}", "事件赋值得分"})
@ColumnWidth(20) @ColumnWidth(20)
private BigDecimal sjff; private BigDecimal sjff;
@ExcelProperty(value = "雪亮工程") //@ExcelProperty(value = "雪亮工程")
@ExcelProperty(value = {"平阴县街道(镇)政法能力得分排行", "${title}", "雪亮工程"})
@ColumnWidth(15) @ColumnWidth(15)
private BigDecimal xlgc; private BigDecimal xlgc;
@ExcelProperty(value = "日核周调") //@ExcelProperty(value = "日核周调")
@ExcelProperty(value = {"平阴县街道(镇)政法能力得分排行", "${title}", "日核周调"})
@ColumnWidth(15) @ColumnWidth(15)
private BigDecimal rhzt; private BigDecimal rhzt;
@ExcelProperty(value = "亮点工作") //@ExcelProperty(value = "亮点工作")
@ExcelProperty(value = {"平阴县街道(镇)政法能力得分排行", "${title}", "亮点工作"})
@ColumnWidth(15) @ColumnWidth(15)
private BigDecimal ldgz; private BigDecimal ldgz;
@ExcelProperty(value = "其他工作") //@ExcelProperty(value = "其他工作")
@ExcelProperty(value = {"平阴县街道(镇)政法能力得分排行", "${title}", "其他工作"})
@ColumnWidth(15) @ColumnWidth(15)
private BigDecimal qtgz; private BigDecimal qtgz;
@ExcelProperty(value = "能力得分") //@ExcelProperty(value = "能力得分")
@ExcelProperty(value = {"平阴县街道(镇)政法能力得分排行", "${title}", "能力得分"})
@ColumnWidth(15) @ColumnWidth(15)
private BigDecimal nldf; private BigDecimal nldf;

4
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/ScreenPyHistoryScoreDetailDao.xml

@ -18,13 +18,15 @@
<resultMap id="selectCommunitySelfOrganizationListMap" type="com.epmet.dto.indexcollect.result.HistoryScoreDetailResultDTO"> <resultMap id="selectCommunitySelfOrganizationListMap" type="com.epmet.dto.indexcollect.result.HistoryScoreDetailResultDTO">
<result property="id" column="id"/> <result property="id" column="id"/>
<result property="title" column="title"/> <result property="title" column="title"/>
<result property="time" column="time"/>
<collection property="detailList" ofType="com.epmet.dto.indexcollect.result.HistoryScoreDetailResultDTO$Detail" <collection property="detailList" ofType="com.epmet.dto.indexcollect.result.HistoryScoreDetailResultDTO$Detail"
column="id" select="selectPerson"></collection> column="id" select="selectPerson"></collection>
</resultMap> </resultMap>
<select id="selectScoreDetailList" resultMap="selectCommunitySelfOrganizationListMap" parameterType="com.epmet.dto.indexcollect.form.HistoryScoreListFormDTO"> <select id="selectScoreDetailList" resultMap="selectCommunitySelfOrganizationListMap" parameterType="com.epmet.dto.indexcollect.form.HistoryScoreListFormDTO">
SELECT SELECT
id AS id, id AS id,
title AS title title AS title,
CONCAT(DATE_FORMAT(start_time,'%Y年%m月%d日'), '-', DATE_FORMAT(end_time, '%Y年%m月%d日')) `time`
FROM screen_py_history_score FROM screen_py_history_score
WHERE WHERE
del_flag = 0 del_flag = 0

Loading…
Cancel
Save