Commit abf7e298 by 谢海旭

旅程客户数据导出接口调整为返回文件url

1 parent 67114fea
......@@ -9,6 +9,7 @@ import cn.com.glsx.process.modules.model.SopInstDTO;
import cn.com.glsx.process.modules.model.SopInstSearch;
import cn.com.glsx.process.modules.model.SopJourneyStageUpdate;
import cn.com.glsx.process.modules.service.SopInstService;
import cn.com.glsx.process.util.FileUploadServerData;
import com.github.pagehelper.PageInfo;
import com.glsx.plat.core.annotation.ResponseResultBody;
import com.glsx.plat.core.web.Result;
......@@ -19,7 +20,6 @@ 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
......@@ -58,8 +58,8 @@ public class SopInstController extends BaseController {
@Operation(summary = "导出客户数据", description = "导出客户数据")
@GetMapping("/customers/export")
public void customersExport(SopCustomerSearch search, HttpServletResponse response) {
sopInstService.customersExport(search, response);
public FileUploadServerData customersExport(SopCustomerSearch search) {
return sopInstService.customersExport(search);
}
@Operation(summary = "查询模板实例客户详细信息", description = "查询模板实例客户详细信息")
......
......@@ -16,6 +16,8 @@ import cn.com.glsx.process.modules.model.*;
import cn.com.glsx.process.modules.model.enums.SopInstStatusEnum;
import cn.com.glsx.process.modules.rabbitmq.MsgProducer;
import cn.com.glsx.process.modules.rabbitmq.RabbitMQConstants;
import cn.com.glsx.process.util.FileUploadServerData;
import cn.com.glsx.process.util.FileUploadUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.glsx.plat.core.enums.SysConstants;
......@@ -31,7 +33,7 @@ import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayOutputStream;
import java.util.*;
import java.util.stream.Collectors;
......@@ -66,7 +68,7 @@ public class SopInstService {
private CustomerSopJourneyFeignClient_T customerSopJourneyFeignClientT;
@Autowired
private MsgProducer msgProducer;
private MsgProducer msgProducer;
/**
* 根据id查询
......@@ -109,7 +111,7 @@ public class SopInstService {
* @param instId
* @return
*/
public boolean delete(String instId) {
public boolean delete(String instId) {
int i = sopInstMapper.deleteByPrimaryKey(instId);
if (i > 0) {
return true;
......@@ -172,7 +174,7 @@ public class SopInstService {
/**
* 更新门店模板实例默认参数的自定义参数
*
* @param instId 实例id
* @param instId 实例id
* @param customData 自定义参数
* @return
*/
......@@ -326,7 +328,7 @@ public class SopInstService {
//页面选择是否跳过处理
SopInstNode sopInstNodeTemp = customNodesMap.get(sopInstNode.getNodeId());
sopInstNode.setNodeSkip(!Objects.isNull(sopInstNodeTemp)?sopInstNodeTemp.getNodeSkip():SopInstNode.NODE_SKIP_FALSE);
sopInstNode.setNodeSkip(!Objects.isNull(sopInstNodeTemp) ? sopInstNodeTemp.getNodeSkip() : SopInstNode.NODE_SKIP_FALSE);
sopInstNodes.add(sopInstNode);
});
sopInstNodeMapper.insertList(sopInstNodes);
......@@ -339,7 +341,7 @@ public class SopInstService {
* @param search
* @return
*/
public Result<PageInfo<CustomerSopJourneyDTO>> customers(SopCustomerSearch search) {
public Result<PageInfo<CustomerSopJourneyDTO>> customers(SopCustomerSearch search) {
String sopJourneyId = search.getSopJourneyId();
SopInst sopInst = sopInstMapper.selectByPrimaryKey(sopJourneyId);
if (Objects.isNull(sopInst)) {
......@@ -356,16 +358,16 @@ public class SopInstService {
String sopJourneyStage = search.getSopJourneyStage();
request.setSopJourneyStages(StringUtils.hasLength(sopJourneyStage)? Lists.newArrayList(sopJourneyStage): null);
request.setSopJourneyStages(StringUtils.hasLength(sopJourneyStage) ? Lists.newArrayList(sopJourneyStage) : null);
String customerPhone = search.getCustomerPhone();
request.setCustomerPhones(StringUtils.hasLength(customerPhone)? Lists.newArrayList(customerPhone): null);
request.setCustomerPhones(StringUtils.hasLength(customerPhone) ? Lists.newArrayList(customerPhone) : null);
request.setCustomerName(search.getCustomerName());
request.setWechatNickname(search.getWechatNickname());
String sopFollowUpPersonId = search.getSopFollowUpPersonId();
request.setSopFollowUpPersonIds(StringUtils.hasLength(sopFollowUpPersonId)? Lists.newArrayList(sopFollowUpPersonId): null);
request.setSopFollowUpPersonIds(StringUtils.hasLength(sopFollowUpPersonId) ? Lists.newArrayList(sopFollowUpPersonId) : null);
request.setSopFollowUpPersonPhone(search.getSopFollowUpPersonPhone());
request.setSopJourneyEnterTimeBegin(search.getSopJourneyEnterTimeBegin());
......@@ -400,17 +402,19 @@ public class SopInstService {
return customerSopJourneyFeignClientT.modifyStage(request);
}
public void customersExport(SopCustomerSearch search, HttpServletResponse response) {
public FileUploadServerData customersExport(SopCustomerSearch search) {
search.setPageSize(5000);
// TODO 空判断
SopInst sopInst = sopInstMapper.selectByPrimaryKey(search.getSopJourneyId());
if (Objects.isNull(sopInst)) {
throw ResultException.create(SystemMessage.ARGS_ERROR.getCode(), "模板实例不存在");
}
List<SopCustomerExcelDTO> data = new ArrayList<>();
List<CustomerSopJourneyDTO> customerSopJourneyDTOList = new ArrayList<>();
getCustomersForExcel(search, customerSopJourneyDTOList);
if (CollectionUtils.isEmpty(customerSopJourneyDTOList)) {
return;
return null;
}
customerSopJourneyDTOList.parallelStream().forEach(customerSopJourneyDTO -> {
......@@ -426,7 +430,11 @@ public class SopInstService {
});
try {
EasyExcelUtils.writeExcel(response, data, "客户数据", "客户数据", SopCustomerExcelDTO.class);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
EasyExcelUtils.writeExcel(outputStream, data, "客户数据", SopCustomerExcelDTO.class);
byte[] bytes = outputStream.toByteArray();
FileUploadServerData fileUploadServerData = FileUploadUtil.uploadToFileSystem("客户数据", bytes, "xlsx");
return fileUploadServerData;
} catch (Exception e) {
throw ResultException.create(SystemMessage.DATA_HANDLE_ERROR.getCode(), "客户数据导出处理异常");
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!