基于若依ruoyi-nbcio增加flowable流程待办消息的提醒,并提供右上角的红字数字提醒(五)

简介: 基于若依ruoyi-nbcio增加flowable流程待办消息的提醒,并提供右上角的红字数字提醒(五)

更多ruoyi-nbcio功能请看演示系统

gitee源代码地址

前后端代码: ruoyi-nbcio: nbcio-boot的若依版本,基于ruoyi-flowable-plus和flowable6.7.2,目前处于移植功能阶段,目标是打造一个最好的若依平台上flowable流程管理系统开源版本,希望有需要的同仁一起打造。如果觉得这个项目对你有帮助,麻烦点个star。

演示地址:RuoYi-Nbcio后台管理系统

1、下面提供给前端待办提醒消息的接口SysNoticeController,增加如下:

/**
   * 补充用户数据,并返回系统消息
   * @return
   */
    @Log(title = "系统消息")
    @GetMapping("/listByUser")
    public R<Map<String, Object>> listByUser(@RequestParam(required = false, defaultValue = "5") Integer pageSize) {
      LoginUser loginUser = commonService.getLoginUser();
    Long userId = loginUser.getUserId();
    // 1.将系统消息补充到用户通告阅读标记表中
    LambdaQueryWrapper<SysNotice> querySaWrapper = new LambdaQueryWrapper<SysNotice>();
    querySaWrapper.eq(SysNotice::getMsgType,Constants.MSG_TYPE_ALL); // 全部人员
    querySaWrapper.eq(SysNotice::getStatus,Constants.CLOSE_FLAG_0.toString());  // 未关闭
    querySaWrapper.eq(SysNotice::getSendStatus, Constants.HAS_SEND); //已发布
    //querySaWrapper.ge(SysNotice::getEndTime, loginUser.getCreateTime()); //新注册用户不看结束通知
    querySaWrapper.notInSql(SysNotice::getNoticeId,"select notice_id from sys_notice_send where user_id='"+userId+"'");
    List<SysNotice> notices = noticeService.list(querySaWrapper);
    if(notices.size()>0) {
      for(int i=0;i<notices.size();i++) { 
        //因为websocket没有判断是否存在这个用户,要是判断会出现问题,故在此判断逻辑
        LambdaQueryWrapper<SysNoticeSend> query = new LambdaQueryWrapper<>();
        query.eq(SysNoticeSend::getNoticeId,notices.get(i).getNoticeId());
        query.eq(SysNoticeSend::getUserId,userId);
        SysNoticeSend one = noticeSendService.getOne(query);
        if(null==one){
          SysNoticeSend noticeSend = new SysNoticeSend();
          noticeSend.setNoticeId(notices.get(i).getNoticeId());
          noticeSend.setUserId(userId);
          noticeSend.setReadFlag(Constants.NO_READ_FLAG);
          noticeSendService.save(noticeSend);
        }
      }
    }
    // 2.查询用户未读的系统消息
    Page<SysNotice> anntMsgList = new Page<SysNotice>(0, pageSize);
    anntMsgList = noticeService.querySysNoticePageByUserId(anntMsgList,userId,"1");//通知公告消息
    Page<SysNotice> sysMsgList = new Page<SysNotice>(0, pageSize);
    sysMsgList = noticeService.querySysNoticePageByUserId(sysMsgList,userId,"2");//系统消息
    Page<SysNotice> todealMsgList = new Page<SysNotice>(0, pageSize);
    todealMsgList = noticeService.querySysNoticePageByUserId(todealMsgList,userId,"3");//待办消息
    Map<String,Object> sysMsgMap = new HashMap<String, Object>();
    sysMsgMap.put("sysMsgList", sysMsgList.getRecords());
    sysMsgMap.put("sysMsgTotal", sysMsgList.getTotal());
    sysMsgMap.put("anntMsgList", anntMsgList.getRecords());
    sysMsgMap.put("anntMsgTotal", anntMsgList.getTotal());
    sysMsgMap.put("todealMsgList", todealMsgList.getRecords());
    sysMsgMap.put("todealMsgTotal", todealMsgList.getTotal());
    return R.ok(sysMsgMap);
    }

2、其中这里用到了querySysNoticePageByUserId方法

