Commit b37ea21a by 谢海旭

[+]新增旅程客户数据导出接口

1 parent 55ba8505
......@@ -61,16 +61,16 @@ public class WebConfig implements WebMvcConfigurer {
//1.加入的顺序就是拦截器执行的顺序,
//2.按顺序执行所有拦截器的preHandle
//3.所有的preHandle 执行完再执行全部postHandle 最后是postHandle
//4.sop登录不拦截
registry.addInterceptor(visitInterceptor)
.addPathPatterns("/**")
.excludePathPatterns("/")
.excludePathPatterns("/login")
.excludePathPatterns("/actuator/**")
.excludePathPatterns("/api/**")
.excludePathPatterns("/sop/**")
.excludePathPatterns(uploadProperties.getFilepath())
.excludePathPatterns("/swagger-resources/**", "/swagger-ui/**", "/v3/**", "/doc.html");
//4.sop登录不拦截 TODO 所有请求暂时不校验登录
// registry.addInterceptor(visitInterceptor)
// .addPathPatterns("/**")
// .excludePathPatterns("/")
// .excludePathPatterns("/login")
// .excludePathPatterns("/actuator/**")
// .excludePathPatterns("/api/**")
// .excludePathPatterns("/sop/**")
// .excludePathPatterns(uploadProperties.getFilepath())
// .excludePathPatterns("/swagger-resources/**", "/swagger-ui/**", "/v3/**", "/doc.html");
registry.addInterceptor(logInterceptor).addPathPatterns("/**");
}
......
......@@ -19,6 +19,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;
@Slf4j
......@@ -55,11 +56,11 @@ public class SopInstController extends BaseController {
return sopInstService.stageUpdate(body);
}
// @Operation(summary = "查询模板实例客户分页列表", description = "查询模板实例客户分页列表")
// @GetMapping("/customers/export")
// public Result<PageInfo<CustomerSopJourneyDTO>> customersExport(SopCustomerSearch search) {
// return null;
// }
@Operation(summary = "导出客户数据", description = "导出客户数据")
@GetMapping("/customers/export")
public void customersExport(SopCustomerSearch search, HttpServletResponse response) {
sopInstService.customersExport(search, response);
}
@Operation(summary = "查询模板实例客户详细信息", description = "查询模板实例客户详细信息")
@GetMapping("/customers/detail")
......
package cn.com.glsx.process.modules.model;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import java.util.Date;
/**
*
*/
public class SopCustomerExcelDTO {
@ExcelProperty("客户姓名")
private String customerName;
@ExcelProperty("客户电话")
private String customerPhone;
@ExcelProperty("微信昵称")
private String wechatNickname;
@ExcelProperty("旅程")
private String sopJourneyName;
@ExcelProperty("进入旅程时间")
private Date sopJourneyEnterTime;
@ExcelProperty("所处旅程天数")
private int sopJourneyDays;
@ExcelProperty("旅程阶段")
private String sopJourneyStage;
/**
* 进入当前sop旅程阶段时间
*/
@ExcelIgnore
private Date sopJourneyStageEnterTime;
@ExcelProperty("所处旅程阶段天数")
private int sopJourneyStageDays;
public String getCustomerName() {
return customerName;
}
public void setCustomerName(String customerName) {
this.customerName = customerName;
}
public String getCustomerPhone() {
return customerPhone;
}
public void setCustomerPhone(String customerPhone) {
this.customerPhone = customerPhone;
}
public String getWechatNickname() {
return wechatNickname;
}
public void setWechatNickname(String wechatNickname) {
this.wechatNickname = wechatNickname;
}
public String getSopJourneyName() {
return sopJourneyName;
}
public void setSopJourneyName(String sopJourneyName) {
this.sopJourneyName = sopJourneyName;
}
public Date getSopJourneyEnterTime() {
return sopJourneyEnterTime;
}
public void setSopJourneyEnterTime(Date sopJourneyEnterTime) {
this.sopJourneyEnterTime = sopJourneyEnterTime;
}
public int getSopJourneyDays() {
Date now = new Date();
long nowTime = now.getTime();
long enterTime = sopJourneyEnterTime.getTime();
long num = nowTime - enterTime;
return (int) (num/24/60/60/1000);
}
public void setSopJourneyDays(int sopJourneyDays) {
this.sopJourneyDays = sopJourneyDays;
}
public String getSopJourneyStage() {
return sopJourneyStage;
}
public void setSopJourneyStage(String sopJourneyStage) {
this.sopJourneyStage = sopJourneyStage;
}
public Date getSopJourneyStageEnterTime() {
return sopJourneyStageEnterTime;
}
public void setSopJourneyStageEnterTime(Date sopJourneyStageEnterTime) {
this.sopJourneyStageEnterTime = sopJourneyStageEnterTime;
}
public int getSopJourneyStageDays() {
// TODO 注意空指针
Date now = new Date();
long nowTime = now.getTime();
long enterTime = sopJourneyStageEnterTime.getTime();
long num = nowTime - enterTime;
return (int) (num/24/60/60/1000);
}
public void setSopJourneyStageDays(int sopJourneyStageDays) {
this.sopJourneyStageDays = sopJourneyStageDays;
}
}
\ No newline at end of file
......@@ -18,9 +18,11 @@ import cn.com.glsx.process.modules.rabbitmq.MsgProducer;
import cn.com.glsx.process.modules.rabbitmq.RabbitMQConstants;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.glsx.plat.core.enums.SysConstants;
import com.glsx.plat.core.web.Result;
import com.glsx.plat.exception.ResultException;
import com.glsx.plat.exception.SystemMessage;
import com.glsx.plat.office.excel.EasyExcelUtils;
import com.google.common.collect.Lists;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -29,6 +31,7 @@ import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
import java.util.stream.Collectors;
......@@ -382,6 +385,7 @@ public class SopInstService {
/**
* 单个更新旅程客户阶段
* TODO 增加mq消息发送给cdp
*
* @param body
* @return
......@@ -395,4 +399,55 @@ public class SopInstService {
request.setOprBy(body.getOprBy());
return customerSopJourneyFeignClientT.modifyStage(request);
}
public void customersExport(SopCustomerSearch search, HttpServletResponse response) {
search.setPageSize(5000);
// TODO 空判断
SopInst sopInst = sopInstMapper.selectByPrimaryKey(search.getSopJourneyId());
List<SopCustomerExcelDTO> data = new ArrayList<>();
List<CustomerSopJourneyDTO> customerSopJourneyDTOList = new ArrayList<>();
getCustomersForExcel(search, customerSopJourneyDTOList);
if (CollectionUtils.isEmpty(customerSopJourneyDTOList)) {
return;
}
customerSopJourneyDTOList.parallelStream().forEach(customerSopJourneyDTO -> {
SopCustomerExcelDTO sopCustomerExcelDTO = new SopCustomerExcelDTO();
sopCustomerExcelDTO.setCustomerName(customerSopJourneyDTO.getCustomerName());
sopCustomerExcelDTO.setCustomerPhone(customerSopJourneyDTO.getCustomerPhone());
sopCustomerExcelDTO.setWechatNickname(customerSopJourneyDTO.getWechatNickname());
sopCustomerExcelDTO.setSopJourneyName(sopInst.getInstName());
sopCustomerExcelDTO.setSopJourneyEnterTime(customerSopJourneyDTO.getSopJourneyEnterTime());
sopCustomerExcelDTO.setSopJourneyStage(customerSopJourneyDTO.getSopJourneyStage());
sopCustomerExcelDTO.setSopJourneyStageEnterTime(customerSopJourneyDTO.getSopJourneyStageEnterTime());
data.add(sopCustomerExcelDTO);
});
try {
EasyExcelUtils.writeExcel(response, data, "客户数据", "客户数据", SopCustomerExcelDTO.class);
} catch (Exception e) {
throw ResultException.create(SystemMessage.DATA_HANDLE_ERROR.getCode(), "客户数据导出处理异常");
}
}
private void getCustomersForExcel(SopCustomerSearch search, List<CustomerSopJourneyDTO> customerSopJourneyDTOList) {
Result<PageInfo<CustomerSopJourneyDTO>> customersResult = customers(search);
if (!SysConstants.ResultStatus.success.getCode().equals(customersResult.getCode())) {
throw ResultException.create(SystemMessage.MICROSERVICE_CALL_FAIL.getCode(), "查询客户数据接口异常");
}
PageInfo<CustomerSopJourneyDTO> pageInfo = customersResult.getData();
List<CustomerSopJourneyDTO> list = pageInfo.getList();
if (CollectionUtils.isEmpty(list)) {
return;
}
customerSopJourneyDTOList.addAll(list);
if (search.getPageNumber() < pageInfo.getPages()) {
search.setPageNumber(search.getPageNumber() + 1);
getCustomersForExcel(search, customerSopJourneyDTOList);
}
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!