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