@Override
  public Page<SysNotice> querySysNoticePageByUserId(Page<SysNotice> page, Long userId, String msgCategory) {
    if (page.getSize() == -1) {
      return page.setRecords(baseMapper.querySysNoticeListByUserId(null, userId.toString(), msgCategory));
    } else {
      return page.setRecords(baseMapper.querySysNoticeListByUserId(page, userId.toString(), msgCategory));
    }
  }

3、上面又用到了sql 在SysNoticeMapper.xml里

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.SysNoticeMapper">
    <resultMap type="com.ruoyi.system.domain.SysNotice" id="SysNoticeResult">
        <result property="noticeId" column="notice_id"/>
        <result property="noticeTitle" column="notice_title"/>
        <result property="noticeType" column="notice_type"/>
        <result property="noticeContent" column="notice_content"/>
        <result property="status" column="status"/>
        <result property="sender" column="sender"/>
        <result property="priority" column="priority"/>
        <result property="msgType" column="msg_type"/>
        <result property="sendStatus" column="send_status"/>
        <result property="sendTime" column="send_time"/>
        <result property="cancelTime" column="cancel_time"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="remark" column="remark"/>
    </resultMap>
    
    <select id="querySysNoticeListByUserId" parameterType="String"  resultMap="SysNoticeResult">
     select * from sys_notice
     where send_status = '1' 
     and status = '0' 
     and notice_type = #{msgCategory} 
     and notice_id IN ( select notice_id from sys_notice_send where user_id = CAST(#{userId} AS SIGNED INTEGER) and read_flag = '0')
     order by create_time DESC
  </select>
</mapper>

至此,后端的代码基本上就这些了,下一节开始讲一下前端。


相关文章
|
5天前
ruoyi-nbcio项目增加右上角的消息提醒
ruoyi-nbcio项目增加右上角的消息提醒
15 0
|
5天前
基于若依ruoyi-nbcio增加flowable流程待办消息的提醒,并提供右上角的红字数字提醒(三)
基于若依ruoyi-nbcio增加flowable流程待办消息的提醒,并提供右上角的红字数字提醒(三)
23 0
|
5天前
|
SQL 前端开发
基于若依ruoyi-nbcio增加flowable流程待办消息的提醒,并提供右上角的红字数字提醒(八)
基于若依ruoyi-nbcio增加flowable流程待办消息的提醒,并提供右上角的红字数字提醒(八)
37 0
|
5天前
|
前端开发
基于若依ruoyi-nbcio增加flowable流程待办消息的提醒,并提供右上角的红字数字提醒(六)
基于若依ruoyi-nbcio增加flowable流程待办消息的提醒,并提供右上角的红字数字提醒(六)
27 0
|
5天前
|
NoSQL Redis
基于若依ruoyi-nbcio增加flowable流程待办消息的提醒,并提供右上角的红字数字提醒(二)
基于若依ruoyi-nbcio增加flowable流程待办消息的提醒,并提供右上角的红字数字提醒(二)
18 0
|
5天前
|
搜索推荐
基于若依ruoyi-nbcio增加flowable流程待办消息的提醒,并提供右上角的红字数字提醒(四)
基于若依ruoyi-nbcio增加flowable流程待办消息的提醒,并提供右上角的红字数字提醒(四)
22 0
|
5天前
|
前端开发
基于若依ruoyi-nbcio增加flowable流程待办消息的提醒,并提供右上角的红字数字提醒(七)
基于若依ruoyi-nbcio增加flowable流程待办消息的提醒,并提供右上角的红字数字提醒(七)
18 0
|
5天前
|
前端开发 数据库
ruoyi-nbcio增加flowable流程待办消息的提醒,并提供右上角的红字数字提醒(一)
ruoyi-nbcio增加flowable流程待办消息的提醒,并提供右上角的红字数字提醒(一)
15 0
|
5天前
|
前端开发
基于jeecgboot的flowable流程支持退回到发起人节点表单修改功能
基于jeecgboot的flowable流程支持退回到发起人节点表单修改功能
31 0
|
5天前
基于若依ruoyi-nbcio支持flowable流程角色,同时修改流转用户为username,流程启动做大调整(三)
基于若依ruoyi-nbcio支持flowable流程角色,同时修改流转用户为username,流程启动做大调整(三)
21 1