| | |
| | | package com.ruoyi.project.system.service.impl;
|
| | |
|
| | | import java.time.LocalDateTime;
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
| | | import com.ruoyi.project.system.mapper.SysUserMapper;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.context.annotation.Lazy;
|
| | | import org.springframework.scheduling.annotation.Scheduled;
|
| | | import org.springframework.stereotype.Service;
|
| | | import com.ruoyi.project.system.domain.SysNotice;
|
| | | import com.ruoyi.project.system.mapper.SysNoticeMapper;
|
| | | import com.ruoyi.project.system.service.ISysNoticeService;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | /**
|
| | | * 公告 服务层实现
|
| | |
| | | @Autowired
|
| | | @Lazy
|
| | | private ISysNoticeService sysNoticeService;
|
| | |
|
| | | @Autowired
|
| | | private UnipushService unipushService;
|
| | |
|
| | | /**
|
| | | * 查询公告信息
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public void simpleNoticeByUser(String title, String message, List<Long> consigneeId, String jumpPath) {
|
| | | public void simpleNoticeByUser(String title, String message, List<Long> consigneeId, String jumpPath) {
|
| | | Long userId = SecurityUtils.getLoginUser().getUserId();
|
| | | Long tenantId = SecurityUtils.getLoginUser().getTenantId();
|
| | | List<SysNotice> sysNotices = consigneeId.stream().map(it -> convertSysNotice(title, message, it,tenantId, jumpPath, userId)).collect(Collectors.toList());
|
| | | List<SysNotice> sysNotices = consigneeId.stream()
|
| | | .map(it -> convertSysNotice(title, message, it, tenantId, jumpPath, unipushService.convertWebPathToAppPath(jumpPath), userId))
|
| | | .collect(Collectors.toList());
|
| | | sysNoticeService.saveBatch(sysNotices);
|
| | | try {
|
| | | unipushService.sendClientMessage(sysNotices);
|
| | | } catch (Exception e) {
|
| | | log.error("APP推送通知失败,原因: {}", e);
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | it.getUserId(),
|
| | | it.getTenantId(),
|
| | | jumpPath,
|
| | | unipushService.convertWebPathToAppPath(jumpPath),
|
| | | userId
|
| | | ))
|
| | | .collect(Collectors.toList());
|
| | |
|
| | | sysNoticeService.saveBatch(collect);
|
| | | try {
|
| | | unipushService.sendClientMessage(collect);
|
| | | } catch (Exception e) {
|
| | | log.error("APP推送通知失败,原因: {}", e);
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | private SysNotice convertSysNotice(String title,String message,Long consigneeId, Long tenantId,String jumpPath,Long currentUserId) {
|
| | | private SysNotice convertSysNotice(String title,String message,Long consigneeId, Long tenantId,String jumpPath,String appJumpPath,Long currentUserId) {
|
| | | SysNotice sysNotice = new SysNotice();
|
| | | sysNotice.setNoticeType("1");
|
| | | sysNotice.setNoticeTitle(title);//标题
|
| | |
| | | sysNotice.setConsigneeId(consigneeId);
|
| | | sysNotice.setSenderId(currentUserId);
|
| | | sysNotice.setJumpPath(jumpPath);
|
| | | sysNotice.setAppJumpPath(appJumpPath);
|
| | | sysNotice.setTenantId(tenantId);
|
| | | return sysNotice;
|
| | | }
|
| | |
|
| | | @Override
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public boolean appReadNotice(Long noticeId) {
|
| | | if (noticeId == null) {
|
| | | return false;
|
| | | }
|
| | | SysNotice sysNotice = noticeMapper.selectNoticeById(noticeId);
|
| | | if (sysNotice == null) {
|
| | | return false;
|
| | | }
|
| | | sysNotice.setStatus("1");
|
| | | return noticeMapper.update(null, Wrappers.<SysNotice>lambdaUpdate()
|
| | | .eq(SysNotice::getNoticeId, noticeId)
|
| | | .eq(SysNotice::getStatus, "0")
|
| | | .set(SysNotice::getStatus, "1")) > 0;
|
| | | }
|
| | | }
|