Commit 73c540e503a8c40064d3cf13cd7912ea31638749
Merge remote-tracking branch 'origin/dev' into test
Showing
1 changed file
with
51 additions
and
41 deletions
fw-shirasawa-service/src/main/java/cn/fw/shirasawa/service/bus/follow/strategy/AbstractFollowStrategy.java
... | ... | @@ -183,69 +183,79 @@ public abstract class AbstractFollowStrategy implements FollowStrategy { |
183 | 183 | @Override |
184 | 184 | @Transactional(rollbackFor = Exception.class) |
185 | 185 | public void completeTask(FollowTaskCompleteDTO taskCompleteDTO) { |
186 | - CluePool cluePool = cluePoolService.getOne(Wrappers.<CluePool>lambdaQuery() | |
186 | + List<CluePool> cluePoolList = cluePoolService.list(Wrappers.<CluePool>lambdaQuery() | |
187 | 187 | .eq(CluePool::getRefererId, taskCompleteDTO.getDetailId()) |
188 | 188 | .eq(CluePool::getClueType, taskCompleteDTO.getFollowType()) |
189 | - .eq(CluePool::getClueStatus, ClueStatusEnum.ONGOING) | |
189 | + .in(CluePool::getClueStatus, ClueStatusEnum.WAITING, ClueStatusEnum.ONGOING) | |
190 | 190 | .eq(CluePool::getBizType, taskCompleteDTO.getBizType()) |
191 | - .last(" limit 1") | |
192 | 191 | ); |
193 | - if (Objects.isNull(cluePool)) { | |
194 | - return; | |
195 | - } | |
196 | - FollowTask task = followTaskService.queryOngoingTaskByClueId(cluePool.getId()); | |
197 | - if (Objects.isNull(task)) { | |
192 | + if (CollectionUtils.isEmpty(cluePoolList)) { | |
198 | 193 | return; |
199 | 194 | } |
200 | - cluePool.setFinishShopId(taskCompleteDTO.getShopId()); | |
201 | - cluePool.setFinishUserId(taskCompleteDTO.getUserId()); | |
202 | - UserInfoDTO user = userService.user(taskCompleteDTO.getUserId()); | |
203 | - if (Objects.nonNull(user)) { | |
204 | - cluePool.setFinishUserName(user.getUserName()); | |
205 | - } | |
206 | - ShopDTO shop = oopService.shop(taskCompleteDTO.getShopId()); | |
207 | - if (Objects.nonNull(shop)) { | |
208 | - cluePool.setFinishShopName(shop.getShortName()); | |
209 | - } | |
210 | - cluePool.setCloseTime(DateUtil.date2LocalDateTime(taskCompleteDTO.getCompleteTime())); | |
211 | - cluePool.setClueStatus(ClueStatusEnum.COMPLETE); | |
212 | - cluePoolService.updateById(cluePool); | |
213 | - | |
214 | - task.setFinishUser(cluePool.getFinishUserId()); | |
215 | - task.setFinishUserName(cluePool.getFinishUserName()); | |
216 | - task.setFinishShop(cluePool.getFinishShopId()); | |
217 | - task.setCloseTime(cluePool.getCloseTime()); | |
218 | - boolean equals = task.getFollowShop().equals(cluePool.getFinishShopId()); | |
219 | - task.setState(equals ? TaskStateEnum.COMPLETE : TaskStateEnum.DEFEAT); | |
220 | - if (!equals) { | |
221 | - task.setReason(TaskDefeatTypeEnum.F); | |
222 | - } | |
223 | - boolean succeed = followTaskService.updateById(task); | |
224 | - if (succeed) { | |
225 | - completeTodo(task.getId()); | |
226 | - CancelApproveEvent event = new CancelApproveEvent(task.getId(), ApproveTypeEnum.FOLLOW_DEFEAT); | |
227 | - eventPublisher.publishEvent(event); | |
195 | + for (CluePool cluePool : cluePoolList) { | |
196 | + cluePool.setFinishShopId(taskCompleteDTO.getShopId()); | |
197 | + cluePool.setFinishUserId(taskCompleteDTO.getUserId()); | |
198 | + UserInfoDTO user = userService.user(taskCompleteDTO.getUserId()); | |
199 | + if (Objects.nonNull(user)) { | |
200 | + cluePool.setFinishUserName(user.getUserName()); | |
201 | + } | |
202 | + ShopDTO shop = oopService.shop(taskCompleteDTO.getShopId()); | |
203 | + if (Objects.nonNull(shop)) { | |
204 | + cluePool.setFinishShopName(shop.getShortName()); | |
205 | + } | |
206 | + cluePool.setCloseTime(DateUtil.date2LocalDateTime(taskCompleteDTO.getCompleteTime())); | |
207 | + cluePool.setClueStatus(ClueStatusEnum.COMPLETE); | |
208 | + cluePoolService.updateById(cluePool); | |
209 | + | |
210 | + if (ClueStatusEnum.ONGOING.equals(cluePool.getClueStatus())) { | |
211 | + FollowTask task = followTaskService.queryOngoingTaskByClueId(cluePool.getId()); | |
212 | + if (Objects.isNull(task)) { | |
213 | + return; | |
214 | + } | |
215 | + task.setFinishUser(cluePool.getFinishUserId()); | |
216 | + task.setFinishUserName(cluePool.getFinishUserName()); | |
217 | + task.setFinishShop(cluePool.getFinishShopId()); | |
218 | + task.setCloseTime(cluePool.getCloseTime()); | |
219 | + boolean equals = task.getFollowShop().equals(cluePool.getFinishShopId()); | |
220 | + task.setState(equals ? TaskStateEnum.COMPLETE : TaskStateEnum.DEFEAT); | |
221 | + if (!equals) { | |
222 | + task.setReason(TaskDefeatTypeEnum.F); | |
223 | + } | |
224 | + boolean succeed = followTaskService.updateById(task); | |
225 | + if (succeed) { | |
226 | + completeTodo(task.getId()); | |
227 | + CancelApproveEvent event = new CancelApproveEvent(task.getId(), ApproveTypeEnum.FOLLOW_DEFEAT); | |
228 | + eventPublisher.publishEvent(event); | |
229 | + } | |
230 | + } | |
228 | 231 | } |
229 | 232 | } |
230 | 233 | |
231 | 234 | @Override |
232 | 235 | public void terminationTaskPlan(FollowTerminationDTO terminationDTO) { |
233 | - CluePool cluePool = cluePoolService.getOne(Wrappers.<CluePool>lambdaQuery() | |
236 | + List<CluePool> cluePoolList = cluePoolService.list(Wrappers.<CluePool>lambdaQuery() | |
234 | 237 | .eq(CluePool::getRefererId, terminationDTO.getDetailId()) |
235 | 238 | .eq(CluePool::getClueType, terminationDTO.getFollowType()) |
236 | - .eq(CluePool::getClueStatus, ClueStatusEnum.ONGOING) | |
239 | + .in(CluePool::getClueStatus, ClueStatusEnum.WAITING, ClueStatusEnum.ONGOING) | |
237 | 240 | .eq(CluePool::getBizType, terminationDTO.getBizType()) |
238 | - .last(" limit 1") | |
239 | 241 | ); |
240 | - if (Objects.isNull(cluePool)) { | |
242 | + if (CollectionUtils.isEmpty(cluePoolList)) { | |
241 | 243 | return; |
242 | 244 | } |
243 | - endTask(cluePool); | |
245 | + for (CluePool cluePool : cluePoolList) { | |
246 | + endTask(cluePool); | |
247 | + } | |
244 | 248 | } |
245 | 249 | |
246 | 250 | @Override |
247 | 251 | @Transactional(rollbackFor = Exception.class) |
248 | 252 | public void endTask(CluePool cluePool) { |
253 | + if (ClueStatusEnum.WAITING.equals(cluePool.getClueStatus())) { | |
254 | + cluePool.setCloseTime(LocalDateTime.now()); | |
255 | + cluePool.setClueStatus(ClueStatusEnum.FAILURE); | |
256 | + cluePoolService.updateById(cluePool); | |
257 | + } | |
258 | + | |
249 | 259 | FollowTask task = followTaskService.queryOngoingTaskByClueId(cluePool.getId()); |
250 | 260 | if (Objects.nonNull(task)) { |
251 | 261 | task.setCloseTime(LocalDateTime.now()); | ... | ... |