Commit da8910bad2920f2fda87359220ffa3225fdcb5ab
1 parent
9ee03e07
feat(*): bug修复
- bug修复
Showing
5 changed files
with
80 additions
and
2 deletions
fw-valhalla-dao/src/main/java/cn/fw/valhalla/dao/mapper/CustomerInitClueMapper.kt
... | ... | @@ -2,6 +2,8 @@ package cn.fw.valhalla.dao.mapper |
2 | 2 | |
3 | 3 | import cn.fw.valhalla.domain.db.ipt.CustomerInitClue |
4 | 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper |
5 | +import org.apache.ibatis.annotations.Param | |
6 | +import org.apache.ibatis.annotations.Select | |
5 | 7 | import org.springframework.stereotype.Repository |
6 | 8 | |
7 | 9 | /** |
... | ... | @@ -13,4 +15,12 @@ import org.springframework.stereotype.Repository |
13 | 15 | * @date : 2024-03-27 17:01 |
14 | 16 | */ |
15 | 17 | @Repository |
16 | -interface CustomerInitClueMapper : BaseMapper<CustomerInitClue> | |
17 | 18 | \ No newline at end of file |
19 | +interface CustomerInitClueMapper : BaseMapper<CustomerInitClue> { | |
20 | + @Select( | |
21 | + "SELECT t1.id FROM customer_init_clue t1" + | |
22 | + " inner join customer t2 on t1.vin = t2.frame_no " + | |
23 | + " where t2.group_id=#{groupId}" + | |
24 | + " and t1.yn=1 and t2.yn=1" | |
25 | + ) | |
26 | + fun queryTransferredCustomer(@Param("groupId") groupId: Long): List<Long> | |
27 | +} | |
18 | 28 | \ No newline at end of file | ... | ... |
fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/task/CallHistoryTask.kt
... | ... | @@ -106,4 +106,15 @@ class CallHistoryTask( |
106 | 106 | } |
107 | 107 | } |
108 | 108 | } |
109 | + | |
110 | + | |
111 | + @Scheduled(initialDelay = 1000 * 30, fixedRate = 1000 * 60 * 5) | |
112 | + fun cacheTransferInitClue() { | |
113 | + customerInitClueBizService.queryTransferredCustomer() | |
114 | + } | |
115 | + | |
116 | + @Scheduled(initialDelay = 1000 * 30, fixedRate = 1000 * 60) | |
117 | + fun dealTransferInitClue() { | |
118 | + customerInitClueBizService.dealClue() | |
119 | + } | |
109 | 120 | } |
110 | 121 | \ No newline at end of file | ... | ... |
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/ipt/CustomerInitClueBizService.kt
... | ... | @@ -15,6 +15,9 @@ import cn.fw.valhalla.rpc.pstn.PstnRpcService |
15 | 15 | import cn.fw.valhalla.service.data.CustomerInitClueCallLogService |
16 | 16 | import cn.fw.valhalla.service.data.CustomerInitClueService |
17 | 17 | import com.baomidou.mybatisplus.extension.kotlin.KtQueryWrapper |
18 | +import kotlinx.coroutines.* | |
19 | +import org.springframework.beans.factory.annotation.Value | |
20 | +import org.springframework.data.redis.core.StringRedisTemplate | |
18 | 21 | import org.springframework.stereotype.Service |
19 | 22 | import org.springframework.transaction.annotation.Transactional |
20 | 23 | import java.util.* |
... | ... | @@ -34,7 +37,10 @@ class CustomerInitClueBizService( |
34 | 37 | private val customerInitClueCallLogService: CustomerInitClueCallLogService, |
35 | 38 | private val oopService: OopService, |
36 | 39 | private val memberRpcService: MemberRpcService, |
37 | - private val pstnRpcService: PstnRpcService | |
40 | + private val pstnRpcService: PstnRpcService, | |
41 | + private val stringRedisTemplate: StringRedisTemplate, | |
42 | + @Value("\${spring.cache.custom.global-prefix}:init-clue:transferred") | |
43 | + private val initTransferredKey: String | |
38 | 44 | ) { |
39 | 45 | /** |
40 | 46 | * 查询池子数据 |
... | ... | @@ -135,6 +141,45 @@ class CustomerInitClueBizService( |
135 | 141 | customerInitClueCallLogService.updateById(callLog.copy(recording = it)) |
136 | 142 | } |
137 | 143 | } |
144 | + | |
145 | + /** | |
146 | + * 缓存已转移线索id | |
147 | + */ | |
148 | + fun queryTransferredCustomer() { | |
149 | + val groupIds = oopService.allGroup() | |
150 | + if (groupIds.isNullOrEmpty()) { | |
151 | + return | |
152 | + } | |
153 | + groupIds.forEach { | |
154 | + CoroutineScope(Dispatchers.IO).launch { | |
155 | + val clueIds = customerInitClueService.queryTransferredCustomer(it.id) | |
156 | + if (clueIds.isNotEmpty()) { | |
157 | + val key = "$initTransferredKey:${it.id}" | |
158 | + stringRedisTemplate.opsForSet().add(key, *clueIds.map { c -> c.toString() }.toTypedArray()) | |
159 | + } | |
160 | + } | |
161 | + } | |
162 | + } | |
163 | + | |
164 | + fun dealClue() { | |
165 | + val groupIds = oopService.allGroup() | |
166 | + if (groupIds.isNullOrEmpty()) { | |
167 | + return | |
168 | + } | |
169 | + groupIds.forEach { | |
170 | + CoroutineScope(Dispatchers.IO).launch { | |
171 | + val key = "$initTransferredKey:${it.id}" | |
172 | + val idList = mutableSetOf<Long>() | |
173 | + val idStr = stringRedisTemplate.opsForSet().pop(key) | |
174 | + while (idStr != null) { | |
175 | + idList.add(idStr.toLong()) | |
176 | + } | |
177 | + if (idList.isNotEmpty()) { | |
178 | + customerInitClueService.removeByIds(idList) | |
179 | + } | |
180 | + } | |
181 | + } | |
182 | + } | |
138 | 183 | } |
139 | 184 | |
140 | 185 | ... | ... |
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/data/CustomerInitClueService.kt
... | ... | @@ -12,4 +12,8 @@ import com.baomidou.mybatisplus.extension.service.IService |
12 | 12 | * @date : 2024-03-27 17:03 |
13 | 13 | */ |
14 | 14 | interface CustomerInitClueService : IService<CustomerInitClue> { |
15 | + /** | |
16 | + * 查询已转移线索 | |
17 | + */ | |
18 | + fun queryTransferredCustomer(groupId: Long?): List<Long> | |
15 | 19 | } |
16 | 20 | \ No newline at end of file | ... | ... |
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/data/impl/CustomerInitClueServiceImpl.kt
... | ... | @@ -16,4 +16,12 @@ import org.springframework.stereotype.Service |
16 | 16 | */ |
17 | 17 | @Service |
18 | 18 | class CustomerInitClueServiceImpl : ServiceImpl<CustomerInitClueMapper, CustomerInitClue>(), CustomerInitClueService { |
19 | + /** | |
20 | + * 查询已转移线索 | |
21 | + */ | |
22 | + override fun queryTransferredCustomer(groupId: Long?): List<Long> { | |
23 | + return groupId?.let { | |
24 | + baseMapper.queryTransferredCustomer(groupId) | |
25 | + } ?: listOf() | |
26 | + } | |
19 | 27 | } |
20 | 28 | \ No newline at end of file | ... | ... |