|
@@ -2,6 +2,7 @@ package com.flow.job;
|
|
|
|
|
|
import com.flow.entity.Notify;
|
|
|
import com.flow.entity.User;
|
|
|
+import com.flow.enums.NotifyEnum;
|
|
|
import com.flow.mapstruct.NotifyRowMapper;
|
|
|
import dm.jdbc.filter.stat.json.JSONObject;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -59,9 +60,8 @@ public class SendUskyJob {
|
|
|
int notifySize = notifies.size();
|
|
|
log.info("需要同步的消息数量为:" + notifySize);
|
|
|
|
|
|
- if (!notifies.isEmpty()) {
|
|
|
+ if (notifySize > 0) {
|
|
|
sendUsky(notifies);
|
|
|
- updateNotify(notifies);
|
|
|
}
|
|
|
|
|
|
// 记录任务结束时间
|
|
@@ -82,6 +82,7 @@ public class SendUskyJob {
|
|
|
String subject = send.getSubject().split("-")[0];
|
|
|
String processName = send.getSubject().split("-")[1];
|
|
|
String approvalResult = "";
|
|
|
+ NotifyEnum sendType = send.getType();
|
|
|
|
|
|
log.info("审批单:{}", processName);
|
|
|
log.info("审批节点:{}", send.getContent());
|
|
@@ -103,21 +104,24 @@ public class SendUskyJob {
|
|
|
}
|
|
|
|
|
|
List<String> userNames = unSend.stream().map(Notify::getSender).collect(Collectors.toList());
|
|
|
- // Map<String, String> userNamesMap = unSendUser(userNames).stream()
|
|
|
- // .collect(Collectors.toMap(User::getUsername, User::getName));
|
|
|
log.info("查询到的未发送用户: {}", userNames);
|
|
|
-
|
|
|
List<User> unSendUsers = unSendUser(userNames);
|
|
|
log.info("查询到未发送的用户信息: {}", unSendUsers);
|
|
|
+
|
|
|
Map<String, String> userNamesMap = unSendUsers.stream()
|
|
|
- .collect(Collectors.toMap(User::getUsername, User::getName));
|
|
|
+ .filter(user -> user.getUsername() != null && user.getName() != null)
|
|
|
+ .collect(Collectors.toMap(
|
|
|
+ User::getUsername, User::getName,
|
|
|
+ (existingValue, newValue) -> existingValue
|
|
|
+ ));
|
|
|
+
|
|
|
log.info("查询到的用户映射: {}", userNamesMap);
|
|
|
|
|
|
if (userNamesMap.containsKey(send.getSender())) {
|
|
|
sendJson.put("infoTypeName", "OA审批");
|
|
|
sendJson.put("infoType", 3);
|
|
|
sendJson.put("infoTitle", "OA审批");
|
|
|
- sendJson.put("infoContent", userNamesMap.get(send.getSender()) + send.getSubject());
|
|
|
+ sendJson.put("infoContent", send.getSubject());
|
|
|
sendJson.put("userName", send.getSender());
|
|
|
sendJson.put("userNames", Collections.singletonList(send.getReceiver()));
|
|
|
sendJson.put("id", send.getId());
|
|
@@ -126,6 +130,12 @@ public class SendUskyJob {
|
|
|
sendJson.put("approvalNode", send.getContent());
|
|
|
sendJson.put("realName", userNamesMap.get(send.getSender()));
|
|
|
|
|
|
+ if ("system".equals(sendType.getType())) {
|
|
|
+ sendJson.put("oaType", "me");
|
|
|
+ } else {
|
|
|
+ sendJson.put("oaType", "todo");
|
|
|
+ }
|
|
|
+
|
|
|
String sendJsonString = sendJson.toString();
|
|
|
log.info("准备发送 {} 的消息:{} ", send.getSender(), sendJsonString);
|
|
|
|
|
@@ -143,6 +153,8 @@ public class SendUskyJob {
|
|
|
}
|
|
|
}
|
|
|
log.info("消息发送完成,成功数量:" + successCount + ",失败数量:" + failCount);
|
|
|
+ // 更新消息发送状态
|
|
|
+ updateNotify(unSend);
|
|
|
}
|
|
|
|
|
|
// 查询未发送的消息
|