|
|
|
@ -2,7 +2,13 @@ package com.bweb.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.metadata.CellData; |
|
|
|
|
|
|
|
import com.alibaba.excel.metadata.Head; |
|
|
|
|
|
|
|
import com.alibaba.excel.write.handler.AbstractCellWriteHandler; |
|
|
|
|
|
|
|
import com.alibaba.excel.write.handler.CellWriteHandler; |
|
|
|
import com.alibaba.excel.write.metadata.fill.FillWrapper; |
|
|
|
import com.alibaba.excel.write.metadata.fill.FillWrapper; |
|
|
|
|
|
|
|
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder; |
|
|
|
|
|
|
|
import com.alibaba.excel.write.metadata.holder.WriteTableHolder; |
|
|
|
import com.alibaba.excel.write.metadata.style.WriteCellStyle; |
|
|
|
import com.alibaba.excel.write.metadata.style.WriteCellStyle; |
|
|
|
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy; |
|
|
|
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy; |
|
|
|
import com.alibaba.excel.write.style.column.SimpleColumnWidthStyleStrategy; |
|
|
|
import com.alibaba.excel.write.style.column.SimpleColumnWidthStyleStrategy; |
|
|
|
@ -18,9 +24,7 @@ import io.swagger.annotations.Api; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
import org.apache.commons.collections4.MapUtils; |
|
|
|
import org.apache.commons.collections4.MapUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.poi.ss.usermodel.HorizontalAlignment; |
|
|
|
import org.apache.poi.ss.usermodel.*; |
|
|
|
import org.apache.poi.ss.usermodel.IndexedColors; |
|
|
|
|
|
|
|
import org.apache.poi.ss.usermodel.VerticalAlignment; |
|
|
|
|
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.stereotype.Controller; |
|
|
|
import org.springframework.stereotype.Controller; |
|
|
|
@ -65,6 +69,7 @@ public class BsGasOrderCountController { |
|
|
|
HashMap<String,Object> mer = new HashMap<>(); |
|
|
|
HashMap<String,Object> mer = new HashMap<>(); |
|
|
|
mer.put("merNo", data.get("merNo")); |
|
|
|
mer.put("merNo", data.get("merNo")); |
|
|
|
mer.put("merName", data.get("merName")); |
|
|
|
mer.put("merName", data.get("merName")); |
|
|
|
|
|
|
|
mer.put("merStatus", data.get("merStatus")); |
|
|
|
merList.add(mer); |
|
|
|
merList.add(mer); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -153,6 +158,7 @@ public class BsGasOrderCountController { |
|
|
|
|
|
|
|
|
|
|
|
// 设置内容的策略
|
|
|
|
// 设置内容的策略
|
|
|
|
WriteCellStyle contentWriteCellStyle = ExcelUtil.getWriteCellStyle(); |
|
|
|
WriteCellStyle contentWriteCellStyle = ExcelUtil.getWriteCellStyle(); |
|
|
|
|
|
|
|
|
|
|
|
WriteCellStyle headWriteCellStyle = new WriteCellStyle(); |
|
|
|
WriteCellStyle headWriteCellStyle = new WriteCellStyle(); |
|
|
|
// 设置头部水平居中对齐
|
|
|
|
// 设置头部水平居中对齐
|
|
|
|
headWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER); |
|
|
|
headWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER); |
|
|
|
@ -164,6 +170,54 @@ public class BsGasOrderCountController { |
|
|
|
.head(getSaleSheetHeadList(startTime, dataList)) |
|
|
|
.head(getSaleSheetHeadList(startTime, dataList)) |
|
|
|
.registerWriteHandler(new SimpleColumnWidthStyleStrategy(20)) |
|
|
|
.registerWriteHandler(new SimpleColumnWidthStyleStrategy(20)) |
|
|
|
.registerWriteHandler(new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle)) |
|
|
|
.registerWriteHandler(new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle)) |
|
|
|
|
|
|
|
.registerWriteHandler(new CellWriteHandler() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void beforeCellCreate(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, Row row, Head head, Integer integer, Integer integer1, Boolean aBoolean) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void afterCellCreate(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, Cell cell, Head head, Integer integer, Boolean aBoolean) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void afterCellDataConverted(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, CellData cellData, Cell cell, Head head, Integer integer, Boolean aBoolean) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void afterCellDispose(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, List<CellData> list, Cell cell, Head head, Integer integer, Boolean aBoolean) { |
|
|
|
|
|
|
|
int rowIndex = cell.getRowIndex(); |
|
|
|
|
|
|
|
int columnIndex = cell.getColumnIndex(); |
|
|
|
|
|
|
|
Workbook workbook = writeSheetHolder.getSheet().getWorkbook(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (rowIndex > 1) { |
|
|
|
|
|
|
|
if (rowIndex <= merList.size()) { |
|
|
|
|
|
|
|
HashMap<String, Object> map = merList.get(rowIndex - 2); |
|
|
|
|
|
|
|
if (!map.isEmpty() && !map.get("merStatus").toString().equals("1")) { |
|
|
|
|
|
|
|
CellStyle oldCellStyle = cell.getCellStyle(); |
|
|
|
|
|
|
|
CellStyle newCellStyle = workbook.createCellStyle(); |
|
|
|
|
|
|
|
newCellStyle.cloneStyleFrom(oldCellStyle); |
|
|
|
|
|
|
|
newCellStyle.setFillForegroundColor(IndexedColors.YELLOW.getIndex()); |
|
|
|
|
|
|
|
newCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); |
|
|
|
|
|
|
|
cell.setCellStyle(newCellStyle); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (rowIndex > 1 && (columnIndex == 2 || columnIndex == 6 || columnIndex == 10 || columnIndex == 14 || columnIndex == 18)) { |
|
|
|
|
|
|
|
CellStyle oldCellStyle = cell.getCellStyle(); |
|
|
|
|
|
|
|
CellStyle newCellStyle = workbook.createCellStyle(); |
|
|
|
|
|
|
|
newCellStyle.cloneStyleFrom(oldCellStyle); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Font font = workbook.createFont(); |
|
|
|
|
|
|
|
font.setColor(IndexedColors.RED.index); |
|
|
|
|
|
|
|
newCellStyle.setFont(font); |
|
|
|
|
|
|
|
cell.setCellStyle(newCellStyle); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
.sheet("统计") |
|
|
|
.sheet("统计") |
|
|
|
.doWrite(excelDataList); |
|
|
|
.doWrite(excelDataList); |
|
|
|
return ResponseMsgUtil.success(path); |
|
|
|
return ResponseMsgUtil.success(path); |
|
|
|
|