Commit 88200fdd authored by huyf's avatar huyf

预装单bug

parent 735c45fc
...@@ -69,4 +69,7 @@ public class SeaPreloadDto { ...@@ -69,4 +69,7 @@ public class SeaPreloadDto {
@ExcelProperty("quantity") @ExcelProperty("quantity")
private Integer quantity; private Integer quantity;
@ExcelProperty("prodAttr")
private String prodAttr;//特性
} }
...@@ -305,8 +305,10 @@ public class ShipmentPreloadExcelExportListener { ...@@ -305,8 +305,10 @@ public class ShipmentPreloadExcelExportListener {
preloadDto.setUsageIds(getUsageMsg(item.getUsageIds())); preloadDto.setUsageIds(getUsageMsg(item.getUsageIds()));
BigDecimal totalWorth = orderInfo.getOrderItemVOList().stream().map(OrderItemBackVO::getWorth).reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal totalWorth = orderInfo.getOrderItemVOList().stream().map(OrderItemBackVO::getWorth).reduce(BigDecimal.ZERO, BigDecimal::add);
preloadDto.setWorth(totalWorth); preloadDto.setWorth(totalWorth);
preloadDto.setTotalVolume(orderInfo.getSumVolume()); preloadDto.setTotalVolume(orderInfo.getSumVolumeFinishedWarehouseIn().compareTo(BigDecimal.ZERO) == 0 ? orderInfo.getSumVolume():orderInfo.getSumVolumeFinishedWarehouseIn());
preloadDto.setTotalWeight(orderInfo.getSumWeight()); preloadDto.setTotalWeight(orderInfo.getSumWeightFinishedWarehouseIn().compareTo(BigDecimal.ZERO) == 0 ? orderInfo.getSumWeight():orderInfo.getSumWeightFinishedWarehouseIn());
// preloadDto.setTotalVolume(orderInfo.getSumVolume());
// preloadDto.setTotalWeight(orderInfo.getSumWeight());
preloadDtoList.add(preloadDto); preloadDtoList.add(preloadDto);
if (StringUtils.isNotBlank(item.getOrderWarehouseInDetails())) { if (StringUtils.isNotBlank(item.getOrderWarehouseInDetails())) {
item.setOrderWarehouseInDetailsVOList(JsonUtils.parseArray(item.getOrderWarehouseInDetails(), OrderWarehouseInDetailsVO.class)); item.setOrderWarehouseInDetailsVOList(JsonUtils.parseArray(item.getOrderWarehouseInDetails(), OrderWarehouseInDetailsVO.class));
......
...@@ -27,7 +27,9 @@ import cn.iocoder.yudao.module.order.service.order.*; ...@@ -27,7 +27,9 @@ import cn.iocoder.yudao.module.order.service.order.*;
import cn.iocoder.yudao.module.order.service.orderWarehouseIn.OrderWarehouseInService; import cn.iocoder.yudao.module.order.service.orderWarehouseIn.OrderWarehouseInService;
import cn.iocoder.yudao.module.order.vo.orderWarehouseIn.OrderWarehouseInBackItemDo; import cn.iocoder.yudao.module.order.vo.orderWarehouseIn.OrderWarehouseInBackItemDo;
import cn.iocoder.yudao.module.order.vo.orderWarehouseIn.OrderWarehouseInBackVO; 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; import cn.iocoder.yudao.module.product.dal.dataobject.productbrank.ProductBrankDO;
import cn.iocoder.yudao.module.product.service.product.ProductAttrService;
import cn.iocoder.yudao.module.product.service.productbrank.ProductBrankService; import cn.iocoder.yudao.module.product.service.productbrank.ProductBrankService;
import cn.iocoder.yudao.module.shipment.dal.dataobject.BoxApprovalDO; import cn.iocoder.yudao.module.shipment.dal.dataobject.BoxApprovalDO;
import cn.iocoder.yudao.module.shipment.dal.dataobject.BoxDO; import cn.iocoder.yudao.module.shipment.dal.dataobject.BoxDO;
...@@ -107,6 +109,9 @@ public class ShipmentSeaPreloadExcelExportListener { ...@@ -107,6 +109,9 @@ public class ShipmentSeaPreloadExcelExportListener {
@Resource @Resource
private OrderService orderService; private OrderService orderService;
@Resource
private ProductAttrService productAttrService;
// @Value("${ue.templates-url}") // @Value("${ue.templates-url}")
// private String path; // private String path;
...@@ -149,6 +154,9 @@ public class ShipmentSeaPreloadExcelExportListener { ...@@ -149,6 +154,9 @@ public class ShipmentSeaPreloadExcelExportListener {
// 不存在则创建一个目录 // 不存在则创建一个目录
fileDir.mkdirs(); fileDir.mkdirs();
} }
List<ProductAttrDO> productAttrDOList = productAttrService.getProductAttrList();
Map<String, String> idNameMap = productAttrDOList.stream()
.collect(Collectors.toMap(attr -> String.valueOf(attr.getId()), ProductAttrDO::getAttrName));
ExcelWriter excelWriter = EasyExcel.write(dir + fileName).withTemplate(inputStream).build(); ExcelWriter excelWriter = EasyExcel.write(dir + fileName).withTemplate(inputStream).build();
WriteSheet sheet = EasyExcel.writerSheet(0).build(); WriteSheet sheet = EasyExcel.writerSheet(0).build();
excelWriter.fill(headMap, sheet); excelWriter.fill(headMap, sheet);
...@@ -204,6 +212,7 @@ public class ShipmentSeaPreloadExcelExportListener { ...@@ -204,6 +212,7 @@ public class ShipmentSeaPreloadExcelExportListener {
.registerWriteHandler(new CustomMergeStrategy(orderMap,orderWarehouseInService,orderItemService,17,true)) .registerWriteHandler(new CustomMergeStrategy(orderMap,orderWarehouseInService,orderItemService,17,true))
.registerWriteHandler(new CustomMergeStrategy(orderMap,orderWarehouseInService,orderItemService,18,false)) .registerWriteHandler(new CustomMergeStrategy(orderMap,orderWarehouseInService,orderItemService,18,false))
.registerWriteHandler(new CustomMergeStrategy(orderMap,orderWarehouseInService,orderItemService,20,false)) .registerWriteHandler(new CustomMergeStrategy(orderMap,orderWarehouseInService,orderItemService,20,false))
.registerWriteHandler(new CustomMergeStrategy(orderMap,orderWarehouseInService,orderItemService,21,false))
.automaticMergeHead(true).head(headList).needHead(true).build(); .automaticMergeHead(true).head(headList).needHead(true).build();
for (Map.Entry<Long, List<BoxPreloadGoodsBackVO>> entry : orderMap.entrySet()) { for (Map.Entry<Long, List<BoxPreloadGoodsBackVO>> entry : orderMap.entrySet()) {
Long orderId = entry.getKey(); Long orderId = entry.getKey();
...@@ -287,6 +296,7 @@ public class ShipmentSeaPreloadExcelExportListener { ...@@ -287,6 +296,7 @@ public class ShipmentSeaPreloadExcelExportListener {
// preloadDto.setQuantity(collect1.get(warehouse.getInTime()).get(warehouse.getUnit()).get(warehouse.getOrderLocationStr4Merge()).stream().mapToInt(OrderWarehouseInBackItemDo::getQuantityAll).sum()); // preloadDto.setQuantity(collect1.get(warehouse.getInTime()).get(warehouse.getUnit()).get(warehouse.getOrderLocationStr4Merge()).stream().mapToInt(OrderWarehouseInBackItemDo::getQuantityAll).sum());
preloadDto.setQuantity(collect1.get(warehouse.getInTime()).get(warehouse.getUnit()).get(warehouse.getOrderLocationStr4Merge()).stream().mapToInt(s -> Objects.isNull(s.getQuantityAll()) ? 0:s.getQuantityAll()).sum()); preloadDto.setQuantity(collect1.get(warehouse.getInTime()).get(warehouse.getUnit()).get(warehouse.getOrderLocationStr4Merge()).stream().mapToInt(s -> Objects.isNull(s.getQuantityAll()) ? 0:s.getQuantityAll()).sum());
// preloadDto.setQuantity(collect.get(warehouse.getInTime()).stream().filter(jj -> jj.getQuantityAll() !=null ).mapToInt(OrderWarehouseInBackItemDo::getQuantityAll).sum()); // preloadDto.setQuantity(collect.get(warehouse.getInTime()).stream().filter(jj -> jj.getQuantityAll() !=null ).mapToInt(OrderWarehouseInBackItemDo::getQuantityAll).sum());
preloadDto.setProdAttr(getAttrNameByIds(item.getProdAttrIds(),idNameMap));
list.add(preloadDto); list.add(preloadDto);
} }
totalNum = totalNum + item.getWarehouseInInfoVO().getCartonsNum(); totalNum = totalNum + item.getWarehouseInInfoVO().getCartonsNum();
...@@ -341,5 +351,18 @@ public class ShipmentSeaPreloadExcelExportListener { ...@@ -341,5 +351,18 @@ public class ShipmentSeaPreloadExcelExportListener {
} }
} }
private String getAttrNameByIds(String attrIds, Map<String, String> idNameMap) {
StringJoiner labelJoiner = new StringJoiner(",");
if(StringUtils.isNotBlank(attrIds)) {
String[] attrIdArray = attrIds.split(",");
for (String attrId : attrIdArray) {
//map一定包含数据,否则是数据错误
labelJoiner.add(idNameMap.get(attrId));
}
return labelJoiner.toString();
}
return "";
}
} }
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