Commit 44b45a50 authored by liuzeheng's avatar liuzeheng

颜色标识

parent b99c08a3
......@@ -5,6 +5,7 @@ import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.apollo.core.event.export.ShipmentLoadExcelExportPushEvent;
import cn.iocoder.yudao.framework.apollo.core.event.export.ShipmentPreloadExcelExportPushEvent;
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
import cn.iocoder.yudao.framework.dict.core.util.DictFrameworkUtils;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
......@@ -20,7 +21,9 @@ import cn.iocoder.yudao.module.order.dal.dataobject.orderWarehouseIn.OrderWareho
import cn.iocoder.yudao.module.order.dto.OrderBackInfoDto;
import cn.iocoder.yudao.module.order.service.order.*;
import cn.iocoder.yudao.module.order.service.orderWarehouseIn.OrderWarehouseInService;
import cn.iocoder.yudao.module.order.vo.order.OrderWarehouseInDetailsVO;
import cn.iocoder.yudao.module.order.vo.orderWarehouseIn.OrderWarehouseInBackItemDo;
import cn.iocoder.yudao.module.order.vo.orderWarehouseIn.OrderWarehouseInBackItemVO;
import cn.iocoder.yudao.module.order.vo.orderWarehouseIn.OrderWarehouseInBackVO;
import cn.iocoder.yudao.module.product.dal.dataobject.product.ProductAttrDO;
import cn.iocoder.yudao.module.product.dal.dataobject.productbrank.ProductBrankDO;
......@@ -33,6 +36,7 @@ import cn.iocoder.yudao.module.shipment.dto.PreloadDto;
import cn.iocoder.yudao.module.shipment.service.box.BoxService;
import cn.iocoder.yudao.module.shipment.service.boxApproval.BoxApprovalService;
import cn.iocoder.yudao.module.shipment.service.boxPreloadGoods.BoxPreloadGoodsService;
import cn.iocoder.yudao.module.shipment.utils.CustomCellWriteHandler;
import cn.iocoder.yudao.module.shipment.utils.CustomMergeStrategy;
import cn.iocoder.yudao.module.shipment.vo.boxPreloadGoods.BoxPreloadGoodsBackVO;
import cn.iocoder.yudao.module.system.framework.ue.UeProperties;
......@@ -40,6 +44,7 @@ import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.metadata.WriteTable;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
......@@ -57,6 +62,7 @@ import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.error;
......@@ -110,6 +116,18 @@ public class ShipmentLoadExcelExportListener {
@Resource
private ProductAttrService productAttrService;
private static List<Integer> colorList = new ArrayList<>();
static {
colorList.add(22);
colorList.add(41);
colorList.add(42);
colorList.add(43);
colorList.add(44);
colorList.add(45);
colorList.add(46);
colorList.add(47);
}
/**
* 订单导出监听
*
......@@ -253,6 +271,13 @@ public class ShipmentLoadExcelExportListener {
Long part = secCount.get(i);
List<Integer> mergeCountList = new ArrayList();
List<Integer> colorRowList = new ArrayList<>();
AtomicInteger colorRowNum = new AtomicInteger(6);
Map<String,Integer> colorMap = new HashMap<>();
Map<String,Integer> mergePkgCountMap = new LinkedHashMap<>();
int colorIndex = 0;
//以订单ID分组
Map<Long, List<BoxPreloadGoodsBackVO>> orderMap =
goodsItemList.stream().filter(item -> item.getSecId().longValue() ==
......@@ -261,13 +286,70 @@ public class ShipmentLoadExcelExportListener {
.collect(Collectors.groupingBy(BoxPreloadGoodsBackVO::getOrderId,
LinkedHashMap::new, Collectors.toList()));
for (Map.Entry<Long, List<BoxPreloadGoodsBackVO>> entry : orderMap.entrySet()) {
Long orderId = entry.getKey();
Long pkgId = entry.getValue().get(0).getPkgId();
//OrderBackInfoDto orderInfo = orderQueryService.info(orderId);
//OrderDO orderDO = orderService.selectOne(OrderDO::getOrderId, orderId);
List<OrderWarehouseInBackItemVO> orderWarehouseInBackItemVOS =
orderWarehouseInService.getOrderWarehouseInListOrderByInTime(orderId);
for (OrderWarehouseInBackItemVO item : orderWarehouseInBackItemVOS) {
int andIncrement = colorRowNum.getAndIncrement();
if (StringUtils.isNotBlank(item.getOrderWarehouseInDetails())) {
JSONArray jsonArray = JSONArray.parseArray(item.getOrderWarehouseInDetails());
if (jsonArray.size() > 0) {
colorMap.put(String.valueOf(andIncrement),colorList.get(colorIndex));
colorRowList.add(andIncrement);//这里加1是为了设置颜色时过滤掉入仓记录那条
}
}
int mergeCount = 1;
if (StringUtils.isNotBlank(item.getOrderWarehouseInDetails())) {
item.setOrderWarehouseInDetailsVOList(JsonUtils.parseArray(item.getOrderWarehouseInDetails(), OrderWarehouseInDetailsVO.class));
}
if (CollectionUtil.isNotEmpty(item.getOrderWarehouseInDetailsVOList())) {
mergeCount = mergeCount + item.getOrderWarehouseInDetailsVOList().size();
List<OrderWarehouseInDetailsVO> orderWarehouseInDetailsVOList =
item.getOrderWarehouseInDetailsVOList();
for (int j = 0; j < orderWarehouseInDetailsVOList.size(); j++) {
int andIncrement1 = colorRowNum.getAndIncrement();
colorMap.put(String.valueOf(andIncrement1),colorList.get(colorIndex));
colorRowList.add(andIncrement1);
}
}
mergeCountList.add(mergeCount);
if (colorIndex == 7) {
colorIndex = 0;
} else {
colorIndex ++;
}
//合包那几个列合并单元格计算
if (pkgId.longValue() != 0L) {
if (mergePkgCountMap.get(String.valueOf(pkgId)) == null) {
mergePkgCountMap.put(String.valueOf(pkgId),mergeCount);
} else {
Integer sumMergePkgCount = mergePkgCountMap.get(String.valueOf(pkgId)) + mergeCount;
mergePkgCountMap.put(String.valueOf(pkgId),sumMergePkgCount);
}
} else {
mergePkgCountMap.put(String.valueOf(item.getId()),mergeCount);
}
}
}
//registerWriteHandler(new XXXStrategy(需要的参数))
//自定义单元格合并策略
WriteTable writeTable = EasyExcel.writerTable(i)
.registerWriteHandler(new CustomMergeStrategy(orderMap, null, null, 0, true))
.registerWriteHandler(new CustomMergeStrategy(orderMap, null, null, 1, true))
.registerWriteHandler(new CustomMergeStrategy(orderMap, null, null, 2, true))
.registerWriteHandler(new CustomMergeStrategy(orderMap, null, null, 7, true))
//2024-06-11 begin
.registerWriteHandler(new CustomCellWriteHandler(colorRowList,3, colorMap))
.registerWriteHandler(new CustomCellWriteHandler(colorRowList,4, colorMap))
.registerWriteHandler(new CustomCellWriteHandler(colorRowList,5, colorMap))
.registerWriteHandler(new CustomCellWriteHandler(colorRowList,6, colorMap))
.registerWriteHandler(new CustomCellWriteHandler(colorRowList,7, colorMap))
//.registerWriteHandler(new CustomMergeStrategy(orderMap, null, null, 7, true)) //end
.registerWriteHandler(new CustomMergeStrategy(orderMap, null, null, 10, true))
.registerWriteHandler(new CustomMergeStrategy(orderMap, null, null, 12, true))
.registerWriteHandler(new CustomMergeStrategy(orderMap, null, null, 13, true))
......
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