| | |
| | | package com.yeshi.buwan.util; |
| | | |
| | | import com.yeshi.buwan.domain.VideoInfo; |
| | | import com.yeshi.buwan.dto.mq.FunTVAlbum2MQMsg; |
| | | import com.yeshi.buwan.dto.mq.IqiyiAlbum2MQMsg; |
| | | import com.yeshi.buwan.dto.mq.SolrVideoMQMsg; |
| | | import com.yeshi.buwan.funtv.entity.FunTVAlbum2; |
| | | import com.yeshi.buwan.funtv.entity.FunTVVideo2; |
| | | import com.yeshi.buwan.iqiyi.entity.IqiyiAlbum2; |
| | | import com.yeshi.buwan.service.imp.JobThreadExecutorServiceImpl; |
| | | import com.yeshi.buwan.service.imp.VideoInfoService; |
| | | import com.yeshi.buwan.service.inter.juhe.FunTV2Service; |
| | | import com.yeshi.buwan.service.inter.juhe.Iqiyi2Service; |
| | | import com.yeshi.buwan.service.manager.SolrAlbumDataManager; |
| | | import com.yeshi.buwan.util.mq.CMQManager; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.context.ApplicationListener; |
| | | import org.springframework.context.event.ContextRefreshedEvent; |
| | | import org.springframework.stereotype.Component; |
| | |
| | | @Component |
| | | public class SpringContext implements ApplicationListener<ContextRefreshedEvent> { |
| | | |
| | | |
| | | @Resource |
| | | private VideoInfoService videoInfoService; |
| | | |
| | |
| | | @Resource |
| | | private Iqiyi2Service iqiyi2Service; |
| | | |
| | | @Resource |
| | | private FunTV2Service funTV2Service; |
| | | |
| | | |
| | | private static boolean isInited = false; |
| | | |
| | | private final static Logger logger = LoggerFactory.getLogger(SpringContext.class); |
| | | |
| | | public void onApplicationEvent(ContextRefreshedEvent arg0) { |
| | | if (arg0.getApplicationContext().getParent() != null) { |
| | |
| | | private void init() { |
| | | doSolrJob(); |
| | | doAddIqiyi2Video(); |
| | | doAddFunTV2Video(); |
| | | } |
| | | |
| | | private void doSolrJob() { |
| | |
| | | for (SolrVideoMQMsg solrVideo : solrMsgList) { |
| | | try { |
| | | VideoInfo videoInfo = videoInfoService.getVideoInfo(solrVideo.getId()); |
| | | if (videoInfo != null) |
| | | solrDataManager.saveOrUpdate(videoInfo); |
| | | if (videoInfo != null) { |
| | | if ("1".equalsIgnoreCase(videoInfo.getShow())) |
| | | solrDataManager.saveOrUpdate(videoInfo); |
| | | else |
| | | solrDataManager.deleteById(videoInfo.getId()); |
| | | } |
| | | CMQManager.getInstance().deleteSolrMsg(solrVideo.getHandler()); |
| | | } catch (Exception e) { |
| | | |
| | |
| | | new JobThreadExecutorServiceImpl().run(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | List<IqiyiAlbum2MQMsg> iqiyiAlbumMsgList = CMQManager.getInstance().consumeAlbumUpdateMsg(16); |
| | | List<IqiyiAlbum2MQMsg> iqiyiAlbumMsgList = CMQManager.getInstance().consumeIqiyiAlbumUpdateMsg(16); |
| | | if (iqiyiAlbumMsgList != null) |
| | | for (IqiyiAlbum2MQMsg iqiyiAlbum2MQMsg : iqiyiAlbumMsgList) { |
| | | try { |
| | |
| | | if (album2 != null) { |
| | | iqiyi2Service.addToVideoInfo(album2); |
| | | } |
| | | CMQManager.getInstance().deleteAlbumUpdateMsg(iqiyiAlbum2MQMsg.getHandler()); |
| | | CMQManager.getInstance().deleteIqiyiAlbumUpdateMsg(iqiyiAlbum2MQMsg.getHandler()); |
| | | } catch (Exception e) { |
| | | |
| | | logger.error("爱奇艺专辑添加到视频出错:" + e.getMessage()); |
| | | logger.error("ID:" + iqiyiAlbum2MQMsg.getId()); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | private void doAddFunTV2Video() { |
| | | new JobThreadExecutorServiceImpl().run(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | List<FunTVAlbum2MQMsg> funTVAlbum2MsgList = CMQManager.getInstance().consumeFunTVAlbumUpdateMsg(16); |
| | | if (funTVAlbum2MsgList != null) |
| | | for (FunTVAlbum2MQMsg funTVAlbum2MQMsg : funTVAlbum2MsgList) { |
| | | try { |
| | | String mediaId = funTVAlbum2MQMsg.getId(); |
| | | FunTVAlbum2 album2 = funTV2Service.getAlbumDetail(mediaId); |
| | | if (album2 != null) { |
| | | funTV2Service.processAlbum(album2); |
| | | } |
| | | CMQManager.getInstance().deleteFunTVAlbumUpdateMsg(funTVAlbum2MQMsg.getHandler()); |
| | | } catch (Exception e) { |
| | | logger.error("风行专辑添加到视频出错:" + e.getMessage()); |
| | | logger.error("ID:" + funTVAlbum2MQMsg.getId()); |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | |
| | | } |