Commit fe0e451c by zhouhaibao

Merge remote-tracking branch 'origin/v1.0.1' into v1.0.1

2 parents 0d46bfb4 59de6caf
......@@ -117,7 +117,7 @@ public class SopInstNode {
* 每日执行次数限制,0表示不限制。
*/
@Column(name = "daily_count")
private Integer dailyCount;
private Integer dailyCount = 0;
@Transient
private List<SopInstNode> sopInstNodeList;
......
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
......@@ -3,6 +3,7 @@ package cn.com.glsx.process.modules.model;
import cn.com.glsx.process.modules.entity.SopInstLink;
import cn.com.glsx.process.modules.entity.SopInstNode;
import cn.com.glsx.process.modules.entity.SopTplGrant;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date;
import java.util.List;
......@@ -39,8 +40,10 @@ public class SopInstDTO {
*/
private String instRemark;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
/**
......
......@@ -67,7 +67,7 @@ public class SopXxlJobUtil {
job = new XxlJobInfo();
}
job.setJobDesc("加载所有SOP实例任务");
job.setScheduleConf("10 */5 * * * ?");
job.setScheduleConf("10 0 */2 * * ?");
job.setExecutorHandler(SOP_LOAD_JOB_ID);
job.setBusKey(SOP_LOAD_JOB_ID);
job.setTriggerStatus(1);
......
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);
}
......@@ -23,7 +23,7 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
@Tag(name = "sop服务")
@RestController
@RequestMapping(value = "/sop")
@RequestMapping(value = "/sop/api")
@ResponseResultBody
public class SopController {
......
......@@ -4,11 +4,9 @@ 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;
import com.glsx.plat.core.annotation.ResponseResultBody;
import com.glsx.plat.core.web.Result;
......@@ -19,7 +17,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
......@@ -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) {
......@@ -58,8 +61,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 = "查询模板实例客户详细信息")
......
......@@ -35,8 +35,9 @@ public class MsgProducer implements RabbitTemplate.ConfirmCallback {
*/
public void topicSend(String exchange,String routingKey,Object content) {
CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
log.info("消息id:{},推送数据到mq:{}",correlationId, JSON.toJSONString(content));
rabbitTemplate.convertAndSend(exchange,routingKey, content,correlationId);
String contentJson = JSON.toJSONString(content);
log.info("消息id:{},推送数据到mq:{}",correlationId, contentJson);
rabbitTemplate.convertAndSend(exchange,routingKey, contentJson,correlationId);
}
/**
......@@ -47,8 +48,9 @@ public class MsgProducer implements RabbitTemplate.ConfirmCallback {
*/
public void topicSend(String routingKey,Object content) {
CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
log.info("消息id:{},推送数据到mq:{}",correlationId, JSON.toJSONString(content));
rabbitTemplate.convertAndSend(RabbitMQConstants.TOPIC_EXCHANGE_PLATFORM_PROCESS,routingKey, content,correlationId);
String contentJson = JSON.toJSONString(content);
log.info("消息id:{},推送数据到mq:{}",correlationId, contentJson);
rabbitTemplate.convertAndSend(RabbitMQConstants.TOPIC_EXCHANGE_PLATFORM_PROCESS,routingKey, contentJson,correlationId);
}
/**
......
......@@ -2,6 +2,7 @@ package cn.com.glsx.process.modules.rabbitmq;
import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
......@@ -9,13 +10,34 @@ import org.springframework.context.annotation.Configuration;
@Configuration
public class RabbitConfig {
public static final String DATA_REPORT_QUEUE_NAME = "dataReport_queue";
public static final String DATA_REPORT_EXCHANGE_NAME = "dataReport_exchange";
public static final String DATA_REPORT_TOPIC = "dataReport.#";
//声明topic交换机
@Bean
public TopicExchange topicExchange(){
public TopicExchange topicExchange() {
//durable(true) 持久化,mq重启之后交换机还在
return ExchangeBuilder.topicExchange(RabbitMQConstants.TOPIC_EXCHANGE_PLATFORM_PROCESS).durable(true).build();
}
@Bean(name = "dataReportQueue")
public Queue dataReportQueue() {
return new Queue(DATA_REPORT_QUEUE_NAME, true);
}
@Bean(name = "dataReportTopicExchange")
public TopicExchange dataReportTopicExchange() {
return new TopicExchange(DATA_REPORT_EXCHANGE_NAME);
}
@Bean
public Binding bindingDataReport(@Qualifier("dataReportQueue") Queue dataReportQueue,
@Qualifier("dataReportTopicExchange") TopicExchange dataReportTopicExchange) {
return BindingBuilder.bind(dataReportQueue).to(dataReportTopicExchange).with(DATA_REPORT_TOPIC);
}
}
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;
......@@ -15,7 +12,10 @@ import cn.com.glsx.process.modules.mapper.*;
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.RabbitConfig;
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 +31,8 @@ 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.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
......@@ -66,7 +67,7 @@ public class SopInstService {
private CustomerSopJourneyFeignClient_T customerSopJourneyFeignClientT;
@Autowired
private MsgProducer msgProducer;
private MsgProducer msgProducer;
/**
* 根据id查询
......@@ -109,7 +110,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;
......@@ -130,6 +131,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
......@@ -172,7 +201,7 @@ public class SopInstService {
/**
* 更新门店模板实例默认参数的自定义参数
*
* @param instId 实例id
* @param instId 实例id
* @param customData 自定义参数
* @return
*/
......@@ -326,7 +355,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 +368,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 +385,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());
......@@ -391,26 +420,56 @@ public class SopInstService {
* @return
*/
public Result<Boolean> stageUpdate(SopJourneyStageUpdate body) {
String orgId = body.getOrgId();
String sopJourneyId = body.getSopJourneyId();
String oneId = body.getOneId();
Result<CustomerSopJourneyDetailDTO> detail = customerSopJourneyFeignClientT.detail(orgId, sopJourneyId, oneId);
if (!SysConstants.ResultStatus.success.getCode().equals(detail.getCode())) {
throw ResultException.create(SystemMessage.ARGS_ERROR.getCode(), "查询客户信息异常");
}
CustomerSopJourneyDetailDTO customerDetail = detail.getData();
if (Objects.isNull(customerDetail)) {
throw ResultException.create(SystemMessage.ARGS_ERROR.getCode(), "客户信息不存在");
}
ModifySopJourneyStageRequest request = new ModifySopJourneyStageRequest();
request.setOrgId(body.getOrgId());
request.setSopJourneyId(body.getSopJourneyId());
request.setOneIds(Lists.newArrayList(body.getOneId()));
request.setOrgId(orgId);
request.setSopJourneyId(sopJourneyId);
request.setOneIds(Lists.newArrayList(oneId));
request.setSopJourneyStage(body.getSopJourneyStage());
request.setOprBy(body.getOprBy());
return customerSopJourneyFeignClientT.modifyStage(request);
Result<Boolean> booleanResult = customerSopJourneyFeignClientT.modifyStage(request);
Date now = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
HashMap<String, Object> mqMap = new HashMap<>();
mqMap.put("org_id", orgId);
mqMap.put("add_way", "SOP");
mqMap.put("customer_phone", customerDetail.getCustomerPhone());
mqMap.put("event_time", sdf.format(now));
mqMap.put("event_type", "MODIFY_SOP_JOURNEY_STAGE");
mqMap.put("platform", "WebPage");
mqMap.put("extra", body);
msgProducer.topicSend(RabbitConfig.DATA_REPORT_EXCHANGE_NAME, "dataReport.customer.event", Lists.newArrayList(mqMap));
return booleanResult;
}
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 +485,13 @@ public class SopInstService {
});
try {
EasyExcelUtils.writeExcel(response, data, "客户数据", "客户数据", SopCustomerExcelDTO.class);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
EasyExcelUtils.writeExcel(outputStream, data, "客户数据", SopCustomerExcelDTO.class);
byte[] bytes = outputStream.toByteArray();
Date now = new Date();
FileUploadServerData fileUploadServerData = FileUploadUtil.uploadToFileSystem(String.format("客户数据_%d", now.getTime()), 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!