表格导出
This commit is contained in:
parent
3b2a63352c
commit
5ffd0e1c93
@ -29,4 +29,14 @@ public class DictBaseConstants {
|
|||||||
public static final String CYCLE_DICT = "cycle_dict";
|
public static final String CYCLE_DICT = "cycle_dict";
|
||||||
/** 企业资产临期判定时间 */
|
/** 企业资产临期判定时间 */
|
||||||
public static final String COMPANY_PROPERTY_EXPIRED = "company_property_expired";
|
public static final String COMPANY_PROPERTY_EXPIRED = "company_property_expired";
|
||||||
|
/** 客户状态 */
|
||||||
|
public static final String DICT_CUS_INFO_STATUS = "cus_info_status";
|
||||||
|
/** 卡券类型 */
|
||||||
|
public static final String MEMBER_COUPON_TYPE = "member_coupon_type";
|
||||||
|
/** 核销规则 */
|
||||||
|
public static final String MEMBER_COUPON_OUT_RULE = "member_coupon_out_rule";
|
||||||
|
/** 适用车型 */
|
||||||
|
public static final String MEMBER_CAR = "member_car";
|
||||||
|
/** 活动类型 */
|
||||||
|
public static final String MEMBER_ACTIVE = "member_active";
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,15 @@
|
|||||||
package cn.iocoder.yudao.module.custom.controller.admin;
|
package cn.iocoder.yudao.module.custom.controller.admin;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||||
import cn.iocoder.yudao.module.custom.entity.CustomerMain;
|
import cn.iocoder.yudao.module.custom.entity.CustomerMain;
|
||||||
import cn.iocoder.yudao.module.custom.service.CustomerCarService;
|
import cn.iocoder.yudao.module.custom.service.CustomerCarService;
|
||||||
import cn.iocoder.yudao.module.custom.service.CustomerMainService;
|
import cn.iocoder.yudao.module.custom.service.CustomerMainService;
|
||||||
|
import cn.iocoder.yudao.module.custom.vo.CustomerExportVO;
|
||||||
import cn.iocoder.yudao.module.custom.vo.CustomerMainPageReqVO;
|
import cn.iocoder.yudao.module.custom.vo.CustomerMainPageReqVO;
|
||||||
import cn.iocoder.yudao.module.custom.vo.CustomerMainRespVO;
|
import cn.iocoder.yudao.module.custom.vo.CustomerMainRespVO;
|
||||||
import cn.iocoder.yudao.module.custom.vo.CustomerMainSaveReqVO;
|
import cn.iocoder.yudao.module.custom.vo.CustomerMainSaveReqVO;
|
||||||
@ -20,8 +25,12 @@ import org.springframework.validation.annotation.Validated;
|
|||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.common.BaseConstants.*;
|
import static cn.iocoder.yudao.common.BaseConstants.*;
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0;
|
||||||
@ -44,6 +53,7 @@ public class CustomerMainController {
|
|||||||
private BusiLabelService busiLabelService;
|
private BusiLabelService busiLabelService;
|
||||||
@Resource
|
@Resource
|
||||||
private CustomerCarService customerCarService;
|
private CustomerCarService customerCarService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 客户管理分页列表查询
|
* 客户管理分页列表查询
|
||||||
*
|
*
|
||||||
@ -76,7 +86,7 @@ public class CustomerMainController {
|
|||||||
@Operation(summary = "创建客户管理")
|
@Operation(summary = "创建客户管理")
|
||||||
@PreAuthorize("@ss.hasPermission('base:customer-main:create')")
|
@PreAuthorize("@ss.hasPermission('base:customer-main:create')")
|
||||||
public CommonResult<Boolean> createCustomerMain(@Valid @RequestBody CustomerMainSaveReqVO saveReqVO) {
|
public CommonResult<Boolean> createCustomerMain(@Valid @RequestBody CustomerMainSaveReqVO saveReqVO) {
|
||||||
customerMainService.saveCustomer(saveReqVO,SIGN_CREATE);
|
customerMainService.saveCustomer(saveReqVO, SIGN_CREATE);
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,7 +109,7 @@ public class CustomerMainController {
|
|||||||
@Operation(summary = "更新客户管理")
|
@Operation(summary = "更新客户管理")
|
||||||
@PreAuthorize("@ss.hasPermission('base:customer-main:update')")
|
@PreAuthorize("@ss.hasPermission('base:customer-main:update')")
|
||||||
public CommonResult<Boolean> updateCustomerMain(@Valid @RequestBody CustomerMainSaveReqVO saveReqVO) {
|
public CommonResult<Boolean> updateCustomerMain(@Valid @RequestBody CustomerMainSaveReqVO saveReqVO) {
|
||||||
customerMainService.saveCustomer(saveReqVO,SIGN_UPDATE);
|
customerMainService.saveCustomer(saveReqVO, SIGN_UPDATE);
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,10 +195,10 @@ public class CustomerMainController {
|
|||||||
/**
|
/**
|
||||||
* 根据姓名和电话查询单条记录
|
* 根据姓名和电话查询单条记录
|
||||||
*
|
*
|
||||||
|
* @param customerMain 查询对象
|
||||||
* @author 小李
|
* @author 小李
|
||||||
* @date 11:19 2024/10/8
|
* @date 11:19 2024/10/8
|
||||||
* @param customerMain 查询对象
|
**/
|
||||||
**/
|
|
||||||
@PostMapping("/getByNameAndMobile")
|
@PostMapping("/getByNameAndMobile")
|
||||||
@Operation(summary = "根据姓名和电话查询单条记录")
|
@Operation(summary = "根据姓名和电话查询单条记录")
|
||||||
public CommonResult<?> getByNameAndMobile(@Valid @RequestBody CustomerMain customerMain) {
|
public CommonResult<?> getByNameAndMobile(@Valid @RequestBody CustomerMain customerMain) {
|
||||||
@ -201,4 +211,39 @@ public class CustomerMainController {
|
|||||||
}
|
}
|
||||||
throw exception0(500, "系统异常");
|
throw exception0(500, "系统异常");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出数据
|
||||||
|
*
|
||||||
|
* @author 小李
|
||||||
|
* @date 19:33 2024/12/2
|
||||||
|
* @param pageReqVO 请求对象
|
||||||
|
**/
|
||||||
|
@GetMapping("/export")
|
||||||
|
@Operation(summary = "导出数据")
|
||||||
|
public void exportData(CustomerMainPageReqVO pageReqVO, HttpServletResponse response) throws IOException {
|
||||||
|
int pageNo = 1, pageSize = 1000;
|
||||||
|
List<CustomerExportVO> list = new ArrayList<>();
|
||||||
|
Page<CustomerMainRespVO> page = new Page<>(pageNo, pageSize);
|
||||||
|
do {
|
||||||
|
IPage<CustomerMainRespVO> customerMainRespVOIPage = customerMainService.queryListPage(pageReqVO, page);
|
||||||
|
List<CustomerMainRespVO> records = customerMainRespVOIPage.getRecords();
|
||||||
|
if (CollUtil.isEmpty(records)){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
List<CustomerExportVO> convertedRecords = records.stream().map(item -> BeanUtils.toBean(item, CustomerExportVO.class)).collect(Collectors.toList());
|
||||||
|
list.addAll(convertedRecords);
|
||||||
|
pageNo++;
|
||||||
|
page.setCurrent(pageNo);
|
||||||
|
}while (true);
|
||||||
|
if (CollUtil.isEmpty(list)){
|
||||||
|
throw exception0(500, "没有数据可以导出");
|
||||||
|
}
|
||||||
|
list.forEach(item -> {
|
||||||
|
if (ObjectUtil.isNotEmpty(item.getIsHangAccount())){
|
||||||
|
item.setIsHangAccount(item.getIsHangAccount().equals("0") ? "否" : "是");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ExcelUtils.write(response, "客户数据.xls", "数据", CustomerExportVO.class, list);
|
||||||
|
}
|
||||||
}
|
}
|
@ -0,0 +1,66 @@
|
|||||||
|
package cn.iocoder.yudao.module.custom.vo;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||||
|
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||||
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.common.DictBaseConstants.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用于导出客户数据VO
|
||||||
|
*
|
||||||
|
* @author 小李
|
||||||
|
* @date 19:20 2024/12/2
|
||||||
|
**/
|
||||||
|
@Data
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
public class CustomerExportVO {
|
||||||
|
|
||||||
|
@ExcelProperty("客户名称")
|
||||||
|
private String cusName;
|
||||||
|
|
||||||
|
@ExcelProperty(value = "性别", converter = DictConvert.class)
|
||||||
|
@DictFormat(DICT_SYS_USER_SEX)
|
||||||
|
private String sex;
|
||||||
|
|
||||||
|
@ExcelProperty("会员等级")
|
||||||
|
private String levelName;
|
||||||
|
|
||||||
|
@ExcelProperty("联系方式")
|
||||||
|
private String phoneNumber;
|
||||||
|
|
||||||
|
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
|
||||||
|
@DateTimeFormat(pattern="yyyy-MM-dd")
|
||||||
|
@ExcelProperty("生日")
|
||||||
|
private LocalDateTime birthday;
|
||||||
|
|
||||||
|
@ExcelProperty("住址")
|
||||||
|
private String address;
|
||||||
|
|
||||||
|
@ExcelProperty("是否挂账")
|
||||||
|
private String isHangAccount;
|
||||||
|
|
||||||
|
@ExcelProperty(value = "客户来源", converter = DictConvert.class)
|
||||||
|
@DictFormat(DICT_CUS_DATA_FROM)
|
||||||
|
private String dataFrom;
|
||||||
|
|
||||||
|
@ExcelProperty(value = "最近办理业务", converter = DictConvert.class)
|
||||||
|
@DictFormat(DICT_CUS_BUSI_TYPE)
|
||||||
|
private String nearDoContent;
|
||||||
|
|
||||||
|
@ExcelProperty("最近业务办理时间")
|
||||||
|
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
|
||||||
|
@DateTimeFormat(pattern="yyyy-MM-dd")
|
||||||
|
private LocalDateTime nearDoTime;
|
||||||
|
|
||||||
|
@ExcelProperty(value = "客户状态", converter = DictConvert.class)
|
||||||
|
@DictFormat(DICT_CUS_INFO_STATUS)
|
||||||
|
private String status;
|
||||||
|
}
|
@ -1,9 +1,13 @@
|
|||||||
package cn.iocoder.yudao.module.member.controller.admin;
|
package cn.iocoder.yudao.module.member.controller.admin;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||||
import cn.iocoder.yudao.module.member.entity.ActiveMain;
|
import cn.iocoder.yudao.module.member.entity.ActiveMain;
|
||||||
import cn.iocoder.yudao.module.member.service.ActiveMainService;
|
import cn.iocoder.yudao.module.member.service.ActiveMainService;
|
||||||
|
import cn.iocoder.yudao.module.member.vo.ActiveMainExportVO;
|
||||||
import cn.iocoder.yudao.module.member.vo.ActiveMainPageReqVO;
|
import cn.iocoder.yudao.module.member.vo.ActiveMainPageReqVO;
|
||||||
import cn.iocoder.yudao.module.member.vo.ActiveMainRespVO;
|
import cn.iocoder.yudao.module.member.vo.ActiveMainRespVO;
|
||||||
import cn.iocoder.yudao.module.member.vo.ActiveMainSaveReqVO;
|
import cn.iocoder.yudao.module.member.vo.ActiveMainSaveReqVO;
|
||||||
@ -17,10 +21,15 @@ import org.springframework.validation.annotation.Validated;
|
|||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0;
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
@Tag(name = "管理后台 - 营销活动")
|
@Tag(name = "管理后台 - 营销活动")
|
||||||
@ -111,4 +120,38 @@ public class ActiveMainController {
|
|||||||
return success(activeMainService.queryListPage(pageReqVO, page));
|
return success(activeMainService.queryListPage(pageReqVO, page));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出数据
|
||||||
|
*
|
||||||
|
* @author 小李
|
||||||
|
* @date 20:25 2024/12/2
|
||||||
|
* @param pageReqVO 请求对象
|
||||||
|
**/
|
||||||
|
@GetMapping("/export")
|
||||||
|
@Operation(summary = "导出数据")
|
||||||
|
public void exportData(ActiveMainPageReqVO pageReqVO, HttpServletResponse response)throws IOException {
|
||||||
|
int pageNo = 1, pageSize = 1000;
|
||||||
|
List<ActiveMainExportVO> list = new ArrayList<>();
|
||||||
|
Page<ActiveMainRespVO> page = new Page<>(pageNo, pageSize);
|
||||||
|
do {
|
||||||
|
IPage<ActiveMainRespVO> activeMainRespVOIPage = activeMainService.queryListPage(pageReqVO, page);
|
||||||
|
List<ActiveMainRespVO> records = activeMainRespVOIPage.getRecords();
|
||||||
|
if (CollUtil.isEmpty(records)){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
List<ActiveMainExportVO> convertedRecords = records.stream().map(item -> BeanUtils.toBean(item, ActiveMainExportVO.class)).collect(Collectors.toList());
|
||||||
|
list.addAll(convertedRecords);
|
||||||
|
pageNo++;
|
||||||
|
page.setCurrent(pageNo);
|
||||||
|
}while (true);
|
||||||
|
if (CollUtil.isEmpty(list)){
|
||||||
|
throw exception0(500, "没有数据可以导出");
|
||||||
|
}
|
||||||
|
list.forEach(item -> {
|
||||||
|
if (ObjectUtil.isNotEmpty(item.getStatus())){
|
||||||
|
item.setStatus(item.getStatus().equals("01") ? "启用" : "停用");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ExcelUtils.write(response, "营销活动数据.xls", "数据", ActiveMainExportVO.class, list);
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,5 +1,7 @@
|
|||||||
package cn.iocoder.yudao.module.member.controller.admin;
|
package cn.iocoder.yudao.module.member.controller.admin;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
@ -8,10 +10,7 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|||||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||||
import cn.iocoder.yudao.module.member.entity.MemberCoupon;
|
import cn.iocoder.yudao.module.member.entity.MemberCoupon;
|
||||||
import cn.iocoder.yudao.module.member.service.MemberCouponService;
|
import cn.iocoder.yudao.module.member.service.MemberCouponService;
|
||||||
import cn.iocoder.yudao.module.member.vo.MemberCouponPageReqVO;
|
import cn.iocoder.yudao.module.member.vo.*;
|
||||||
import cn.iocoder.yudao.module.member.vo.MemberCouponRespVO;
|
|
||||||
import cn.iocoder.yudao.module.member.vo.MemberCouponSaveReqVO;
|
|
||||||
import cn.iocoder.yudao.module.member.vo.MemberLevelRespVO;
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
@ -25,9 +24,12 @@ import javax.annotation.Resource;
|
|||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||||
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0;
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
@Tag(name = "管理后台 - 基础卡券")
|
@Tag(name = "管理后台 - 基础卡券")
|
||||||
@ -138,5 +140,34 @@ public class MemberCouponController {
|
|||||||
return success(couponService.queryListPage(pageReqVO, page));
|
return success(couponService.queryListPage(pageReqVO, page));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出数据
|
||||||
|
*
|
||||||
|
* @author 小李
|
||||||
|
* @date 19:53 2024/12/2
|
||||||
|
* @param pageReqVO 请求数据
|
||||||
|
**/
|
||||||
|
@GetMapping("/export")
|
||||||
|
@Operation(summary = "导出数据")
|
||||||
|
public void exportData(MemberCouponPageReqVO pageReqVO, HttpServletResponse response)throws IOException{
|
||||||
|
int pageNo = 1, pageSize = 1000;
|
||||||
|
List<MemberCouponExportVO> list = new ArrayList<>();
|
||||||
|
Page<MemberCouponRespVO> page = new Page<>(pageNo, pageSize);
|
||||||
|
do {
|
||||||
|
IPage<MemberCouponRespVO> memberCouponRespVOIPage = couponService.queryListPage(pageReqVO, page);
|
||||||
|
List<MemberCouponRespVO> records = memberCouponRespVOIPage.getRecords();
|
||||||
|
if (CollUtil.isEmpty(records)){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
List<MemberCouponExportVO> convertedRecords = records.stream().map(item -> BeanUtils.toBean(item, MemberCouponExportVO.class)).collect(Collectors.toList());
|
||||||
|
list.addAll(convertedRecords);
|
||||||
|
pageNo++;
|
||||||
|
page.setCurrent(pageNo);
|
||||||
|
}while (true);
|
||||||
|
if (CollUtil.isEmpty(list)){
|
||||||
|
throw exception0(500, "没有数据可以导出");
|
||||||
|
}
|
||||||
|
ExcelUtils.write(response, "基础卡券数据.xls", "数据", MemberCouponExportVO.class, list);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,9 +1,13 @@
|
|||||||
package cn.iocoder.yudao.module.member.controller.admin;
|
package cn.iocoder.yudao.module.member.controller.admin;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||||
import cn.iocoder.yudao.module.member.entity.MemberLevel;
|
import cn.iocoder.yudao.module.member.entity.MemberLevel;
|
||||||
import cn.iocoder.yudao.module.member.service.MemberLevelService;
|
import cn.iocoder.yudao.module.member.service.MemberLevelService;
|
||||||
|
import cn.iocoder.yudao.module.member.vo.MemberLevelExportVO;
|
||||||
import cn.iocoder.yudao.module.member.vo.MemberLevelPageReqVO;
|
import cn.iocoder.yudao.module.member.vo.MemberLevelPageReqVO;
|
||||||
import cn.iocoder.yudao.module.member.vo.MemberLevelRespVO;
|
import cn.iocoder.yudao.module.member.vo.MemberLevelRespVO;
|
||||||
import cn.iocoder.yudao.module.member.vo.MemberLevelSaveReqVO;
|
import cn.iocoder.yudao.module.member.vo.MemberLevelSaveReqVO;
|
||||||
@ -17,10 +21,15 @@ import org.springframework.validation.annotation.Validated;
|
|||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0;
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
|
|
||||||
@ -127,4 +136,39 @@ public class MemberLevelController {
|
|||||||
return success(levelService.queryListAll(pageReqVO));
|
return success(levelService.queryListAll(pageReqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出数据
|
||||||
|
*
|
||||||
|
* @author 小李
|
||||||
|
* @date 19:41 2024/12/2
|
||||||
|
* @param pageReqVO 请求对象
|
||||||
|
**/
|
||||||
|
@GetMapping("/export")
|
||||||
|
@Operation(summary = "导出数据")
|
||||||
|
public void exportData(MemberLevelPageReqVO pageReqVO, HttpServletResponse response)throws IOException {
|
||||||
|
int pageNo = 1, pageSize = 1000;
|
||||||
|
List<MemberLevelExportVO> list = new ArrayList<>();
|
||||||
|
Page<MemberLevelRespVO> page = new Page<>(pageNo, pageSize);
|
||||||
|
do {
|
||||||
|
IPage<MemberLevelRespVO> memberLevelRespVOIPage = levelService.queryListPage(pageReqVO, page);
|
||||||
|
List<MemberLevelRespVO> records = memberLevelRespVOIPage.getRecords();
|
||||||
|
if (CollUtil.isEmpty(records)){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
List<MemberLevelExportVO> convertedRecords = records.stream().map(item -> BeanUtils.toBean(item, MemberLevelExportVO.class)).collect(Collectors.toList());
|
||||||
|
list.addAll(convertedRecords);
|
||||||
|
pageNo++;
|
||||||
|
page.setCurrent(pageNo);
|
||||||
|
}while (true);
|
||||||
|
if (CollUtil.isEmpty(list)){
|
||||||
|
throw exception0(500, "没有数据可以导出");
|
||||||
|
}
|
||||||
|
list.forEach(item -> {
|
||||||
|
if (ObjectUtil.isNotEmpty(item.getStatus())){
|
||||||
|
item.setStatus(item.getStatus().equals("01") ? "启用" : "停用");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ExcelUtils.write(response, "会员等级数据.xls", "数据", MemberLevelExportVO.class, list);
|
||||||
|
}
|
||||||
}
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.vo;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||||
|
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||||
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.common.DictBaseConstants.MEMBER_ACTIVE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用于导出营销活动VO
|
||||||
|
*
|
||||||
|
* @author 小李
|
||||||
|
* @date 20:26 2024/12/2
|
||||||
|
**/
|
||||||
|
@Data
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
public class ActiveMainExportVO {
|
||||||
|
|
||||||
|
@ExcelProperty("活动名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ExcelProperty(value = "活动类型", converter = DictConvert.class)
|
||||||
|
@DictFormat(MEMBER_ACTIVE)
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
@ExcelProperty("活动开始时间")
|
||||||
|
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||||
|
private LocalDateTime beginTime;
|
||||||
|
|
||||||
|
@ExcelProperty("活动结束时间")
|
||||||
|
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||||
|
private LocalDateTime endTime;
|
||||||
|
|
||||||
|
@ExcelProperty("活动状态")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
@ExcelProperty("活动描述")
|
||||||
|
private String remark;
|
||||||
|
}
|
@ -0,0 +1,56 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.vo;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||||
|
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||||
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.common.DictBaseConstants.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用于基础卡券导出VO
|
||||||
|
*
|
||||||
|
* @author 小李
|
||||||
|
* @date 19:55 2024/12/2
|
||||||
|
**/
|
||||||
|
@Data
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
public class MemberCouponExportVO {
|
||||||
|
|
||||||
|
@ExcelProperty("卡券名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ExcelProperty(value = "卡券类型", converter = DictConvert.class)
|
||||||
|
@DictFormat(MEMBER_COUPON_TYPE)
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
@ExcelProperty(value = "适用车型", converter = DictConvert.class)
|
||||||
|
@DictFormat(MEMBER_CAR)
|
||||||
|
private String carModel;
|
||||||
|
|
||||||
|
@ExcelProperty(value = "核销规则", converter = DictConvert.class)
|
||||||
|
@DictFormat(MEMBER_COUPON_OUT_RULE)
|
||||||
|
private String outRule;
|
||||||
|
|
||||||
|
@ExcelProperty("开始有效期")
|
||||||
|
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||||
|
private LocalDateTime beginTime;
|
||||||
|
|
||||||
|
@ExcelProperty("结束有效期")
|
||||||
|
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||||
|
private LocalDateTime endTime;
|
||||||
|
|
||||||
|
@ExcelProperty("面额")
|
||||||
|
private BigDecimal amount;
|
||||||
|
|
||||||
|
@ExcelProperty("备注")
|
||||||
|
private String remark;
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.vo;
|
||||||
|
|
||||||
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用于会员等级导出VO
|
||||||
|
*
|
||||||
|
* @author 小李
|
||||||
|
* @date 19:42 2024/12/2
|
||||||
|
**/
|
||||||
|
@Data
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
public class MemberLevelExportVO {
|
||||||
|
|
||||||
|
@ExcelProperty("等级名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ExcelProperty("状态")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
@ExcelProperty("升级所需积分")
|
||||||
|
private String growthValue;
|
||||||
|
|
||||||
|
@ExcelProperty("会员折扣")
|
||||||
|
private BigDecimal discount;
|
||||||
|
|
||||||
|
@ExcelProperty("等级说明")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
@ExcelProperty("等级权益")
|
||||||
|
private String userEquity;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user