幸运24-后台-个人数据-导出

This commit is contained in:
2025-09-27 20:08:06 +08:00
parent 14b1c2d28e
commit 481b034b3b
3 changed files with 51 additions and 4 deletions

View File

@@ -218,7 +218,9 @@ public class Lucky24RecordAdminService {
}
// 如果列表为空或起始索引超出范围,则创建空的子列表
List<Lucky24PersonalStat> subList = (list.isEmpty() || startIndex >= list.size())
List<Lucky24PersonalStat> subList = pageNo <= 0 || pageSize <= 0?
list:
(list.isEmpty() || startIndex >= list.size())
? Collections.emptyList()
: list.subList(startIndex, endIndex);
@@ -318,8 +320,8 @@ public class Lucky24RecordAdminService {
dateStrList.sort(Comparator.reverseOrder());
// 按大到小排序
int startIndex = (pageNo -1) * pageSize;
int endIndex = Math.min(startIndex + pageSize, dateStrList.size());
int startIndex = pageNo <= 0 || pageSize <= 0? 0: (pageNo -1) * pageSize;
int endIndex = pageNo <= 0 || pageSize <= 0? dateStrList.size(): Math.min(startIndex + pageSize, dateStrList.size());
page.setTotal(dateStrList.size());
List<String> subDateStrList = dateStrList.subList(startIndex, endIndex);

View File

@@ -10,6 +10,7 @@ import com.accompany.common.result.BusiResult;
import com.accompany.common.result.PageResult;
import com.accompany.common.status.BusiStatus;
import com.accompany.core.exception.ServiceException;
import com.accompany.sharding.vo.Lucky24PersonalStat;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.support.ExcelTypeEnum;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -17,6 +18,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
@@ -74,6 +76,34 @@ public class Lucky24RecordAdminController extends BaseController {
return BusiResult.success(vo);
}
@SneakyThrows
@ApiOperation("导出个人数据")
@ApiImplicitParams({
@ApiImplicitParam(value = "partitionId", name = "分区ID", required = true),
@ApiImplicitParam(value = "erbanNo", name = "用户ID"),
@ApiImplicitParam(value = "date", name = "开始日期", required = true),
@ApiImplicitParam(value = "userRechargeLevel", name = "用户充值等级", required = false),
@ApiImplicitParam(value = "poolType", name = "数组类型", required = true),
@ApiImplicitParam(value = "sortCol", name = "排序列", required = true),
@ApiImplicitParam(value = "sortOrder", name = "排序方式", required = true)
})
@GetMapping("/personal/export")
public void exportPersonal(HttpServletResponse response,
Integer partitionId, Long erbanNo, String date, String userRechargeLevel, Integer poolType,
String sortCol, String sortOrder) {
if (null == partitionId || (null == erbanNo && !StringUtils.hasText(date))) {
throw new ServiceException(BusiStatus.PARAMERROR);
}
Lucky24PersonalStatVo vo = service.getPersonal(partitionId, erbanNo, date, userRechargeLevel, poolType, sortCol, sortOrder, 1, -1);
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("utf-8");
// 这里URLEncoder.encode可以防止中文乱码
String excelName = URLEncoder.encode("幸运24个人数据", StandardCharsets.UTF_8);
response.setHeader("Content-disposition", "attachment;filename=" + excelName + ExcelTypeEnum.XLSX.getValue());
EasyExcel.write(response.getOutputStream(), Lucky24PersonalStat.class).sheet("幸运24个人数据").doWrite(vo.getDataPage().getRows());
}
@ApiOperation("运营数据")
@ApiImplicitParams({
@ApiImplicitParam(value = "erbanNo", name = "用户ID", required = true),

View File

@@ -1,5 +1,6 @@
package com.accompany.sharding.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
@@ -14,33 +15,47 @@ import java.math.BigDecimal;
@ApiModel
public class Lucky24PersonalStat {
@ExcelProperty("日期")
@ApiModelProperty("日期")
private String date;
@ExcelProperty("分区id")
@ApiModelProperty("分区id")
private Integer partitionId;
@ExcelProperty("分区描述")
@ApiModelProperty("分区描述")
private Integer poolType;
@ExcelProperty("uid")
@ApiModelProperty("uid")
private Long uid;
@ExcelProperty("erbanNO")
@ApiModelProperty("erbanNO")
private Long erbanNo;
@ExcelProperty("用户充值等级")
@ApiModelProperty("用户充值等级")
private String userRechargeLevel;
@ExcelProperty("送礼金币总额")
@ApiModelProperty("送礼金币总额")
private Long totalInput;
@ExcelProperty("送礼返币总额")
@ApiModelProperty("送礼返币总额")
private Long totalOutput;
@ExcelProperty("相差")
@ApiModelProperty("相差")
private Long production;
@ExcelProperty("投产比")
@ApiModelProperty("投产比")
private BigDecimal productionRatio;
@ExcelProperty("平均投入金额")
@ApiModelProperty("平均投入金额")
private BigDecimal avgInput;
@ExcelProperty("参与次数")
@ApiModelProperty("参与次数")
private Long num;
@ExcelProperty("中奖人数")
@ApiModelProperty("中奖人数")
private Long winNum;
@ExcelProperty("中奖率")
@ApiModelProperty("中奖率")
private BigDecimal winRate;
@@ -59,4 +74,4 @@ public class Lucky24PersonalStat {
this.winNum = 0L;
this.winRate = BigDecimal.ZERO;
}
}
}