Commit d92866f9 by liyanlin

fix

parent 3f48464f
...@@ -22,7 +22,7 @@ public class EbayFeeJob { ...@@ -22,7 +22,7 @@ public class EbayFeeJob {
@Resource @Resource
private SyncEbayFeeService service; private SyncEbayFeeService service;
@Scheduled(cron = "* 16 * * * ?") @Scheduled(cron = "0 0 16 * * ?")
public void SyncEbayTransaction(){ public void SyncEbayTransaction(){
service.SyncEbayTransaction(); service.SyncEbayTransaction();
} }
......
...@@ -39,23 +39,35 @@ public class SyncEbayFeeServiceImpl implements SyncEbayFeeService { ...@@ -39,23 +39,35 @@ public class SyncEbayFeeServiceImpl implements SyncEbayFeeService {
@Resource @Resource
private DcBaseEbayTransactionMapper dcBaseEbayTransactionMapper; private DcBaseEbayTransactionMapper dcBaseEbayTransactionMapper;
//当前需要跑的账号
private final static String[] RUN_ACCOUNT = new String[]{"ottlueilwitz3","jalenhe","uha4mmada","rownmelody5","nthonyp6ecket","rayallen9","barbara_spence95","nbrysonhall","credit4free"};
@Resource @Resource
private EbayTransactionApi ebayTransactionApi; private EbayTransactionApi ebayTransactionApi;
@Override @Override
public void SyncEbayTransaction() { public void SyncEbayTransaction() {
//获取未跑或失败的任务 //获取未跑或失败的任务
List<EbayAccountReportTask> ebayAccountReportTaskList = ebayAccountReportTaskService.list(new LambdaQueryWrapper<EbayAccountReportTask>() List<EbayAccountReportTask> ebayAccountReportTaskList = ebayAccountReportTaskService.list(
.ne(EbayAccountReportTask::getStatus, 1)); new LambdaQueryWrapper<EbayAccountReportTask>()
.ne(EbayAccountReportTask::getStatus, 1)
);
/*List<EbayAccountReportTask> ebayAccountReportTaskList = ebayAccountReportTaskService.list(new LambdaQueryWrapper<EbayAccountReportTask>() /*List<EbayAccountReportTask> ebayAccountReportTaskList = ebayAccountReportTaskService.list(new LambdaQueryWrapper<EbayAccountReportTask>()
.ge(EbayAccountReportTask::getStartTime, LocalDateTime.of(2021, 4, 16, 0, 0, 0)) .ge(EbayAccountReportTask::getStartTime, LocalDateTime.of(2021, 5, 1, 0, 0, 0))
.lt(EbayAccountReportTask::getStartTime, LocalDateTime.of(2021, 5, 1, 0, 0, 0)));*/ .lt(EbayAccountReportTask::getStartTime, LocalDateTime.of(2021, 5, 26, 0, 0, 0)));*/
//获取账号信息 //获取账号信息
List<Integer> accountIdList = ebayAccountReportTaskList.stream().map(x -> x.getAccountId()).distinct().collect(Collectors.toList()); List<Integer> accountIdList = ebayAccountReportTaskList.stream().map(x -> x.getAccountId()).distinct().collect(Collectors.toList());
List<DcBaseCompanyAccount> accountList = dcBaseCompanyAccountService.list(new LambdaQueryWrapper<DcBaseCompanyAccount>().in(DcBaseCompanyAccount::getAccountId, accountIdList)); List<DcBaseCompanyAccount> accountList = dcBaseCompanyAccountService.list(
new LambdaQueryWrapper<DcBaseCompanyAccount>()
.in(DcBaseCompanyAccount::getAccountId, accountIdList)
.in(DcBaseCompanyAccount::getAccountName,RUN_ACCOUNT)
);
//循环跑任务 //循环跑任务
List<EbayAccountReportTask> needUpdateEbayAccountReportTaskList = new ArrayList<>();
ebayAccountReportTaskList.forEach(x -> { ebayAccountReportTaskList.forEach(x -> {
if(accountList.stream().noneMatch(a -> a.getAccountId().equals(x.getAccountId()))){
return;
}
//获取token //获取token
Integer pageNum = 1; Integer pageNum = 1;
StringBuffer accessToken = new StringBuffer("Bearer "); StringBuffer accessToken = new StringBuffer("Bearer ");
...@@ -63,6 +75,9 @@ public class SyncEbayFeeServiceImpl implements SyncEbayFeeService { ...@@ -63,6 +75,9 @@ public class SyncEbayFeeServiceImpl implements SyncEbayFeeService {
try { try {
//禁用账号直接跳过 //禁用账号直接跳过
if(!currentAccount.getStatus()){ if(!currentAccount.getStatus()){
x.setStatus(2);
x.setErrorMsg("当前账号被禁用");
needUpdateEbayAccountReportTaskList.add(x);
return; return;
} }
accessToken.append(JSON.parseObject(currentAccount.getAuthJson()).get("access_token")); accessToken.append(JSON.parseObject(currentAccount.getAuthJson()).get("access_token"));
...@@ -71,6 +86,7 @@ public class SyncEbayFeeServiceImpl implements SyncEbayFeeService { ...@@ -71,6 +86,7 @@ public class SyncEbayFeeServiceImpl implements SyncEbayFeeService {
log.error(msg); log.error(msg);
x.setStatus(2); x.setStatus(2);
x.setErrorMsg(msg); x.setErrorMsg(msg);
needUpdateEbayAccountReportTaskList.add(x);
return; return;
} }
DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
...@@ -88,8 +104,9 @@ public class SyncEbayFeeServiceImpl implements SyncEbayFeeService { ...@@ -88,8 +104,9 @@ public class SyncEbayFeeServiceImpl implements SyncEbayFeeService {
x.setStatus(2); x.setStatus(2);
x.setErrorMsg(msg); x.setErrorMsg(msg);
} }
needUpdateEbayAccountReportTaskList.add(x);
}); });
//ebayAccountReportTaskService.updateBatchById(ebayAccountReportTaskList); ebayAccountReportTaskService.updateBatchById(needUpdateEbayAccountReportTaskList);
} }
private boolean doGet(String accessToken, String filter, Integer limit, Integer pageNum, List<Transaction> transactions) { private boolean doGet(String accessToken, String filter, Integer limit, Integer pageNum, List<Transaction> transactions) {
......
...@@ -26,9 +26,7 @@ import org.springframework.stereotype.Component; ...@@ -26,9 +26,7 @@ import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.time.ZoneId; import java.time.ZoneId;
import java.util.Calendar; import java.util.*;
import java.util.Date;
import java.util.List;
/** /**
* <p> * <p>
...@@ -53,6 +51,8 @@ public class CustomerReader implements ItemReader<EbayItem> { ...@@ -53,6 +51,8 @@ public class CustomerReader implements ItemReader<EbayItem> {
private GetAccountCall getAccountCall; private GetAccountCall getAccountCall;
//当前页码 //当前页码
private Integer pageNum; private Integer pageNum;
//无需跑任务的账号
private final static String[] CANNOT_RUN_ACCOUNT = new String[]{"ottlueilwitz3","jalenhe","uha4mmada","rownmelody5","nthonyp6ecket","rayallen9","barbara_spence95","nbrysonhall","credit4free"};
@Resource @Resource
...@@ -119,7 +119,12 @@ public class CustomerReader implements ItemReader<EbayItem> { ...@@ -119,7 +119,12 @@ public class CustomerReader implements ItemReader<EbayItem> {
dcBaseCompanyAccount = dcBaseCompanyAccountMapper.selectOne(new LambdaQueryWrapper<DcBaseCompanyAccount>() dcBaseCompanyAccount = dcBaseCompanyAccountMapper.selectOne(new LambdaQueryWrapper<DcBaseCompanyAccount>()
.eq(DcBaseCompanyAccount::getPlatformId, DcBaseCompanyAccount.EBAY_PLATFORM_ID) .eq(DcBaseCompanyAccount::getPlatformId, DcBaseCompanyAccount.EBAY_PLATFORM_ID)
.eq(DcBaseCompanyAccount::getAccountId, ebayAccountReportTask.getAccountId())); .eq(DcBaseCompanyAccount::getAccountId, ebayAccountReportTask.getAccountId()));
if(Arrays.stream(this.CANNOT_RUN_ACCOUNT).anyMatch(x -> x.equals(dcBaseCompanyAccount.getAccountName().toLowerCase()))){
ebayAccountReportTask.setStatus(2);
ebayAccountReportTask.setErrorMsg("旧接口不跑该任务");
this.nextAccount();
return;
}
log.info("切换任务 切换后当前账号:{},剩余待跑任务数量:{}", dcBaseCompanyAccount.getAccountName(), ebayAccountReportTaskList.size()); log.info("切换任务 切换后当前账号:{},剩余待跑任务数量:{}", dcBaseCompanyAccount.getAccountName(), ebayAccountReportTaskList.size());
this.refreshAccountCall(); this.refreshAccountCall();
this.refreshPage(); this.refreshPage();
......
...@@ -29,6 +29,6 @@ public class CustomerWriter implements ItemWriter<DcBaseFinanceEbay> { ...@@ -29,6 +29,6 @@ public class CustomerWriter implements ItemWriter<DcBaseFinanceEbay> {
@Override @Override
public void write(@NonNull List<? extends DcBaseFinanceEbay> items) { public void write(@NonNull List<? extends DcBaseFinanceEbay> items) {
log.info("批量写入DcBaseFinanceEbay"); log.info("批量写入DcBaseFinanceEbay");
dcBaseFinanceEbayService.saveBatch(items.stream().map(var -> (DcBaseFinanceEbay) var).collect(Collectors.toList())); dcBaseFinanceEbayService.InsertAllIgnoreExist(items.stream().map(var -> (DcBaseFinanceEbay) var).collect(Collectors.toList()));
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment