| | |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringPool; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.google.common.base.Joiner; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | import org.jeecg.common.api.dto.message.*; |
| | | import org.jeecg.common.aspect.UrlMatchEnum; |
| | | import org.jeecg.common.constant.*; |
| | | import org.jeecg.common.constant.enums.MessageSplitTypeEnum; |
| | | import org.jeecg.common.constant.enums.MessageTypeEnum; |
| | | import org.jeecg.common.desensitization.util.SensitiveInfoUtil; |
| | | import org.jeecg.common.exception.JeecgBootException; |
| | |
| | | import java.sql.DatabaseMetaData; |
| | | import java.sql.SQLException; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @Description: 底层共通业务API,提供其他独立模块调用 |
| | |
| | | |
| | | @Autowired |
| | | private IQuartzJobService quartzJobService; |
| | | @Autowired |
| | | private ISysDictItemService sysDictItemService; |
| | | |
| | | @Override |
| | | //@SensitiveDecode |
| | |
| | | |
| | | @Override |
| | | public void sendSysAnnouncement(MessageDTO message) { |
| | | |
| | | if (StringUtils.isNotBlank(message.getMessageType())) { |
| | | //获取消息类型对应角色用户 |
| | | MessageSplitTypeEnum messageSplitTypeEnum = MessageSplitTypeEnum.valueOfType(message.getMessageType()); |
| | | SysDict sysDict = sysDictService.getOne(new LambdaQueryWrapper<SysDict>().eq(SysDict::getDictCode, messageSplitTypeEnum.getDictCode())); |
| | | List<SysDictItem> sysDictItemList = sysDictItemService.list(new QueryWrapper<SysDictItem>().eq("dict_id",sysDict.getId())); |
| | | if (CollectionUtils.isNotEmpty(sysDictItemList)) { |
| | | List<SysUser> sysUserList = sysUserService.getUserByRoleCodeList(sysDictItemList.stream().map(SysDictItem::getItemValue).collect(Collectors.toList())); |
| | | if (CollectionUtils.isNotEmpty(sysUserList)) { |
| | | Set<String> userIdList = new HashSet<>(Arrays.asList(message.getToUser().split(StringPool.COMMA))); |
| | | userIdList.addAll(sysUserList.stream().map(SysUser::getUsername).collect(Collectors.toList())); |
| | | message.setToUser(StringUtils.join(userIdList, StringPool.COMMA)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | this.sendSysAnnouncement(message.getFromUser(), message.getToUser(), message.getTitle(), message.getContent(), message.getCategory()); |
| | | try { |
| | | // 同步发送第三方APP消息 |
| | |
| | | quartzJobService.deleteAndStopJob(quartzJob); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void sendAnnouncement(String fromUser, String toUser, String title, String msgContent) { |
| | | SysAnnouncement announcement = new SysAnnouncement(); |
| | | announcement.setTitile(title); |
| | | announcement.setMsgContent(msgContent); |
| | | announcement.setSender(fromUser); |
| | | announcement.setPriority(CommonConstant.PRIORITY_M); |
| | | announcement.setMsgType(CommonConstant.MSG_TYPE_UESR); |
| | | announcement.setSendStatus(CommonConstant.HAS_SEND); |
| | | announcement.setSendTime(new Date()); |
| | | announcement.setMsgCategory(CommonConstant.MSG_CATEGORY_2); |
| | | announcement.setDelFlag(String.valueOf(CommonConstant.DEL_FLAG_0)); |
| | | sysAnnouncementMapper.insert(announcement); |
| | | // 2.插入用户通告阅读标记表记录 |
| | | String userId = toUser; |
| | | String[] userIds = userId.split(","); |
| | | String anntId = announcement.getId(); |
| | | for (int i = 0; i < userIds.length; i++) { |
| | | if (oConvertUtils.isNotEmpty(userIds[i])) { |
| | | SysUser sysUser = userMapper.getUserByName(userIds[i]); |
| | | if (sysUser == null) { |
| | | continue; |
| | | } |
| | | SysAnnouncementSend announcementSend = new SysAnnouncementSend(); |
| | | announcementSend.setAnntId(anntId); |
| | | announcementSend.setUserId(sysUser.getId()); |
| | | announcementSend.setReadFlag(CommonConstant.NO_READ_FLAG); |
| | | sysAnnouncementSendMapper.insert(announcementSend); |
| | | JSONObject obj = new JSONObject(); |
| | | obj.put("cmd", "user"); |
| | | obj.put("userId", sysUser.getId()); |
| | | obj.put("msgId", announcement.getId()); |
| | | obj.put("msgTxt", announcement.getTitile()); |
| | | webSocket.sendOneMessage(sysUser.getId(), obj.toJSONString()); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | } |