Commit 9257d6d9 by wilse

fix something bug

parent bb3d571c
......@@ -44,5 +44,6 @@ public class EbayAccountReportTask implements Serializable {
@ApiModelProperty(value = "异常信息")
private String errorMsg;
@ApiModelProperty("是否为新接口任务")
private Boolean isNewApi;
}
......@@ -49,7 +49,7 @@ public interface DcInventoryBalanceMapper extends BaseMapper<DcInventoryBalance>
BigDecimal getFbaInventoryAmountSum(LocalDate lastDay);
// 非FBA在库金额(不包含耗材仓)
@Select("select ifnull(sum(balance_rmb),0) from dc_inventory_balance where statistical_time = #{lastDay} and hq_type<>'FBA仓' and hq_type<>'耗材仓' and is_transfer=0")
@Select("select ifnull(sum(balance_rmb),0) from dc_inventory_balance where statistical_time = #{lastDay} and hq_type<>'FBA仓' and hq_type<>'耗材仓' and is_transfer=0 and warehouse_code not in ('BLDYYMS','BLRUIYUN','BLTEST')")
BigDecimal getNotFbaInventoryAmountSum(@Param("lastDay") LocalDate lastDay);
// 非FBA在库金额(耗材仓)
......
......@@ -41,13 +41,6 @@ public class SyncEbayFeeServiceImpl implements SyncEbayFeeService {
@Resource
private DcBaseEbayTransactionMapper dcBaseEbayTransactionMapper;
//当前需要跑的账号
private final static String[] RUN_ACCOUNT = new String[]{"ottlueilwitz3", "jalenhe", "uha4mmada", "rownmelody5",
"nthonyp6ecket", "rayallen9", "barbara_spence95", "nbrysonhall", "credit4free", "barbara_spence95", "onesines",
"coragios","suiedar","onesines","mmodatc","sjunqli","sytbing","entinaioc","senabchuan","talenmit","dudios",
"elecajxin","foneneo","gulilaev","vackeo","bnetufay","pjonusta","Elesporm","shaelefy","behcvtg","Jiangblwin",
"sytradenal","tmeiligda","gfruitan","Voasaon","Athltvc","nweifnmj","skillkedio","qmavitrd","covrivers",
"fruicang","touitdare","sweypvep","mudrwman","vuhnoghe","chsh-b","chsh-c","belar-dnb"};
@Resource
private EbayTransactionApi ebayTransactionApi;
......@@ -61,6 +54,7 @@ public class SyncEbayFeeServiceImpl implements SyncEbayFeeService {
List<EbayAccountReportTask> ebayAccountReportTaskList = ebayAccountReportTaskService.list(
new LambdaQueryWrapper<EbayAccountReportTask>()
.ne(EbayAccountReportTask::getStatus, 1)
.eq(EbayAccountReportTask::getIsNewApi,true)
.ge(EbayAccountReportTask::getStartTime, LocalDateTime.now().minusDays(60))
);
/*List<EbayAccountReportTask> ebayAccountReportTaskList = ebayAccountReportTaskService.list(new LambdaQueryWrapper<EbayAccountReportTask>()
......@@ -71,13 +65,15 @@ public class SyncEbayFeeServiceImpl implements SyncEbayFeeService {
List<DcBaseCompanyAccount> accountList = dcBaseCompanyAccountService.list(
new LambdaQueryWrapper<DcBaseCompanyAccount>()
.in(DcBaseCompanyAccount::getAccountId, accountIdList)
.in(DcBaseCompanyAccount::getAccountName, RUN_ACCOUNT)
.eq(DcBaseCompanyAccount::getAuthStatus,2)
);
//循环跑任务
List<EbayAccountReportTask> needUpdateEbayAccountReportTaskList = new ArrayList<>();
ebayAccountReportTaskList.forEach(x -> {
if (accountList.stream().noneMatch(a -> a.getAccountId().equals(x.getAccountId()))) {
x.setStatus(2);
x.setErrorMsg("当前账号不存在");
needUpdateEbayAccountReportTaskList.add(x);
return;
}
//获取token
......
......@@ -4,7 +4,7 @@ spring:
name: base-sync-ebay-transaction
# 数据配置
datasource:
url: jdbc:mysql://10.0.8.15:3306/bailun_datacenter?serverTimezone=GMT%2B8&characterEncoding=utf-8&rewriteBatchedStatements=true
url: jdbc:mysql://10.0.8.15:3306/bailun_datacenter?serverTimezone=GMT%2B8&characterEncoding=utf-8&rewriteBatchedStatements=true&useSSL=false
username: root
password: '#7kfnymAM$Y9-Ntf'
driver-class-name: com.mysql.jdbc.Driver
......@@ -22,6 +22,17 @@ spring:
cloud:
task:
closecontext-enabled: true
rabbitmq:
host: 111.230.164.154
port: 5672
username: bailun
password: 1234abcd
template:
mandatory: true
publisher-confirms: true
publisher-returns: true
queue:
isAck: true
#mybatis plus 配置
mybatis-plus:
......
......@@ -4,12 +4,12 @@ spring:
name: base-sync-ebay-transaction
# 数据配置
datasource:
url: jdbc:mysql://gz-cdb-kp7s5i79.sql.tencentcdb.com:61691/bailun_datacenter?serverTimezone=GMT%2B8&characterEncoding=utf-8&rewriteBatchedStatements=true
url: jdbc:mysql://gz-cdb-kp7s5i79.sql.tencentcdb.com:61691/bailun_datacenter?serverTimezone=GMT%2B8&characterEncoding=utf-8&rewriteBatchedStatements=true&useSSL=false
username: root
password: '#7kfnymAM$Y9-Ntf'
driver-class-name: com.mysql.jdbc.Driver
dataflow-datasource:
url: jdbc:mysql://gz-cdb-kp7s5i79.sql.tencentcdb.com:61691/bailun_datacenter?serverTimezone=GMT%2B8&characterEncoding=utf-8&rewriteBatchedStatements=true
url: jdbc:mysql://gz-cdb-kp7s5i79.sql.tencentcdb.com:61691/bailun_datacenter?serverTimezone=GMT%2B8&characterEncoding=utf-8&rewriteBatchedStatements=true&useSSL=false
username: root
password: '#7kfnymAM$Y9-Ntf'
driver-class-name: com.mysql.jdbc.Driver
......@@ -20,6 +20,17 @@ spring:
cloud:
task:
closecontext-enabled: true
rabbitmq:
host: 111.230.164.154
port: 5672
username: bailun
password: 1234abcd
template:
mandatory: true
publisher-confirms: true
publisher-returns: true
queue:
isAck: true
#mybatis plus 配置
mybatis-plus:
......
......@@ -20,7 +20,6 @@ class EbayTransactionApplicationTests {
}
@Test
@Rollback
public void testSyncEbayFeeJob(){
service.SyncEbayTransaction();
}
......
......@@ -4,7 +4,7 @@ spring:
name: base-sync-ebay-transaction
# 数据配置
datasource:
url: jdbc:mysql://10.0.8.15:3306/bailun_datacenter?serverTimezone=GMT%2B8&characterEncoding=utf-8&rewriteBatchedStatements=true?useSSL=false
url: jdbc:mysql://10.0.8.15:3306/bailun_datacenter?serverTimezone=GMT%2B8&characterEncoding=utf-8&rewriteBatchedStatements=true&useSSL=false
username: root
password: '#7kfnymAM$Y9-Ntf'
driver-class-name: com.mysql.jdbc.Driver
......@@ -22,6 +22,17 @@ spring:
cloud:
task:
closecontext-enabled: true
rabbitmq:
host: 111.230.164.154
port: 5672
username: bailun
password: 1234abcd
template:
mandatory: true
publisher-confirms: true
publisher-returns: true
queue:
isAck: true
#mybatis plus 配置
mybatis-plus:
......
......@@ -4,7 +4,7 @@ spring:
name: base-sync-ebay-transaction
# 数据配置
datasource:
url: jdbc:mysql://gz-cdb-kp7s5i79.sql.tencentcdb.com:61691/bailun_datacenter?serverTimezone=GMT%2B8&characterEncoding=utf-8&rewriteBatchedStatements=true?useSSL=false
url: jdbc:mysql://gz-cdb-kp7s5i79.sql.tencentcdb.com:61691/bailun_datacenter?serverTimezone=GMT%2B8&characterEncoding=utf-8&rewriteBatchedStatements=true&useSSL=false
username: root
password: '#7kfnymAM$Y9-Ntf'
driver-class-name: com.mysql.jdbc.Driver
......@@ -20,6 +20,17 @@ spring:
cloud:
task:
closecontext-enabled: true
rabbitmq:
host: 111.230.164.154
port: 5672
username: bailun
password: 1234abcd
template:
mandatory: true
publisher-confirms: true
publisher-returns: true
queue:
isAck: true
#mybatis plus 配置
mybatis-plus:
......
......@@ -10,6 +10,17 @@ spring:
driver-class-name: com.mysql.jdbc.Driver
main:
allow-bean-definition-overriding: true
rabbitmq:
host: 111.230.164.154
port: 5672
username: bailun
password: 1234abcd
template:
mandatory: true
publisher-confirms: true
publisher-returns: true
queue:
isAck: true
#mybatis plus 配置
mybatis-plus:
......@@ -20,6 +31,7 @@ mybatis-plus:
feign:
hystrix:
enabled: false
......
......@@ -10,6 +10,17 @@ spring:
driver-class-name: com.mysql.jdbc.Driver
main:
allow-bean-definition-overriding: true
rabbitmq:
host: 111.230.164.154
port: 5672
username: bailun
password: 1234abcd
template:
mandatory: true
publisher-confirms: true
publisher-returns: true
queue:
isAck: true
#mybatis plus 配置
mybatis-plus:
......@@ -19,6 +30,7 @@ mybatis-plus:
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
feign:
hystrix:
enabled: false
......
......@@ -98,6 +98,15 @@ public class BalanceSheetServiceTest {
}
@Test
public void balanceSheetTest1() throws ParseException {
LocalDate now = LocalDate.of(2021,11,1);
while (LocalDate.now().compareTo(now)>0){
balanceSheetService.generateBalanceSheet(now);
now = now.plusDays(1);
}
}
@Test
public void test(){
/*System.out.println("----------------------------------");
DcJobConfig dcJobConfig = dcJobConfigMapper.selectByName("finance-generate-balance-sheet");
......
......@@ -59,7 +59,7 @@ public class JobConfiguration {
@Bean
public Step handleDataStep() {
return stepBuilderFactory.get("getData")
.<EbayItem, DcBaseFinanceEbay>chunk(100) // <输入,输出> 。chunk通俗的讲类似于SQL的commit; 这里表示处理(processor)100条后写入(writer)一次。
.<EbayItem, DcBaseFinanceEbay>chunk(10) // <输入,输出> 。chunk通俗的讲类似于SQL的commit; 这里表示处理(processor)100条后写入(writer)一次。
.reader(customerReader) //指定ItemReader
.processor(customerProcessor) //指定ItemProcessor
.writer(customerWriter)//指定ItemWriter
......
......@@ -20,11 +20,13 @@ import com.ebay.soap.eBLBaseComponents.DetailLevelCodeType;
import com.ebay.soap.eBLBaseComponents.PaginationType;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.session.SqlSession;
import org.springframework.batch.item.ItemReader;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*;
......@@ -51,13 +53,6 @@ public class CustomerReader implements ItemReader<EbayItem> {
private GetAccountCall getAccountCall;
//当前页码
private Integer pageNum;
//无需跑任务的账号
private final static String[] CANNOT_RUN_ACCOUNT = new String[]{"ottlueilwitz3","jalenhe","uha4mmada","rownmelody5",
"nthonyp6ecket","rayallen9","barbara_spence95","nbrysonhall","credit4free", "onesines","coragios","suiedar",
"onesines","mmodatc","sjunqli","sytbing","entinaioc","senabchuan","talenmit","dudios","elecajxin","foneneo",
"gulilaev","vackeo","bnetufay","pjonusta","Elesporm","shaelefy","behcvtg","Jiangblwin","sytradenal",
"tmeiligda","gfruitan","Voasaon","Athltvc","nweifnmj","skillkedio","qmavitrd","covrivers","fruicang",
"touitdare","sweypvep","mudrwman","vuhnoghe","chsh-b","chsh-c","belar-dnb"};
@Resource
......@@ -73,7 +68,10 @@ public class CustomerReader implements ItemReader<EbayItem> {
private void init() {
log.info("初始化reader 开始..");
ebayAccountReportTaskList = ebayAccountReportTaskMapper.selectList(new LambdaQueryWrapper<EbayAccountReportTask>()
.ne(EbayAccountReportTask::getStatus, 1));
.eq(EbayAccountReportTask::getStatus, 0)
.ge(EbayAccountReportTask::getStartTime, LocalDateTime.now().minusMonths(4))
.eq(EbayAccountReportTask::getIsNewApi, false)
.last("limit 500"));
this.pageNum = 1;
log.info("初始化reader 结束");
......@@ -123,10 +121,12 @@ public class CustomerReader implements ItemReader<EbayItem> {
ebayAccountReportTask = ebayAccountReportTaskList.remove(0);
dcBaseCompanyAccount = dcBaseCompanyAccountMapper.selectOne(new LambdaQueryWrapper<DcBaseCompanyAccount>()
.eq(DcBaseCompanyAccount::getPlatformId, DcBaseCompanyAccount.EBAY_PLATFORM_ID)
.eq(DcBaseCompanyAccount::getAccountId, ebayAccountReportTask.getAccountId()));
if(Arrays.stream(this.CANNOT_RUN_ACCOUNT).anyMatch(x -> x.equals(dcBaseCompanyAccount.getAccountName().toLowerCase()))){
.eq(DcBaseCompanyAccount::getAccountId, ebayAccountReportTask.getAccountId())
.ge(DcBaseCompanyAccount::getBjModified, LocalDateTime.now().minusDays(1))
.last("limit 1"));
if (dcBaseCompanyAccount == null) {
ebayAccountReportTask.setStatus(2);
ebayAccountReportTask.setErrorMsg("旧接口不跑该任务");
ebayAccountReportTask.setErrorMsg("账号不存在或token没更新");
this.nextAccount();
return;
}
......@@ -185,8 +185,11 @@ public class CustomerReader implements ItemReader<EbayItem> {
accountEntryTypeList = Lists.newArrayList(accountEntryTypes);
}
ebayAccountReportTask.setStatus(1);
if (ListUtil.isEmpty(accountEntryTypeList)) {
ebayAccountReportTask.setErrorMsg("NONE");
}
} catch (Exception ex) {
String errMsg = String.format("请求ebay广告服务异常,当前账号:%s,当前页码:%s", dcBaseCompanyAccount.getAccountName(), pageNum);
String errMsg = String.format("请求ebay广告服务异常,当前账号:%s,当前页码:%s,异常:%s", dcBaseCompanyAccount.getAccountName(), pageNum, ex.getMessage());
log.error(errMsg);
//todo log ebay exception
ebayAccountReportTask.setStatus(2);
......
......@@ -22,6 +22,17 @@ spring:
cloud:
task:
closecontext-enabled: true
rabbitmq:
host: 111.230.164.154
port: 5672
username: bailun
password: 1234abcd
template:
mandatory: true
publisher-confirms: true
publisher-returns: true
queue:
isAck: true
#mybatis plus 配置
mybatis-plus:
......
......@@ -4,12 +4,12 @@ spring:
name: ebay-report-consumer
# 数据配置
datasource-biz:
url: jdbc:mysql://gz-cdb-kp7s5i79.sql.tencentcdb.com:61691/bailun_datacenter?serverTimezone=GMT%2B8&characterEncoding=utf-8&rewriteBatchedStatements=true
url: jdbc:mysql://gz-cdb-kp7s5i79.sql.tencentcdb.com:61691/bailun_datacenter?serverTimezone=GMT%2B8&characterEncoding=utf-8&rewriteBatchedStatements=true&useSSL=false
username: root
password: '#7kfnymAM$Y9-Ntf'
driver-class-name: com.mysql.jdbc.Driver
dataflow-datasource:
url: jdbc:mysql://gz-cdb-kp7s5i79.sql.tencentcdb.com:61691/bailun_datacenter?serverTimezone=GMT%2B8&characterEncoding=utf-8&rewriteBatchedStatements=true
url: jdbc:mysql://gz-cdb-kp7s5i79.sql.tencentcdb.com:61691/bailun_datacenter?serverTimezone=GMT%2B8&characterEncoding=utf-8&rewriteBatchedStatements=true&useSSL=false
username: root
password: '#7kfnymAM$Y9-Ntf'
driver-class-name: com.mysql.jdbc.Driver
......@@ -20,6 +20,17 @@ spring:
cloud:
task:
closecontext-enabled: true
rabbitmq:
host: 111.230.164.154
port: 5672
username: bailun
password: 1234abcd
template:
mandatory: true
publisher-confirms: true
publisher-returns: true
queue:
isAck: true
#mybatis plus 配置
mybatis-plus:
......
......@@ -11,6 +11,7 @@ import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.Arrays;
/**
* <p>
......@@ -26,6 +27,13 @@ public class CustomerProcessor implements ItemProcessor<DcBaseCompanyAccount, Eb
@Resource
JobProperty jobProperty;
private final static String[] NEW_API_ACCOUNTS = new String[]{"ottlueilwitz3", "jalenhe", "uha4mmada", "rownmelody5",
"nthonyp6ecket", "rayallen9", "barbara_spence95", "nbrysonhall", "credit4free", "onesines", "coragios", "suiedar",
"onesines", "mmodatc", "sjunqli", "sytbing", "entinaioc", "senabchuan", "talenmit", "dudios", "elecajxin", "foneneo",
"gulilaev", "vackeo", "bnetufay", "pjonusta", "Elesporm", "shaelefy", "behcvtg", "Jiangblwin", "sytradenal",
"tmeiligda", "gfruitan", "Voasaon", "Athltvc", "nweifnmj", "skillkedio", "qmavitrd", "covrivers", "fruicang",
"touitdare", "sweypvep", "mudrwman", "vuhnoghe", "chsh-b", "chsh-c", "belar-dnb"};
@Override
public EbayAccountReportTask process(@NonNull DcBaseCompanyAccount item) {
......@@ -36,7 +44,7 @@ public class CustomerProcessor implements ItemProcessor<DcBaseCompanyAccount, Eb
ebayAccountReportTask.setAccountId(item.getAccountId());
ebayAccountReportTask.setStartTime(LocalDateTime.of(dcJobConfig.getStartTime().toLocalDate(), LocalTime.MIN));
ebayAccountReportTask.setEndTime(LocalDateTime.of(dcJobConfig.getStartTime().toLocalDate(), LocalTime.MIN).plusDays(1));
ebayAccountReportTask.setIsNewApi(Arrays.stream(NEW_API_ACCOUNTS).anyMatch(x -> x.equals(item.getAccountName())));
return ebayAccountReportTask;
}
}
......@@ -9,6 +9,7 @@ import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;
/**
......@@ -31,7 +32,8 @@ public class CustomerReader implements ItemReader<DcBaseCompanyAccount> {
void init() {
dcBaseCompanyAccountList = dcBaseCompanyAccountMapper.selectList(new LambdaQueryWrapper<DcBaseCompanyAccount>()
.eq(DcBaseCompanyAccount::getPlatformId, DcBaseCompanyAccount.EBAY_PLATFORM_ID)
.eq(DcBaseCompanyAccount::getStatus, DcBaseCompanyAccount.STATUS_ON));
.eq(DcBaseCompanyAccount::getStatus, DcBaseCompanyAccount.STATUS_ON)
.gt(DcBaseCompanyAccount::getBjModified, LocalDateTime.now().minusDays(1)));
}
public DcBaseCompanyAccount read() {
......
......@@ -22,6 +22,17 @@ spring:
cloud:
task:
closecontext-enabled: true
rabbitmq:
host: 111.230.164.154
port: 5672
username: bailun
password: 1234abcd
template:
mandatory: true
publisher-confirms: true
publisher-returns: true
queue:
isAck: true
#mybatis plus 配置
mybatis-plus:
......
......@@ -20,6 +20,17 @@ spring:
cloud:
task:
closecontext-enabled: true
rabbitmq:
host: 111.230.164.154
port: 5672
username: bailun
password: 1234abcd
template:
mandatory: true
publisher-confirms: true
publisher-returns: true
queue:
isAck: true
#mybatis plus 配置
mybatis-plus:
......
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