From e717df69babf932e1205fc3c95498e35409445f7 Mon Sep 17 00:00:00 2001 From: dzc <2388224167@qq.com> Date: Mon, 20 Oct 2025 19:02:02 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E9=99=90=E5=88=B6=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datascope/SelectCountByScope.java | 4 +- .../WalletTransactionController.java | 35 ++++++++++++--- .../WalletRechargeImportController.java | 8 +++- .../rule/WalletRuleTransactionController.java | 6 --- .../wallet/mapper/WalletManageMapper.java | 4 ++ .../mapper/WalletTransactionMapper.java | 45 +++++-------------- .../recharge/WalletRechargeImportMapper.java | 2 + .../service/impl/WalletManageServiceImpl.java | 5 ++- .../impl/WalletTransactionServiceImpl.java | 6 ++- .../recharge/WalletRechargeImportMapper.xml | 22 +++++++++ 10 files changed, 87 insertions(+), 50 deletions(-) diff --git a/pjcloud-common/pjcloud-common-data/src/main/java/com/bsd/pjcloud/common/data/datascope/SelectCountByScope.java b/pjcloud-common/pjcloud-common-data/src/main/java/com/bsd/pjcloud/common/data/datascope/SelectCountByScope.java index 8b91ff22d..2dac2ff84 100644 --- a/pjcloud-common/pjcloud-common-data/src/main/java/com/bsd/pjcloud/common/data/datascope/SelectCountByScope.java +++ b/pjcloud-common/pjcloud-common-data/src/main/java/com/bsd/pjcloud/common/data/datascope/SelectCountByScope.java @@ -20,9 +20,9 @@ public class SelectCountByScope extends AbstractMethod { @Override public MappedStatement injectMappedStatement(Class mapperClass, Class modelClass, TableInfo tableInfo) { - SqlMethod sqlMethod = SqlMethod.SELECT_LIST; + SqlMethod sqlMethod = SqlMethod.SELECT_COUNT; - String sql = String.format(sqlMethod.getSql(), this.sqlFirst(), this.sqlSelectColumns(tableInfo, true), + String sql = String.format(sqlMethod.getSql(), this.sqlFirst(), "*", tableInfo.getTableName(), this.sqlWhereEntityWrapper(true, tableInfo), this.sqlOrderBy(tableInfo), this.sqlComment()); SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass); diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/WalletTransactionController.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/WalletTransactionController.java index 5c79e3515..7aea54866 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/WalletTransactionController.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/WalletTransactionController.java @@ -189,7 +189,12 @@ public class WalletTransactionController { public void exportCz(HttpServletResponse response, @RequestBody WalletTransactionDto dto) { dto.setBizTypes(WalletBizEnum.getTopUpCodes()); dto.setType(WalletTransactionDto.TYPE_INCOME); - List list = walletTransactionService.scopeList(dto, DataScope.of()); + + DataScope dataScope = DataScope.of(); + Long count = walletTransactionMapper.count(dto, dataScope); + if (count > 5000) throw new RuntimeException("导出数据超出5000条,请缩小查询范围"); + + List list = walletTransactionService.scopeList(dto, dataScope); walletTransactionService.exportByTemplate(response, dto, "file/个人充值明细.xlsx", list); } @@ -199,7 +204,12 @@ public class WalletTransactionController { public void exportJz(HttpServletResponse response, @RequestBody WalletTransactionDto dto) { dto.setBizTypes(WalletBizEnum.getTopUpCodes()); dto.setType(WalletTransactionDto.TYPE_EXPENSE); - List list = walletTransactionService.scopeList(dto, DataScope.of()); + + DataScope dataScope = DataScope.of(); + Long count = walletTransactionMapper.count(dto, dataScope); + if (count > 5000) throw new RuntimeException("导出数据超出5000条,请缩小查询范围"); + + List list = walletTransactionService.scopeList(dto, dataScope); walletTransactionService.exportByTemplate(response, dto, "file/个人记账扣款明细.xlsx", list); } @@ -209,7 +219,12 @@ public class WalletTransactionController { @PreAuthorize("@pms.hasPermission('wallet_walletTransaction_export')") public void exportXf(HttpServletResponse response, @RequestBody WalletTransactionDto dto) { dto.setBizTypes(List.of(WalletBizEnum.PAYMENT.getCode())); - List list = walletTransactionService.scopeList(dto, DataScope.of()); + + DataScope dataScope = DataScope.of(); + Long count = walletTransactionMapper.count(dto, dataScope); + if (count > 5000) throw new RuntimeException("导出数据超出5000条,请缩小查询范围"); + + List list = walletTransactionService.scopeList(dto, dataScope); walletTransactionService.exportByTemplate(response, dto, "file/个人消费明细.xlsx", list); } @@ -219,7 +234,12 @@ public class WalletTransactionController { public void exportTk(HttpServletResponse response, @RequestBody WalletTransactionDto dto) { dto.setBizTypes(List.of(WalletBizEnum.REFUND.getCode())); dto.setIsFindOrder(true); - List list = walletTransactionService.scopeList(dto, DataScope.of()); + + DataScope dataScope = DataScope.of(); + Long count = walletTransactionMapper.count(dto, dataScope); + if (count > 5000) throw new RuntimeException("导出数据超出5000条,请缩小查询范围"); + + List list = walletTransactionService.scopeList(dto, dataScope); walletTransactionService.exportByTemplate(response, dto, "file/个人退款明细.xlsx", list); } @@ -229,7 +249,12 @@ public class WalletTransactionController { public void exportTh(HttpServletResponse response, @RequestBody WalletTransactionDto dto) { dto.setBizTypes(List.of(WalletBizEnum.RETURN_CANTEEN.getCode())); dto.setIsFindOrder(false); - List list = walletTransactionService.scopeList(dto, DataScope.of()); + + DataScope dataScope = DataScope.of(); + Long count = walletTransactionMapper.count(dto, dataScope); + if (count > 5000) throw new RuntimeException("导出数据超出5000条,请缩小查询范围"); + + List list = walletTransactionService.scopeList(dto, dataScope); walletTransactionService.exportByTemplate(response, dto, "file/退还各自食堂明细.xlsx", list); } } \ No newline at end of file diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/recharge/WalletRechargeImportController.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/recharge/WalletRechargeImportController.java index 73e65d66f..4f96418b2 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/recharge/WalletRechargeImportController.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/recharge/WalletRechargeImportController.java @@ -12,6 +12,7 @@ import com.alibaba.excel.write.metadata.fill.FillConfig; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.bsd.pjcloud.common.core.exception.ServiceException; import com.bsd.pjcloud.common.core.util.R; import com.bsd.pjcloud.common.data.datascope.DataScope; import com.bsd.pjcloud.common.idempotent.annotation.Idempotent; @@ -21,6 +22,7 @@ import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum; import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeImportDto; import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeImportEntity; import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeImportVo; +import com.bsd.pjcloud.wallet.mapper.recharge.WalletRechargeImportMapper; import com.bsd.pjcloud.wallet.service.WalletRechargeImportService; import jakarta.servlet.http.HttpServletResponse; import org.springframework.security.access.prepost.PreAuthorize; @@ -54,6 +56,7 @@ import java.util.Map; public class WalletRechargeImportController { private final WalletRechargeImportService walletRechargeImportService; + private final WalletRechargeImportMapper walletRechargeImportMapper; @Operation(summary = "恢复", description = "恢复") @Idempotent(expireTime = 5, info = "正在处理中,请勿重复操作") @@ -113,7 +116,10 @@ public class WalletRechargeImportController { @PostMapping("/export") @PreAuthorize("@pms.hasPermission('wallet_walletRechargeImport_export')") public void export(HttpServletResponse response, @RequestBody WalletRechargeImportDto dto) throws IOException { - List list = walletRechargeImportService.scopeList(dto, DataScope.of()); + DataScope dataScope = DataScope.of(); + Long count = walletRechargeImportMapper.count(dto, dataScope); + if (count > 5000) throw new RuntimeException("导出数据超出5000条,请缩小查询范围"); + List list = walletRechargeImportService.scopeList(dto, dataScope); try (ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).withTemplate(ResourceUtil.getStream("file/批量充值扣款流水明细.xlsx")).build()) { WriteSheet writeSheet = EasyExcel.writerSheet().build(); FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build(); diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/rule/WalletRuleTransactionController.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/rule/WalletRuleTransactionController.java index 0ab63623c..f707a112c 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/rule/WalletRuleTransactionController.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/rule/WalletRuleTransactionController.java @@ -148,10 +148,4 @@ public class WalletRuleTransactionController { return R.ok(walletRuleTransactionService.removeBatchByIds(CollUtil.toList(ids))); } - @ResponseExcel - @GetMapping("/export") - @PreAuthorize("@pms.hasPermission('wallet_walletRuleTransaction_export')") - public List export(WalletRuleTransactionEntity walletRuleTransaction, Long[] ids) { - return walletRuleTransactionService.list(Wrappers.lambdaQuery(walletRuleTransaction).in(ArrayUtil.isNotEmpty(ids), WalletRuleTransactionEntity::getId, ids)); - } } \ No newline at end of file diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/WalletManageMapper.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/WalletManageMapper.java index fc1774cf9..84ddbdf51 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/WalletManageMapper.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/WalletManageMapper.java @@ -153,6 +153,10 @@ public interface WalletManageMapper extends PjcloudBaseMapper scopeList(WalletManageDto dto, DataScope dataScope) { List list = selectListByScope(commonQuery(dto), dataScope); return BeanUtils.toBean(list, WalletManageVo.class); diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/WalletTransactionMapper.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/WalletTransactionMapper.java index b124fe95a..053c1b5ff 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/WalletTransactionMapper.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/WalletTransactionMapper.java @@ -26,7 +26,7 @@ import java.util.Objects; @Mapper public interface WalletTransactionMapper extends PjcloudBaseMapper { - default Page scopePageList(Page page, WalletTransactionDto dto, DataScope dataScope) { + default LambdaQueryWrapper commonWrapperQuery(WalletTransactionDto dto) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper() .eq(ObjectUtil.isNotEmpty(dto.getWalletId()), WalletTransactionEntity::getWalletId, dto.getWalletId()) .eq(ObjectUtil.isNotEmpty(dto.getBizType()), WalletTransactionEntity::getBizType, dto.getBizType()) @@ -58,47 +58,24 @@ public interface WalletTransactionMapper extends PjcloudBaseMapper scopePageList(Page page, WalletTransactionDto dto, DataScope dataScope) { + Page list = selectPageByScope(page, commonWrapperQuery(dto), dataScope); list.setRecords(BeanUtils.toBean(list.getRecords(), WalletTransactionVo.class)); return list; } default List scopeList(WalletTransactionDto dto, DataScope dataScope) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper() - .eq(ObjectUtil.isNotEmpty(dto.getWalletId()), WalletTransactionEntity::getWalletId, dto.getWalletId()) - .eq(ObjectUtil.isNotEmpty(dto.getBizType()), WalletTransactionEntity::getBizType, dto.getBizType()) - .eq(ObjectUtil.isNotEmpty(dto.getUserId()), WalletTransactionEntity::getUserId, dto.getUserId()) - .eq(ObjectUtil.isNotEmpty(dto.getDeptId()), WalletTransactionEntity::getDeptId, dto.getDeptId()) - .in(ObjectUtil.isNotEmpty(dto.getUserIds()), WalletTransactionEntity::getUserId, dto.getUserIds()) - .in(ObjectUtil.isNotEmpty(dto.getBizTypes()), WalletTransactionEntity::getBizType, dto.getBizTypes()) - .between( - ObjectUtil.isNotEmpty(dto.getCreateTimeList()), - WalletTransactionEntity::getCreateTime, - ObjectUtil.isNotEmpty(dto.getCreateTimeList()) ? dto.getCreateTimeList()[0] : null, - ObjectUtil.isNotEmpty(dto.getCreateTimeList()) ? dto.getCreateTimeList()[1] : null - ) - .orderByDesc(WalletTransactionEntity::getCreateTime) - .orderByDesc(WalletTransactionEntity::getUserId); - if (ObjectUtil.isNotEmpty(dto.getIsInclude())) { - if (dto.getIsInclude()) { - wrapper.in(ObjectUtil.isNotEmpty(dto.getDeptIds()), WalletTransactionEntity::getDeptId, - dto.getDeptIds()); - } else { - wrapper.notIn(ObjectUtil.isNotEmpty(dto.getDeptIds()), WalletTransactionEntity::getDeptId, - dto.getDeptIds()); - } - } else { - wrapper.in(ObjectUtil.isNotEmpty(dto.getDeptIds()), WalletTransactionEntity::getDeptId, dto.getDeptIds()); - } - if (ObjectUtil.equals(dto.getType(), WalletTransactionDto.TYPE_INCOME)) { - wrapper.gt(WalletTransactionEntity::getPrice, 0); - } else if (Objects.equals(dto.getType(), WalletTransactionDto.TYPE_EXPENSE)) { - wrapper.lt(WalletTransactionEntity::getPrice, 0); - } - List list = selectListByScope(wrapper, dataScope); + List list = selectListByScope(commonWrapperQuery(dto), dataScope); return BeanUtils.toBean(list, WalletTransactionVo.class); } + default Long count(WalletTransactionDto dto, DataScope dataScope) { + return selectCountByScope(commonWrapperQuery(dto), dataScope); + } + Page scopeJzPageList(Page page, @Param("dto") WalletTransactionDto dto, DataScope dataScope); Integer getTransactionPriceCount(@Param("month") String importTimeStr, @Param("walletId") Long walletId, diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/recharge/WalletRechargeImportMapper.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/recharge/WalletRechargeImportMapper.java index 2082ea2f5..7d7a70c58 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/recharge/WalletRechargeImportMapper.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/recharge/WalletRechargeImportMapper.java @@ -21,6 +21,8 @@ public interface WalletRechargeImportMapper extends PjcloudBaseMapper scopeList(@Param("dto") WalletRechargeImportDto dto, DataScope dataScope); + Long count(@Param("dto") WalletRechargeImportDto dto, DataScope dataScope); + default Page pageJoin(Page page, WalletRechargeImportDto dto) { MPJLambdaWrapper wrapper = new MPJLambdaWrapper() .eqIfExists(WalletRechargeImportEntity::getId, dto.getId()) diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/WalletManageServiceImpl.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/WalletManageServiceImpl.java index 122145ffa..b9d39667c 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/WalletManageServiceImpl.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/WalletManageServiceImpl.java @@ -399,7 +399,10 @@ public class WalletManageServiceImpl extends ServiceImpl list = scopeList(dto, DataScope.of()); + DataScope dataScope = DataScope.of(); + Long count = baseMapper.count(dto, dataScope); + if (count > 5000) throw new RuntimeException("导出数据超出5000条,请缩小查询范围"); + List list = scopeList(dto, dataScope); try (ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).withTemplate(ResourceUtil.getStream(fileName)).build()) { WriteSheet writeSheet = EasyExcel.writerSheet().build(); FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build(); diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/WalletTransactionServiceImpl.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/WalletTransactionServiceImpl.java index 528cb48d9..82e9a1e8a 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/WalletTransactionServiceImpl.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/WalletTransactionServiceImpl.java @@ -270,7 +270,11 @@ public class WalletTransactionServiceImpl extends ServiceImpl { if (ObjectUtil.isNotEmpty(v.getBizId())) { - v.setOrderId(Long.valueOf(v.getBizId())); + try { + v.setOrderId(Long.valueOf(v.getBizId())); + } catch (Exception e) { + log.error("|{}|订单号转换错误,bizId:|{}|", TAG, v.getBizId()); + } } }); } diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/resources/mapper/recharge/WalletRechargeImportMapper.xml b/pjcloud-wallet/pjcloud-wallet-biz/src/main/resources/mapper/recharge/WalletRechargeImportMapper.xml index 24ac7129d..72b3155c4 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/resources/mapper/recharge/WalletRechargeImportMapper.xml +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/resources/mapper/recharge/WalletRechargeImportMapper.xml @@ -111,4 +111,26 @@ + + \ No newline at end of file