master
wangning 7 years ago
commit f7774cf14f

@ -2,17 +2,15 @@ package au.com.royalpay.payment.manage.task;
import au.com.royalpay.payment.manage.mappers.bill.BillOrderMapper; import au.com.royalpay.payment.manage.mappers.bill.BillOrderMapper;
import au.com.royalpay.payment.manage.mappers.payment.OrderMapper; import au.com.royalpay.payment.manage.mappers.payment.OrderMapper;
import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.util.List;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List;
/** /**
* Created by wangning on 2018/1/2. * Created by wangning on 2018/1/2.
@ -25,25 +23,30 @@ public class BillOrderCheckTask {
@Resource @Resource
private OrderMapper orderMapper; private OrderMapper orderMapper;
@Resource
private SynchronizedScheduler synchronizedScheduler;
@Scheduled(cron = "0 0/3 * * * ?") @Scheduled(cron = "0 0/3 * * * ?")
public void checkGreenChannel() { public void checkGreenChannel() {
List<String> orderIds = billOrderMapper.findOrderIdByStatus("0"); synchronizedScheduler.executeProcess("manage_task:checkGreenChannel", 120_000, () -> {
if(CollectionUtils.isEmpty(orderIds)){ List<String> orderIds = billOrderMapper.findOrderIdByStatus("0");
return; if (CollectionUtils.isEmpty(orderIds)) {
} return;
for (String p : orderIds) {
if (p==null){
continue;
} }
JSONObject order = orderMapper.find(p); for (String p : orderIds) {
int status = order.getIntValue("status"); if (p == null) {
if(status==3||status==1){ continue;
billOrderMapper.updateStatusByOrderId(p,"2"); }
JSONObject order = orderMapper.find(p);
int status = order.getIntValue("status");
if (status == 3 || status == 1) {
billOrderMapper.updateStatusByOrderId(p, "2");
}
if (status == 5) {
billOrderMapper.updateStatusByOrderId(p, "1");
}
} }
if(status==5){ });
billOrderMapper.updateStatusByOrderId(p,"1");
}
}
} }
} }

@ -2,6 +2,7 @@ package au.com.royalpay.payment.manage.task;
import au.com.royalpay.payment.manage.application.core.SimpleClientService; import au.com.royalpay.payment.manage.application.core.SimpleClientService;
import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -16,13 +17,16 @@ import javax.annotation.Resource;
public class CheckPartnerAuthStatusAndSendMessageTask { public class CheckPartnerAuthStatusAndSendMessageTask {
@Resource @Resource
private SimpleClientService simpleClientService; private SimpleClientService simpleClientService;
@Resource
private SynchronizedScheduler synchronizedScheduler;
// @Scheduled(cron = "0 0 9 * * ?") // @Scheduled(cron = "0 0 9 * * ?")
// public void checkAuthAndSendMessage(){ // public void checkAuthAndSendMessage(){
// simpleClientService.checkAuthAndSendMessage(); // simpleClientService.checkAuthAndSendMessage();
// } // }
@Scheduled(cron = "0 0 9 * * ?") @Scheduled(cron = "0 0 9 * * ?")
public void checkGreenChannel(){ public void checkGreenChannel() {
simpleClientService.checkGreenChannelClients(); synchronizedScheduler.executeProcess("manage_task:CheckPartnerAuthStatus", 120_000, () -> simpleClientService.checkGreenChannelClients());
} }
} }

@ -3,6 +3,7 @@ package au.com.royalpay.payment.manage.task;
import au.com.royalpay.payment.manage.apps.core.CustomerImpressionService; import au.com.royalpay.payment.manage.apps.core.CustomerImpressionService;
import au.com.royalpay.payment.manage.mappers.system.ClientMapper; import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@ -27,32 +28,36 @@ public class CustomerImpressionTask {
private ClientMapper clientMapper; private ClientMapper clientMapper;
@Resource @Resource
private CustomerImpressionService customerImpressionService; private CustomerImpressionService customerImpressionService;
@Resource
private SynchronizedScheduler synchronizedScheduler;
private ThreadPoolExecutor generatePool = new ThreadPoolExecutor(10, 30, 5, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>()); private ThreadPoolExecutor generatePool = new ThreadPoolExecutor(10, 30, 5, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
@Scheduled(cron = "0 30 3 * * ?") @Scheduled(cron = "0 30 3 * * ?")
public void generateTags() { public void generateTags() {
List<JSONObject> clients = clientMapper.listValidClient(); synchronizedScheduler.executeProcess("manage_task:CustomerImpression", 120_000, () -> {
List<List<JSONObject>> splitList = new ArrayList<>(); List<JSONObject> clients = clientMapper.listValidClient();
for (int i = 0; i < clients.size(); i+=200) { List<List<JSONObject>> splitList = new ArrayList<>();
if(i+200>clients.size()){ for (int i = 0; i < clients.size(); i += 200) {
splitList.add(clients.subList(i,clients.size())); if (i + 200 > clients.size()) {
}else { splitList.add(clients.subList(i, clients.size()));
splitList.add(clients.subList(i,i+200)); } else {
} splitList.add(clients.subList(i, i + 200));
}
} }
for (List<JSONObject> splitClients : splitList) { for (List<JSONObject> splitClients : splitList) {
Runnable task = () -> splitClients.forEach((p)->{ Runnable task = () -> splitClients.forEach((p) -> {
System.out.println("当前执行到"+p.getIntValue("client_id")); System.out.println("当前执行到" + p.getIntValue("client_id"));
customerImpressionService.generateTag(p.getIntValue("client_id")); customerImpressionService.generateTag(p.getIntValue("client_id"));
}); });
generatePool.execute(task); generatePool.execute(task);
} }
});
} }
@Scheduled(cron = "0/1 * * * * ?") @Scheduled(cron = "0/1 * * * * ?")
public void generateInfo() { public void generateInfo() {
customerImpressionService.generateInfo(); synchronizedScheduler.executeProcess("manage_task:CustomerImpression", 1_000, () -> customerImpressionService.generateInfo());
} }
} }

@ -2,6 +2,7 @@ package au.com.royalpay.payment.manage.task;
import au.com.royalpay.payment.manage.analysis.core.DailyReport; import au.com.royalpay.payment.manage.analysis.core.DailyReport;
import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler;
import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@ -21,10 +22,14 @@ public class DailyReportGenerationTask {
@Resource @Resource
private DailyReport dailyReport; private DailyReport dailyReport;
@Resource
private SynchronizedScheduler synchronizedScheduler;
@Scheduled(cron = "0 0 10 * * ?") @Scheduled(cron = "0 0 10 * * ?")
public void autoGenerateReport() { public void autoGenerateReport() {
Date yesterday = DateUtils.addDays(new Date(), -1); synchronizedScheduler.executeProcess("manage_task:autoGenerateDailyReport", 120_000, () -> {
dailyReport.generateReport(DateFormatUtils.format(yesterday, "yyyy-MM-dd"), true); Date yesterday = DateUtils.addDays(new Date(), -1);
dailyReport.generateReport(DateFormatUtils.format(yesterday, "yyyy-MM-dd"), true);
});
} }
} }

@ -2,6 +2,7 @@ package au.com.royalpay.payment.manage.task;
import au.com.royalpay.payment.manage.analysis.core.DashboardService; import au.com.royalpay.payment.manage.analysis.core.DashboardService;
import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
@ -19,8 +20,12 @@ import javax.annotation.Resource;
public class DashboardTaskManager { public class DashboardTaskManager {
@Resource @Resource
private DashboardService dashboardService; private DashboardService dashboardService;
@Resource
private SynchronizedScheduler synchronizedScheduler;
@Scheduled(cron = "0 0 2 * * ?") @Scheduled(cron = "0 0 2 * * ?")
public void analysisDashboard(){ public void analysisDashboard() {
dashboardService.generateCustomersAndOrdersStatistics(DateUtils.addDays(new Date(), -1)); synchronizedScheduler.executeProcess("manage_task:dashboardTask", 120_000,
() -> dashboardService.generateCustomersAndOrdersStatistics(DateUtils.addDays(new Date(), -1)));
} }
} }

@ -1,6 +1,7 @@
package au.com.royalpay.payment.manage.task; package au.com.royalpay.payment.manage.task;
import au.com.royalpay.payment.manage.billqrcode.core.PartnerBillService; import au.com.royalpay.payment.manage.billqrcode.core.PartnerBillService;
import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -15,9 +16,12 @@ import javax.annotation.Resource;
public class DirectedBillCodeStatusDailyCheck { public class DirectedBillCodeStatusDailyCheck {
@Resource @Resource
private PartnerBillService partnerBillService; private PartnerBillService partnerBillService;
@Resource
private SynchronizedScheduler synchronizedScheduler;
@Scheduled(cron = "0 30 5 * * ?") @Scheduled(cron = "0 30 5 * * ?")
public void statusDailyCheck(){ public void statusDailyCheck() {
partnerBillService.dailyCheckDirectedBillCode(); synchronizedScheduler.executeProcess("manage_task:dailyCheckDirected", 120_000,
() -> partnerBillService.dailyCheckDirectedBillCode());
} }
} }

@ -3,6 +3,7 @@ package au.com.royalpay.payment.manage.task;
import au.com.royalpay.payment.manage.mappers.ofei.TopUpOrderMapper; import au.com.royalpay.payment.manage.mappers.ofei.TopUpOrderMapper;
import au.com.royalpay.payment.manage.ofei.core.OfeiServer; import au.com.royalpay.payment.manage.ofei.core.OfeiServer;
import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -22,14 +23,19 @@ public class OfeiOrderCheckTask {
private OfeiServer ofeiServer; private OfeiServer ofeiServer;
@Resource @Resource
private TopUpOrderMapper topUpOrderMapper; private TopUpOrderMapper topUpOrderMapper;
@Resource
private SynchronizedScheduler synchronizedScheduler;
@Scheduled(cron = "0 0/20 * * * ?") @Scheduled(cron = "0 0/20 * * * ?")
public void checkGreenChannel(){ public void checkGreenChannel() {
List<String> orderIds = topUpOrderMapper.findOrderIdByStatus("10"); synchronizedScheduler.executeProcess("manage_task:ofeiOrderCheck", 120_000, () -> {
if(CollectionUtils.isEmpty(orderIds)){ List<String> orderIds = topUpOrderMapper.findOrderIdByStatus("10");
return; if (CollectionUtils.isEmpty(orderIds)) {
} return;
for (String orderId : orderIds) { }
ofeiServer.checkOrder(orderId); for (String orderId : orderIds) {
} ofeiServer.checkOrder(orderId);
}
});
} }
} }

@ -3,6 +3,7 @@ package au.com.royalpay.payment.manage.task;
import au.com.royalpay.payment.manage.merchants.core.ClientManager; import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import au.com.royalpay.payment.tools.env.PlatformEnvironment; import au.com.royalpay.payment.tools.env.PlatformEnvironment;
import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -13,15 +14,19 @@ import javax.annotation.Resource;
* Created by yixian on 2017-02-22. * Created by yixian on 2017-02-22.
*/ */
@Component @Component
@ConditionalOnProperty(value = "app.run-tasks",havingValue = "true") @ConditionalOnProperty(value = "app.run-tasks", havingValue = "true")
public class PartnerInitEmailChecker { public class PartnerInitEmailChecker {
@Resource @Resource
private ClientManager clientManager; private ClientManager clientManager;
@Resource
private SynchronizedScheduler synchronizedScheduler;
@Scheduled(cron = "0 0/5 * * * *") @Scheduled(cron = "0 0/5 * * * *")
public void checkEmailStatus(){ public void checkEmailStatus() {
if (PlatformEnvironment.getEnv().taskEnabled()) { if (PlatformEnvironment.getEnv().taskEnabled()) {
clientManager.checkEmailStatus(); synchronizedScheduler.executeProcess("manage_task:emailStatusCheck", 120_000,
() -> clientManager.checkEmailStatus());
} }
} }
} }

