Commit a831086f by huluobin

update

parent 4816c5c4
......@@ -107,6 +107,16 @@ public class AmazonAdDownloadReportJob implements SimpleJob {
dcBaseFinanceAmazonAdProduct = new DcBaseFinanceAmazonAdProduct();
}
BeanUtils.copyProperties(dcBaseFinanceAmazonAdProduct, amazonAdProduct);
dcBaseFinanceAmazonAdProduct.setAccountId(jobAmazonAdLog.getAccountId());
dcBaseFinanceAmazonAdProduct.setCompanyId(jobAmazonAdLog.getCompanyId());
dcBaseFinanceAmazonAdProduct.setReportDate(jobAmazonAdLog.getReportDate());
dcBaseFinanceAmazonAdProduct.setExchangeRate(CallBailunSystem.getExchangeRate(dcBaseFinanceAmazonAdProduct.getCurrency(), CurrencyType.CNY.value(), jobAmazonAdLog.getReportDate().atStartOfDay()));
dcBaseFinanceAmazonAdProduct.setExchangeRateUsd(CallBailunSystem.getExchangeRate(dcBaseFinanceAmazonAdProduct.getCurrency(), CurrencyType.USD.value(), jobAmazonAdLog.getReportDate().atStartOfDay()));
dcBaseFinanceAmazonAdProduct.setBjModifyTime(LocalDateTime.now());
dcBaseFinanceAmazonAdProduct.setType(jobAmazonAdLog.getType());
dcBaseFinanceAmazonAdProductMapper.upsertSelective(dcBaseFinanceAmazonAdProduct);
}
}
......
......@@ -44,13 +44,13 @@ public class AmazonAdGenerateReportIdJob implements SimpleJob {
.andAmazonAdAuthJsonNotEqualTo("")
.example());
for (int i = 2; i <= 6; i++) {
int finalI = i;
dcBaseCompanyAccountList
// .stream()
// .filter(dcBaseCompanyAccount -> dcBaseCompanyAccount.getAccountId().equals(671))
.forEach(dcBaseCompanyAccount -> {
LocalDateTime reportDate = LocalDateTime.of(2020, 10, finalI, 0, 0);
LocalDateTime reportDate = LocalDateTime.now().minusHours(36);
// LocalDateTime reportDate = LocalDateTime.of(2020, 10, 2, 0, 0);
//productAds
try {
// LocalDateTime reportDate = LocalDateTime.of(2020, 9, 1, 0, 0);
......@@ -188,11 +188,8 @@ public class AmazonAdGenerateReportIdJob implements SimpleJob {
} catch (Exception ex) {
log.error("下载展示报告异常 帐号id :{} 日期:{} 异常信息:{} ", dcBaseCompanyAccount.getAccountId(), reportDate, ex.getMessage(), ex);
}
});
}
}
}
......
......@@ -3,7 +3,6 @@ package com.bailuntec.job;
import com.bailuntec.domain.pojo.AmazonAdProduct;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.executor.ShardingContexts;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import lombok.extern.slf4j.Slf4j;
import okhttp3.OkHttpClient;
......@@ -11,7 +10,7 @@ import okhttp3.Request;
import okhttp3.Response;
import org.junit.jupiter.api.Test;
import java.io.*;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.List;
......@@ -55,8 +54,7 @@ class AmazonAdDownloadReportJobTest {
}.getType();
StringBuilder html= new StringBuilder();
StringBuilder html = new StringBuilder();
Scanner sc = new Scanner(inputStream);
while (sc.hasNextLine()) {
......
......@@ -25,7 +25,7 @@ public class SyncCostFirstFinishJobTest {
SyncCostFirstFinishJob syncCostFirstFinishJob = new SyncCostFirstFinishJob();
JobPointLog jobPointLog = new JobPointLog("base-sync-cost-first-finish", 1, 1000, 1, 1,
LocalDateTime.of(2020, 8, 1, 0, 0, 0),
LocalDateTime.of(2020, 10, 9, 0, 0, 0));
LocalDateTime.of(2020, 10, 10, 0, 0, 0));
syncCostFirstFinishJob.executeJob(null, jobPointLog);
}
......
......@@ -57,11 +57,15 @@ public class EbayFinanceAdSyncJob extends PointJob {
for (JobAccountLog jobAccountLog : listByPage) {
try {
//先删除再更新
dcBaseFinanceEbayMapper.deleteByExample(DcBaseFinanceEbayExample.newAndCreateCriteria()
.andBjDateBetween(startTime, endTime)
.andAccountIdEqualTo(jobAccountLog.getAccountId())
.example());
}catch (Exception ex){
}
jobAccountLog.setStartTime(startTime.plusHours(15));
jobAccountLog.setEndTime(endTime.plusHours(15));
......@@ -73,7 +77,6 @@ public class EbayFinanceAdSyncJob extends PointJob {
jobPointLog.setStartTime(startTime.plusDays(1));
jobPointLog.setEndTime(endTime.plusDays(1));
jobPointLogMapper.updateByPrimaryKey(jobPointLog);
}
} catch (Exception e) {
......
......@@ -7,6 +7,7 @@ import com.bailuntec.domain.example.DcBaseCompanyAccountExample;
import com.bailuntec.domain.example.DcBaseFinanceEbayExample;
import com.bailuntec.mapper.DcBaseCompanyAccountMapper;
import com.bailuntec.mapper.DcBaseFinanceEbayMapper;
import com.bailuntec.support.PointJob;
import com.bailuntec.utils.SessionUtil;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.executor.ShardingContexts;
......@@ -33,12 +34,12 @@ public class EbayFinanceAdSyncJobTest {
@Test
public void executeJob() {
EbayFinanceAdSyncJob ebayFinanceAdSyncJob = new EbayFinanceAdSyncJob();
PointJob ebayFinanceAdSyncJob = new EbayFinanceAdSyncJob();
ShardingContext shardingContext = new ShardingContext(
new ShardingContexts("x", "base-sync-finance-ebay-ad", 1, null, new HashMap<>()), 0
);
ebayFinanceAdSyncJob.executeJob(shardingContext, null);
ebayFinanceAdSyncJob.execute(shardingContext);
}
......
......@@ -3,6 +3,7 @@ package com.bailuntec;
import com.alibaba.druid.pool.DruidDataSource;
import com.bailuntec.job.OrderSyncJob;
import com.bailuntec.job.OrderSyncJob30;
import com.bailuntec.job.OrderSyncTask;
import com.bailuntec.listener.OrderSyncJobListener;
import com.bailuntec.utils.PropertiesUtil;
import com.dangdang.ddframe.job.config.JobCoreConfiguration;
......@@ -29,7 +30,7 @@ public class Application {
public static void main(String[] args) {
new JobScheduler(createRegistryCenter(), createJobConfiguration(), createJobEventConfiguration(), new OrderSyncJobListener()).init();
new JobScheduler(createRegistryCenter(), createJobConfiguration1(), createJobEventConfiguration(), new OrderSyncJobListener()).init();
// new JobScheduler(createRegistryCenter(), createJobConfiguration2(), createJobEventConfiguration(), new OrderSyncJobListener()).init();
new JobScheduler(createRegistryCenter(), createJobConfiguration2(), createJobEventConfiguration(), new OrderSyncJobListener()).init();
}
......@@ -60,14 +61,14 @@ public class Application {
return LiteJobConfiguration.newBuilder(simpleJobConfig).build();
}
// private static LiteJobConfiguration createJobConfiguration2() {
// JobCoreConfiguration simpleCoreConfig = JobCoreConfiguration.newBuilder(
// propertiesUtil.getPropertyAsString("JOB_COROUTINE_NAME"),
// propertiesUtil.getPropertyAsString("JOB_COROUTINE_CRON"),
// propertiesUtil.getPropertyAsInt("SHARDING_TOTAL_COUNT")).build();
// SimpleJobConfiguration simpleJobConfig = new SimpleJobConfiguration(simpleCoreConfig, OrderSyncTask.class.getCanonicalName());
// return LiteJobConfiguration.newBuilder(simpleJobConfig).build();
// }
private static LiteJobConfiguration createJobConfiguration2() {
JobCoreConfiguration simpleCoreConfig = JobCoreConfiguration.newBuilder(
propertiesUtil.getPropertyAsString("JOB_COROUTINE_NAME"),
propertiesUtil.getPropertyAsString("JOB_COROUTINE_CRON"),
propertiesUtil.getPropertyAsInt("SHARDING_TOTAL_COUNT")).build();
SimpleJobConfiguration simpleJobConfig = new SimpleJobConfiguration(simpleCoreConfig, OrderSyncTask.class.getCanonicalName());
return LiteJobConfiguration.newBuilder(simpleJobConfig).build();
}
private static JobEventConfiguration createJobEventConfiguration() {
return new JobEventRdbConfiguration(setUpEventTraceDataSource());
......
......@@ -19,7 +19,7 @@ JOB_NAME30=base-sync-oms-skus30
#JOB_NAME=base-sync-oms-order
JOB_CRON30=0 0 22,23,00 * * ? *
JOB_COROUTINE_NAME=base-sync-oms-order-task2
JOB_COROUTINE_NAME=base-sync-oms-order-task3
JOB_COROUTINE_CRON=0/1 * * * * ?
SHARDING_TOTAL_COUNT=1
......@@ -518,6 +518,6 @@
where status = 0
and bj_create &lt; #{localDateTime}
and id % #{shardingContext.shardingTotalCount} = #{shardingContext.shardingItem}
order by bj_modified desc
order by report_date
</select>
</mapper>
package com.bailuntec.utils;
import com.bailuntec.domain.constant.CommonConstant;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import java.io.Reader;
public class ReadSessionUtil {
//当前线程里面存放session
private static final ThreadLocal<SqlSession> threadLocal = new ThreadLocal<>();
private static final ThreadLocal<SqlSession> threadLocalTransction = new ThreadLocal<>();
private static Reader reader = null;
private static SqlSessionFactoryBuilder builder = null;
private static SqlSessionFactory factory = null;
//不允许对该类进行new操作
private ReadSessionUtil() {
}
static {
try {
//1.加载配置文件
reader = Resources.getResourceAsReader("mybatis-readonly-config.xml");
//2.得到工厂的创建对象
builder = new SqlSessionFactoryBuilder();
//3.得到工厂对象
factory = builder.build(reader);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("SqlSessionFactory初始化失败, 请检查配置文件路径和内容");
}
}
//获取自动提交session
public static SqlSession getSession() {
SqlSession session = threadLocal.get();
if (session == null) {
SqlSessionFactory factory = getFactory();
session = factory.openSession(true);
threadLocal.set(session);
}
return session;
}
//获取手动提交session
public static SqlSession getTranstionSession() {
SqlSession session = threadLocalTransction.get();
if (session == null) {
SqlSessionFactory factory = getFactory();
session = factory.openSession();
threadLocalTransction.set(session);
}
return session;
}
//关闭session
public static void closeTranstionSession() {
try {
SqlSession session = threadLocalTransction.get();
if (session != null) {
session.close();
}
threadLocalTransction.set(null);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("MYSQL关闭Session异常",e);
}
}
//关闭session
public static void closeSession() {
try {
SqlSession session = threadLocal.get();
if (session != null) {
session.close();
}
threadLocal.set(null);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("MYSQL关闭Session异常",e);
}
}
//获得工厂对象
public static SqlSessionFactory getFactory() {
if (factory == null) {
factory = builder.build(reader);
}
return factory;
}
}
......@@ -2,3 +2,7 @@ driver=com.mysql.jdbc.Driver
url=jdbc:mysql://gz-cdb-kp7s5i79.sql.tencentcdb.com:61691/bailun_datacenter?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
username=root
password=#7kfnymAM$Y9-Ntf
readonly-url=jdbc:mysql://gz-cdbrg-qdyec2j3.sql.tencentcdb.com:59667/bailun_datacenter?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
readonly-username=root
readonly-password=#7kfnymAM$Y9-Ntf
......@@ -2,3 +2,9 @@ driver=com.mysql.jdbc.Driver
url=jdbc:mysql://10.0.8.15:3306/bailun_datacenter?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
username=root
password=#7kfnymAM$Y9-Ntf
readonly-url=jdbc:mysql://10.0.8.21:3306/bailun_datacenter?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
readonly-username=root
readonly-password=#7kfnymAM$Y9-Ntf
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="true">
<configuration scan="false" scanPeriod="60 seconds" debug="true">
<!-- 彩色日志格式 -->
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
<conversionRule conversionWord="wex"
......
<!--<?xml version="1.0" encoding="UTF-8" ?>-->
<!--<!DOCTYPE configuration-->
<!-- PUBLIC "-//mybatis.org//DTD Config 3.0//EN"-->
<!-- "http://mybatis.org/dtd/mybatis-3-config.dtd">-->
<!--<configuration>-->
<!-- &lt;!&ndash;<properties resource="db-tj.properties"/>&ndash;&gt;-->
<!-- <properties resource="readonly-db-dev.properties"/>-->
<!-- &lt;!&ndash; <properties resource="readonly-db-prod.properties"/>&ndash;&gt;-->
<!-- <settings>-->
<!-- <setting name="mapUnderscoreToCamelCase" value="true"/>-->
<!-- </settings>-->
<!-- <typeAliases>-->
<!-- <typeAlias type="com.bailuntec.support.DruidDataSourceFactory" alias="DRUID"/>-->
<!-- <package name="com.bailuntec.domain"/>-->
<!-- </typeAliases>-->
<!-- &lt;!&ndash; <plugins>&ndash;&gt;-->
<!-- &lt;!&ndash; <plugin interceptor="com.bailuntec.support.SqlCostInterceptor"/>&ndash;&gt;-->
<!-- &lt;!&ndash; </plugins>&ndash;&gt;-->
<!-- <environments default="work">-->
<!-- <environment id="work">-->
<!-- <transactionManager type="JDBC"/>-->
<!-- <dataSource type="DRUID">-->
<!-- <property name="driver" value="${driver}"/>-->
<!-- <property name="url" value="${url}"/>-->
<!-- <property name="username" value="${username}"/>-->
<!-- <property name="password" value="${password}"/>-->
<!-- </dataSource>-->
<!-- </environment>-->
<!-- </environments>-->
<!-- <mappers>-->
<!-- <package name="com.bailuntec.mapper"/>-->
<!-- </mappers>-->
<!--</configuration>-->
driver=com.mysql.jdbc.Driver
url=jdbc:mysql://gz-cdbrg-qdyec2j3.sql.tencentcdb.com:59667/bailun_datacenter?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
username=root
password=#7kfnymAM$Y9-Ntf
driver=com.mysql.jdbc.Driver
url=jdbc:mysql://10.0.8.21:3306/bailun_datacenter?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
username=root
password=#7kfnymAM$Y9-Ntf
......@@ -217,6 +217,7 @@ public class AutoTurnoverJob extends PointJob {
//库存对应的仓库
dcBaseWarehouse = baseWarehouseMapper.selectOneByExample(DcBaseWarehouseExample.newAndCreateCriteria().andWarehouseCodeEqualTo(warehouseCode).example());
BigDecimal incrementalRatio = BigDecimal.ONE;
int compareSales = 0;
//销量
DcAutoSalesMapper autoSalesMapper;
......
......@@ -5,6 +5,7 @@ import com.bailuntec.domain.entity.DcAutoTurnover;
import com.bailuntec.mapper.DcAutoSalesForecastStageConfigMapper;
import com.bailuntec.mapper.DcBaseOmsSkuMapper;
import com.bailuntec.service.AutoTurnoverService;
import com.bailuntec.utils.ReadSessionUtil;
import com.bailuntec.utils.SessionUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.session.SqlSession;
......@@ -29,7 +30,8 @@ public class AutoTurnoverServiceImpl implements AutoTurnoverService {
@Override
public List<BigDecimal> getAutoTurnoverSaleDetails(DcAutoTurnover dcAutoTurnover, int turnoverDays, int autoForecastDay) {
SqlSession session = SessionUtil.getFactory().openSession(true);
SqlSession session = ReadSessionUtil.getFactory().openSession(true);
// SqlSession readOnlySession = ReadSessionUtil.getFactory().openSession(true);
try {
Queue<BigDecimal> forecastSalesDetails = new LinkedList<>();
......
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