1.优化日志信息
2.清理无用的文件
Showing
10 changed files
with
75 additions
and
182 deletions
| ... | @@ -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 | } | ... | ... |
| 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 | } | ||
| 52 | 44 | ||
| 53 | autoUser.route(tableOperationMsg); | 45 | TableOperationMsg tableOperationMsg = JSONUtil.parseMsg2Object(content,TableOperationMsg.class); |
| 46 | log.info("同步会员信息,解析参数后的结果,memberInfoConsumer# ==>> {}", tableOperationMsg); | ||
| 47 | |||
| 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)) { |
| 78 | throw new BadRequestException("无参数"); | ||
| 79 | } | ||
| 100 | 80 | ||
| 101 | // channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); | 81 | TableOperationMsg tableOperationMsg = JSONUtil.parseMsg2Object(content,TableOperationMsg.class); |
| 102 | 82 | ||
| 103 | } catch (Exception e) { | 83 | log.info("同步会员信息,解析参数后的结果,memberInfoConsumer# ==>> {}", tableOperationMsg); |
| 104 | log.error("消费uc-engine消息失败, cause ==>> [ucEngineConsumer#{}]", e.getMessage()); | 84 | this.autoUser.route(tableOperationMsg); |
| 105 | channel.basicReject(message.getMessageProperties().getDeliveryTag(), false); | ||
| 106 | |||
| 107 | /*if (MapUtils.isNotEmpty(error)) { | ||
| 108 | String errorStart = this.error.get("start"); | ||
| 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) { |
| 90 | log.error("消费uc-engine消息失败, cause ==>> [ucEngineConsumer#{}]", e.getMessage()); | ||
| 91 | |||
| 92 | // channel.basicReject(message.getMessageProperties().getDeliveryTag(), false); | ||
| 120 | } | 93 | } |
| 121 | |||
| 122 | log.info("ucEventConsumer ====>>>> end"); | ||
| 123 | } | ||
| 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 | /** | ... | ... |
This diff is collapsed.
Click to expand it.
| ... | @@ -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 | } | ... | ... |
-
Please register or sign in to post a comment