@ -2,6 +2,7 @@ package au.com.royalpay.payment.manage.task;
import au.com.royalpay.payment.manage.analysis.core.CustomersAnalysisService; import au.com.royalpay.payment.manage.analysis.core.CustomersAnalysisService;
import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
@ -19,8 +20,12 @@ import javax.annotation.Resource;
public class PartnerTransactionsDailyMsgTaskManager { public class PartnerTransactionsDailyMsgTaskManager {
@Resource @Resource
private CustomersAnalysisService customersAnalysisService; private CustomersAnalysisService customersAnalysisService;
@Resource
private SynchronizedScheduler synchronizedScheduler;
@Scheduled(cron = "0 0 8 * * ?") @Scheduled(cron = "0 0 8 * * ?")
public void analysisDashboard(){ public void analysisDashboard() {
customersAnalysisService.sendPartnerTransactionDaily(DateUtils.addDays(new Date(), -1)); synchronizedScheduler.executeProcess("manage_task:partnerDailyMsg", 120_000,
() -> customersAnalysisService.sendPartnerTransactionDaily(DateUtils.addDays(new Date(), -1)));
} }
} }

@ -8,6 +8,7 @@ import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApi;
import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApiProvider; import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApiProvider;
import au.com.royalpay.payment.tools.connections.mpsupport.beans.TemplateMessage; import au.com.royalpay.payment.tools.connections.mpsupport.beans.TemplateMessage;
import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.commons.lang3.time.DateFormatUtils;
@ -44,56 +45,61 @@ public class PostponeClientTask {
private ClientAccountMapper clientAccountMapper; private ClientAccountMapper clientAccountMapper;
@Resource @Resource
private ManagerMapper managerMapper; private ManagerMapper managerMapper;
@Resource
private SynchronizedScheduler synchronizedScheduler;
@Scheduled(cron = "0 30 8 * * ?") @Scheduled(cron = "0 30 8 * * ?")
public void checkGreenChannel() { public void checkGreenChannel() {
Date now = new Date(); synchronizedScheduler.executeProcess("manage_task:postPoneClient", 120_000, () -> {
Date tomorrow = DateUtils.addDays(now, 1); Date now = new Date();
Date yearTomorrow = DateUtils.addYears(tomorrow, 1); Date tomorrow = DateUtils.addDays(now, 1);
String expireDate = DateFormatUtils.format(yearTomorrow, "yyyy-MM-dd"); Date yearTomorrow = DateUtils.addYears(tomorrow, 1);
List<JSONObject> expiryClient = clientRateMapper.getAllExpiry(now); String expireDate = DateFormatUtils.format(yearTomorrow, "yyyy-MM-dd");
List<JSONObject> expiryClient = clientRateMapper.getAllExpiry(now);
if(CollectionUtils.isEmpty(expiryClient)){
return; if (CollectionUtils.isEmpty(expiryClient)) {
} return;
Map<Integer, JSONObject> expiryClients = new HashMap<>();
expiryClient.forEach(p -> {
expiryClients.put(p.getInteger("client_id"), p);
});
expiryClients.values().forEach(p -> {
int client_id = p.getIntValue("client_id");
List<JSONObject> adminAccounts = clientAccountMapper.listAdminAccounts(client_id);
List<JSONObject> clientRates = clientRateMapper.maxChannelExpiryTime(client_id, null);
JSONObject wechatRate = clientRateMapper.latestChannelCleanDays("Wechat", p.getIntValue("client_id"));
int cleanDays = 1;
if (wechatRate.getInteger("clean_days") != null) {
cleanDays = wechatRate.getIntValue("clean_days");
} else {
cleanDays = wechatRate.getIntValue("c_clean_days");
} }
int finalCleanDays = cleanDays; Map<Integer, JSONObject> expiryClients = new HashMap<>();
clientRates.forEach(o -> { expiryClient.forEach(p -> {
JSONObject record = clientRateMapper.latestExpiryConfig(client_id,o.getString("rate_name")); expiryClients.put(p.getInteger("client_id"), p);
record.remove("client_rate_id");
record.put("active_time", now);
record.put("manager_id", 0);
record.put("expiry_time", yearTomorrow);
record.put("create_time", now);
record.put("update_time", now);
record.put("clean_days", finalCleanDays);
record.put("manager_name", "System");
record.put("remark", "费率到期系统自动延期1年");
clientRateMapper.saveRate(record);
}); });
adminAccounts.forEach(o -> { expiryClients.values().forEach(p -> {
sendClientPostponeNotify(o, expireDate); int client_id = p.getIntValue("client_id");
List<JSONObject> adminAccounts = clientAccountMapper.listAdminAccounts(client_id);
List<JSONObject> clientRates = clientRateMapper.maxChannelExpiryTime(client_id, null);
JSONObject wechatRate = clientRateMapper.latestChannelCleanDays("Wechat", p.getIntValue("client_id"));
int cleanDays = 1;
if (wechatRate.getInteger("clean_days") != null) {
cleanDays = wechatRate.getIntValue("clean_days");
} else {
cleanDays = wechatRate.getIntValue("c_clean_days");
}
int finalCleanDays = cleanDays;
clientRates.forEach(o -> {
JSONObject record = clientRateMapper.latestExpiryConfig(client_id, o.getString("rate_name"));
record.remove("client_rate_id");
record.put("active_time", now);
record.put("manager_id", 0);
record.put("expiry_time", yearTomorrow);
record.put("create_time", now);
record.put("update_time", now);
record.put("clean_days", finalCleanDays);
record.put("manager_name", "System");
record.put("remark", "费率到期系统自动延期1年");
clientRateMapper.saveRate(record);
});
adminAccounts.forEach(o -> {
sendClientPostponeNotify(o, expireDate);
});
}); });
sendComplianceNotify(expiryClients, expireDate);
}); });
sendComplianceNotify(expiryClients, expireDate);
} }
private void sendClientPostponeNotify(JSONObject account,String newExpireDate) { private void sendClientPostponeNotify(JSONObject account, String newExpireDate) {
JSONObject client = clientManager.getClientInfo(account.getIntValue("client_id")); JSONObject client = clientManager.getClientInfo(account.getIntValue("client_id"));
try { try {
@ -101,8 +107,8 @@ public class PostponeClientTask {
if (api != null) { if (api != null) {
String templateId = api.getTemplateId("client-postpone"); String templateId = api.getTemplateId("client-postpone");
if (templateId != null) { if (templateId != null) {
TemplateMessage notice = initClientMessage(client,newExpireDate,account.getString("wechat_openid"),templateId); TemplateMessage notice = initClientMessage(client, newExpireDate, account.getString("wechat_openid"), templateId);
api.sendTemplateMessage(notice); api.sendTemplateMessage(notice);
} }
} }
} catch (Exception e) { } catch (Exception e) {
@ -129,7 +135,7 @@ public class PostponeClientTask {
private TemplateMessage initClientMessage(JSONObject client, String newExpiryDate, String wechatOpenid, String templateId) { private TemplateMessage initClientMessage(JSONObject client, String newExpiryDate, String wechatOpenid, String templateId) {
TemplateMessage notice = new TemplateMessage(wechatOpenid, templateId, null); TemplateMessage notice = new TemplateMessage(wechatOpenid, templateId, null);
notice.put("first", "您好您的合同费率已到期根据合同协议系统已自动为您延期1年。", "#ff0000"); notice.put("first", "您好您的合同费率已到期根据合同协议系统已自动为您延期1年。", "#ff0000");
notice.put("keyword1", client.getString("short_name")+"("+client.getString("client_moniker")+")", "#ff0000"); notice.put("keyword1", client.getString("short_name") + "(" + client.getString("client_moniker") + ")", "#ff0000");
notice.put("keyword2", newExpiryDate, "#0000ff"); notice.put("keyword2", newExpiryDate, "#0000ff");
notice.put("remark", "如有疑问请联系RoyalPay", "#000000"); notice.put("remark", "如有疑问请联系RoyalPay", "#000000");
return notice; return notice;

@ -3,6 +3,7 @@ package au.com.royalpay.payment.manage.task;
import au.com.royalpay.payment.manage.redpack.core.ActRedPackService; import au.com.royalpay.payment.manage.redpack.core.ActRedPackService;
import au.com.royalpay.payment.manage.redpack.core.RedpackService; import au.com.royalpay.payment.manage.redpack.core.RedpackService;
import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@ -23,20 +24,22 @@ public class RedPackTaskManager {
private RedpackService redpackService; private RedpackService redpackService;
@Resource @Resource
private ActRedPackService actRedPackService; private ActRedPackService actRedPackService;
@Resource
private SynchronizedScheduler synchronizedScheduler;
@Scheduled(cron = "0 0/10 * * * ?") @Scheduled(cron = "0 0/10 * * * ?")
public void updateRedPackStatus() { public void updateRedPackStatus() {
redpackService.updateRedPacketsStatus("3"); synchronizedScheduler.executeProcess("manage_task:updateRedpackStatus", 120_000, () -> redpackService.updateRedPacketsStatus("3"));
} }
@Scheduled(cron = "0 0/10 * * * ?") @Scheduled(cron = "0 0/10 * * * ?")
public void updateAlipayRedPackStatus() { public void updateAlipayRedPackStatus() {
redpackService.updateAlipayRedPacketsStatus("3"); synchronizedScheduler.executeProcess("manage_task:updateAlipayRedpackStatus", 120_000, () -> redpackService.updateAlipayRedPacketsStatus("3"));
} }
@Scheduled(cron = "0 0/3 * * * *") @Scheduled(cron = "0 0/3 * * * *")
public void resendFailedRedpack() { public void resendFailedRedpack() {
actRedPackService.resendFailed(); synchronizedScheduler.executeProcess("manage_task:resendFailedRedpack", 120_000, () -> actRedPackService.resendFailed());
} }
} }

@ -2,6 +2,7 @@ package au.com.royalpay.payment.manage.task;
import au.com.royalpay.payment.manage.analysis.core.EstimateAnalysisService; import au.com.royalpay.payment.manage.analysis.core.EstimateAnalysisService;
import au.com.royalpay.payment.manage.analysis.core.PlatformClearService; import au.com.royalpay.payment.manage.analysis.core.PlatformClearService;
import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -19,26 +20,28 @@ public class SettleEstimateTaskManger {
@Resource @Resource
private PlatformClearService platformClearService; private PlatformClearService platformClearService;
@Resource
private SynchronizedScheduler synchronizedScheduler;
// 3:15 am at every work days // 3:15 am at every work days
@Scheduled(cron = "0 20 3 * * ?") @Scheduled(cron = "0 20 3 * * ?")
public void generateSettleAmount() { public void generateSettleAmount() {
estimateAnalysisService.generateSettleAmount(); synchronizedScheduler.executeProcess("manage_task:genSettleAmount", 120_000, () -> estimateAnalysisService.generateSettleAmount());
} }
// 2:15 every day // 2:15 every day
@Scheduled(cron = "0 0 3 * * ?") @Scheduled(cron = "0 0 3 * * ?")
public void generateTransactionAmount() { public void generateTransactionAmount() {
estimateAnalysisService.generateTransactionData(); synchronizedScheduler.executeProcess("manage_task:genTransAmount", 120_000, () -> estimateAnalysisService.generateTransactionData());
} }
@Scheduled(cron = "0 0 13 * * ?") @Scheduled(cron = "0 0 13 * * ?")
public void generateSettleLogs() { public void generateSettleLogs() {
platformClearService.generateSettleLogs(); synchronizedScheduler.executeProcess("manage_task:genSettleLog", 120_000, () -> platformClearService.generateSettleLogs());
} }
@Scheduled(cron = "0 0 10 * * ?") @Scheduled(cron = "0 0 10 * * ?")
public void generateSettleLogs2() { public void generateSettleLogs2() {
platformClearService.generateSettleLogs(); synchronizedScheduler.executeProcess("manage_task:genSettleLog", 120_000, () -> platformClearService.generateSettleLogs());
} }
} }

@ -1,6 +1,7 @@
package au.com.royalpay.payment.manage.task; package au.com.royalpay.payment.manage.task;
import au.com.royalpay.payment.manage.merchantid.core.MerchantIdManageService; import au.com.royalpay.payment.manage.merchantid.core.MerchantIdManageService;
import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -12,8 +13,11 @@ import javax.annotation.Resource;
public class SubMerchantIdTaskManager { public class SubMerchantIdTaskManager {
@Resource @Resource
private MerchantIdManageService merchantIdManageService; private MerchantIdManageService merchantIdManageService;
@Resource
private SynchronizedScheduler synchronizedScheduler;
@Scheduled(cron = "0 0 4 * * ?") @Scheduled(cron = "0 0 4 * * ?")
public void analysisDashboard(){ public void analysisDashboard() {
merchantIdManageService.generateClientsSunMerchantId(); synchronizedScheduler.executeProcess("manage_task:checkSubMchId", 120_000, () -> merchantIdManageService.generateClientsSunMerchantId());
} }
} }

@ -2,6 +2,7 @@ package au.com.royalpay.payment.manage.task;
import au.com.royalpay.payment.manage.analysis.core.WeekReporter; import au.com.royalpay.payment.manage.analysis.core.WeekReporter;
import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler;
import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@ -21,11 +22,15 @@ public class WeekReportGenerationTask {
@Resource @Resource
private WeekReporter weekReporter; private WeekReporter weekReporter;
@Resource
private SynchronizedScheduler synchronizedScheduler;
@Scheduled(cron = "0 0 2 * * 1") @Scheduled(cron = "0 0 2 * * 1")
public void autoGenerateReport() { public void autoGenerateReport() {
Date lastweek = new Date(); synchronizedScheduler.executeProcess("manage_task:genWeekReport", 120_000, () -> {
lastweek = DateUtils.addDays(lastweek, -7); Date lastweek = new Date();
weekReporter.generateReport(DateFormatUtils.format(lastweek, "yyyy-MM-dd"), true); lastweek = DateUtils.addDays(lastweek, -7);
weekReporter.generateReport(DateFormatUtils.format(lastweek, "yyyy-MM-dd"), true);
});
} }
} }

Loading…
Cancel
Save