Commit bd34af00 by 谢海旭

删除旧的模板下发门店接口、增加查询旅程客户分页列表与详情接口、增加关联活动发布mq消息

1 parent 58bb130b
package cn.com.glsx.process.modules.model;
import cn.hutool.db.Page;
import lombok.Data;
@Data
public class SopCustomerSearch extends Page {
/**
* 组织ID
*/
private String orgId;
/**
* 客户oneID
*/
private String oneId;
/**
* 客户旅程id
*/
private String sopJourneyId;
/**
* 客户旅程阶段
*/
private String sopJourneyStage;
/**
* 客户手机号列表
*/
private String customerPhone;
/**
* 客户姓名
*/
private String customerName;
/**
* 客户微信昵称
*/
private String wechatNickname;
/**
* 客户旅程跟进人id
*/
private String sopFollowUpPersonId;
/**
* 进入sop旅程时间-开始
*/
private String sopJourneyEnterTimeBegin;
/**
* 进入sop旅程时间-结束
*/
private String sopJourneyEnterTimeEnd;
}
...@@ -134,6 +134,19 @@ ...@@ -134,6 +134,19 @@
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-zipkin</artifactId> <artifactId>spring-cloud-sleuth-zipkin</artifactId>
</dependency> </dependency>
<!-- cdp 接口依赖 -->
<dependency>
<groupId>cn.com.glsx</groupId>
<artifactId>platform-cdp-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!--rabbitmq-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
...@@ -25,7 +25,7 @@ import cn.com.glsx.process.job.xxljob.core.SopXxlJobUtil; ...@@ -25,7 +25,7 @@ import cn.com.glsx.process.job.xxljob.core.SopXxlJobUtil;
@EnableDubbo @EnableDubbo
@EnableRestAdmin @EnableRestAdmin
@EnableDiscoveryClient @EnableDiscoveryClient
@EnableFeignClients(basePackages = { "cn.com.glsx.*.api","cn.com.glsx.*.*.api" }) @EnableFeignClients(basePackages = { "cn.com.glsx.*.api", "cn.com.glsx.process.modules.client" })
@SpringBootApplication @SpringBootApplication
@EnableAspectJAutoProxy @EnableAspectJAutoProxy
public class Application implements CommandLineRunner { public class Application implements CommandLineRunner {
......
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 com.github.pagehelper.PageInfo;
import com.glsx.plat.core.web.Result;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
/**
* @Title: CustomerSopJourneyFeignClient.java
* @Description: 客户sop旅程
* @author caiym
* @date 2023年09月13日 11:12:51
* @version V1.0.0
* @Company: didihu.com.cn
* @Copyright Copyright (c) 2021
*/
@FeignClient(name = "platform-cdp1", url = "http://192.168.3.122:8616/cdp/sop", contextId = "customerSopJourney", path = "/api/customerSopJourney", decode404 = true)
public interface CustomerSopJourneyFeignClient_T {
@Operation(description = "分页查询客户旅程信息")
@PostMapping("/page")
Result<PageInfo<CustomerSopJourneyDTO>> pageCustomerSopJourney(@RequestBody CustomerSopJourneySearch request);
@Operation(description = "获取客户旅程详情")
@GetMapping("/detail")
Result<CustomerSopJourneyDetailDTO> detail(@RequestParam("orgId") String orgId, @RequestParam("sopJourneyId") String sopJourneyId, @RequestParam("oneId") String oneId);
}
package cn.com.glsx.process.modules.controller; package cn.com.glsx.process.modules.controller;
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.BaseController;
import cn.com.glsx.process.modules.entity.SopInst; 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.SopInstDTO;
import cn.com.glsx.process.modules.model.SopInstSearch; import cn.com.glsx.process.modules.model.SopInstSearch;
import cn.com.glsx.process.modules.service.SopInstService; import cn.com.glsx.process.modules.service.SopInstService;
...@@ -39,6 +42,18 @@ public class SopInstController extends BaseController { ...@@ -39,6 +42,18 @@ public class SopInstController extends BaseController {
return sopInstService.selectByGroupId(search); return sopInstService.selectByGroupId(search);
} }
@Operation(summary = "查询模板实例客户分页列表", description = "查询模板实例客户分页列表")
@GetMapping("/customers")
public Result<PageInfo<CustomerSopJourneyDTO>> customers(SopCustomerSearch search) {
return sopInstService.customers(search);
}
@Operation(summary = "查询模板实例客户详细信息", description = "查询模板实例客户详细信息")
@GetMapping("/customers/detail")
public Result<CustomerSopJourneyDetailDTO> customerDetail(SopCustomerSearch search) {
return sopInstService.customerDetail(search);
}
@Operation(summary = "根据id查询SOP门店模板实例详情", description = "根据id查询SOP门店模板实例详情") @Operation(summary = "根据id查询SOP门店模板实例详情", description = "根据id查询SOP门店模板实例详情")
@GetMapping("/{instId}") @GetMapping("/{instId}")
public SopInstDTO findById(@PathVariable("instId") String instId) { public SopInstDTO findById(@PathVariable("instId") String instId) {
......
...@@ -37,11 +37,4 @@ public class SopTplGrantController extends BaseController { ...@@ -37,11 +37,4 @@ public class SopTplGrantController extends BaseController {
return sopTplGrantService.list(search); return sopTplGrantService.list(search);
} }
@Operation(summary = "下发门店", description = "下发门店")
@PostMapping
public String add(@RequestBody @Validated List<SopTplGrant> sopTplGrants) {
sopTplGrantService.add(sopTplGrants);
return "success";
}
} }
package cn.com.glsx.process.modules.rabbitmq;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.UUID;
/**
* 编写消息的生产者
*/
@Component
@Slf4j
public class MsgProducer implements RabbitTemplate.ConfirmCallback {
//由于rabbitTemplate的scope属性设置为ConfigurableBeanFactory.SCOPE_PROTOTYPE,所以不能自动注入
private RabbitTemplate rabbitTemplate;
/**
* 构造方法注入rabbitTemplate
*/
@Autowired
public MsgProducer(RabbitTemplate rabbitTemplate) {
this.rabbitTemplate = rabbitTemplate;
rabbitTemplate.setConfirmCallback(this); //rabbitTemplate如果为单例的话,那回调就是最后设置的内容
}
/**
* topic模式
*
* @param content
*/
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);
}
/**
* topic模式
* 交换机使用本项目默认
*
* @param content
*/
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);
}
/**
* 回调
*/
@Override
public void confirm(CorrelationData correlationData, boolean ack, String cause) {
log.info(" 回调id:" + correlationData);
if (ack) {
log.info("交换机已收到id为:{}的消息",correlationData);
} else {
log.info("交换机已收到id为:{}的消息,原因:{}",correlationData, cause);
}
}
}
package cn.com.glsx.process.modules.rabbitmq;
import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class RabbitConfig {
//声明topic交换机
@Bean
public TopicExchange topicExchange(){
//durable(true) 持久化,mq重启之后交换机还在
return ExchangeBuilder.topicExchange(RabbitMQConstants.TOPIC_EXCHANGE_PLATFORM_PROCESS).durable(true).build();
}
}
package cn.com.glsx.process.modules.rabbitmq;
public interface RabbitMQConstants {
String TOPIC_EXCHANGE_PLATFORM_PROCESS = "sop.platform-process";
String ROUTING_KEY_SOP_INST_INST_PARAM_CUSTOM_DATA_UPDATE = "sop_inst.inst_param.custom_data.update";
}
package cn.com.glsx.process.modules.service; 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.process.modules.client.CustomerSopJourneyFeignClient_T;
import cn.com.glsx.process.modules.converter.SopInstConverter; import cn.com.glsx.process.modules.converter.SopInstConverter;
import cn.com.glsx.process.modules.converter.SopTplConverter; import cn.com.glsx.process.modules.converter.SopTplConverter;
import cn.com.glsx.process.modules.converter.SopTplLinKConverter; import cn.com.glsx.process.modules.converter.SopTplLinKConverter;
import cn.com.glsx.process.modules.converter.SopTplNodeConverter; import cn.com.glsx.process.modules.converter.SopTplNodeConverter;
import cn.com.glsx.process.modules.entity.*; import cn.com.glsx.process.modules.entity.*;
import cn.com.glsx.process.modules.mapper.*; import cn.com.glsx.process.modules.mapper.*;
import cn.com.glsx.process.modules.model.SopCustomerSearch;
import cn.com.glsx.process.modules.model.SopInstDTO; 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.SopTplDTO; import cn.com.glsx.process.modules.model.SopTplDTO;
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.RabbitMQConstants;
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.web.Result; import com.glsx.plat.core.web.Result;
import com.glsx.plat.exception.ResultException; import com.glsx.plat.exception.ResultException;
import com.glsx.plat.exception.SystemMessage; import com.glsx.plat.exception.SystemMessage;
import com.google.common.collect.Lists;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -48,6 +58,14 @@ public class SopInstService { ...@@ -48,6 +58,14 @@ public class SopInstService {
@Autowired @Autowired
private SopTplGrantMapper sopTplGrantMapper; private SopTplGrantMapper sopTplGrantMapper;
@Autowired
private CustomerSopJourneyFeignClient customerSopJourneyFeignClient;
@Autowired
private CustomerSopJourneyFeignClient_T customerSopJourneyFeignClientT;
@Autowired
private MsgProducer msgProducer;
/** /**
* 根据id查询 * 根据id查询
...@@ -174,6 +192,10 @@ public class SopInstService { ...@@ -174,6 +192,10 @@ public class SopInstService {
} }
sopInstMapper.updateInstParamCustomData(instId, customData); sopInstMapper.updateInstParamCustomData(instId, customData);
//发送字段数据变更通知消息
customData.put("instId", instId);
msgProducer.topicSend(RabbitMQConstants.ROUTING_KEY_SOP_INST_INST_PARAM_CUSTOM_DATA_UPDATE, customData);
return result; return result;
} }
...@@ -300,6 +322,7 @@ public class SopInstService { ...@@ -300,6 +322,7 @@ public class SopInstService {
sopInstNode.setInstId(instId); sopInstNode.setInstId(instId);
sopInstNode.setNodeStatus(SopInstNode.NODE_STATUS_NORMAL); sopInstNode.setNodeStatus(SopInstNode.NODE_STATUS_NORMAL);
//页面选择是否跳过处理
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);
...@@ -307,4 +330,52 @@ public class SopInstService { ...@@ -307,4 +330,52 @@ public class SopInstService {
sopInstNodeMapper.insertList(sopInstNodes); sopInstNodeMapper.insertList(sopInstNodes);
} }
} }
/**
* 查询模板实例客户分页列表
*
* @param search
* @return
*/
public Result<PageInfo<CustomerSopJourneyDTO>> customers(SopCustomerSearch search) {
String sopJourneyId = search.getSopJourneyId();
SopInst sopInst = sopInstMapper.selectByPrimaryKey(sopJourneyId);
if (Objects.isNull(sopInst)) {
throw ResultException.create(SystemMessage.ARGS_ERROR.getCode(), "该模板实例不存在!");
}
SopTplGrant sopTplGrant = sopTplGrantMapper.selectByPrimaryKey(sopInst.getGrantId());
// 改converter转换
CustomerSopJourneySearch request = new CustomerSopJourneySearch();
request.setPageNum(search.getPageNumber());
request.setPageSize(search.getPageSize());
request.setOrgId(sopTplGrant.getGroupId());
request.setSopJourneyIds(Lists.newArrayList(sopJourneyId));
String sopJourneyStage = search.getSopJourneyStage();
request.setSopJourneyStages(StringUtils.hasLength(sopJourneyStage)? Lists.newArrayList(sopJourneyStage): null);
String customerPhone = search.getCustomerPhone();
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.setSopJourneyEnterTimeBegin(search.getSopJourneyEnterTimeBegin());
request.setSopJourneyEnterTimeEnd(search.getSopJourneyEnterTimeEnd());
return customerSopJourneyFeignClientT.pageCustomerSopJourney(request);
}
/**
* 查询模板实例客户详细信息
*
* @param search
* @return
*/
public Result<CustomerSopJourneyDetailDTO> customerDetail(SopCustomerSearch search) {
return customerSopJourneyFeignClientT.detail(search.getOrgId(), search.getSopJourneyId(), search.getOneId());
}
} }
...@@ -62,70 +62,4 @@ public class SopTplGrantService { ...@@ -62,70 +62,4 @@ public class SopTplGrantService {
sopTplGrantMapper.del(id); sopTplGrantMapper.del(id);
} }
@Transactional
public void add(List<SopTplGrant> sopTplGrants) {
String tplId = sopTplGrants.get(0).getTplId();
List<String> groupIds = sopTplGrants.stream().map(sopTplGrant -> sopTplGrant.getGroupId()).collect(Collectors.toList());
List<SopTplGrant> grants = sopTplGrantMapper.selectByTplIdAndGroupIds(tplId, groupIds);
if (!CollectionUtils.isEmpty(grants)) {
throw ResultException.create(SystemMessage.ARGS_ERROR.getCode(), String.format("%s已存在该旅程,请确认后重新操作", grants.get(0).getGroupName()));
}
Date date = new Date();
//新增派发门店记录
sopTplGrants.forEach(sopTplGrant -> {
sopTplGrant.setGrantStatus(SopTplGrant.GRANT_STATUS_NORMAL);
sopTplGrant.setCreateTime(date);
sopTplGrant.setUpdateTime(date);
});
sopTplGrantMapper.insertList(sopTplGrants);
SopTpl sopTpl = sopTplMapper.selectByPrimaryKey(tplId);
Assert.state(sopTpl != null, "模板不存在!");
SopTplNode nodeQuery = new SopTplNode();
nodeQuery.setTplId(tplId);
List<SopTplNode> nodes = sopTplNodeMapper.select(nodeQuery);
SopTplLink linkQuery = new SopTplLink();
linkQuery.setTplId(tplId);
List<SopTplLink> links = sopTplLinkMapper.select(linkQuery);
SopTplConverter sopTplConverter = SopTplConverter.INSTANCE;
SopTplLinKConverter sopTplLinKConverter = SopTplLinKConverter.INSTANCE;
SopTplNodeConverter sopTplNodeConverter = SopTplNodeConverter.INSTANCE;
for (SopTplGrant sopTplGrant : sopTplGrants) {
Integer grantId = sopTplGrant.getGrantId();
//克隆模板内容
SopInst sopInst = sopTplConverter.do2inst(sopTpl);
sopInst.setInstId(tplId + grantId);
sopInst.setGrantId(grantId);
sopInst.setCreateTime(date);
sopInst.setUpdateTime(date);
sopInst.setInstStatus(SopInstStatusEnum.UNUSED.getValue());
sopInstMapper.insert(sopInst);
//克隆连接
String instId = sopInst.getInstId();
List<SopInstLink> sopInstLinks = new ArrayList<>();
links.forEach(sopTplLink -> {
SopInstLink sopInstLink = sopTplLinKConverter.tpl2inst(sopTplLink);
sopInstLink.setInstId(instId);
sopInstLinks.add(sopInstLink);
});
sopInstLinkMapper.insertList(sopInstLinks);
//克隆节点
List<SopInstNode> sopInstNodes = new ArrayList<>();
nodes.forEach(sopTplNode -> {
SopInstNode sopInstNode = sopTplNodeConverter.tpl2inst(sopTplNode);
sopInstNode.setInstId(instId);
sopInstNode.setNodeSkip(SopInstNode.NODE_SKIP_FALSE);
sopInstNode.setNodeStatus(SopInstNode.NODE_STATUS_NORMAL);
sopInstNodes.add(sopInstNode);
});
sopInstNodeMapper.insertList(sopInstNodes);
}
}
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!