Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
O
operate-customer-service
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
沈振路
operate-customer-service
Commits
e5c0a9c9
提交
e5c0a9c9
authored
10月 25, 2022
作者:
沈振路
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'customer_service_SZlu'
上级
d367dc6c
c6890edc
隐藏空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
234 行增加
和
52 行删除
+234
-52
pom.xml
pom.xml
+2
-2
CustomerServiceCommonAsyncComponent.java
...tomer/components/CustomerServiceCommonAsyncComponent.java
+50
-0
RabbitConfig.java
...main/java/com/yaoyaozw/customer/configs/RabbitConfig.java
+24
-11
RabbitCommonNameConstant.java
...yaoyaozw/customer/constants/RabbitCommonNameConstant.java
+38
-0
TestController.java
...java/com/yaoyaozw/customer/controller/TestController.java
+64
-0
SchedulingTask.java
...java/com/yaoyaozw/customer/scheduling/SchedulingTask.java
+1
-34
CrowdPackageService.java
...va/com/yaoyaozw/customer/service/CrowdPackageService.java
+6
-0
CrowdPackageServiceImpl.java
...oyaozw/customer/service/impl/CrowdPackageServiceImpl.java
+40
-0
CustomerGraphicsDelayServiceImpl.java
...stomer/service/impl/CustomerGraphicsDelayServiceImpl.java
+7
-5
KanbanCommonMapper.xml
src/main/resources/mapper/KanbanCommonMapper.xml
+2
-0
没有找到文件。
pom.xml
浏览文件 @
e5c0a9c9
...
@@ -224,10 +224,10 @@
...
@@ -224,10 +224,10 @@
<artifactId>
spring-cloud-starter-netflix-hystrix
</artifactId>
<artifactId>
spring-cloud-starter-netflix-hystrix
</artifactId>
</dependency>
</dependency>
<!--
<dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-amqp
</artifactId>
<artifactId>
spring-boot-starter-amqp
</artifactId>
</dependency>
-->
</dependency>
<dependency>
<dependency>
...
...
src/main/java/com/yaoyaozw/customer/components/CustomerServiceCommonAsyncComponent.java
浏览文件 @
e5c0a9c9
...
@@ -8,9 +8,11 @@ import cn.hutool.json.JSONUtil;
...
@@ -8,9 +8,11 @@ import cn.hutool.json.JSONUtil;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.TypeReference
;
import
com.alibaba.fastjson.TypeReference
;
import
com.sun.org.apache.xpath.internal.operations.Bool
;
import
com.yaoyaozw.customer.common.R
;
import
com.yaoyaozw.customer.common.R
;
import
com.yaoyaozw.customer.constants.ApiResultConstant
;
import
com.yaoyaozw.customer.constants.ApiResultConstant
;
import
com.yaoyaozw.customer.constants.CustomerCommonConstant
;
import
com.yaoyaozw.customer.constants.CustomerCommonConstant
;
import
com.yaoyaozw.customer.constants.RabbitCommonNameConstant
;
import
com.yaoyaozw.customer.entity.*
;
import
com.yaoyaozw.customer.entity.*
;
import
com.yaoyaozw.customer.enums.CustomerStoreTemplateEnum
;
import
com.yaoyaozw.customer.enums.CustomerStoreTemplateEnum
;
import
com.yaoyaozw.customer.feigns.ReferralFeignClient
;
import
com.yaoyaozw.customer.feigns.ReferralFeignClient
;
...
@@ -28,6 +30,8 @@ import com.yaoyaozw.customer.vo.customer.CrowdPackageUserVO;
...
@@ -28,6 +30,8 @@ import com.yaoyaozw.customer.vo.customer.CrowdPackageUserVO;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.amqp.rabbit.annotation.RabbitListener
;
import
org.springframework.amqp.rabbit.core.RabbitTemplate
;
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.scheduling.annotation.Async
;
import
org.springframework.scheduling.annotation.Async
;
...
@@ -69,6 +73,8 @@ public class CustomerServiceCommonAsyncComponent {
...
@@ -69,6 +73,8 @@ public class CustomerServiceCommonAsyncComponent {
private
KanbanCommonMapper
kanbanCommonMapper
;
private
KanbanCommonMapper
kanbanCommonMapper
;
@Autowired
@Autowired
private
CustomerGraphicsDelayMapper
customerGraphicsDelayMapper
;
private
CustomerGraphicsDelayMapper
customerGraphicsDelayMapper
;
@Autowired
private
RabbitTemplate
rabbitTemplate
;
@Async
(
"myExecutor"
)
@Async
(
"myExecutor"
)
...
@@ -542,6 +548,7 @@ public class CustomerServiceCommonAsyncComponent {
...
@@ -542,6 +548,7 @@ public class CustomerServiceCommonAsyncComponent {
* 以下是公有方法
* 以下是公有方法
*/
*/
public
void
getCopyReferral
(
String
dateStr
,
AuthInfoVO
authInfoVo
,
ReferralEntity
referralEntity
)
{
public
void
getCopyReferral
(
String
dateStr
,
AuthInfoVO
authInfoVo
,
ReferralEntity
referralEntity
)
{
// ygAccessLimit(true, authInfoVo.getStoreType());
referralEntity
.
setStoreType
(
authInfoVo
.
getStoreType
());
referralEntity
.
setStoreType
(
authInfoVo
.
getStoreType
());
// 非常用链接类型的name需要处理
// 非常用链接类型的name需要处理
String
name
=
referralEntity
.
getName
();
String
name
=
referralEntity
.
getName
();
...
@@ -600,7 +607,50 @@ public class CustomerServiceCommonAsyncComponent {
...
@@ -600,7 +607,50 @@ public class CustomerServiceCommonAsyncComponent {
return
userEntityList
;
return
userEntityList
;
}
}
private
void
ygAccessLimit
(
Boolean
checkStoreType
,
String
storeType
)
{
if
(
checkStoreType
&&
!
CustomerCommonConstant
.
STORE_NAME_YANG_GUANG
.
equals
(
storeType
))
{
// 需要校验书城但是不是阳光书城,直接返回
return
;
}
boolean
go
;
synchronized
(
rabbitTemplate
)
{
// 从redis查询计数
Object
count
=
redisTemplate
.
opsForValue
().
get
(
CustomerCommonConstant
.
YANG_GUANG_ACCESS_LIMIT_REDIS_KEY
);
if
(
ObjectUtil
.
isNull
(
count
))
{
// redis中没有,设置0
redisTemplate
.
opsForValue
().
set
(
CustomerCommonConstant
.
YANG_GUANG_ACCESS_LIMIT_REDIS_KEY
,
0
);
count
=
0
;
}
LOCAL_LOG
.
info
(
"当前count: {}"
,
count
);
long
stamp
=
System
.
currentTimeMillis
();
// 判断计数是否达到上限
go
=
(
Integer
)
count
<
80
;
if
(
go
)
{
// 没有达到上限,发送消息并且计数加1
rabbitTemplate
.
convertAndSend
(
RabbitCommonNameConstant
.
OPERATE_COMMON_EXCHANGE
,
RabbitCommonNameConstant
.
YG_LIMIT_TTL_ROUTE_KEY
,
stamp
);
redisTemplate
.
opsForValue
().
increment
(
CustomerCommonConstant
.
YANG_GUANG_ACCESS_LIMIT_REDIS_KEY
);
}
}
if
(!
go
)
{
// 计数达到上限了,休眠30秒,递归调用
try
{
LOCAL_LOG
.
info
(
"达到上限, 休眠15秒"
);
Thread
.
sleep
(
15000
);
// 再次调用不需要校验书城
ygAccessLimit
(
false
,
""
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
}
}
@RabbitListener
(
queues
=
RabbitCommonNameConstant
.
YG_LIMIT_DEATH_QUEUE
)
public
void
listener
()
{
redisTemplate
.
opsForValue
().
decrement
(
CustomerCommonConstant
.
YANG_GUANG_ACCESS_LIMIT_REDIS_KEY
);
}
}
}
src/main/java/com/yaoyaozw/customer/configs/RabbitConfig.java
浏览文件 @
e5c0a9c9
package
com
.
yaoyaozw
.
customer
.
configs
;
package
com
.
yaoyaozw
.
customer
.
configs
;
import
com.yaoyaozw.customer.constants.RabbitCommonNameConstant
;
import
org.springframework.amqp.core.Binding
;
import
org.springframework.amqp.core.BindingBuilder
;
import
org.springframework.amqp.core.DirectExchange
;
import
org.springframework.amqp.core.Queue
;
import
org.springframework.amqp.support.converter.Jackson2JsonMessageConverter
;
import
org.springframework.amqp.support.converter.MessageConverter
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
...
@@ -10,42 +17,48 @@ import java.util.Map;
...
@@ -10,42 +17,48 @@ import java.util.Map;
* @author darker
* @author darker
* @date 2022/10/21 16:04
* @date 2022/10/21 16:04
*/
*/
//
@Configuration
@Configuration
public
class
RabbitConfig
{
public
class
RabbitConfig
{
/* @Bean
/* @Bean
public MessageConverter messageConverter(){
return new Jackson2JsonMessageConverter();
}*/
@Bean
public
Queue
directQueue
(){
public
Queue
directQueue
(){
Map
<
String
,
Object
>
map
=
new
HashMap
<>(
4
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>(
4
);
map.put("x-dead-letter-exchange",
"DEATH_EXCHANGE"
);
map
.
put
(
"x-dead-letter-exchange"
,
RabbitCommonNameConstant
.
DEATH_EXCHANGE
);
map.put("x-dead-letter-routing-key",
"death"
);
map
.
put
(
"x-dead-letter-routing-key"
,
RabbitCommonNameConstant
.
YG_LIMIT_DEATH_ROUTE_KEY
);
map
.
put
(
"x-message-ttl"
,
60000
);
map
.
put
(
"x-message-ttl"
,
60000
);
return new Queue(
"YG_ACCESS_LIMIT"
, true, false, false, map);
return
new
Queue
(
RabbitCommonNameConstant
.
YG_LIMIT_TTL_QUEUE
,
true
,
false
,
false
,
map
);
}
}
@Bean
@Bean
public
DirectExchange
directExchange
(){
public
DirectExchange
directExchange
(){
return new DirectExchange(
"TTL_EXCHANGE"
);
return
new
DirectExchange
(
RabbitCommonNameConstant
.
OPERATE_COMMON_EXCHANGE
);
}
}
@Bean
@Bean
public
Queue
deathQueue
(){
public
Queue
deathQueue
(){
return new Queue(
"DEATH_QUEUE"
);
return
new
Queue
(
RabbitCommonNameConstant
.
YG_LIMIT_DEATH_QUEUE
);
}
}
@Bean
@Bean
public
DirectExchange
deathExchange
(){
public
DirectExchange
deathExchange
(){
return new DirectExchange(
"DEATH_EXCHANGE"
);
return
new
DirectExchange
(
RabbitCommonNameConstant
.
DEATH_EXCHANGE
);
}
}
@Bean
@Bean
public
Binding
bindingDirect
(){
public
Binding
bindingDirect
(){
return BindingBuilder.bind(directQueue()).to(directExchange()).with(
"yg_limit"
);
return
BindingBuilder
.
bind
(
directQueue
()).
to
(
directExchange
()).
with
(
RabbitCommonNameConstant
.
YG_LIMIT_TTL_ROUTE_KEY
);
}
}
@Bean
@Bean
public
Binding
bindingDeath
(){
public
Binding
bindingDeath
(){
return BindingBuilder.bind(deathQueue()).to(deathExchange()).with(
"death"
);
return
BindingBuilder
.
bind
(
deathQueue
()).
to
(
deathExchange
()).
with
(
RabbitCommonNameConstant
.
YG_LIMIT_DEATH_ROUTE_KEY
);
}
*/
}
}
}
src/main/java/com/yaoyaozw/customer/constants/RabbitCommonNameConstant.java
0 → 100644
浏览文件 @
e5c0a9c9
package
com
.
yaoyaozw
.
customer
.
constants
;
/**
* @author darker
* @date 2022/10/24 14:40
*/
public
class
RabbitCommonNameConstant
{
/**
* 1、运营系统交换机
*/
public
static
final
String
OPERATE_COMMON_EXCHANGE
=
"OPERATE_COMMON_EXCHANGE"
;
/**
* 阳光访问频率控制
*/
public
static
final
String
YG_LIMIT_TTL_QUEUE
=
"YG_LIMIT_TTL_QUEUE"
;
public
static
final
String
YG_LIMIT_TTL_ROUTE_KEY
=
"YG_LIMIT"
;
/**
* 2、死信交换机 - 死信队列 - routeKey
*/
public
static
final
String
DEATH_EXCHANGE
=
"DEATH_EXCHANGE"
;
/**
* 阳光访问频率死信
*/
public
static
final
String
YG_LIMIT_DEATH_QUEUE
=
"YG_LIMIT_DEATH_QUEUE"
;
public
static
final
String
YG_LIMIT_DEATH_ROUTE_KEY
=
"YG_LIMIT_DEATH"
;
}
src/main/java/com/yaoyaozw/customer/controller/TestController.java
浏览文件 @
e5c0a9c9
package
com
.
yaoyaozw
.
customer
.
controller
;
package
com
.
yaoyaozw
.
customer
.
controller
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.rabbitmq.client.AMQP
;
import
com.rabbitmq.client.Channel
;
import
com.yaoyaozw.customer.constants.CustomerCommonConstant
;
import
com.yaoyaozw.customer.constants.RabbitCommonNameConstant
;
import
com.yaoyaozw.customer.dto.integration.IntegrationRequestDTO
;
import
com.yaoyaozw.customer.dto.integration.IntegrationRequestDTO
;
import
com.yaoyaozw.customer.service.AccountOrderService
;
import
com.yaoyaozw.customer.service.AccountOrderService
;
import
com.yaoyaozw.customer.service.CustomerDelayPublishService
;
import
com.yaoyaozw.customer.service.CustomerDelayPublishService
;
import
com.yaoyaozw.customer.service.CustomerGraphicsService
;
import
com.yaoyaozw.customer.service.CustomerGraphicsService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.amqp.rabbit.annotation.RabbitListener
;
import
org.springframework.amqp.rabbit.core.ChannelCallback
;
import
org.springframework.amqp.rabbit.core.RabbitTemplate
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
...
@@ -15,6 +25,7 @@ import java.util.Calendar;
...
@@ -15,6 +25,7 @@ import java.util.Calendar;
* @author wgh
* @author wgh
* @date 2022/10/10 20:04
* @date 2022/10/10 20:04
*/
*/
@Slf4j
@RestController
@RestController
@RequestMapping
(
"/customer-service/test"
)
@RequestMapping
(
"/customer-service/test"
)
public
class
TestController
{
public
class
TestController
{
...
@@ -25,6 +36,10 @@ public class TestController {
...
@@ -25,6 +36,10 @@ public class TestController {
private
AccountOrderService
accountOrderService
;
private
AccountOrderService
accountOrderService
;
@Autowired
@Autowired
private
CustomerDelayPublishService
customerDelayPublishService
;
private
CustomerDelayPublishService
customerDelayPublishService
;
@Autowired
private
RabbitTemplate
rabbitTemplate
;
@Autowired
private
RedisTemplate
<
String
,
Object
>
redisTemplate
;
@GetMapping
(
"/CustomerTest"
)
@GetMapping
(
"/CustomerTest"
)
public
void
test
(){
public
void
test
(){
...
@@ -69,4 +84,53 @@ public class TestController {
...
@@ -69,4 +84,53 @@ public class TestController {
integrationRequestDTO
.
setRequestDate
(
calendar
.
getTime
());
integrationRequestDTO
.
setRequestDate
(
calendar
.
getTime
());
accountOrderService
.
activeUserByOrder
(
integrationRequestDTO
);
accountOrderService
.
activeUserByOrder
(
integrationRequestDTO
);
}
}
@GetMapping
(
"/ygLimit"
)
public
void
ygLimit
(){
limit
();
}
private
void
limit
()
{
boolean
go
;
synchronized
(
rabbitTemplate
)
{
// 从redis查询计数
Object
count
=
redisTemplate
.
opsForValue
().
get
(
CustomerCommonConstant
.
YANG_GUANG_ACCESS_LIMIT_REDIS_KEY
);
if
(
ObjectUtil
.
isNull
(
count
))
{
// redis中没有,设置0
redisTemplate
.
opsForValue
().
set
(
CustomerCommonConstant
.
YANG_GUANG_ACCESS_LIMIT_REDIS_KEY
,
0
);
count
=
0
;
}
log
.
info
(
"当前count: {}"
,
count
);
long
stamp
=
System
.
currentTimeMillis
();
// 判断计数是否达到上限
go
=
(
Integer
)
count
<
40
;
if
(
go
)
{
// 没有达到上限,发送消息并且计数加1
rabbitTemplate
.
convertAndSend
(
RabbitCommonNameConstant
.
OPERATE_COMMON_EXCHANGE
,
RabbitCommonNameConstant
.
YG_LIMIT_TTL_ROUTE_KEY
,
stamp
);
redisTemplate
.
opsForValue
().
increment
(
CustomerCommonConstant
.
YANG_GUANG_ACCESS_LIMIT_REDIS_KEY
);
}
}
if
(!
go
)
{
// 计数达到上限了,休眠30秒,递归调用
try
{
log
.
info
(
"达到上限, 休眠15秒"
);
Thread
.
sleep
(
15000
);
limit
();
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
}
}
@RabbitListener
(
queues
=
RabbitCommonNameConstant
.
YG_LIMIT_DEATH_QUEUE
)
public
void
listener
()
{
log
.
info
(
"消费"
);
redisTemplate
.
opsForValue
().
decrement
(
CustomerCommonConstant
.
YANG_GUANG_ACCESS_LIMIT_REDIS_KEY
);
}
}
}
src/main/java/com/yaoyaozw/customer/scheduling/SchedulingTask.java
浏览文件 @
e5c0a9c9
...
@@ -129,39 +129,6 @@ public class SchedulingTask {
...
@@ -129,39 +129,6 @@ public class SchedulingTask {
*/
*/
// @Scheduled(cron = "0 0/15 * * * ?")
// @Scheduled(cron = "0 0/15 * * * ?")
public
void
updateCrowdPackageNumFromRedis
()
{
public
void
updateCrowdPackageNumFromRedis
()
{
localLog
.
info
(
"开始同步redis中人群包人数至数据库"
);
crowdPackageService
.
updateCrowdPackageNumFromRedis
();
HashMap
<
String
,
Integer
>
entries
=
(
HashMap
<
String
,
Integer
>)
redisTemplate
.
boundHashOps
(
CustomerCommonConstant
.
CROWD_HUMAN_NUN_REDIS_KEY
).
entries
();
if
(
CollectionUtil
.
isEmpty
(
entries
))
{
return
;
}
localLog
.
info
(
"redis中获取到人群包人数数据: {}对"
,
entries
.
size
());
Date
now
=
new
Date
();
List
<
CrowdPackage
>
list
=
crowdPackageService
.
list
();
localLog
.
info
(
"数据库中获取人群包: {}条"
,
list
.
size
());
List
<
CrowdPackage
>
resultList
=
list
.
stream
().
filter
(
item
->
entries
.
containsKey
(
item
.
getId
().
toString
()))
.
peek
(
item
->
{
item
.
setLastCountTime
(
now
);
Integer
num
=
entries
.
get
(
item
.
getId
().
toString
());
item
.
setCrowdNum
(
num
);
}).
collect
(
Collectors
.
toList
());
if
(
entries
.
size
()
!=
list
.
size
())
{
localLog
.
info
(
"删除redis在数据库中不存在的人群包"
);
List
<
String
>
idList
=
list
.
stream
().
map
(
item
->
String
.
valueOf
(
item
.
getId
())).
collect
(
Collectors
.
toList
());
for
(
String
key
:
entries
.
keySet
())
{
if
(!
idList
.
contains
(
key
))
{
localLog
.
info
(
"redis中人群包id: {} 在数据库中不存在, 删除"
,
key
);
redisTemplate
.
opsForHash
().
delete
(
CustomerCommonConstant
.
CROWD_HUMAN_NUN_REDIS_KEY
,
key
);
}
}
}
localLog
.
info
(
"要更新人群包: {} 条"
,
resultList
.
size
());
if
(
CollectionUtil
.
isNotEmpty
(
resultList
))
{
crowdPackageService
.
updateBatchById
(
resultList
);
}
localLog
.
info
(
"删除创建时的临时数据"
);
crowdPackageService
.
remove
(
new
QueryWrapper
<
CrowdPackage
>().
isNull
(
"package_name"
));
}
}
}
}
src/main/java/com/yaoyaozw/customer/service/CrowdPackageService.java
浏览文件 @
e5c0a9c9
...
@@ -99,4 +99,10 @@ public interface CrowdPackageService extends IService<CrowdPackage> {
...
@@ -99,4 +99,10 @@ public interface CrowdPackageService extends IService<CrowdPackage> {
* @return {@link BaseResult}
* @return {@link BaseResult}
*/
*/
BaseResult
updateUserPackageBatch
(
List
<
String
>
openIdList
);
BaseResult
updateUserPackageBatch
(
List
<
String
>
openIdList
);
/**
* 更新包num人群复述
*/
void
updateCrowdPackageNumFromRedis
();
}
}
src/main/java/com/yaoyaozw/customer/service/impl/CrowdPackageServiceImpl.java
浏览文件 @
e5c0a9c9
...
@@ -11,6 +11,7 @@ import com.yaoyaozw.customer.common.GenericsResult;
...
@@ -11,6 +11,7 @@ import com.yaoyaozw.customer.common.GenericsResult;
import
com.yaoyaozw.customer.components.CustomerServiceCommonAsyncComponent
;
import
com.yaoyaozw.customer.components.CustomerServiceCommonAsyncComponent
;
import
com.yaoyaozw.customer.components.TokenManager
;
import
com.yaoyaozw.customer.components.TokenManager
;
import
com.yaoyaozw.customer.constants.CrowdPackageCommonConstant
;
import
com.yaoyaozw.customer.constants.CrowdPackageCommonConstant
;
import
com.yaoyaozw.customer.constants.CustomerCommonConstant
;
import
com.yaoyaozw.customer.dto.crowd.CrowdPackageQueryDTO
;
import
com.yaoyaozw.customer.dto.crowd.CrowdPackageQueryDTO
;
import
com.yaoyaozw.customer.dto.crowd.CrowdPackageConditionDTO
;
import
com.yaoyaozw.customer.dto.crowd.CrowdPackageConditionDTO
;
import
com.yaoyaozw.customer.entity.CrowdPackage
;
import
com.yaoyaozw.customer.entity.CrowdPackage
;
...
@@ -34,6 +35,7 @@ import org.springframework.data.redis.core.RedisTemplate;
...
@@ -34,6 +35,7 @@ import org.springframework.data.redis.core.RedisTemplate;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -234,6 +236,44 @@ public class CrowdPackageServiceImpl extends ServiceImpl<MaterialCrowdPackageMap
...
@@ -234,6 +236,44 @@ public class CrowdPackageServiceImpl extends ServiceImpl<MaterialCrowdPackageMap
return
new
BaseResult
().
success
();
return
new
BaseResult
().
success
();
}
}
@Override
public
void
updateCrowdPackageNumFromRedis
()
{
LOCAL_LOG
.
info
(
"开始同步redis中人群包人数至数据库"
);
HashMap
<
String
,
Integer
>
entries
=
(
HashMap
<
String
,
Integer
>)
redisTemplate
.
boundHashOps
(
CustomerCommonConstant
.
CROWD_HUMAN_NUN_REDIS_KEY
).
entries
();
if
(
CollectionUtil
.
isEmpty
(
entries
))
{
return
;
}
LOCAL_LOG
.
info
(
"redis中获取到人群包人数数据: {}对"
,
entries
.
size
());
Date
now
=
new
Date
();
List
<
CrowdPackage
>
list
=
super
.
list
();
LOCAL_LOG
.
info
(
"数据库中获取人群包: {}条"
,
list
.
size
());
List
<
CrowdPackage
>
resultList
=
list
.
stream
().
filter
(
item
->
entries
.
containsKey
(
item
.
getId
().
toString
()))
.
peek
(
item
->
{
item
.
setLastCountTime
(
now
);
Integer
num
=
entries
.
get
(
item
.
getId
().
toString
());
item
.
setCrowdNum
(
num
);
}).
collect
(
Collectors
.
toList
());
if
(
entries
.
size
()
!=
list
.
size
())
{
LOCAL_LOG
.
info
(
"删除redis在数据库中不存在的人群包"
);
List
<
String
>
idList
=
list
.
stream
().
map
(
item
->
String
.
valueOf
(
item
.
getId
())).
collect
(
Collectors
.
toList
());
for
(
String
key
:
entries
.
keySet
())
{
if
(!
idList
.
contains
(
key
))
{
LOCAL_LOG
.
info
(
"redis中人群包id: {} 在数据库中不存在, 删除"
,
key
);
redisTemplate
.
opsForHash
().
delete
(
CustomerCommonConstant
.
CROWD_HUMAN_NUN_REDIS_KEY
,
key
);
}
}
}
LOCAL_LOG
.
info
(
"要更新人群包: {} 条"
,
resultList
.
size
());
if
(
CollectionUtil
.
isNotEmpty
(
resultList
))
{
super
.
updateBatchById
(
resultList
);
}
LOCAL_LOG
.
info
(
"删除创建时的临时数据"
);
super
.
remove
(
new
QueryWrapper
<
CrowdPackage
>().
isNull
(
"package_name"
));
}
/**
/**
* 构造操作符
* 构造操作符
*
*
...
...
src/main/java/com/yaoyaozw/customer/service/impl/CustomerGraphicsDelayServiceImpl.java
浏览文件 @
e5c0a9c9
...
@@ -169,13 +169,15 @@ public class CustomerGraphicsDelayServiceImpl extends ServiceImpl<CustomerGraphi
...
@@ -169,13 +169,15 @@ public class CustomerGraphicsDelayServiceImpl extends ServiceImpl<CustomerGraphi
// 查询链接数据
// 查询链接数据
ReferralEntity
referralEntity
=
referralEntityService
.
getOne
(
new
QueryWrapper
<
ReferralEntity
>().
eq
(
"material_graphics_id"
,
id
));
ReferralEntity
referralEntity
=
referralEntityService
.
getOne
(
new
QueryWrapper
<
ReferralEntity
>().
eq
(
"material_graphics_id"
,
id
));
if
(
ObjectUtil
.
isNull
(
referralEntity
))
{
if
(
ObjectUtil
.
isNotNull
(
referralEntity
))
{
return
new
GenericsResult
<>(
false
,
"找不到链接数据"
);
CustomerReferralDTO
customerReferralDto
=
new
CustomerReferralDTO
();
BeanUtil
.
copyProperties
(
referralEntity
,
customerReferralDto
);
customerDelayGraphicsDetailVO
.
setCustomerReferralDto
(
customerReferralDto
);
}
else
{
customerDelayGraphicsDetailVO
.
setCustomerReferralDto
(
new
CustomerReferralDTO
());
}
}
CustomerReferralDTO
customerReferralDto
=
new
CustomerReferralDTO
();
BeanUtil
.
copyProperties
(
referralEntity
,
customerReferralDto
);
customerDelayGraphicsDetailVO
.
setCustomerReferralDto
(
customerReferralDto
);
AuthInfoVO
authInfoVO
=
super
.
baseMapper
.
getCustomerDelayAuthInfo
(
id
);
AuthInfoVO
authInfoVO
=
super
.
baseMapper
.
getCustomerDelayAuthInfo
(
id
);
customerDelayGraphicsDetailVO
.
setAuthInfoVo
(
authInfoVO
);
customerDelayGraphicsDetailVO
.
setAuthInfoVo
(
authInfoVO
);
...
...
src/main/resources/mapper/KanbanCommonMapper.xml
浏览文件 @
e5c0a9c9
...
@@ -59,6 +59,7 @@
...
@@ -59,6 +59,7 @@
on ae.store_id = se.id
on ae.store_id = se.id
where ae.app_id = #{appId}
where ae.app_id = #{appId}
and is_active = 1
</select>
</select>
</mapper>
</mapper>
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论