幸运24-后台-个人数据-导出
This commit is contained in:
@@ -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);
|
||||
|
@@ -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),
|
||||
|
Reference in New Issue
Block a user