Commit a3cdf637 by huluobin

update

parent 2509d9aa
#n:information_schema
!<md> [null, 0, null, null, -2147483648, -2147483648]
...@@ -4,7 +4,7 @@ spring: ...@@ -4,7 +4,7 @@ spring:
name: base-sync-sample name: base-sync-sample
# 数据配置 # 数据配置
datasource: datasource:
url: jdbc:mysql://10.0.8.15:3306/bailun_datacenter?serverTimezone=GMT%2B8&characterEncoding=utf-8 url: jdbc:mysql://10.0.8.15:3306/bailun_datacenter?serverTimezone=GMT%2B8&characterEncoding=utf-8&rewriteBatchedStatements=true
username: root username: root
password: '#7kfnymAM$Y9-Ntf' password: '#7kfnymAM$Y9-Ntf'
driver-class-name: com.mysql.jdbc.Driver driver-class-name: com.mysql.jdbc.Driver
......
...@@ -4,7 +4,7 @@ spring: ...@@ -4,7 +4,7 @@ spring:
name: base-sync-sample name: base-sync-sample
# 数据配置 # 数据配置
datasource: datasource:
url: jdbc:mysql://gz-cdb-kp7s5i79.sql.tencentcdb.com:61691/bailun_datacenter?serverTimezone=GMT%2B8&characterEncoding=utf-8 url: jdbc:mysql://gz-cdb-kp7s5i79.sql.tencentcdb.com:61691/bailun_datacenter?serverTimezone=GMT%2B8&characterEncoding=utf-8&rewriteBatchedStatements=true
username: root username: root
password: '#7kfnymAM$Y9-Ntf' password: '#7kfnymAM$Y9-Ntf'
driver-class-name: com.mysql.jdbc.Driver driver-class-name: com.mysql.jdbc.Driver
......
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>datacenter-base</artifactId>
<groupId>com.bailuntec</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>base-sync-sku</artifactId>
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven-surefire-plugin.version>2.18.1</maven-surefire-plugin.version>
<maven.build.timestamp.format>yyyyMMddHHmm</maven.build.timestamp.format>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.3.3.RELEASE</version>
<configuration>
<mainClass>com.bailuntec.job.SkuApp</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.0.0</version>
<configuration>
<skipDockerBuild>false</skipDockerBuild>
<imageName>ccr.ccs.tencentyun.com/blt.data.job/base-sync-sku:${maven.build.timestamp}
</imageName>
<dockerDirectory>src/main/docker</dockerDirectory>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
<serverId>bailuntec-docker</serverId>
</configuration>
</plugin>
</plugins>
</build>
</project>
FROM openjdk:8-jdk-alpine
VOLUME /tmp
ADD base-sync-oms-order-1.0-SNAPSHOT.jar base-sync-oms-order-1.0-SNAPSHOT.jar
RUN echo "Asia/Shanghai" > /etc/timezone
ENTRYPOINT ["java","-Xms2048m","-Xmx2048m","-jar","-Dspring.profiles.active=prod","/base-sync-oms-order-1.0-SNAPSHOT.jar"]
EXPOSE 8080
package com.bailuntec.job;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;
/**
* <p>
*
* </p>
*
* @author robbendev
* @since 2020/10/28 3:16 下午
*/
@SpringBootApplication
@EnableScheduling
@ComponentScan("com.bailuntec")
@EnableFeignClients(basePackages = {"com.bailuntec.api", "com.bailuntec.*.api"})
public class SkuApp {
public static void main(String[] args) {
SpringApplication.run(SkuApp.class, args);
}
}
package com.bailuntec.job;
import com.bailuntec.job.service.SkuService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
@Slf4j
@Component
public class SkuJob {
@Resource
SkuService skuService;
@Scheduled(cron = "0/10 * * * * ?")
public void syncSkuMappingOnline() {
try {
log.info("每10秒同步线上sku映射 开始");
skuService.syncSkuMappingOnline();
log.info("每10秒同步线上sku映射 结束");
} catch (Exception ex) {
log.error("每10秒同步线上sku映射 异常:", ex);
}
}
}
package com.bailuntec.job.service;
import com.bailuntec.api.bailuntec.pps.PpsApi;
import com.bailuntec.api.bailuntec.pps.request.GetListingSkuMapPagesReq;
import com.bailuntec.api.bailuntec.pps.response.GetListingSkuMapPagesItem;
import com.bailuntec.api.bailuntec.pps.response.PpsPage;
import com.bailuntec.api.bailuntec.pps.response.PpsResult;
import com.bailuntec.application.IDcBaseSkuMappingOnlineService;
import com.bailuntec.common.ListUtil;
import com.bailuntec.domain.DcBaseSkuMappingOnline;
import com.bailuntec.domain.DcJobConfig;
import com.bailuntec.infrastructure.mapper.DcJobConfigMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;
/**
* <p>
*
* </p>
*
* @author robbendev
* @since 2020/10/7 11:38 上午
*/
@Slf4j
@Service
public class SkuService {
@Resource
DcJobConfigMapper dcJobConfigMapper;
@Resource
PpsApi ppsApi;
@Resource
IDcBaseSkuMappingOnlineService dcBaseSkuMappingOnlineService;
private final static String baseSyncSkuMappingOnline = "base-sync-sku-mapping-online"
public void syncSkuMappingOnline() {
DcJobConfig dcJobConfig = dcJobConfigMapper.selectByName(baseSyncSkuMappingOnline);
Integer currentPage = dcJobConfig.getPageNum();
Integer pageSize = dcJobConfig.getPageSize();
for (; ; ) {
GetListingSkuMapPagesReq req = new GetListingSkuMapPagesReq();
req.setPageIndex(currentPage);
req.setPageNumber(pageSize);
req.setBeginTime(dcJobConfig.getStartTime());
req.setEndTime(dcJobConfig.getEndTime());
PpsResult<PpsPage<GetListingSkuMapPagesItem>> result = ppsApi.getListingSkuMapPages(req);
if (ListUtil.isEmpty(result.getResult().getData())) {
break;
}
List<DcBaseSkuMappingOnline> dcBaseSkuMappingOnlineList = result.getResult().getData()
.stream()
.map(getListingSkuMapPagesItem -> getListingSkuMapPagesItem.getDetails()
.stream()
.map(getListingSkuMapPagesItemDetail -> {
DcBaseSkuMappingOnline dcBaseSkuMappingOnline = new DcBaseSkuMappingOnline();
//item
dcBaseSkuMappingOnline.setAccountId(getListingSkuMapPagesItem.getAccountId());
dcBaseSkuMappingOnline.setAccountName(getListingSkuMapPagesItem.getAccountName());
dcBaseSkuMappingOnline.setIsDeleted(getListingSkuMapPagesItem.getIsDeleted());
dcBaseSkuMappingOnline.setItemId(getListingSkuMapPagesItem.getItemId());
dcBaseSkuMappingOnline.setPlatform(getListingSkuMapPagesItem.getPlatform());
dcBaseSkuMappingOnline.setSite(getListingSkuMapPagesItem.getSite());
//detail
dcBaseSkuMappingOnline.setItemSku(getListingSkuMapPagesItemDetail.getItemSku());
dcBaseSkuMappingOnline.setSkuCode(getListingSkuMapPagesItemDetail.getSkuCode());
return dcBaseSkuMappingOnline;
})
.collect(Collectors.toList()))
.flatMap(List::stream)
.collect(Collectors.toList());
dcBaseSkuMappingOnlineService.saveBatch(dcBaseSkuMappingOnlineList);
}
dcJobConfigMapper.updateById(dcJobConfig.refresh());
}
}
spring:
# 服务名称
application:
name: base-sync-sample
# 数据配置
datasource:
url: jdbc:mysql://10.0.8.15:3306/bailun_datacenter?serverTimezone=GMT%2B8&characterEncoding=utf-8&rewriteBatchedStatements=true
username: root
password: '#7kfnymAM$Y9-Ntf'
driver-class-name: com.mysql.jdbc.Driver
main:
allow-bean-definition-overriding: true
#mybatis plus 配置
mybatis-plus:
mapper-locations:
- classpath*:com/bailuntec/mapper/*.xml
# configuration:
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
feign:
hystrix:
enabled: false
client:
config:
default:
connectTimeout: 30000
readTimeout: 30000
server:
port: 8080
spring:
# 服务名称
application:
name: base-sync-sample
# 数据配置
datasource:
url: jdbc:mysql://gz-cdb-kp7s5i79.sql.tencentcdb.com:61691/bailun_datacenter?serverTimezone=GMT%2B8&characterEncoding=utf-8&rewriteBatchedStatements=true
username: root
password: '#7kfnymAM$Y9-Ntf'
driver-class-name: com.mysql.jdbc.Driver
main:
allow-bean-definition-overriding: true
#mybatis plus 配置
mybatis-plus:
mapper-locations:
- classpath*:com/bailuntec/mapper/*.xml
# configuration:
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
feign:
hystrix:
enabled: false
client:
config:
default:
connectTimeout: 30000
readTimeout: 30000
server:
port: 1224
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
<module>base-sync-company</module> <module>base-sync-company</module>
<module>base-sync-purchase-details</module> <module>base-sync-purchase-details</module>
<module>base-sync-ebay</module> <module>base-sync-ebay</module>
<module>base-sync-sku</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