ValhallaGeneralApiServiceImpl.java
5.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
package cn.fw.valhalla.controller.api;
import cn.fw.common.web.annotation.ControllerMethod;
import cn.fw.data.base.domain.common.Message;
import cn.fw.valhalla.domain.db.follow.ClueTask;
import cn.fw.valhalla.domain.dto.CustomerDetailDto;
import cn.fw.valhalla.sdk.api.ValhallaGeneralApiService;
import cn.fw.valhalla.sdk.param.CustomerQueryReq;
import cn.fw.valhalla.sdk.param.ReachLogReq;
import cn.fw.valhalla.sdk.result.AccidentFollowerResult;
import cn.fw.valhalla.sdk.result.CustomerClueDeadline;
import cn.fw.valhalla.sdk.result.CustomerSimpleInfoDto;
import cn.fw.valhalla.service.bus.ReachLogBizService;
import cn.fw.valhalla.service.bus.cust.CustomerBizService;
import cn.fw.valhalla.service.bus.follow.ClueApiBizService;
import cn.fw.valhalla.service.bus.follow.FollowApiBizService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import static cn.fw.common.businessvalidator.Validator.BV;
import static cn.fw.common.web.util.ResultBuilder.success;
/**
* @author : kurisu
* @className : ValhallaGeneralApiServiceImpl
* @description : 通用api实现
* @date: 2020-11-11 16:01
*/
@Slf4j
@RestController
@RequestMapping("/api/valhalla/general")
public class ValhallaGeneralApiServiceImpl implements ValhallaGeneralApiService {
private final ReachLogBizService reachLogBizService;
/**
* 保有客数据服务
*/
private final CustomerBizService customerBiz;
private final FollowApiBizService followApiBizService;
private final ClueApiBizService clueApiBizService;
@Autowired
public ValhallaGeneralApiServiceImpl(final ReachLogBizService reachLogBizService,
final CustomerBizService customerBiz,
final FollowApiBizService followApiBizService,
final ClueApiBizService clueApiBizService) {
this.reachLogBizService = reachLogBizService;
this.customerBiz = customerBiz;
this.followApiBizService = followApiBizService;
this.clueApiBizService = clueApiBizService;
}
@PostMapping("/reach/save")
@Override
@ControllerMethod("保存进站记录")
public Message<Void> saveReachLog(@Valid @RequestBody ReachLogReq reachLogReq) {
reachLogBizService.saveReachLog(reachLogReq);
return success();
}
@Override
@PostMapping("/query/customer/list")
@ControllerMethod("查询保有客档案列表")
public Message<List<CustomerSimpleInfoDto>> queryCustomList(@Valid @RequestBody CustomerQueryReq customerQueryReq) {
List<CustomerDetailDto> list = customerBiz.queryCustomList(customerQueryReq);
List<CustomerSimpleInfoDto> dtoList = new ArrayList<>();
for (CustomerDetailDto customer : list) {
CustomerSimpleInfoDto dto = new CustomerSimpleInfoDto();
BeanUtils.copyProperties(customer, dto);
dtoList.add(dto);
}
return success(dtoList);
}
/**
* 查询车辆最短的一个跟进的截止日期(不包含事故车)
*
* @param vin
* @return
*/
@GetMapping("/query/customer/clue/deadline")
@Override
@ControllerMethod("查询车辆最短的一个跟进的截止日期")
public Message<CustomerClueDeadline> queryClueDeadline(@RequestParam("vin") final String vin, @RequestParam("groupId") final Long groupId) {
BV.isNotBlank(vin, () -> "vin不能为空");
return success(clueApiBizService.queryClueDeadline(vin, groupId));
}
/**
* 查询车辆最短的一个跟进的截止日期(不包含事故车)
*
* @param vinList
* @return
*/
@GetMapping("/query/customer/clue/batch/deadline")
@Override
@ControllerMethod("查询车辆最短的一个跟进的截止日期[批量]")
public Message<List<CustomerClueDeadline>> queryClueDeadlineBatch(@RequestParam("vinList") final List<String> vinList, @RequestParam("groupId") final Long groupId) {
BV.isNotEmpty(vinList, () -> "车辆vin不能为空");
int size = vinList.size();
BV.isTrue(size <= 1000, () -> "已经超过可查询的最大查询数量[1000]");
return success(clueApiBizService.queryClueDeadlineBatch(vinList, groupId));
}
@Override
@GetMapping("/query/accident/follower")
@ControllerMethod("查询进行中的事故车跟进人员")
public Message<AccidentFollowerResult> queryByPlate(@RequestParam("plateNo") String plateNo, @RequestParam("groupId") Long groupId) {
ClueTask clueTask = followApiBizService.queryAccidentFollowerByPlate(plateNo, groupId);
if (Objects.isNull(clueTask)) {
return success();
}
AccidentFollowerResult result = new AccidentFollowerResult();
result.setUserId(clueTask.getFollowUser());
result.setUserName(clueTask.getFollowUserName());
result.setShopId(clueTask.getFollowShop());
return success(result);
}
}