From c952aab8ce904bc4146e5049faf5dab9f661a1fb Mon Sep 17 00:00:00 2001 From: luoyang Date: Thu, 23 Apr 2020 18:05:27 +0800 Subject: [PATCH] add synchronizedScheduler citypartner prize --- pom.xml | 2 +- .../manage/task/OrgCommissionTask.java | 24 +++++++++++-------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index d9906ee3d..3b96f3bfc 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ 4.0.0 manage - 2.2.9 + 2.2.10 UTF-8 1.8.0 diff --git a/src/main/java/au/com/royalpay/payment/manage/task/OrgCommissionTask.java b/src/main/java/au/com/royalpay/payment/manage/task/OrgCommissionTask.java index 614ef9212..1a7a42647 100644 --- a/src/main/java/au/com/royalpay/payment/manage/task/OrgCommissionTask.java +++ b/src/main/java/au/com/royalpay/payment/manage/task/OrgCommissionTask.java @@ -5,10 +5,12 @@ import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; import javax.annotation.Resource; import java.util.Calendar; import java.util.Date; +import java.util.List; @Component @ConditionalOnProperty(value = "app.run-tasks", havingValue = "true") @@ -21,16 +23,18 @@ public class OrgCommissionTask { @Scheduled(cron = "0 15 0 1 * ?") public void generateOrgCommission() { - Calendar monthCal = Calendar.getInstance(); - monthCal.setTime(new Date()); - int year = monthCal.get(Calendar.YEAR); - int month = monthCal.get(Calendar.MONTH); - if (month == 0) { - year = year - 1; - month = 12; - } - String monthStr = year + "-" + month; - cityPartnerPrizeService.generate(monthStr); + synchronizedScheduler.executeProcess("manage_task:cityPartnerPrize", 120_000, () -> { + Calendar monthCal = Calendar.getInstance(); + monthCal.setTime(new Date()); + int year = monthCal.get(Calendar.YEAR); + int month = monthCal.get(Calendar.MONTH); + if (month == 0) { + year = year - 1; + month = 12; + } + String monthStr = year + "-" + month; + cityPartnerPrizeService.generate(monthStr); + }); } }