|
@@ -14,6 +14,7 @@ import com.lantone.common.enums.StatusEnum;
|
|
|
import com.lantone.common.exception.Asserts;
|
|
|
import com.lantone.common.util.DateUtil;
|
|
|
import com.lantone.common.util.ListUtil;
|
|
|
+import com.lantone.common.util.StringUtil;
|
|
|
import com.lantone.common.util.SysUserUtils;
|
|
|
import com.lantone.common.vo.AddNoticeVO;
|
|
|
import com.lantone.common.vo.GetHospitalUserVO;
|
|
@@ -85,6 +86,7 @@ public class NoticeManagementFacade {
|
|
|
*/
|
|
|
public IPage<GetMyNoticeListDTO> listPage(GetMyNoticeListVO getMyNoticeListVO) {
|
|
|
getMyNoticeListVO.setId(SysUserUtils.getCurrentPrincipleId());
|
|
|
+ getMyNoticeListVO.setHospitalId(SysUserUtils.getCurrentHospitalId());
|
|
|
return noticeUserFacade.getBaseMapper().listPage(getMyNoticeListVO);
|
|
|
}
|
|
|
|
|
@@ -114,14 +116,14 @@ public class NoticeManagementFacade {
|
|
|
notice.setCreator(SysUserUtils.getCurrentPrincipleId() + "");
|
|
|
notice.setGmtCreate(DateUtil.now());
|
|
|
//根据通知类型查询通知用户
|
|
|
- Set<Long> userIds = new HashSet<>();
|
|
|
+ Set<HospitalUser> hospitalUsers = new HashSet<>();
|
|
|
if (ReceiveTypeEnum.ALL.getKey().equals(addNoticeVO.getReceiveType())) {
|
|
|
//获取当前登录用户管理的医院
|
|
|
List<Long> hospitals = hospitalFacade.getBaseMapper()
|
|
|
.getHospitalTreeInfo(SysUserUtils.getCurrentHospitalId(), StatusEnum.Enable.getKey()).stream()
|
|
|
.map(GetHospitalTreeDTO::getHospitalId).collect(Collectors.toList());
|
|
|
//获取这些组织的用户
|
|
|
- getUserByHospitals(hospitals, userIds);
|
|
|
+ getUserByHospitals(hospitals, hospitalUsers);
|
|
|
} else if (ReceiveTypeEnum.CUSTOM.getKey().equals(addNoticeVO.getReceiveType())) {
|
|
|
if (ListUtil.isEmpty(addNoticeVO.getSendHospitals()) &&
|
|
|
ListUtil.isEmpty(addNoticeVO.getSendDepts()) &&
|
|
@@ -130,46 +132,58 @@ public class NoticeManagementFacade {
|
|
|
}
|
|
|
//获取通知的医院-转成用户
|
|
|
if (ListUtil.isNotEmpty(addNoticeVO.getSendHospitals())) {
|
|
|
- getUserByHospitals(addNoticeVO.getSendHospitals(), userIds);
|
|
|
+ getUserByHospitals(addNoticeVO.getSendHospitals(), hospitalUsers);
|
|
|
}
|
|
|
//获取通知的科室-转成用户
|
|
|
if (ListUtil.isNotEmpty(addNoticeVO.getSendDepts())) {
|
|
|
- getUserByDepts(addNoticeVO.getSendDepts(), userIds);
|
|
|
+ getUserByDepts(addNoticeVO.getSendDepts(), hospitalUsers);
|
|
|
}
|
|
|
if (ListUtil.isNotEmpty(addNoticeVO.getSendUsers())) {
|
|
|
- userIds.addAll(addNoticeVO.getSendUsers());
|
|
|
+ try {
|
|
|
+ addNoticeVO.getSendUsers().stream().forEach(temp -> {
|
|
|
+ if (StringUtil.isNotBlank(temp) && temp.contains("-")) {
|
|
|
+ HospitalUser hospitaluser = new HospitalUser();
|
|
|
+ hospitaluser.setHospitalId(Long.parseLong(temp.split("-")[0]));
|
|
|
+ hospitaluser.setUserId(Long.parseLong(temp.split("-")[1]));
|
|
|
+ hospitalUsers.add(hospitaluser);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } catch (Exception e) {
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
Asserts.fail("接收类型不存在,请检查重新输入~");
|
|
|
}
|
|
|
- if (userIds.isEmpty()) {
|
|
|
+ if (hospitalUsers.isEmpty()) {
|
|
|
Asserts.fail("通知用户为空,请联系管理员~");
|
|
|
}
|
|
|
if (noticeFacade.save(notice)) {
|
|
|
//发送通知
|
|
|
- return sendNotice(userIds, notice.getId());
|
|
|
+ return sendNotice(hospitalUsers, notice.getId());
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @param userIds
|
|
|
+ * @param hospitalUsers
|
|
|
* @param id
|
|
|
* @Description发送通知
|
|
|
* @Return java.lang.Boolean
|
|
|
*/
|
|
|
- private Boolean sendNotice(Set<Long> userIds, Long id) {
|
|
|
+ private Boolean sendNotice(Set<HospitalUser> hospitalUsers, Long id) {
|
|
|
List<NoticeUser> noticeUsers = new ArrayList<>();
|
|
|
List<SendToTopicDTO> sendToTopics = new ArrayList<>();
|
|
|
- userIds.stream().forEach(userId -> {
|
|
|
+ hospitalUsers.stream().forEach(hospitalUser -> {
|
|
|
NoticeUser noticeUser = new NoticeUser();
|
|
|
- noticeUser.setUserId(userId);
|
|
|
+ noticeUser.setHospitalId(hospitalUser.getHospitalId());
|
|
|
+ noticeUser.setUserId(hospitalUser.getUserId());
|
|
|
noticeUser.setNoticeId(id);
|
|
|
noticeUsers.add(noticeUser);
|
|
|
SendToTopicDTO sendToTopicDTO = new SendToTopicDTO();
|
|
|
sendToTopicDTO.setMessage("+1");
|
|
|
sendToTopicDTO.setType("count");
|
|
|
- sendToTopicDTO.setTopic(userId + "");
|
|
|
+ sendToTopicDTO.setTopic(hospitalUser.getHospitalId() + "-" + hospitalUser.getUserId() + "");
|
|
|
sendToTopics.add(sendToTopicDTO);
|
|
|
});
|
|
|
messageService.sendToTopic(sendToTopics);
|
|
@@ -178,45 +192,43 @@ public class NoticeManagementFacade {
|
|
|
|
|
|
/**
|
|
|
* @param hospitals
|
|
|
- * @param userIds
|
|
|
+ * @param hospitalUsers
|
|
|
* @Description获取医院的用户
|
|
|
* @Return void
|
|
|
*/
|
|
|
- private void getUserByHospitals(List<Long> hospitals, Set<Long> userIds) {
|
|
|
+ private void getUserByHospitals(List<Long> hospitals, Set<HospitalUser> hospitalUsers) {
|
|
|
|
|
|
if (ListUtil.isEmpty(hospitals)) {
|
|
|
Asserts.fail("当前管理员发送通知的组织集合为空,请联系管理员~");
|
|
|
}
|
|
|
//获取该医院的用户
|
|
|
- Set<Long> tempUsers = hospitalUserFacade.list(new QueryWrapper<HospitalUser>()
|
|
|
+ Set<HospitalUser> tempUsers = hospitalUserFacade.list(new QueryWrapper<HospitalUser>()
|
|
|
.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
- .in("hospital_id", hospitals)).stream().map(HospitalUser::getUserId).collect(Collectors.toSet());
|
|
|
+ .in("hospital_id", hospitals)).stream().collect(Collectors.toSet());
|
|
|
if (tempUsers != null && tempUsers.isEmpty()) {
|
|
|
- userIds.addAll(tempUsers);
|
|
|
+ hospitalUsers.addAll(tempUsers);
|
|
|
}
|
|
|
//获取医院的科室
|
|
|
List<Long> tempDepts = deptFacade.list(new QueryWrapper<Dept>()
|
|
|
.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
.in("hospital_id", hospitals)).stream().map(Dept::getId).collect(Collectors.toList());
|
|
|
if (ListUtil.isNotEmpty(tempDepts)) {
|
|
|
- getUserByDepts(tempDepts, userIds);
|
|
|
+ getUserByDepts(tempDepts, hospitalUsers);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @param depts
|
|
|
- * @param userIds
|
|
|
+ * @param hospitalUsers
|
|
|
* @Description获取科室的用户
|
|
|
* @Return void
|
|
|
*/
|
|
|
- private void getUserByDepts(List<Long> depts, Set<Long> userIds) {
|
|
|
+ private void getUserByDepts(List<Long> depts, Set<HospitalUser> hospitalUsers) {
|
|
|
if (ListUtil.isEmpty(depts)) {
|
|
|
Asserts.fail("当前管理员发送通知的组织集合为空,请联系管理员~");
|
|
|
}
|
|
|
//获取该医院的用户
|
|
|
- userIds.addAll(deptUserFacade.list(new QueryWrapper<DeptUser>()
|
|
|
- .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
- .in("dept_id", depts)).stream().map(DeptUser::getUserId).collect(Collectors.toSet()));
|
|
|
+ hospitalUsers.addAll(deptUserFacade.getBaseMapper().getDeptUser(depts).stream().collect(Collectors.toSet()));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -277,6 +289,7 @@ public class NoticeManagementFacade {
|
|
|
public Map<String, Integer> getNotNoticeCount() {
|
|
|
Map<String, Integer> out = new HashMap<>();
|
|
|
out.put("count", noticeUserFacade.count(new QueryWrapper<NoticeUser>()
|
|
|
+ .eq("hospital_id", SysUserUtils.getCurrentHospitalId())
|
|
|
.eq("user_id", SysUserUtils.getCurrentPrincipleId())
|
|
|
.eq("status", ReadTypeEnum.NOT_READ.getKey())
|
|
|
.eq("is_deleted", IsDeleteEnum.N.getKey())));
|