Commit 09e16c02 authored by honghy's avatar honghy

空运已装单添加底色

parent c0e65d3b
...@@ -250,7 +250,7 @@ public class ShipmentLoadExcelExportListener2 { ...@@ -250,7 +250,7 @@ public class ShipmentLoadExcelExportListener2 {
if(orderInfo.getCustomsType()!=null){ if(orderInfo.getCustomsType()!=null){
preloadDto.setCustomsType(DictFrameworkUtils.getDictDataFromCache("customs_type",orderInfo.getCustomsType()+"").getLabel()); preloadDto.setCustomsType(DictFrameworkUtils.getDictDataFromCache("customs_type",orderInfo.getCustomsType()+"").getLabel());
if (CustomsTypeEnum.CUSTOMS_TYPE_3.getValue().equals(orderInfo.getCustomsType())){ if (CustomsTypeEnum.CUSTOMS_TYPE_3.getValue().equals(orderInfo.getCustomsType())){
Integer color = Integer.valueOf(IndexedColors.BLUE1.index); Integer color = Integer.valueOf(IndexedColors.ROYAL_BLUE.index);
if (prodAttrTag){ if (prodAttrTag){
color=Integer.valueOf(IndexedColors.ROYAL_BLUE.index); color=Integer.valueOf(IndexedColors.ROYAL_BLUE.index);
} }
......
package cn.iocoder.yudao.module.shipment.utils; package cn.iocoder.yudao.module.shipment.utils;
import cn.iocoder.yudao.module.shipment.dto.AirLoadDto; import cn.iocoder.yudao.module.shipment.dto.AirLoadDto;
import cn.iocoder.yudao.module.shipment.dto.PreloadDto; import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.Head; import com.alibaba.excel.metadata.Head;
import com.alibaba.excel.write.merge.AbstractMergeStrategy; import com.alibaba.excel.write.merge.AbstractMergeStrategy;
import org.apache.poi.ss.usermodel.Cell; import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
import org.apache.poi.ss.usermodel.Sheet; import com.alibaba.excel.write.metadata.holder.WriteTableHolder;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.CellRangeAddress;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
...@@ -34,8 +35,6 @@ public class CustomAirLoadMergeStrategyNew extends AbstractMergeStrategy { ...@@ -34,8 +35,6 @@ public class CustomAirLoadMergeStrategyNew extends AbstractMergeStrategy {
private List<Integer> mergePkgCountList; private List<Integer> mergePkgCountList;
private int mergeType; private int mergeType;
/** /**
...@@ -46,14 +45,31 @@ public class CustomAirLoadMergeStrategyNew extends AbstractMergeStrategy { ...@@ -46,14 +45,31 @@ public class CustomAirLoadMergeStrategyNew extends AbstractMergeStrategy {
// 需要开始合并单元格的首行index // 需要开始合并单元格的首行index
private Integer rowIndex; private Integer rowIndex;
private Map<String,Integer> colorMap;
// exportDataList为待合并目标列的值 partMerge为另外一种合并方式计算好的合并行数,mergeType 合并类型 1为订单维度合并 2为入仓记录维度的合并 // exportDataList为待合并目标列的值 partMerge为另外一种合并方式计算好的合并行数,mergeType 合并类型 1为订单维度合并 2为入仓记录维度的合并
public CustomAirLoadMergeStrategyNew(List<AirLoadDto> exportDataList, List<Integer> partMergeList, List<Integer> colorRowList,List<Integer> mergePkgCountList, Integer targetColumnIndex, int mergeType) { public CustomAirLoadMergeStrategyNew(List<AirLoadDto> exportDataList, List<Integer> partMergeList, List<Integer> colorRowList,List<Integer> mergePkgCountList, Integer targetColumnIndex, int mergeType, Map<String,Integer> colorMap) {
this.exportFieldGroupCountList = getGroupCountList(exportDataList,targetColumnIndex); this.exportFieldGroupCountList = getGroupCountList(exportDataList,targetColumnIndex);
this.partMergeList = partMergeList; this.partMergeList = partMergeList;
this.mergeType = mergeType; this.mergeType = mergeType;
this.targetColumnIndex = targetColumnIndex; this.targetColumnIndex = targetColumnIndex;
this.colorRowList = colorRowList; this.colorRowList = colorRowList;
this.mergePkgCountList = mergePkgCountList; this.mergePkgCountList = mergePkgCountList;
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);
}
} }
......
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