Commit 840c87af by 林永健

[+] 增加首页客户旅程统计接口

1 parent 73643ab9
package cn.com.glsx.process.modules.model;
import cn.com.glsx.process.modules.entity.SopInst;
import lombok.Data;
import org.springframework.beans.BeanUtils;
import java.util.Map;
@Data
public class SopInstCustomerStatisticDTO extends SopInst {
/**
* 客户统计数据:Map<阶段, 客户数>
*/
private Map<String, Long> statistics;
public SopInstCustomerStatisticDTO(SopInst inst) {
BeanUtils.copyProperties(inst, this);
}
}
\ No newline at end of file
package cn.com.glsx.process.modules.client;
import cn.com.glsx.cdp.modules.model.customer.CustomerSopJourneyDTO;
import cn.com.glsx.cdp.modules.model.customer.CustomerSopJourneyDetailDTO;
import cn.com.glsx.cdp.modules.model.customer.CustomerSopJourneySearch;
import cn.com.glsx.cdp.modules.model.customer.ModifySopJourneyStageRequest;
import cn.com.glsx.cdp.modules.model.customer.*;
import com.github.pagehelper.PageInfo;
import com.glsx.plat.core.web.Result;
import io.swagger.v3.oas.annotations.Operation;
......@@ -13,6 +10,8 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
* @Title: CustomerSopJourneyFeignClient.java
* @Description: 客户sop旅程
......@@ -35,4 +34,8 @@ public interface CustomerSopJourneyFeignClient_T {
@Operation(description = "修改客户旅程")
@PostMapping("/sopJourneyStage/modify")
Result<Boolean> modifyStage(@RequestBody ModifySopJourneyStageRequest request);
@Operation(description = "查询客户旅程客户统计数据")
@PostMapping("/statistics")
Result<List<CustomerSopJourneyStatisticsDTO>> statisticsCustomerSopJourney(@RequestBody CustomerSopJourneySearch request);
}
......@@ -4,10 +4,7 @@ import cn.com.glsx.cdp.modules.model.customer.CustomerSopJourneyDTO;
import cn.com.glsx.cdp.modules.model.customer.CustomerSopJourneyDetailDTO;
import cn.com.glsx.process.modules.BaseController;
import cn.com.glsx.process.modules.entity.SopInst;
import cn.com.glsx.process.modules.model.SopCustomerSearch;
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.model.*;
import cn.com.glsx.process.modules.service.SopInstService;
import cn.com.glsx.process.util.FileUploadServerData;
import com.github.pagehelper.PageInfo;
......@@ -44,6 +41,12 @@ public class SopInstController extends BaseController {
return sopInstService.selectByGroupId(search);
}
@Operation(summary = "查询门店下SOP模板实例分页列表(包含客户统计数据)", description = "查询门店下SOP模板实例分页列表(包含客户统计数据)")
@GetMapping("/customer/statistic")
public PageInfo<SopInstCustomerStatisticDTO> selectByGroupIdWithCustomer(@Validated SopInstSearch search) {
return sopInstService.selectByGroupIdWithCustomer(search);
}
@Operation(summary = "查询模板实例客户分页列表", description = "查询模板实例客户分页列表")
@GetMapping("/customers")
public Result<PageInfo<CustomerSopJourneyDTO>> customers(SopCustomerSearch search) {
......
package cn.com.glsx.process.modules.service;
import cn.com.glsx.cdp.api.customer.CustomerSopJourneyFeignClient;
import cn.com.glsx.cdp.modules.model.customer.CustomerSopJourneyDTO;
import cn.com.glsx.cdp.modules.model.customer.CustomerSopJourneyDetailDTO;
import cn.com.glsx.cdp.modules.model.customer.CustomerSopJourneySearch;
import cn.com.glsx.cdp.modules.model.customer.ModifySopJourneyStageRequest;
import cn.com.glsx.cdp.modules.model.customer.*;
import cn.com.glsx.process.modules.client.CustomerSopJourneyFeignClient_T;
import cn.com.glsx.process.modules.converter.SopInstConverter;
import cn.com.glsx.process.modules.converter.SopTplConverter;
......@@ -132,6 +129,34 @@ public class SopInstService {
}
/**
* 首页统计接口
* 查询门店下SOP模板实例分页列表(包含客户统计数据)
*/
public PageInfo<SopInstCustomerStatisticDTO> selectByGroupIdWithCustomer(SopInstSearch search) {
PageHelper.startPage(search.getPageNumber(), search.getPageSize());
List<SopInst> list = sopInstMapper.selectByGroupId(search);
if (CollectionUtils.isEmpty(list)) {
return new PageInfo<>();
}
// 获取实例id列表
List<SopInstCustomerStatisticDTO> res = list.stream().map(SopInstCustomerStatisticDTO::new).collect(Collectors.toList());
List<String> instIds = res.stream().filter(p -> StringUtils.hasLength(p.getInstId())).map(p -> p.getInstId()).collect(Collectors.toList());
if (CollectionUtils.isEmpty(instIds)) {
return new PageInfo<>(res);
}
// feign 阶段-客户统计数据
CustomerSopJourneySearch req = new CustomerSopJourneySearch();
req.setSopJourneyIds(instIds);
Result<List<CustomerSopJourneyStatisticsDTO>> result = customerSopJourneyFeignClientT.statisticsCustomerSopJourney(req);
if (result != null && !CollectionUtils.isEmpty(result.getData())) {
Map<String, List<CustomerSopJourneyStatisticsDTO>> resultMap = result.getData().stream().collect(Collectors.groupingBy(p -> p.getSopJourneyId()));
res.forEach(p -> p.setStatistics(resultMap.getOrDefault(p.getInstId(), new ArrayList<>())
.stream().collect(Collectors.toMap(i -> i.getSopJourneyStage(), i -> i.getCount(), Long::sum))));
}
return new PageInfo<>(res);
}
/**
* 通过实例默认输入参数查询指定门店模板实例
*
* @param customData
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!