Commit f93069a0 authored by honghy's avatar honghy

海运已装单添加底色

parent 9af4107e
package cn.iocoder.yudao.module.shipment.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 报关方式枚举
*
* @author jayden
*/
@Getter
@AllArgsConstructor
public enum CustomsTypeEnum {
CUSTOMS_TYPE_1("我司全代", 1),
CUSTOMS_TYPE_2("自单代报", 2),
CUSTOMS_TYPE_3("混合报关", 3);
private final String name;
private final Integer value;
}
package cn.iocoder.yudao.module.shipment.utils;
import cn.iocoder.yudao.module.shipment.dto.AirLoadDto;
import cn.iocoder.yudao.module.shipment.dto.LoadDto;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.Head;
import com.alibaba.excel.write.merge.AbstractMergeStrategy;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Sheet;
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
import com.alibaba.excel.write.metadata.holder.WriteTableHolder;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.springframework.util.CollectionUtils;
......@@ -41,14 +42,33 @@ public class CustomLoadMergeStrategyNew extends AbstractMergeStrategy {
// 需要开始合并单元格的首行index
private Integer rowIndex;
private List<Integer> colorRowList;
private Map<String,Integer> colorMap;
// exportDataList为待合并目标列的值 partMerge为另外一种合并方式计算好的合并行数,mergeType 合并类型 1为订单维度合并 2为入仓记录维度的合并
public CustomLoadMergeStrategyNew(List<LoadDto> exportDataList, List<Integer> partMergeList, Integer targetColumnIndex, int mergeType) {
public CustomLoadMergeStrategyNew(List<LoadDto> exportDataList, List<Integer> partMergeList, Integer targetColumnIndex, int mergeType,List<Integer> colorRowList, Map<String,Integer> colorMap) {
this.exportFieldGroupCountList = getGroupCountList(exportDataList,targetColumnIndex);
this.partMergeList = partMergeList;
this.mergeType = mergeType;
this.targetColumnIndex = targetColumnIndex;
this.colorRowList = colorRowList;
this.colorMap = colorMap;
}
@Override
public void afterCellDispose(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, List<CellData> cellDataList, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) {
Workbook workbook = writeSheetHolder.getSheet().getWorkbook();
if (colorRowList.contains(cell.getRowIndex()) && cell.getColumnIndex() == targetColumnIndex) {
CellStyle cellStyle = workbook.createCellStyle();
cellStyle.setFillForegroundColor(IndexedColors.fromInt(colorMap.get(String.valueOf(cell.getRowIndex()))).index);
cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
cell.setCellStyle(cellStyle);
}
if (!isHead) {
this.merge(writeSheetHolder.getSheet(), cell, head, relativeRowIndex);
}
}
@Override
protected void merge(Sheet sheet, Cell cell, Head head, Integer relativeRowIndex) {
......@@ -56,6 +76,7 @@ public class CustomLoadMergeStrategyNew extends AbstractMergeStrategy {
if (null == rowIndex) {
rowIndex = cell.getRowIndex();
}
// 仅从首行以及目标列的单元格开始合并,忽略其他
if (cell.getRowIndex() == rowIndex && cell.getColumnIndex() == targetColumnIndex ) {
if (mergeType == 1) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment