task edit for docker

master
yixian 6 years ago
parent b55f8e3f9d
commit 3034bf99fd

@ -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.payment.OrderMapper;
import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler;
import com.alibaba.fastjson.JSONObject;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.List;
import javax.annotation.Resource;
import java.util.List;
/**
* Created by wangning on 2018/1/2.
@ -25,25 +23,30 @@ public class BillOrderCheckTask {
@Resource
private OrderMapper orderMapper;
@Resource
private SynchronizedScheduler synchronizedScheduler;
@Scheduled(cron = "0 0/3 * * * ?")
public void checkGreenChannel() {
List<String> orderIds = billOrderMapper.findOrderIdByStatus("0");
if(CollectionUtils.isEmpty(orderIds)){
return;
}
for (String p : orderIds) {
if (p==null){
continue;
synchronizedScheduler.executeProcess("manage_task:checkGreenChannel", 120_000, () -> {
List<String> orderIds = billOrderMapper.findOrderIdByStatus("0");
if (CollectionUtils.isEmpty(orderIds)) {
return;
}
JSONObject order = orderMapper.find(p);
int status = order.getIntValue("status");
if(status==3||status==1){
billOrderMapper.updateStatusByOrderId(p,"2");
for (String p : orderIds) {
if (p == null) {
continue;
}
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.tools.scheduler.SynchronizedScheduler;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@ -16,13 +17,16 @@ import javax.annotation.Resource;
public class CheckPartnerAuthStatusAndSendMessageTask {
@Resource
private SimpleClientService simpleClientService;
@Resource
private SynchronizedScheduler synchronizedScheduler;
// @Scheduled(cron = "0 0 9 * * ?")
// public void checkAuthAndSendMessage(){
// simpleClientService.checkAuthAndSendMessage();
// }
@Scheduled(cron = "0 0 9 * * ?")
public void checkGreenChannel(){
simpleClientService.checkGreenChannelClients();
public void checkGreenChannel() {
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.mappers.system.ClientMapper;
import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler;
import com.alibaba.fastjson.JSONObject;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@ -27,32 +28,36 @@ public class CustomerImpressionTask {
private ClientMapper clientMapper;
@Resource
private CustomerImpressionService customerImpressionService;
@Resource
private SynchronizedScheduler synchronizedScheduler;
private ThreadPoolExecutor generatePool = new ThreadPoolExecutor(10, 30, 5, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
@Scheduled(cron = "0 30 3 * * ?")
public void generateTags() {
List<JSONObject> clients = clientMapper.listValidClient();
List<List<JSONObject>> splitList = new ArrayList<>();
for (int i = 0; i < clients.size(); i+=200) {
if(i+200>clients.size()){
splitList.add(clients.subList(i,clients.size()));
}else {
splitList.add(clients.subList(i,i+200));
}
synchronizedScheduler.executeProcess("manage_task:CustomerImpression", 120_000, () -> {
List<JSONObject> clients = clientMapper.listValidClient();
List<List<JSONObject>> splitList = new ArrayList<>();
for (int i = 0; i < clients.size(); i += 200) {
if (i + 200 > clients.size()) {
splitList.add(clients.subList(i, clients.size()));
} else {
splitList.add(clients.subList(i, i + 200));
}
}
for (List<JSONObject> splitClients : splitList) {
Runnable task = () -> splitClients.forEach((p)->{
System.out.println("当前执行到"+p.getIntValue("client_id"));
customerImpressionService.generateTag(p.getIntValue("client_id"));
});
generatePool.execute(task);
}
}
for (List<JSONObject> splitClients : splitList) {
Runnable task = () -> splitClients.forEach((p) -> {
System.out.println("当前执行到" + p.getIntValue("client_id"));
customerImpressionService.generateTag(p.getIntValue("client_id"));
});
generatePool.execute(task);
}
});
}
@Scheduled(cron = "0/1 * * * * ?")
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.tools.scheduler.SynchronizedScheduler;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@ -21,10 +22,14 @@ public class DailyReportGenerationTask {
@Resource
private DailyReport dailyReport;
@Resource
private SynchronizedScheduler synchronizedScheduler;
@Scheduled(cron = "0 0 10 * * ?")
public void autoGenerateReport() {
Date yesterday = DateUtils.addDays(new Date(), -1);
dailyReport.generateReport(DateFormatUtils.format(yesterday, "yyyy-MM-dd"), true);
synchronizedScheduler.executeProcess("manage_task:autoGenerateDailyReport", 120_000, () -> {
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.tools.scheduler.SynchronizedScheduler;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled;
@ -19,8 +20,12 @@ import javax.annotation.Resource;
public class DashboardTaskManager {
@Resource
private DashboardService dashboardService;
@Resource
private SynchronizedScheduler synchronizedScheduler;
@Scheduled(cron = "0 0 2 * * ?")
public void analysisDashboard(){
dashboardService.generateCustomersAndOrdersStatistics(DateUtils.addDays(new Date(), -1));
public void analysisDashboard() {
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;
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.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@ -15,9 +16,12 @@ import javax.annotation.Resource;
public class DirectedBillCodeStatusDailyCheck {
@Resource
private PartnerBillService partnerBillService;
@Resource
private SynchronizedScheduler synchronizedScheduler;
@Scheduled(cron = "0 30 5 * * ?")
public void statusDailyCheck(){
partnerBillService.dailyCheckDirectedBillCode();
public void statusDailyCheck() {
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.ofei.core.OfeiServer;
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;
@ -22,14 +23,19 @@ public class OfeiOrderCheckTask {
private OfeiServer ofeiServer;
@Resource
private TopUpOrderMapper topUpOrderMapper;
@Resource
private SynchronizedScheduler synchronizedScheduler;
@Scheduled(cron = "0 0/20 * * * ?")
public void checkGreenChannel(){
List<String> orderIds = topUpOrderMapper.findOrderIdByStatus("10");
if(CollectionUtils.isEmpty(orderIds)){
return;
}
for (String orderId : orderIds) {
ofeiServer.checkOrder(orderId);
}
public void checkGreenChannel() {
synchronizedScheduler.executeProcess("manage_task:ofeiOrderCheck", 120_000, () -> {
List<String> orderIds = topUpOrderMapper.findOrderIdByStatus("10");
if (CollectionUtils.isEmpty(orderIds)) {
return;
}
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.tools.env.PlatformEnvironment;
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;
@ -13,15 +14,19 @@ import javax.annotation.Resource;
* Created by yixian on 2017-02-22.
*/
@Component
@ConditionalOnProperty(value = "app.run-tasks",havingValue = "true")
@ConditionalOnProperty(value = "app.run-tasks", havingValue = "true")
public class PartnerInitEmailChecker {
@Resource
private ClientManager clientManager;
@Resource
private SynchronizedScheduler synchronizedScheduler;
@Scheduled(cron = "0 0/5 * * * *")
public void checkEmailStatus(){
public void checkEmailStatus() {
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.tools.scheduler.SynchronizedScheduler;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled;
@ -19,8 +20,12 @@ import javax.annotation.Resource;
public class PartnerTransactionsDailyMsgTaskManager {
@Resource
private CustomersAnalysisService customersAnalysisService;
@Resource
private SynchronizedScheduler synchronizedScheduler;
@Scheduled(cron = "0 0 8 * * ?")
public void analysisDashboard(){
customersAnalysisService.sendPartnerTransactionDaily(DateUtils.addDays(new Date(), -1));
public void analysisDashboard() {
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.beans.TemplateMessage;
import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.time.DateFormatUtils;
@ -44,56 +45,61 @@ public class PostponeClientTask {
private ClientAccountMapper clientAccountMapper;
@Resource
private ManagerMapper managerMapper;
@Resource
private SynchronizedScheduler synchronizedScheduler;
@Scheduled(cron = "0 30 8 * * ?")
@Scheduled(cron = "0 30 8 * * ?")
public void checkGreenChannel() {
Date now = new Date();
Date tomorrow = DateUtils.addDays(now, 1);
Date yearTomorrow = DateUtils.addYears(tomorrow, 1);
String expireDate = DateFormatUtils.format(yearTomorrow, "yyyy-MM-dd");
List<JSONObject> expiryClient = clientRateMapper.getAllExpiry(now);
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");
synchronizedScheduler.executeProcess("manage_task:postPoneClient", 120_000, () -> {
Date now = new Date();
Date tomorrow = DateUtils.addDays(now, 1);
Date yearTomorrow = DateUtils.addYears(tomorrow, 1);
String expireDate = DateFormatUtils.format(yearTomorrow, "yyyy-MM-dd");
List<JSONObject> expiryClient = clientRateMapper.getAllExpiry(now);
if (CollectionUtils.isEmpty(expiryClient)) {
return;
}
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);
Map<Integer, JSONObject> expiryClients = new HashMap<>();
expiryClient.forEach(p -> {
expiryClients.put(p.getInteger("client_id"), p);
});
adminAccounts.forEach(o -> {
sendClientPostponeNotify(o, expireDate);
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;
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"));
try {
@ -101,8 +107,8 @@ public class PostponeClientTask {
if (api != null) {
String templateId = api.getTemplateId("client-postpone");
if (templateId != null) {
TemplateMessage notice = initClientMessage(client,newExpireDate,account.getString("wechat_openid"),templateId);
api.sendTemplateMessage(notice);
TemplateMessage notice = initClientMessage(client, newExpireDate, account.getString("wechat_openid"), templateId);
api.sendTemplateMessage(notice);
}
}
} catch (Exception e) {
@ -129,7 +135,7 @@ public class PostponeClientTask {
private TemplateMessage initClientMessage(JSONObject client, String newExpiryDate, String wechatOpenid, String templateId) {
TemplateMessage notice = new TemplateMessage(wechatOpenid, templateId, null);
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("remark", "如有疑问请联系RoyalPay", "#000000");
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.RedpackService;
import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@ -23,20 +24,22 @@ public class RedPackTaskManager {
private RedpackService redpackService;
@Resource
private ActRedPackService actRedPackService;
@Resource
private SynchronizedScheduler synchronizedScheduler;
@Scheduled(cron = "0 0/10 * * * ?")
public void updateRedPackStatus() {
redpackService.updateRedPacketsStatus("3");
synchronizedScheduler.executeProcess("manage_task:updateRedpackStatus", 120_000, () -> redpackService.updateRedPacketsStatus("3"));
}
@Scheduled(cron = "0 0/10 * * * ?")
public void updateAlipayRedPackStatus() {
redpackService.updateAlipayRedPacketsStatus("3");
synchronizedScheduler.executeProcess("manage_task:updateAlipayRedpackStatus", 120_000, () -> redpackService.updateAlipayRedPacketsStatus("3"));
}
@Scheduled(cron = "0 0/3 * * * *")
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.PlatformClearService;
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;
@ -19,26 +20,28 @@ public class SettleEstimateTaskManger {
@Resource
private PlatformClearService platformClearService;
@Resource
private SynchronizedScheduler synchronizedScheduler;
// 3:15 am at every work days
@Scheduled(cron = "0 20 3 * * ?")
public void generateSettleAmount() {
estimateAnalysisService.generateSettleAmount();
synchronizedScheduler.executeProcess("manage_task:genSettleAmount", 120_000, () -> estimateAnalysisService.generateSettleAmount());
}
// 2:15 every day
@Scheduled(cron = "0 0 3 * * ?")
public void generateTransactionAmount() {
estimateAnalysisService.generateTransactionData();
synchronizedScheduler.executeProcess("manage_task:genTransAmount", 120_000, () -> estimateAnalysisService.generateTransactionData());
}
@Scheduled(cron = "0 0 13 * * ?")
public void generateSettleLogs() {
platformClearService.generateSettleLogs();
synchronizedScheduler.executeProcess("manage_task:genSettleLog", 120_000, () -> platformClearService.generateSettleLogs());
}
@Scheduled(cron = "0 0 10 * * ?")
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;
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.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@ -12,8 +13,11 @@ import javax.annotation.Resource;
public class SubMerchantIdTaskManager {
@Resource
private MerchantIdManageService merchantIdManageService;
@Resource
private SynchronizedScheduler synchronizedScheduler;
@Scheduled(cron = "0 0 4 * * ?")
public void analysisDashboard(){
merchantIdManageService.generateClientsSunMerchantId();
public void analysisDashboard() {
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.tools.scheduler.SynchronizedScheduler;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@ -21,11 +22,15 @@ public class WeekReportGenerationTask {
@Resource
private WeekReporter weekReporter;
@Resource
private SynchronizedScheduler synchronizedScheduler;
@Scheduled(cron = "0 0 2 * * 1")
public void autoGenerateReport() {
Date lastweek = new Date();
lastweek = DateUtils.addDays(lastweek, -7);
weekReporter.generateReport(DateFormatUtils.format(lastweek, "yyyy-MM-dd"), true);
synchronizedScheduler.executeProcess("manage_task:genWeekReport", 120_000, () -> {
Date lastweek = new Date();
lastweek = DateUtils.addDays(lastweek, -7);
weekReporter.generateReport(DateFormatUtils.format(lastweek, "yyyy-MM-dd"), true);
});
}
}

Loading…
Cancel
Save