Commit ee39ce190e3e25aa7d294cca39ab7ac0694e9c6d
1 parent
be4d1cc6
续保跟进角色调整,跟进任务分配
Showing
9 changed files
with
165 additions
and
85 deletions
fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/RoleChangeDTO.java
0 → 100644
1 | +package cn.fw.valhalla.domain.dto; | ||
2 | + | ||
3 | +import lombok.AllArgsConstructor; | ||
4 | +import lombok.Data; | ||
5 | +import lombok.NoArgsConstructor; | ||
6 | +import lombok.ToString; | ||
7 | + | ||
8 | +/** | ||
9 | + * @author : kurisu | ||
10 | + * @className : RoleChangeDTO | ||
11 | + * @description : 角色变动dto | ||
12 | + * @date: 2021-02-20 15:11 | ||
13 | + */ | ||
14 | +@Data | ||
15 | +@AllArgsConstructor | ||
16 | +@NoArgsConstructor | ||
17 | +@ToString | ||
18 | +public class RoleChangeDTO { | ||
19 | + /** | ||
20 | + * 门店 | ||
21 | + */ | ||
22 | + private Long shopId; | ||
23 | + /** | ||
24 | + * 用户id | ||
25 | + */ | ||
26 | + private Long userId; | ||
27 | + /** | ||
28 | + * 用户名称 | ||
29 | + */ | ||
30 | + private String userName; | ||
31 | +} |
fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/task/RoleChangeTask.java
1 | package cn.fw.valhalla.controller.task; | 1 | package cn.fw.valhalla.controller.task; |
2 | 2 | ||
3 | +import cn.fw.valhalla.common.constant.RoleCode; | ||
3 | import cn.fw.valhalla.common.utils.StringUtils; | 4 | import cn.fw.valhalla.common.utils.StringUtils; |
4 | import cn.fw.valhalla.domain.db.LeaveNeedDo; | 5 | import cn.fw.valhalla.domain.db.LeaveNeedDo; |
6 | +import cn.fw.valhalla.domain.dto.RoleChangeDTO; | ||
7 | +import cn.fw.valhalla.domain.enums.LeaveReasonEnum; | ||
8 | +import cn.fw.valhalla.domain.enums.LeaveTodoTypeEnum; | ||
5 | import cn.fw.valhalla.service.bus.LeaveNeedDoBizService; | 9 | import cn.fw.valhalla.service.bus.LeaveNeedDoBizService; |
6 | import com.alibaba.fastjson.JSONObject; | 10 | import com.alibaba.fastjson.JSONObject; |
7 | import lombok.Getter; | 11 | import lombok.Getter; |
@@ -15,6 +19,7 @@ import org.springframework.stereotype.Component; | @@ -15,6 +19,7 @@ import org.springframework.stereotype.Component; | ||
15 | import org.springframework.util.CollectionUtils; | 19 | import org.springframework.util.CollectionUtils; |
16 | 20 | ||
17 | import java.util.ArrayList; | 21 | import java.util.ArrayList; |
22 | +import java.util.Date; | ||
18 | import java.util.List; | 23 | import java.util.List; |
19 | import java.util.Objects; | 24 | import java.util.Objects; |
20 | 25 | ||
@@ -31,9 +36,9 @@ public class RoleChangeTask { | @@ -31,9 +36,9 @@ public class RoleChangeTask { | ||
31 | private final LeaveNeedDoBizService leaveNeedDoBizService; | 36 | private final LeaveNeedDoBizService leaveNeedDoBizService; |
32 | private final StringRedisTemplate redisTemplate; | 37 | private final StringRedisTemplate redisTemplate; |
33 | 38 | ||
34 | - @Value("${spring.cache.custom.global-prefix}:mq:role:change") | 39 | + @Value("${spring.cache.custom.global-prefix}:mq:role") |
35 | @Getter | 40 | @Getter |
36 | - private String roleChangeKey; | 41 | + private String keyPrefix; |
37 | 42 | ||
38 | @Autowired | 43 | @Autowired |
39 | public RoleChangeTask(final LeaveNeedDoBizService leaveNeedDoBizService, | 44 | public RoleChangeTask(final LeaveNeedDoBizService leaveNeedDoBizService, |
@@ -44,28 +49,71 @@ public class RoleChangeTask { | @@ -44,28 +49,71 @@ public class RoleChangeTask { | ||
44 | 49 | ||
45 | 50 | ||
46 | /** | 51 | /** |
47 | - * 处理员工角色变动 | 52 | + * 服务顾问角色变动 |
48 | */ | 53 | */ |
49 | @Scheduled(initialDelay = 1000 * 30, fixedRate = 1000 * 60 * 60) | 54 | @Scheduled(initialDelay = 1000 * 30, fixedRate = 1000 * 60 * 60) |
50 | - public void dealData() { | 55 | + public void dealFwgwData() { |
51 | List<String> failList = new ArrayList<>(); | 56 | List<String> failList = new ArrayList<>(); |
52 | String jsonStr; | 57 | String jsonStr; |
53 | - while ((jsonStr = redisTemplate.opsForList().leftPop(getRoleChangeKey())) != null) { | ||
54 | - LeaveNeedDo leaveNeedDo = JSONObject.parseObject(jsonStr, LeaveNeedDo.class); | ||
55 | - if (Objects.isNull(leaveNeedDo)) { | 58 | + while ((jsonStr = redisTemplate.opsForList().leftPop(getRedisKey(RoleCode.FWGW))) != null) { |
59 | + RoleChangeDTO roleChangeDTO = JSONObject.parseObject(jsonStr, RoleChangeDTO.class); | ||
60 | + if (Objects.isNull(roleChangeDTO)) { | ||
56 | continue; | 61 | continue; |
57 | } | 62 | } |
58 | try { | 63 | try { |
59 | - leaveNeedDoBizService.add(leaveNeedDo); | 64 | + leaveNeedDoBizService.add(createDb(roleChangeDTO.getUserId(), roleChangeDTO.getShopId(), roleChangeDTO.getUserName())); |
60 | } catch (Exception e) { | 65 | } catch (Exception e) { |
61 | if (StringUtils.isValid(jsonStr)) { | 66 | if (StringUtils.isValid(jsonStr)) { |
62 | failList.add(jsonStr); | 67 | failList.add(jsonStr); |
63 | } | 68 | } |
64 | - log.error("处理员工角色变动失败", e); | 69 | + log.error("处理服务接待角色变动失败", e); |
65 | } | 70 | } |
66 | } | 71 | } |
67 | if (!CollectionUtils.isEmpty(failList)) { | 72 | if (!CollectionUtils.isEmpty(failList)) { |
68 | - redisTemplate.opsForList().rightPushAll(getRoleChangeKey(), failList); | 73 | + redisTemplate.opsForList().rightPushAll(getRedisKey(RoleCode.FWGW), failList); |
69 | } | 74 | } |
70 | } | 75 | } |
76 | + | ||
77 | + /** | ||
78 | + * 续保角色 | ||
79 | + */ | ||
80 | + @Scheduled(initialDelay = 1000 * 30, fixedRate = 1000 * 60 * 60) | ||
81 | + public void dealXbData() { | ||
82 | + List<String> failList = new ArrayList<>(); | ||
83 | + String jsonStr; | ||
84 | + while ((jsonStr = redisTemplate.opsForList().leftPop(getRedisKey(RoleCode.XBGJ))) != null) { | ||
85 | + RoleChangeDTO roleChangeDTO = JSONObject.parseObject(jsonStr, RoleChangeDTO.class); | ||
86 | + if (Objects.isNull(roleChangeDTO)) { | ||
87 | + continue; | ||
88 | + } | ||
89 | + try { | ||
90 | + leaveNeedDoBizService.xbgjChanged(roleChangeDTO); | ||
91 | + } catch (Exception e) { | ||
92 | + if (StringUtils.isValid(jsonStr)) { | ||
93 | + failList.add(jsonStr); | ||
94 | + } | ||
95 | + log.error("处理续保跟进角色变动失败", e); | ||
96 | + } | ||
97 | + } | ||
98 | + if (!CollectionUtils.isEmpty(failList)) { | ||
99 | + redisTemplate.opsForList().rightPushAll(getRedisKey(RoleCode.XBGJ), failList); | ||
100 | + } | ||
101 | + } | ||
102 | + | ||
103 | + private String getRedisKey(final String roleCode) { | ||
104 | + return String.format("%s:change:%s", getKeyPrefix(), roleCode); | ||
105 | + } | ||
106 | + | ||
107 | + private LeaveNeedDo createDb(Long userId, Long shopId, String userName) { | ||
108 | + LeaveNeedDo leaveNeedDo = new LeaveNeedDo(); | ||
109 | + leaveNeedDo.setDone(Boolean.FALSE); | ||
110 | + leaveNeedDo.setEffectiveTime(new Date()); | ||
111 | + leaveNeedDo.setReason(LeaveReasonEnum.CHANGE); | ||
112 | + leaveNeedDo.setType(LeaveTodoTypeEnum.CUSTOMER); | ||
113 | + leaveNeedDo.setShopId(shopId); | ||
114 | + leaveNeedDo.setUserId(userId); | ||
115 | + leaveNeedDo.setUserName(userName); | ||
116 | + leaveNeedDo.setCreateTime(new Date()); | ||
117 | + return leaveNeedDo; | ||
118 | + } | ||
71 | } | 119 | } |
fw-valhalla-service/src/main/java/cn/fw/valhalla/component/RoleChangeConsumer.java
@@ -4,6 +4,7 @@ import cn.fw.erp.sdk.api.enums.OperateTypeEnum; | @@ -4,6 +4,7 @@ import cn.fw.erp.sdk.api.enums.OperateTypeEnum; | ||
4 | import cn.fw.erp.sdk.api.mq.RoleChangeEvent; | 4 | import cn.fw.erp.sdk.api.mq.RoleChangeEvent; |
5 | import cn.fw.valhalla.common.constant.RoleCode; | 5 | import cn.fw.valhalla.common.constant.RoleCode; |
6 | import cn.fw.valhalla.domain.db.LeaveNeedDo; | 6 | import cn.fw.valhalla.domain.db.LeaveNeedDo; |
7 | +import cn.fw.valhalla.domain.dto.RoleChangeDTO; | ||
7 | import cn.fw.valhalla.domain.enums.LeaveReasonEnum; | 8 | import cn.fw.valhalla.domain.enums.LeaveReasonEnum; |
8 | import cn.fw.valhalla.domain.enums.LeaveTodoTypeEnum; | 9 | import cn.fw.valhalla.domain.enums.LeaveTodoTypeEnum; |
9 | import com.alibaba.fastjson.JSON; | 10 | import com.alibaba.fastjson.JSON; |
@@ -32,9 +33,9 @@ import java.util.Objects; | @@ -32,9 +33,9 @@ import java.util.Objects; | ||
32 | public class RoleChangeConsumer implements RocketMQListener<RoleChangeEvent> { | 33 | public class RoleChangeConsumer implements RocketMQListener<RoleChangeEvent> { |
33 | private final StringRedisTemplate redisTemplate; | 34 | private final StringRedisTemplate redisTemplate; |
34 | 35 | ||
35 | - @Value("${spring.cache.custom.global-prefix}:mq:role:change") | 36 | + @Value("${spring.cache.custom.global-prefix}:mq:role") |
36 | @Getter | 37 | @Getter |
37 | - private String roleChangeKey; | 38 | + private String keyPrefix; |
38 | 39 | ||
39 | @Autowired | 40 | @Autowired |
40 | public RoleChangeConsumer(final StringRedisTemplate redisTemplate) { | 41 | public RoleChangeConsumer(final StringRedisTemplate redisTemplate) { |
@@ -48,28 +49,21 @@ public class RoleChangeConsumer implements RocketMQListener<RoleChangeEvent> { | @@ -48,28 +49,21 @@ public class RoleChangeConsumer implements RocketMQListener<RoleChangeEvent> { | ||
48 | if (Objects.isNull(t)) { | 49 | if (Objects.isNull(t)) { |
49 | return; | 50 | return; |
50 | } | 51 | } |
51 | - if (OperateTypeEnum.REMOVE.getValue().equals(t.getType()) && RoleCode.FWGW.equalsIgnoreCase(t.getRoleCode())) { | ||
52 | - Long shopId = t.getRangeValue(); | ||
53 | - Long userId = t.getUserId(); | ||
54 | - String userName = t.getUserName(); | ||
55 | - LeaveNeedDo leaveNeedDo = createDb(userId, shopId, userName); | ||
56 | - redisTemplate.boundListOps(getRoleChangeKey()).rightPush(JSONObject.toJSONString(leaveNeedDo)); | 52 | + if (OperateTypeEnum.BLOCK.getValue().equals(t.getType()) && RoleCode.FWGW.equalsIgnoreCase(t.getRoleCode())) { |
53 | + String jsonString = JSONObject.toJSONString(new RoleChangeDTO(t.getRangeValue(), t.getUserId(), t.getUserName())); | ||
54 | + redisTemplate.boundListOps(getRedisKey(RoleCode.FWGW)).rightPush(jsonString); | ||
55 | + } | ||
56 | + | ||
57 | + if (OperateTypeEnum.BLOCK.getValue().equals(t.getType()) && RoleCode.XBGJ.equalsIgnoreCase(t.getRoleCode())) { | ||
58 | + String jsonString = JSONObject.toJSONString(new RoleChangeDTO(t.getRangeValue(), t.getUserId(), t.getUserName())); | ||
59 | + redisTemplate.boundListOps(getRedisKey(RoleCode.XBGJ)).rightPush(jsonString); | ||
57 | } | 60 | } |
58 | } catch (Exception ex) { | 61 | } catch (Exception ex) { |
59 | log.error("消费角色变动mq失败,原因:{}", JSON.toJSONString(ex)); | 62 | log.error("消费角色变动mq失败,原因:{}", JSON.toJSONString(ex)); |
60 | } | 63 | } |
61 | } | 64 | } |
62 | 65 | ||
63 | - private LeaveNeedDo createDb(Long userId, Long shopId, String userName) { | ||
64 | - LeaveNeedDo leaveNeedDo = new LeaveNeedDo(); | ||
65 | - leaveNeedDo.setDone(Boolean.FALSE); | ||
66 | - leaveNeedDo.setEffectiveTime(new Date()); | ||
67 | - leaveNeedDo.setReason(LeaveReasonEnum.CHANGE); | ||
68 | - leaveNeedDo.setType(LeaveTodoTypeEnum.CUSTOMER); | ||
69 | - leaveNeedDo.setShopId(shopId); | ||
70 | - leaveNeedDo.setUserId(userId); | ||
71 | - leaveNeedDo.setUserName(userName); | ||
72 | - leaveNeedDo.setCreateTime(new Date()); | ||
73 | - return leaveNeedDo; | 66 | + private String getRedisKey(final String roleCode) { |
67 | + return String.format("%s:change:%s", getKeyPrefix(), roleCode); | ||
74 | } | 68 | } |
75 | } | 69 | } |
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/LeaveNeedDoBizService.java
@@ -12,11 +12,11 @@ import cn.fw.valhalla.common.enums.AllocationTypeEnum; | @@ -12,11 +12,11 @@ import cn.fw.valhalla.common.enums.AllocationTypeEnum; | ||
12 | import cn.fw.valhalla.common.utils.DateUtil; | 12 | import cn.fw.valhalla.common.utils.DateUtil; |
13 | import cn.fw.valhalla.domain.db.LeaveNeedDo; | 13 | import cn.fw.valhalla.domain.db.LeaveNeedDo; |
14 | import cn.fw.valhalla.domain.db.customer.Customer; | 14 | import cn.fw.valhalla.domain.db.customer.Customer; |
15 | -import cn.fw.valhalla.domain.db.follow.FollowRecord; | ||
16 | import cn.fw.valhalla.domain.db.follow.FollowTask; | 15 | import cn.fw.valhalla.domain.db.follow.FollowTask; |
17 | import cn.fw.valhalla.domain.db.pool.CustomerCluePool; | 16 | import cn.fw.valhalla.domain.db.pool.CustomerCluePool; |
18 | import cn.fw.valhalla.domain.db.pool.StammkundePool; | 17 | import cn.fw.valhalla.domain.db.pool.StammkundePool; |
19 | import cn.fw.valhalla.domain.dto.LeaveAllocationDTO; | 18 | import cn.fw.valhalla.domain.dto.LeaveAllocationDTO; |
19 | +import cn.fw.valhalla.domain.dto.RoleChangeDTO; | ||
20 | import cn.fw.valhalla.domain.dto.StammkundeDto; | 20 | import cn.fw.valhalla.domain.dto.StammkundeDto; |
21 | import cn.fw.valhalla.domain.enums.*; | 21 | import cn.fw.valhalla.domain.enums.*; |
22 | import cn.fw.valhalla.domain.query.LeaveQueryVO; | 22 | import cn.fw.valhalla.domain.query.LeaveQueryVO; |
@@ -177,6 +177,41 @@ public class LeaveNeedDoBizService { | @@ -177,6 +177,41 @@ public class LeaveNeedDoBizService { | ||
177 | } | 177 | } |
178 | } | 178 | } |
179 | 179 | ||
180 | + | ||
181 | + @Transactional(rollbackFor = Exception.class) | ||
182 | + public void xbgjChanged(RoleChangeDTO dto) { | ||
183 | + final Long userId = dto.getUserId(); | ||
184 | + final Long shopId = dto.getShopId(); | ||
185 | + List<ClueStatusEnum> statusList = Arrays.asList(ClueStatusEnum.WAITING, ClueStatusEnum.ONGOING); | ||
186 | + List<CustomerCluePool> list = customerCluePoolService.list(Wrappers.<CustomerCluePool>lambdaQuery() | ||
187 | + .in(CustomerCluePool::getClueStatus, statusList) | ||
188 | + .eq(CustomerCluePool::getOriginalShopId, shopId) | ||
189 | + .eq(CustomerCluePool::getClueType, FollowTypeEnum.IR) | ||
190 | + .eq(CustomerCluePool::getOriginalUserId, userId) | ||
191 | + ); | ||
192 | + if (CollectionUtils.isEmpty(list)) { | ||
193 | + return; | ||
194 | + } | ||
195 | + List<PostUserDTO> userList = userService.getUserByRole(shopId, RoleCode.XBGJ); | ||
196 | + BV.isNotEmpty(userList, () -> "更换跟进人员失败:没有更多续保跟进员"); | ||
197 | + Collections.shuffle(userList); | ||
198 | + PostUserDTO userDTO = userList.stream().filter(u -> !u.getUserId().equals(userId)).findAny().orElse(null); | ||
199 | + BV.notNull(userDTO, () -> "更换跟进人员失败:没有更多续保跟进员"); | ||
200 | + | ||
201 | + for (CustomerCluePool clue : list) { | ||
202 | + if (ClueStatusEnum.WAITING.equals(clue.getClueStatus())) { | ||
203 | + clue.setOriginalUserId(userDTO.getUserId()); | ||
204 | + clue.setOriginalUserName(userDTO.getUserName()); | ||
205 | + clue.setOriginalShopId(shopId); | ||
206 | + Optional.ofNullable(oopService.shop(shopId)).ifPresent(shop -> clue.setOriginalShopName(shop.getShortName())); | ||
207 | + continue; | ||
208 | + } | ||
209 | + dealTask(clue, userDTO.getUserId(), shopId); | ||
210 | + } | ||
211 | + | ||
212 | + customerCluePoolService.updateBatchById(list); | ||
213 | + } | ||
214 | + | ||
180 | private void prepareAllocation(LeaveAllocationDTO dto) { | 215 | private void prepareAllocation(LeaveAllocationDTO dto) { |
181 | AllocationTypeEnum typeEnum = AllocationTypeEnum.ofValue(dto.getAllocationType()); | 216 | AllocationTypeEnum typeEnum = AllocationTypeEnum.ofValue(dto.getAllocationType()); |
182 | BV.notNull(typeEnum, () -> "分配方式不正确,请重试"); | 217 | BV.notNull(typeEnum, () -> "分配方式不正确,请重试"); |
@@ -312,31 +347,27 @@ public class LeaveNeedDoBizService { | @@ -312,31 +347,27 @@ public class LeaveNeedDoBizService { | ||
312 | customerCluePoolService.updateBatchById(list); | 347 | customerCluePoolService.updateBatchById(list); |
313 | } | 348 | } |
314 | 349 | ||
315 | - private void dealTask(CustomerCluePool clue, Long adviserId, Long shopId) { | ||
316 | - if (Boolean.FALSE.equals(clue.getRedistribution())) { | ||
317 | - clue.setRedistribution(Boolean.TRUE); | ||
318 | - } | 350 | + private void dealTask(CustomerCluePool clue, Long userId, Long shopId) { |
319 | FollowTask task = followTaskService.queryOngoingTaskByClueId(clue.getId()); | 351 | FollowTask task = followTaskService.queryOngoingTaskByClueId(clue.getId()); |
320 | if (Objects.isNull(task)) { | 352 | if (Objects.isNull(task)) { |
321 | return; | 353 | return; |
322 | } | 354 | } |
323 | - UserInfoDTO user = userService.user(adviserId); | 355 | + UserInfoDTO user = userService.user(userId); |
324 | String userName = Objects.nonNull(user) ? user.getUserName() : ""; | 356 | String userName = Objects.nonNull(user) ? user.getUserName() : ""; |
325 | - | ||
326 | - if (Boolean.TRUE.equals(task.getRedistribution())) { | ||
327 | - task.setFollowUser(adviserId); | ||
328 | - task.setFollowUserName(userName); | ||
329 | - task.setFollowShop(shopId); | ||
330 | - followTaskService.updateById(task); | ||
331 | - stopRecord(task); | ||
332 | - return; | ||
333 | - } | ||
334 | task.setCloseTime(new Date()); | 357 | task.setCloseTime(new Date()); |
335 | task.setState(TaskStateEnum.DEFEAT); | 358 | task.setState(TaskStateEnum.DEFEAT); |
336 | task.setReason(TaskDefeatTypeEnum.D); | 359 | task.setReason(TaskDefeatTypeEnum.D); |
337 | followTaskService.updateById(task); | 360 | followTaskService.updateById(task); |
338 | followRecordService.removeByTaskId(task.getId()); | 361 | followRecordService.removeByTaskId(task.getId()); |
339 | 362 | ||
363 | + if (Boolean.TRUE.equals(task.getRedistribution())) { | ||
364 | + clue.setCloseTime(new Date()); | ||
365 | + clue.setClueStatus(ClueStatusEnum.FAILURE); | ||
366 | + return; | ||
367 | + } else { | ||
368 | + clue.setRedistribution(Boolean.TRUE); | ||
369 | + } | ||
370 | + | ||
340 | FollowTask nTask = new FollowTask(); | 371 | FollowTask nTask = new FollowTask(); |
341 | nTask.setClueId(clue.getId()); | 372 | nTask.setClueId(clue.getId()); |
342 | nTask.setCustomerId(clue.getRefererId()); | 373 | nTask.setCustomerId(clue.getRefererId()); |
@@ -345,7 +376,7 @@ public class LeaveNeedDoBizService { | @@ -345,7 +376,7 @@ public class LeaveNeedDoBizService { | ||
345 | nTask.setBeginTime(new Date()); | 376 | nTask.setBeginTime(new Date()); |
346 | nTask.setRedistribution(Boolean.TRUE); | 377 | nTask.setRedistribution(Boolean.TRUE); |
347 | nTask.setDeadline(clue.getDeadline()); | 378 | nTask.setDeadline(clue.getDeadline()); |
348 | - nTask.setFollowUser(adviserId); | 379 | + nTask.setFollowUser(userId); |
349 | task.setFollowUserName(userName); | 380 | task.setFollowUserName(userName); |
350 | nTask.setFollowShop(shopId); | 381 | nTask.setFollowShop(shopId); |
351 | nTask.setGroupId(clue.getGroupId()); | 382 | nTask.setGroupId(clue.getGroupId()); |
@@ -353,36 +384,6 @@ public class LeaveNeedDoBizService { | @@ -353,36 +384,6 @@ public class LeaveNeedDoBizService { | ||
353 | followBizService.startTask(nTask); | 384 | followBizService.startTask(nTask); |
354 | } | 385 | } |
355 | 386 | ||
356 | - private void stopRecord(FollowTask task) { | ||
357 | - List<FollowRecord> list = followRecordService.list(Wrappers.<FollowRecord>lambdaQuery() | ||
358 | - .eq(FollowRecord::getTaskId, task.getId()) | ||
359 | - .eq(FollowRecord::getOutTime, Boolean.FALSE) | ||
360 | - .eq(FollowRecord::getAddTodo, Boolean.FALSE) | ||
361 | - .isNull(FollowRecord::getFollowTime) | ||
362 | - ); | ||
363 | - if (!CollectionUtils.isEmpty(list)) { | ||
364 | - list.forEach(r -> { | ||
365 | - r.setUserId(task.getFollowUser()); | ||
366 | - r.setUserName(task.getFollowUserName()); | ||
367 | - r.setShopId(task.getFollowShop()); | ||
368 | - }); | ||
369 | - followRecordService.updateBatchById(list); | ||
370 | - } | ||
371 | - | ||
372 | - list = followRecordService.list(Wrappers.<FollowRecord>lambdaQuery() | ||
373 | - .eq(FollowRecord::getTaskId, task.getId()) | ||
374 | - .eq(FollowRecord::getOutTime, Boolean.FALSE) | ||
375 | - .eq(FollowRecord::getAddTodo, Boolean.TRUE) | ||
376 | - .isNull(FollowRecord::getFollowTime) | ||
377 | - ); | ||
378 | - if (CollectionUtils.isEmpty(list)) { | ||
379 | - return; | ||
380 | - } | ||
381 | - for (FollowRecord record : list) { | ||
382 | - followBizService.completeRecordAndEnd(record, true); | ||
383 | - } | ||
384 | - } | ||
385 | - | ||
386 | 387 | ||
387 | private void finish(LoginAuthBean user, Long leaveId, String key) { | 388 | private void finish(LoginAuthBean user, Long leaveId, String key) { |
388 | leaveNeedDoService.dealById(leaveId); | 389 | leaveNeedDoService.dealById(leaveId); |
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/FollowBizService.java
@@ -173,10 +173,10 @@ public class FollowBizService { | @@ -173,10 +173,10 @@ public class FollowBizService { | ||
173 | * @param record | 173 | * @param record |
174 | */ | 174 | */ |
175 | @Transactional(rollbackFor = Exception.class) | 175 | @Transactional(rollbackFor = Exception.class) |
176 | - public void completeRecordAndEnd(FollowRecord record, boolean needNew) { | 176 | + public void completeRecordAndEnd(FollowRecord record) { |
177 | FollowStrategy strategy = followMap.get(record.getType()); | 177 | FollowStrategy strategy = followMap.get(record.getType()); |
178 | Assert.notNull(strategy, "strategy cannot be null"); | 178 | Assert.notNull(strategy, "strategy cannot be null"); |
179 | - strategy.completeRecordAndEnd(record, needNew); | 179 | + strategy.completeRecordAndEnd(record); |
180 | } | 180 | } |
181 | 181 | ||
182 | /** | 182 | /** |
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/strategy/AbstractFollowStrategy.java
@@ -3,6 +3,7 @@ package cn.fw.valhalla.service.bus.follow.strategy; | @@ -3,6 +3,7 @@ package cn.fw.valhalla.service.bus.follow.strategy; | ||
3 | import cn.fw.common.cache.locker.DistributedLocker; | 3 | import cn.fw.common.cache.locker.DistributedLocker; |
4 | import cn.fw.common.exception.BusinessException; | 4 | import cn.fw.common.exception.BusinessException; |
5 | import cn.fw.common.web.auth.LoginAuthBean; | 5 | import cn.fw.common.web.auth.LoginAuthBean; |
6 | +import cn.fw.valhalla.common.constant.RoleCode; | ||
6 | import cn.fw.valhalla.common.utils.DateUtil; | 7 | import cn.fw.valhalla.common.utils.DateUtil; |
7 | import cn.fw.valhalla.common.utils.StringUtils; | 8 | import cn.fw.valhalla.common.utils.StringUtils; |
8 | import cn.fw.valhalla.domain.db.OriginalData; | 9 | import cn.fw.valhalla.domain.db.OriginalData; |
@@ -23,7 +24,9 @@ import cn.fw.valhalla.rpc.angel.dto.InsuranceDTO; | @@ -23,7 +24,9 @@ import cn.fw.valhalla.rpc.angel.dto.InsuranceDTO; | ||
23 | import cn.fw.valhalla.rpc.erp.TodoRpcService; | 24 | import cn.fw.valhalla.rpc.erp.TodoRpcService; |
24 | import cn.fw.valhalla.rpc.erp.UserService; | 25 | import cn.fw.valhalla.rpc.erp.UserService; |
25 | import cn.fw.valhalla.rpc.erp.dto.BackLogItemDTO; | 26 | import cn.fw.valhalla.rpc.erp.dto.BackLogItemDTO; |
27 | +import cn.fw.valhalla.rpc.erp.dto.PostUserDTO; | ||
26 | import cn.fw.valhalla.rpc.erp.dto.UserInfoDTO; | 28 | import cn.fw.valhalla.rpc.erp.dto.UserInfoDTO; |
29 | +import cn.fw.valhalla.rpc.erp.dto.UserRoleDataRangeDTO; | ||
27 | import cn.fw.valhalla.rpc.oop.OopService; | 30 | import cn.fw.valhalla.rpc.oop.OopService; |
28 | import cn.fw.valhalla.rpc.oop.dto.ShopDTO; | 31 | import cn.fw.valhalla.rpc.oop.dto.ShopDTO; |
29 | import cn.fw.valhalla.service.bus.cust.CustomerBizService; | 32 | import cn.fw.valhalla.service.bus.cust.CustomerBizService; |
@@ -234,7 +237,7 @@ public abstract class AbstractFollowStrategy implements FollowStrategy { | @@ -234,7 +237,7 @@ public abstract class AbstractFollowStrategy implements FollowStrategy { | ||
234 | 237 | ||
235 | @Override | 238 | @Override |
236 | @Transactional(rollbackFor = Exception.class) | 239 | @Transactional(rollbackFor = Exception.class) |
237 | - public void completeRecordAndEnd(FollowRecord record, boolean needNew) { | 240 | + public void completeRecordAndEnd(FollowRecord record) { |
238 | boolean equals = Boolean.FALSE.equals(record.getOutTime()) && Objects.isNull(record.getFollowTime()); | 241 | boolean equals = Boolean.FALSE.equals(record.getOutTime()) && Objects.isNull(record.getFollowTime()); |
239 | if (!equals) { | 242 | if (!equals) { |
240 | return; | 243 | return; |
@@ -242,9 +245,7 @@ public abstract class AbstractFollowStrategy implements FollowStrategy { | @@ -242,9 +245,7 @@ public abstract class AbstractFollowStrategy implements FollowStrategy { | ||
242 | final Date followTime = DateUtil.localDateTime2Date(LocalDateTime.now()); | 245 | final Date followTime = DateUtil.localDateTime2Date(LocalDateTime.now()); |
243 | record.setFollowTime(followTime); | 246 | record.setFollowTime(followTime); |
244 | followRecordService.updateById(record); | 247 | followRecordService.updateById(record); |
245 | - if (needNew) { | ||
246 | - this.addTaskRecord(record, false); | ||
247 | - } | 248 | + this.addTaskRecord(record, false); |
248 | BackLogItemDTO dto = new BackLogItemDTO(record.getUserId(), getItemCode(record.getType()), String.valueOf(record.getId()), followTime, record.getShopId()); | 249 | BackLogItemDTO dto = new BackLogItemDTO(record.getUserId(), getItemCode(record.getType()), String.valueOf(record.getId()), followTime, record.getShopId()); |
249 | todoRpcService.complete(dto); | 250 | todoRpcService.complete(dto); |
250 | } | 251 | } |
@@ -845,7 +846,7 @@ public abstract class AbstractFollowStrategy implements FollowStrategy { | @@ -845,7 +846,7 @@ public abstract class AbstractFollowStrategy implements FollowStrategy { | ||
845 | if (!CollectionUtils.isEmpty(recordList)) { | 846 | if (!CollectionUtils.isEmpty(recordList)) { |
846 | for (FollowRecord record : recordList) { | 847 | for (FollowRecord record : recordList) { |
847 | if (Boolean.TRUE.equals(record.getAddTodo())) { | 848 | if (Boolean.TRUE.equals(record.getAddTodo())) { |
848 | - completeRecordAndEnd(record, false); | 849 | + completeRecordAndEnd(record); |
849 | } else { | 850 | } else { |
850 | followRecordService.removeById(record.getId()); | 851 | followRecordService.removeById(record.getId()); |
851 | } | 852 | } |
@@ -867,6 +868,11 @@ public abstract class AbstractFollowStrategy implements FollowStrategy { | @@ -867,6 +868,11 @@ public abstract class AbstractFollowStrategy implements FollowStrategy { | ||
867 | if (!TaskStateEnum.ONGOING.equals(task.getState())) { | 868 | if (!TaskStateEnum.ONGOING.equals(task.getState())) { |
868 | return true; | 869 | return true; |
869 | } | 870 | } |
871 | + boolean isFwgw = FollowTypeEnum.FM.equals(task.getType()) || FollowTypeEnum.RM.equals(task.getType()); | ||
872 | + List<UserRoleDataRangeDTO> dataRange = userService.getUserRoleDataRange(task.getFollowUser(), isFwgw ? RoleCode.FWGW : RoleCode.XBGJ); | ||
873 | + if (CollectionUtils.isEmpty(dataRange)) { | ||
874 | + return true; | ||
875 | + } | ||
870 | //任务截止日期 | 876 | //任务截止日期 |
871 | final Date deadline = task.getDeadline(); | 877 | final Date deadline = task.getDeadline(); |
872 | Optional<SettingVO> fcsetting = settingBizService.querySettingByType(record.getType(), SettingTypeEnum.FOLLOW_CYCLE, record.getGroupId()); | 878 | Optional<SettingVO> fcsetting = settingBizService.querySettingByType(record.getType(), SettingTypeEnum.FOLLOW_CYCLE, record.getGroupId()); |
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/strategy/FollowStrategy.java
@@ -69,7 +69,7 @@ public interface FollowStrategy { | @@ -69,7 +69,7 @@ public interface FollowStrategy { | ||
69 | * | 69 | * |
70 | * @param record | 70 | * @param record |
71 | */ | 71 | */ |
72 | - void completeRecordAndEnd(FollowRecord record, boolean needNew); | 72 | + void completeRecordAndEnd(FollowRecord record); |
73 | 73 | ||
74 | /** | 74 | /** |
75 | * 上传跟进附件 | 75 | * 上传跟进附件 |
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/strategy/impl/ACFollowStrategy.java
@@ -105,7 +105,7 @@ public class ACFollowStrategy extends AbstractFollowStrategy { | @@ -105,7 +105,7 @@ public class ACFollowStrategy extends AbstractFollowStrategy { | ||
105 | } | 105 | } |
106 | 106 | ||
107 | @Override | 107 | @Override |
108 | - public void completeRecordAndEnd(FollowRecord record, boolean needNew) { | 108 | + public void completeRecordAndEnd(FollowRecord record) { |
109 | final Date followTime = DateUtil.localDateTime2Date(LocalDateTime.now()); | 109 | final Date followTime = DateUtil.localDateTime2Date(LocalDateTime.now()); |
110 | BackLogItemDTO dto = new BackLogItemDTO(record.getUserId(), getItemCode(record.getType()), String.valueOf(record.getId()), followTime, record.getShopId()); | 110 | BackLogItemDTO dto = new BackLogItemDTO(record.getUserId(), getItemCode(record.getType()), String.valueOf(record.getId()), followTime, record.getShopId()); |
111 | if (Boolean.FALSE.equals(record.getOutTime()) && Objects.isNull(record.getFollowTime())) { | 111 | if (Boolean.FALSE.equals(record.getOutTime()) && Objects.isNull(record.getFollowTime())) { |
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/data/impl/FollowRecordServiceImpl.java
@@ -73,7 +73,7 @@ public class FollowRecordServiceImpl extends ServiceImpl<FollowRecordMapper, Fol | @@ -73,7 +73,7 @@ public class FollowRecordServiceImpl extends ServiceImpl<FollowRecordMapper, Fol | ||
73 | public boolean removeByTaskId(Long taskId) { | 73 | public boolean removeByTaskId(Long taskId) { |
74 | return this.remove(Wrappers.<FollowRecord>lambdaQuery() | 74 | return this.remove(Wrappers.<FollowRecord>lambdaQuery() |
75 | .eq(FollowRecord::getTaskId, taskId) | 75 | .eq(FollowRecord::getTaskId, taskId) |
76 | - .eq(FollowRecord::getOutTime, Boolean.FALSE) | 76 | + .eq(FollowRecord::getAddTodo, Boolean.FALSE) |
77 | .isNull(FollowRecord::getFollowTime) | 77 | .isNull(FollowRecord::getFollowTime) |
78 | ); | 78 | ); |
79 | } | 79 | } |