1.优化
Showing
3 changed files
with
49 additions
and
9 deletions
| ... | @@ -54,7 +54,7 @@ public class UserTvServiceImpl implements UserTvService { | ... | @@ -54,7 +54,7 @@ public class UserTvServiceImpl implements UserTvService { |
| 54 | 54 | ||
| 55 | // 主账号会员code | 55 | // 主账号会员code |
| 56 | String priorityMemberCode = userTvDTO.getPriorityMemberCode(); | 56 | String priorityMemberCode = userTvDTO.getPriorityMemberCode(); |
| 57 | if (StringUtils.isNotBlank(platformAccount)) | 57 | if (StringUtils.isNotBlank(priorityMemberCode)) |
| 58 | return this.findMemberByMemberCode(priorityMemberCode); | 58 | return this.findMemberByMemberCode(priorityMemberCode); |
| 59 | else | 59 | else |
| 60 | return this.findMemberByMemberId(userTvDTO.getMemberId()); | 60 | return this.findMemberByMemberId(userTvDTO.getMemberId()); | ... | ... |
| 1 | package com.topdraw.mq.consumer; | 1 | package com.topdraw.mq.consumer; |
| 2 | 2 | ||
| 3 | import com.alibaba.fastjson.JSON; | ||
| 3 | import com.alibaba.fastjson.JSONObject; | 4 | import com.alibaba.fastjson.JSONObject; |
| 4 | import com.fasterxml.jackson.annotation.JsonFormat; | 5 | import com.fasterxml.jackson.annotation.JsonFormat; |
| 6 | import com.topdraw.business.module.member.service.dto.MemberDTO; | ||
| 7 | import com.topdraw.business.module.user.iptv.service.UserTvService; | ||
| 8 | import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO; | ||
| 5 | import com.topdraw.config.RabbitMqConfig; | 9 | import com.topdraw.config.RabbitMqConfig; |
| 6 | import com.topdraw.mq.domain.DataSyncMsg; | 10 | import com.topdraw.mq.domain.DataSyncMsg; |
| 7 | import com.topdraw.resttemplate.RestTemplateClient; | 11 | import com.topdraw.resttemplate.RestTemplateClient; |
| 8 | import com.topdraw.util.JSONUtil; | 12 | import com.topdraw.util.JSONUtil; |
| 9 | import lombok.Data; | 13 | import lombok.Data; |
| 10 | import lombok.extern.slf4j.Slf4j; | 14 | import lombok.extern.slf4j.Slf4j; |
| 15 | import org.apache.commons.lang3.StringUtils; | ||
| 11 | import org.springframework.amqp.core.ExchangeTypes; | 16 | import org.springframework.amqp.core.ExchangeTypes; |
| 12 | import org.springframework.amqp.rabbit.annotation.*; | 17 | import org.springframework.amqp.rabbit.annotation.*; |
| 13 | import org.springframework.beans.factory.annotation.Autowired; | 18 | import org.springframework.beans.factory.annotation.Autowired; |
| ... | @@ -15,6 +20,7 @@ import org.springframework.stereotype.Component; | ... | @@ -15,6 +20,7 @@ import org.springframework.stereotype.Component; |
| 15 | import org.springframework.util.Assert; | 20 | import org.springframework.util.Assert; |
| 16 | 21 | ||
| 17 | import java.sql.Timestamp; | 22 | import java.sql.Timestamp; |
| 23 | import java.util.Objects; | ||
| 18 | 24 | ||
| 19 | @Component | 25 | @Component |
| 20 | @Slf4j | 26 | @Slf4j |
| ... | @@ -22,9 +28,8 @@ public class UcEventBusConsumer { | ... | @@ -22,9 +28,8 @@ public class UcEventBusConsumer { |
| 22 | 28 | ||
| 23 | @Autowired | 29 | @Autowired |
| 24 | RestTemplateClient restTemplateClient; | 30 | RestTemplateClient restTemplateClient; |
| 25 | |||
| 26 | @Autowired | 31 | @Autowired |
| 27 | AutoRoute autoUser; | 32 | private UserTvService userTvService; |
| 28 | 33 | ||
| 29 | /** | 34 | /** |
| 30 | * 事件 | 35 | * 事件 |
| ... | @@ -43,7 +48,7 @@ public class UcEventBusConsumer { | ... | @@ -43,7 +48,7 @@ public class UcEventBusConsumer { |
| 43 | public void ucEventConsumer(String content) { | 48 | public void ucEventConsumer(String content) { |
| 44 | log.info(" receive dataSync msg , content is : {} ", content); | 49 | log.info(" receive dataSync msg , content is : {} ", content); |
| 45 | DataSyncMsg dataSyncMsg = this.parseContent(content); | 50 | DataSyncMsg dataSyncMsg = this.parseContent(content); |
| 46 | // this.taskDeal(dataSyncMsg); | 51 | this.taskDeal(dataSyncMsg); |
| 47 | log.info("ucEventConsumer ====>>>> end"); | 52 | log.info("ucEventConsumer ====>>>> end"); |
| 48 | } | 53 | } |
| 49 | 54 | ||
| ... | @@ -73,16 +78,51 @@ public class UcEventBusConsumer { | ... | @@ -73,16 +78,51 @@ public class UcEventBusConsumer { |
| 73 | 78 | ||
| 74 | case "PLAY": | 79 | case "PLAY": |
| 75 | PlayContent playContent = JSONUtil.parseMsg2Object(content, PlayContent.class); | 80 | PlayContent playContent = JSONUtil.parseMsg2Object(content, PlayContent.class); |
| 81 | |||
| 82 | PlayContent.MsgData msgData = playContent.getMsgData(); | ||
| 83 | if (Objects.nonNull(msgData)) { | ||
| 84 | String time = playContent.getTime(); | ||
| 85 | Integer deviceType = playContent.getDeviceType(); | ||
| 86 | String platformAccount = msgData.getPlatformAccount(); | ||
| 87 | |||
| 88 | String mediaCode = msgData.getMediaCode(); | ||
| 89 | Long mediaId = msgData.getMediaId(); | ||
| 90 | String mediaName = msgData.getMediaName(); | ||
| 91 | Integer playDuration = msgData.getPlayDuration(); | ||
| 92 | |||
| 93 | DataSyncMsg dataSyncMsg = new DataSyncMsg(); | ||
| 94 | dataSyncMsg.setEventType(evt); | ||
| 95 | DataSyncMsg.MsgData msgData1 = new DataSyncMsg.MsgData(); | ||
| 96 | |||
| 97 | if (StringUtils.isNotBlank(platformAccount)) { | ||
| 98 | MemberDTO memberDTO = this.userTvService.findMemberByPlatformAccount(platformAccount); | ||
| 99 | Long memberId = memberDTO.getId(); | ||
| 100 | String memberCode = memberDTO.getCode(); | ||
| 101 | msgData1.setMemberCode(memberCode); | ||
| 102 | } | ||
| 103 | |||
| 104 | |||
| 105 | msgData1.setEvent(8); | ||
| 106 | msgData1.setDeviceType(deviceType); | ||
| 107 | msgData1.setMediaId(mediaId); | ||
| 108 | JSONObject jsonObject = new JSONObject(); | ||
| 109 | jsonObject.put("mediaId", mediaId); | ||
| 110 | jsonObject.put("mediaName", mediaName); | ||
| 111 | jsonObject.put("playDuration", playDuration); | ||
| 112 | jsonObject.put("mediaCode", mediaCode); | ||
| 113 | jsonObject.put("time", time); | ||
| 114 | msgData1.setDescription(JSON.toJSONString(jsonObject)); | ||
| 115 | |||
| 116 | dataSyncMsg.setMsg(msgData1); | ||
| 117 | return dataSyncMsg; | ||
| 118 | } | ||
| 119 | |||
| 76 | System.out.println(playContent); | 120 | System.out.println(playContent); |
| 77 | break; | 121 | break; |
| 78 | 122 | ||
| 79 | } | 123 | } |
| 80 | 124 | ||
| 81 | DataSyncMsg dataSyncMsg = JSONUtil.parseMsg2Object(content,DataSyncMsg.class); | 125 | return null; |
| 82 | Assert.notNull(dataSyncMsg,"ERROR -->> operationConsumer -->> parseContent -->> 【dataSyncMsg】 not be null !!"); | ||
| 83 | DataSyncMsg.MsgData msgData = dataSyncMsg.getMsg(); | ||
| 84 | Assert.notNull(msgData,"ERROR -->> operationConsumer -->> parseContent -->> 【msgData】 not be null !!"); | ||
| 85 | return dataSyncMsg; | ||
| 86 | } | 126 | } |
| 87 | 127 | ||
| 88 | /** | 128 | /** | ... | ... |
-
Please register or sign in to post a comment