From 8c04d27e5cebb7e654c208533e9567c4df2c8acc Mon Sep 17 00:00:00 2001 From: yujian <yujian@163.com> Date: 星期四, 12 十二月 2019 14:21:44 +0800 Subject: [PATCH] 券时间限制 --- fanli/src/main/java/com/yeshi/fanli/job/BrandInfoJob.java | 32 ++++++++++---------------------- 1 files changed, 10 insertions(+), 22 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/job/BrandInfoJob.java b/fanli/src/main/java/com/yeshi/fanli/job/BrandInfoJob.java index dd3ec02..b563cde 100644 --- a/fanli/src/main/java/com/yeshi/fanli/job/BrandInfoJob.java +++ b/fanli/src/main/java/com/yeshi/fanli/job/BrandInfoJob.java @@ -1,11 +1,9 @@ package com.yeshi.fanli.job; -import java.util.Date; - import javax.annotation.Resource; +import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; -import org.yeshi.utils.DateUtil; import com.yeshi.fanli.log.LogHelper; import com.yeshi.fanli.service.inter.brand.BrandInfoService; @@ -26,7 +24,7 @@ /** * 姣忎袱涓皬鏃惰繘琛屾洿鏂板搧鐗屽晢鍝佷俊鎭� */ -// @Scheduled(cron = "0 0 1/2 * * ? ") + @Scheduled(cron = "0 0 1/2 * * ? ") public void updateGoods() { if (!Constant.IS_TASK) return; @@ -34,25 +32,15 @@ long count = brandInfoService.countValidByCid(null); if (count == 0) return; - - for (int page = 1; page < (count / 100) + 1; page++) { - brandInfoService.addShopAndGoods((page - 1) * 100, 100); + + long totalPage = (count / 100) + 1; + for (long page = 0; page < totalPage; page++) { + try { + brandInfoService.addShopAndGoods(page * 100, 100); + } catch (Exception e) { + LogHelper.errorDetailInfo(e); + } } } - /** - * 娓呯悊鍓嶄竴澶╃殑 - */ -// @Scheduled(cron = "0 30 0 * * ? ") - public void removeAgoByDate() { - if (!Constant.IS_TASK) - return; - - try { - brandInfoService.removeAgoByDate(DateUtil.reduceDay(1, new Date())); - } catch (Exception e) { - LogHelper.errorDetailInfo(e); - } - } - } -- Gitblit v1.8.0