1.同步master,优化任务处理过程
Showing
13 changed files
with
248 additions
and
56 deletions
| 1 | package com.topdraw.business.module.task.template.constant; | ||
| 2 | |||
| 3 | /** | ||
| 4 | * @author : | ||
| 5 | * @description: | ||
| 6 | * @function : | ||
| 7 | * @date :Created in 2022/6/18 14:30 | ||
| 8 | * @version: : | ||
| 9 | * @modified By: | ||
| 10 | * @since : modified in 2022/6/18 14:30 | ||
| 11 | */ | ||
| 12 | public interface TaskEventName { | ||
| 13 | //类型 1:登录;2:观影;3:参加活动;4:订购;5:优享会员;6:签到;7:完成设置; | ||
| 14 | // 8:播放记录;10:跨屏绑定;11:积分转移;30:积分兑换商品;98:系统操作;99:其他 | ||
| 15 | String LOGIN = "LOGIN"; | ||
| 16 | String VIEW = "VIEW"; | ||
| 17 | String ACTIVITY = "ACTIVITY"; | ||
| 18 | String ORDER = "ORDER"; | ||
| 19 | String MEMBER_PRIORITY = "MEMBER_PRIORITY"; | ||
| 20 | String SIGN = "SIGN"; | ||
| 21 | String COMPLETE_INFO = "COMPLETE_INFO"; | ||
| 22 | String PLAY = "PLAY"; | ||
| 23 | String BINDING = "BINDING"; | ||
| 24 | String POINTS_TRANS = "POINTS_TRANS"; | ||
| 25 | String POINTS_EXCHANGE_GOODS = "POINTS_EXCHANGE_GOODS"; | ||
| 26 | String SYSTEM_OPERATE = "SYSTEM_OPERATE"; | ||
| 27 | String OTHER = "OHHER"; | ||
| 28 | |||
| 29 | } |
| 1 | package com.topdraw.business.module.task.template.constant; | ||
| 2 | |||
| 3 | /** | ||
| 4 | * @author : | ||
| 5 | * @description: | ||
| 6 | * @function : | ||
| 7 | * @date :Created in 2022/6/18 14:30 | ||
| 8 | * @version: : | ||
| 9 | * @modified By: | ||
| 10 | * @since : modified in 2022/6/18 14:30 | ||
| 11 | */ | ||
| 12 | public interface TaskEventType { | ||
| 13 | //类型 1:登录;2:观影;3:参加活动;4:订购;5:优享会员;6:签到;7:完成设置; | ||
| 14 | // 8:播放记录;10:跨屏绑定;11:积分转移;30:积分兑换商品;98:系统操作;99:其他 | ||
| 15 | int LOGIN = 1; | ||
| 16 | int VIEW = 2; | ||
| 17 | int ACTIVITY = 3; | ||
| 18 | int ORDER = 4; | ||
| 19 | int MEMBER_PRIORITY = 5; | ||
| 20 | int SIGN = 6; | ||
| 21 | int COMPLETE_INFO = 7; | ||
| 22 | int PLAY = 8; | ||
| 23 | int BINDING = 10; | ||
| 24 | int POINTS_TRANS = 11; | ||
| 25 | int POINTS_EXCHANGE_GOODS = 30; | ||
| 26 | int SYSTEM_OPERATE = 98; | ||
| 27 | int OHHER = 99; | ||
| 28 | |||
| 29 | } |
| ... | @@ -56,4 +56,11 @@ public interface UserTvRepository extends JpaRepository<UserTv, Long>, JpaSpecif | ... | @@ -56,4 +56,11 @@ public interface UserTvRepository extends JpaRepository<UserTv, Long>, JpaSpecif |
| 56 | " `vis_user_id` = :#{#resources.visUserId}, " + | 56 | " `vis_user_id` = :#{#resources.visUserId}, " + |
| 57 | " `update_time` = now() WHERE `platform_account` = :#{#resources.platformAccount}", nativeQuery = true) | 57 | " `update_time` = now() WHERE `platform_account` = :#{#resources.platformAccount}", nativeQuery = true) |
| 58 | void updateUserTvByPlatformAccount(@Param("resources") UserTv userTv); | 58 | void updateUserTvByPlatformAccount(@Param("resources") UserTv userTv); |
| 59 | |||
| 60 | Long countByPlatformAccount(String platformAccount); | ||
| 61 | |||
| 62 | @Modifying | ||
| 63 | @Query(value = "UPDATE `uc_user_tv` SET `priority_member_code` = :#{#resources.priorityMemberCode}, " + | ||
| 64 | "`update_time` = now() WHERE `platform_account` = :#{#resources.platformAccount}", nativeQuery = true) | ||
| 65 | void updatePriorityMemberCode(@Param("resources") UserTv userTv); | ||
| 59 | } | 66 | } | ... | ... |
| ... | @@ -108,4 +108,17 @@ public interface UserTvService { | ... | @@ -108,4 +108,17 @@ public interface UserTvService { |
| 108 | * @param userTv | 108 | * @param userTv |
| 109 | */ | 109 | */ |
| 110 | void updateUserTvByPlatformAccount(UserTv userTv); | 110 | void updateUserTvByPlatformAccount(UserTv userTv); |
| 111 | |||
| 112 | /** | ||
| 113 | * | ||
| 114 | * @param platformAccount | ||
| 115 | * @return | ||
| 116 | */ | ||
| 117 | Long countByPlatformAccount(String platformAccount); | ||
| 118 | |||
| 119 | /** | ||
| 120 | * | ||
| 121 | * @param userTv | ||
| 122 | */ | ||
| 123 | void doUpdatePriorityMemberCode(UserTv userTv); | ||
| 111 | } | 124 | } | ... | ... |
| ... | @@ -62,6 +62,16 @@ public class UserTvServiceImpl implements UserTvService { | ... | @@ -62,6 +62,16 @@ public class UserTvServiceImpl implements UserTvService { |
| 62 | this.userTvRepository.updateUserTvByPlatformAccount(userTv); | 62 | this.userTvRepository.updateUserTvByPlatformAccount(userTv); |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | @Override | ||
| 66 | public Long countByPlatformAccount(String platformAccount) { | ||
| 67 | return this.userTvRepository.countByPlatformAccount(platformAccount); | ||
| 68 | } | ||
| 69 | |||
| 70 | @Override | ||
| 71 | public void doUpdatePriorityMemberCode(UserTv userTv) { | ||
| 72 | this.userTvRepository.updatePriorityMemberCode(userTv); | ||
| 73 | } | ||
| 74 | |||
| 65 | 75 | ||
| 66 | /** | 76 | /** |
| 67 | * 获取大屏账户对应的会员 | 77 | * 获取大屏账户对应的会员 | ... | ... |
| ... | @@ -21,13 +21,7 @@ public class ExpOperationServiceImpl implements ExpOperationService { | ... | @@ -21,13 +21,7 @@ public class ExpOperationServiceImpl implements ExpOperationService { |
| 21 | @Autowired | 21 | @Autowired |
| 22 | private ExpDetailService expDetailService; | 22 | private ExpDetailService expDetailService; |
| 23 | @Autowired | 23 | @Autowired |
| 24 | private MemberOperationService memberOperationService; | ||
| 25 | @Autowired | ||
| 26 | private MemberLevelService memberLevelService; | ||
| 27 | @Autowired | ||
| 28 | private MemberService memberService; | 24 | private MemberService memberService; |
| 29 | @Autowired | ||
| 30 | ThreadPoolTaskExecutor threadPoolTaskExecutor; | ||
| 31 | 25 | ||
| 32 | public void asyncMemberExpAndLevel(Member member) { | 26 | public void asyncMemberExpAndLevel(Member member) { |
| 33 | String code = member.getCode(); | 27 | String code = member.getCode(); | ... | ... |
| ... | @@ -349,6 +349,31 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -349,6 +349,31 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 349 | } | 349 | } |
| 350 | 350 | ||
| 351 | @Transactional(propagation = Propagation.SUPPORTS, rollbackFor = Exception.class) | 351 | @Transactional(propagation = Propagation.SUPPORTS, rollbackFor = Exception.class) |
| 352 | public void asyncUserTvChangeMainAccount(UserTvDTO userTvDTO) { | ||
| 353 | log.info("asyncUserTv ==>> userTvDTO ==>> {}", userTvDTO); | ||
| 354 | |||
| 355 | String priorityMemberCode = userTvDTO.getPriorityMemberCode(); | ||
| 356 | if (StringUtils.isBlank(priorityMemberCode)) { | ||
| 357 | log.error("大屏账号设置主会员异常,主会员code不存在"); | ||
| 358 | return; | ||
| 359 | } | ||
| 360 | |||
| 361 | String platformAccount = userTvDTO.getPlatformAccount(); | ||
| 362 | UserTvDTO _userTvDTO = this.userTvService.findByPlatformAccount(platformAccount); | ||
| 363 | log.info("从数据库中获取大屏信息, _userTvDTO ==>> {}", _userTvDTO); | ||
| 364 | if (Objects.isNull(_userTvDTO.getId())) { | ||
| 365 | log.error("大屏账号设置主会员异常,大屏账号不存在"); | ||
| 366 | return; | ||
| 367 | } | ||
| 368 | |||
| 369 | UserTv userTv = new UserTv(); | ||
| 370 | userTv.setId(_userTvDTO.getId()); | ||
| 371 | userTv.setPriorityMemberCode(priorityMemberCode); | ||
| 372 | log.info("开始修改大屏数据,userTv ==>>{}", userTv); | ||
| 373 | this.userTvService.doUpdatePriorityMemberCode(userTv); | ||
| 374 | } | ||
| 375 | |||
| 376 | @Transactional(propagation = Propagation.SUPPORTS, rollbackFor = Exception.class) | ||
| 352 | public void asyncUserTv(UserTvDTO userTvDTO) { | 377 | public void asyncUserTv(UserTvDTO userTvDTO) { |
| 353 | log.info("asyncUserTv ==>> userTvDTO ==>> {}", userTvDTO); | 378 | log.info("asyncUserTv ==>> userTvDTO ==>> {}", userTvDTO); |
| 354 | String platformAccount = userTvDTO.getPlatformAccount(); | 379 | String platformAccount = userTvDTO.getPlatformAccount(); | ... | ... |
| 1 | package com.topdraw.config.redis; | ||
| 2 | |||
| 3 | /** | ||
| 4 | * @author : | ||
| 5 | * @description: | ||
| 6 | * @function : | ||
| 7 | * @date :Created in 2022/6/18 17:22 | ||
| 8 | * @version: : | ||
| 9 | * @modified By: | ||
| 10 | * @since : modified in 2022/6/18 17:22 | ||
| 11 | */ | ||
| 12 | public class RedisKeyConstant { | ||
| 13 | |||
| 14 | |||
| 15 | public static final String CACHE_PLATFROMACCOUNT_PLAYDURATION = "ucc::play::playduration::"; | ||
| 16 | } |
| ... | @@ -9,17 +9,20 @@ import com.topdraw.business.module.task.attribute.service.TaskAttrService; | ... | @@ -9,17 +9,20 @@ import com.topdraw.business.module.task.attribute.service.TaskAttrService; |
| 9 | import com.topdraw.business.module.task.attribute.service.dto.TaskAttrDTO; | 9 | import com.topdraw.business.module.task.attribute.service.dto.TaskAttrDTO; |
| 10 | import com.topdraw.business.module.task.domain.Task; | 10 | import com.topdraw.business.module.task.domain.Task; |
| 11 | import com.topdraw.business.module.task.service.TaskService; | 11 | import com.topdraw.business.module.task.service.TaskService; |
| 12 | import com.topdraw.business.module.task.template.constant.TaskEventName; | ||
| 13 | import com.topdraw.business.module.task.template.constant.TaskEventType; | ||
| 12 | import com.topdraw.business.module.task.template.service.TaskTemplateService; | 14 | import com.topdraw.business.module.task.template.service.TaskTemplateService; |
| 13 | import com.topdraw.business.module.task.template.service.dto.TaskTemplateDTO; | 15 | import com.topdraw.business.module.task.template.service.dto.TaskTemplateDTO; |
| 14 | import com.topdraw.business.module.user.iptv.service.UserTvService; | 16 | import com.topdraw.business.module.user.iptv.service.UserTvService; |
| 15 | import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO; | 17 | import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO; |
| 18 | import com.topdraw.config.redis.RedisKeyConstant; | ||
| 19 | import com.topdraw.exception.BadRequestException; | ||
| 16 | import com.topdraw.exception.EntityNotFoundException; | 20 | import com.topdraw.exception.EntityNotFoundException; |
| 17 | import com.topdraw.mq.domain.DataSyncMsg; | 21 | import com.topdraw.mq.domain.DataSyncMsg; |
| 18 | import com.topdraw.resttemplate.RestTemplateClient; | 22 | import com.topdraw.resttemplate.RestTemplateClient; |
| 19 | import com.topdraw.util.DateUtil; | 23 | import com.topdraw.util.DateUtil; |
| 20 | import com.topdraw.util.FileUtil; | 24 | import com.topdraw.util.FileUtil; |
| 21 | import com.topdraw.util.JSONUtil; | 25 | import com.topdraw.util.JSONUtil; |
| 22 | import com.topdraw.util.TimestampUtil; | ||
| 23 | import com.topdraw.utils.RedisUtils; | 26 | import com.topdraw.utils.RedisUtils; |
| 24 | import lombok.Data; | 27 | import lombok.Data; |
| 25 | import lombok.extern.slf4j.Slf4j; | 28 | import lombok.extern.slf4j.Slf4j; |
| ... | @@ -31,6 +34,7 @@ import org.springframework.amqp.rabbit.annotation.*; | ... | @@ -31,6 +34,7 @@ import org.springframework.amqp.rabbit.annotation.*; |
| 31 | import org.springframework.beans.factory.annotation.Autowired; | 34 | import org.springframework.beans.factory.annotation.Autowired; |
| 32 | import org.springframework.beans.factory.annotation.Value; | 35 | import org.springframework.beans.factory.annotation.Value; |
| 33 | import org.springframework.stereotype.Component; | 36 | import org.springframework.stereotype.Component; |
| 37 | import org.springframework.web.server.ResponseStatusException; | ||
| 34 | 38 | ||
| 35 | import java.io.IOException; | 39 | import java.io.IOException; |
| 36 | import java.text.ParseException; | 40 | import java.text.ParseException; |
| ... | @@ -57,7 +61,6 @@ public class UcEventBusIptv2ManagementUcEngine { | ... | @@ -57,7 +61,6 @@ public class UcEventBusIptv2ManagementUcEngine { |
| 57 | @Autowired | 61 | @Autowired |
| 58 | private RedisUtils redisUtils; | 62 | private RedisUtils redisUtils; |
| 59 | 63 | ||
| 60 | |||
| 61 | @Value("#{rabbitMqErrorLogConfig.getEventBusError()}") | 64 | @Value("#{rabbitMqErrorLogConfig.getEventBusError()}") |
| 62 | private Map<String, String> error; | 65 | private Map<String, String> error; |
| 63 | 66 | ||
| ... | @@ -73,16 +76,22 @@ public class UcEventBusIptv2ManagementUcEngine { | ... | @@ -73,16 +76,22 @@ public class UcEventBusIptv2ManagementUcEngine { |
| 73 | containerFactory = "#{rabbitMqSourceConfig.getEventBusSource()}", | 76 | containerFactory = "#{rabbitMqSourceConfig.getEventBusSource()}", |
| 74 | autoStartup = "#{rabbitMqSourceConfig.getEventBusStartUp()}", | 77 | autoStartup = "#{rabbitMqSourceConfig.getEventBusStartUp()}", |
| 75 | ackMode = "AUTO") | 78 | ackMode = "AUTO") |
| 76 | public void eventBusConsumer(Channel channel, Message message, String content) throws ParseException, IOException { | 79 | public void eventBusConsumer(Channel channel, Message message, String content) throws IOException { |
| 77 | log.info(" receive dataSync msg , content is : {} ", content); | 80 | log.info(" receive dataSync msg , content is : {} ", content); |
| 78 | try { | 81 | try { |
| 79 | 82 | ||
| 80 | this.parseContent(content); | 83 | PlayContent playContent = JSONUtil.parseMsg2Object(content, PlayContent.class); |
| 84 | log.info("解析后的参数 , playContent ==>> {} ", playContent); | ||
| 85 | if (Objects.nonNull(playContent)) { | ||
| 86 | this.parseContent(playContent); | ||
| 87 | } | ||
| 81 | 88 | ||
| 82 | // channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); | 89 | // channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); |
| 83 | 90 | ||
| 84 | } catch (Exception e) { | 91 | } catch (Exception e) { |
| 85 | 92 | ||
| 93 | log.error("eventBus 消费异常 ==>> {}",e.getMessage()); | ||
| 94 | |||
| 86 | channel.basicReject(message.getMessageProperties().getDeliveryTag(), false); | 95 | channel.basicReject(message.getMessageProperties().getDeliveryTag(), false); |
| 87 | 96 | ||
| 88 | if (MapUtils.isNotEmpty(error)) { | 97 | if (MapUtils.isNotEmpty(error)) { |
| ... | @@ -97,33 +106,35 @@ public class UcEventBusIptv2ManagementUcEngine { | ... | @@ -97,33 +106,35 @@ public class UcEventBusIptv2ManagementUcEngine { |
| 97 | 106 | ||
| 98 | } | 107 | } |
| 99 | 108 | ||
| 100 | e.printStackTrace(); | ||
| 101 | } | 109 | } |
| 102 | log.info("ucEventConsumer ====>>>> end"); | 110 | log.info("eventBusConsumer ====>>>> end"); |
| 103 | } | 111 | } |
| 104 | 112 | ||
| 105 | 113 | ||
| 106 | /** | 114 | /** |
| 107 | * 数据解析 | 115 | * 数据解析 |
| 108 | * @param content | 116 | * @param playContent |
| 109 | * @return | 117 | * @return |
| 110 | */ | 118 | */ |
| 111 | private void parseContent(String content) throws ParseException { | 119 | private void parseContent(PlayContent playContent) throws ParseException { |
| 112 | 120 | PlayContent.MsgData msgData = playContent.getMsgData(); | |
| 113 | PlayContent commonMsg = JSONUtil.parseMsg2Object(content, PlayContent.class); | 121 | if (Objects.isNull(msgData)) { |
| 122 | log.error("eventBus事件消息体为空,msgData ==>> {}", msgData); | ||
| 123 | return; | ||
| 124 | } | ||
| 114 | 125 | ||
| 115 | String evt = commonMsg.getEvt(); | 126 | String evt = playContent.getEvt(); |
| 116 | switch (evt.toUpperCase()) { | 127 | switch (evt.toUpperCase()) { |
| 117 | 128 | ||
| 118 | case "PLAY": | 129 | case TaskEventName.PLAY: |
| 119 | PlayContent playContent = JSONUtil.parseMsg2Object(content, PlayContent.class); | ||
| 120 | |||
| 121 | PlayContent.MsgData msgData = playContent.getMsgData(); | ||
| 122 | if (Objects.nonNull(msgData)) { | ||
| 123 | String time = playContent.getTime(); | 130 | String time = playContent.getTime(); |
| 124 | String formatDate = DateUtil.formatDate(time); | 131 | String formatDate = DateUtil.formatDate(time); |
| 125 | Integer deviceType = playContent.getDeviceType(); | 132 | Integer deviceType = playContent.getDeviceType(); |
| 126 | String platformAccount = msgData.getPlatformAccount(); | 133 | String platformAccount = msgData.getPlatformAccount(); |
| 134 | if (StringUtils.isBlank(platformAccount)){ | ||
| 135 | log.error("参数错误,platformAccount不得为空, msgData ==>> {}", msgData); | ||
| 136 | return; | ||
| 137 | } | ||
| 127 | 138 | ||
| 128 | String mediaCode = msgData.getMediaCode(); | 139 | String mediaCode = msgData.getMediaCode(); |
| 129 | Long mediaId = msgData.getMediaId(); | 140 | Long mediaId = msgData.getMediaId(); |
| ... | @@ -136,16 +147,23 @@ public class UcEventBusIptv2ManagementUcEngine { | ... | @@ -136,16 +147,23 @@ public class UcEventBusIptv2ManagementUcEngine { |
| 136 | 147 | ||
| 137 | DataSyncMsg dataSyncMsg = new DataSyncMsg(); | 148 | DataSyncMsg dataSyncMsg = new DataSyncMsg(); |
| 138 | dataSyncMsg.setEvt(evt); | 149 | dataSyncMsg.setEvt(evt); |
| 150 | dataSyncMsg.setEvent(TaskEventType.PLAY); | ||
| 151 | dataSyncMsg.setTime(LocalDateTime.now()); | ||
| 152 | dataSyncMsg.setDeviceType(deviceType); | ||
| 153 | |||
| 139 | DataSyncMsg.MsgData msg = new DataSyncMsg.MsgData(); | 154 | DataSyncMsg.MsgData msg = new DataSyncMsg.MsgData(); |
| 155 | msg.setPlatformAccount(platformAccount); | ||
| 156 | msg.setMediaId(mediaId); | ||
| 140 | 157 | ||
| 141 | Integer playDurationValueTotal = 0; | 158 | Integer playDurationValueTotal = 0; |
| 142 | if (StringUtils.isNotBlank(platformAccount)) { | 159 | if (StringUtils.isNotBlank(platformAccount)) { |
| 143 | 160 | ||
| 144 | UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount); | 161 | Long count = this.userTvService.countByPlatformAccount(platformAccount); |
| 162 | log.info("通过大屏账号查询对应记录的条数,==>> {}", count); | ||
| 163 | |||
| 164 | if(count > 0L) { | ||
| 165 | String key = RedisKeyConstant.CACHE_PLATFROMACCOUNT_PLAYDURATION+platformAccount+"|"+formatDate; | ||
| 145 | 166 | ||
| 146 | if(Objects.nonNull(userTvDTO)) { | ||
| 147 | // 用大屏账号+日期做为key,并判断这个key是否存在 ,数据类型为hash eg:<total,1>,<1,playDuration>,<2,playDuration> | ||
| 148 | String key = platformAccount+"|"+formatDate; | ||
| 149 | Map<Object, Object> hmget = | 167 | Map<Object, Object> hmget = |
| 150 | this.redisUtils.hmget(key); | 168 | this.redisUtils.hmget(key); |
| 151 | 169 | ||
| ... | @@ -155,28 +173,35 @@ public class UcEventBusIptv2ManagementUcEngine { | ... | @@ -155,28 +173,35 @@ public class UcEventBusIptv2ManagementUcEngine { |
| 155 | playDurationValueTotal = playDuration; | 173 | playDurationValueTotal = playDuration; |
| 156 | Map<String, Object> map = new HashMap<>(); | 174 | Map<String, Object> map = new HashMap<>(); |
| 157 | map.put("total", playDurationValueTotal); | 175 | map.put("total", playDurationValueTotal); |
| 158 | map.put("1", playDuration); | 176 | // 存储时间36小时 |
| 159 | this.redisUtils.hmset(key, map, 129600); | 177 | this.redisUtils.hmset(key, map, 129600); |
| 160 | 178 | ||
| 161 | } else { | 179 | } else { |
| 162 | 180 | ||
| 163 | // 计算播放总时长 total = 播放总时长+当前播放时长 | 181 | // 计算播放总时长 total = 播放总时长+当前播放时长 |
| 164 | Integer total = this.getRedisTotal(hmget); | 182 | Integer total = this.getTotalPlayDurationFromRedis(key); |
| 165 | playDurationValueTotal = total + playDuration; | 183 | playDurationValueTotal = total + playDuration; |
| 166 | 184 | ||
| 167 | } | 185 | } |
| 168 | 186 | ||
| 169 | Integer totalKey = this.getRedisTotalKey(hmget); | ||
| 170 | Integer maxSize = totalKey + 1; | ||
| 171 | |||
| 172 | Map<String, Object> map = new HashMap<>(); | 187 | Map<String, Object> map = new HashMap<>(); |
| 173 | map.put(String.valueOf(maxSize), playDuration); | ||
| 174 | map.put("total", playDurationValueTotal); | 188 | map.put("total", playDurationValueTotal); |
| 175 | this.redisUtils.hmset(key, map); | 189 | this.redisUtils.hmset(key, map); |
| 176 | 190 | ||
| 177 | this.checkTask(playDurationValueTotal, time, deviceType, | ||
| 178 | mediaCode, mediaId, mediaName, dataSyncMsg, msg, userTvDTO); | ||
| 179 | 191 | ||
| 192 | JSONObject jsonObject1 = new JSONObject(); | ||
| 193 | jsonObject1.put("PLAYDURATION",playDurationValueTotal); | ||
| 194 | |||
| 195 | msg.setParam(JSON.toJSONString(jsonObject1)); | ||
| 196 | |||
| 197 | dataSyncMsg.setMsgData(JSON.toJSONString(msg)); | ||
| 198 | log.info("调用uc-engine的接口 ==>> /uce/taskOperation/dealTask, 参数 ==>> {}",dataSyncMsg); | ||
| 199 | JSONObject response = this.restTemplateClient.dealTask(dataSyncMsg); | ||
| 200 | if (Objects.nonNull(response)) { | ||
| 201 | log.info("uc-engine任务处理接口的响应结果,/uce/taskOperation/dealTask ==>> {}",response); | ||
| 202 | } else { | ||
| 203 | log.error("uc-engine响应超时,请检查uc-engine服务"); | ||
| 204 | throw new BadRequestException("uc-engine响应超时"); | ||
| 180 | } | 205 | } |
| 181 | 206 | ||
| 182 | } | 207 | } |
| ... | @@ -184,18 +209,35 @@ public class UcEventBusIptv2ManagementUcEngine { | ... | @@ -184,18 +209,35 @@ public class UcEventBusIptv2ManagementUcEngine { |
| 184 | } | 209 | } |
| 185 | 210 | ||
| 186 | break; | 211 | break; |
| 187 | |||
| 188 | } | 212 | } |
| 189 | 213 | ||
| 190 | //return null; | 214 | //return null; |
| 191 | } | 215 | } |
| 192 | 216 | ||
| 217 | |||
| 218 | |||
| 219 | |||
| 220 | |||
| 221 | |||
| 222 | |||
| 223 | |||
| 224 | |||
| 225 | |||
| 226 | |||
| 227 | |||
| 228 | |||
| 229 | |||
| 230 | |||
| 231 | |||
| 232 | |||
| 233 | |||
| 193 | private DataSyncMsg checkTask(Integer playDurationValueTotal, String time, Integer deviceType, String mediaCode, | 234 | private DataSyncMsg checkTask(Integer playDurationValueTotal, String time, Integer deviceType, String mediaCode, |
| 194 | Long mediaId, String mediaName, DataSyncMsg dataSyncMsg, | 235 | Long mediaId, String mediaName, DataSyncMsg dataSyncMsg, |
| 195 | DataSyncMsg.MsgData msgData, UserTvDTO userTvDTO) { | 236 | DataSyncMsg.MsgData msgData, UserTvDTO userTvDTO) { |
| 196 | 237 | ||
| 197 | // 检查播放记录任务 | 238 | // 检查播放记录任务 |
| 198 | List<TaskAttrDTO> taskAttrDTOList = new ArrayList<>(); | 239 | List<TaskAttrDTO> taskAttrDTOList = new ArrayList<>(); |
| 240 | // TODO 枚举 | ||
| 199 | TaskTemplateDTO taskTemplateDTO = this.taskTemplateService.findByType(8); | 241 | TaskTemplateDTO taskTemplateDTO = this.taskTemplateService.findByType(8); |
| 200 | if (Objects.nonNull(taskTemplateDTO.getId())) { | 242 | if (Objects.nonNull(taskTemplateDTO.getId())) { |
| 201 | List<Task> taskList = this.taskService.findByTemplateId(taskTemplateDTO.getId()); | 243 | List<Task> taskList = this.taskService.findByTemplateId(taskTemplateDTO.getId()); |
| ... | @@ -250,7 +292,7 @@ public class UcEventBusIptv2ManagementUcEngine { | ... | @@ -250,7 +292,7 @@ public class UcEventBusIptv2ManagementUcEngine { |
| 250 | Integer integer = attrList.get(i).get(0); | 292 | Integer integer = attrList.get(i).get(0); |
| 251 | 293 | ||
| 252 | if (playDurationValueTotal >= integer) { | 294 | if (playDurationValueTotal >= integer) { |
| 253 | dataSyncMsg1 = getDataSyncMsg(time, mediaCode, mediaId, mediaName, integer, dataSyncMsg, | 295 | dataSyncMsg1 = getDataSyncMsg(time, mediaCode, mediaId, mediaName, playDurationValueTotal, dataSyncMsg, |
| 254 | msgData, userTvDTO); | 296 | msgData, userTvDTO); |
| 255 | dataSyncMsg1.setEvt("PLAY"); | 297 | dataSyncMsg1.setEvt("PLAY"); |
| 256 | dataSyncMsg1.setEvent(8); | 298 | dataSyncMsg1.setEvent(8); |
| ... | @@ -266,6 +308,18 @@ public class UcEventBusIptv2ManagementUcEngine { | ... | @@ -266,6 +308,18 @@ public class UcEventBusIptv2ManagementUcEngine { |
| 266 | return dataSyncMsg1; | 308 | return dataSyncMsg1; |
| 267 | } | 309 | } |
| 268 | 310 | ||
| 311 | private Integer getTotalPlayDurationFromRedis(String key) { | ||
| 312 | Map<Object, Object> total = this.redisUtils.hmget("key"); | ||
| 313 | if (Objects.nonNull(total)){ | ||
| 314 | Object total1 = total.get("total"); | ||
| 315 | if (Objects.nonNull(total1)) { | ||
| 316 | return Integer.valueOf(total1.toString()); | ||
| 317 | } | ||
| 318 | } | ||
| 319 | |||
| 320 | return 0; | ||
| 321 | } | ||
| 322 | |||
| 269 | private Integer getRedisTotalKey(Map<Object, Object> hmget) { | 323 | private Integer getRedisTotalKey(Map<Object, Object> hmget) { |
| 270 | Set<Object> objects = hmget.keySet(); | 324 | Set<Object> objects = hmget.keySet(); |
| 271 | return objects.size(); | 325 | return objects.size(); | ... | ... |
| ... | @@ -42,24 +42,23 @@ public class RestTemplateClient { | ... | @@ -42,24 +42,23 @@ public class RestTemplateClient { |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | public JSONObject dealTask(DataSyncMsg dataSyncMsg) { | 44 | public JSONObject dealTask(DataSyncMsg dataSyncMsg) { |
| 45 | JSONObject resultSet = null; | ||
| 45 | String url = BASE_URL + "/uce/taskOperation/dealTask"; | 46 | String url = BASE_URL + "/uce/taskOperation/dealTask"; |
| 46 | log.info("request uc : url is " + url + ", dataSyncMsg is " + dataSyncMsg); | 47 | log.info("request uc : url is " + url + ", dataSyncMsg is " + dataSyncMsg); |
| 47 | String content = JSON.toJSONString(dataSyncMsg); | 48 | String content = JSON.toJSONString(dataSyncMsg); |
| 48 | HashMap<Object, Object> objectObjectHashMap = new HashMap<>(); | 49 | HashMap<Object, Object> objectObjectHashMap = new HashMap<>(); |
| 49 | objectObjectHashMap.put("content", content); | 50 | objectObjectHashMap.put("content", content); |
| 50 | log.info("===>>>" + content); | ||
| 51 | restTemplate.postForEntity(url, objectObjectHashMap, String.class); | 51 | restTemplate.postForEntity(url, objectObjectHashMap, String.class); |
| 52 | /* ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, objectObjectHashMap, String.class); | 52 | ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, objectObjectHashMap, String.class); |
| 53 | if (responseEntity.getStatusCode().is2xxSuccessful()) { | 53 | if (responseEntity.getStatusCode().is2xxSuccessful()) { |
| 54 | String entityBody = responseEntity.getBody();444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444被44444444444444 444444 44444 44444 44444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444 | 54 | String entityBody = responseEntity.getBody(); |
| 55 | JSONObject jsonObject = JSONObject.parseObject(entityBody); | 55 | JSONObject jsonObject = JSONObject.parseObject(entityBody); |
| 56 | if (jsonObject.getInteger("businessCode").equals(200)) { | 56 | if (jsonObject.getInteger("businessCode").equals(ResponseStatusConstant.OK)) { |
| 57 | resultSet = jsonObject.getJSONArray("resultSet").getJSONObject(0); | 57 | resultSet = jsonObject.getJSONArray("resultSet").getJSONObject(0); |
| 58 | } | 58 | } |
| 59 | } | 59 | } |
| 60 | log.info("uc response: " + resultSet.toJSONString()); | 60 | log.info("uc response: " + resultSet.toJSONString()); |
| 61 | return resultSet;*/ | 61 | return resultSet; |
| 62 | return null; | ||
| 63 | } | 62 | } |
| 64 | 63 | ||
| 65 | public JSONObject getMemberInfo(Long memberId) { | 64 | public JSONObject getMemberInfo(Long memberId) { | ... | ... |
| ... | @@ -99,12 +99,12 @@ mutil-mq: | ... | @@ -99,12 +99,12 @@ mutil-mq: |
| 99 | service: | 99 | service: |
| 100 | mq: | 100 | mq: |
| 101 | list: | 101 | list: |
| 102 | # - source: event | 102 | - source: event |
| 103 | # exchange: event.exchange | 103 | exchange: event.exchange |
| 104 | # queue: event.queue | 104 | queue: event.queue |
| 105 | # exchange-type: direct | 105 | exchange-type: direct |
| 106 | # routing-key: | 106 | routing-key: |
| 107 | # active: service | 107 | active: service |
| 108 | - source: collection | 108 | - source: collection |
| 109 | exchange: exchange.collection | 109 | exchange: exchange.collection |
| 110 | queue: collection.queue | 110 | queue: collection.queue |
| ... | @@ -136,12 +136,12 @@ service: | ... | @@ -136,12 +136,12 @@ service: |
| 136 | # exchange-type: direct | 136 | # exchange-type: direct |
| 137 | # routing-key: | 137 | # routing-key: |
| 138 | # active: service | 138 | # active: service |
| 139 | # - source: eventBus | 139 | - source: eventBus |
| 140 | # exchange: uc.eventbus | 140 | exchange: uc.eventbus |
| 141 | # queue: uc.eventbus | 141 | queue: uc.eventbus |
| 142 | # exchange-type: topic | 142 | exchange-type: topic |
| 143 | # routing-key: uc.eventbus.*.topic | 143 | routing-key: uc.eventbus.*.topic |
| 144 | # active: service | 144 | active: service |
| 145 | - source: uce | 145 | - source: uce |
| 146 | exchange: uce.exchange | 146 | exchange: uce.exchange |
| 147 | queue: uce.queue | 147 | queue: uce.queue | ... | ... |
| ... | @@ -64,12 +64,12 @@ | ... | @@ -64,12 +64,12 @@ |
| 64 | 64 | ||
| 65 | 65 | ||
| 66 | <!--监控sql日志输出 --> | 66 | <!--监控sql日志输出 --> |
| 67 | <logger name="jdbc.sqlonly" level="INFO" additivity="false"> | 67 | <logger name="jdbc.sqlonly" level="OFF" additivity="false"> |
| 68 | <appender-ref ref="console" /> | 68 | <appender-ref ref="console" /> |
| 69 | <appender-ref ref="info" /> | 69 | <appender-ref ref="info" /> |
| 70 | </logger> | 70 | </logger> |
| 71 | 71 | ||
| 72 | <logger name="jdbc.resultset" level="ERROR" additivity="false"> | 72 | <logger name="jdbc.resultset" level="OFF" additivity="false"> |
| 73 | <appender-ref ref="console" /> | 73 | <appender-ref ref="console" /> |
| 74 | <appender-ref ref="info" /> | 74 | <appender-ref ref="info" /> |
| 75 | </logger> | 75 | </logger> | ... | ... |
-
Please register or sign in to post a comment