| | |
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.scheduling.annotation.Scheduled;
|
| | | import org.springframework.stereotype.Component;
|
| | |
|
| | | import com.xxl.job.core.biz.model.ReturnT;
|
| | | import com.xxl.job.core.handler.annotation.XxlJob;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.order.tb.TaoBaoOrderService;
|
| | | import com.yeshi.fanli.util.CMQManager;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.RedisKeyEnum;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | |
| | | while (its.hasNext()) {
|
| | | String key = its.next();
|
| | | List<TaoBaoOrder> orders = map.get(key);
|
| | | String redisKey = "addorderqueue-" + TaoBaoOrderUtil.getOrderDataHashCode(orders);
|
| | | ;
|
| | | String redisKey = RedisKeyEnum.getRedisKey(RedisKeyEnum.addOrderQueue,
|
| | | TaoBaoOrderUtil.getOrderDataHashCode(orders));
|
| | | // redis做频率限制
|
| | | try {
|
| | | if (!StringUtil.isNullOrEmpty(redisManager.getCommonString(redisKey))) {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | @XxlJob("updateTBRelationAndSpecialOrderHandler")
|
| | | public ReturnT<String> updateTBRelationAndSpecialOrder(String param) throws Exception {
|
| | | if ("1".equalsIgnoreCase(param)) {// 爬取近20分钟的数据
|
| | | doJob1();
|
| | | } else if ("1day".equalsIgnoreCase(param)) {// 每5分钟更新(近1天数据)
|
| | | doJob2();
|
| | | }
|
| | | return ReturnT.SUCCESS;
|
| | | }
|
| | |
|
| | | // 每30s爬取一次
|
| | | @Scheduled(cron = "0/30 * * * * ? ")
|
| | | public void doJob1() {
|
| | | if (!Constant.IS_TASK)
|
| | | return;
|
| | | // 爬取近20分钟的数据
|
| | | LogHelper.job("爬单:30s爬取一次单");
|
| | | Date systemDate = TaoKeApiUtil.getTaoBaoSystemTime();
|
| | | long endTime = systemDate != null ? systemDate.getTime() : System.currentTimeMillis();
|
| | |
| | | }
|
| | |
|
| | | // 每5分钟更新(近1天数据)
|
| | | @Scheduled(cron = "0 0/5 * * * ? ")
|
| | | public void doJob2() {
|
| | | if (!Constant.IS_TASK)
|
| | | return;
|
| | | LogHelper.job("爬单:5min爬取一次单");
|
| | | Date systemDate = TaoKeApiUtil.getTaoBaoSystemTime();
|
| | | long endTime = systemDate != null ? systemDate.getTime() : System.currentTimeMillis();
|