| | |
| | | package com.yeshi.fanli.job;
|
| | |
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
| | | import org.springframework.stereotype.Component;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.activity.RecommendActivity;
|
| | | import com.yeshi.fanli.entity.bus.recommend.RecommendSectionGoods;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.exception.ActivityException;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.activity.ActivityService;
|
| | | import com.yeshi.fanli.service.inter.config.EveryDayTaskService;
|
| | | import com.yeshi.fanli.service.inter.goods.RecommendSectionGoodsService;
|
| | | import com.yeshi.fanli.service.inter.brand.BrandClassShopGoodsService;
|
| | | import com.yeshi.fanli.service.inter.brand.BrandClassShopService;
|
| | | import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService;
|
| | | import com.yeshi.fanli.service.inter.lable.LabelService;
|
| | | import com.yeshi.fanli.service.inter.lable.QualityFactoryService;
|
| | | import com.yeshi.fanli.service.inter.lable.QualityFlashSaleService;
|
| | | import com.yeshi.fanli.service.inter.taobao.ShareHotGoodsService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TLJBuyGoodsService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsActivityService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService;
|
| | | import com.yeshi.fanli.util.CMQManager;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | | import com.yeshi.fanli.util.cache.HttpGoodsCacheManager;
|
| | |
|
| | | /**
|
| | | * 淘宝商品更细
|
| | |
| | | private TaoBaoGoodsBriefService taoBaoGoodsBriefService;
|
| | |
|
| | | @Resource
|
| | | private EveryDayTaskService everyDayTaskService;
|
| | |
|
| | | @Resource
|
| | | private RecommendSectionGoodsService recommendSectionGoodsService;
|
| | |
|
| | | @Resource
|
| | | private ActivityService activityService;
|
| | |
|
| | | @Resource
|
| | |
| | |
|
| | | @Resource
|
| | | private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private QualityFlashSaleService qualityFlashSaleService;
|
| | | |
| | | |
| | |
|
| | | @Scheduled(cron = "0 0 0 * * ?")
|
| | | public void doJob() {
|
| | | if (!Constant.IS_TASK)
|
| | | return;
|
| | | taoBaoGoodsBriefService.getUpdateTaoBao();
|
| | | }
|
| | | @Resource
|
| | | private BrandClassShopService brandClassShopService;
|
| | |
|
| | | // 两小时执行一次 对推荐商品信息进行更新
|
| | | @Scheduled(cron = "0 0 */2 * * ?")
|
| | | public void doUpdateJob() {
|
| | | if (!Constant.IS_TASK)
|
| | | return;
|
| | | List<RecommendSectionGoods> list = taoBaoGoodsBriefService.listRecommendSectionGoods();
|
| | | for (RecommendSectionGoods recommendSectionGoods : list) {
|
| | | try {
|
| | | TaoBaoGoodsBrief goods = TaoKeApiUtil
|
| | | .searchGoodsDetail(recommendSectionGoods.getTaoBaoGoodsBrief().getAuctionId());
|
| | | taoBaoGoodsUpdateService.updateTaoBaoGoods(goods);
|
| | | } catch (TaobaoGoodsDownException e1) {
|
| | | taoBaoGoodsUpdateService.downTaoBaoGoods(recommendSectionGoods.getTaoBaoGoodsBrief().getAuctionId());
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | @Resource
|
| | | private TaoBaoGoodsActivityService taoBaoGoodsActivityService;
|
| | |
|
| | | @Resource
|
| | | private ShareHotGoodsService shareHotGoodsService;
|
| | |
|
| | | @Resource
|
| | | private TLJBuyGoodsService tljBuyGoodsService;
|
| | |
|
| | | @Resource
|
| | | private BrandClassShopGoodsService brandClassShopGoodsService;
|
| | |
|
| | | @Resource
|
| | | private HttpGoodsCacheManager httpGoodsCacheManager;
|
| | |
|
| | | // 动态商品更新 ,1个小时更新
|
| | | @Scheduled(cron = "0 0 */1 * * ?")
|
| | |
| | | }
|
| | |
|
| | | try {
|
| | | LogHelper.test("---执行--updateQualityFactoryWeightJob--");
|
| | |
|
| | | qualityFactoryService.updateWeight(10, 3);
|
| | |
|
| | | qualityFactoryService.updateWeight(1, 4);
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | taoBaoGoodsUpdateService.deleteOutOfDate();
|
| | | }
|
| | |
|
| | | // 添加精选库中需要更新的淘宝商品ID(2个小时执行一次)
|
| | | @Scheduled(cron = "0 0 1/2 * * ? ")
|
| | | public void addNeddUpdateTaoBaoGoods() {
|
| | | if (!Constant.IS_TASK) {
|
| | | /**
|
| | | * 更新超过4个小时未更新的商品
|
| | | */
|
| | | // 1个小时更新
|
| | | @Scheduled(cron = "0 0 1/1 * * ? ")
|
| | | public void addNeedUpdateTaoBaoGoods() {
|
| | | if (!Constant.IS_TASK)
|
| | | return;
|
| | |
|
| | | List<Long> list = taoBaoGoodsUpdateService.listNeedUpdateGoodsId(0, 2000, 4);
|
| | | if (list == null || list.size() == 0) {
|
| | | return;
|
| | | }
|
| | | |
| | | LogHelper.test("---addNeddUpdateTaoBaoGoods----execute ");
|
| | | |
| | | List<Long> list = qualityFactoryService.queryNeedUpdate(0, 3000, 4);
|
| | | if (list != null) {
|
| | | for (Long id : list) {
|
| | | try {
|
| | | CMQManager.getInstance().addNeedUpdateTaoBaoGoodsId(id);
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | for (Long id : list) {
|
| | | try {
|
| | | CMQManager.getInstance().addNeedUpdateTaoBaoGoodsId(id);
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 定时清理超过6个小时未更新的限时抢购商品
|
| | | */
|
| | | @Scheduled(cron = "0 15 0/6 * * ? ")
|
| | | public void removeFlashSaleGoods() {
|
| | | |
| | | if (!Constant.IS_TASK) {
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | try {
|
| | | while (true) {
|
| | | List<Long> list = qualityFlashSaleService.queryNeedRemove(0, 100, 6);
|
| | | |
| | | List<Long> list = qualityFlashSaleService.queryNeedRemove(0, 200, 6);
|
| | | if (list == null || list.size() == 0) {
|
| | | break;
|
| | | } |
| | | |
| | | }
|
| | | qualityFlashSaleService.deleteBatchByPrimaryKey(list);
|
| | | }
|
| | | |
| | |
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | | // 更新增加品牌商品,每天早上6点执行一次
|
| | | @Scheduled(cron = "0 0 6 * * ? ")
|
| | | public void updateAddBrandGoods() {
|
| | | if (!Constant.IS_TASK)
|
| | | return;
|
| | | brandClassShopService.updateShopGoods();
|
| | | }
|
| | |
|
| | | // 更新原有精品库的品牌商品,每天凌晨3点执行一次
|
| | | @Scheduled(cron = "0 0 3 * * ? ")
|
| | | public void updateBrandGoods() {
|
| | | if (!Constant.IS_TASK)
|
| | | return;
|
| | | brandClassShopGoodsService.startUpdateGoods();
|
| | | }
|
| | |
|
| | | // 每天凌晨4点模拟请求
|
| | | @Scheduled(cron = "0 0 4 * * ? ")
|
| | | public void simulateRequest() {
|
| | | httpGoodsCacheManager.requestHomeRecommend();
|
| | | httpGoodsCacheManager.requestClassGoods();
|
| | | httpGoodsCacheManager.requestBrandGoods();
|
| | | httpGoodsCacheManager.requestDynamic();
|
| | | httpGoodsCacheManager.requestCommonTemplate();
|
| | | }
|
| | | }
|