Commit b2f302b1 by huluobin

# update

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