Commit 8c89bf6af3a8bbc0aab8205a1095c91c03f30378
1 parent
2d727f47
bug调整
Showing
3 changed files
with
18 additions
and
20 deletions
fw-valhalla-rpc/src/main/java/cn/fw/valhalla/rpc/erp/TodoRpcService.java
... | ... | @@ -17,10 +17,7 @@ import org.springframework.data.redis.core.StringRedisTemplate; |
17 | 17 | import org.springframework.stereotype.Service; |
18 | 18 | import org.springframework.util.CollectionUtils; |
19 | 19 | |
20 | -import java.util.ArrayList; | |
21 | -import java.util.List; | |
22 | -import java.util.Objects; | |
23 | -import java.util.Optional; | |
20 | +import java.util.*; | |
24 | 21 | import java.util.stream.Collectors; |
25 | 22 | |
26 | 23 | /** |
... | ... | @@ -163,28 +160,27 @@ public class TodoRpcService { |
163 | 160 | } |
164 | 161 | return Optional.of(dto); |
165 | 162 | } catch (Exception e) { |
166 | - log.error("缓存设置信息失败 key[{}]", key, e); | |
163 | + log.error("缓存信息获取失败 key[{}]", key, e); | |
167 | 164 | return Optional.empty(); |
168 | 165 | } |
169 | 166 | } |
170 | 167 | |
171 | - public List<BackLogItemDTO> getAllFromCache(final String key) { | |
168 | + public Collection<BackLogItemDTO> getAllFromCache(final String key) { | |
172 | 169 | try { |
173 | 170 | Boolean hasKey = redisTemplate.hasKey(key); |
174 | 171 | if (!Boolean.TRUE.equals(hasKey)) { |
175 | - return new ArrayList<>(); | |
172 | + return new HashSet<>(); | |
176 | 173 | } |
177 | 174 | BoundListOperations<String, String> ops = redisTemplate.boundListOps(key); |
178 | 175 | List<String> stringList = ops.range(0, -1); |
176 | + redisTemplate.delete(key); | |
179 | 177 | if (CollectionUtils.isEmpty(stringList)) { |
180 | - return new ArrayList<>(); | |
178 | + return new HashSet<>(); | |
181 | 179 | } |
182 | - List<BackLogItemDTO> dtos = stringList.stream().map(str -> JSONObject.parseObject(str, BackLogItemDTO.class)).collect(Collectors.toList()); | |
183 | - redisTemplate.delete(key); | |
184 | - return dtos; | |
180 | + return stringList.stream().map(str -> JSONObject.parseObject(str, BackLogItemDTO.class)).collect(Collectors.toSet()); | |
185 | 181 | } catch (Exception e) { |
186 | - log.error("缓存设置信息失败 key[{}]", key, e); | |
187 | - return new ArrayList<>(); | |
182 | + log.error("缓存信息获取失败 key[{}]", key, e); | |
183 | + return new HashSet<>(); | |
188 | 184 | } |
189 | 185 | } |
190 | 186 | ... | ... |
fw-valhalla-rpc/src/main/java/cn/fw/valhalla/rpc/erp/dto/BackLogItemDTO.java
1 | 1 | package cn.fw.valhalla.rpc.erp.dto; |
2 | 2 | |
3 | 3 | import lombok.Data; |
4 | +import lombok.EqualsAndHashCode; | |
4 | 5 | import lombok.ToString; |
5 | 6 | |
6 | 7 | import java.util.Date; |
... | ... | @@ -14,6 +15,7 @@ import java.util.Objects; |
14 | 15 | */ |
15 | 16 | @Data |
16 | 17 | @ToString |
18 | +@EqualsAndHashCode | |
17 | 19 | public class BackLogItemDTO { |
18 | 20 | /** |
19 | 21 | * 发送次数 | ... | ... |
fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/task/FollowRecordTask.java
... | ... | @@ -22,9 +22,9 @@ import org.springframework.util.CollectionUtils; |
22 | 22 | |
23 | 23 | import java.time.LocalDateTime; |
24 | 24 | import java.util.ArrayList; |
25 | +import java.util.Collection; | |
25 | 26 | import java.util.List; |
26 | 27 | import java.util.Objects; |
27 | -import java.util.Optional; | |
28 | 28 | |
29 | 29 | /** |
30 | 30 | * @author : kurisu |
... | ... | @@ -125,21 +125,21 @@ public class FollowRecordTask { |
125 | 125 | /** |
126 | 126 | * 完成待办的重试 |
127 | 127 | */ |
128 | - @Scheduled(initialDelay = 1500, fixedRate = 1000) | |
128 | + @Scheduled(initialDelay = 1500, fixedRate = 15 * 1000) | |
129 | 129 | public void retryCompleteTodoItem() { |
130 | 130 | String key = todoRpcService.generateKey(TodoRpcService.TodoOperationEnum.COMPLETE); |
131 | - Optional<BackLogItemDTO> fromCache = todoRpcService.getOneFromCache(key); | |
132 | - fromCache.ifPresent(todoRpcService::complete); | |
131 | + Collection<BackLogItemDTO> all = todoRpcService.getAllFromCache(key); | |
132 | + all.forEach(todoRpcService::complete); | |
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
136 | 136 | * 取消待办的重试 |
137 | 137 | */ |
138 | - @Scheduled(initialDelay = 1000, fixedRate = 1000) | |
138 | + @Scheduled(initialDelay = 1000, fixedRate = 10 * 1000) | |
139 | 139 | public void retryCancelTodoItem() { |
140 | 140 | String key = todoRpcService.generateKey(TodoRpcService.TodoOperationEnum.CANCEL); |
141 | - Optional<BackLogItemDTO> fromCache = todoRpcService.getOneFromCache(key); | |
142 | - fromCache.ifPresent(todoRpcService::cancel); | |
141 | + Collection<BackLogItemDTO> all = todoRpcService.getAllFromCache(key); | |
142 | + all.forEach(todoRpcService::cancel); | |
143 | 143 | } |
144 | 144 | |
145 | 145 | ... | ... |