Commit ffd4b675e8717069a71a8884f8a774fa1c5eba72
1 parent
88309c14
2022年10月20日15:12:42 重发直播审计待办接口
Showing
3 changed files
with
28 additions
and
11 deletions
fw-dalaran-domain/src/main/java/cn/fw/dalaran/domain/db/TodoHistory.java
... | ... | @@ -46,4 +46,11 @@ public class TodoHistory extends BaseAuditableTimeEntity<TodoHistory, Long> { |
46 | 46 | * 附加信息 |
47 | 47 | */ |
48 | 48 | private String extra; |
49 | + | |
50 | + /** | |
51 | + * 自定义去重条件 | |
52 | + */ | |
53 | + public String getRemoveDuplicatesCondition() { | |
54 | + return this.getUserId() + "-->" + this.getDataId(); | |
55 | + } | |
49 | 56 | } | ... | ... |
fw-dalaran-server/src/main/java/cn/fw/dalaran/server/controller/app/OtherController.java
... | ... | @@ -3,11 +3,10 @@ package cn.fw.dalaran.server.controller.app; |
3 | 3 | import cn.fw.common.web.annotation.ControllerMethod; |
4 | 4 | import cn.fw.common.web.auth.LoginAuthBean; |
5 | 5 | import cn.fw.common.web.auth.annotation.CurrentUser; |
6 | -import cn.fw.dalaran.common.constants.DalaranConstants; | |
7 | 6 | import cn.fw.dalaran.domain.param.LiveCheckParams; |
8 | 7 | import cn.fw.dalaran.domain.vo.LiveCheckVo; |
9 | 8 | import cn.fw.dalaran.rpc.erp.UserRoleRpcService; |
10 | -import cn.fw.dalaran.rpc.erp.dto.UserInfoDTO; | |
9 | +import cn.fw.dalaran.server.task.TodoTask; | |
11 | 10 | import cn.fw.dalaran.service.Common; |
12 | 11 | import cn.fw.dalaran.service.biz.OtherBizService; |
13 | 12 | import cn.fw.data.base.domain.common.Message; |
... | ... | @@ -23,7 +22,6 @@ import javax.validation.Valid; |
23 | 22 | import javax.validation.constraints.NotBlank; |
24 | 23 | import javax.validation.constraints.NotNull; |
25 | 24 | import java.io.File; |
26 | -import java.util.List; | |
27 | 25 | import java.util.Objects; |
28 | 26 | |
29 | 27 | import static cn.fw.common.web.util.ResultBuilder.success; |
... | ... | @@ -46,6 +44,7 @@ public class OtherController { |
46 | 44 | private final OtherBizService otherBizService; |
47 | 45 | private final Common common; |
48 | 46 | private final UserRoleRpcService userRoleRpcService; |
47 | + private final TodoTask todoTask;// 定时任务 | |
49 | 48 | |
50 | 49 | /** |
51 | 50 | * 获取直播审计页面 |
... | ... | @@ -110,13 +109,15 @@ public class OtherController { |
110 | 109 | } |
111 | 110 | |
112 | 111 | /** |
112 | + * 重发直播审计待办 | |
113 | 113 | * |
114 | - * @param shopId 门店id | |
114 | + * @param timestamp 时间戳 | |
115 | 115 | * @return |
116 | 116 | */ |
117 | - @GetMapping("/test") | |
118 | - public Message<List<UserInfoDTO>> test(Long shopId) { | |
119 | - return Message.success(userRoleRpcService.getUsers(shopId, DalaranConstants.ZBSJ_ROLE_CODE)); | |
117 | + @GetMapping("/resendLiveCheckBacklog") | |
118 | + public Message<Void> test(@NotNull(message = "请必须指定时间戳") Long timestamp) { | |
119 | + todoTask.sendLiveCheckBacklog(timestamp); | |
120 | + return Message.success(); | |
120 | 121 | } |
121 | 122 | |
122 | 123 | } | ... | ... |
fw-dalaran-server/src/main/java/cn/fw/dalaran/server/task/TodoTask.java
... | ... | @@ -136,12 +136,21 @@ public class TodoTask { |
136 | 136 | */ |
137 | 137 | @Scheduled(fixedRate = 15 * 60 * 1000, initialDelay = 5 * 1000) |
138 | 138 | public void sendLiveCheckBacklog() { |
139 | + this.sendLiveCheckBacklog(System.currentTimeMillis()); | |
140 | + } | |
141 | + | |
142 | + /** | |
143 | + * 发送直播审计待办 | |
144 | + * | |
145 | + * @param timeStamp 指定时间 | |
146 | + */ | |
147 | + public void sendLiveCheckBacklog(Long timeStamp) { | |
139 | 148 | final List<ActivityTheme> themeList = activityThemeService.lambdaQuery() |
140 | - .gt(ActivityTheme::getEndTime, new Date(System.currentTimeMillis() - 7 * 24 * 3600 * 1000)) | |
149 | + .gt(ActivityTheme::getEndTime, new Date(timeStamp - 7 * 24 * 3600 * 1000)) | |
141 | 150 | .list() |
142 | 151 | .stream() |
143 | 152 | .filter(item -> { |
144 | - final long timeSub = System.currentTimeMillis() - item.getEndTime().getTime(); | |
153 | + final long timeSub = timeStamp - item.getEndTime().getTime(); | |
145 | 154 | return 24 * 3600 * 1000 < timeSub && timeSub < 2 * 24 * 3600 * 1000; |
146 | 155 | }) |
147 | 156 | .collect(Collectors.toList());// 找到需要审计的主题 |
... | ... | @@ -187,7 +196,7 @@ public class TodoTask { |
187 | 196 | .map(item -> {// 遍历每个门店 |
188 | 197 | TodoHistory todo = new TodoHistory(); |
189 | 198 | List<UserInfoDTO> users = userRoleRpcService.getUsers(item, DalaranConstants.ZBSJ_ROLE_CODE);// 获取门店拥有'直播审计'角色的人 |
190 | - if (users.size() > 0) { | |
199 | + if (!users.isEmpty()) { | |
191 | 200 | todo.setSend(false); |
192 | 201 | todo.setDone(false); |
193 | 202 | todo.setTodoDone(false); |
... | ... | @@ -205,7 +214,7 @@ public class TodoTask { |
205 | 214 | }) |
206 | 215 | .filter(item -> Objects.nonNull(item.getTodoCode())) |
207 | 216 | .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> |
208 | - new TreeSet<>(Comparator.comparing(TodoHistory::getDataId))), ArrayList::new) | |
217 | + new TreeSet<>(Comparator.comparing(TodoHistory::getRemoveDuplicatesCondition))), ArrayList::new) | |
209 | 218 | ); |
210 | 219 | if (!Objects.equals(hasSaveTodo.size(), 0) && Objects.equals(collect.size(), hasSaveTodo.size())) |
211 | 220 | return; | ... | ... |