master:下载excel调优;

pull/1121/head
liujiang 2025-10-19 18:18:40 +08:00
parent 4d45bfe75a
commit 179f3389dd
4 changed files with 33 additions and 8 deletions

View File

@ -281,17 +281,29 @@ public class StoreProductStockServiceImpl implements IStoreProductStockService {
if (!SecurityUtils.isAdmin() && !SecurityUtils.isStoreManagerOrSub(exportDTO.getStoreId())) {
throw new ServiceException("当前用户非档口管理者或子账号,无权限操作!", HttpStatus.ERROR);
}
List<StoreProdStockDownloadDTO> 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<StoreProductColor> prodColorList = this.prodColorMapper.selectList(new LambdaQueryWrapper<StoreProductColor>()
.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;
}

View File

@ -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<StoreStorageDetailDownloadDTO> 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<StoreProduct> storeProdList = this.storeProdMapper.selectList(new LambdaQueryWrapper<StoreProduct>()
.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;
}
}

View File

@ -96,7 +96,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectExportList" resultType="com.ruoyi.xkt.dto.storeProductStock.StoreProdStockDownloadDTO">
SELECT
DENSE_RANK() OVER ( ORDER BY sps.create_time ) AS orderNum,
sps.prod_art_num,
sps.color_name,
sps.size_30 AS size30Quantity,
@ -131,7 +130,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectAllStockList" resultType="com.ruoyi.xkt.dto.storeProductStock.StoreProdStockDownloadDTO">
SELECT
DENSE_RANK() OVER ( ORDER BY sps.create_time ) AS orderNum,
sps.prod_art_num,
sps.color_name,
sps.size_30 AS size30Quantity,

View File

@ -6,7 +6,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectExportList" resultType="com.ruoyi.xkt.dto.storeProdStorage.StoreStorageDetailDownloadDTO">
SELECT
DENSE_RANK() OVER (ORDER BY sps.code, sps.create_time) AS orderNum,
sps.`code`,
sf.fac_name,
sps.create_time,
@ -62,7 +61,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectExportListVoucherDateBetween" resultType="com.ruoyi.xkt.dto.storeProdStorage.StoreStorageDetailDownloadDTO">
SELECT
DENSE_RANK() OVER (ORDER BY sps.code, sps.create_time) AS orderNum,
sps.`code`,
sf.fac_name,
sps.create_time,