Commit 6856ef82 6856ef82f2f45a4566e254e89b02ebcd98aaa6e0 by xianghan

1.优化日志信息

2.清理无用的文件
1 parent 80f8168f
...@@ -9,6 +9,7 @@ import com.topdraw.business.module.exp.detail.service.mapper.ExpDetailMapper; ...@@ -9,6 +9,7 @@ import com.topdraw.business.module.exp.detail.service.mapper.ExpDetailMapper;
9 import com.topdraw.utils.RedisUtils; 9 import com.topdraw.utils.RedisUtils;
10 import com.topdraw.utils.StringUtils; 10 import com.topdraw.utils.StringUtils;
11 import com.topdraw.utils.ValidationUtil; 11 import com.topdraw.utils.ValidationUtil;
12 import lombok.extern.slf4j.Slf4j;
12 import org.springframework.beans.factory.annotation.Autowired; 13 import org.springframework.beans.factory.annotation.Autowired;
13 import org.springframework.dao.EmptyResultDataAccessException; 14 import org.springframework.dao.EmptyResultDataAccessException;
14 import org.springframework.stereotype.Service; 15 import org.springframework.stereotype.Service;
...@@ -23,6 +24,7 @@ import org.springframework.util.Assert; ...@@ -23,6 +24,7 @@ import org.springframework.util.Assert;
23 */ 24 */
24 @Service 25 @Service
25 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) 26 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
27 @Slf4j
26 public class ExpDetailServiceImpl implements ExpDetailService { 28 public class ExpDetailServiceImpl implements ExpDetailService {
27 29
28 @Autowired 30 @Autowired
...@@ -57,8 +59,7 @@ public class ExpDetailServiceImpl implements ExpDetailService { ...@@ -57,8 +59,7 @@ public class ExpDetailServiceImpl implements ExpDetailService {
57 ExpDetail.copy(resources); 59 ExpDetail.copy(resources);
58 this.expDetailRepository.save(ExpDetail); 60 this.expDetailRepository.save(ExpDetail);
59 } catch (Exception e) { 61 } catch (Exception e) {
60 e.printStackTrace(); 62 log.error("修改会员成长值详情异常,ExpDetailServiceImplupdate");
61 throw e;
62 } finally { 63 } finally {
63 this.redisUtils.doUnLock("expDetail::memberId::" + resources.getMemberId()); 64 this.redisUtils.doUnLock("expDetail::memberId::" + resources.getMemberId());
64 } 65 }
......
...@@ -89,7 +89,7 @@ public class MemberAddressBuilder { ...@@ -89,7 +89,7 @@ public class MemberAddressBuilder {
89 89
90 MemberAddress memberAddress = new MemberAddress(); 90 MemberAddress memberAddress = new MemberAddress();
91 memberAddress.setId(Objects.nonNull(id)?null:id); 91 memberAddress.setId(Objects.nonNull(id)?null:id);
92 memberAddress.setMemberId(Objects.isNull(memberId)?null:memberId); 92 memberAddress.setMemberId(memberId);
93 memberAddress.setMemberCode(stringIsNull(memberCode)); 93 memberAddress.setMemberCode(stringIsNull(memberCode));
94 94
95 memberAddress.setSequence(Objects.nonNull(sequence)?null:DEFAULT_VALUE_1); 95 memberAddress.setSequence(Objects.nonNull(sequence)?null:DEFAULT_VALUE_1);
......
1 package com.topdraw.business.module.member.address.service.impl; 1 package com.topdraw.business.module.member.address.service.impl;
2 2
3 import com.topdraw.business.module.member.address.domain.MemberAddress; 3 import com.topdraw.business.module.member.address.domain.MemberAddress;
4 import com.topdraw.business.module.member.address.domain.MemberAddressBuilder;
5 import com.topdraw.business.module.member.address.repository.MemberAddressRepository; 4 import com.topdraw.business.module.member.address.repository.MemberAddressRepository;
6 import com.topdraw.business.module.member.address.service.MemberAddressService; 5 import com.topdraw.business.module.member.address.service.MemberAddressService;
7 import com.topdraw.business.module.member.address.service.dto.MemberAddressDTO; 6 import com.topdraw.business.module.member.address.service.dto.MemberAddressDTO;
8 import com.topdraw.business.module.member.address.service.mapper.MemberAddressMapper; 7 import com.topdraw.business.module.member.address.service.mapper.MemberAddressMapper;
9 import com.topdraw.business.module.member.service.MemberService; 8 import com.topdraw.business.module.member.service.MemberService;
10 import com.topdraw.business.module.member.service.dto.MemberDTO;
11 import com.topdraw.utils.ValidationUtil; 9 import com.topdraw.utils.ValidationUtil;
12 import lombok.extern.slf4j.Slf4j; 10 import lombok.extern.slf4j.Slf4j;
13 import org.springframework.beans.BeanUtils; 11 import org.springframework.beans.BeanUtils;
...@@ -45,10 +43,9 @@ public class MemberAddressServiceImpl implements MemberAddressService { ...@@ -45,10 +43,9 @@ public class MemberAddressServiceImpl implements MemberAddressService {
45 @Override 43 @Override
46 @Transactional(rollbackFor = Exception.class) 44 @Transactional(rollbackFor = Exception.class)
47 public MemberAddressDTO create(MemberAddress resources) { 45 public MemberAddressDTO create(MemberAddress resources) {
48 log.info("MemberAddressServiceImpl ==>> create ==>> param ==>> [{}]",resources); 46 log.info("保存会员地址信息,参数 create# memberAddress ==>> resources ==>> {}", resources);
49 MemberAddress memberAddress = this.memberAddressRepository.save(resources); 47 MemberAddress memberAddress = this.memberAddressRepository.save(resources);
50 48
51 log.info("MemberAddressServiceImpl ==>> create ==>> result ==>> [{}]",resources);
52 MemberAddressDTO memberAddressDTO = new MemberAddressDTO(); 49 MemberAddressDTO memberAddressDTO = new MemberAddressDTO();
53 BeanUtils.copyProperties(memberAddress, memberAddressDTO); 50 BeanUtils.copyProperties(memberAddress, memberAddressDTO);
54 return memberAddressDTO; 51 return memberAddressDTO;
...@@ -58,24 +55,24 @@ public class MemberAddressServiceImpl implements MemberAddressService { ...@@ -58,24 +55,24 @@ public class MemberAddressServiceImpl implements MemberAddressService {
58 @Override 55 @Override
59 @Transactional(rollbackFor = Exception.class) 56 @Transactional(rollbackFor = Exception.class)
60 public MemberAddressDTO update(MemberAddress resources) { 57 public MemberAddressDTO update(MemberAddress resources) {
61 log.info("MemberAddressServiceImpl ==>> update ==>> param ==>> [{}]",resources); 58 log.info("修改会员地址信息,参数 update# memberAddress ==>> resources ==>> {}", resources);
62 Assert.notNull(resources.getId(),"id can't be null"); 59
63 try { 60 try {
64 MemberAddress _memberAddress = this.memberAddressRepository.findById(resources.getId()).orElseGet(MemberAddress::new); 61 MemberAddress memberAddress = this.memberAddressRepository.findById(resources.getId()).orElseGet(MemberAddress::new);
65 ValidationUtil.isNull( _memberAddress.getId(),"MemberAddress","id",resources.getId()); 62 ValidationUtil.isNull( memberAddress.getId(),"MemberAddress","id",resources.getId());
66 _memberAddress.copy(resources); 63 memberAddress.copy(resources);
67 MemberAddress memberAddress = this.memberAddressRepository.save(_memberAddress); 64 MemberAddress memberAddressSaveResult = this.memberAddressRepository.save(memberAddress);
68 65
69 MemberAddressDTO memberAddressDTO = new MemberAddressDTO(); 66 MemberAddressDTO memberAddressDTO = new MemberAddressDTO();
70 BeanUtils.copyProperties(memberAddress, memberAddressDTO); 67 BeanUtils.copyProperties(memberAddressSaveResult, memberAddressDTO);
71 68
72 return memberAddressDTO; 69 return memberAddressDTO;
73 70
74 } catch (Exception e) { 71 } catch (Exception e) {
75 e.printStackTrace(); 72 log.error("修改会员地址信息异常,update# memberAddress message ==>> {}", e.getMessage());
76 throw e;
77 } 73 }
78 74
75 return null;
79 } 76 }
80 77
81 @Override 78 @Override
...@@ -93,25 +90,4 @@ public class MemberAddressServiceImpl implements MemberAddressService { ...@@ -93,25 +90,4 @@ public class MemberAddressServiceImpl implements MemberAddressService {
93 return this.memberAddressMapper.toDto(memberAddress); 90 return this.memberAddressMapper.toDto(memberAddress);
94 } 91 }
95 92
96 /**
97 * 检查会员
98 * @param memberAddress
99 * @return
100 */
101 private MemberDTO checkMember(MemberAddress memberAddress){
102 Long memberId = memberAddress.getMemberId();
103 String memberCode = memberAddress.getMemberCode();
104 return this.checkMember(memberId,memberCode);
105 }
106
107 /**
108 * 检查会员
109 * @param memberId 会员id
110 * @param memberCode 会员code
111 * @return
112 */
113 private MemberDTO checkMember(Long memberId, String memberCode) {
114 return this.memberService.checkMember(memberId, memberCode);
115 }
116
117 } 93 }
......
...@@ -9,9 +9,6 @@ import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO; ...@@ -9,9 +9,6 @@ import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO;
9 import com.topdraw.business.module.member.profile.service.mapper.MemberProfileMapper; 9 import com.topdraw.business.module.member.profile.service.mapper.MemberProfileMapper;
10 import com.topdraw.business.module.member.service.MemberService; 10 import com.topdraw.business.module.member.service.MemberService;
11 import com.topdraw.business.module.member.service.dto.MemberDTO; 11 import com.topdraw.business.module.member.service.dto.MemberDTO;
12 import com.topdraw.util.Base64Util;
13 import com.topdraw.utils.RedisUtils;
14 import com.topdraw.utils.StringUtils;
15 import com.topdraw.utils.ValidationUtil; 12 import com.topdraw.utils.ValidationUtil;
16 import lombok.extern.slf4j.Slf4j; 13 import lombok.extern.slf4j.Slf4j;
17 import org.springframework.beans.BeanUtils; 14 import org.springframework.beans.BeanUtils;
...@@ -42,6 +39,7 @@ public class MemberProfileServiceImpl implements MemberProfileService { ...@@ -42,6 +39,7 @@ public class MemberProfileServiceImpl implements MemberProfileService {
42 private MemberProfileRepository memberProfileRepository; 39 private MemberProfileRepository memberProfileRepository;
43 40
44 @Override 41 @Override
42 @Transactional(readOnly = true)
45 public MemberProfileDTO findById(Long id) { 43 public MemberProfileDTO findById(Long id) {
46 MemberProfile MemberProfile = this.memberProfileRepository.findById(id).orElseGet(MemberProfile::new); 44 MemberProfile MemberProfile = this.memberProfileRepository.findById(id).orElseGet(MemberProfile::new);
47 ValidationUtil.isNull(MemberProfile.getId(),"MemberProfile","id",id); 45 ValidationUtil.isNull(MemberProfile.getId(),"MemberProfile","id",id);
...@@ -49,6 +47,7 @@ public class MemberProfileServiceImpl implements MemberProfileService { ...@@ -49,6 +47,7 @@ public class MemberProfileServiceImpl implements MemberProfileService {
49 } 47 }
50 48
51 @Override 49 @Override
50 @Transactional(readOnly = true)
52 public MemberProfileDTO findByMemberId(Long memberId) { 51 public MemberProfileDTO findByMemberId(Long memberId) {
53 log.info("MemberProfileDTO ==>> findByMemberId ==>> resources ===>> [{}]",memberId); 52 log.info("MemberProfileDTO ==>> findByMemberId ==>> resources ===>> [{}]",memberId);
54 MemberProfile memberProfile = this.memberProfileRepository.findByMemberId(memberId).orElseGet(MemberProfile::new); 53 MemberProfile memberProfile = this.memberProfileRepository.findByMemberId(memberId).orElseGet(MemberProfile::new);
...@@ -56,10 +55,10 @@ public class MemberProfileServiceImpl implements MemberProfileService { ...@@ -56,10 +55,10 @@ public class MemberProfileServiceImpl implements MemberProfileService {
56 } 55 }
57 56
58 @Override 57 @Override
58 @Transactional(readOnly = true)
59 public MemberProfileDTO findByMemberCode(String memberCode) { 59 public MemberProfileDTO findByMemberCode(String memberCode) {
60 log.info("MemberProfileDTO ==>> findByMemberCode ==>> resources ===>> [{}]",memberCode); 60 log.info("MemberProfileDTO ==>> findByMemberCode ==>> resources ===>> [{}]",memberCode);
61 MemberDTO memberDTO = this.memberService.findByCode(memberCode); 61 MemberDTO memberDTO = this.memberService.findByCode(memberCode);
62 log.info("MemberProfileDTO ==>> findByMemberCode ==>> result ===>> [{}]",memberDTO);
63 return this.findByMemberId(memberDTO.getId()); 62 return this.findByMemberId(memberDTO.getId());
64 } 63 }
65 64
...@@ -79,21 +78,18 @@ public class MemberProfileServiceImpl implements MemberProfileService { ...@@ -79,21 +78,18 @@ public class MemberProfileServiceImpl implements MemberProfileService {
79 @Override 78 @Override
80 @Transactional(rollbackFor = Exception.class) 79 @Transactional(rollbackFor = Exception.class)
81 public MemberProfile createDefault(MemberProfile resources) { 80 public MemberProfile createDefault(MemberProfile resources) {
82 MemberProfile memberProfile = MemberProfileBuilder.build(resources); 81 return this.create(MemberProfileBuilder.build(resources));
83 return this.create(memberProfile);
84 } 82 }
85 83
86 @Override 84 @Override
87 @Transactional(rollbackFor = Exception.class) 85 @Transactional(rollbackFor = Exception.class)
88 public MemberProfile createDefault(Member resources) { 86 public MemberProfile createDefault(Member resources) {
89 MemberProfile memberProfile = MemberProfileBuilder.build(resources); 87 return this.create(MemberProfileBuilder.build(resources));
90 return this.create(memberProfile);
91 } 88 }
92 89
93 @Override 90 @Override
94 public MemberProfile createDefaultByMemberId(Long resources) { 91 public MemberProfile createDefaultByMemberId(Long resources) {
95 MemberProfile memberProfile = MemberProfileBuilder.build(resources); 92 return this.create(MemberProfileBuilder.build(resources));
96 return this.create(memberProfile);
97 } 93 }
98 94
99 private MemberDTO checkMember(MemberProfile resources){ 95 private MemberDTO checkMember(MemberProfile resources){
...@@ -111,11 +107,11 @@ public class MemberProfileServiceImpl implements MemberProfileService { ...@@ -111,11 +107,11 @@ public class MemberProfileServiceImpl implements MemberProfileService {
111 // 检查会员是否存在 107 // 检查会员是否存在
112 MemberDTO memberDTO = this.checkMember(resources); 108 MemberDTO memberDTO = this.checkMember(resources);
113 109
114 MemberProfileDTO _memberProfileDTO = this.findByMemberId(memberDTO.getId()); 110 MemberProfileDTO memberProfileDTO = this.findByMemberId(memberDTO.getId());
115 111
116 if (Objects.nonNull(_memberProfileDTO.getId())) { 112 if (Objects.nonNull(memberProfileDTO.getId())) {
117 resources.setId(_memberProfileDTO.getId()); 113 resources.setId(memberProfileDTO.getId());
118 resources.setCreateTime(_memberProfileDTO.getCreateTime()); 114 resources.setCreateTime(memberProfileDTO.getCreateTime());
119 } 115 }
120 116
121 resources.setMemberId(memberDTO.getId()); 117 resources.setMemberId(memberDTO.getId());
...@@ -123,8 +119,8 @@ public class MemberProfileServiceImpl implements MemberProfileService { ...@@ -123,8 +119,8 @@ public class MemberProfileServiceImpl implements MemberProfileService {
123 log.info("memberProfileServiceImpl ==>> update ==>> memberId ==>> {} || resources =>> {}", memberDTO.getId(), resources); 119 log.info("memberProfileServiceImpl ==>> update ==>> memberId ==>> {} || resources =>> {}", memberDTO.getId(), resources);
124 MemberProfile _memberProfile = this.memberProfileRepository.save(resources); 120 MemberProfile _memberProfile = this.memberProfileRepository.save(resources);
125 121
126 MemberProfileDTO memberProfileDTO = new MemberProfileDTO(); 122 MemberProfileDTO memberProfileDTO1 = new MemberProfileDTO();
127 BeanUtils.copyProperties(_memberProfile, memberProfileDTO); 123 BeanUtils.copyProperties(_memberProfile, memberProfileDTO1);
128 return memberProfileDTO; 124 return memberProfileDTO;
129 125
130 } 126 }
......
...@@ -11,7 +11,5 @@ package com.topdraw.exception; ...@@ -11,7 +11,5 @@ package com.topdraw.exception;
11 */ 11 */
12 public interface GlobeExceptionCode { 12 public interface GlobeExceptionCode {
13 13
14 // 会员信息
15 Integer MEMBER_CODE_IS_NULL = 000100001;
16 14
17 } 15 }
......
1 package com.topdraw.exception;
2
3 /**
4 * @author :
5 * @description:
6 * @function :
7 * @date :Created in 2022/5/13 15:50
8 * @version: :
9 * @modified By:
10 * @since : modified in 2022/5/13 15:50
11 */
12 public class RabbitMqExceptionHandler {
13
14
15
16 }
1 package com.topdraw.mq.consumer; 1 package com.topdraw.mq.consumer;
2 2
3 import com.rabbitmq.client.Channel; 3 import com.rabbitmq.client.Channel;
4 import com.topdraw.exception.BadRequestException;
4 import com.topdraw.mq.domain.TableOperationMsg; 5 import com.topdraw.mq.domain.TableOperationMsg;
5 import com.topdraw.resttemplate.RestTemplateClient;
6 import com.topdraw.util.FileUtil;
7 import com.topdraw.util.JSONUtil; 6 import com.topdraw.util.JSONUtil;
8 import lombok.extern.slf4j.Slf4j; 7 import lombok.extern.slf4j.Slf4j;
9 import org.apache.commons.collections4.MapUtils;
10 import org.springframework.amqp.core.Message; 8 import org.springframework.amqp.core.Message;
11 import org.springframework.amqp.rabbit.annotation.*; 9 import org.springframework.amqp.rabbit.annotation.*;
12 import org.springframework.amqp.rabbit.core.RabbitTemplate;
13 import org.springframework.beans.factory.annotation.Autowired; 10 import org.springframework.beans.factory.annotation.Autowired;
14 import org.springframework.beans.factory.annotation.Value;
15 import org.springframework.stereotype.Component; 11 import org.springframework.stereotype.Component;
16 import org.springframework.util.Assert; 12 import org.springframework.util.StringUtils;
17 13
18 import java.io.IOException; 14 import java.io.IOException;
19 import java.time.LocalDate;
20 import java.util.Map;
21 15
22 @Component 16 @Component
23 @Slf4j 17 @Slf4j
24 public class UcEngineManagement2IptvConsumer { 18 public class UcEngineManagement2IptvConsumer {
25 19
26 @Autowired 20 @Autowired
27 AutoRoute autoUser; 21 private AutoRoute autoUser;
28
29 @Autowired
30 RestTemplateClient restTemplateClient;
31
32 @Autowired
33 private RabbitTemplate rabbitTemplate;
34 22
35 // @Value("#{rabbitMqErrorLogConfig.getUceError()}") 23 // @Value("#{rabbitMqErrorLogConfig.getUceError()}")
36 // private Map<String, String> error; 24 // private Map<String, String> error;
...@@ -43,37 +31,28 @@ public class UcEngineManagement2IptvConsumer { ...@@ -43,37 +31,28 @@ public class UcEngineManagement2IptvConsumer {
43 @RabbitHandler 31 @RabbitHandler
44 @RabbitListener(queues = "#{rabbitMqConfig.getMemberInfoQueue()}", 32 @RabbitListener(queues = "#{rabbitMqConfig.getMemberInfoQueue()}",
45 ackMode = "AUTO") 33 ackMode = "AUTO")
34 @Deprecated
46 public void memberInfoConsumer(Channel channel, Message message, String content) throws IOException { 35 public void memberInfoConsumer(Channel channel, Message message, String content) throws IOException {
47 log.info(" receive MemberInfoAsync msg , content is : {} ", content); 36 // TODO 已废弃
37 log.info("同步会员信息,参数 memberInfoConsumer# ==>> {} ", content);
48 38
49 try { 39 try {
50 40
51 TableOperationMsg tableOperationMsg = this.parseContent(content); 41 if (StringUtils.isEmpty(content)) {
42 throw new BadRequestException("无参数");
43 }
44
45 TableOperationMsg tableOperationMsg = JSONUtil.parseMsg2Object(content,TableOperationMsg.class);
46 log.info("同步会员信息,解析参数后的结果,memberInfoConsumer# ==>> {}", tableOperationMsg);
52 47
53 autoUser.route(tableOperationMsg); 48 this.autoUser.route(tableOperationMsg);
54 49
55 // channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); 50 // channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
56 51
57 } catch (Exception e) { 52 } catch (Exception e) {
58 log.error("消费uc-engine消息失败, cause ==>> [memberInfoConsumer#{}]", e.getMessage()); 53 log.error("消费uc-engine消息失败, memberInfoConsumer# message ==>> {}", e.getMessage());
59 // channel.basicReject(message.getMessageProperties().getDeliveryTag(), false); 54 // channel.basicReject(message.getMessageProperties().getDeliveryTag(), false);
60
61 /*if (MapUtils.isNotEmpty(error)) {
62 String errorStart = this.error.get("start");
63
64 if (errorStart.equalsIgnoreCase("true")) {
65 String fileName = this.error.get("fileName")+"_"+ LocalDate.now() +".log";
66 String filePath = this.error.get("filePath");
67 String filePath1 = filePath+fileName;
68 FileUtil.writeStringToFile2(filePath1, content, e.getMessage());
69 }
70
71 }*/
72
73
74 } 55 }
75
76 log.info("ucEventConsumer ====>>>> end");
77 } 56 }
78 57
79 /** 58 /**
...@@ -91,46 +70,27 @@ public class UcEngineManagement2IptvConsumer { ...@@ -91,46 +70,27 @@ public class UcEngineManagement2IptvConsumer {
91 @RabbitHandler 70 @RabbitHandler
92 @RabbitListener(queues = "#{rabbitMqConfig.getUceQueue()}", ackMode = "AUTO") 71 @RabbitListener(queues = "#{rabbitMqConfig.getUceQueue()}", ackMode = "AUTO")
93 public void ucEngineConsumer(Channel channel, Message message, String content) throws IOException { 72 public void ucEngineConsumer(Channel channel, Message message, String content) throws IOException {
94 log.info(" receive ucEngineConsumer msg , content is : {} ", content); 73 log.info("消费uc-engine信息,参数 ucEngineConsumer# content ==>> {} ", content);
95 74
96 try { 75 try {
97 TableOperationMsg tableOperationMsg = this.parseContent(content);
98 76
99 autoUser.route(tableOperationMsg); 77 if (StringUtils.isEmpty(content)) {
100 78 throw new BadRequestException("无参数");
101 // channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); 79 }
102 80
103 } catch (Exception e) { 81 TableOperationMsg tableOperationMsg = JSONUtil.parseMsg2Object(content,TableOperationMsg.class);
104 log.error("消费uc-engine消息失败, cause ==>> [ucEngineConsumer#{}]", e.getMessage());
105 channel.basicReject(message.getMessageProperties().getDeliveryTag(), false);
106 82
107 /*if (MapUtils.isNotEmpty(error)) { 83 log.info("同步会员信息,解析参数后的结果,memberInfoConsumer# ==>> {}", tableOperationMsg);
108 String errorStart = this.error.get("start"); 84 this.autoUser.route(tableOperationMsg);
109 85
110 if (errorStart.equalsIgnoreCase("true")) {
111 String fileName = this.error.get("fileName")+"_"+ LocalDate.now() +".log";
112 String filePath = this.error.get("filePath");
113 String filePath1 = filePath+fileName;
114 FileUtil.writeStringToFile2(filePath1, content, e.getMessage());
115 }
116 86
117 }*/ 87 // channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
118 88
119 e.printStackTrace(); 89 } catch (Exception e) {
120 } 90 log.error("消费uc-engine消息失败, cause ==>> [ucEngineConsumer#{}]", e.getMessage());
121 91
122 log.info("ucEventConsumer ====>>>> end"); 92 // channel.basicReject(message.getMessageProperties().getDeliveryTag(), false);
123 } 93 }
124
125 /**
126 * 数据解析
127 * @param content
128 * @return
129 */
130 private TableOperationMsg parseContent(String content) {
131 TableOperationMsg tableOperationMsg = JSONUtil.parseMsg2Object(content,TableOperationMsg.class);
132 Assert.notNull(tableOperationMsg,"ERROR -->> operationConsumer -->> parseContent -->> 【dataSyncMsg】 not be null !!");
133 return tableOperationMsg;
134 } 94 }
135 95
136 } 96 }
......
...@@ -7,20 +7,14 @@ import com.topdraw.business.module.task.template.constant.TaskEventType; ...@@ -7,20 +7,14 @@ import com.topdraw.business.module.task.template.constant.TaskEventType;
7 import com.topdraw.exception.BadRequestException; 7 import com.topdraw.exception.BadRequestException;
8 import com.topdraw.mq.domain.DataSyncMsg; 8 import com.topdraw.mq.domain.DataSyncMsg;
9 import com.topdraw.resttemplate.RestTemplateClient; 9 import com.topdraw.resttemplate.RestTemplateClient;
10 import com.topdraw.util.FileUtil;
11 import com.topdraw.util.JSONUtil; 10 import com.topdraw.util.JSONUtil;
12 import lombok.Data;
13 import lombok.extern.slf4j.Slf4j; 11 import lombok.extern.slf4j.Slf4j;
14 import org.apache.commons.collections4.MapUtils;
15 import org.apache.commons.lang3.StringUtils; 12 import org.apache.commons.lang3.StringUtils;
16 import org.springframework.amqp.core.Message; 13 import org.springframework.amqp.core.Message;
17 import org.springframework.amqp.rabbit.annotation.*; 14 import org.springframework.amqp.rabbit.annotation.*;
18 import org.springframework.beans.factory.annotation.Autowired; 15 import org.springframework.beans.factory.annotation.Autowired;
19 import org.springframework.beans.factory.annotation.Value;
20 import org.springframework.stereotype.Component; 16 import org.springframework.stereotype.Component;
21 17
22 import java.io.IOException;
23 import java.time.LocalDate;
24 import java.time.LocalDateTime; 18 import java.time.LocalDateTime;
25 import java.util.*; 19 import java.util.*;
26 20
...@@ -50,24 +44,28 @@ public class UcEventBusIptv2ManagementUcEngine { ...@@ -50,24 +44,28 @@ public class UcEventBusIptv2ManagementUcEngine {
50 @RabbitListener(queues = "#{rabbitMqConfig.getEventBusQueue()}", 44 @RabbitListener(queues = "#{rabbitMqConfig.getEventBusQueue()}",
51 ackMode = "AUTO") 45 ackMode = "AUTO")
52 public void eventBusConsumer(Channel channel, Message message, String content) throws Exception { 46 public void eventBusConsumer(Channel channel, Message message, String content) throws Exception {
53 log.info(" receive dataSync msg , content is ==>> {} ", content); 47 log.info("消费eventBus数据,参数 eventBusConsumer# content ==>> {} ", content);
54 try { 48 try {
55 49
50 if (StringUtils.isBlank(content)) {
51 throw new BadRequestException("无参数");
52 }
53
56 DataSyncMsg dataSyncMsg = JSONUtil.parseMsg2Object(content, DataSyncMsg.class); 54 DataSyncMsg dataSyncMsg = JSONUtil.parseMsg2Object(content, DataSyncMsg.class);
57 log.info("解析后的参数 , playContent ==>> {} ", dataSyncMsg); 55 log.info("消费eventBus数据,解析参数,eventBusConsumer# ==>> {} ", dataSyncMsg);
58 56
59 if (Objects.nonNull(dataSyncMsg)) { 57 if (Objects.nonNull(dataSyncMsg)) {
60 58
61 String evt = dataSyncMsg.getEvt(); 59 String evt = dataSyncMsg.getEvt();
62 if (StringUtils.isBlank(evt)) { 60 if (StringUtils.isBlank(evt)) {
63 log.error("eventBus事件类型(evt)为空"); 61 log.error("消费eventBus数据异常,eventBusConsumer# message ==>> eventBus事件类型(evt)为空");
64 throw new BadRequestException("参数错误,事件类型 evt不存在"); 62 throw new BadRequestException("参数错误,事件类型 evt不存在");
65 } 63 }
66 64
67 LocalDateTime time = dataSyncMsg.getTime(); 65 LocalDateTime time = dataSyncMsg.getTime();
68 if (Objects.isNull(time)) { 66 if (Objects.isNull(time)) {
69 log.error("参数错误,事件发送时间(time)不存在"); 67 log.error("消费eventBus数据异常,eventBusConsumer# message ==>> 发送时间(time)不存在");
70 throw new BadRequestException("参数错误,事件发送时间(time)不存在"); 68 throw new BadRequestException("参数错误,发送时间(time)不得为空");
71 } /*else { 69 } /*else {
72 if (time.isAfter(LocalDateTime.now()) || time.toLocalDate().compareTo(LocalDate.now()) != 0) { 70 if (time.isAfter(LocalDateTime.now()) || time.toLocalDate().compareTo(LocalDate.now()) != 0) {
73 log.error("参数错误,事件发送时间(time)非法 ==>> {}", time); 71 log.error("参数错误,事件发送时间(time)非法 ==>> {}", time);
...@@ -77,8 +75,8 @@ public class UcEventBusIptv2ManagementUcEngine { ...@@ -77,8 +75,8 @@ public class UcEventBusIptv2ManagementUcEngine {
77 75
78 String msgData = dataSyncMsg.getMsgData(); 76 String msgData = dataSyncMsg.getMsgData();
79 if (StringUtils.isBlank(msgData)) { 77 if (StringUtils.isBlank(msgData)) {
80 log.error("eventBus事件消息体(msgData)为空"); 78 log.error("消费eventBus数据异常,eventBusConsumer# message ==>> 消息体(msgData)为空");
81 throw new BadRequestException("参数错误,事件类型 evt不存在"); 79 throw new BadRequestException("参数错误,消息体(msgData)不得为空");
82 } 80 }
83 81
84 switch (dataSyncMsg.getEvt().toUpperCase()) { 82 switch (dataSyncMsg.getEvt().toUpperCase()) {
...@@ -97,7 +95,7 @@ public class UcEventBusIptv2ManagementUcEngine { ...@@ -97,7 +95,7 @@ public class UcEventBusIptv2ManagementUcEngine {
97 95
98 } catch (Exception e) { 96 } catch (Exception e) {
99 97
100 log.error("eventBus 消费异常 ==>> {}",e.getMessage()); 98 log.error("eventBus消费异常,eventBusConsumer# message ==>> {}", e.getMessage());
101 99
102 // TODO使用slf4j记录日志 100 // TODO使用slf4j记录日志
103 /*if (MapUtils.isNotEmpty(error)) { 101 /*if (MapUtils.isNotEmpty(error)) {
...@@ -113,7 +111,7 @@ public class UcEventBusIptv2ManagementUcEngine { ...@@ -113,7 +111,7 @@ public class UcEventBusIptv2ManagementUcEngine {
113 }*/ 111 }*/
114 112
115 } 113 }
116 log.info("eventBusConsumer ====>>>> end"); 114
117 } 115 }
118 116
119 /** 117 /**
......
...@@ -6,21 +6,15 @@ import com.rabbitmq.client.Channel; ...@@ -6,21 +6,15 @@ import com.rabbitmq.client.Channel;
6 import com.topdraw.exception.BadRequestException; 6 import com.topdraw.exception.BadRequestException;
7 import com.topdraw.mq.domain.DataSyncMsg; 7 import com.topdraw.mq.domain.DataSyncMsg;
8 import com.topdraw.resttemplate.RestTemplateClient; 8 import com.topdraw.resttemplate.RestTemplateClient;
9 import com.topdraw.util.FileUtil;
10 import com.topdraw.util.JSONUtil; 9 import com.topdraw.util.JSONUtil;
11 import lombok.extern.slf4j.Slf4j; 10 import lombok.extern.slf4j.Slf4j;
12 import org.apache.commons.collections4.MapUtils;
13 import org.apache.commons.lang3.StringUtils;
14 import org.springframework.amqp.core.Message; 11 import org.springframework.amqp.core.Message;
15 import org.springframework.amqp.rabbit.annotation.*; 12 import org.springframework.amqp.rabbit.annotation.*;
16 import org.springframework.beans.factory.annotation.Autowired; 13 import org.springframework.beans.factory.annotation.Autowired;
17 import org.springframework.beans.factory.annotation.Value;
18 import org.springframework.stereotype.Component; 14 import org.springframework.stereotype.Component;
15 import org.springframework.util.StringUtils;
19 16
20 import java.io.IOException; 17 import java.io.IOException;
21 import java.time.LocalDate;
22 import java.util.Map;
23 import java.util.Objects;
24 18
25 @Component 19 @Component
26 @Slf4j 20 @Slf4j
...@@ -48,34 +42,23 @@ public class UcGatewayIptv2IptvConsumer { ...@@ -48,34 +42,23 @@ public class UcGatewayIptv2IptvConsumer {
48 @RabbitListener(queues = "#{rabbitMqConfig.getUcgEventQueue()}", 42 @RabbitListener(queues = "#{rabbitMqConfig.getUcgEventQueue()}",
49 ackMode = "AUTO") 43 ackMode = "AUTO")
50 public void eventConsumer(Channel channel, Message message, String content) throws IOException { 44 public void eventConsumer(Channel channel, Message message, String content) throws IOException {
51 log.info(" eventConsumer receive dataSync msg , content is : {} ", content); 45 log.info("消费uc-gateway任务消息,参数eventConsumer# content ==>> {} ", content);
52 try { 46 try {
53 DataSyncMsg dataSyncMsg = JSONUtil.parseMsg2Object(content, DataSyncMsg.class);
54 47
55 if (Objects.nonNull(dataSyncMsg)) { 48 if (StringUtils.isEmpty(content)) {
56 boolean jsonObject = this.restTemplateClient.dealTask(dataSyncMsg); 49 throw new BadRequestException("无参数");
57 if (!jsonObject) {
58 throw new BadRequestException("uce处理任务响应超时");
59 } 50 }
60 }
61
62 } catch (Exception e) {
63
64 log.error("普通权益事件处理异常, ==>> {}", e.getMessage());
65 51
66 /*if (MapUtils.isNotEmpty(error)) { 52 DataSyncMsg dataSyncMsg = JSONUtil.parseMsg2Object(content, DataSyncMsg.class);
67 String errorStart = this.error.get("start"); 53 log.info("消费uc-gateway任务消息,解析参数结果,eventBusConsumer# dataSyncMsg ==>> {} ", dataSyncMsg);
68 54
69 if (StringUtils.isEmpty(errorStart) || errorStart.equalsIgnoreCase("true")) { 55 if (!this.restTemplateClient.dealTask(dataSyncMsg)) {
70 String fileName = this.error.get("fileName")+"_"+ LocalDate.now() +".log"; 56 throw new BadRequestException("uce处理任务响应超时");
71 String filePath = this.error.get("filePath");
72 String filePath1 = filePath+fileName;
73 FileUtil.writeStringToFile2(filePath1, content, e.getMessage());
74 } 57 }
75 58
76 }*/ 59 } catch (Exception e) {
60 log.error("普通权益事件处理异常,eventConsumer# message ==>> {}", e.getMessage());
77 } 61 }
78 log.info("ucEventConsumer ====>>>> end");
79 } 62 }
80 63
81 64
...@@ -93,49 +76,45 @@ public class UcGatewayIptv2IptvConsumer { ...@@ -93,49 +76,45 @@ public class UcGatewayIptv2IptvConsumer {
93 @RabbitListener(queues = "#{rabbitMqConfig.getGrowthReportQueue()}", 76 @RabbitListener(queues = "#{rabbitMqConfig.getGrowthReportQueue()}",
94 ackMode = "AUTO") 77 ackMode = "AUTO")
95 public void dealGrowthReport(Channel channel, Message message, String content) throws IOException { 78 public void dealGrowthReport(Channel channel, Message message, String content) throws IOException {
96 log.info("receive dealGrowthReport add message, content {}", content); 79 log.info("消费uc-gateway成长报告消息,参数 dealGrowthReport# content ==>> {}", content);
97 80
98 try { 81 try {
99 82
100 JSONObject jsonObject = JSON.parseObject(content, JSONObject.class); 83 if (StringUtils.isEmpty(content)) {
101 if (Objects.nonNull(content)) { 84 throw new BadRequestException("无参数");
102 Object msgData = jsonObject.get("msgData");
103 Boolean response = this.restTemplateClient.saveGrowthReport(JSON.toJSONString(msgData));
104 if (!response) {
105 log.error("同步大屏成长报告失败,uce接口响应超时");
106 }
107 } 85 }
108 86
109 } catch (Exception e) { 87 JSONObject jsonObject = JSON.parseObject(content, JSONObject.class);
110 log.error("同步大屏成长报告失败,cause ==>> {}", e.getMessage()); 88 log.info("消费uc-gateway任务消息,解析参数结果,dealGrowthReport# jsonObject ==>> {} ", jsonObject);
111
112 /*if (MapUtils.isNotEmpty(error)) {
113 String errorStart = this.error.get("start");
114 89
115 if (errorStart.equalsIgnoreCase("true")) { 90 if (!this.restTemplateClient.saveGrowthReport(JSON.toJSONString(jsonObject.get("msgData")))) {
116 String fileName = this.error.get("fileName")+"_"+ LocalDate.now() +".log"; 91 log.error("同步大屏成长报告失败,uce接口响应超时");
117 String filePath = this.error.get("filePath");
118 String filePath1 = filePath+fileName;
119 FileUtil.writeStringToFile2(filePath1, content, e.getMessage());
120 } 92 }
121 93
122 }*/ 94 } catch (Exception e) {
95 log.error("消费uc-gateway成长报告消息异常,dealGrowthReport# message ==>> {}", e.getMessage());
123 } 96 }
124 } 97 }
125 98
126 /** 99 /**
127 * @description 添加收藏记录 100 * @description 收藏记录
128 * @param content 消息内容 101 * @param content 消息内容
129 */ 102 */
130 @RabbitHandler 103 @RabbitHandler
131 @RabbitListener(queues = "#{rabbitMqConfig.getUcgCollectionQueue()}", ackMode = "AUTO") 104 @RabbitListener(queues = "#{rabbitMqConfig.getUcgCollectionQueue()}", ackMode = "AUTO")
132 public void collectionConsumer(Channel channel, Message message, String content) throws IOException { 105 public void collectionConsumer(Channel channel, Message message, String content) throws IOException {
133 log.info("receive UserCollection add message, content {}", content); 106 // TODO 收藏统一的操作入口,uc-gateway需要修改发送的队列
107 log.info("消费uc-gateway收藏操作消息,参数 collectionConsumer# content ==>> {}", content);
134 108
135 try { 109 try {
136 110
111 if (StringUtils.isEmpty(content)) {
112 throw new BadRequestException("无参数");
113 }
114
137 JSONObject jsonObject = JSON.parseObject(content, JSONObject.class); 115 JSONObject jsonObject = JSON.parseObject(content, JSONObject.class);
138 if (Objects.nonNull(content)) { 116 log.info("消费uc-gateway收藏操作消息,解析参数结果,collectionConsumer# jsonObject ==>> {} ", jsonObject);
117
139 String evt = jsonObject.get("evt").toString(); 118 String evt = jsonObject.get("evt").toString();
140 String msgData = jsonObject.get("msgData").toString(); 119 String msgData = jsonObject.get("msgData").toString();
141 switch (evt.toUpperCase()) { 120 switch (evt.toUpperCase()) {
...@@ -155,24 +134,9 @@ public class UcGatewayIptv2IptvConsumer { ...@@ -155,24 +134,9 @@ public class UcGatewayIptv2IptvConsumer {
155 break; 134 break;
156 135
157 } 136 }
158 }
159 137
160 } catch (Exception e) { 138 } catch (Exception e) {
161 139 log.error("消费uc-gateway收藏操作消息异常,collectionConsumer# massage ==>> {}", e.getMessage());
162 log.error("收藏事件处理异常,cause ==>> {}", e.getMessage());
163
164 /*if (MapUtils.isNotEmpty(error)) {
165 String errorStart = this.error.get("start");
166
167 if (errorStart.equalsIgnoreCase("true")) {
168 String fileName = this.error.get("fileName")+"_"+ LocalDate.now() +".log";
169 String filePath = this.error.get("filePath");
170 String filePath1 = filePath+fileName;
171 FileUtil.writeStringToFile2(filePath1, content, e.getMessage());
172 }
173
174 }*/
175
176 } 140 }
177 } 141 }
178 142
...@@ -188,40 +152,26 @@ public class UcGatewayIptv2IptvConsumer { ...@@ -188,40 +152,26 @@ public class UcGatewayIptv2IptvConsumer {
188 @RabbitHandler 152 @RabbitHandler
189 @RabbitListener(queues = "#{rabbitMqConfig.getViewRecordQueue()}", ackMode = "AUTO") 153 @RabbitListener(queues = "#{rabbitMqConfig.getViewRecordQueue()}", ackMode = "AUTO")
190 public void viewRecordConsumer(Channel channel, Message message, String content) throws IOException { 154 public void viewRecordConsumer(Channel channel, Message message, String content) throws IOException {
191 log.info("viewRecordConsumer receive ViewRecord add message, content {}", content); 155 log.info("消费uc-gateway观影记录消息,参数 viewRecordConsumer# content ==>> {}", content);
192 156
193 try { 157 try {
194 158
159 if (StringUtils.isEmpty(content)) {
160 throw new BadRequestException("无参数");
161 }
162
195 JSONObject jsonObject = JSON.parseObject(content, JSONObject.class); 163 JSONObject jsonObject = JSON.parseObject(content, JSONObject.class);
196 if (Objects.nonNull(content)) { 164 log.info("消费uc-gateway观影记录消息,解析参数结果,viewRecordConsumer# jsonObject ==>> {} ", jsonObject);
165
197 String evt = jsonObject.get("evt").toString(); 166 String evt = jsonObject.get("evt").toString();
198 String msgData = jsonObject.get("msgData").toString(); 167 String msgData = jsonObject.get("msgData").toString();
199 switch (evt.toUpperCase()) { 168 // 观影
200 // 添加收藏 169 if ("VIEWING".equals(evt.toUpperCase())) {
201 case "VIEWRECORD":
202 this.restTemplateClient.dealViewRecord(msgData); 170 this.restTemplateClient.dealViewRecord(msgData);
203 break;
204 default:
205 break;
206 }
207 } 171 }
208 172
209 } catch (Exception e) { 173 } catch (Exception e) {
210 log.error("观影事件处理异常,cause ==>> {}", e.getMessage()); 174 log.error("消费uc-gateway观影记录消息,viewRecordConsumer# message ==>> {}", e.getMessage());
211
212 /*if (MapUtils.isNotEmpty(error)) {
213 String errorStart = this.error.get("start");
214
215 if (errorStart.equalsIgnoreCase("true")) {
216 String fileName = this.error.get("fileName")+"_"+ LocalDate.now() +".log";
217 String filePath = this.error.get("filePath");
218 String filePath1 = filePath+fileName;
219 FileUtil.writeStringToFile2(filePath1, content, e.getMessage());
220 }
221
222 }*/
223
224
225 } 175 }
226 } 176 }
227 177
...@@ -239,50 +189,27 @@ public class UcGatewayIptv2IptvConsumer { ...@@ -239,50 +189,27 @@ public class UcGatewayIptv2IptvConsumer {
239 @RabbitListener(queues = "#{rabbitMqConfig.getUcgCollectionQueueAdd()}", 189 @RabbitListener(queues = "#{rabbitMqConfig.getUcgCollectionQueueAdd()}",
240 ackMode = "AUTO") 190 ackMode = "AUTO")
241 public void collectionConsumerAdd(Channel channel, Message message, String content) throws IOException { 191 public void collectionConsumerAdd(Channel channel, Message message, String content) throws IOException {
242 log.info("receive collectionConsumerAdd add message, content {}", content); 192 log.info("消费uc-gateway添加收藏记录事件,参数 collectionConsumerAdd# content ==>> {} ", content);
243 193
244 try { 194 try {
245 195
196 if (StringUtils.isEmpty(content)) {
197 throw new BadRequestException("无参数");
198 }
199
246 JSONObject jsonObject = JSON.parseObject(content, JSONObject.class); 200 JSONObject jsonObject = JSON.parseObject(content, JSONObject.class);
247 if (Objects.nonNull(content)) { 201 log.info("消费uc-gateway添加收藏记录事件,解析参数结果,collectionConsumerAdd# jsonObject ==>> {} ", jsonObject);
202
248 String evt = jsonObject.get("evt").toString(); 203 String evt = jsonObject.get("evt").toString();
249 String msgData = jsonObject.get("msgData").toString(); 204 String msgData = jsonObject.get("msgData").toString();
250 switch (evt.toUpperCase()) {
251 // 添加收藏 205 // 添加收藏
252 case "ADDCOLLECTION": 206 if ("ADDCOLLECTION".equals(evt.toUpperCase())) {
253 this.restTemplateClient.addCollection(msgData); 207 this.restTemplateClient.addCollection(msgData);
254 break;
255 // 删除收藏
256 case "DELETECOLLECTION":
257 this.restTemplateClient.deleteCollection(msgData);
258 break;
259 // 删除全部收藏
260 case "DELETEALLCOLLECTION":
261 this.restTemplateClient.deleteAllCollection(msgData);
262 break;
263 default:
264 break;
265
266 }
267 } 208 }
268 209
269 210
270 } catch (Exception e) { 211 } catch (Exception e) {
271
272 log.error("添加收藏记录事件处理异常,cause ==>> {}", e.getMessage()); 212 log.error("添加收藏记录事件处理异常,cause ==>> {}", e.getMessage());
273
274 /*if (MapUtils.isNotEmpty(error)) {
275 String errorStart = this.error.get("start");
276
277 if (errorStart.equalsIgnoreCase("true")) {
278 String fileName = this.error.get("fileName")+"_"+ LocalDate.now() +".log";
279 String filePath = this.error.get("filePath");
280 String filePath1 = filePath+fileName;
281 FileUtil.writeStringToFile2(filePath1, content, e.getMessage());
282 }
283
284 }*/
285
286 } 213 }
287 } 214 }
288 215
...@@ -298,48 +225,27 @@ public class UcGatewayIptv2IptvConsumer { ...@@ -298,48 +225,27 @@ public class UcGatewayIptv2IptvConsumer {
298 @RabbitHandler 225 @RabbitHandler
299 @RabbitListener(queues = "#{rabbitMqConfig.getUcgCollectionQueueDelete()}", ackMode = "AUTO") 226 @RabbitListener(queues = "#{rabbitMqConfig.getUcgCollectionQueueDelete()}", ackMode = "AUTO")
300 public void collectionConsumerDelete(Channel channel, Message message, String content) throws IOException { 227 public void collectionConsumerDelete(Channel channel, Message message, String content) throws IOException {
301 log.info("receive collectionConsumerDelete add message, content {}", content); 228 log.info("消费uc-gateway删除收藏记录,参数 collectionConsumerDelete# content ==>> {}", content);
302 229
303 try { 230 try {
231
232 if (StringUtils.isEmpty(content)) {
233 throw new BadRequestException("无参数");
234 }
235
304 JSONObject jsonObject = JSON.parseObject(content, JSONObject.class); 236 JSONObject jsonObject = JSON.parseObject(content, JSONObject.class);
305 if (Objects.nonNull(content)) { 237 log.info("消费uc-gateway删除收藏记录,解析参数结果,collectionConsumerDelete# jsonObject ==>> {} ", jsonObject);
238
306 String evt = jsonObject.get("evt").toString(); 239 String evt = jsonObject.get("evt").toString();
307 String msgData = jsonObject.get("msgData").toString(); 240 String msgData = jsonObject.get("msgData").toString();
308 switch (evt.toUpperCase()) {
309 // 添加收藏
310 case "ADDCOLLECTION":
311 this.restTemplateClient.addCollection(msgData);
312 break;
313 // 删除收藏 241 // 删除收藏
314 case "DELETECOLLECTION": 242 if ("DELETECOLLECTION".equals(evt.toUpperCase())) {
315 this.restTemplateClient.deleteCollection(msgData); 243 this.restTemplateClient.deleteCollection(msgData);
316 break;
317 // 删除全部收藏
318 case "DELETEALLCOLLECTION":
319 this.restTemplateClient.deleteAllCollection(msgData);
320 break;
321 default:
322 break;
323
324 }
325 } 244 }
326 245
327 } catch (Exception e) { 246 } catch (Exception e) {
328 247
329 log.error("删除收藏记录事件处理异常,cause ==>> {}", e.getMessage()); 248 log.error("消费uc-gateway删除收藏记录异常,collectionConsumerDelete# message ==>> {}", e.getMessage());
330
331 /* if (MapUtils.isNotEmpty(error)) {
332 String errorStart = this.error.get("start");
333
334 if (errorStart.equalsIgnoreCase("true")) {
335 String fileName = this.error.get("fileName")+"_"+ LocalDate.now() +".log";
336 String filePath = this.error.get("filePath");
337 String filePath1 = filePath+fileName;
338 FileUtil.writeStringToFile2(filePath1, content, e.getMessage());
339 }
340
341 }*/
342
343 249
344 } 250 }
345 } 251 }
...@@ -357,53 +263,27 @@ public class UcGatewayIptv2IptvConsumer { ...@@ -357,53 +263,27 @@ public class UcGatewayIptv2IptvConsumer {
357 @RabbitListener(queues = "#{rabbitMqConfig.getUcgCollectionQueueDeleteAll()}", 263 @RabbitListener(queues = "#{rabbitMqConfig.getUcgCollectionQueueDeleteAll()}",
358 ackMode = "AUTO") 264 ackMode = "AUTO")
359 public void collectionConsumerDeleteAll(Channel channel, Message message, String content) throws IOException { 265 public void collectionConsumerDeleteAll(Channel channel, Message message, String content) throws IOException {
360 log.info("receive collectionConsumerDeleteAll add message, content {}", content); 266 log.info("消费uc-gateway删除全部收藏记录,参数 collectionConsumerDeleteAll# content ==>> {}", content);
361 267
362 try { 268 try {
363 269
270 if (StringUtils.isEmpty(content)) {
271 throw new BadRequestException("无参数");
272 }
273
364 JSONObject jsonObject = JSON.parseObject(content, JSONObject.class); 274 JSONObject jsonObject = JSON.parseObject(content, JSONObject.class);
365 if (Objects.nonNull(content)) { 275 log.info("消费uc-gateway删除全部收藏记录,解析参数结果,collectionConsumerDeleteAll# jsonObject ==>> {} ", jsonObject);
276
366 String evt = jsonObject.get("evt").toString(); 277 String evt = jsonObject.get("evt").toString();
367 String msgData = jsonObject.get("msgData").toString(); 278 String msgData = jsonObject.get("msgData").toString();
368 switch (evt.toUpperCase()) {
369 // 添加收藏
370 case "ADDCOLLECTION":
371 this.restTemplateClient.addCollection(msgData);
372 break;
373 // 删除收藏
374 case "DELETECOLLECTION":
375 this.restTemplateClient.deleteCollection(msgData);
376 break;
377 // 删除全部收藏 279 // 删除全部收藏
378 case "DELETEALLCOLLECTION": 280 if ("DELETEALLCOLLECTION".equals(evt.toUpperCase())) {
379 this.restTemplateClient.deleteAllCollection(msgData); 281 this.restTemplateClient.deleteAllCollection(msgData);
380 break;
381 default:
382 break;
383
384 }
385 } 282 }
386 283
387 } catch (Exception e) { 284 } catch (Exception e) {
388 log.error("删除全部收藏记录事件处理异常,cause ==>> {}", e.getMessage()); 285 log.error("消费uc-gateway删除全部收藏记录,collectionConsumerDeleteAll# message ==>> {}", e.getMessage());
389
390 /*if (MapUtils.isNotEmpty(error)) {
391 String errorStart = this.error.get("start");
392
393 if (errorStart.equalsIgnoreCase("true")) {
394 String fileName = this.error.get("fileName")+"_"+ LocalDate.now() +".log";
395 String filePath = this.error.get("filePath");
396 String filePath1 = filePath+fileName;
397 FileUtil.writeStringToFile2(filePath1, content, e.getMessage());
398 }
399
400 }*/
401 } 286 }
402 } 287 }
403 288
404
405
406
407
408
409 } 289 }
......
...@@ -3,21 +3,17 @@ package com.topdraw.mq.consumer; ...@@ -3,21 +3,17 @@ package com.topdraw.mq.consumer;
3 3
4 import com.alibaba.fastjson.JSONObject; 4 import com.alibaba.fastjson.JSONObject;
5 import com.rabbitmq.client.Channel; 5 import com.rabbitmq.client.Channel;
6 import com.topdraw.exception.BadRequestException;
6 import com.topdraw.mq.domain.SubscribeBean; 7 import com.topdraw.mq.domain.SubscribeBean;
7 import com.topdraw.resttemplate.RestTemplateClient; 8 import com.topdraw.resttemplate.RestTemplateClient;
8 import com.topdraw.util.FileUtil;
9 import lombok.extern.slf4j.Slf4j; 9 import lombok.extern.slf4j.Slf4j;
10 import org.apache.commons.collections4.MapUtils;
11 import org.springframework.amqp.core.Message; 10 import org.springframework.amqp.core.Message;
12 import org.springframework.amqp.rabbit.annotation.*; 11 import org.springframework.amqp.rabbit.annotation.*;
13 import org.springframework.beans.factory.annotation.Autowired; 12 import org.springframework.beans.factory.annotation.Autowired;
14 import org.springframework.beans.factory.annotation.Value;
15 import org.springframework.stereotype.Component; 13 import org.springframework.stereotype.Component;
16 import org.springframework.transaction.annotation.Transactional; 14 import org.springframework.util.StringUtils;
17 15
18 import java.io.IOException; 16 import java.io.IOException;
19 import java.time.LocalDate;
20 import java.util.Map;
21 17
22 /** 18 /**
23 * 微信事件 19 * 微信事件
...@@ -49,9 +45,15 @@ public class WeiXinEventConsumer { ...@@ -49,9 +45,15 @@ public class WeiXinEventConsumer {
49 @RabbitHandler 45 @RabbitHandler
50 @RabbitListener(queues = "#{rabbitMqConfig.getWechatQueue()}", ackMode = "AUTO") 46 @RabbitListener(queues = "#{rabbitMqConfig.getWechatQueue()}", ackMode = "AUTO")
51 public void subOrUnSubEvent(Channel channel, Message message, String content) throws IOException { 47 public void subOrUnSubEvent(Channel channel, Message message, String content) throws IOException {
48 log.info("消费wechat-gate公众号关注、取关消息,参数 subOrUnSubEvent# content ==>> {}", content);
52 try { 49 try {
53 log.info("receive wxu subOrUnSub message, content {}", content); 50
51 if (StringUtils.isEmpty(content)) {
52 throw new BadRequestException("无参数");
53 }
54
54 JSONObject jsonObject = JSONObject.parseObject(content); 55 JSONObject jsonObject = JSONObject.parseObject(content);
56 log.info("消费uc-gate公众号关注、取关消息,解析参数结果,subOrUnSubEvent# jsonObject ==>> {} ", jsonObject);
55 57
56 JSONObject map = jsonObject.getJSONObject("appIdMap"); 58 JSONObject map = jsonObject.getJSONObject("appIdMap");
57 JSONObject wechatMsg = jsonObject.getJSONObject("allFieldsMap"); 59 JSONObject wechatMsg = jsonObject.getJSONObject("allFieldsMap");
...@@ -65,8 +67,6 @@ public class WeiXinEventConsumer { ...@@ -65,8 +67,6 @@ public class WeiXinEventConsumer {
65 String event = wechatMsg.getString("Event"); 67 String event = wechatMsg.getString("Event");
66 String eventKey = wechatMsg.getString("EventKey"); 68 String eventKey = wechatMsg.getString("EventKey");
67 69
68 log.info("event ==>> {}", event);
69
70 SubscribeBean subscribeBean = new SubscribeBean(); 70 SubscribeBean subscribeBean = new SubscribeBean();
71 subscribeBean.setAppid(appid); 71 subscribeBean.setAppid(appid);
72 subscribeBean.setOpenid(openid); 72 subscribeBean.setOpenid(openid);
...@@ -74,38 +74,18 @@ public class WeiXinEventConsumer { ...@@ -74,38 +74,18 @@ public class WeiXinEventConsumer {
74 subscribeBean.setEventKey(eventKey); 74 subscribeBean.setEventKey(eventKey);
75 75
76 if (event.equals("subscribe")) { 76 if (event.equals("subscribe")) {
77 log.info("send subscribe request start");
78 this.restTemplateClient.subscribe(subscribeBean); 77 this.restTemplateClient.subscribe(subscribeBean);
79 log.info("send subscribe request end ");
80 } 78 }
81 79
82 if (event.equals("unsubscribe")) { 80 if (event.equals("unsubscribe")) {
83 log.info("send unsubscribe request start");
84 this.restTemplateClient.unsubscribe(subscribeBean); 81 this.restTemplateClient.unsubscribe(subscribeBean);
85 log.info("send unsubscribe request end");
86 } 82 }
87 83
88 // channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); 84 // channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
89 } 85 }
90 86
91 } catch (Exception e) { 87 } catch (Exception e) {
92 log.error("WXSubscribeConsumer || subOrUnSub msg error || {} || {}", content, e.getMessage()); 88 log.error("消费wechat-gate公众号关注、取关消息异常,subOrUnSubEvent# message ==>> {}", e.getMessage());
93
94 /*channel.basicReject(message.getMessageProperties().getDeliveryTag(), false);
95
96 if (MapUtils.isNotEmpty(error)) {
97 String errorStart = this.error.get("start");
98
99 if (errorStart.equalsIgnoreCase("true")) {
100 String fileName = this.error.get("fileName")+"_"+LocalDate.now() +".log";
101 String filePath = this.error.get("filePath");
102 String filePath1 = filePath+fileName;
103 FileUtil.writeStringToFile2(filePath1, content, e.getMessage());
104 }
105
106 }*/
107
108 log.info("ucEventConsumer ====>>>> end");
109 } 89 }
110 90
111 } 91 }
......