CommonController.java
5.05 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
package cn.fw.valhalla.controller.app;
import cn.fw.common.web.annotation.ControllerMethod;
import cn.fw.data.base.domain.common.Message;
import cn.fw.security.auth.client.annotation.Authorization;
import cn.fw.security.auth.client.annotation.IgnoreAuth;
import cn.fw.security.auth.client.enums.AuthType;
import cn.fw.valhalla.common.utils.DateUtil;
import cn.fw.valhalla.domain.vo.PostUserVO;
import cn.fw.valhalla.service.bus.CommonService;
import cn.fw.valhalla.service.bus.CustomerImportBizService;
import cn.fw.valhalla.service.bus.LeaveNeedDoBizService;
import cn.fw.valhalla.service.bus.follow.FollowBizService;
import cn.fw.valhalla.service.bus.pub.PubStandBizService;
import cn.fw.valhalla.service.report.CustomerRetentionRatioBizService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import static cn.fw.common.web.util.ResultBuilder.success;
/**
* @author : kurisu
* @className : CommonController
* @description : 公共接口
* @date: 2020-10-22 11:06
*/
@Slf4j
@RestController
@RequiredArgsConstructor
@Authorization(AuthType.APP)
@Validated
@RequestMapping("/app/common")
public class CommonController {
private final CommonService commonService;
private final LeaveNeedDoBizService leaveNeedDoBizService;
private final CustomerImportBizService customerImportBizService;
private final CustomerRetentionRatioBizService customerRetentionRatioBizService;
private final FollowBizService followBizService;
private final PubStandBizService pubStandBizService;
@GetMapping("/staff/list")
@IgnoreAuth
@ControllerMethod("查询人员")
public Message<List<PostUserVO>> list(@NotNull(message = "服务站ID不能为空") final Long shopId) {
List<PostUserVO> list = commonService.getUsers(shopId);
return success(list);
}
@GetMapping("/leave/add")
@Authorization(AuthType.NONE)
@ControllerMethod("添加离职待分配数据")
public Message<Void> add(@NotNull(message = "服务站ID不能为空") final Long shopId,
@NotNull(message = "用户ID不能为空") final Long userId) {
leaveNeedDoBizService.add(userId, shopId);
return success();
}
@GetMapping("/import/deal")
@Authorization(AuthType.NONE)
@ControllerMethod("处理导入的档案数据")
public Message<Void> dealImport() {
customerImportBizService.integrated();
return success();
}
@GetMapping("/import/apportion")
@Authorization(AuthType.NONE)
@ControllerMethod("导入的档案分配顾问")
public Message<Void> apportion() {
customerImportBizService.apportion();
return success();
}
@GetMapping("/crr/extracting")
@Authorization(AuthType.NONE)
@ControllerMethod("保有客保持率抽取")
public Message<Void> crrExtracting(String date) {
Date nowDate = new Date();
if (StringUtils.isNotBlank(date) && NumberUtils.isDigits(date)) {
LocalDateTime localDateTime = Instant.ofEpochMilli(NumberUtils.toLong(date)).atZone(ZoneId.systemDefault()).toLocalDateTime();
nowDate = DateUtil.localDateTime2Date(localDateTime);
}
customerRetentionRatioBizService.extracting(DateUtil.startDate(nowDate));
return success();
}
/**
* 交车后取消订单时回滚档案
*
* @param vin
* @return
*/
@GetMapping("/customer/rollback")
@Authorization(AuthType.NONE)
@ControllerMethod("交车后取消订单时回滚档案")
public Message<Void> customerRollback(@NotBlank(message = "车架号不能为空") String vin,
@RequestParam(defaultValue = "2", required = false, name = "groupId") Long groupId) {
commonService.rollBack(vin, groupId);
return success();
}
@GetMapping("/clue/manual/create")
@Authorization(AuthType.NONE)
@ControllerMethod("处理续保数据缺失")
public Message<Integer> createNextClue(Long groupId) {
if (Objects.isNull(groupId)) {
groupId = 2L;
}
commonService.createClue(groupId);
return success();
}
@GetMapping("/clue/manual/start")
@Authorization(AuthType.NONE)
@ControllerMethod("手动开始任务")
public Message<Integer> manualStartClue() {
followBizService.manualStartClue();
return success();
}
@PutMapping("/stand/sync")
@IgnoreAuth
@ControllerMethod("同步站岗队列")
public Message<Void> syncStand(Long groupId) {
if (Objects.isNull(groupId)) {
groupId = 2L;
}
pubStandBizService.syncQueue(groupId);
return success();
}
}