Commit c8f909d3 authored by huyf's avatar huyf

海运应收汇总bug&海运已装单需求

parent e8820b96
...@@ -21,12 +21,18 @@ public class LoadDto { ...@@ -21,12 +21,18 @@ public class LoadDto {
@ExcelProperty("prodTitleZh") @ExcelProperty("prodTitleZh")
private String prodTitleZh; private String prodTitleZh;
@ExcelProperty("quantity")
private Integer quantity;
@ExcelProperty("brand") @ExcelProperty("brand")
private String brand; private String brand;
@ExcelProperty("productRecord") @ExcelProperty("productRecord")
private String productRecord; private String productRecord;
@ExcelProperty("prodAttr")
private String prodAttr;//特性
@ExcelProperty("sumNum") @ExcelProperty("sumNum")
private Integer sumNum; private Integer sumNum;
...@@ -45,6 +51,9 @@ public class LoadDto { ...@@ -45,6 +51,9 @@ public class LoadDto {
@ExcelProperty("material") @ExcelProperty("material")
private String material; private String material;
@ExcelProperty("usageIds")
private String usageIds;//用途
@ExcelProperty("merge") @ExcelProperty("merge")
private String merge; private String merge;
...@@ -57,7 +66,4 @@ public class LoadDto { ...@@ -57,7 +66,4 @@ public class LoadDto {
@ExcelProperty("worth") @ExcelProperty("worth")
private BigDecimal worth; private BigDecimal worth;
@ExcelProperty("quantity")
private Integer quantity;
} }
...@@ -470,9 +470,10 @@ public class ShipmentReceivableExcelExportListener2 { ...@@ -470,9 +470,10 @@ public class ShipmentReceivableExcelExportListener2 {
map.put("sumNum", orderInfo.getSumNum()); map.put("sumNum", orderInfo.getSumNum());
sum14 = sum14 + orderInfo.getSumNum(); sum14 = sum14 + orderInfo.getSumNum();
} }
map.put("sumVolume", orderInfo.getOrderItemVOList().stream().map(OrderItemBackVO::getChargeVolume).reduce(BigDecimal.ZERO,BigDecimal::add)); BigDecimal volume = orderInfo.getOrderItemVOList().stream().map(OrderItemBackVO::getChargeVolume).reduce(BigDecimal.ZERO, BigDecimal::add);
map.put("sumVolume", volume);
// map.put("sumVolume", orderInfo.getSumVolume()); // map.put("sumVolume", orderInfo.getSumVolume());
sum15 = sum15.add(orderInfo.getSumVolume()); sum15 = sum15.add(volume);
map.put("sumWeight", orderInfo.getSumWeight()); map.put("sumWeight", orderInfo.getSumWeight());
sum16 = sum16.add(orderInfo.getSumWeight()); sum16 = sum16.add(orderInfo.getSumWeight());
map.put("vWeight", orderInfo.getVWeight()); map.put("vWeight", orderInfo.getVWeight());
......
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.Head;
import com.alibaba.excel.write.merge.AbstractMergeStrategy;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.util.CellRangeAddress;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author huyufeng
* @date 2022/12/14
* @description 自定义单元格合并策略
*/
public class CustomLoadMergeStrategyNew extends AbstractMergeStrategy {
/**
* 分组,每几行合并一次
*/
private List<Integer> exportFieldGroupCountList;
private List<Integer> partMergeList;
private int mergeType;
/**
* 目标合并列index
*/
private Integer targetColumnIndex;
// 需要开始合并单元格的首行index
private Integer rowIndex;
// exportDataList为待合并目标列的值 partMerge为另外一种合并方式计算好的合并行数,mergeType 合并类型 1为订单维度合并 2为入仓记录维度的合并
public CustomLoadMergeStrategyNew(List<LoadDto> exportDataList, List<Integer> partMergeList, Integer targetColumnIndex, int mergeType) {
this.exportFieldGroupCountList = getGroupCountList(exportDataList,targetColumnIndex);
this.partMergeList = partMergeList;
this.mergeType = mergeType;
this.targetColumnIndex = targetColumnIndex;
}
@Override
protected void merge(Sheet sheet, Cell cell, Head head, Integer relativeRowIndex) {
if (null == rowIndex) {
rowIndex = cell.getRowIndex();
}
// 仅从首行以及目标列的单元格开始合并,忽略其他
if (cell.getRowIndex() == rowIndex && cell.getColumnIndex() == targetColumnIndex ) {
if (mergeType == 1) {
mergeGroupColumn(sheet,exportFieldGroupCountList);
} else if (mergeType == 2) {
mergeGroupColumn(sheet,partMergeList);
}
}
}
private void mergeGroupColumn(Sheet sheet,List<Integer> list) {
int rowCount = rowIndex;
for (Integer count : list) {
if (count == 1) {
rowCount += count;
continue;
}
// 合并单元格
CellRangeAddress cellRangeAddress = new CellRangeAddress(rowCount, rowCount + count - 1, targetColumnIndex, targetColumnIndex);
sheet.addMergedRegionUnsafe(cellRangeAddress);
rowCount += count;
}
}
// 该方法将目标列根据值是否相同连续可合并,存储可合并的行数
private List<Integer> getGroupCountList(List<LoadDto> exportDataList,Integer targetColumnIndex) {
if (CollectionUtils.isEmpty(exportDataList)) {
return new ArrayList<>();
}
List<Integer> groupCountList = new ArrayList<>();
int count = 1;
LinkedHashMap<String, List<LoadDto>> collect = exportDataList.stream().collect(Collectors.groupingBy(LoadDto::getId, LinkedHashMap::new, Collectors.toList()));
for (Map.Entry<String, List<LoadDto>> entry : collect.entrySet()) {
groupCountList.add(entry.getValue().size());
}
return groupCountList;
}
}
...@@ -282,9 +282,9 @@ public class DownloadLogServiceImpl extends AbstractService<DownloadLogMapper, D ...@@ -282,9 +282,9 @@ public class DownloadLogServiceImpl extends AbstractService<DownloadLogMapper, D
break; break;
//已装单导出 //已装单导出
case SHIPMENT_LOAD_EXCEL_EXPORT: case SHIPMENT_LOAD_EXCEL_EXPORT:
shipmentLoadExcelExportPushEvent(downloadLog); // shipmentLoadExcelExportPushEvent(downloadLog);
//总体切换 //总体切换
//shipmentLoadExcelExportPushEvent2(downloadLog); shipmentLoadExcelExportPushEvent2(downloadLog);
break; break;
//应收汇总导出修改导出Excel样式 //应收汇总导出修改导出Excel样式
case SHIPMENT_RECEIVABLE_EXCEL_EXPORT: case SHIPMENT_RECEIVABLE_EXCEL_EXPORT:
......
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