Commit abf7e298 by 谢海旭

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

1 parent 67114fea
...@@ -9,6 +9,7 @@ import cn.com.glsx.process.modules.model.SopInstDTO; ...@@ -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.SopInstSearch;
import cn.com.glsx.process.modules.model.SopJourneyStageUpdate; import cn.com.glsx.process.modules.model.SopJourneyStageUpdate;
import cn.com.glsx.process.modules.service.SopInstService; import cn.com.glsx.process.modules.service.SopInstService;
import cn.com.glsx.process.util.FileUploadServerData;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.glsx.plat.core.annotation.ResponseResultBody; import com.glsx.plat.core.annotation.ResponseResultBody;
import com.glsx.plat.core.web.Result; import com.glsx.plat.core.web.Result;
...@@ -19,7 +20,6 @@ import org.springframework.validation.annotation.Validated; ...@@ -19,7 +20,6 @@ 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 java.util.Map; import java.util.Map;
@Slf4j @Slf4j
...@@ -58,8 +58,8 @@ public class SopInstController extends BaseController { ...@@ -58,8 +58,8 @@ public class SopInstController extends BaseController {
@Operation(summary = "导出客户数据", description = "导出客户数据") @Operation(summary = "导出客户数据", description = "导出客户数据")
@GetMapping("/customers/export") @GetMapping("/customers/export")
public void customersExport(SopCustomerSearch search, HttpServletResponse response) { public FileUploadServerData customersExport(SopCustomerSearch search) {
sopInstService.customersExport(search, response); return sopInstService.customersExport(search);
} }
@Operation(summary = "查询模板实例客户详细信息", description = "查询模板实例客户详细信息") @Operation(summary = "查询模板实例客户详细信息", description = "查询模板实例客户详细信息")
......
...@@ -16,6 +16,8 @@ import cn.com.glsx.process.modules.model.*; ...@@ -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.model.enums.SopInstStatusEnum;
import cn.com.glsx.process.modules.rabbitmq.MsgProducer; import cn.com.glsx.process.modules.rabbitmq.MsgProducer;
import cn.com.glsx.process.modules.rabbitmq.RabbitMQConstants; 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.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.glsx.plat.core.enums.SysConstants; import com.glsx.plat.core.enums.SysConstants;
...@@ -31,7 +33,7 @@ import org.springframework.util.Assert; ...@@ -31,7 +33,7 @@ import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import javax.servlet.http.HttpServletResponse; import java.io.ByteArrayOutputStream;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -326,7 +328,7 @@ public class SopInstService { ...@@ -326,7 +328,7 @@ public class SopInstService {
//页面选择是否跳过处理 //页面选择是否跳过处理
SopInstNode sopInstNodeTemp = customNodesMap.get(sopInstNode.getNodeId()); 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); sopInstNodes.add(sopInstNode);
}); });
sopInstNodeMapper.insertList(sopInstNodes); sopInstNodeMapper.insertList(sopInstNodes);
...@@ -356,16 +358,16 @@ public class SopInstService { ...@@ -356,16 +358,16 @@ public class SopInstService {
String sopJourneyStage = search.getSopJourneyStage(); 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(); 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.setCustomerName(search.getCustomerName());
request.setWechatNickname(search.getWechatNickname()); request.setWechatNickname(search.getWechatNickname());
String sopFollowUpPersonId = search.getSopFollowUpPersonId(); 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.setSopFollowUpPersonPhone(search.getSopFollowUpPersonPhone());
request.setSopJourneyEnterTimeBegin(search.getSopJourneyEnterTimeBegin()); request.setSopJourneyEnterTimeBegin(search.getSopJourneyEnterTimeBegin());
...@@ -400,17 +402,19 @@ public class SopInstService { ...@@ -400,17 +402,19 @@ public class SopInstService {
return customerSopJourneyFeignClientT.modifyStage(request); return customerSopJourneyFeignClientT.modifyStage(request);
} }
public void customersExport(SopCustomerSearch search, HttpServletResponse response) { public FileUploadServerData customersExport(SopCustomerSearch search) {
search.setPageSize(5000); search.setPageSize(5000);
// TODO 空判断
SopInst sopInst = sopInstMapper.selectByPrimaryKey(search.getSopJourneyId()); SopInst sopInst = sopInstMapper.selectByPrimaryKey(search.getSopJourneyId());
if (Objects.isNull(sopInst)) {
throw ResultException.create(SystemMessage.ARGS_ERROR.getCode(), "模板实例不存在");
}
List<SopCustomerExcelDTO> data = new ArrayList<>(); List<SopCustomerExcelDTO> data = new ArrayList<>();
List<CustomerSopJourneyDTO> customerSopJourneyDTOList = new ArrayList<>(); List<CustomerSopJourneyDTO> customerSopJourneyDTOList = new ArrayList<>();
getCustomersForExcel(search, customerSopJourneyDTOList); getCustomersForExcel(search, customerSopJourneyDTOList);
if (CollectionUtils.isEmpty(customerSopJourneyDTOList)) { if (CollectionUtils.isEmpty(customerSopJourneyDTOList)) {
return; return null;
} }
customerSopJourneyDTOList.parallelStream().forEach(customerSopJourneyDTO -> { customerSopJourneyDTOList.parallelStream().forEach(customerSopJourneyDTO -> {
...@@ -426,7 +430,11 @@ public class SopInstService { ...@@ -426,7 +430,11 @@ public class SopInstService {
}); });
try { 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) { } catch (Exception e) {
throw ResultException.create(SystemMessage.DATA_HANDLE_ERROR.getCode(), "客户数据导出处理异常"); 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!