Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
JDCLOUD
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gavelinfo
JDCLOUD
Commits
f13d85a3
Commit
f13d85a3
authored
Jun 16, 2022
by
zhoumaotao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整代码2
parent
b2b1958f
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
850 additions
and
0 deletions
+850
-0
README.md
gavel-web/datasyncweb/README.md
+3
-0
pom.xml
gavel-web/datasyncweb/gavel-datasync/pom.xml
+96
-0
DatasyncApplication.java
...src/main/java/com/gavel/datasync/DatasyncApplication.java
+13
-0
InitConfig.java
...c/src/main/java/com/gavel/datasync/config/InitConfig.java
+19
-0
RedisConfig.java
.../src/main/java/com/gavel/datasync/config/RedisConfig.java
+276
-0
DatasyncController.java
...ava/com/gavel/datasync/controller/DatasyncController.java
+90
-0
DatasyncService.java
...main/java/com/gavel/datasync/service/DatasyncService.java
+43
-0
DatasyncServiceImpl.java
.../com/gavel/datasync/service/impl/DatasyncServiceImpl.java
+237
-0
JDClientUtil.java
...c/src/main/java/com/gavel/datasync/util/JDClientUtil.java
+14
-0
application.properties
.../gavel-datasync/src/main/resources/application.properties
+2
-0
open-api-sdk-2.0-2022-03-15.jar
...vel-local/local-artifacts/open-api-sdk-2.0-2022-03-15.jar
+0
-0
pom.xml
gavel-web/datasyncweb/gavel-local/pom.xml
+44
-0
pom.xml
gavel-web/datasyncweb/pom.xml
+13
-0
No files found.
gavel-web/datasyncweb/README.md
0 → 100644
View file @
f13d85a3
# datasync
京东订单接口调用
\ No newline at end of file
gavel-web/datasyncweb/gavel-datasync/pom.xml
0 → 100644
View file @
f13d85a3
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-parent
</artifactId>
<version>
2.0.3.RELEASE
</version>
<relativePath/>
<!-- lookup parent from repository -->
</parent>
<groupId>
com.gavel.datasync
</groupId>
<artifactId>
datasync
</artifactId>
<version>
1.0.0
</version>
<name>
gavel-datasync
</name>
<description>
gavel-datasync
</description>
<properties>
<java.version>
1.8
</java.version>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-redis
</artifactId>
</dependency>
<dependency>
<groupId>
com.squareup.okhttp3
</groupId>
<artifactId>
okhttp
</artifactId>
<version>
3.8.1
</version>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
<version>
1.2.46
</version>
</dependency>
<dependency>
<groupId>
org.apache.commons
</groupId>
<artifactId>
commons-pool2
</artifactId>
</dependency>
<dependency>
<groupId>
com.google.guava
</groupId>
<artifactId>
guava
</artifactId>
<version>
19.0
</version>
</dependency>
<dependency>
<groupId>
commons-codec
</groupId>
<artifactId>
commons-codec
</artifactId>
</dependency>
<dependency>
<groupId>
org.apache.commons
</groupId>
<artifactId>
commons-lang3
</artifactId>
</dependency>
<dependency>
<groupId>
com.jd
</groupId>
<artifactId>
open-api-sdk
</artifactId>
<version>
1.0.0
</version>
</dependency>
<dependency>
<groupId>
com.gavel.platform
</groupId>
<artifactId>
gavel-common
</artifactId>
<version>
1.0.0
</version>
</dependency>
<dependency>
<groupId>
org.codehaus.jackson
</groupId>
<artifactId>
jackson-mapper-asl
</artifactId>
<version>
1.9.13
</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
</plugin>
</plugins>
</build>
</project>
gavel-web/datasyncweb/gavel-datasync/src/main/java/com/gavel/datasync/DatasyncApplication.java
0 → 100644
View file @
f13d85a3
package
com
.
gavel
.
datasync
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
@SpringBootApplication
public
class
DatasyncApplication
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
DatasyncApplication
.
class
,
args
);
}
}
gavel-web/datasyncweb/gavel-datasync/src/main/java/com/gavel/datasync/config/InitConfig.java
0 → 100644
View file @
f13d85a3
package
com
.
gavel
.
datasync
.
config
;
import
org.springframework.boot.CommandLineRunner
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.core.annotation.Order
;
import
org.springframework.stereotype.Component
;
@Configuration
public
class
InitConfig
{
@Component
@Order
(
0
)
//通过order值的大小来决定启动的顺序
public
class
CollectorRunner
implements
CommandLineRunner
{
@Override
public
void
run
(
String
...
args
)
throws
Exception
{
}
}
}
gavel-web/datasyncweb/gavel-datasync/src/main/java/com/gavel/datasync/config/RedisConfig.java
0 → 100644
View file @
f13d85a3
package
com
.
gavel
.
datasync
.
config
;
import
java.time.Duration
;
import
org.apache.commons.pool2.impl.GenericObjectPoolConfig
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.autoconfigure.data.redis.RedisProperties
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.data.redis.connection.RedisPassword
;
import
org.springframework.data.redis.connection.RedisStandaloneConfiguration
;
import
org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration
;
import
org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory
;
import
org.springframework.data.redis.connection.lettuce.LettucePoolingClientConfiguration
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer
;
import
org.springframework.data.redis.serializer.StringRedisSerializer
;
import
com.fasterxml.jackson.annotation.JsonAutoDetect
;
import
com.fasterxml.jackson.annotation.PropertyAccessor
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
@Configuration
public
class
RedisConfig
{
@Autowired
private
RedisProperties
redisProperties
;
@Value
(
"${redis.username:}"
)
private
String
username
;
@Value
(
"${redis.password:}"
)
private
String
password
;
@Value
(
"${redis.host:localhost}"
)
private
String
host
;
@Value
(
"${redis.port:6379}"
)
private
int
port
;
@Value
(
"${redis.database:0}"
)
private
Integer
database
;
//最大空闲数
@Value
(
"${redis.pool.maxIdle:20}"
)
private
int
maxIdle
;
//控制一个pool可分配多少个jedis实例,用来替换上面的maxActive
@Value
(
"${redis.pool.maxTotal:200}"
)
private
int
maxTotal
;
//连接池的最大数据库连接数
@Value
(
"${redis.pool.maxActive:-1}"
)
private
int
maxActive
;
//最大建立连接等待时间。如果超过此时间将接到异常
@Value
(
"${redis.pool.maxWaitMillis:1000}"
)
private
long
maxWaitMillis
;
//逐出连接的最小空闲时间 默认1800000毫秒(30分钟)
@Value
(
"${redis.pool.minEvictableIdleTimeMillis:1800000}"
)
private
Long
minEvictableIdleTimeMillis
;
//每次释放连接的最大数目
@Value
(
"${redis.pool.numTestsPerEvictionRun:3}"
)
private
Integer
numTestsPerEvictionRun
;
//逐出扫描的时间间隔(毫秒) 如果为负数,则不运行逐出线程
@Value
(
"${redis.pool.timeBetweenEvictionRunsMillis:-1}"
)
private
Long
timeBetweenEvictionRunsMillis
;
//是否在从池中取出连接前进行检验,如果检验失败,则从池中取出连接并尝试取出另一个
@Value
(
"${redis.pool.testOnBorrow:true}"
)
private
boolean
testOnBorrow
;
//#在空闲时检查有效性, 默认false
@Value
(
"${redis.pool.testWhileIdle:false}"
)
private
boolean
testWhileIdle
;
//#是否进行有效性检查
@Value
(
"${redis.pool.testOnReturn:false}"
)
private
boolean
testOnReturn
;
/**
* JedisPoolConfig 连接池
* @return
*/
@Bean
(
"genericObjectPoolConfig"
)
public
GenericObjectPoolConfig
genericObjectPoolConfig
()
{
//连接池配置
GenericObjectPoolConfig
genericObjectPoolConfig
=
new
GenericObjectPoolConfig
();
// 最大空闲数
genericObjectPoolConfig
.
setMaxIdle
(
maxIdle
);
// 连接池的最大数据库连接数
genericObjectPoolConfig
.
setMaxTotal
(
maxTotal
);
// 最大建立连接等待时间
genericObjectPoolConfig
.
setMaxWaitMillis
(
maxWaitMillis
);
// 逐出连接的最小空闲时间 默认1800000毫秒(30分钟)
genericObjectPoolConfig
.
setMinEvictableIdleTimeMillis
(
minEvictableIdleTimeMillis
);
// 每次逐出检查时 逐出的最大数目 如果为负数就是 : 1/abs(n), 默认3
genericObjectPoolConfig
.
setNumTestsPerEvictionRun
(
numTestsPerEvictionRun
);
// 逐出扫描的时间间隔(毫秒) 如果为负数,则不运行逐出线程, 默认-1
genericObjectPoolConfig
.
setTimeBetweenEvictionRunsMillis
(
timeBetweenEvictionRunsMillis
);
// 是否在从池中取出连接前进行检验,如果检验失败,则从池中去除连接并尝试取出另一个
genericObjectPoolConfig
.
setTestOnBorrow
(
testOnBorrow
);
// 在空闲时检查有效性, 默认false
genericObjectPoolConfig
.
setTestWhileIdle
(
testWhileIdle
);
return
genericObjectPoolConfig
;
}
/**
* jedis连接工厂
* @return
*/
@Primary
@Bean
(
"lettuceConnectionFactory"
)
public
LettuceConnectionFactory
lettuceConnectionFactory
()
{
RedisStandaloneConfiguration
redisStandaloneConfiguration
=
new
RedisStandaloneConfiguration
();
//设置redis服务器的host或者ip地址
redisStandaloneConfiguration
.
setHostName
(
host
);
redisStandaloneConfiguration
.
setPort
(
port
);
redisStandaloneConfiguration
.
setPassword
(
RedisPassword
.
of
(
password
));
redisStandaloneConfiguration
.
setDatabase
(
database
);
return
new
LettuceConnectionFactory
(
redisStandaloneConfiguration
,
lettuceClientConfiguration
());
}
private
LettuceClientConfiguration
lettuceClientConfiguration
(){
LettucePoolingClientConfiguration
.
LettucePoolingClientConfigurationBuilder
builder
=
LettucePoolingClientConfiguration
.
builder
();
builder
.
poolConfig
(
genericObjectPoolConfig
());
if
(
this
.
redisProperties
.
isSsl
())
{
builder
.
useSsl
();
}
if
(
this
.
redisProperties
.
getTimeout
()
!=
null
)
{
Duration
timeout
=
this
.
redisProperties
.
getTimeout
();
builder
.
commandTimeout
(
timeout
).
shutdownTimeout
(
timeout
);
}
builder
.
poolConfig
(
genericObjectPoolConfig
());
return
builder
.
build
();
}
@Bean
(
"redisTemplate"
)
public
RedisTemplate
<
String
,
Object
>
redisTemplate
(
LettuceConnectionFactory
connectionFactory
)
{
RedisTemplate
<
String
,
Object
>
template
=
new
RedisTemplate
<
String
,
Object
>();
template
.
setConnectionFactory
(
lettuceConnectionFactory
());
Jackson2JsonRedisSerializer
<
Object
>
jackson2JsonRedisSerializer
=
new
Jackson2JsonRedisSerializer
<>(
Object
.
class
);
ObjectMapper
om
=
new
ObjectMapper
();
om
.
setVisibility
(
PropertyAccessor
.
ALL
,
JsonAutoDetect
.
Visibility
.
ANY
);
om
.
enableDefaultTyping
(
ObjectMapper
.
DefaultTyping
.
NON_FINAL
);
jackson2JsonRedisSerializer
.
setObjectMapper
(
om
);
StringRedisSerializer
stringRedisSerializer
=
new
StringRedisSerializer
();
// key采用String的序列化方式
template
.
setKeySerializer
(
stringRedisSerializer
);
// hash的key也采用String的序列化方式
template
.
setHashKeySerializer
(
stringRedisSerializer
);
// value序列化方式采用jackson
template
.
setValueSerializer
(
jackson2JsonRedisSerializer
);
// hash的value序列化方式采用jackson
template
.
setHashValueSerializer
(
jackson2JsonRedisSerializer
);
//redis开启事务保证所有命令串行执行
template
.
setEnableTransactionSupport
(
true
);
template
.
afterPropertiesSet
();
return
template
;
}
public
String
getUsername
()
{
return
username
;
}
public
void
setUsername
(
String
username
)
{
this
.
username
=
username
;
}
public
String
getPassword
()
{
return
password
;
}
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
public
String
getHost
()
{
return
host
;
}
public
void
setHost
(
String
host
)
{
this
.
host
=
host
;
}
public
int
getPort
()
{
return
port
;
}
public
void
setPort
(
int
port
)
{
this
.
port
=
port
;
}
public
Integer
getDatabase
()
{
return
database
;
}
public
void
setDatabase
(
Integer
database
)
{
this
.
database
=
database
;
}
public
int
getMaxIdle
()
{
return
maxIdle
;
}
public
void
setMaxIdle
(
int
maxIdle
)
{
this
.
maxIdle
=
maxIdle
;
}
public
int
getMaxTotal
()
{
return
maxTotal
;
}
public
void
setMaxTotal
(
int
maxTotal
)
{
this
.
maxTotal
=
maxTotal
;
}
public
int
getMaxActive
()
{
return
maxActive
;
}
public
void
setMaxActive
(
int
maxActive
)
{
this
.
maxActive
=
maxActive
;
}
public
long
getMaxWaitMillis
()
{
return
maxWaitMillis
;
}
public
void
setMaxWaitMillis
(
long
maxWaitMillis
)
{
this
.
maxWaitMillis
=
maxWaitMillis
;
}
public
Long
getMinEvictableIdleTimeMillis
()
{
return
minEvictableIdleTimeMillis
;
}
public
void
setMinEvictableIdleTimeMillis
(
Long
minEvictableIdleTimeMillis
)
{
this
.
minEvictableIdleTimeMillis
=
minEvictableIdleTimeMillis
;
}
public
Integer
getNumTestsPerEvictionRun
()
{
return
numTestsPerEvictionRun
;
}
public
void
setNumTestsPerEvictionRun
(
Integer
numTestsPerEvictionRun
)
{
this
.
numTestsPerEvictionRun
=
numTestsPerEvictionRun
;
}
public
Long
getTimeBetweenEvictionRunsMillis
()
{
return
timeBetweenEvictionRunsMillis
;
}
public
void
setTimeBetweenEvictionRunsMillis
(
Long
timeBetweenEvictionRunsMillis
)
{
this
.
timeBetweenEvictionRunsMillis
=
timeBetweenEvictionRunsMillis
;
}
public
boolean
isTestOnBorrow
()
{
return
testOnBorrow
;
}
public
void
setTestOnBorrow
(
boolean
testOnBorrow
)
{
this
.
testOnBorrow
=
testOnBorrow
;
}
public
boolean
isTestWhileIdle
()
{
return
testWhileIdle
;
}
public
void
setTestWhileIdle
(
boolean
testWhileIdle
)
{
this
.
testWhileIdle
=
testWhileIdle
;
}
public
boolean
isTestOnReturn
()
{
return
testOnReturn
;
}
public
void
setTestOnReturn
(
boolean
testOnReturn
)
{
this
.
testOnReturn
=
testOnReturn
;
}
}
gavel-web/datasyncweb/gavel-datasync/src/main/java/com/gavel/datasync/controller/DatasyncController.java
0 → 100644
View file @
f13d85a3
package
com
.
gavel
.
datasync
.
controller
;
import
com.alibaba.fastjson.JSONObject
;
import
com.gavel.datasync.service.DatasyncService
;
import
com.jd.open.api.sdk.domain.supplier.IDpsSearchAllOrdersInterface.response.searchAllOrders.QueryAllOrdersForJosResult
;
import
com.jd.open.api.sdk.domain.supplier.ProductManagementService.response.find.CategoryDto
;
import
com.jd.open.api.sdk.domain.supplier.ProductManagementService.response.find.MyProductInfoDto
;
import
com.jd.open.api.sdk.domain.supplier.ProductManagementService.response.find.SimpleBrandDto
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.Date
;
import
java.util.List
;
@RestController
public
class
DatasyncController
{
@Autowired
private
DatasyncService
datasyncService
;
@PostMapping
(
"/datasync"
)
@ResponseBody
public
Object
httpDoTran
(
@RequestBody
JSONObject
param
){
return
"success!"
;
}
/**
* 获取类目接口查询
*/
@PostMapping
(
"/getCategories"
)
@ResponseBody
public
Object
getCategories
(
@RequestBody
JSONObject
param
)
{
List
<
CategoryDto
>
categoryDtoList
=
datasyncService
.
getCategories
();
return
categoryDtoList
;
}
/**
* 获取品牌接口查询
*/
@PostMapping
(
"/getBrands"
)
@ResponseBody
public
Object
getBrands
(
@RequestBody
JSONObject
param
)
{
List
<
SimpleBrandDto
>
simpleBrandDtoList
=
datasyncService
.
getBrands
();
return
simpleBrandDtoList
;
}
/**
* 获取商品接口
*/
@PostMapping
(
"/getProducts"
)
@ResponseBody
public
Object
getProducts
(
@RequestBody
JSONObject
param
)
{
Date
time
=
param
.
getDate
(
"time"
);
String
brandid
=
param
.
getString
(
"brandid"
);
String
categoryid
=
param
.
getString
(
"categoryid"
);
List
<
MyProductInfoDto
>
myProductInfoDtoList
=
datasyncService
.
getProducts
(
time
,
brandid
,
categoryid
);
return
myProductInfoDtoList
;
}
/**
* 获取查询订单
*/
@PostMapping
(
"/searchOrders"
)
@ResponseBody
public
Object
searchOrders
(
@RequestBody
JSONObject
param
)
{
Date
start
=
param
.
getDate
(
"start"
);
Date
end
=
param
.
getDate
(
"end"
);
List
<
QueryAllOrdersForJosResult
>
resultLists
=
datasyncService
.
searchOrders
(
start
,
end
);
return
resultLists
;
}
/**
* 获取查询订单
*/
@PostMapping
(
"/searchOrders2"
)
@ResponseBody
public
Object
searchOrders2
(
@RequestBody
JSONObject
param
)
{
Date
start
=
param
.
getDate
(
"start"
);
Date
end
=
param
.
getDate
(
"end"
);
List
<
QueryAllOrdersForJosResult
>
resultLists
=
datasyncService
.
searchOrders2
(
start
,
end
);
return
resultLists
;
}
}
gavel-web/datasyncweb/gavel-datasync/src/main/java/com/gavel/datasync/service/DatasyncService.java
0 → 100644
View file @
f13d85a3
package
com
.
gavel
.
datasync
.
service
;
import
com.jd.open.api.sdk.domain.supplier.IDpsSearchAllOrdersInterface.response.searchAllOrders.QueryAllOrdersForJosResult
;
import
com.jd.open.api.sdk.domain.supplier.ProductManagementService.response.find.CategoryDto
;
import
com.jd.open.api.sdk.domain.supplier.ProductManagementService.response.find.MyProductInfoDto
;
import
com.jd.open.api.sdk.domain.supplier.ProductManagementService.response.find.SimpleBrandDto
;
import
java.util.Date
;
import
java.util.List
;
public
interface
DatasyncService
{
/**
* 获取类目接口查询
* @return
*/
public
List
<
CategoryDto
>
getCategories
();
/**
* 获取品牌接口查询
* @return
*/
public
List
<
SimpleBrandDto
>
getBrands
();
/**
* 获取商品接口
* @param time
* @param brandid
* @param categoryid
* @return
*/
public
List
<
MyProductInfoDto
>
getProducts
(
Date
time
,
String
brandid
,
String
categoryid
);
/**
* 获取订单信息
* @param start
* @param end
* @return
*/
public
List
<
QueryAllOrdersForJosResult
>
searchOrders
(
Date
start
,
Date
end
);
public
List
<
QueryAllOrdersForJosResult
>
searchOrders2
(
Date
start
,
Date
end
);
}
gavel-web/datasyncweb/gavel-datasync/src/main/java/com/gavel/datasync/service/impl/DatasyncServiceImpl.java
0 → 100644
View file @
f13d85a3
package
com
.
gavel
.
datasync
.
service
.
impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.gavel.common.utils.DateUtils
;
import
com.gavel.common.utils.NumberUtils
;
import
com.gavel.datasync.service.DatasyncService
;
import
com.gavel.datasync.util.JDClientUtil
;
import
com.jd.open.api.sdk.DefaultJdClient
;
import
com.jd.open.api.sdk.JdClient
;
import
com.jd.open.api.sdk.domain.supplier.IDpsSearchAllOrdersInterface.response.searchAllOrders.QueryAllOrdersForJosResult
;
import
com.jd.open.api.sdk.domain.supplier.ProductManagementService.response.find.CategoryDto
;
import
com.jd.open.api.sdk.domain.supplier.ProductManagementService.response.find.MyProductInfoDto
;
import
com.jd.open.api.sdk.domain.supplier.ProductManagementService.response.find.SimpleBrandDto
;
import
com.jd.open.api.sdk.request.supplier.DropshipDpsSearchAllOrdersRequest
;
import
com.jd.open.api.sdk.request.supplier.VcItemBrandsFindRequest
;
import
com.jd.open.api.sdk.request.supplier.VcItemCategoriesFindRequest
;
import
com.jd.open.api.sdk.request.supplier.VcItemProductsFindRequest
;
import
com.jd.open.api.sdk.response.supplier.DropshipDpsSearchAllOrdersResponse
;
import
com.jd.open.api.sdk.response.supplier.VcItemBrandsFindResponse
;
import
com.jd.open.api.sdk.response.supplier.VcItemCategoriesFindResponse
;
import
com.jd.open.api.sdk.response.supplier.VcItemProductsFindResponse
;
import
com.jd.security.tde.InvalidKeyPermission
;
import
com.jd.security.tde.InvalidTokenException
;
import
com.jd.security.tde.MalformedException
;
import
com.jd.security.tdeclient.*
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Service
;
import
javax.crypto.BadPaddingException
;
import
javax.crypto.IllegalBlockSizeException
;
import
javax.crypto.NoSuchPaddingException
;
import
java.io.IOException
;
import
java.security.InvalidAlgorithmParameterException
;
import
java.security.InvalidKeyException
;
import
java.security.NoSuchAlgorithmException
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
@Service
public
class
DatasyncServiceImpl
implements
DatasyncService
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
DatasyncServiceImpl
.
class
);
@Override
public
List
<
CategoryDto
>
getCategories
()
{
JdClient
client
=
createClient
();
VcItemCategoriesFindRequest
request
=
new
VcItemCategoriesFindRequest
();
try
{
VcItemCategoriesFindResponse
response
=
client
.
execute
(
request
);
return
response
.
getJosResultDto
().
getResult
();
}
catch
(
Exception
e
)
{
logger
.
error
(
"========类目信息错误!!! ==========="
+
e
);
}
return
null
;
}
@Override
public
List
<
SimpleBrandDto
>
getBrands
()
{
JdClient
client
=
createClient
();
VcItemBrandsFindRequest
request
=
new
VcItemBrandsFindRequest
();
try
{
VcItemBrandsFindResponse
response
=
client
.
execute
(
request
);
return
response
.
getJosResultDto
().
getResult
();
}
catch
(
Exception
e
)
{
logger
.
error
(
"========品牌信息错误!!! ==========="
+
e
);
}
return
null
;
}
@Override
public
List
<
MyProductInfoDto
>
getProducts
(
Date
time
,
String
brandid
,
String
categoryid
)
{
try
{
JdClient
client
=
createClient
();
VcItemProductsFindRequest
request
=
new
VcItemProductsFindRequest
();
final
int
PAGE_SIZE
=
50
;
request
.
setOffset
(
0
);
request
.
setPageSize
(
PAGE_SIZE
);
request
.
setBrandId
(
Integer
.
valueOf
(
brandid
));
request
.
setCategoryId
(
Integer
.
valueOf
(
categoryid
));
request
.
setBeginModifyTime
(
time
);
VcItemProductsFindResponse
response
=
client
.
execute
(
request
);
if
(
response
==
null
)
{
logger
.
error
(
"商品信息为空!"
);
return
null
;
}
if
(!
"0"
.
equalsIgnoreCase
(
response
.
getCode
()))
{
logger
.
error
(
response
.
getZhDesc
());
return
null
;
}
int
offset
=
0
;
int
nextPageNo
=
0
;
List
<
MyProductInfoDto
>
addUProductList
=
new
ArrayList
<>();
int
totalPageNo
=
response
.
getJosResultDto
().
getCount
()/
PAGE_SIZE
;
while
(!
NumberUtils
.
Greater
(
nextPageNo
,
totalPageNo
)
)
{
request
.
setOffset
(
offset
);
if
(
nextPageNo
>
0
){
response
=
client
.
execute
(
request
);
}
List
<
MyProductInfoDto
>
productInfoDtos
=
response
.
getJosResultDto
().
getResult
();
nextPageNo
=
nextPageNo
+
1
;
offset
=
nextPageNo
*
50
;
addUProductList
.
addAll
(
productInfoDtos
);
}
return
addUProductList
;
}
catch
(
Exception
e
){
logger
.
error
(
"========商品信息错误!!! ==========="
+
e
);
}
return
null
;
}
@Override
public
List
<
QueryAllOrdersForJosResult
>
searchOrders
(
Date
start
,
Date
end
)
{
try
{
JdClient
client
=
createClient
();
final
int
PAGE_SIZE
=
50
;
DropshipDpsSearchAllOrdersRequest
request
=
new
DropshipDpsSearchAllOrdersRequest
();
request
.
setPage
(
1
);
request
.
setPageSize
(
PAGE_SIZE
);
request
.
setModifiedBeginDate
(
DateUtils
.
beginOfDay
(
start
));
//修改开始时间
request
.
setModifiedEndDate
(
DateUtils
.
endOfDay
(
end
));
//修改开始时间
logger
.
info
(
"订单调用1"
);
DropshipDpsSearchAllOrdersResponse
response
=
client
.
execute
(
request
);
logger
.
info
(
"订单调用2"
);
if
(
response
==
null
)
{
logger
.
error
(
"订单信息为空!"
);
return
null
;
}
if
(!
"0"
.
equalsIgnoreCase
(
response
.
getCode
()))
{
logger
.
error
(
response
.
getZhDesc
());
return
null
;
}
List
<
QueryAllOrdersForJosResult
>
allOrdersForJosResults
=
new
ArrayList
<>();
int
totalPageNo
=
response
.
getSearchallordersResult
().
getRecordCount
()/
PAGE_SIZE
+
1
;
int
nextPageNo
=
1
;
while
(!
NumberUtils
.
Greater
(
nextPageNo
,
totalPageNo
))
{
request
.
setPage
(
nextPageNo
);
if
(
nextPageNo
>
1
){
response
=
client
.
execute
(
request
);
}
List
<
QueryAllOrdersForJosResult
>
resultList
=
response
.
getSearchallordersResult
().
getQueryAllOrdersForJosResult
();
//订单数据
for
(
QueryAllOrdersForJosResult
result
:
resultList
){
//consigneeName|telephone|phone|address|email
result
.
setConsigneeName
(
getValue
(
result
.
getConsigneeName
()));
result
.
setTelephone
(
getValue
(
result
.
getTelephone
()));
result
.
setPhone
(
getValue
(
result
.
getPhone
()));
result
.
setAddress
(
getValue
(
result
.
getAddress
()));
result
.
setEmail
(
getValue
(
result
.
getEmail
()));
}
nextPageNo
=
nextPageNo
+
1
;
allOrdersForJosResults
.
addAll
(
resultList
);
}
logger
.
info
(
"订单结果记录条数"
,
allOrdersForJosResults
.
size
());
return
allOrdersForJosResults
;
}
catch
(
Exception
e
)
{
logger
.
error
(
"========订单信息错误!!! ==========="
+
e
);
}
return
null
;
}
@Override
public
List
<
QueryAllOrdersForJosResult
>
searchOrders2
(
Date
start
,
Date
end
)
{
try
{
JdClient
client
=
createClient
();
final
int
PAGE_SIZE
=
50
;
DropshipDpsSearchAllOrdersRequest
request
=
new
DropshipDpsSearchAllOrdersRequest
();
request
.
setPage
(
1
);
request
.
setPageSize
(
PAGE_SIZE
);
request
.
setBeginDate
(
DateUtils
.
beginOfDay
(
start
));
//修改开始时间
request
.
setEndDate
(
DateUtils
.
endOfDay
(
end
));
//修改开始时间
logger
.
info
(
"订单调用1"
);
DropshipDpsSearchAllOrdersResponse
response
=
client
.
execute
(
request
);
logger
.
info
(
"订单调用2"
);
if
(
response
==
null
)
{
logger
.
error
(
"订单信息为空!"
);
return
null
;
}
if
(!
"0"
.
equalsIgnoreCase
(
response
.
getCode
()))
{
logger
.
error
(
response
.
getZhDesc
());
return
null
;
}
List
<
QueryAllOrdersForJosResult
>
allOrdersForJosResults
=
new
ArrayList
<>();
int
totalPageNo
=
response
.
getSearchallordersResult
().
getRecordCount
()/
PAGE_SIZE
+
1
;
int
nextPageNo
=
1
;
while
(!
NumberUtils
.
Greater
(
nextPageNo
,
totalPageNo
))
{
request
.
setPage
(
nextPageNo
);
if
(
nextPageNo
>
1
){
response
=
client
.
execute
(
request
);
}
List
<
QueryAllOrdersForJosResult
>
resultList
=
response
.
getSearchallordersResult
().
getQueryAllOrdersForJosResult
();
//订单数据
for
(
QueryAllOrdersForJosResult
result
:
resultList
){
//consigneeName|telephone|phone|address|email
result
.
setConsigneeName
(
getValue
(
result
.
getConsigneeName
()));
result
.
setTelephone
(
getValue
(
result
.
getTelephone
()));
result
.
setPhone
(
getValue
(
result
.
getPhone
()));
result
.
setAddress
(
getValue
(
result
.
getAddress
()));
result
.
setEmail
(
getValue
(
result
.
getEmail
()));
}
nextPageNo
=
nextPageNo
+
1
;
allOrdersForJosResults
.
addAll
(
resultList
);
}
logger
.
info
(
"订单结果记录条数"
,
allOrdersForJosResults
.
size
());
return
allOrdersForJosResults
;
}
catch
(
Exception
e
)
{
logger
.
error
(
"========订单信息错误!!! ==========="
+
e
);
}
return
null
;
}
private
JdClient
createClient
()
{
return
new
DefaultJdClient
(
JDClientUtil
.
SERVER_URL
,
JDClientUtil
.
ACCESS_TOKEN
,
JDClientUtil
.
APPKEY
,
JDClientUtil
.
APPSECRET
);
}
private
TDEClient
getTdeClient
()
{
TDEClient
tdeClient
=
null
;
try
{
tdeClient
=
SecretJdClient
.
getInstance
(
JDClientUtil
.
SERVER_URL
,
JDClientUtil
.
ACCESS_TOKEN
,
JDClientUtil
.
APPKEY
,
JDClientUtil
.
APPSECRET
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"错误信息P01"
,
e
.
getMessage
());
}
return
tdeClient
;
}
private
String
getValue
(
String
val
){
TDEClient
tdeClient
=
getTdeClient
();
String
s
=
""
;
try
{
s
=
tdeClient
.
decryptString
(
val
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"错误信息P02"
,
e
.
getMessage
());
}
return
s
;
}
}
gavel-web/datasyncweb/gavel-datasync/src/main/java/com/gavel/datasync/util/JDClientUtil.java
0 → 100644
View file @
f13d85a3
package
com
.
gavel
.
datasync
.
util
;
public
class
JDClientUtil
{
// 正式环境
public
static
final
String
SERVER_URL
=
"https://api.jd.com/routerjson"
;
public
static
final
String
APPKEY
=
"FEAFBABCDEEC48A569A10818138D7841"
;
public
static
final
String
APPSECRET
=
"36c196b5b2ea4c2aaaae6d80010a28a8"
;
public
static
final
String
ACCESS_TOKEN
=
"1d4a07ea9743455d99c2f7f63e2f7971a3zw"
;
}
gavel-web/datasyncweb/gavel-datasync/src/main/resources/application.properties
0 → 100644
View file @
f13d85a3
#服务器端口
server.port
=
9080
\ No newline at end of file
gavel-web/datasyncweb/gavel-local/local-artifacts/open-api-sdk-2.0-2022-03-15.jar
0 → 100644
View file @
f13d85a3
File added
gavel-web/datasyncweb/gavel-local/pom.xml
0 → 100644
View file @
f13d85a3
<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"
>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
com.gavel.local
</groupId>
<artifactId>
gavel-local
</artifactId>
<version>
1.0.0
</version>
<packaging>
pom
</packaging>
<name>
gavel-local
</name>
<build>
<plugins>
<plugin>
<artifactId>
maven-install-plugin
</artifactId>
<version>
2.2
</version>
<executions>
<execution>
<id>
open-api-sdk
</id>
<phase>
install
</phase>
<goals>
<goal>
install-file
</goal>
</goals>
<configuration>
<file>
local-artifacts/open-api-sdk-2.0-2022-03-15.jar
</file>
<groupId>
com.jd
</groupId>
<artifactId>
open-api-sdk
</artifactId>
<version>
1.0.0
</version>
<packaging>
jar
</packaging>
<generatePom>
true
</generatePom>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>
maven-resources-plugin
</artifactId>
<version>
2.5
</version>
<configuration>
<encoding>
UTF-8
</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
gavel-web/datasyncweb/pom.xml
0 → 100644
View file @
f13d85a3
<?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/maven-v4_0_0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
com.gavel.dasyncweb
</groupId>
<artifactId>
dasyncweb
</artifactId>
<packaging>
pom
</packaging>
<version>
1.0
</version>
<modules>
<module>
gavel-local
</module>
<module>
gavel-datasync
</module>
</modules>
</project>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment