Commit 2d5d7cc737046169a8416ce73aa61c287de5dc32

Authored by 张志伟
1 parent dbd3caa4

:zap: 对接新待办

fw-valhalla-rpc/src/main/java/cn/fw/valhalla/rpc/backlog/dto/BackLogItemDTO.java
@@ -5,6 +5,7 @@ import lombok.EqualsAndHashCode; @@ -5,6 +5,7 @@ import lombok.EqualsAndHashCode;
5 import lombok.ToString; 5 import lombok.ToString;
6 6
7 import java.util.Date; 7 import java.util.Date;
  8 +import java.util.Map;
8 import java.util.Objects; 9 import java.util.Objects;
9 10
10 /** 11 /**
@@ -43,6 +44,7 @@ public class BackLogItemDTO { @@ -43,6 +44,7 @@ public class BackLogItemDTO {
43 private Date dataTime; 44 private Date dataTime;
44 private Date expireTime; 45 private Date expireTime;
45 private Long shopId; 46 private Long shopId;
  47 + private Map<String, String> dynamicMap;
46 48
47 public BackLogItemDTO(Long userId, String itemCode, String dataId, Date dataTime, Long shopId) { 49 public BackLogItemDTO(Long userId, String itemCode, String dataId, Date dataTime, Long shopId) {
48 this.userId = userId; 50 this.userId = userId;
fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/app/FollowController.java
@@ -15,9 +15,7 @@ import cn.fw.valhalla.domain.vo.follow.CustomerClueHistoryVO; @@ -15,9 +15,7 @@ import cn.fw.valhalla.domain.vo.follow.CustomerClueHistoryVO;
15 import cn.fw.valhalla.domain.vo.follow.FollowDetailVO; 15 import cn.fw.valhalla.domain.vo.follow.FollowDetailVO;
16 import cn.fw.valhalla.domain.vo.follow.FollowRecordVO; 16 import cn.fw.valhalla.domain.vo.follow.FollowRecordVO;
17 import cn.fw.valhalla.domain.vo.follow.FollowTodoListVO; 17 import cn.fw.valhalla.domain.vo.follow.FollowTodoListVO;
18 -import cn.fw.valhalla.rpc.sms.SmsRpcService;  
19 import cn.fw.valhalla.service.bus.follow.FollowBizService; 18 import cn.fw.valhalla.service.bus.follow.FollowBizService;
20 -import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;  
21 import lombok.extern.slf4j.Slf4j; 19 import lombok.extern.slf4j.Slf4j;
22 import org.springframework.beans.factory.annotation.Autowired; 20 import org.springframework.beans.factory.annotation.Autowired;
23 import org.springframework.validation.annotation.Validated; 21 import org.springframework.validation.annotation.Validated;
@@ -29,10 +27,7 @@ import java.util.List; @@ -29,10 +27,7 @@ import java.util.List;
29 import java.util.Objects; 27 import java.util.Objects;
30 28
31 import static cn.fw.common.businessvalidator.Validator.BV; 29 import static cn.fw.common.businessvalidator.Validator.BV;
32 -import static cn.fw.common.web.util.ExceptionHandler.handleException;  
33 -import static cn.fw.common.web.util.ResultBuilder.failureWithMessage;  
34 import static cn.fw.common.web.util.ResultBuilder.success; 30 import static cn.fw.common.web.util.ResultBuilder.success;
35 -import static cn.fw.valhalla.common.constant.MessageStr.QUERY_FAILURE;  
36 31
37 /** 32 /**
38 * @author : kurisu 33 * @author : kurisu
@@ -56,6 +51,7 @@ public class FollowController { @@ -56,6 +51,7 @@ public class FollowController {
56 51
57 @GetMapping("/todo/list") 52 @GetMapping("/todo/list")
58 @ControllerMethod("分页查询跟进待办列表") 53 @ControllerMethod("分页查询跟进待办列表")
  54 + @Deprecated
59 public Message<AppPage<FollowTodoListVO>> todoList(@CurrentUser LoginAuthBean currentUser, final FollowQueryVO queryVO) { 55 public Message<AppPage<FollowTodoListVO>> todoList(@CurrentUser LoginAuthBean currentUser, final FollowQueryVO queryVO) {
60 BV.notNull(queryVO.getType(), "跟进类型不正确"); 56 BV.notNull(queryVO.getType(), "跟进类型不正确");
61 AppPage<FollowTodoListVO> page = followBizService.todoList(queryVO, currentUser); 57 AppPage<FollowTodoListVO> page = followBizService.todoList(queryVO, currentUser);
@@ -64,11 +60,8 @@ public class FollowController { @@ -64,11 +60,8 @@ public class FollowController {
64 60
65 @GetMapping("/todo/detail") 61 @GetMapping("/todo/detail")
66 @ControllerMethod("查询跟进待办详情") 62 @ControllerMethod("查询跟进待办详情")
67 - public Message<FollowDetailVO> todoDetail(@NotNull(message = "跟进记录id不能为空") final Long id,  
68 - @NotNull(message = "跟进类型不能为空") final Integer type) {  
69 - FollowTypeEnum typeEnum = FollowTypeEnum.ofValue(type);  
70 - BV.notNull(typeEnum, "跟进类型不正确");  
71 - FollowDetailVO detailVO = followBizService.todoDetail(id, typeEnum); 63 + public Message<FollowDetailVO> todoDetail(@NotNull(message = "跟进记录id不能为空") final Long id) {
  64 + FollowDetailVO detailVO = followBizService.todoDetail(id);
72 return success(detailVO); 65 return success(detailVO);
73 } 66 }
74 67
@@ -83,8 +76,8 @@ public class FollowController { @@ -83,8 +76,8 @@ public class FollowController {
83 @GetMapping("/todo/record") 76 @GetMapping("/todo/record")
84 @IgnoreAuth 77 @IgnoreAuth
85 @ControllerMethod("查询跟进历史记录") 78 @ControllerMethod("查询跟进历史记录")
86 - public Message<List<FollowRecordVO>> todoRecord(@NotNull(message = "跟进任务id不能为空") final Long taskId, final Integer type) {  
87 - return success(followBizService.todoRecord(taskId, type)); 79 + public Message<List<FollowRecordVO>> todoRecord(@NotNull(message = "跟进任务id不能为空") final Long taskId) {
  80 + return success(followBizService.todoRecord(taskId));
88 } 81 }
89 82
90 @GetMapping("/sms/template") 83 @GetMapping("/sms/template")
fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/task/FollowRecordTask.java
1 package cn.fw.valhalla.controller.task; 1 package cn.fw.valhalla.controller.task;
2 2
3 import cn.fw.valhalla.common.utils.DateUtil; 3 import cn.fw.valhalla.common.utils.DateUtil;
  4 +import cn.fw.valhalla.common.utils.StringUtils;
4 import cn.fw.valhalla.domain.db.follow.FollowRecord; 5 import cn.fw.valhalla.domain.db.follow.FollowRecord;
5 import cn.fw.valhalla.domain.db.follow.FollowTask; 6 import cn.fw.valhalla.domain.db.follow.FollowTask;
6 import cn.fw.valhalla.domain.enums.FollowTypeEnum; 7 import cn.fw.valhalla.domain.enums.FollowTypeEnum;
7 import cn.fw.valhalla.domain.enums.TaskStateEnum; 8 import cn.fw.valhalla.domain.enums.TaskStateEnum;
  9 +import cn.fw.valhalla.domain.vo.follow.*;
8 import cn.fw.valhalla.rpc.backlog.TodoRpcService; 10 import cn.fw.valhalla.rpc.backlog.TodoRpcService;
9 import cn.fw.valhalla.rpc.backlog.dto.BackLogItemDTO; 11 import cn.fw.valhalla.rpc.backlog.dto.BackLogItemDTO;
10 import cn.fw.valhalla.service.bus.follow.FollowBizService; 12 import cn.fw.valhalla.service.bus.follow.FollowBizService;
@@ -21,10 +23,7 @@ import org.springframework.transaction.annotation.Transactional; @@ -21,10 +23,7 @@ import org.springframework.transaction.annotation.Transactional;
21 import org.springframework.util.CollectionUtils; 23 import org.springframework.util.CollectionUtils;
22 24
23 import java.time.LocalDateTime; 25 import java.time.LocalDateTime;
24 -import java.util.ArrayList;  
25 -import java.util.Collection;  
26 -import java.util.List;  
27 -import java.util.Objects; 26 +import java.util.*;
28 27
29 /** 28 /**
30 * @author : kurisu 29 * @author : kurisu
@@ -154,6 +153,7 @@ public class FollowRecordTask { @@ -154,6 +153,7 @@ public class FollowRecordTask {
154 if (Objects.nonNull(task) && TaskStateEnum.ONGOING.equals(task.getState())) { 153 if (Objects.nonNull(task) && TaskStateEnum.ONGOING.equals(task.getState())) {
155 BackLogItemDTO dto = new BackLogItemDTO(record.getUserId(), getItemCode(record.getType()), String.valueOf(record.getId()), record.getPlanTime(), record.getShopId()); 154 BackLogItemDTO dto = new BackLogItemDTO(record.getUserId(), getItemCode(record.getType()), String.valueOf(record.getId()), record.getPlanTime(), record.getShopId());
156 dto.setExpireTime(record.getDeadline()); 155 dto.setExpireTime(record.getDeadline());
  156 + dto.setDynamicMap(create(record));
157 todoRpcService.push(dto); 157 todoRpcService.push(dto);
158 idList.add(record.getId()); 158 idList.add(record.getId());
159 } else { 159 } else {
@@ -166,6 +166,32 @@ public class FollowRecordTask { @@ -166,6 +166,32 @@ public class FollowRecordTask {
166 } 166 }
167 } 167 }
168 168
  169 + private Map<String, String> create(FollowRecord record) {
  170 + FollowDetailVO vo = followBizService.todoDetail(record.getId(), record.getType());
  171 + Map<String, String> dynamicMap = new HashMap<>();
  172 + dynamicMap.put("type", record.getType().getValue().toString());
  173 + dynamicMap.put("taskId", record.getTaskId().toString());
  174 + dynamicMap.put("id", record.getId().toString());
  175 + if (Objects.nonNull(vo)) {
  176 + dynamicMap.put("state", "1");
  177 + dynamicMap.put("plateNo", StringUtils.isValid(vo.getPlateNo()) ? vo.getPlateNo() : "");
  178 + dynamicMap.put("name", StringUtils.isValid(vo.getName()) ? vo.getPlateNo() : "");
  179 + if (vo instanceof FMDetailVO) {
  180 + dynamicMap.put("buyDate", DateUtil.getFullDateString(((FMDetailVO) vo).getBuyDate()));
  181 + dynamicMap.put("expirTime", DateUtil.getFullDateString(((FMDetailVO) vo).getFMExpiration()));
  182 + } else if (vo instanceof RMDetailVO) {
  183 + dynamicMap.put("currentMileage", Optional.ofNullable(((RMDetailVO) vo).getLastMileage()).map(String::valueOf).orElse(""));
  184 + dynamicMap.put("arrivalTime", DateUtil.getFullDateString(((RMDetailVO) vo).getDeliveryTime()));
  185 + } else if (vo instanceof IRDetailVO) {
  186 + dynamicMap.put("expirTime", DateUtil.getFullDateString(((IRDetailVO) vo).getTclInsExpiration()));
  187 + dynamicMap.put("insComName", StringUtils.isValid(((IRDetailVO) vo).getTclInsComName()) ? vo.getPlateNo() : "");
  188 + } else if (vo instanceof ACDetailVO) {
  189 + dynamicMap.put("insComName", StringUtils.isValid(((ACDetailVO) vo).getInsComName()) ? vo.getPlateNo() : "");
  190 + }
  191 + }
  192 + return dynamicMap;
  193 + }
  194 +
169 private String getItemCode(FollowTypeEnum type) { 195 private String getItemCode(FollowTypeEnum type) {
170 switch (type) { 196 switch (type) {
171 case AC: 197 case AC:
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/FollowBizService.java
@@ -118,6 +118,7 @@ public class FollowBizService { @@ -118,6 +118,7 @@ public class FollowBizService {
118 * @param currentUser 118 * @param currentUser
119 * @return 119 * @return
120 */ 120 */
  121 + @Deprecated
121 public AppPage<FollowTodoListVO> todoList(FollowQueryVO queryVO, LoginAuthBean currentUser) { 122 public AppPage<FollowTodoListVO> todoList(FollowQueryVO queryVO, LoginAuthBean currentUser) {
122 Integer pageSize = queryVO.getPageSize(); 123 Integer pageSize = queryVO.getPageSize();
123 Integer current = queryVO.getCurrent(); 124 Integer current = queryVO.getCurrent();
@@ -156,7 +157,20 @@ public class FollowBizService { @@ -156,7 +157,20 @@ public class FollowBizService {
156 * 查询待办详情 157 * 查询待办详情
157 * 158 *
158 * @param id 159 * @param id
159 - * @param type 160 + * @return
  161 + */
  162 + public FollowDetailVO todoDetail(Long id) {
  163 + FollowTask followTask = followTaskService.getById(id);
  164 + BV.notNull(followTask, () -> "跟进不能为空");
  165 + FollowStrategy strategy = followMap.get(followTask.getType());
  166 + Assert.notNull(strategy, "strategy cannot be null");
  167 + return strategy.getDetail(id);
  168 + }
  169 +
  170 + /**
  171 + * 查询待办详情
  172 + *
  173 + * @param id
160 * @return 174 * @return
161 */ 175 */
162 public FollowDetailVO todoDetail(Long id, FollowTypeEnum type) { 176 public FollowDetailVO todoDetail(Long id, FollowTypeEnum type) {
@@ -169,17 +183,12 @@ public class FollowBizService { @@ -169,17 +183,12 @@ public class FollowBizService {
169 * 查询跟进历史 183 * 查询跟进历史
170 * 184 *
171 * @param taskId 185 * @param taskId
172 - * @param type  
173 * @return 186 * @return
174 */ 187 */
175 - public List<FollowRecordVO> todoRecord(Long taskId, Integer type) {  
176 - FollowTypeEnum typeEnum = FollowTypeEnum.ofValue(type);  
177 - if (Objects.isNull(typeEnum)) {  
178 - FollowTask task = followTaskService.getById(taskId);  
179 - BV.notNull(task, () -> "跟进任务不存在");  
180 - typeEnum = task.getType();  
181 - }  
182 - FollowStrategy strategy = followMap.get(typeEnum); 188 + public List<FollowRecordVO> todoRecord(Long taskId) {
  189 + FollowTask task = followTaskService.getById(taskId);
  190 + BV.notNull(task, () -> "跟进任务不存在");
  191 + FollowStrategy strategy = followMap.get(task.getType());
183 BV.notNull(strategy, () -> "跟进类型不正确"); 192 BV.notNull(strategy, () -> "跟进类型不正确");
184 return strategy.getRecordList(taskId); 193 return strategy.getRecordList(taskId);
185 } 194 }