From 179f3389dd730ecd79cb6e9c8a1118b130454c73 Mon Sep 17 00:00:00 2001 From: liujiang <569804566@qq.com> Date: Sun, 19 Oct 2025 18:18:40 +0800 Subject: [PATCH] =?UTF-8?q?master=EF=BC=9A=E4=B8=8B=E8=BD=BDexcel=E8=B0=83?= =?UTF-8?q?=E4=BC=98=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/StoreProductStockServiceImpl.java | 16 ++++++++++++-- .../StoreProductStorageDetailServiceImpl.java | 21 +++++++++++++++++-- .../mapper/StoreProductStockMapper.xml | 2 -- .../StoreProductStorageDetailMapper.xml | 2 -- 4 files changed, 33 insertions(+), 8 deletions(-) diff --git a/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreProductStockServiceImpl.java b/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreProductStockServiceImpl.java index dad4dc81c..799879109 100644 --- a/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreProductStockServiceImpl.java +++ b/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreProductStockServiceImpl.java @@ -281,17 +281,29 @@ public class StoreProductStockServiceImpl implements IStoreProductStockService { if (!SecurityUtils.isAdmin() && !SecurityUtils.isStoreManagerOrSub(exportDTO.getStoreId())) { throw new ServiceException("当前用户非档口管理者或子账号,无权限操作!", HttpStatus.ERROR); } + List downloadList; // 导出勾选 if (CollectionUtils.isNotEmpty(exportDTO.getStoreProdStockIdList())) { - return this.storeProdStockMapper.selectExportList(exportDTO.getStoreProdStockIdList()); + downloadList = this.storeProdStockMapper.selectExportList(exportDTO.getStoreProdStockIdList()); // 导出所有库存明细 } else { Optional.ofNullable(exportDTO.getFullExport()) .orElseThrow(() -> new ServiceException("全量导出,fullExport不能为空!", HttpStatus.ERROR)); List prodColorList = this.prodColorMapper.selectList(new LambdaQueryWrapper() .eq(StoreProductColor::getStoreId, exportDTO.getStoreId()).eq(StoreProductColor::getDelFlag, Constants.UNDELETED)); - return this.storeProdStockMapper.selectAllStockList(prodColorList.stream().map(StoreProductColor::getId).collect(Collectors.toList())); + downloadList = this.storeProdStockMapper.selectAllStockList(prodColorList.stream().map(StoreProductColor::getId).collect(Collectors.toList())); } + // 根据prod_art_num相同设置orderNum相同 + int orderNum = 1; + String currentCode = downloadList.get(0).getProdArtNum(); + for (int i = 0; i < downloadList.size(); i++) { + if (!currentCode.equals(downloadList.get(i).getProdArtNum())) { + currentCode = downloadList.get(i).getProdArtNum(); + orderNum++; + } + downloadList.get(i).setOrderNum(orderNum); + } + return downloadList; } diff --git a/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreProductStorageDetailServiceImpl.java b/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreProductStorageDetailServiceImpl.java index c360cec90..ac54c090c 100644 --- a/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreProductStorageDetailServiceImpl.java +++ b/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreProductStorageDetailServiceImpl.java @@ -20,6 +20,7 @@ import org.springframework.transaction.annotation.Transactional; import java.time.LocalDate; import java.time.ZoneId; import java.time.temporal.ChronoUnit; +import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; @@ -49,8 +50,9 @@ public class StoreProductStorageDetailServiceImpl implements IStoreProductStorag if (!SecurityUtils.isAdmin() && !SecurityUtils.isStoreManagerOrSub(exportDTO.getStoreId())) { throw new ServiceException("当前用户非档口管理者或子账号,无权限操作!", HttpStatus.ERROR); } + List downloadList; if (CollectionUtils.isNotEmpty(exportDTO.getStoreProdStorageIdList())) { - return this.storageDetailMapper.selectExportList(exportDTO); + downloadList = this.storageDetailMapper.selectExportList(exportDTO); } else { // 没有传时间,则设置当前时间往前推半年 if (ObjectUtils.isEmpty(exportDTO.getVoucherDateStart()) && ObjectUtils.isEmpty(exportDTO.getVoucherDateEnd())) { @@ -73,7 +75,22 @@ public class StoreProductStorageDetailServiceImpl implements IStoreProductStorag List storeProdList = this.storeProdMapper.selectList(new LambdaQueryWrapper() .eq(StoreProduct::getStoreId, exportDTO.getStoreId()).eq(StoreProduct::getDelFlag, Constants.UNDELETED)); exportDTO.setStoreProdIdList(storeProdList.stream().map(StoreProduct::getId).collect(Collectors.toList())); - return this.storageDetailMapper.selectExportListVoucherDateBetween(exportDTO); + downloadList = this.storageDetailMapper.selectExportListVoucherDateBetween(exportDTO); } + if (CollectionUtils.isEmpty(downloadList)) { + return new ArrayList<>(); + } + // 根据code相同设置orderNum相同 + int orderNum = 1; + String currentCode = downloadList.get(0).getCode(); + for (int i = 0; i < downloadList.size(); i++) { + if (!currentCode.equals(downloadList.get(i).getCode())) { + currentCode = downloadList.get(i).getCode(); + orderNum++; + } + downloadList.get(i).setOrderNum(orderNum); + } + return downloadList; } + } diff --git a/xkt/src/main/resources/mapper/StoreProductStockMapper.xml b/xkt/src/main/resources/mapper/StoreProductStockMapper.xml index 1940a181d..326fe4441 100644 --- a/xkt/src/main/resources/mapper/StoreProductStockMapper.xml +++ b/xkt/src/main/resources/mapper/StoreProductStockMapper.xml @@ -96,7 +96,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" SELECT - DENSE_RANK() OVER ( ORDER BY sps.create_time ) AS orderNum, sps.prod_art_num, sps.color_name, sps.size_30 AS size30Quantity, diff --git a/xkt/src/main/resources/mapper/StoreProductStorageDetailMapper.xml b/xkt/src/main/resources/mapper/StoreProductStorageDetailMapper.xml index 2a3287e37..cddcf6ce0 100644 --- a/xkt/src/main/resources/mapper/StoreProductStorageDetailMapper.xml +++ b/xkt/src/main/resources/mapper/StoreProductStorageDetailMapper.xml @@ -6,7 +6,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" SELECT - DENSE_RANK() OVER (ORDER BY sps.code, sps.create_time) AS orderNum, sps.`code`, sf.fac_name, sps.create_time,