|
@@ -41,10 +41,7 @@ import org.springframework.util.StringUtils;
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
-import java.util.concurrent.CompletableFuture;
|
|
|
|
|
-import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
|
-import java.util.concurrent.ThreadLocalRandom;
|
|
|
|
|
-import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
+import java.util.concurrent.*;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@Component
|
|
@Component
|
|
@@ -139,23 +136,24 @@ public class SendMsg {
|
|
|
Map<String, FsCoursePlaySourceConfig> miniMap = getMiniMap();
|
|
Map<String, FsCoursePlaySourceConfig> miniMap = getMiniMap();
|
|
|
// 获取 pad 发送的企微
|
|
// 获取 pad 发送的企微
|
|
|
getQwUserList().forEach(e -> {
|
|
getQwUserList().forEach(e -> {
|
|
|
- // 如果没有值就执行后面的方法 并且入值
|
|
|
|
|
qwMap.computeIfAbsent(e.getId(), k -> {
|
|
qwMap.computeIfAbsent(e.getId(), k -> {
|
|
|
- // 线程启动
|
|
|
|
|
- CompletableFuture.runAsync(() -> {
|
|
|
|
|
|
|
+ CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
|
|
|
try {
|
|
try {
|
|
|
log.info("开始任务:{}", e.getQwUserName());
|
|
log.info("开始任务:{}", e.getQwUserName());
|
|
|
- // 开始任务
|
|
|
|
|
processUser(e, delayStart, delayEnd, miniMap);
|
|
processUser(e, delayStart, delayEnd, miniMap);
|
|
|
} catch (Exception exception) {
|
|
} catch (Exception exception) {
|
|
|
log.error("发送错误:", exception);
|
|
log.error("发送错误:", exception);
|
|
|
} finally {
|
|
} finally {
|
|
|
log.info("删除任务:{}", e.getQwUserName());
|
|
log.info("删除任务:{}", e.getQwUserName());
|
|
|
qwMap.remove(e.getId());
|
|
qwMap.remove(e.getId());
|
|
|
-// removeQwMap.putIfAbsent(e.getId(), System.currentTimeMillis());
|
|
|
|
|
}
|
|
}
|
|
|
}, customThreadPool);
|
|
}, customThreadPool);
|
|
|
- return System.currentTimeMillis(); // 占位值
|
|
|
|
|
|
|
+ future.exceptionally(ex -> {
|
|
|
|
|
+ log.error("任务提交异常,userId={}, qwUserName={}", e.getId(), e.getQwUserName(), ex);
|
|
|
|
|
+ qwMap.remove(e.getId());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ });
|
|
|
|
|
+ return System.currentTimeMillis();
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|