Commit e4f79b38 e4f79b382bc9740dbaf7e0cc8ec3f06bdcd098cd by xianghan

1.update

1 parent 9c6f17c3
1 package com.topdraw.config;
2
3 public class LocalConstants {
4
5 // 小屏侧
6 public static final String ENV_MOBILE = "mobile";
7
8 // 大屏侧
9 public static final String ENV_VIS = "vis";
10
11 // 服务侧
12 public static final String ENV_SERVICE = "service";
13
14 // 管理侧
15 public static final String ENV_MANAGEMENT = "management";
16
17 // 大屏类型
18 public static final int DEVICE_VIS = 1;
19
20 // 小屏类型
21 public static final int DEVICE_MOBILE = 2;
22
23 // 平台类型
24 public static final String PLATFORM_TYPE_SERVICE = "service";
25 public static final String PLATFORM_TYPE_MANAGEMENT = "management";
26
27 //会员平台类型 类型 1:大屏;2:小屏
28 public static final Integer MEMBER_PLATFORM_TYPE_VIS = 1;
29 public static final Integer MEMBER_PLATFORM_TYPE_WEIXIN = 2;
30
31 // 重庆_重数_vis
32 public static final String APP_CODE_CHONGQING_CHONGSHU_VIS = "CHONGQING_chongshu_vis";
33
34
35 // 事件类型 3:参加活动
36 public static final Integer EVT_TYPE_ACTIVITY = 3;
37 }
...@@ -38,7 +38,9 @@ public class RabbitMqConfig { ...@@ -38,7 +38,9 @@ public class RabbitMqConfig {
38 38
39 /** 路由(事件)--direct route.key*/ 39 /** 路由(事件)--direct route.key*/
40 // 事件,uc-gateway 40 // 事件,uc-gateway
41 public static final String UC_ROUTE_KEY_DIRECT_EVENT_AAA = "uc.route.key.direct.event.aaa"; 41 // public static final String UC_ROUTE_KEY_DIRECT_EVENT_AAA = "uc.route.key.direct.event.aaa";
42 public static final String UC_ROUTE_KEY_DIRECT_EVENT_AAA = "gateway.common.consumer.event.direct";
43 public static final String UC_EVENTBUS_TOPIC = "uc.eventbus.aa";
42 // uc-service 服务侧 44 // uc-service 服务侧
43 public static final String UC_ROUTE_KEY_DIRECT_EVENT_BBB = "uc.route.key.direct.event.bbb"; 45 public static final String UC_ROUTE_KEY_DIRECT_EVENT_BBB = "uc.route.key.direct.event.bbb";
44 // uc-service 管理侧 46 // uc-service 管理侧
...@@ -46,6 +48,8 @@ public class RabbitMqConfig { ...@@ -46,6 +48,8 @@ public class RabbitMqConfig {
46 48
47 public static final String ENGINE_TO_IPTV_CONSUMER_MEMBER_DIRECT = "engine.iptv.consumer.member.direct"; 49 public static final String ENGINE_TO_IPTV_CONSUMER_MEMBER_DIRECT = "engine.iptv.consumer.member.direct";
48 50
51
52
49 @Value("${mutil-mq.service.host}") 53 @Value("${mutil-mq.service.host}")
50 private String serviceHost; 54 private String serviceHost;
51 @Value("${mutil-mq.service.port}") 55 @Value("${mutil-mq.service.port}")
...@@ -124,6 +128,10 @@ public class RabbitMqConfig { ...@@ -124,6 +128,10 @@ public class RabbitMqConfig {
124 return u; 128 return u;
125 } 129 }
126 130
131
132 public static final String UC_EVENTBUS = "uc.eventbus";
133 public static final String UC_EVENTBUS_KEY = "uc.eventbus.*.topic";
134
127 /** 135 /**
128 * 处理事件 136 * 处理事件
129 * @return org.springframework.amqp.core.Queue 137 * @return org.springframework.amqp.core.Queue
...@@ -135,5 +143,29 @@ public class RabbitMqConfig { ...@@ -135,5 +143,29 @@ public class RabbitMqConfig {
135 return new Queue(UC_ROUTE_KEY_DIRECT_EVENT_AAA); 143 return new Queue(UC_ROUTE_KEY_DIRECT_EVENT_AAA);
136 } 144 }
137 145
146 /**
147 * 处理事件
148 * @return org.springframework.amqp.core.Queue
149 * @author XiangHan
150 * @date 2021/9/7 10:19 上午
151 */
152 @Bean
153 public Queue eventTopic() {
154 return new Queue(UC_EVENTBUS_TOPIC);
155 }
156
138 157
158 @Bean
159 TopicExchange eventBusDirect() {
160 return ExchangeBuilder.topicExchange(UC_EVENTBUS)
161 .durable(true).build();
162 }
163
164 @Bean
165 Binding collectionAddBinding(TopicExchange eventBusDirect, Queue eventTopic) {
166 return BindingBuilder
167 .bind(eventTopic)
168 .to(eventBusDirect)
169 .with(UC_EVENTBUS_KEY);
170 }
139 } 171 }
......
1 package com.topdraw.config;
2
3 import cn.hutool.core.util.ObjectUtil;
4 import org.springframework.beans.factory.annotation.Value;
5 import org.springframework.stereotype.Component;
6
7 @Component
8 public class ServiceEnvConfig {
9
10 // uc两侧部署,需配置位于哪一侧 mobile小屏侧 vis大屏侧
11 public static String UC_SERVICE_TYPE;
12
13 @Value("${service.area:mobile}")
14 public void setUcServiceType(String ucServiceType) {
15 UC_SERVICE_TYPE = ucServiceType;
16 }
17
18 public static boolean isMobile() {
19 return ObjectUtil.equals(UC_SERVICE_TYPE, LocalConstants.ENV_MOBILE);
20 }
21
22 public static boolean isVis() {
23 return ObjectUtil.equals(UC_SERVICE_TYPE, LocalConstants.ENV_VIS);
24 }
25
26
27 // service: 服务侧 management: 管理侧
28 public static String UC_SERVICE_PLATFORM;
29
30 @Value("${service.platform:management}")
31 public void setUcServicePlatform(String ucServicePlatform) {
32 UC_SERVICE_PLATFORM = ucServicePlatform;
33 }
34
35 public static boolean isService() {
36 return ObjectUtil.equals(UC_SERVICE_PLATFORM, LocalConstants.ENV_SERVICE);
37 }
38
39 public static boolean isManagement() {
40 return ObjectUtil.equals(UC_SERVICE_PLATFORM, LocalConstants.ENV_MANAGEMENT);
41 }
42
43 }
...@@ -31,11 +31,11 @@ public class UcEngineEventConsumer { ...@@ -31,11 +31,11 @@ public class UcEngineEventConsumer {
31 * @author Hongyan Wang 31 * @author Hongyan Wang
32 * @date 2021/9/7 11:26 上午 32 * @date 2021/9/7 11:26 上午
33 */ 33 */
34 @RabbitHandler 34 /* @RabbitHandler
35 @RabbitListener(bindings = { 35 @RabbitListener(bindings = {
36 @QueueBinding(value = @Queue(value = RabbitMqConfig.ENGINE_TO_IPTV_CONSUMER_MEMBER_DIRECT), 36 @QueueBinding(value = @Queue(value = RabbitMqConfig.ENGINE_TO_IPTV_CONSUMER_MEMBER_DIRECT),
37 exchange = @Exchange(value = ExchangeTypes.DIRECT)) 37 exchange = @Exchange(value = ExchangeTypes.DIRECT))
38 }, containerFactory = "serviceRabbitListenerContainerFactory") 38 }, containerFactory = "serviceRabbitListenerContainerFactory")*/
39 public void ucEventConsumer(String content) { 39 public void ucEventConsumer(String content) {
40 log.info(" receive dataSync msg , content is : {} ", content); 40 log.info(" receive dataSync msg , content is : {} ", content);
41 TableOperationMsg tableOperationMsg = this.parseContent(content); 41 TableOperationMsg tableOperationMsg = this.parseContent(content);
......
1 package com.topdraw.mq.consumer;
2
3 import com.alibaba.fastjson.JSONObject;
4 import com.fasterxml.jackson.annotation.JsonFormat;
5 import com.topdraw.config.RabbitMqConfig;
6 import com.topdraw.mq.domain.DataSyncMsg;
7 import com.topdraw.resttemplate.RestTemplateClient;
8 import com.topdraw.util.JSONUtil;
9 import lombok.Data;
10 import lombok.extern.slf4j.Slf4j;
11 import org.springframework.amqp.core.ExchangeTypes;
12 import org.springframework.amqp.rabbit.annotation.*;
13 import org.springframework.beans.factory.annotation.Autowired;
14 import org.springframework.stereotype.Component;
15 import org.springframework.util.Assert;
16
17 import java.sql.Timestamp;
18
19 @Component
20 @Slf4j
21 public class UcEventBusConsumer {
22
23 @Autowired
24 RestTemplateClient restTemplateClient;
25
26 @Autowired
27 AutoRoute autoUser;
28
29 /**
30 * 事件
31 * @param content
32 * @description 基础数据同步
33 * @author Hongyan Wang
34 * @date 2021/9/7 11:26 上午
35 */
36 @RabbitHandler/*
37 @RabbitListener(bindings = {
38 @QueueBinding(value = @Queue(value = RabbitMqConfig.UC_EVENTBUS_TOPIC),
39 exchange = @Exchange(type = ExchangeTypes.TOPIC, name = RabbitMqConfig.UC_EVENTBUS),
40 key = RabbitMqConfig.UC_EVENTBUS_KEY)
41 }, containerFactory = "managementRabbitListenerContainerFactory")*/
42 @RabbitListener(queues = RabbitMqConfig.UC_EVENTBUS_TOPIC, containerFactory = "managementRabbitListenerContainerFactory")
43 public void ucEventConsumer(String content) {
44 log.info(" receive dataSync msg , content is : {} ", content);
45 DataSyncMsg dataSyncMsg = this.parseContent(content);
46 // this.taskDeal(dataSyncMsg);
47 log.info("ucEventConsumer ====>>>> end");
48 }
49
50 /**
51 * 数据解析
52 * @param content
53 * @return
54 */
55 /*{
56 "evt": "play”, // 表示播放
57 "deviceType": 1, // 1代表大屏
58 "time": "2022-04-01 00:10:09”,
59 "msgData": {
60 "platformAccount": "itv094430@“, // 大屏用户账号
61 "playDuration": 60, // 播放时长,单位分钟
62 "mediaId": 3433, // 节目id,此次是累计计算,可不传
63 "mediaCode": "media_123”, // 节目标识,同上
64 "mediaName": "白宫陷落” // 节目名称,同上
65 }
66 }*/
67 private DataSyncMsg parseContent(String content) {
68
69 CommonMsg commonMsg = JSONUtil.parseMsg2Object(content, CommonMsg.class);
70
71 String evt = commonMsg.getEvt();
72 switch (evt.toUpperCase()) {
73
74 case "PLAY":
75 PlayContent playContent = JSONUtil.parseMsg2Object(content, PlayContent.class);
76 System.out.println(playContent);
77 break;
78
79 }
80
81 DataSyncMsg dataSyncMsg = JSONUtil.parseMsg2Object(content,DataSyncMsg.class);
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 }
87
88 /**
89 * 任务处理
90 * @param dataSyncMsg
91 */
92 private void taskDeal(DataSyncMsg dataSyncMsg) {
93 this.restTemplateClient.dealTask(dataSyncMsg);
94 }
95
96 @Data
97 static class PlayContent {
98 private String evt;
99 private Integer deviceType;
100 private String time;
101 private MsgData msgData;
102
103 @Data
104 static class MsgData {
105 private String platformAccount;
106 private Integer playDuration;
107 private Long mediaId;
108 private String mediaCode;
109 private String mediaName;
110 }
111 }
112
113 @Data
114 static class CommonMsg {
115 private String evt;
116 private Integer deviceType;
117 private String time;
118 }
119 }
...@@ -36,7 +36,7 @@ public class UcGatewayEventConsumer { ...@@ -36,7 +36,7 @@ public class UcGatewayEventConsumer {
36 public void ucEventConsumer(String content) { 36 public void ucEventConsumer(String content) {
37 log.info(" receive dataSync msg , content is : {} ", content); 37 log.info(" receive dataSync msg , content is : {} ", content);
38 DataSyncMsg dataSyncMsg = this.parseContent(content); 38 DataSyncMsg dataSyncMsg = this.parseContent(content);
39 this.taskDeal(dataSyncMsg); 39 //this.taskDeal(dataSyncMsg);
40 log.info("ucEventConsumer ====>>>> end"); 40 log.info("ucEventConsumer ====>>>> end");
41 } 41 }
42 42
......
...@@ -155,8 +155,8 @@ public class WeiXinEventConsumer { ...@@ -155,8 +155,8 @@ public class WeiXinEventConsumer {
155 String eventKey = wechatMsg.getString("EventKey"); 155 String eventKey = wechatMsg.getString("EventKey");
156 156
157 SubscribeBean subscribeBean = new SubscribeBean(); 157 SubscribeBean subscribeBean = new SubscribeBean();
158 subscribeBean.setAppId(appid); 158 subscribeBean.setAppid(appid);
159 subscribeBean.setOpenId(openid); 159 subscribeBean.setOpenid(openid);
160 subscribeBean.setUnionid(unionid); 160 subscribeBean.setUnionid(unionid);
161 subscribeBean.setEventKey(eventKey); 161 subscribeBean.setEventKey(eventKey);
162 162
......
...@@ -53,6 +53,7 @@ public class DataSyncMsg implements Serializable { ...@@ -53,6 +53,7 @@ public class DataSyncMsg implements Serializable {
53 private Long mediaId; 53 private Long mediaId;
54 private Long itemId; 54 private Long itemId;
55 private String param; 55 private String param;
56 private String description;
56 } 57 }
57 58
58 } 59 }
......
...@@ -10,10 +10,10 @@ import lombok.NoArgsConstructor; ...@@ -10,10 +10,10 @@ import lombok.NoArgsConstructor;
10 public class SubscribeBean { 10 public class SubscribeBean {
11 11
12 /** */ 12 /** */
13 private String openId; 13 private String openid;
14 14
15 /** */ 15 /** */
16 private String appId; 16 private String appid;
17 17
18 private String unionid; 18 private String unionid;
19 19
......
...@@ -41,7 +41,7 @@ public class RestTemplateClient { ...@@ -41,7 +41,7 @@ public class RestTemplateClient {
41 } 41 }
42 42
43 public JSONObject dealTask(DataSyncMsg dataSyncMsg) { 43 public JSONObject dealTask(DataSyncMsg dataSyncMsg) {
44 String url = BASE_URL + "/ucEngine/api/taskOperation/dealTask"; 44 String url = BASE_URL + "/uce/taskOperation/dealTask";
45 log.info("request uc : url is " + url + ", dataSyncMsg is " + dataSyncMsg); 45 log.info("request uc : url is " + url + ", dataSyncMsg is " + dataSyncMsg);
46 String content = JSON.toJSONString(dataSyncMsg); 46 String content = JSON.toJSONString(dataSyncMsg);
47 HashMap<Object, Object> objectObjectHashMap = new HashMap<>(); 47 HashMap<Object, Object> objectObjectHashMap = new HashMap<>();
...@@ -63,7 +63,7 @@ public class RestTemplateClient { ...@@ -63,7 +63,7 @@ public class RestTemplateClient {
63 63
64 public JSONObject getMemberInfo(Long memberId) { 64 public JSONObject getMemberInfo(Long memberId) {
65 JSONObject resultSet = null; 65 JSONObject resultSet = null;
66 String url = BASE_URL + "/api/member/findById/" + memberId; 66 String url = BASE_URL + "/uce/member/findById/" + memberId;
67 log.info("request uc : url is " + url + ", memberId is " + memberId); 67 log.info("request uc : url is " + url + ", memberId is " + memberId);
68 ResponseEntity<String> responseEntity = restTemplate.getForEntity(url, String.class); 68 ResponseEntity<String> responseEntity = restTemplate.getForEntity(url, String.class);
69 if (responseEntity.getStatusCode().is2xxSuccessful()) { 69 if (responseEntity.getStatusCode().is2xxSuccessful()) {
...@@ -78,7 +78,7 @@ public class RestTemplateClient { ...@@ -78,7 +78,7 @@ public class RestTemplateClient {
78 } 78 }
79 79
80 public String createMemberAddress(MemberAddress member) { 80 public String createMemberAddress(MemberAddress member) {
81 String url = BASE_URL + "/api/MemberAddress/create"; 81 String url = BASE_URL + "/uce/memberAddress/create";
82 log.info("request uc : url is " + url + ", memberId is " + JSONObject.toJSONString(member)); 82 log.info("request uc : url is " + url + ", memberId is " + JSONObject.toJSONString(member));
83 restTemplate.postForEntity(url, member, String.class); 83 restTemplate.postForEntity(url, member, String.class);
84 /* ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, member, String.class); 84 /* ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, member, String.class);
...@@ -91,7 +91,7 @@ public class RestTemplateClient { ...@@ -91,7 +91,7 @@ public class RestTemplateClient {
91 } 91 }
92 92
93 public String unsubscribe(SubscribeBean subscribeBean) { 93 public String unsubscribe(SubscribeBean subscribeBean) {
94 String url = BASE_URL + "/ucEngine/api/userOperation/unsubscribe"; 94 String url = BASE_URL + "/uce/userOperation/unsubscribe";
95 String content = JSON.toJSONString(subscribeBean); 95 String content = JSON.toJSONString(subscribeBean);
96 96
97 HashMap<Object, Object> objectObjectHashMap = new HashMap<>(); 97 HashMap<Object, Object> objectObjectHashMap = new HashMap<>();
...@@ -107,7 +107,7 @@ public class RestTemplateClient { ...@@ -107,7 +107,7 @@ public class RestTemplateClient {
107 } 107 }
108 108
109 public String subscribe(SubscribeBean subscribeBean) { 109 public String subscribe(SubscribeBean subscribeBean) {
110 String url = BASE_URL + "/ucEngine/api/userOperation/subscribe"; 110 String url = BASE_URL + "/uce/userOperation/subscribe";
111 String content = JSON.toJSONString(subscribeBean); 111 String content = JSON.toJSONString(subscribeBean);
112 112
113 HashMap<String, String> objectObjectHashMap = new HashMap<>(); 113 HashMap<String, String> objectObjectHashMap = new HashMap<>();
...@@ -124,7 +124,7 @@ public class RestTemplateClient { ...@@ -124,7 +124,7 @@ public class RestTemplateClient {
124 } 124 }
125 125
126 public String sendQrCodeMessage(String content) { 126 public String sendQrCodeMessage(String content) {
127 String url = BASE_URL + "/ucEngine/api/userOperation/sendQrCodeMessage"; 127 String url = BASE_URL + "/uce/userOperation/sendQrCodeMessage";
128 restTemplate.postForEntity(url, content, String.class); 128 restTemplate.postForEntity(url, content, String.class);
129 /* ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, content, String.class); 129 /* ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, content, String.class);
130 String entityBody = ""; 130 String entityBody = "";
...@@ -136,7 +136,7 @@ public class RestTemplateClient { ...@@ -136,7 +136,7 @@ public class RestTemplateClient {
136 } 136 }
137 137
138 public String addCollection(String content) { 138 public String addCollection(String content) {
139 String url = BASE_URL + "/ucEngine/api/userOperation/addCollection"; 139 String url = BASE_URL + "/uce/userOperation/addCollection";
140 //处理接口调用 中文不显示问题 140 //处理接口调用 中文不显示问题
141 content = new String(Base64.getEncoder().encode(content.getBytes(StandardCharsets.UTF_8))); 141 content = new String(Base64.getEncoder().encode(content.getBytes(StandardCharsets.UTF_8)));
142 142
...@@ -151,7 +151,7 @@ public class RestTemplateClient { ...@@ -151,7 +151,7 @@ public class RestTemplateClient {
151 } 151 }
152 152
153 public String deleteCollection(String content) { 153 public String deleteCollection(String content) {
154 String url = BASE_URL + "/ucEngine/api/userOperation/deleteCollection"; 154 String url = BASE_URL + "/uce/userOperation/deleteCollection";
155 restTemplate.postForEntity(url, content, String.class); 155 restTemplate.postForEntity(url, content, String.class);
156 /* ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, content, String.class); 156 /* ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, content, String.class);
157 String entityBody = ""; 157 String entityBody = "";
...@@ -163,7 +163,7 @@ public class RestTemplateClient { ...@@ -163,7 +163,7 @@ public class RestTemplateClient {
163 } 163 }
164 164
165 public String deleteAllCollection(String content) { 165 public String deleteAllCollection(String content) {
166 String url = BASE_URL + "/ucEngine/api/userOperation/deleteAllCollection"; 166 String url = BASE_URL + "/uce/userOperation/deleteAllCollection";
167 restTemplate.postForEntity(url, content, String.class); 167 restTemplate.postForEntity(url, content, String.class);
168 /*ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, content, String.class); 168 /*ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, content, String.class);
169 String entityBody = ""; 169 String entityBody = "";
......