parent
996bcefc98
commit
aafa9df04d
@ -0,0 +1,37 @@
|
|||||||
|
package com.ruoyi.quartz.domain;
|
||||||
|
|
||||||
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author yuxiangyong
|
||||||
|
* @create 2023-07-17 20:31
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class CJTRetryRequest implements Serializable {
|
||||||
|
|
||||||
|
private LocalDateTime executeTime;
|
||||||
|
private Integer count;
|
||||||
|
|
||||||
|
public CJTRetryRequest(LocalDateTime executeTime, Integer count) {
|
||||||
|
this.executeTime = executeTime;
|
||||||
|
this.count = count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addCount(){
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getQueryFrom(Long reduceMinutes){
|
||||||
|
return DateUtils.ldt2str(executeTime.minusMinutes(reduceMinutes),DateUtils.YYYY_MM_DD_HH_MM_SS);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getQueryTo(){
|
||||||
|
return DateUtils.ldt2str(executeTime,DateUtils.YYYY_MM_DD_HH_MM_SS);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,110 @@
|
|||||||
|
package com.ruoyi.quartz.task.CJT;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.redis.RedisCache;
|
||||||
|
import com.ruoyi.common.enums.AppType;
|
||||||
|
import com.ruoyi.quartz.domain.CJTRetryRequest;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author yuxiangyong
|
||||||
|
* @create 2023-08-02 20:14
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component("retryErrorSyncJob")
|
||||||
|
public class RetryErrorSyncJob {
|
||||||
|
@Autowired
|
||||||
|
private RedisCache redisCache;
|
||||||
|
@Autowired
|
||||||
|
private ManufactureOrderSyncJob manufactureOrderSyncJob;
|
||||||
|
@Autowired
|
||||||
|
private PurchaseArrivalOpenSyncJob purchaseArrivalOpenSyncJob;
|
||||||
|
@Autowired
|
||||||
|
private PurchaseOrderSyncJob purchaseOrderSyncJob;
|
||||||
|
@Autowired
|
||||||
|
private SaleDeliverySyncJob saleDeliverySyncJob;
|
||||||
|
@Autowired
|
||||||
|
private SaleDispatchSyncJob saleDispatchSyncJob;
|
||||||
|
@Autowired
|
||||||
|
private SaleOrderSyncJob saleOrderSyncJob;
|
||||||
|
|
||||||
|
public void execute(String appTypeCode) {
|
||||||
|
AppType appType = AppType.getByCode(appTypeCode);
|
||||||
|
if (appType != null) {
|
||||||
|
executeDetail(appType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void execute() {
|
||||||
|
List<AppType> retryJobList = retryJobList();
|
||||||
|
for (AppType retryJobType : retryJobList) {
|
||||||
|
executeDetail(retryJobType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void executeDetail(AppType retryJobType) {
|
||||||
|
CJTRetryRequest request = null;
|
||||||
|
String retryKey = null;
|
||||||
|
switch (retryJobType) {
|
||||||
|
case SYNC_CJT_MANUFACTURE_ORDER_DATA_TO_MULTI_TABLE:
|
||||||
|
retryKey = manufactureOrderSyncJob.getRetryKey();
|
||||||
|
do {
|
||||||
|
request = (CJTRetryRequest) redisCache.leftPop(retryKey);
|
||||||
|
manufactureOrderSyncJob.execute(request);
|
||||||
|
} while (request != null);
|
||||||
|
break;
|
||||||
|
case SYNC_CJT_PURCHASE_ARRIVAL_ORDER_DATA_TO_MULTI_TABLE:
|
||||||
|
retryKey = purchaseArrivalOpenSyncJob.getRetryKey();
|
||||||
|
do {
|
||||||
|
request = (CJTRetryRequest) redisCache.leftPop(retryKey);
|
||||||
|
purchaseArrivalOpenSyncJob.execute(request);
|
||||||
|
} while (request != null);
|
||||||
|
break;
|
||||||
|
case SYNC_CJT_PURCHASE_ORDER_DATA_TO_MULTI_TABLE:
|
||||||
|
retryKey = purchaseOrderSyncJob.getRetryKey();
|
||||||
|
do {
|
||||||
|
request = (CJTRetryRequest) redisCache.leftPop(retryKey);
|
||||||
|
purchaseOrderSyncJob.execute(request);
|
||||||
|
} while (request != null);
|
||||||
|
break;
|
||||||
|
case SYNC_CJT_SALE_DELIVERY_DATA_TO_MULTI_TABLE:
|
||||||
|
retryKey = saleDeliverySyncJob.getRetryKey();
|
||||||
|
do {
|
||||||
|
request = (CJTRetryRequest) redisCache.leftPop(retryKey);
|
||||||
|
saleDeliverySyncJob.execute(request);
|
||||||
|
} while (request != null);
|
||||||
|
break;
|
||||||
|
case SYNC_CJT_SALE_ORDER_DATA_TO_MULTI_TABLE:
|
||||||
|
retryKey = saleOrderSyncJob.getRetryKey();
|
||||||
|
do {
|
||||||
|
request = (CJTRetryRequest) redisCache.leftPop(retryKey);
|
||||||
|
saleOrderSyncJob.execute(request);
|
||||||
|
} while (request != null);
|
||||||
|
break;
|
||||||
|
case SYNC_CJT_SALE_DISPATCH_DATA_TO_MULTI_TABLE:
|
||||||
|
retryKey = saleDispatchSyncJob.getRetryKey();
|
||||||
|
do {
|
||||||
|
request = (CJTRetryRequest) redisCache.leftPop(retryKey);
|
||||||
|
saleDispatchSyncJob.execute(request);
|
||||||
|
} while (request != null);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<AppType> retryJobList() {
|
||||||
|
return Arrays.asList(
|
||||||
|
AppType.SYNC_CJT_MANUFACTURE_ORDER_DATA_TO_MULTI_TABLE,
|
||||||
|
AppType.SYNC_CJT_PURCHASE_ARRIVAL_ORDER_DATA_TO_MULTI_TABLE,
|
||||||
|
AppType.SYNC_CJT_PURCHASE_ORDER_DATA_TO_MULTI_TABLE,
|
||||||
|
AppType.SYNC_CJT_SALE_DELIVERY_DATA_TO_MULTI_TABLE,
|
||||||
|
AppType.SYNC_CJT_SALE_ORDER_DATA_TO_MULTI_TABLE,
|
||||||
|
AppType.SYNC_CJT_SALE_DISPATCH_DATA_TO_MULTI_TABLE
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue