Commit f386ebb17ac1e48c1485ba5f7a9b94f8eb433171

Authored by 张志伟
2 parents f76fb181 4bb0bf70

Merge remote-tracking branch 'origin/dev' into test

fw-valhalla-service/src/main/java/cn/fw/valhalla/component/FlowConsumer.java
... ... @@ -5,15 +5,18 @@ import cn.fw.flow.result.ApproveCheckMessageDto;
5 5 import cn.fw.valhalla.domain.db.ApproveRecord;
6 6 import cn.fw.valhalla.domain.db.follow.FollowTask;
7 7 import cn.fw.valhalla.domain.enums.ApproveStateEnum;
  8 +import cn.fw.valhalla.domain.enums.FollowTypeEnum;
8 9 import cn.fw.valhalla.domain.enums.TaskStateEnum;
9 10 import cn.fw.valhalla.service.bus.cust.CustomerBizService;
10 11 import cn.fw.valhalla.service.data.ApproveRecordService;
11 12 import cn.fw.valhalla.service.data.FollowTaskService;
  13 +import cn.fw.valhalla.service.event.StopTaskEvent;
12 14 import com.alibaba.fastjson.JSONObject;
13 15 import lombok.extern.slf4j.Slf4j;
14 16 import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
15 17 import org.apache.rocketmq.spring.core.RocketMQListener;
16 18 import org.springframework.beans.factory.annotation.Autowired;
  19 +import org.springframework.context.ApplicationEventPublisher;
17 20 import org.springframework.stereotype.Service;
18 21 import org.springframework.transaction.annotation.Transactional;
19 22  
... ... @@ -33,15 +36,18 @@ public class FlowConsumer implements RocketMQListener<ApproveCheckMessageDto> {
33 36 private final CustomerBizService customerBizService;
34 37 private final ApproveRecordService approveRecordService;
35 38 private final FollowTaskService followTaskService;
  39 + private final ApplicationEventPublisher eventPublisher;
36 40  
37 41  
38 42 @Autowired
39 43 public FlowConsumer(final CustomerBizService customerBizService,
40 44 final ApproveRecordService approveRecordService,
41   - final FollowTaskService followTaskService) {
  45 + final FollowTaskService followTaskService,
  46 + final ApplicationEventPublisher eventPublisher) {
42 47 this.customerBizService = customerBizService;
43 48 this.approveRecordService = approveRecordService;
44 49 this.followTaskService = followTaskService;
  50 + this.eventPublisher = eventPublisher;
45 51 }
46 52  
47 53 @Override
... ... @@ -71,6 +77,11 @@ public class FlowConsumer implements RocketMQListener<ApproveCheckMessageDto> {
71 77 if (Objects.isNull(task) || !TaskStateEnum.ONGOING.equals(task.getState())) {
72 78 return;
73 79 }
  80 + if (FollowTypeEnum.AC.equals(task.getType())) {
  81 + StopTaskEvent stopTaskEvent = new StopTaskEvent(task);
  82 + eventPublisher.publishEvent(stopTaskEvent);
  83 + return;
  84 + }
74 85 customerBizService.abandon(task);
75 86 }
76 87 }
... ...
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/cust/AccidentPoolBizService.java
... ... @@ -242,6 +242,7 @@ public class AccidentPoolBizService {
242 242 task.setRedistribution(Boolean.FALSE);
243 243 task.setDeadline(pool.getDeadline());
244 244 task.setFollowUser(pool.getOriginalUserId());
  245 + task.setFollowUserName(pool.getOriginalUserName());
245 246 task.setFollowShop(pool.getOriginalShopId());
246 247 task.setGroupId(pool.getGroupId());
247 248 task.setCreateTime(new Date());
... ...
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/strategy/impl/ACFollowStrategy.java
... ... @@ -30,6 +30,7 @@ import org.springframework.util.CollectionUtils;
30 30  
31 31 import java.time.LocalDateTime;
32 32 import java.util.*;
  33 +import java.util.stream.Collectors;
33 34  
34 35 import static cn.fw.common.businessvalidator.Validator.BV;
35 36 import static cn.fw.valhalla.common.utils.DateUtil.date2LocalDateTime;
... ... @@ -57,7 +58,15 @@ public class ACFollowStrategy extends AbstractFollowStrategy {
57 58  
58 59 @Override
59 60 public List<FollowTodoListVO> getList(Integer startIndex, Integer pageSize, Long userId) {
60   - List<FollowRecord> list = this.list(startIndex, pageSize, userId, getFollowType());
  61 + List<FollowTask> taskList = followTaskService.list(Wrappers.<FollowTask>lambdaQuery()
  62 + .eq(FollowTask::getType, getFollowType())
  63 + .eq(FollowTask::getState, TaskStateEnum.ONGOING)
  64 + );
  65 + List<Long> taskIds = null;
  66 + if (!CollectionUtils.isEmpty(taskList)) {
  67 + taskIds = taskList.stream().map(FollowTask::getId).collect(Collectors.toList());
  68 + }
  69 + List<FollowRecord> list = this.queryList(startIndex, pageSize, userId, getFollowType(), taskIds);
61 70 if (CollectionUtils.isEmpty(list)) {
62 71 return new ArrayList<>();
63 72 }
... ... @@ -177,12 +186,12 @@ public class ACFollowStrategy extends AbstractFollowStrategy {
177 186 * @param userId
178 187 * @return
179 188 */
180   - @Override
181   - protected List<FollowRecord> list(Integer startIndex, Integer pageSize, Long userId, FollowTypeEnum followType) {
  189 + public List<FollowRecord> queryList(Integer startIndex, Integer pageSize, Long userId, FollowTypeEnum followType, List<Long> taskIds) {
182 190 String sql = String.format("limit %s,%s", startIndex, pageSize);
183 191 return followRecordService.list(Wrappers.<FollowRecord>lambdaQuery()
184 192 .eq(FollowRecord::getUserId, userId)
185 193 .eq(FollowRecord::getType, followType)
  194 + .in(!CollectionUtils.isEmpty(taskIds), FollowRecord::getTaskId, taskIds)
186 195 .le(FollowRecord::getPlanTime, new Date())
187 196 .and(w1 -> w1.ge(FollowRecord::getLimitTime, new Date()).or().ge(FollowRecord::getDeadline, new Date()))
188 197 .last(sql)
... ...