gongchunyi
4 天以前 be82fb8e6a3ce42786c42dc7c48c7baf67d1b49b
src/main/java/com/ruoyi/project/system/service/impl/SysNoticeServiceImpl.java
@@ -1,5 +1,6 @@
package com.ruoyi.project.system.service.impl;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -22,6 +23,7 @@
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;
@@ -50,6 +52,9 @@
    @Autowired
    @Lazy
    private ISysNoticeService sysNoticeService;
    @Autowired
    private UnipushService unipushService;
    /**
     * 查询公告信息
@@ -139,20 +144,25 @@
    }
    @Override
    public void simpleNoticeByUser(String title, String message,  List<Long> consigneeId, Long tenantId,
                                    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());
        sysNoticeService.saveBatch(sysNotices);
        try {
            unipushService.sendClientMessage(sysNotices);
        } catch (Exception e) {
            log.error("APP推送通知失败,原因: {}", e);
        }
    }
    @Override
    public void simpleNoticeAll(String title, String message, Long rootDeptId, String jumpPath) {
    public void simpleNoticeAll(String title, String message,  String jumpPath) {
        Long userId = SecurityUtils.getLoginUser().getUserId();
        if (userId == null) {
            return;
        }
        Long rootDeptId = SecurityUtils.getLoginUser().getTenantId();
        //  查所有子部门
        List<SysDept> childrenDepts = deptMapper.selectChildrenDeptById(rootDeptId);
@@ -195,6 +205,11 @@
                .collect(Collectors.toList());
        sysNoticeService.saveBatch(collect);
        try {
            unipushService.sendClientMessage(collect);
        } catch (Exception e) {
            log.error("APP推送通知失败,原因: {}", e);
        }
    }
@@ -210,4 +225,5 @@
        sysNotice.setTenantId(tenantId);
        return sysNotice;
    }
}