Commit 52c72085 authored by lanbaoming's avatar lanbaoming

Merge branch 'dev'

# Conflicts:
#	yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/BpmCreateServiceFactoryImpl.java
#	yudao-module-order/yudao-module-order-core/src/main/java/cn/iocoder/yudao/module/order/service/order/impl/OrderBusinessServiceImpl.java
#	yudao-module-shipment/yudao-module-shipment-core/src/main/java/cn/iocoder/yudao/module/shipment/service/makeBillOfLading/MakeBillOfLadingServiceImpl.java
parents cf0ca276 72fdc215
......@@ -34,12 +34,14 @@ public class BpmCreateServiceFactoryImpl implements BpmCreateServiceFactory {
* @param copyUserId 抄送人列表,不需要传null
* @return 流程实例ID,需回写到表单对象中
*/
public String createBmp(Long userId, Long orderFormId, String workFlowKey, String businessNo, String[] copyUserId) {
public String createBmp(Long userId, Long orderFormId, String workFlowKey,
String businessNo, String[] copyUserId) {
Map<String, Object> processInstanceVariables = new HashMap<>();
if (StrUtil.isNotBlank(businessNo)) {
processInstanceVariables.put("businessNo", businessNo);
}
String processInstanceId = processInstanceApi.createProcessInstance(userId,
String processInstanceId =
processInstanceApi.createProcessInstance(userId,
new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(workFlowKey).setVariables(processInstanceVariables).setBusinessKey(String.valueOf(orderFormId)).setCopyUserIds(copyUserId));
return processInstanceId;
}
......
......@@ -2226,8 +2226,7 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
// 没有待处理的清关费未报价异常,则需要生成
//生成清关费异常 lanbm 2024-06-06 添加参数type=6,是处理价格异常
noQuoteOrAutomaticNoQuote =
this.createClearanceFeeNoQuiteException(
orderDO,
this.createClearanceFeeNoQuiteException(orderDO,
noQuoteOrAutomaticNoQuote,
orderItemDO, type);
// 这里可能因为自动处理未报价异常(包括未报价清关费异常)时,
......@@ -2443,7 +2442,7 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
}
//lanbm 2024-06-06 添加的逻辑点
*/
noQuoteOrAutomaticNoQuote=1;
if (orderItemDO.getItemStatus() == -1 && !orderItemDO.getIsProd()) {
if (CollectionUtil.isEmpty(orderNoQuoteExceptionDOList)) {
......@@ -2608,22 +2607,16 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
// 查询是否有重量超限异常,如果有则不生成清关费异常
// TODO 查询是否有重量超限异常和渠道包装重量超限异常,如果有则不生成清关费异常
List<OrderExceptionDO> goodsOverweightExceptionDOList =
orderExceptionService.getPendingOrderExceptionByOrderIdAndOrderItemIdAndProdIdAndExceptionKeys(
orderDO.getOrderId(),
orderExceptionService.getPendingOrderExceptionByOrderIdAndOrderItemIdAndProdIdAndExceptionKeys(orderDO.getOrderId(),
null,
orderItemDO.getProdId(),
CollectionUtil.newArrayList(
OrderExceptionEnum.GOODS_OVERWEIGHT_EXCEPTION.getKey(),
OrderExceptionEnum.LINE_WEIGHT_EXCEPTION.getKey()));
CollectionUtil.newArrayList(OrderExceptionEnum.GOODS_OVERWEIGHT_EXCEPTION.getKey(), OrderExceptionEnum.LINE_WEIGHT_EXCEPTION.getKey()));
/*
String s = "type=" + type.toString() + " TransportId=" +
orderDO.getTransportId().toString() +
" NeedOrderInquiry=" + orderItemDO.getNeedOrderInquiry().toString();
//lanbm 2024-06-06 添加的逻辑点
//空运,单询价
if (orderDO.getTransportId() == 3
&& orderItemDO.getNeedOrderInquiry() == 1) {
......@@ -2635,8 +2628,7 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
OrderExceptionEnum.CUSTOMS_FEE_NOT_QUOTE_EXCEPTION.getKey());
if (CollectionUtil.isNotEmpty(orderClearanceFeeNoQuoteExceptionDOList)) {
// 当其他业务补充了品名空运清关费价格后,
// 如果还有待处理的清关费未报价异常,需要同步处理掉
// 当其他业务补充了品名空运清关费价格后,如果还有待处理的清关费未报价异常,需要同步处理掉
orderExceptionService.autoProcessException(orderDO.getOrderId(),
orderItemDO.getOrderItemId(),
OrderExceptionEnum.CUSTOMS_FEE_NOT_QUOTE_EXCEPTION,
......@@ -2655,7 +2647,6 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
zTest z = new zTest();
z.setTestname(s);
z.setCreatedate(new Date());
zTestMapper.insert(z);
}*/
//end lanbm 2024-06-06 添加的逻辑点
......@@ -2670,7 +2661,6 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
orderItemDO.getOrderItemId(),
OrderExceptionEnum.CUSTOMS_FEE_NOT_QUOTE_EXCEPTION.getKey());
//运费加清关价才生成清关费异常 lanbm 2024-06-06 添加注释
//计费方式:0 运费/清关费 1 全包价
if (orderItemDO.getCharging() == 0 &&
(Objects.isNull(orderItemDO.getOriginalClearanceFreight()) ||
orderItemDO.getOriginalClearanceFreight().compareTo(BigDecimal.ZERO) == 0)
......@@ -2716,7 +2706,6 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
}
}
return noQuoteOrAutomaticNoQuote;
}
private void createFeeChangeException(OrderDO orderDO, Integer type, BigDecimal oldFreightAndClearanceFee, BigDecimal newFreightAndClearanceFee) {
......
......@@ -5,7 +5,6 @@ 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;
......@@ -21,13 +20,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;
import cn.iocoder.yudao.module.product.service.product.ProductAttrService;
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.BoxDO;
......@@ -36,7 +31,6 @@ 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;
......@@ -44,7 +38,6 @@ 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;
......@@ -62,7 +55,6 @@ 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;
......@@ -72,9 +64,7 @@ import static cn.iocoder.yudao.module.shipment.enums.ErrorCodeConstants.HAVE_NOT
/**
* 自编号订单excel导出监听
* lanbm 2024-06-05 修改模板样式和添加列字段
* 海运已装单数据导出
* NG2408045L
*
* @author zhengYi
*/
@Component("ShipmentLoadExcelExportListener")
......@@ -113,20 +103,8 @@ public class ShipmentLoadExcelExportListener {
@Resource
private OrderService orderService;
@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);
}
// @Value("${ue.templates-url}")
// private String path;
/**
* 订单导出监听
......@@ -134,132 +112,63 @@ public class ShipmentLoadExcelExportListener {
* @param event 编号记录
*/
@EventListener(ShipmentLoadExcelExportPushEvent.class)
public void shipmentLoadExcelExportPushEvent(
ShipmentLoadExcelExportPushEvent event) {
public void shipmentLoadExcelExportPushEvent(ShipmentLoadExcelExportPushEvent event) {
if (StringUtils.isNotBlank(event.getRequestParams())) {
try {
DateTimeFormatter formatter =
DateTimeFormatter.ofPattern(DATA_FORMAT);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATA_FORMAT);
String nowTime = formatter.format(LocalDateTime.now());
String dir = ueProperties.getTempDir().concat("/load/excel/");
String fileName = event.getUserId().
toString().concat(StrUtil.DASHED).
concat(event.getUserType().toString()).
concat(StrUtil.DASHED).concat(nowTime).
concat("shipment_load.xlsx");
String fileName = event.getUserId().toString().concat(StrUtil.DASHED).concat(event.getUserType().toString()).concat(StrUtil.DASHED).concat(nowTime).concat("shipment_load.xlsx");
InputStream inputStream = null;
//获取模板 2024-06-05 添加注释
inputStream = getClass().getClassLoader().
getResourceAsStream(
ueProperties.getTemplatesUrl() + "/load.xlsx");
inputStream = getClass().getClassLoader().getResourceAsStream(ueProperties.getTemplatesUrl() + "/load.xlsx");
Map headMap = new HashMap();
JSONObject jsonObject =
JSONObject.parseObject(event.getRequestParams());
JSONObject jsonObject = JSONObject.parseObject(event.getRequestParams());
Long shipmentId = jsonObject.getLong("shipmentId");
List<BoxPreloadGoodsBackVO> goodsItemList =
boxPreloadGoodsService.getShipGoodItemList(shipmentId);
List<BoxPreloadGoodsBackVO> goodsItemList = boxPreloadGoodsService.getShipGoodItemList(shipmentId);
if (CollectionUtil.isEmpty(goodsItemList)) {
event.setResult(HAVE_NOT_PRELOAD_GOODS.getMsg());
}
BoxDO box = boxService.getBox(shipmentId);
CabinetDO cabinet = cabinetService.getCabinet(box.getCabinetId());
BoxApprovalDO boxApprovalDO =
boxApprovalService.getOne(
new LambdaQueryWrapperX<BoxApprovalDO>().
eq(BoxApprovalDO::getShipmentId, shipmentId).
eq(BoxApprovalDO::getApprovalType, 2).
last("limit 1"));
BoxApprovalDO boxApprovalDO = boxApprovalService.getOne(new LambdaQueryWrapperX<BoxApprovalDO>().eq(BoxApprovalDO::getShipmentId, shipmentId).eq(BoxApprovalDO::getApprovalType, 2).last("limit 1"));
headMap.put("selfNo", box.getSelfNo());
headMap.put("ctnNo", box.getCubNo());
if (cabinet != null) {
headMap.put("ctnNo",box.getCubNo());
if(cabinet != null) {
headMap.put("cabinetName", cabinet.getName());
}
headMap.put("exportDate", DateUtils.formatDate(new Date()));
if (boxApprovalDO != null) {
headMap.put("date",
DateUtils.formatDate(boxApprovalDO.getCreateTime()));
headMap.put("date", DateUtils.formatDate(boxApprovalDO.getCreateTime()));
}
File fileDir = new File(dir);
if (!fileDir.exists()) {
if (!fileDir.exists()){
// 不存在则创建一个目录
fileDir.mkdirs();
}
//write 写入的文件路径
//withTemplate 使用的模板
ExcelWriter excelWriter =
EasyExcel.write(dir + fileName).
withTemplate(inputStream).build();
ExcelWriter excelWriter = EasyExcel.write(dir + fileName).withTemplate(inputStream).build();
WriteSheet sheet = EasyExcel.writerSheet(0).build();
excelWriter.fill(headMap, sheet);
//商品属性获取 lanbm 2024-06-05 add
List<ProductAttrDO> ProductAttrList =
productAttrService.getProductAttrList();
Map<Long, String> ProductAttrMap = null;
if (CollectionUtil.isEmpty(ProductAttrList) == false) {
ProductAttrMap = ProductAttrList.stream().
collect(Collectors.toMap(ProductAttrDO::getId,
ProductAttrDO::getAttrName));
}
//end 商品属性获取 lanbm 2024-06-05 add
if (box.getLdStatus() != null && box.getLdStatus() >= 43) {
//43、已装柜、待封柜
if (box.getLdStatus() != null && box.getLdStatus()>=43) {//43、已装柜、待封柜
//以secId排序
goodsItemList.sort(Comparator.comparing(
BoxPreloadGoodsBackVO::getSecId).
thenComparing(BoxPreloadGoodsBackVO::getTidanNum).
thenComparing(BoxPreloadGoodsBackVO::getId));
goodsItemList.sort(Comparator.comparing(BoxPreloadGoodsBackVO::getSecId).thenComparing(BoxPreloadGoodsBackVO::getTidanNum).thenComparing(BoxPreloadGoodsBackVO::getId));
int allTotalNum = 0;
BigDecimal allTotalVolume = new BigDecimal(0);
BigDecimal allTotalWeight = new BigDecimal(0);
List<Long> secCount =
goodsItemList.stream().
map(BoxPreloadGoodsBackVO::getSecId).
distinct().sorted().collect(Collectors.toList());
List<Long> secCount = goodsItemList.stream().map(BoxPreloadGoodsBackVO::getSecId).distinct().sorted().collect(Collectors.toList());
if (!CollectionUtils.isEmpty(secCount)) {
for (int i = 0; i < secCount.size(); i++) {
for (int i=0;i<secCount.size();i++){
List<String> list1 = new ArrayList();
List<List<String>> headList = new ArrayList<>();
String head = "";
if (i == 0) {
head = "第" + NumberUtils.int2chineseNum(i + 1)
+ "部分(Be loaded inside of the container)";
head = "第"+ NumberUtils.int2chineseNum(i+1) +"部分(Be loaded inside of the container)";
} else {
head = "第" + NumberUtils.int2chineseNum(i + 1)
+ "部分(after " + NumberUtils.format(i + 1) + " parts)";
head = "第"+NumberUtils.int2chineseNum(i+1)+"部分(after "+ NumberUtils.format(i+1)+" parts)";
}
list1.add(head);
headList.add(list1);
headList.add(list1);
headList.add(list1);
headList.add(list1);
headList.add(list1);
headList.add(list1);
headList.add(list1);
headList.add(list1);
headList.add(list1);
headList.add(list1);
headList.add(list1);
headList.add(list1);
headList.add(list1);
headList.add(list1);
headList.add(list1);
headList.add(list1);
headList.add(list1);
headList.add(list1);
headList.add(list1);
headList.add(list1);headList.add(list1);headList.add(list1);headList.add(list1);headList.add(list1);headList.add(list1);headList.add(list1);
headList.add(list1);headList.add(list1);headList.add(list1);headList.add(list1);headList.add(list1);headList.add(list1);headList.add(list1);
headList.add(list1);headList.add(list1);headList.add(list1);headList.add(list1);headList.add(list1);headList.add(list1);headList.add(list1);
List<LoadDto> list = new ArrayList<>();
......@@ -267,165 +176,71 @@ public class ShipmentLoadExcelExportListener {
BigDecimal totalVolume = new BigDecimal(0);
BigDecimal totalWeight = new BigDecimal(0);
Map<String, Integer> numMap = new HashMap();
Map<String,Integer> numMap = new HashMap();
Long part = secCount.get(i);
List<Integer> mergeCountList = new ArrayList();
List<Integer> colorRowList = new ArrayList<>();
AtomicInteger colorRowNum = new AtomicInteger(5);
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() ==
part.longValue() &&
StringUtils.isNotBlank(item.getWarehouseInInfo()))
.collect(Collectors.groupingBy(BoxPreloadGoodsBackVO::getOrderId,
LinkedHashMap::new, Collectors.toList()));
for (Map.Entry<Long, List<BoxPreloadGoodsBackVO>> entry : orderMap.entrySet()) {
Long orderId = entry.getKey();
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 ++;
}
}
}
//registerWriteHandler(new XXXStrategy(需要的参数))
//自定义单元格合并策略
Map<Long, List<BoxPreloadGoodsBackVO>> orderMap = goodsItemList.stream().filter(item -> item.getSecId().longValue()==part.longValue() && StringUtils.isNotBlank(item.getWarehouseInInfo()))
.collect(Collectors.groupingBy(BoxPreloadGoodsBackVO::getOrderId,LinkedHashMap::new,Collectors.toList()));
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))
//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))
.registerWriteHandler(new CustomMergeStrategy(orderMap, null, null, 14, true))
.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))
.registerWriteHandler(new CustomMergeStrategy(orderMap,null,null,10,true))
.registerWriteHandler(new CustomMergeStrategy(orderMap,null,null,12,true))
.registerWriteHandler(new CustomMergeStrategy(orderMap,null,null,13,true))
.registerWriteHandler(new CustomMergeStrategy(orderMap,null,null,14,true))
.automaticMergeHead(true).head(headList).needHead(true).build();
for (Map.Entry<Long, List<BoxPreloadGoodsBackVO>> entry : orderMap.entrySet()) {
Long orderId = entry.getKey();
OrderBackInfoDto orderInfo = orderQueryService.info(orderId);
List<BoxPreloadGoodsBackVO> boxPreload = entry.getValue();
List<OrderItemDO> orderItems =
boxPreload.stream().map(item -> orderItemService.
getOrderItem(item.getOrderItemId())).
collect(Collectors.toList());
for (OrderItemDO item : orderItems) {
List<OrderWarehouseInDO> orderWarehouseInDOS =
orderWarehouseInService.selectList(
OrderWarehouseInDO::getOrderItemId,
item.getOrderItemId());
List<OrderItemDO> orderItems = boxPreload.stream().map(item -> orderItemService.getOrderItem(item.getOrderItemId())).collect(Collectors.toList());
for(OrderItemDO item : orderItems) {
List<OrderWarehouseInDO> orderWarehouseInDOS = orderWarehouseInService.selectList(OrderWarehouseInDO::getOrderItemId, item.getOrderItemId());
LoadDto preloadDto = new LoadDto();
preloadDto.setOrderNo(orderInfo.getOrderNo());
if (numMap.get(orderInfo.getOrderNo()) != null) {
preloadDto.setId(String.valueOf(numMap.get(orderInfo.getOrderNo())));
} else {
preloadDto.setId(String.valueOf(numMap.size() + 1));
numMap.put(orderInfo.getOrderNo(), numMap.size() + 1);
preloadDto.setId(String.valueOf(numMap.size()+1));
numMap.put(orderInfo.getOrderNo(),numMap.size()+1);
}
preloadDto.setMarks(orderInfo.getMarks());
List<OrderGuanlianDO> guanlianList =
orderGuanlianService.getGuanlianListByOrderId(
orderInfo.getOrderId());
List<OrderGuanlianDO> guanlianList = orderGuanlianService.getGuanlianListByOrderId(orderInfo.getOrderId());
//rIdList为此订单的所有关联订单
List<Long> rIdList = new ArrayList<>();
for (OrderGuanlianDO orderGuanlianDO : guanlianList) {
Long oId = orderGuanlianDO.getOrderId();
Long rId = orderGuanlianDO.getRelateOrderId();
if (oId.equals(orderId)) {
if(oId.equals(orderId)) {
rIdList.add((rId));
} else if (rId.equals(orderId)) {
} else if(rId.equals(orderId)) {
rIdList.add(oId);
}
}
if (CollectionUtil.isNotEmpty(rIdList)) {
List<OrderDO> orderDOS =
orderService.selectList(OrderDO::getOrderId, rIdList);
List<OrderDO> orderDOS = orderService.selectList(OrderDO::getOrderId, rIdList);
if (CollectionUtil.isNotEmpty(orderDOS)) {
preloadDto.setRelateOrder(orderDOS.stream().map(
OrderDO::getOrderNo).collect(Collectors.joining(",")));
preloadDto.setRelateOrder(orderDOS.stream().map(OrderDO::getOrderNo).collect(Collectors.joining(",")));
}
}
preloadDto.setProdTitleZh(item.getProdTitleZh() + " " + item.getProdTitleEn());
preloadDto.setProdTitleZh(item.getProdTitleZh()+ " " +item.getProdTitleEn());
preloadDto.setMerge(orderInfo.getOldNumbers());
ProductBrankDO productBrank =
productBrankService.getProductBrank(item.getBrand());
if (productBrank != null && StringUtils.isNotBlank(productBrank.getTitleZh())) {
ProductBrankDO productBrank = productBrankService.getProductBrank(item.getBrand());
if(productBrank!=null && StringUtils.isNotBlank(productBrank.getTitleZh())){
preloadDto.setBrand(productBrank.getTitleZh());
}
//材质
if (StringUtils.isNotBlank(item.getMaterial())) {
preloadDto.setMaterial(
DictFrameworkUtils.getDictDataFromCache("product_material",
item.getMaterial() + "").getLabel());
if(StringUtils.isNotBlank(item.getMaterial())){
preloadDto.setMaterial(DictFrameworkUtils.getDictDataFromCache("product_material",item.getMaterial()+"").getLabel());
}
//品牌
if (productBrank != null && productBrank.getFiling() != null) {
preloadDto.setProductRecord(productBrank.getFiling().equals("0") ? "N" : "Y");
if(productBrank !=null && productBrank.getFiling()!=null){
preloadDto.setProductRecord(productBrank.getFiling().equals("0")? "N":"Y");
}
//用途
if (item.getUsageIds() == null || item.getUsageIds().length() == 0) {
preloadDto.setUsageIds("");
} else {
//在缓存数据字典中获取用途信息
String sUserdName = DictFrameworkUtils.getDictDataFromCache(
"order_item_usage",
item.getUsageIds() + "").getLabel();
preloadDto.setUsageIds(sUserdName);
}
//商品特性赋值 lanbm 2024-06-05 add
String sR = getAttrName(item, ProductAttrMap);
preloadDto.setProdAttrIds(sR);
preloadDto.setSumNum(item.getWarehouseInInfoVO().getCartonsNum());
if (CollectionUtil.isNotEmpty(orderWarehouseInDOS)) {
if(CollectionUtil.isNotEmpty(orderWarehouseInDOS)){
String warehousingSpecificationType = orderWarehouseInDOS.stream().map(j -> {
return DictFrameworkUtils.getDictDataFromCache("warehousing_specification_type", j.getSpecificationType() + "").getLabel();
}).distinct().collect(Collectors.joining("/"));
......@@ -437,10 +252,8 @@ public class ShipmentLoadExcelExportListener {
}
preloadDto.setSumVolume(item.getWarehouseInInfoVO().getVolume());
preloadDto.setSumWeight(item.getWarehouseInInfoVO().getWeight());
if (orderInfo.getCustomsType() != null) {
preloadDto.setCustomsType(
DictFrameworkUtils.getDictDataFromCache("customs_type",
orderInfo.getCustomsType() + "").getLabel());
if(orderInfo.getCustomsType()!=null){
preloadDto.setCustomsType(DictFrameworkUtils.getDictDataFromCache("customs_type",orderInfo.getCustomsType()+"").getLabel());
}
preloadDto.setWorth(item.getWorth());
preloadDto.setQuantity(item.getWarehouseInInfoVO().getQuantityAll());
......@@ -459,7 +272,7 @@ public class ShipmentLoadExcelExportListener {
allTotalNum = allTotalNum + totalNum;
allTotalVolume = allTotalVolume.add(totalVolume);
allTotalWeight = allTotalWeight.add(totalWeight);
if (i == secCount.size() - 1) {
if(i==secCount.size()-1){
LoadDto preloadDto1 = new LoadDto();
preloadDto1.setId("IN TOTAL");
preloadDto1.setSumNum(allTotalNum);
......@@ -467,12 +280,11 @@ public class ShipmentLoadExcelExportListener {
preloadDto1.setSumWeight(allTotalWeight);
list.add(preloadDto1);
}
excelWriter.write(list, sheet, writeTable);
excelWriter.write(list,sheet,writeTable);
}
}
}
excelWriter.finish();
inputStream.close();
// 获取到临时文件
......@@ -490,8 +302,8 @@ public class ShipmentLoadExcelExportListener {
event.setFileName(fileDO.getPath());
event.setUrl(fileDO.getUrl());
event.setFileId(fileDO.getId());
} catch (Exception e) {
e.printStackTrace();
event.setResult(e.getMessage());
}
......@@ -500,35 +312,4 @@ public class ShipmentLoadExcelExportListener {
}
}
/*
lanbm 2024-06-05 添加商品属性转换函数
*/
private String getAttrName(OrderItemDO item, Map<Long, String> ProductAttrMap) {
String sReult = "";
//lanbm 2024-06-05添加商品特性
if (item.getProdAttrIds() == null || item.getProdAttrIds().length() == 0) {
return sReult;
} else {
if (ProductAttrMap == null) {
return sReult;
} else {
String sAttrName = "";
List<String> resultList = Arrays.asList(
item.getProdAttrIds().split(","));
for (String sId : resultList
) {
Long l = Long.parseLong(sId);
if (sAttrName.length() != 0) {
sAttrName += "," + ProductAttrMap.get(l);
} else {
sAttrName += ProductAttrMap.get(l);
}
}
sReult = sAttrName;
}
}
//end lanbm 2024-06-05添加商品特性
return sReult;
}
}
......@@ -12,11 +12,14 @@ import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
import cn.iocoder.yudao.framework.dict.core.dto.DictDataRespDTO;
import cn.iocoder.yudao.framework.dict.core.util.DictFrameworkUtils;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.ecw.dal.dataobject.cabinet.CabinetDO;
import cn.iocoder.yudao.module.ecw.service.cabinet.CabinetService;
import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileDO;
import cn.iocoder.yudao.module.infra.service.file.FileService;
import cn.iocoder.yudao.module.order.dal.dataobject.order.OrderDO;
import cn.iocoder.yudao.module.order.dal.dataobject.orderGuanlian.OrderGuanlianDO;
import cn.iocoder.yudao.module.order.dal.dataobject.orderItem.OrderItemDO;
import cn.iocoder.yudao.module.order.dal.dataobject.orderWarehouseIn.OrderWarehouseInDO;
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;
......@@ -43,6 +46,7 @@ import cn.iocoder.yudao.module.shipment.service.boxPkgOrder.BoxPkgOrderService;
import cn.iocoder.yudao.module.shipment.service.boxPreloadGoods.BoxPreloadGoodsService;
import cn.iocoder.yudao.module.shipment.utils.CustomAirLoadMergeStrategyNew;
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;
import com.alibaba.excel.EasyExcel;
......@@ -72,6 +76,16 @@ import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.excel.constant.ExportConstant.DATA_FORMAT;
import static cn.iocoder.yudao.module.shipment.enums.ErrorCodeConstants.HAVE_NOT_PRELOAD_GOODS;
/**
* 自编号订单excel导出监听
* lanbm 2024-06-05 修改模板样式和添加列字段
* 海运已装单数据导出
* NG2408045L
* @author zhengYi
*/
@Component("ShipmentLoadExcelExportListener2")
@AllArgsConstructor
@Slf4j
......@@ -99,9 +113,6 @@ public class ShipmentLoadExcelExportListener2 {
@Resource
private BoxApprovalService boxApprovalService;
@Resource
private OrderLocationService orderLocationService;
@Resource
private OrderGuanlianService orderGuanlianService;
......@@ -111,18 +122,9 @@ public class ShipmentLoadExcelExportListener2 {
@Resource
private OrderService orderService;
@Resource
private ProductService productService;
@Resource
private ProductAttrService productAttrService;
@Resource
private BoxPkgOrderService boxPkgOrderService;
@Resource
private BoxMergePkgService boxMergePkgService;
private static List<Integer> colorList = new ArrayList<>();
static {
colorList.add(22);
......@@ -140,113 +142,167 @@ public class ShipmentLoadExcelExportListener2 {
*
* @param event 编号记录
*/
@EventListener(ShipmentLoadExcelExportPushEvent2.class)
public void shipmentAirLoadExcelExportPushEvent(
ShipmentLoadExcelExportPushEvent2 event) {
@EventListener(ShipmentLoadExcelExportPushEvent.class)
public void shipmentLoadExcelExportPushEvent(
ShipmentLoadExcelExportPushEvent event) {
if (StringUtils.isNotBlank(event.getRequestParams())) {
try {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATA_FORMAT);
DateTimeFormatter formatter =
DateTimeFormatter.ofPattern(DATA_FORMAT);
String nowTime = formatter.format(LocalDateTime.now());
String dir = ueProperties.getTempDir().concat("/load/excel/");
File fileDir = new File(dir);
if (!fileDir.exists()){
// 不存在则创建一个目录
fileDir.mkdirs();
}
String fileName = event.getUserId().toString().
concat(StrUtil.DASHED).concat(event.getUserType().
toString()).concat(StrUtil.DASHED).
concat(nowTime).concat("shipment_load.xlsx");
String fileName = event.getUserId().
toString().concat(StrUtil.DASHED).
concat(event.getUserType().toString()).
concat(StrUtil.DASHED).concat(nowTime).
concat("shipment_load.xlsx");
InputStream inputStream = null;
inputStream = this.getClass().getClassLoader().
//获取模板 2024-06-05 添加注释
inputStream = getClass().getClassLoader().
getResourceAsStream(
ueProperties.getTemplatesUrl() + "/load.xlsx");
JSONObject jsonObject = JSONObject.parseObject(event.getRequestParams());
Long shipmentId = jsonObject.getLong("shipmentId");
Map headMap = new HashMap();
List<BoxPreloadGoodsBackVO> goodsItemList = boxPreloadGoodsService.getShipGoodItemList(shipmentId);
JSONObject jsonObject =
JSONObject.parseObject(event.getRequestParams());
Long shipmentId = jsonObject.getLong("shipmentId");
List<BoxPreloadGoodsBackVO> goodsItemList =
boxPreloadGoodsService.getShipGoodItemList(shipmentId);
if (CollectionUtil.isEmpty(goodsItemList)) {
event.setResult(HAVE_NOT_PRELOAD_GOODS.getMsg());
}
BoxDO box = boxService.getBox(shipmentId);
BoxApprovalDO boxApprovalDO = boxApprovalService.getOne(new LambdaQueryWrapperX<BoxApprovalDO>().eq(BoxApprovalDO::getShipmentId, shipmentId).eq(BoxApprovalDO::getApprovalType, 1).last("limit 1"));
CabinetDO cabinet = cabinetService.getCabinet(box.getCabinetId());
BoxApprovalDO boxApprovalDO =
boxApprovalService.getOne(
new LambdaQueryWrapperX<BoxApprovalDO>().
eq(BoxApprovalDO::getShipmentId, shipmentId).
eq(BoxApprovalDO::getApprovalType, 2).
last("limit 1"));
headMap.put("selfNo", box.getSelfNo());
headMap.put("airChannel","");
headMap.put("ctnNo", box.getCubNo());
if (cabinet != null) {
headMap.put("cabinetName", cabinet.getName());
}
headMap.put("exportDate", DateUtils.formatDate(new Date()));
if (boxApprovalDO != null) {
headMap.put("date", DateUtils.formatDate(boxApprovalDO.getUpdateTime()));
headMap.put("date",
DateUtils.formatDate(boxApprovalDO.getCreateTime()));
}
File fileDir = new File(dir);
if (!fileDir.exists()) {
// 不存在则创建一个目录
fileDir.mkdirs();
}
ExcelWriter excelWriter = EasyExcel.write(dir + fileName).withTemplate(inputStream).build();
//write 写入的文件路径
//withTemplate 使用的模板
ExcelWriter excelWriter =
EasyExcel.write(dir + fileName).
withTemplate(inputStream).build();
WriteSheet sheet = EasyExcel.writerSheet(0).build();
excelWriter.fill(headMap, sheet);
//商品属性获取 lanbm 2024-06-05 add
List<ProductAttrDO> ProductAttrList =
productAttrService.getProductAttrList();
Map<Long, String> ProductAttrMap = null;
if (CollectionUtil.isEmpty(ProductAttrList) == false) {
ProductAttrMap = ProductAttrList.stream().
collect(Collectors.toMap(ProductAttrDO::getId,
ProductAttrDO::getAttrName));
}
//end 商品属性获取 lanbm 2024-06-05 add
if (box.getLdStatus() != null && box.getLdStatus() >= 43) {
//43、已装柜、待封柜
//以secId排序
goodsItemList.sort(Comparator.comparing(BoxPreloadGoodsBackVO::getPkgId).reversed().thenComparing(BoxPreloadGoodsBackVO::getTidanNum));
List<Long> pkgIds = goodsItemList.stream().filter(item -> item.getPkgId() != null && item.getPkgId() > 0L).map(BoxPreloadGoodsBackVO::getPkgId).distinct().collect(Collectors.toList());
Map<String,Integer> map = new HashMap<>();
if (CollectionUtil.isNotEmpty(pkgIds)) {
map = boxPkgOrderService.getMergeOrderQualityByPkgIds(pkgIds);
}
Long disMergePkgCount = goodsItemList.stream().filter(item -> item.getPkgId() != null && item.getPkgId() > 0L).map(BoxPreloadGoodsBackVO::getPkgId).distinct().count();
int sumMergeCount = disMergePkgCount.intValue();
// goodsItemList.sort(Comparator.comparing(BoxPreloadGoodsBackVO::getSecId).thenComparing(BoxPreloadGoodsBackVO::getTidanNum).thenComparing(BoxPreloadGoodsBackVO::getId));
goodsItemList.sort(Comparator.comparing(
BoxPreloadGoodsBackVO::getSecId).
thenComparing(BoxPreloadGoodsBackVO::getTidanNum).
thenComparing(BoxPreloadGoodsBackVO::getId));
int allTotalNum = 0;
BigDecimal allTotalVolume = new BigDecimal(0);
BigDecimal allTotalWeight = new BigDecimal(0);
Map<String,BigDecimal> mergeVolumnMap = new HashMap<>();
Map<String,BigDecimal> mergeWeightMap = new HashMap<>();
Map<String,Integer> mergeQualityMap = new HashMap<>();
int totalMergeQuality = 0;
BigDecimal totalMergeVolume = new BigDecimal("0");
BigDecimal totalMergeWeight = new BigDecimal("0");
List<Long> secCount = goodsItemList.stream().map(BoxPreloadGoodsBackVO::getSecId).distinct().sorted().collect(Collectors.toList());
List<Long> secCount =
goodsItemList.stream().
map(BoxPreloadGoodsBackVO::getSecId).
distinct().sorted().collect(Collectors.toList());
if (!CollectionUtils.isEmpty(secCount)) {
for (int i=0;i<secCount.size();i++){
for (int i = 0; i < secCount.size(); i++) {
List<String> list1 = new ArrayList();
List<List<String>> headList = new ArrayList<>();
String head = "";
if (i == 0) {
head = "第"+ NumberUtils.int2chineseNum(i+1) +"部分(Be loaded inside of the container)";
head = "第" + NumberUtils.int2chineseNum(i + 1)
+ "部分(Be loaded inside of the container)";
} else {
head = "第"+NumberUtils.int2chineseNum(i+1)+"部分(after "+ NumberUtils.format(i+1)+" parts)";
head = "第" + NumberUtils.int2chineseNum(i + 1)
+ "部分(after " + NumberUtils.format(i + 1) + " parts)";
}
list1.add(head);
headList.add(list1);headList.add(list1);headList.add(list1);headList.add(list1);headList.add(list1);headList.add(list1);headList.add(list1);
headList.add(list1);headList.add(list1);headList.add(list1);headList.add(list1);headList.add(list1);headList.add(list1);headList.add(list1);
headList.add(list1);headList.add(list1);headList.add(list1);headList.add(list1);headList.add(list1);headList.add(list1);headList.add(list1);
headList.add(list1);headList.add(list1);headList.add(list1);headList.add(list1);
List<PreloadDto> list = new ArrayList<>();
headList.add(list1);
headList.add(list1);
headList.add(list1);
headList.add(list1);
headList.add(list1);
headList.add(list1);
headList.add(list1);
headList.add(list1);
headList.add(list1);
headList.add(list1);
headList.add(list1);
headList.add(list1);
headList.add(list1);
headList.add(list1);
headList.add(list1);
headList.add(list1);
headList.add(list1);
headList.add(list1);
headList.add(list1);
List<LoadDto> list = new ArrayList<>();
int totalNum = 0;
BigDecimal totalVolume = new BigDecimal(0);
BigDecimal totalWeight = new BigDecimal(0);
Map<String,Integer> numMap = new HashMap();
List<AirLoadDto> preloadDtoList = new ArrayList<>();
Map<String, Integer> numMap = new HashMap();
Long part = secCount.get(i);
List<Integer> mergeCountList = new ArrayList();
List<Integer> mergeCountList = new ArrayList();
List<Integer> colorRowList = new ArrayList<>();
AtomicInteger colorRowNum = new AtomicInteger(5);
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()==part.longValue() &&
goodsItemList.stream().filter(item -> item.getSecId().longValue() ==
part.longValue() &&
StringUtils.isNotBlank(item.getWarehouseInInfo()))
.collect(Collectors.groupingBy(BoxPreloadGoodsBackVO::getOrderId,
LinkedHashMap::new,Collectors.toList()));
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) {
......@@ -255,80 +311,6 @@ public class ShipmentLoadExcelExportListener2 {
}
}
int mergeCount = 1;
AirLoadDto preloadDto =new AirLoadDto();
if (numMap.get(orderInfo.getOrderNo()) != null) {
preloadDto.setId(String.valueOf(numMap.get(orderInfo.getOrderNo())));
} else {
preloadDto.setId(String.valueOf(numMap.size()+1));
numMap.put(orderInfo.getOrderNo(),numMap.size()+1);
}
preloadDto.setOrderNo(orderInfo.getOrderNo());
preloadDto.setMarks(orderInfo.getMarks());
preloadDto.setProdTitleZh(item.getProdTitleZh()+ " " +item.getProdTitleEn());
preloadDto.setQuantity(item.getQuantityAll());
ProductBrankDO productBrank = productBrankService.getProductBrank(item.getBrand());
if(productBrank!=null && StringUtils.isNotBlank(productBrank.getTitleZh())){
preloadDto.setBrand(productBrank.getTitleZh());
}
if(productBrank !=null && productBrank.getFiling()!=null){
preloadDto.setProductRecord(productBrank.getFiling().equals("0")? "N":"Y");
}
List<ProductAttrDO> productAttrDOList = productAttrService.getProductAttrList();
Map<String, String> idNameMap = productAttrDOList.stream()
.collect(Collectors.toMap(attr -> String.valueOf(attr.getId()), ProductAttrDO::getAttrName));
preloadDto.setProdAttr(getAttrNameByIds(item.getProdAttrIds(),idNameMap));
if(orderInfo.getCustomsType()!=null){
preloadDto.setCustomsType(DictFrameworkUtils.getDictDataFromCache("customs_type",orderInfo.getCustomsType()+"").getLabel());
}
preloadDto.setSumNum(item.getCartonsNum());
preloadDto.setPackageType(DictFrameworkUtils.getDictDataFromCache("packaging_type",item.getUnit()).getLabel());
preloadDto.setBoxGauge(item.getBoxGauge());
preloadDto.setSumVolume(item.getVolume());
preloadDto.setSumWeight(item.getWeight());
List<BoxPkgOrderDO> boxPkgOrderDOS =
boxPkgOrderService.selectList(BoxPkgOrderDO::getOrderId, orderId);
if (CollectionUtil.isNotEmpty(boxPkgOrderDOS)) {
preloadDto.setMergePkgNum(1);
BoxMergePkgDO boxMergePkg = boxMergePkgService.getBoxMergePkg(boxPkgOrderDOS.get(0).getPkgId());
preloadDto.setMergePkgBoxGauge(boxMergePkg.getPkgLength()+"*"+boxMergePkg.getPkgWidth()+"*"+boxMergePkg.getPkgHight());
preloadDto.setMergePkgVolume(boxMergePkg.getSumVolume());
preloadDto.setMergePkgWeight(boxMergePkg.getSumWeight());
preloadDto.setMergePkgQua(map.get(String.valueOf(boxMergePkg.getId())));
preloadDto.setMergePkgCode(boxMergePkg.getPkgNum());
if (mergeVolumnMap.get(String.valueOf(boxMergePkg.getId())) == null) {
mergeVolumnMap.put(String.valueOf(boxMergePkg.getId()),boxMergePkg.getSumVolume());
}
if (mergeWeightMap.get(String.valueOf(boxMergePkg.getId())) == null) {
mergeWeightMap.put(String.valueOf(boxMergePkg.getId()),boxMergePkg.getSumWeight());
}
if (mergeQualityMap.get(String.valueOf(boxMergePkg.getId())) == null) {
mergeQualityMap.put(String.valueOf(boxMergePkg.getId()),map.get(String.valueOf(boxMergePkg.getId())));
}
} else {
sumMergeCount = sumMergeCount + item.getCartonsNum();
preloadDto.setMergePkgNum(item.getCartonsNum());
preloadDto.setMergePkgBoxGauge(item.getBoxGauge());
preloadDto.setMergePkgVolume(item.getVolume());
preloadDto.setMergePkgWeight(item.getWeight());
if (item.getQuantityAll() == null) {
preloadDto.setMergePkgQua(null);
} else {
preloadDto.setMergePkgQua(item.getQuantityAll());
totalMergeQuality = totalMergeQuality + item.getQuantityAll();
}
preloadDto.setMergePkgCode(orderInfo.getOrderNo());
totalMergeVolume = totalMergeVolume.add(item.getVolume());
totalMergeWeight = totalMergeWeight.add(item.getWeight());
}
if(StringUtils.isNotBlank(item.getMaterial())){
preloadDto.setMaterial(DictFrameworkUtils.getDictDataFromCache("product_material",item.getMaterial()+"").getLabel());
}
preloadDto.setUsageIds(getUsageMsg(item.getUsageIds()));
BigDecimal totalWorth = orderInfo.getOrderItemVOList().stream().map(OrderItemBackVO::getWorth).reduce(BigDecimal.ZERO, BigDecimal::add);
preloadDto.setWorth(totalWorth);
preloadDto.setTotalVolume(orderDO.getSumVolumeFinishedWarehouseIn().compareTo(BigDecimal.ZERO) == 0 ? orderInfo.getSumVolume():orderDO.getSumVolumeFinishedWarehouseIn());
preloadDto.setTotalWeight(orderDO.getSumWeightFinishedWarehouseIn().compareTo(BigDecimal.ZERO) == 0 ? orderInfo.getSumWeight():orderDO.getSumWeightFinishedWarehouseIn());
preloadDtoList.add(preloadDto);
if (StringUtils.isNotBlank(item.getOrderWarehouseInDetails())) {
item.setOrderWarehouseInDetailsVOList(JsonUtils.parseArray(item.getOrderWarehouseInDetails(), OrderWarehouseInDetailsVO.class));
}
......@@ -337,34 +319,9 @@ public class ShipmentLoadExcelExportListener2 {
List<OrderWarehouseInDetailsVO> orderWarehouseInDetailsVOList =
item.getOrderWarehouseInDetailsVOList();
for (int j = 0; j < orderWarehouseInDetailsVOList.size(); j++) {
OrderWarehouseInDetailsVO orderWarehouseInDetailsVO = orderWarehouseInDetailsVOList.get(j);
int andIncrement1 = colorRowNum.getAndIncrement();
colorMap.put(String.valueOf(andIncrement1),colorList.get(colorIndex));
colorRowList.add(andIncrement1);
AirLoadDto preloadDto1 = new AirLoadDto();
BeanUtil.copyProperties(preloadDto,preloadDto1);
ProductBrankDO productBrankDetail = productBrankService.getProductBrank(orderWarehouseInDetailsVO.getBrand());
if(productBrankDetail!=null && StringUtils.isNotBlank(productBrankDetail.getTitleZh())){
preloadDto1.setBrand(productBrankDetail.getTitleZh());
}
if(productBrank !=null && productBrank.getFiling()!=null){
preloadDto1.setProductRecord(productBrank.getFiling().equals("0")? "N":"Y");
}
preloadDto1.setQuantity(orderWarehouseInDetailsVO.getQuantityAll());
if (StringUtils.isNotBlank(orderWarehouseInDetailsVO.getMaterial())) {
preloadDto1.setMaterial(DictFrameworkUtils.getDictDataFromCache("product_material",orderWarehouseInDetailsVO.getMaterial()+"").getLabel());
}
preloadDto1.setProdAttr(getAttrNameByIds(orderWarehouseInDetailsVO.getProdAttrIds(),idNameMap));
// if (StringUtils.isNotBlank(orderWarehouseInDetailsVO.getUnit())) {
// preloadDto1.setPackageType(DictFrameworkUtils.getDictDataFromCache("packaging_type",orderWarehouseInDetailsVO.getUnit()).getLabel());
// }
preloadDto1.setUsageIds(getUsageMsg(orderWarehouseInDetailsVO.getUsageIds()));
// preloadDto1.setNumber(orderWarehouseInDetailsVO.getExpressNo());
ProductDO product = productService.getProduct(orderWarehouseInDetailsVO.getProdId());
if (product != null) {
preloadDto1.setProdTitleZh(product.getTitleZh() + "" + product.getTitleEn());
}
preloadDtoList.add(preloadDto1);
}
}
mergeCountList.add(mergeCount);
......@@ -373,110 +330,158 @@ public class ShipmentLoadExcelExportListener2 {
} 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);
}
}
//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))
//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))
.registerWriteHandler(new CustomMergeStrategy(orderMap, null, null, 14, true))
.automaticMergeHead(true).head(headList).needHead(true).build();
for (Map.Entry<Long, List<BoxPreloadGoodsBackVO>> entry : orderMap.entrySet()) {
Long orderId = entry.getKey();
OrderBackInfoDto orderInfo = orderQueryService.info(orderId);
List<BoxPreloadGoodsBackVO> boxPreload = entry.getValue();
List<OrderItemDO> orderItems =
boxPreload.stream().map(item -> orderItemService.
getOrderItem(item.getOrderItemId())).
collect(Collectors.toList());
for (OrderItemDO item : orderItems) {
List<OrderWarehouseInDO> orderWarehouseInDOS =
orderWarehouseInService.selectList(
OrderWarehouseInDO::getOrderItemId,
item.getOrderItemId());
LoadDto preloadDto = new LoadDto();
preloadDto.setOrderNo(orderInfo.getOrderNo());
if (numMap.get(orderInfo.getOrderNo()) != null) {
preloadDto.setId(String.valueOf(numMap.get(orderInfo.getOrderNo())));
} else {
mergePkgCountMap.put(String.valueOf(item.getId()),mergeCount);
preloadDto.setId(String.valueOf(numMap.size() + 1));
numMap.put(orderInfo.getOrderNo(), numMap.size() + 1);
}
preloadDto.setMarks(orderInfo.getMarks());
List<OrderGuanlianDO> guanlianList =
orderGuanlianService.getGuanlianListByOrderId(
orderInfo.getOrderId());
//rIdList为此订单的所有关联订单
List<Long> rIdList = new ArrayList<>();
for (OrderGuanlianDO orderGuanlianDO : guanlianList) {
Long oId = orderGuanlianDO.getOrderId();
Long rId = orderGuanlianDO.getRelateOrderId();
if (oId.equals(orderId)) {
rIdList.add((rId));
} else if (rId.equals(orderId)) {
rIdList.add(oId);
}
}
if (CollectionUtil.isNotEmpty(rIdList)) {
List<OrderDO> orderDOS =
orderService.selectList(OrderDO::getOrderId, rIdList);
if (CollectionUtil.isNotEmpty(orderDOS)) {
preloadDto.setRelateOrder(orderDOS.stream().map(
OrderDO::getOrderNo).collect(Collectors.joining(",")));
}
}
preloadDto.setProdTitleZh(item.getProdTitleZh() + " " + item.getProdTitleEn());
preloadDto.setMerge(orderInfo.getOldNumbers());
ProductBrankDO productBrank =
productBrankService.getProductBrank(item.getBrand());
if (productBrank != null && StringUtils.isNotBlank(productBrank.getTitleZh())) {
preloadDto.setBrand(productBrank.getTitleZh());
}
int sumNum = orderWarehouseInBackItemVOS.stream().mapToInt(j -> {
if (j.getOrderWarehouseInDetailsVOList() == null) {
return 0;
} else {
int sum = j.getOrderWarehouseInDetailsVOList().stream().mapToInt(vo -> Objects.isNull(vo.getCartonsNum()) ? 0 : vo.getCartonsNum()).sum();
return sum;
//材质
if (StringUtils.isNotBlank(item.getMaterial())) {
preloadDto.setMaterial(
DictFrameworkUtils.getDictDataFromCache("product_material",
item.getMaterial() + "").getLabel());
}
}).sum();
BigDecimal sumVolume = orderWarehouseInBackItemVOS.stream().map(j -> {
if (j.getOrderWarehouseInDetailsVOList() == null) {
return BigDecimal.ZERO;
} else {
BigDecimal decimal = j.getOrderWarehouseInDetailsVOList().stream().map(vo -> Objects.isNull(vo.getVolume()) ? BigDecimal.ZERO : vo.getVolume()).reduce(BigDecimal.ZERO, BigDecimal::add);
return decimal;
//品牌
if (productBrank != null && productBrank.getFiling() != null) {
preloadDto.setProductRecord(productBrank.getFiling().equals("0") ? "N" : "Y");
}
}).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal sumWeight = orderWarehouseInBackItemVOS.stream().map(j -> {
if (j.getOrderWarehouseInDetailsVOList() == null) {
return BigDecimal.ZERO;
//用途
if (item.getUsageIds() == null || item.getUsageIds().length() == 0) {
preloadDto.setUsageIds("");
} else {
BigDecimal decimal = j.getOrderWarehouseInDetailsVOList().stream().map(vo -> Objects.isNull(vo.getWeight()) ? BigDecimal.ZERO : vo.getWeight()).reduce(BigDecimal.ZERO, BigDecimal::add);
return decimal;
}
}).reduce(BigDecimal.ZERO, BigDecimal::add);
totalNum = totalNum + sumNum;
totalVolume = totalVolume.add(sumVolume);
totalWeight = totalWeight.add(sumWeight);
totalNum = totalNum + orderInfo.getSumNum();
totalVolume = totalVolume.add(orderInfo.getSumVolume());
totalWeight = totalWeight.add(orderInfo.getSumWeight());
}
AirLoadDto preloadDto = new AirLoadDto();
BigDecimal volumeReduce = mergeVolumnMap.values().stream().reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal weightReduce = mergeWeightMap.values().stream().reduce(BigDecimal.ZERO, BigDecimal::add);
totalMergeVolume = totalMergeVolume.add(volumeReduce);
totalMergeWeight = totalMergeWeight.add(weightReduce);
Integer qualityReduce = mergeQualityMap.values().stream().reduce(0, Integer::sum);
totalMergeQuality = totalMergeQuality + qualityReduce.intValue();
//在缓存数据字典中获取用途信息
String sUserdName = DictFrameworkUtils.getDictDataFromCache(
"order_item_usage",
item.getUsageIds() + "").getLabel();
preloadDto.setUsageIds(sUserdName);
}
//商品特性赋值 lanbm 2024-06-05 add
String sR = getAttrName(item, ProductAttrMap);
preloadDto.setProdAttrIds(sR);
preloadDto.setSumNum(item.getWarehouseInInfoVO().getCartonsNum());
if (CollectionUtil.isNotEmpty(orderWarehouseInDOS)) {
String warehousingSpecificationType = orderWarehouseInDOS.stream().map(j -> {
return DictFrameworkUtils.getDictDataFromCache("warehousing_specification_type", j.getSpecificationType() + "").getLabel();
}).distinct().collect(Collectors.joining("/"));
String packagingType = orderWarehouseInDOS.stream().map(j -> {
return DictFrameworkUtils.getDictDataFromCache("packaging_type", j.getUnit()).getLabel();
}).distinct().collect(Collectors.joining("/"));
preloadDto.setUnit(warehousingSpecificationType);
preloadDto.setPackageType(packagingType);
}
preloadDto.setSumVolume(item.getWarehouseInInfoVO().getVolume());
preloadDto.setSumWeight(item.getWarehouseInInfoVO().getWeight());
if (orderInfo.getCustomsType() != null) {
preloadDto.setCustomsType(
DictFrameworkUtils.getDictDataFromCache("customs_type",
orderInfo.getCustomsType() + "").getLabel());
}
preloadDto.setWorth(item.getWorth());
preloadDto.setQuantity(item.getWarehouseInInfoVO().getQuantityAll());
list.add(preloadDto);
totalNum = totalNum + item.getWarehouseInInfoVO().getCartonsNum();
totalVolume = totalVolume.add(item.getWarehouseInInfoVO().getVolume());
totalWeight = totalWeight.add(item.getWarehouseInInfoVO().getWeight());
}
}
LoadDto preloadDto = new LoadDto();
preloadDto.setId("TOTAL");
preloadDto.setSumNum(totalNum);
preloadDto.setSumVolume(totalVolume);
preloadDto.setSumWeight(totalWeight);
preloadDto.setMergePkgNum(sumMergeCount);
preloadDto.setMergePkgVolume(totalMergeVolume);
preloadDto.setMergePkgWeight(totalMergeWeight);
preloadDto.setMergePkgQua(totalMergeQuality);
preloadDtoList.add(preloadDto);
list.add(preloadDto);
allTotalNum = allTotalNum + totalNum;
allTotalVolume = allTotalVolume.add(totalVolume);
allTotalWeight = allTotalWeight.add(totalWeight);
//2023-12-19 客户要求空运已装单取消一个总计,因为海运分部分有总计 空运不分部分
// if(i==secCount.size()-1){
// AirLoadDto preloadDto1 = new AirLoadDto();
// preloadDto1.setId("IN TOTAL");
// preloadDto1.setSumNum(allTotalNum);
// preloadDto1.setSumVolume(allTotalVolume);
// preloadDto1.setSumWeight(allTotalWeight);
// preloadDtoList.add(preloadDto1);
// }
List<Integer> mergePkgCountList = mergePkgCountMap.entrySet().stream().map(Map.Entry::getValue).collect(Collectors.toList());
WriteTable writeTable = EasyExcel.writerTable(i)
.registerWriteHandler(new CustomAirLoadMergeStrategyNew(preloadDtoList,mergeCountList,colorRowList,null,0,1))
.registerWriteHandler(new CustomAirLoadMergeStrategyNew(preloadDtoList,mergeCountList,colorRowList,null,1,1))
.registerWriteHandler(new CustomAirLoadMergeStrategyNew(preloadDtoList,mergeCountList,colorRowList,null,2,1))
.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 CustomAirLoadMergeStrategyNew(preloadDtoList,mergeCountList,colorRowList,null,8,1))
.registerWriteHandler(new CustomAirLoadMergeStrategyNew(preloadDtoList,mergeCountList,colorRowList,null,9,2))
.registerWriteHandler(new CustomAirLoadMergeStrategyNew(preloadDtoList,mergeCountList,colorRowList,null,10,2))
.registerWriteHandler(new CustomAirLoadMergeStrategyNew(preloadDtoList,mergeCountList,colorRowList,null,11,2))
// .registerWriteHandler(new CustomCellWriteHandler(colorRowList,11, colorMap))
.registerWriteHandler(new CustomAirLoadMergeStrategyNew(preloadDtoList,mergeCountList,colorRowList,null,12,2))
.registerWriteHandler(new CustomAirLoadMergeStrategyNew(preloadDtoList,mergeCountList,colorRowList,null,13,2))
.registerWriteHandler(new CustomAirLoadMergeStrategyNew(preloadDtoList,mergeCountList,colorRowList,mergePkgCountList,14,3))
.registerWriteHandler(new CustomAirLoadMergeStrategyNew(preloadDtoList,mergeCountList,colorRowList,mergePkgCountList,15,3))
.registerWriteHandler(new CustomAirLoadMergeStrategyNew(preloadDtoList,mergeCountList,colorRowList,mergePkgCountList,16,3))
.registerWriteHandler(new CustomAirLoadMergeStrategyNew(preloadDtoList,mergeCountList,colorRowList,mergePkgCountList,17,3))
.registerWriteHandler(new CustomAirLoadMergeStrategyNew(preloadDtoList,mergeCountList,colorRowList,mergePkgCountList,18,3))
.registerWriteHandler(new CustomAirLoadMergeStrategyNew(preloadDtoList,mergeCountList,colorRowList,mergePkgCountList,19,3))
// .registerWriteHandler(new CustomMergeStrategyNew(preloadDtoList,mergeCountList,colorRowList,20,1))
.registerWriteHandler(new CustomCellWriteHandler(colorRowList,20, colorMap))
.registerWriteHandler(new CustomCellWriteHandler(colorRowList,21, colorMap))
.registerWriteHandler(new CustomAirLoadMergeStrategyNew(preloadDtoList,mergeCountList,colorRowList,null,22,1))
.registerWriteHandler(new CustomAirLoadMergeStrategyNew(preloadDtoList,mergeCountList,colorRowList,null,23,1))
.registerWriteHandler(new CustomAirLoadMergeStrategyNew(preloadDtoList,mergeCountList,colorRowList,null,24,1))
.automaticMergeHead(true).head(headList).needHead(true).build();
excelWriter.write(preloadDtoList,sheet,writeTable);
if (i == secCount.size() - 1) {
LoadDto preloadDto1 = new LoadDto();
preloadDto1.setId("IN TOTAL");
preloadDto1.setSumNum(allTotalNum);
preloadDto1.setSumVolume(allTotalVolume);
preloadDto1.setSumWeight(allTotalWeight);
list.add(preloadDto1);
}
excelWriter.write(list, sheet, writeTable);
}
}
}
excelWriter.finish();
inputStream.close();
// 获取到临时文件
......@@ -494,8 +499,8 @@ public class ShipmentLoadExcelExportListener2 {
event.setFileName(fileDO.getPath());
event.setUrl(fileDO.getUrl());
event.setFileId(fileDO.getId());
} catch (Exception e) {
log.info("预装单导出失败",e);
e.printStackTrace();
event.setResult(e.getMessage());
}
......@@ -535,32 +540,5 @@ public class ShipmentLoadExcelExportListener2 {
//end lanbm 2024-06-05添加商品特性
return sReult;
}
private String getUsageMsg(String usageIdsDetail) {
if (StringUtils.isNotEmpty(usageIdsDetail)) {
StringJoiner labelJoiner = new StringJoiner(",");
for (String usageId : usageIdsDetail.split(",")) {
DictDataRespDTO usageValue = DictFrameworkUtils.getDictDataFromCache("order_item_usage", usageId);
if (usageValue != null) {
labelJoiner.add(usageValue.getLabel());
}
}
return labelJoiner.toString();
} else {
return "";
}
}
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 "";
}
}
......@@ -218,8 +218,7 @@ public class MakeBillOfLadingServiceImpl extends AbstractService<MakeBillOfLadin
if (null != createReqVO.getNeedBackend() && createReqVO.getNeedBackend()) {
OrderDO orderDo = orderService.getById(createReqVO.getOrderId());
OrderObjectiveDO orderObjectiveDO =
orderObjectiveService.getByOrderId(orderDo.getOrderId());
OrderObjectiveDO orderObjectiveDO = orderObjectiveService.getByOrderId(orderDo.getOrderId());
/*BoxDO box = boxService.getBox(shipmentId);
......@@ -265,8 +264,8 @@ public class MakeBillOfLadingServiceImpl extends AbstractService<MakeBillOfLadin
orderService.selectOne(OrderDO::getOrderId,
createReqVO.getOrderId());
//创建审批流
/* lanbm 2024-06-13 不创建审批流程
//lanbm 2024-06-13 取消流程的创建
/*
String bpmProcessId =
bpmCreateServiceFactory.createBmp(
SecurityFrameworkUtils.getLoginUserId(),
......@@ -276,7 +275,6 @@ public class MakeBillOfLadingServiceImpl extends AbstractService<MakeBillOfLadin
createReqVO.getCopyUserId());
makeBillOfLading.setBpmProcessId(bpmProcessId);
*/
//lanbm 2024-05-24 修改为自动审批通过
//ecw_make_bill_of_lading
/*
......
......@@ -193,7 +193,8 @@ public class MakeBillOfLadingController {
MakeBillOfLadingBackVO vResult =
MakeBillOfLadingConvert.INSTANCE.convert(lading);
//前端是根据 status 来判断的,此处逻辑可以不用理会
//lanbm 2024-06-13 添加注释
if (lading.getBpmProcessId() == null ||
lading.getBpmProcessId().length() == 0) {
vResult.setBpmStatus("-1");
......
......@@ -76,4 +76,9 @@ public class ReceiptItemReq extends PageParam {
*/
private String accountNo;
/*
审批状态 lanbm 2024-06-13 add
*/
private String status;
}
......@@ -17,6 +17,9 @@
<sql id="WherePage">
<where>
p.deleted=0
<if test="status != null and status != ''">
AND p.status=#{status}
</if>
<if test="accountNo != null and accountNo != ''">
AND p.account_no=#{accountNo}
</if>
......@@ -38,7 +41,7 @@
<!--收款明细提交审批日期-->
<if test="sDate2 != null and sDate2 != '' and
eDate2 != null and eDate2 != ''">
AND a.create_time BETWEEN #{sDate2} and #{eDate2})
AND a.create_time BETWEEN #{sDate2} and #{eDate2}
</if>
<!--收款明细提交审批通过日期-->
......
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