|
@@ -24,6 +24,7 @@ import work.baiyun.chronicdiseaseapp.service.UserBindingService;
|
|
|
import work.baiyun.chronicdiseaseapp.util.SecurityUtils;
|
|
import work.baiyun.chronicdiseaseapp.util.SecurityUtils;
|
|
|
import work.baiyun.chronicdiseaseapp.mapper.PatientReminderMapper;
|
|
import work.baiyun.chronicdiseaseapp.mapper.PatientReminderMapper;
|
|
|
import work.baiyun.chronicdiseaseapp.model.po.PatientReminder;
|
|
import work.baiyun.chronicdiseaseapp.model.po.PatientReminder;
|
|
|
|
|
+import work.baiyun.chronicdiseaseapp.enums.SubscriptionAvailability;
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -72,14 +73,15 @@ public class MessageServiceImpl implements MessageService {
|
|
|
// 推送通知(先检查患者提醒设置)
|
|
// 推送通知(先检查患者提醒设置)
|
|
|
if (message.getNotifySubscribe() == 1) {
|
|
if (message.getNotifySubscribe() == 1) {
|
|
|
boolean canSend = true;
|
|
boolean canSend = true;
|
|
|
|
|
+ PatientReminder pr = null;
|
|
|
try {
|
|
try {
|
|
|
- PatientReminder pr = patientReminderMapper.selectByPatientUserId(receiverId);
|
|
|
|
|
|
|
+ pr = patientReminderMapper.selectByPatientUserId(receiverId);
|
|
|
if (pr != null) {
|
|
if (pr != null) {
|
|
|
// 如果总开关被关闭,禁止推送;如果订阅授权不可用,也禁止
|
|
// 如果总开关被关闭,禁止推送;如果订阅授权不可用,也禁止
|
|
|
if (pr.getNotificationEnabled() == null || pr.getNotificationEnabled() != 1) {
|
|
if (pr.getNotificationEnabled() == null || pr.getNotificationEnabled() != 1) {
|
|
|
canSend = false;
|
|
canSend = false;
|
|
|
}
|
|
}
|
|
|
- if (pr.getSubscriptionAvailable() == null || pr.getSubscriptionAvailable() != 1) {
|
|
|
|
|
|
|
+ if (pr.getSubscriptionAvailable() == null || pr.getSubscriptionAvailable() == SubscriptionAvailability.NONE) {
|
|
|
canSend = false;
|
|
canSend = false;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -94,6 +96,12 @@ public class MessageServiceImpl implements MessageService {
|
|
|
String nickname = user != null ? user.getNickname() : "未知用户";
|
|
String nickname = user != null ? user.getNickname() : "未知用户";
|
|
|
if (pushResult.get("errcode").equals(0)) {
|
|
if (pushResult.get("errcode").equals(0)) {
|
|
|
pushDetails.append("已成功推送给患者").append(nickname).append("\n");
|
|
pushDetails.append("已成功推送给患者").append(nickname).append("\n");
|
|
|
|
|
+ try {
|
|
|
|
|
+ if (pr != null && pr.getSubscriptionAvailable() == SubscriptionAvailability.ONCE) {
|
|
|
|
|
+ pr.setSubscriptionAvailable(SubscriptionAvailability.NONE);
|
|
|
|
|
+ patientReminderMapper.updateById(pr);
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception ignored) {}
|
|
|
} else {
|
|
} else {
|
|
|
pushDetails.append("未能推送给患者").append(nickname).append("(无权限)\n");
|
|
pushDetails.append("未能推送给患者").append(nickname).append("(无权限)\n");
|
|
|
}
|
|
}
|
|
@@ -127,7 +135,7 @@ public class MessageServiceImpl implements MessageService {
|
|
|
if (prFamily.getNotificationEnabled() == null || prFamily.getNotificationEnabled() != 1) {
|
|
if (prFamily.getNotificationEnabled() == null || prFamily.getNotificationEnabled() != 1) {
|
|
|
canSendFamily = false;
|
|
canSendFamily = false;
|
|
|
}
|
|
}
|
|
|
- if (prFamily.getSubscriptionAvailable() == null || prFamily.getSubscriptionAvailable() != 1) {
|
|
|
|
|
|
|
+ if (prFamily.getSubscriptionAvailable() == null || prFamily.getSubscriptionAvailable() == SubscriptionAvailability.NONE) {
|
|
|
canSendFamily = false;
|
|
canSendFamily = false;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -142,6 +150,13 @@ public class MessageServiceImpl implements MessageService {
|
|
|
String familyNickname = familyUser != null ? familyUser.getNickname() : "未知用户";
|
|
String familyNickname = familyUser != null ? familyUser.getNickname() : "未知用户";
|
|
|
if (pushResultFamily.get("errcode").equals(0)) {
|
|
if (pushResultFamily.get("errcode").equals(0)) {
|
|
|
pushDetails.append("已成功推送给患者家属").append(familyNickname).append("\n");
|
|
pushDetails.append("已成功推送给患者家属").append(familyNickname).append("\n");
|
|
|
|
|
+ try {
|
|
|
|
|
+ PatientReminder prFamily = patientReminderMapper.selectByPatientUserId(familyId);
|
|
|
|
|
+ if (prFamily != null && prFamily.getSubscriptionAvailable() == SubscriptionAvailability.ONCE) {
|
|
|
|
|
+ prFamily.setSubscriptionAvailable(SubscriptionAvailability.NONE);
|
|
|
|
|
+ patientReminderMapper.updateById(prFamily);
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception ignored) {}
|
|
|
} else {
|
|
} else {
|
|
|
pushDetails.append("未能推送给患者家属").append(familyNickname).append("(无权限)\n");
|
|
pushDetails.append("未能推送给患者家属").append(familyNickname).append("(无权限)\n");
|
|
|
}
|
|
}
|
|
@@ -290,7 +305,7 @@ public class MessageServiceImpl implements MessageService {
|
|
|
if (pr.getNotificationEnabled() == null || pr.getNotificationEnabled() != 1) {
|
|
if (pr.getNotificationEnabled() == null || pr.getNotificationEnabled() != 1) {
|
|
|
canSendAnomaly = false;
|
|
canSendAnomaly = false;
|
|
|
}
|
|
}
|
|
|
- if (pr.getSubscriptionAvailable() == null || pr.getSubscriptionAvailable() != 1) {
|
|
|
|
|
|
|
+ if (pr.getSubscriptionAvailable() == null || pr.getSubscriptionAvailable() == SubscriptionAvailability.NONE) {
|
|
|
canSendAnomaly = false;
|
|
canSendAnomaly = false;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|