Commit 2bbf6387 by huluobin

update

parent 7be08f88
...@@ -65,5 +65,4 @@ class AmazonAdDownloadReportJobTest { ...@@ -65,5 +65,4 @@ class AmazonAdDownloadReportJobTest {
} }
} }
...@@ -20,8 +20,6 @@ public class AmazonAdGenerateReportIdJobTest { ...@@ -20,8 +20,6 @@ public class AmazonAdGenerateReportIdJobTest {
public void executeJob() { public void executeJob() {
AmazonAdGenerateReportIdJob amazonAdGenerateReportIdJob = new AmazonAdGenerateReportIdJob(); AmazonAdGenerateReportIdJob amazonAdGenerateReportIdJob = new AmazonAdGenerateReportIdJob();
while (true) { amazonAdGenerateReportIdJob.execute(new ShardingContext(new ShardingContexts("x", "base-amazon-ad-product-generate", 1, null, new HashMap<>()), 0));
amazonAdGenerateReportIdJob.execute(new ShardingContext(new ShardingContexts("x", "base-amazon-ad-product-generate", 1, null, new HashMap<>()), 0));
}
} }
} }
...@@ -10,7 +10,6 @@ import com.bailuntec.domain.example.DcBaseFinanceEbayExample; ...@@ -10,7 +10,6 @@ import com.bailuntec.domain.example.DcBaseFinanceEbayExample;
import com.bailuntec.mapper.DcBaseCompanyAccountMapper; import com.bailuntec.mapper.DcBaseCompanyAccountMapper;
import com.bailuntec.mapper.DcBaseFinanceEbayMapper; import com.bailuntec.mapper.DcBaseFinanceEbayMapper;
import com.bailuntec.mapper.JobAccountLogMapper; import com.bailuntec.mapper.JobAccountLogMapper;
import com.bailuntec.mapper.JobPointLogMapper;
import com.bailuntec.support.CallBailunSystem; import com.bailuntec.support.CallBailunSystem;
import com.bailuntec.support.PointJob; import com.bailuntec.support.PointJob;
import com.bailuntec.utils.SessionUtil; import com.bailuntec.utils.SessionUtil;
...@@ -43,7 +42,6 @@ public class EbayFinanceAdSyncJob extends PointJob { ...@@ -43,7 +42,6 @@ public class EbayFinanceAdSyncJob extends PointJob {
try { try {
JobAccountLogMapper jobAccountLogMapper = SessionUtil.getSession().getMapper(JobAccountLogMapper.class); JobAccountLogMapper jobAccountLogMapper = SessionUtil.getSession().getMapper(JobAccountLogMapper.class);
JobPointLogMapper jobPointLogMapper = SessionUtil.getSession().getMapper(JobPointLogMapper.class);
DcBaseFinanceEbayMapper dcBaseFinanceEbayMapper = SessionUtil.getSession().getMapper(DcBaseFinanceEbayMapper.class); DcBaseFinanceEbayMapper dcBaseFinanceEbayMapper = SessionUtil.getSession().getMapper(DcBaseFinanceEbayMapper.class);
//拿到账号集合 //拿到账号集合
...@@ -55,28 +53,25 @@ public class EbayFinanceAdSyncJob extends PointJob { ...@@ -55,28 +53,25 @@ public class EbayFinanceAdSyncJob extends PointJob {
if (startTime.toLocalDate().compareTo(LocalDate.now()) < 0) { if (startTime.toLocalDate().compareTo(LocalDate.now()) < 0) {
for (JobAccountLog jobAccountLog : listByPage) { listByPage.parallelStream().forEach(jobAccountLog -> {
//先删除再更新
dcBaseFinanceEbayMapper.deleteByExample(DcBaseFinanceEbayExample.newAndCreateCriteria()
.andBjDateBetween(startTime, endTime)
.andAccountIdEqualTo(jobAccountLog.getAccountId())
.example());
try {
//先删除再更新
dcBaseFinanceEbayMapper.deleteByExample(DcBaseFinanceEbayExample.newAndCreateCriteria()
.andBjDateBetween(startTime, endTime)
.andAccountIdEqualTo(jobAccountLog.getAccountId())
.example());
}catch (Exception ex){
}
jobAccountLog.setStartTime(startTime.plusHours(15)); jobAccountLog.setStartTime(startTime.plusHours(15));
jobAccountLog.setEndTime(endTime.plusHours(15)); jobAccountLog.setEndTime(endTime.plusHours(15));
callSaasApi(jobAccountLog, shardingContext); this.callSaaSApi(jobAccountLog, shardingContext);
log.info("帐号:{} 日期:{} ebay广告费用同步完成", jobAccountLog.getAccountId(), startTime); log.info("帐号:{} 日期:{} ebay广告费用同步完成", jobAccountLog.getAccountId(), startTime);
} });
jobPointLog.setStartTime(startTime.plusDays(1)); jobPointLog.setStartTime(startTime.plusDays(1));
jobPointLog.setEndTime(endTime.plusDays(1)); jobPointLog.setEndTime(endTime.plusDays(1));
jobPointLog.setGmtModified(LocalDateTime.now());
} }
} catch (Exception e) { } catch (Exception e) {
...@@ -87,7 +82,7 @@ public class EbayFinanceAdSyncJob extends PointJob { ...@@ -87,7 +82,7 @@ public class EbayFinanceAdSyncJob extends PointJob {
} }
public void callSaasApi(JobAccountLog jobAccountLog, ShardingContext shardingContext) { public void callSaaSApi(JobAccountLog jobAccountLog, ShardingContext shardingContext) {
try { try {
DcBaseCompanyAccount dcBaseCompanyAccount = getToken(jobAccountLog); DcBaseCompanyAccount dcBaseCompanyAccount = getToken(jobAccountLog);
......
import com.bailuntec.domain.entity.JobAccountLog;
import com.bailuntec.domain.entity.JobPointLog;
import com.bailuntec.job.EbayFinanceAdSyncJob;
import com.bailuntec.job.EbayFinanceSyncJob;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.executor.ShardingContexts;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@Slf4j
public class EbayFinanceSyncJobTest {
@Test
public void test3() {
EbayFinanceSyncJob skuSyncJob = new EbayFinanceSyncJob();
ShardingContext job = new ShardingContext(new ShardingContexts("1", "job", 1, "", new HashMap<>()), 0);
skuSyncJob.executeJob(job, new JobPointLog("", null, 100, 1, 1,
LocalDateTime.now().minusMonths(1),
LocalDateTime.now().minusDays(29)));
}
@Test
public void test1() {
ExecutorService threadPool = Executors.newFixedThreadPool(300);
//获取时间区间reportDate列表
List<LocalDateTime> localDateList = Stream.iterate(LocalDateTime.of(2020, 9, 30, 0, 0), localDate -> localDate.plusDays(1))
.limit(ChronoUnit.DAYS.between(LocalDateTime.of(2020, 9, 30, 0, 0),
LocalDateTime.of(2020, 11, 2, 0, 0)) + 1)
.collect(Collectors.toList());
localDateList.forEach(localDateTime -> {
threadPool.execute(() -> {
EbayFinanceAdSyncJob skuSyncJob = new EbayFinanceAdSyncJob();
JobAccountLog jobAccountLog = new JobAccountLog();
jobAccountLog.setAccountId(314);
jobAccountLog.setStartTime(localDateTime);
jobAccountLog.setEndTime(localDateTime.plusDays(1));
jobAccountLog.setIntervalTime(1);
jobAccountLog.setPageIndex(1);
jobAccountLog.setPageSize(100);
skuSyncJob.callSaasApi(jobAccountLog, null);
});
});
threadPool.shutdown();
try {//等待直到所有任务完成
threadPool.awaitTermination(Integer.MAX_VALUE, TimeUnit.MINUTES);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
...@@ -3,6 +3,7 @@ package com.bailuntec.job; ...@@ -3,6 +3,7 @@ package com.bailuntec.job;
import com.alibaba.excel.EasyExcel; import com.alibaba.excel.EasyExcel;
import com.bailuntec.domain.entity.DcBaseCompanyAccount; import com.bailuntec.domain.entity.DcBaseCompanyAccount;
import com.bailuntec.domain.entity.DcBaseFinanceEbay; import com.bailuntec.domain.entity.DcBaseFinanceEbay;
import com.bailuntec.domain.entity.JobPointLog;
import com.bailuntec.domain.example.DcBaseCompanyAccountExample; import com.bailuntec.domain.example.DcBaseCompanyAccountExample;
import com.bailuntec.domain.example.DcBaseFinanceEbayExample; import com.bailuntec.domain.example.DcBaseFinanceEbayExample;
import com.bailuntec.mapper.DcBaseCompanyAccountMapper; import com.bailuntec.mapper.DcBaseCompanyAccountMapper;
...@@ -16,10 +17,12 @@ import org.junit.Test; ...@@ -16,10 +17,12 @@ import org.junit.Test;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
/** /**
* <p> * <p>
...@@ -80,11 +83,21 @@ public class EbayFinanceAdSyncJobTest { ...@@ -80,11 +83,21 @@ public class EbayFinanceAdSyncJobTest {
@Test @Test
public void testThreadPool() { public void testThreadPool() {
EbayFinanceAdSyncJob ebayFinanceAdSyncJob = new EbayFinanceAdSyncJob(); EbayFinanceAdSyncJob ebayFinanceAdSyncJob = new EbayFinanceAdSyncJob();
ShardingContext shardingContext = new ShardingContext(
new ShardingContexts("x", "base-sync-finance-ebay-ad", 1, null, new HashMap<>()), 0
);
ebayFinanceAdSyncJob.executeJob(shardingContext, null); LocalDateTime start = LocalDateTime.of(2020, 10, 31, 0, 0);
LocalDateTime end = LocalDateTime.of(2020, 11, 16, 0, 0);
List<LocalDateTime> localDateTimeList = Stream.iterate(start,
localDateTime -> localDateTime.plusDays(1))
.limit(ChronoUnit.DAYS.between(start, end) + 1)
.collect(Collectors.toList());
localDateTimeList.parallelStream().forEach(localDateTime -> {
JobPointLog jobPointLog = new JobPointLog();
jobPointLog.setStartTime(localDateTime);
jobPointLog.setEndTime(localDateTime.plusDays(1));
ebayFinanceAdSyncJob.executeJob(null, jobPointLog);
});
} }
} }
...@@ -22,6 +22,13 @@ public class DruidDataSourceFactory implements DataSourceFactory { ...@@ -22,6 +22,13 @@ public class DruidDataSourceFactory implements DataSourceFactory {
hikariConfig.setJdbcUrl(this.props.getProperty("url")); hikariConfig.setJdbcUrl(this.props.getProperty("url"));
hikariConfig.setUsername(this.props.getProperty("username")); hikariConfig.setUsername(this.props.getProperty("username"));
hikariConfig.setPassword(this.props.getProperty("password")); hikariConfig.setPassword(this.props.getProperty("password"));
hikariConfig.setReadOnly(false);
hikariConfig.setConnectionTimeout(60000L);
hikariConfig.setIdleTimeout(60000L);
hikariConfig.setValidationTimeout(3000L);
hikariConfig.setMaxLifetime(60000L);
hikariConfig.setMaximumPoolSize(1000);
hikariConfig.setMinimumIdle(10);
return new HikariDataSource(hikariConfig); return new HikariDataSource(hikariConfig);
} }
......
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
<configuration> <configuration>
<!--<properties resource="db-tj.properties"/>--> <!--<properties resource="db-tj.properties"/>-->
<properties resource="db-dev.properties"/> <properties resource="db-dev.properties"/>
<!-- <properties resource="db-prod.properties"/>--> <!-- <properties resource="db-prod.properties"/>-->
<settings> <settings>
<setting name="mapUnderscoreToCamelCase" value="true"/> <setting name="mapUnderscoreToCamelCase" value="true"/>
</settings> </settings>
......
...@@ -10,8 +10,9 @@ EVENT_RDB_STORAGE_PASSWORD=#7kfnymAM$Y9-Ntf ...@@ -10,8 +10,9 @@ EVENT_RDB_STORAGE_PASSWORD=#7kfnymAM$Y9-Ntf
ZOOKEEPER_SERVER=172.31.255.120:2181 ZOOKEEPER_SERVER=172.31.255.120:2181
NAME_SPACE=data-center NAME_SPACE=data-center
JOB_NAME=show-auto-turnover2 JOB_NAME=show-auto-turnover4
JOB_CRON=0 0 3 * * ? #JOB_CRON=0 0 3 * * ?
JOB_CRON=0 50 9 * * ?
SHARDING_TOTAL_COUNT=8 SHARDING_TOTAL_COUNT=8
...@@ -20,6 +21,6 @@ JOB_CRON_NE_NORMAL=0 0 1 ? * MON ...@@ -20,6 +21,6 @@ JOB_CRON_NE_NORMAL=0 0 1 ? * MON
JOB_NAME_INCREMENT=show-auto-turnover-increment JOB_NAME_INCREMENT=show-auto-turnover-increment
JOB_CRON_INCREMENT=0 52 17 * * ? JOB_CRON_INCREMENT=0 0 14 * * ?
SHARDING_TOTAL_COUNT_INCREMENT=8 SHARDING_TOTAL_COUNT_INCREMENT=8
...@@ -110,11 +110,6 @@ public class AutoTurnoverTest { ...@@ -110,11 +110,6 @@ public class AutoTurnoverTest {
autoTurnoverJob.executeJob(shardingContext, jobPointLog); autoTurnoverJob.executeJob(shardingContext, jobPointLog);
} }
// @Test
// public void test5() {
// AutoTurnoverJobListener autoTurnoverJobListener = new AutoTurnoverJobListener();
// autoTurnoverJobListener.afterJobExecuted(null);
// }
@Test @Test
public void test55() { public void test55() {
...@@ -137,11 +132,12 @@ public class AutoTurnoverTest { ...@@ -137,11 +132,12 @@ public class AutoTurnoverTest {
} }
//949406801 GZBLWH
@Test @Test
public void testXX() { public void testXX() {
DcBaseStock dcBaseStock = SessionUtil.getSession().getMapper(DcBaseStockMapper.class) DcBaseStock dcBaseStock = SessionUtil.getSession().getMapper(DcBaseStockMapper.class)
.selectOneByExample(DcBaseStockExample.newAndCreateCriteria() .selectOneByExample(DcBaseStockExample.newAndCreateCriteria()
.andBailunSkuEqualTo("948906502") .andBailunSkuEqualTo("949406801")
.andWarehouseCodeEqualTo("GZBLWH") .andWarehouseCodeEqualTo("GZBLWH")
.example()); .example());
......
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