Commit b2f302b1 by huluobin

# update

parent 318de9d8
package com.bailuntec.job;
import com.bailuntec.application.IDcBaseFinanceEbayService;
import com.bailuntec.common.JsonUtilByFsJson;
import com.bailuntec.common.ListUtil;
import com.bailuntec.domain.DcBaseCompanyAccount;
import com.bailuntec.domain.DcBaseFinanceEbay;
import com.bailuntec.domain.DcJobConfig;
import com.bailuntec.infrastructure.mapper.DcBaseCompanyAccountMapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ebay.sdk.ApiContext;
import com.ebay.sdk.ApiCredential;
import com.ebay.sdk.TimeFilter;
......@@ -48,20 +51,23 @@ public class EbayItemReader implements ItemReader<EbayItem> {
private DcJobConfig dcJobConfig;
private final DcBaseCompanyAccountMapper dcBaseCompanyAccountMapper;
private final IDcBaseFinanceEbayService dcBaseFinanceEbayService;
@SneakyThrows
public EbayItemReader(DcBaseCompanyAccountMapper dcBaseCompanyAccountMapper,
DcJobConfig dcJobConfig) {
DcJobConfig dcJobConfig, IDcBaseFinanceEbayService dcBaseFinanceEbayService) {
this.dcBaseCompanyAccountMapper = dcBaseCompanyAccountMapper;
this.dcJobConfig = dcJobConfig;
this.dcBaseFinanceEbayService = dcBaseFinanceEbayService;
this.init();
}
private void init() {
log.info("初始化reader 开始..");
dcBaseCompanyAccountList = dcBaseCompanyAccountMapper.queryPageEbay();
this.pageNum = dcJobConfig.getPageNum();
this.nextAccount();
log.info("初始化reader 结束");
}
......@@ -104,6 +110,11 @@ public class EbayItemReader implements ItemReader<EbayItem> {
log.info("切换账号 切换后当前账号:{},剩余待跑账号数量:{}", dcBaseCompanyAccount.getAccountName(), dcBaseCompanyAccountList.size());
this.refreshAccountCall();
this.refreshPage();
//切换账号后 抓取广告费用前 前先清除已经抓取的数据
dcBaseFinanceEbayService.remove(new LambdaQueryWrapper<DcBaseFinanceEbay>()
.between(DcBaseFinanceEbay::getBjDate, dcJobConfig.getStartTime(), dcJobConfig.getEndTime())
.eq(DcBaseFinanceEbay::getAccountId, dcBaseCompanyAccount.getAccountId()));
}
if (ListUtil.isEmpty(accountEntryTypeList) && ListUtil.isNotEmpty(dcBaseCompanyAccountList)) {
this.nextAccount();
......
......@@ -32,15 +32,8 @@ public class EbayJobListener extends JobExecutionListenerSupport {
@Override
public void afterJob(JobExecution jobExecution) {
DcJobConfig dcJobConfig = jobConfiguration.getDcJobConfig();
dcJobConfigMapper.updateById(dcJobConfig.refresh());
}
@Override
public void beforeJob(JobExecution jobExecution) {
DcJobConfig dcJobConfig = dcJobConfigMapper.selectByName("base-sync-finance-ebay-ad");
jobConfiguration.setDcJobConfig(dcJobConfig);
DcJobConfig dcJobConfig = jobConfiguration.getDcJobConfig();
if (jobExecution.getStatus() == BatchStatus.COMPLETED) {
log.info("!!! JOB FINISHED! Time to verify the results");
......@@ -50,5 +43,13 @@ public class EbayJobListener extends JobExecutionListenerSupport {
//todo 任务失败提醒推送
log.error("!!! JOB FAILED");
}
dcJobConfigMapper.updateById(dcJobConfig.refresh());
}
@Override
public void beforeJob(JobExecution jobExecution) {
}
}
......@@ -49,13 +49,13 @@ public class JobConfiguration {
this.dcBaseCompanyAccountMapper = dcBaseCompanyAccountMapper;
this.dcBaseFinanceEbayService = dcBaseFinanceEbayService;
this.oaApi = oaApi;
dcJobConfig = dcJobConfigMapper.selectByName("base-sync-finance-ebay-ad");
}
@Bean
EbayItemReader reader() {
return new EbayItemReader(dcBaseCompanyAccountMapper, dcJobConfig);
return new EbayItemReader(dcBaseCompanyAccountMapper, dcJobConfig,
dcBaseFinanceEbayService);
}
@Bean
......
......@@ -10,6 +10,8 @@ spring:
driver-class-name: com.mysql.jdbc.Driver
main:
allow-bean-definition-overriding: true
batch:
initialize-schema: always
#mybatis plus 配置
mybatis-plus:
......
......@@ -12,7 +12,7 @@
<artifactId>datacenter-finance</artifactId>
<packaging>pom</packaging>
<modules>
<module>finance-balance-sheet</module>
<!-- <module>finance-balance-sheet</module>-->
</modules>
</project>
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