admin
2019-07-30 573c491b4a1ba60e12a5678a01c1546c0077c1ee
fanli/src/main/java/com/yeshi/fanli/job/UpdateDaTaoKeJob.java
@@ -1,21 +1,15 @@
package com.yeshi.fanli.job;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import com.yeshi.fanli.entity.bus.lable.BoutiqueAutoRule;
import com.yeshi.fanli.entity.bus.lable.QualityFactory;
import com.yeshi.fanli.entity.common.AdminUser;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.lable.QualityFactoryService;
import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailService;
import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailV2Service;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.taobao.DaTaoKeUtil;
/**
 * 更新大淘客数据
@@ -30,53 +24,100 @@
   @Resource
   private DaTaoKeGoodsDetailService daTaoKeGoodsService;
   // 两小时执行一次 对商品信息进行更新
   @Scheduled(cron = "0 0 0/2 * * ?")
   public void doUpdateJob() {
   @Resource
   private DaTaoKeGoodsDetailV2Service daTaoKeGoodsDetailV2Service;
      if (!Constant.IS_TASK)
         return;
      List<TaoBaoGoodsBrief> listgoods = DaTaoKeUtil.getDingDongQiang();
      if (listgoods == null || listgoods.size() == 0) {
         return;
      }
      try {
         /* 操作人: 开发账号 */
         AdminUser admin = new AdminUser(2L);
         BoutiqueAutoRule autoRule = new BoutiqueAutoRule();
         autoRule.setAdminUser(admin);
         autoRule.setCalss9k9(false);
         autoRule.setFlashSale(true);
         autoRule.setStartWeight(1);
         autoRule.setEndWeight(3000);
         autoRule.setGoodsSource(QualityFactory.SOURCE_TAOBAO_DATAOKE);
         qualityFactoryService.autoInsertOrUpadateStorage(listgoods, null, autoRule);
      } catch (Exception e) {
         try {
            LogHelper.errorDetailInfo(e);
         } catch (Exception e1) {
            e1.printStackTrace();
         }
      }
   }
   //20分钟更新一次
   @Scheduled(cron = "0 0/20 * * * ? ")
   // 1个小时更新一次
   @Scheduled(cron = "0 0 0/1 * * ? ")
   public void doSyncJob() {
      if (!Constant.IS_TASK)
         return;
      try {
         daTaoKeGoodsService.startSyncGoods();
         new Thread(new Runnable() {
            @Override
            public void run() {
               daTaoKeGoodsService.startSyncGoods();
            }
         }).start();
      } catch (Exception e) {
         try {
            LogHelper.errorDetailInfo(e);
         } catch (Exception e1) {
            e1.printStackTrace();
         }
         LogHelper.errorDetailInfo(e);
      }
   }
   // 每天早上同步一次
   @Scheduled(cron = "0 0 6 * * ? ")
   public void doSyncJobNew() {
      if (!Constant.IS_TASK)
         return;
      try {
         new Thread(new Runnable() {
            @Override
            public void run() {
               daTaoKeGoodsDetailV2Service.startSyncGoods();
            }
         }).start();
      } catch (Exception e) {
         LogHelper.errorDetailInfo(e);
      }
   }
   @Scheduled(cron = "0 0/10 * * * ? ")
   public void doUpdateJobNew() {
      if (!Constant.IS_TASK)
         return;
      try {
         new Thread(new Runnable() {
            @Override
            public void run() {
               daTaoKeGoodsDetailV2Service.updateNewGoods();
            }
         }).start();
      } catch (Exception e) {
         LogHelper.errorDetailInfo(e);
      }
   }
   @Scheduled(cron = "0 0/10 * * * ? ")
   public void doDeleteJobNew() {
      if (!Constant.IS_TASK)
         return;
      try {
         new Thread(new Runnable() {
            @Override
            public void run() {
               daTaoKeGoodsDetailV2Service.deleteInvalid();
            }
         }).start();
      } catch (Exception e) {
         LogHelper.errorDetailInfo(e);
      }
   }
   // 每天的8点,11点,19点,23点执行一次
   @Scheduled(cron = "0 0 8,11,19,23 * * ? ")
   public void doUpdateInfoJobNew() {
      if (!Constant.IS_TASK)
         return;
      try {
         new Thread(new Runnable() {
            @Override
            public void run() {
               daTaoKeGoodsDetailV2Service.updateData();
            }
         }).start();
      } catch (Exception e) {
         LogHelper.errorDetailInfo(e);
      }
   }