feat:限制导出
This commit is contained in:
1 parent
30cc11c44e
commit
e717df69ba
10 files changed
+87
-50
No files matched your search
+2
-2
@@ -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);
|
||||
|
||||
+30
-5
@@ -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<WalletTransactionVo> list = walletTransactionService.scopeList(dto, DataScope.of());
|
||||
|
||||
DataScope dataScope = DataScope.of();
|
||||
Long count = walletTransactionMapper.count(dto, dataScope);
|
||||
if (count > 5000) throw new RuntimeException("导出数据超出5000条,请缩小查询范围");
|
||||
|
||||
List<WalletTransactionVo> 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<WalletTransactionVo> list = walletTransactionService.scopeList(dto, DataScope.of());
|
||||
|
||||
DataScope dataScope = DataScope.of();
|
||||
Long count = walletTransactionMapper.count(dto, dataScope);
|
||||
if (count > 5000) throw new RuntimeException("导出数据超出5000条,请缩小查询范围");
|
||||
|
||||
List<WalletTransactionVo> 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<WalletTransactionVo> list = walletTransactionService.scopeList(dto, DataScope.of());
|
||||
|
||||
DataScope dataScope = DataScope.of();
|
||||
Long count = walletTransactionMapper.count(dto, dataScope);
|
||||
if (count > 5000) throw new RuntimeException("导出数据超出5000条,请缩小查询范围");
|
||||
|
||||
List<WalletTransactionVo> 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<WalletTransactionVo> list = walletTransactionService.scopeList(dto, DataScope.of());
|
||||
|
||||
DataScope dataScope = DataScope.of();
|
||||
Long count = walletTransactionMapper.count(dto, dataScope);
|
||||
if (count > 5000) throw new RuntimeException("导出数据超出5000条,请缩小查询范围");
|
||||
|
||||
List<WalletTransactionVo> 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<WalletTransactionVo> list = walletTransactionService.scopeList(dto, DataScope.of());
|
||||
|
||||
DataScope dataScope = DataScope.of();
|
||||
Long count = walletTransactionMapper.count(dto, dataScope);
|
||||
if (count > 5000) throw new RuntimeException("导出数据超出5000条,请缩小查询范围");
|
||||
|
||||
List<WalletTransactionVo> list = walletTransactionService.scopeList(dto, dataScope);
|
||||
walletTransactionService.exportByTemplate(response, dto, "file/退还各自食堂明细.xlsx", list);
|
||||
}
|
||||
}
|
||||
+7
-1
@@ -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<WalletRechargeImportVo> list = walletRechargeImportService.scopeList(dto, DataScope.of());
|
||||
DataScope dataScope = DataScope.of();
|
||||
Long count = walletRechargeImportMapper.count(dto, dataScope);
|
||||
if (count > 5000) throw new RuntimeException("导出数据超出5000条,请缩小查询范围");
|
||||
List<WalletRechargeImportVo> 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();
|
||||
|
||||
-6
@@ -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<WalletRuleTransactionEntity> export(WalletRuleTransactionEntity walletRuleTransaction, Long[] ids) {
|
||||
return walletRuleTransactionService.list(Wrappers.lambdaQuery(walletRuleTransaction).in(ArrayUtil.isNotEmpty(ids), WalletRuleTransactionEntity::getId, ids));
|
||||
}
|
||||
}
|
||||
+4
@@ -153,6 +153,10 @@ public interface WalletManageMapper extends PjcloudBaseMapper<WalletManageEntity
|
||||
return list;
|
||||
}
|
||||
|
||||
default Long count(WalletManageDto dto, DataScope dataScope) {
|
||||
return selectCountByScope(commonQuery(dto), dataScope);
|
||||
}
|
||||
|
||||
default List<WalletManageVo> scopeList(WalletManageDto dto, DataScope dataScope) {
|
||||
List<WalletManageEntity> list = selectListByScope(commonQuery(dto), dataScope);
|
||||
return BeanUtils.toBean(list, WalletManageVo.class);
|
||||
|
||||
+11
-34
@@ -26,7 +26,7 @@ import java.util.Objects;
|
||||
@Mapper
|
||||
public interface WalletTransactionMapper extends PjcloudBaseMapper<WalletTransactionEntity> {
|
||||
|
||||
default Page<WalletTransactionVo> scopePageList(Page page, WalletTransactionDto dto, DataScope dataScope) {
|
||||
default LambdaQueryWrapper<WalletTransactionEntity> commonWrapperQuery(WalletTransactionDto dto) {
|
||||
LambdaQueryWrapper<WalletTransactionEntity> wrapper = new LambdaQueryWrapper<WalletTransactionEntity>()
|
||||
.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<WalletTransac
|
||||
} else if (Objects.equals(dto.getType(), WalletTransactionDto.TYPE_EXPENSE)) {
|
||||
wrapper.lt(WalletTransactionEntity::getPrice, 0);
|
||||
}
|
||||
Page list = selectPageByScope(page, wrapper, dataScope);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
default Page<WalletTransactionVo> 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<WalletTransactionVo> scopeList(WalletTransactionDto dto, DataScope dataScope) {
|
||||
LambdaQueryWrapper<WalletTransactionEntity> wrapper = new LambdaQueryWrapper<WalletTransactionEntity>()
|
||||
.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<WalletTransactionEntity> list = selectListByScope(wrapper, dataScope);
|
||||
List<WalletTransactionEntity> list = selectListByScope(commonWrapperQuery(dto), dataScope);
|
||||
return BeanUtils.toBean(list, WalletTransactionVo.class);
|
||||
}
|
||||
|
||||
default Long count(WalletTransactionDto dto, DataScope dataScope) {
|
||||
return selectCountByScope(commonWrapperQuery(dto), dataScope);
|
||||
}
|
||||
|
||||
Page<WalletTransactionVo> scopeJzPageList(Page page, @Param("dto") WalletTransactionDto dto, DataScope dataScope);
|
||||
|
||||
Integer getTransactionPriceCount(@Param("month") String importTimeStr, @Param("walletId") Long walletId,
|
||||
|
||||
+2
@@ -21,6 +21,8 @@ public interface WalletRechargeImportMapper extends PjcloudBaseMapper<WalletRech
|
||||
|
||||
List<WalletRechargeImportVo> scopeList(@Param("dto") WalletRechargeImportDto dto, DataScope dataScope);
|
||||
|
||||
Long count(@Param("dto") WalletRechargeImportDto dto, DataScope dataScope);
|
||||
|
||||
default Page<WalletRechargeImportVo> pageJoin(Page page, WalletRechargeImportDto dto) {
|
||||
MPJLambdaWrapper<WalletRechargeImportEntity> wrapper = new MPJLambdaWrapper<WalletRechargeImportEntity>()
|
||||
.eqIfExists(WalletRechargeImportEntity::getId, dto.getId())
|
||||
|
||||
+4
-1
@@ -399,7 +399,10 @@ public class WalletManageServiceImpl extends ServiceImpl<WalletManageMapper, Wal
|
||||
@Override
|
||||
public void export(HttpServletResponse response, Page page, WalletManageDto dto) {
|
||||
String fileName = "file/账户余额.xlsx";
|
||||
List<WalletManageVo> list = scopeList(dto, DataScope.of());
|
||||
DataScope dataScope = DataScope.of();
|
||||
Long count = baseMapper.count(dto, dataScope);
|
||||
if (count > 5000) throw new RuntimeException("导出数据超出5000条,请缩小查询范围");
|
||||
List<WalletManageVo> 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();
|
||||
|
||||
+5
-1
@@ -270,7 +270,11 @@ public class WalletTransactionServiceImpl extends ServiceImpl<WalletTransactionM
|
||||
if (dto.getIsFindOrder()) {
|
||||
list.forEach(v -> {
|
||||
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());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+22
@@ -111,4 +111,26 @@
|
||||
<select id="scopeList" resultType="com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeImportVo">
|
||||
<include refid="selectJoin"/>
|
||||
</select>
|
||||
|
||||
<select id="count" resultType="java.lang.Long">
|
||||
count(0)
|
||||
from wallet_recharge_import a
|
||||
inner join wallet_recharge_apply p on p.id = a.apply_id
|
||||
<where>
|
||||
<include refid="whereA"/>
|
||||
and p.process_id is not null
|
||||
<if test="dto.bizType != null and dto.bizType != ''">
|
||||
and p.biz_type = #{dto.bizType}
|
||||
</if>
|
||||
<if test="dto.processStatus != null and dto.processStatus != ''">
|
||||
and p.process_status = #{dto.processStatus}
|
||||
</if>
|
||||
<if test="dto.walletTypeId != null">
|
||||
and p.wallet_type_id = #{dto.walletTypeId}
|
||||
</if>
|
||||
<if test="dto.processTimeList != null and dto.processTimeList.length == 2">
|
||||
and p.process_time between #{dto.processTimeList[0]} and #{dto.processTimeList[1]}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in new issue
Block a user