记得上下班打卡 | git大法好,push需谨慎
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liquidnet-bus-v1
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
董敬伟
liquidnet-bus-v1
Commits
4ffbd16b
Commit
4ffbd16b
authored
Aug 23, 2021
by
jiangxiulong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
redis
parent
89388ab8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
146 additions
and
69 deletions
+146
-69
pom.xml
liquidnet-bus-service/liquidnet-service-sweet/pom.xml
+4
-0
JxlDataImpl.java
...net/service/sweet/service/impl/syncRedis/JxlDataImpl.java
+142
-69
No files found.
liquidnet-bus-service/liquidnet-service-sweet/pom.xml
View file @
4ffbd16b
...
@@ -65,6 +65,10 @@
...
@@ -65,6 +65,10 @@
<version>
1.0-SNAPSHOT
</version>
<version>
1.0-SNAPSHOT
</version>
<scope>
compile
</scope>
<scope>
compile
</scope>
</dependency>
</dependency>
<dependency>
<groupId>
redis.clients
</groupId>
<artifactId>
jedis
</artifactId>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
...
...
liquidnet-bus-service/liquidnet-service-sweet/src/main/java/com/liquidnet/service/sweet/service/impl/syncRedis/JxlDataImpl.java
View file @
4ffbd16b
package
com
.
liquidnet
.
service
.
sweet
.
service
.
impl
.
syncRedis
;
package
com
.
liquidnet
.
service
.
sweet
.
service
.
impl
.
syncRedis
;
import
com.fasterxml.jackson.annotation.JsonAutoDetect
;
import
com.fasterxml.jackson.annotation.PropertyAccessor
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.SerializationFeature
;
import
com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
;
import
com.liquidnet.common.cache.redis.util.RedisUtil
;
import
com.liquidnet.common.cache.redis.util.RedisUtil
;
import
com.liquidnet.service.adam.dto.vo.admin.AdminUpushVo
;
import
com.liquidnet.service.adam.dto.vo.admin.AdminUpushVo
;
import
com.liquidnet.service.kylin.constant.KylinRedisConst
;
import
com.liquidnet.service.kylin.constant.KylinRedisConst
;
...
@@ -11,6 +17,8 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -11,6 +17,8 @@ import lombok.extern.slf4j.Slf4j;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
redis.clients.jedis.Jedis
;
import
redis.clients.jedis.JedisPool
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.LinkedList
;
import
java.util.LinkedList
;
...
@@ -23,38 +31,72 @@ public class JxlDataImpl {
...
@@ -23,38 +31,72 @@ public class JxlDataImpl {
@Autowired
@Autowired
private
RedisUtil
redisUtil
;
private
RedisUtil
redisUtil
;
private
static
final
JedisPool
jedisPool
;
private
static
final
ObjectMapper
toObjMapper
;
static
{
jedisPool
=
new
JedisPool
(
"zhengzai.redis.rds.aliyuncs.com"
,
6380
);
toObjMapper
=
new
ObjectMapper
();
toObjMapper
.
setVisibility
(
PropertyAccessor
.
ALL
,
JsonAutoDetect
.
Visibility
.
ANY
);
toObjMapper
.
disable
(
SerializationFeature
.
WRITE_DATES_AS_TIMESTAMPS
);
toObjMapper
.
registerModule
(
new
JavaTimeModule
());
toObjMapper
.
activateDefaultTyping
(
toObjMapper
.
getPolymorphicTypeValidator
(),
ObjectMapper
.
DefaultTyping
.
NON_FINAL
);
}
private
Jedis
getRedis
()
{
Jedis
resource
=
jedisPool
.
getResource
();
resource
.
auth
(
"NBs$%6hW"
);
resource
.
select
(
15
);
return
resource
;
}
public
Boolean
basicServicesVersions
()
{
public
Boolean
basicServicesVersions
()
{
RedisTemplate
<
String
,
Object
>
redisTemplateByDb
=
redisUtil
.
getRedisTemplateByDb
(
15
);
try
{
// RedisTemplate<String, Object> redis = redisUtil.getRedisTemplateByDb(15);
Jedis
redis
=
getRedis
();
String
appAndroid
=
KylinRedisConst
.
ZHENGZAI_APP_VERSIONS_ANDROID
;
String
appAndroid
=
KylinRedisConst
.
ZHENGZAI_APP_VERSIONS_ANDROID
;
String
appIos
=
KylinRedisConst
.
ZHENGZAI_APP_VERSIONS_IOS
;
String
appIos
=
KylinRedisConst
.
ZHENGZAI_APP_VERSIONS_IOS
;
String
checkAndroid
=
KylinRedisConst
.
ZHENGZAI_APP_VERSIONS_CHECK_ANDROID
;
String
checkAndroid
=
KylinRedisConst
.
ZHENGZAI_APP_VERSIONS_CHECK_ANDROID
;
String
checkIos
=
KylinRedisConst
.
ZHENGZAI_APP_VERSIONS_CHECK_IOS
;
String
checkIos
=
KylinRedisConst
.
ZHENGZAI_APP_VERSIONS_CHECK_IOS
;
ZhengzaiAppVersionsVo
appAndroidValue
=
(
ZhengzaiAppVersionsVo
)
redisTemplateByDb
.
opsForValue
().
get
(
appAndroid
);
ZhengzaiAppVersionsVo
appAndroidValue
=
toObjMapper
.
readValue
(
redis
.
get
(
appAndroid
),
ZhengzaiAppVersionsVo
.
class
);
redisUtil
.
set
(
appAndroid
,
appAndroidValue
);
redisUtil
.
set
(
appAndroid
,
appAndroidValue
);
ZhengzaiAppVersionsVo
appIosValue
=
(
ZhengzaiAppVersionsVo
)
redisTemplateByDb
.
opsForValue
().
get
(
appIo
s
);
ZhengzaiAppVersionsVo
appIosValue
=
toObjMapper
.
readValue
(
redis
.
get
(
appIos
),
ZhengzaiAppVersionsVo
.
clas
s
);
redisUtil
.
set
(
appIos
,
appIosValue
);
redisUtil
.
set
(
appIos
,
appIosValue
);
ZhengzaiAppVersionsVo
checkAndroidValue
=
(
ZhengzaiAppVersionsVo
)
redisTemplateByDb
.
opsForValue
().
get
(
checkAndroid
);
ZhengzaiAppVersionsVo
checkAndroidValue
=
toObjMapper
.
readValue
(
redis
.
get
(
checkAndroid
),
ZhengzaiAppVersionsVo
.
class
);
redisUtil
.
set
(
checkAndroid
,
checkAndroidValue
);
redisUtil
.
set
(
checkAndroid
,
checkAndroidValue
);
ZhengzaiAppVersionsVo
checkIosValue
=
(
ZhengzaiAppVersionsVo
)
redisTemplateByDb
.
opsForValue
().
get
(
checkIo
s
);
ZhengzaiAppVersionsVo
checkIosValue
=
toObjMapper
.
readValue
(
redis
.
get
(
checkIos
),
ZhengzaiAppVersionsVo
.
clas
s
);
redisUtil
.
set
(
checkIos
,
checkIosValue
);
redisUtil
.
set
(
checkIos
,
checkIosValue
);
return
true
;
return
true
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
false
;
}
}
}
public
Boolean
basicServicesUpush
()
{
public
Boolean
basicServicesUpush
()
{
RedisTemplate
<
String
,
Object
>
redisTemplateByDb
=
redisUtil
.
getRedisTemplateByDb
(
15
);
try
{
// RedisTemplate<String, Object> redis = redisUtil.getRedisTemplateByDb(15);
Jedis
redis
=
getRedis
();
String
pushAndroid
=
KylinRedisConst
.
ADMIN_UPUSH_LIST_IOS
;
String
pushAndroid
=
KylinRedisConst
.
ADMIN_UPUSH_LIST_IOS
;
String
pushIos
=
KylinRedisConst
.
ADMIN_UPUSH_LIST_ANDROID
;
String
pushIos
=
KylinRedisConst
.
ADMIN_UPUSH_LIST_ANDROID
;
LinkedList
<
AdminUpushVo
>
pushAndroidList
=
(
LinkedList
<
AdminUpushVo
>)
redisTemplateByDb
.
opsForValue
().
get
(
pushAndroid
);
// LinkedList<AdminUpushVo> pushAndroidList = (LinkedList<AdminUpushVo>) redis.get(pushAndroid);
LinkedList
<
AdminUpushVo
>
pushAndroidList
=
toObjMapper
.
readValue
(
redis
.
get
(
pushAndroid
),
new
TypeReference
<
LinkedList
<
AdminUpushVo
>>(){});
redisUtil
.
set
(
pushAndroid
,
pushAndroidList
);
redisUtil
.
set
(
pushAndroid
,
pushAndroidList
);
LinkedList
<
AdminUpushVo
>
pushIosList
=
(
LinkedList
<
AdminUpushVo
>)
redisTemplateByDb
.
opsForValue
().
get
(
pushIos
);
// LinkedList<AdminUpushVo> pushIosList = (LinkedList<AdminUpushVo>) redis.get(pushIos);
LinkedList
<
AdminUpushVo
>
pushIosList
=
toObjMapper
.
readValue
(
redis
.
get
(
pushIos
),
new
TypeReference
<
LinkedList
<
AdminUpushVo
>>(){});
redisUtil
.
set
(
pushIos
,
pushIosList
);
redisUtil
.
set
(
pushIos
,
pushIosList
);
return
true
;
return
true
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
false
;
}
}
}
public
Boolean
sweetAccessToken
()
{
public
Boolean
sweetAccessToken
()
{
...
@@ -64,73 +106,104 @@ public class JxlDataImpl {
...
@@ -64,73 +106,104 @@ public class JxlDataImpl {
}
}
public
Boolean
sweetAnswer
()
{
public
Boolean
sweetAnswer
()
{
RedisTemplate
<
String
,
Object
>
redisTemplateByDb
=
redisUtil
.
getRedisTemplateByDb
(
15
);
try
{
// RedisTemplate<String, Object> redis = redisUtil.getRedisTemplateByDb(15);
Jedis
redis
=
getRedis
();
String
redisKey
=
"sweet:answer:phone*"
;
String
redisKey
=
"sweet:answer:phone*"
;
Set
<
String
>
keys
=
redisTemplateByDb
.
keys
(
redisKey
);
Set
<
String
>
keys
=
redis
.
keys
(
redisKey
);
for
(
String
key
:
keys
)
{
for
(
String
key
:
keys
)
{
SweetAnswerVo
answer
=
(
SweetAnswerVo
)
redisTemplateByDb
.
opsForValue
().
get
(
key
);
SweetAnswerVo
answer
=
toObjMapper
.
readValue
(
redis
.
get
(
key
),
SweetAnswerVo
.
class
);
redisUtil
.
set
(
key
,
answer
);
redisUtil
.
set
(
key
,
answer
);
}
}
return
true
;
return
true
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
false
;
}
}
}
public
Boolean
sweetOpenId
()
{
public
Boolean
sweetOpenId
()
{
RedisTemplate
<
String
,
Object
>
redisTemplateByDb
=
redisUtil
.
getRedisTemplateByDb
(
15
);
try
{
// RedisTemplate<String, Object> redis = redisUtil.getRedisTemplateByDb(15);
Jedis
redis
=
getRedis
();
String
redisKey
=
"sweet:wechatUser:openId*"
;
String
redisKey
=
"sweet:wechatUser:openId*"
;
Set
<
String
>
keys
=
redisTemplateByDb
.
keys
(
redisKey
);
Set
<
String
>
keys
=
redis
.
keys
(
redisKey
);
for
(
String
key
:
keys
)
{
for
(
String
key
:
keys
)
{
String
value
=
(
String
)
redisTemplateByDb
.
opsForValue
()
.
get
(
key
);
String
value
=
redis
.
get
(
key
);
redisUtil
.
set
(
key
,
value
);
redisUtil
.
set
(
key
,
value
);
}
}
return
true
;
return
true
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
false
;
}
}
}
public
Boolean
sweetUnionId
()
{
public
Boolean
sweetUnionId
()
{
RedisTemplate
<
String
,
Object
>
redisTemplateByDb
=
redisUtil
.
getRedisTemplateByDb
(
15
);
try
{
// RedisTemplate<String, Object> redis = redisUtil.getRedisTemplateByDb(15);
Jedis
redis
=
getRedis
();
String
redisKey
=
"sweet:wechatUser:unionId*"
;
String
redisKey
=
"sweet:wechatUser:unionId*"
;
Set
<
String
>
keys
=
redisTemplateByDb
.
keys
(
redisKey
);
Set
<
String
>
keys
=
redis
.
keys
(
redisKey
);
for
(
String
key
:
keys
)
{
for
(
String
key
:
keys
)
{
try
{
try
{
SweetWechatUser
userInfo
=
(
SweetWechatUser
)
redisTemplateByDb
.
opsForValue
().
get
(
key
);
SweetWechatUser
userInfo
=
toObjMapper
.
readValue
(
redis
.
get
(
key
),
SweetWechatUser
.
class
);
redisUtil
.
set
(
key
,
userInfo
);
redisUtil
.
set
(
key
,
userInfo
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"同步wechatUser失败"
+
key
,
e
);
log
.
error
(
"同步wechatUser失败"
+
key
,
e
);
}
}
}
}
return
true
;
return
true
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
false
;
}
}
}
public
Boolean
sweetUnionIdStr
()
{
public
Boolean
sweetUnionIdStr
()
{
RedisTemplate
<
String
,
Object
>
redisTemplateByDb
=
redisUtil
.
getRedisTemplateByDb
(
15
);
try
{
// RedisTemplate<String, Object> redis = redisUtil.getRedisTemplateByDb(15);
Jedis
redis
=
getRedis
();
String
redisKey
=
"sweet:wechatUser:unionIdStr*"
;
String
redisKey
=
"sweet:wechatUser:unionIdStr*"
;
Set
<
String
>
keys
=
redisTemplateByDb
.
keys
(
redisKey
);
Set
<
String
>
keys
=
redis
.
keys
(
redisKey
);
for
(
String
key
:
keys
)
{
for
(
String
key
:
keys
)
{
String
value
=
(
String
)
redisTemplateByDb
.
opsForValue
()
.
get
(
key
);
String
value
=
redis
.
get
(
key
);
redisUtil
.
set
(
key
,
value
);
redisUtil
.
set
(
key
,
value
);
}
}
return
true
;
return
true
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
false
;
}
}
}
public
Boolean
kylinBanner
()
{
public
Boolean
kylinBanner
()
{
RedisTemplate
<
String
,
Object
>
redisTemplateByDb
=
redisUtil
.
getRedisTemplateByDb
(
15
);
try
{
// RedisTemplate<String, Object> redis = redisUtil.getRedisTemplateByDb(15);
Jedis
redis
=
getRedis
();
String
bannerKey
=
KylinRedisConst
.
ADMIN_BANNER_LIST
;
String
bannerKey
=
KylinRedisConst
.
ADMIN_BANNER_LIST
;
ArrayList
<
KylinBanners
>
bannerList
=
(
ArrayList
<
KylinBanners
>)
redisTemplateByDb
.
opsForValue
().
get
(
bannerKey
);
// ArrayList<KylinBanners> bannerList = (ArrayList<KylinBanners>) redis.get(bannerKey);
ArrayList
<
KylinBanners
>
bannerList
=
toObjMapper
.
readValue
(
redis
.
get
(
bannerKey
),
new
TypeReference
<
ArrayList
<
KylinBanners
>>(){});
redisUtil
.
set
(
bannerKey
,
bannerList
);
redisUtil
.
set
(
bannerKey
,
bannerList
);
return
true
;
return
true
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
false
;
}
}
}
}
}
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