CustomerChangeProducer.java
1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package cn.fw.valhalla.component.producer;
import cn.fw.valhalla.domain.vo.customer.CustomerDetailVO;
import cn.fw.valhalla.sdk.result.CustomerInfoDto;
import cn.fw.valhalla.service.bus.cust.CustomerBizService;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.Objects;
/**
* @author kurisu
*/
@Slf4j
@Component
public class CustomerChangeProducer {
@Autowired
private RocketMQTemplate rocketMQTemplate;
@Autowired
private CustomerBizService customerBizService;
@RequestMapping(value = "send")
public void send(CustomerInfoDto customerInfoDto) {
try {
log.info("售后保有客信息变更mq: body:[{}]", customerInfoDto);
if (Objects.isNull(customerInfoDto.getGroupId())) {
log.warn("售后保有客信息变更mq集团id为空");
return;
}
CustomerDetailVO detailByVin = customerBizService.getDetailByVin(customerInfoDto.getFrameNo(), customerInfoDto.getGroupId());
BeanUtils.copyProperties(detailByVin, customerInfoDto);
rocketMQTemplate.syncSend(CustomerInfoDto.TOPIC + ":*", customerInfoDto);
} catch (Exception e) {
e.printStackTrace();
}
}
}