From d2c37020f760f53ee9328fb4baadecc2716ea094 Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期三, 04 三月 2026 13:18:19 +0800
Subject: [PATCH] yys  系统消息管理开发

---
 src/main/java/com/ruoyi/project/system/domain/SysNotice.java                       |    1 
 src/main/java/com/ruoyi/inspectiontask/service/impl/InspectionTaskServiceImpl.java |    2 
 src/main/resources/mapper/system/SysNoticeMapper.xml                               |  121 ++++--
 src/main/java/com/ruoyi/project/system/service/impl/SysNoticeServiceImpl.java      |  334 +++++++++++++++-----
 src/main/resources/application-prod.yml                                            |    8 
 src/main/java/com/ruoyi/common/config/IgnoreTableConfig.java                       |    1 
 src/main/java/com/ruoyi/project/system/controller/SysNoticeController.java         |  188 ++++++-----
 src/main/java/com/ruoyi/sales/controller/BusinessOpportunityController.java        |   13 
 src/main/java/com/ruoyi/project/system/mapper/SysUserMapper.java                   |    4 
 src/main/java/com/ruoyi/project/system/mapper/SysNoticeMapper.java                 |  125 ++++---
 src/main/resources/mapper/system/SysUserMapper.xml                                 |    2 
 src/main/resources/application-dev.yml                                             |    8 
 src/main/java/com/ruoyi/project/system/service/ISysNoticeService.java              |  152 +++++---
 13 files changed, 599 insertions(+), 360 deletions(-)

diff --git a/src/main/java/com/ruoyi/common/config/IgnoreTableConfig.java b/src/main/java/com/ruoyi/common/config/IgnoreTableConfig.java
index 24dce9c..d50a545 100644
--- a/src/main/java/com/ruoyi/common/config/IgnoreTableConfig.java
+++ b/src/main/java/com/ruoyi/common/config/IgnoreTableConfig.java
@@ -34,6 +34,7 @@
         IGNORE_TABLES.add("sys_user_dept");
         IGNORE_TABLES.add("sys_job_log");
         IGNORE_TABLES.add("gen_table");
+        IGNORE_TABLES.add("sys_user_client");
         IGNORE_TABLES.add("gen_table_column");
         IGNORE_TABLES.add("area");
     }
diff --git a/src/main/java/com/ruoyi/inspectiontask/service/impl/InspectionTaskServiceImpl.java b/src/main/java/com/ruoyi/inspectiontask/service/impl/InspectionTaskServiceImpl.java
index 6439f69..2946bc6 100644
--- a/src/main/java/com/ruoyi/inspectiontask/service/impl/InspectionTaskServiceImpl.java
+++ b/src/main/java/com/ruoyi/inspectiontask/service/impl/InspectionTaskServiceImpl.java
@@ -76,7 +76,7 @@
         // 鎵归噺鏌ヨ鐧昏浜�
         Map<Long, SysUser> sysUserMap;
         if (!registrantIds.isEmpty()) {
-            List<SysUser> sysUsers = sysUserMapper.selectList(registrantIds);
+            List<SysUser> sysUsers = sysUserMapper.selectLists(registrantIds);
             sysUserMap = sysUsers.stream().collect(Collectors.toMap(SysUser::getUserId, Function.identity()));
         } else {
             sysUserMap = new HashMap<>();
diff --git a/src/main/java/com/ruoyi/project/system/controller/SysNoticeController.java b/src/main/java/com/ruoyi/project/system/controller/SysNoticeController.java
index 0050920..5402415 100644
--- a/src/main/java/com/ruoyi/project/system/controller/SysNoticeController.java
+++ b/src/main/java/com/ruoyi/project/system/controller/SysNoticeController.java
@@ -1,91 +1,97 @@
-package com.ruoyi.project.system.controller;
-
-import java.util.List;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-import com.ruoyi.framework.aspectj.lang.annotation.Log;
-import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
-import com.ruoyi.framework.web.controller.BaseController;
-import com.ruoyi.framework.web.domain.AjaxResult;
-import com.ruoyi.framework.web.page.TableDataInfo;
-import com.ruoyi.project.system.domain.SysNotice;
-import com.ruoyi.project.system.service.ISysNoticeService;
-
-/**
- * 鍏憡 淇℃伅鎿嶄綔澶勭悊
- * 
- * @author ruoyi
- */
-@RestController
-@RequestMapping("/system/notice")
-public class SysNoticeController extends BaseController
-{
-    @Autowired
-    private ISysNoticeService noticeService;
-
-    /**
-     * 鑾峰彇閫氱煡鍏憡鍒楄〃
-     */
-    @PreAuthorize("@ss.hasPermi('system:notice:list')")
-    @GetMapping("/list")
-    public TableDataInfo list(SysNotice notice)
-    {
-        startPage();
-        List<SysNotice> list = noticeService.selectNoticeList(notice);
-        return getDataTable(list);
-    }
-
-    /**
-     * 鏍规嵁閫氱煡鍏憡缂栧彿鑾峰彇璇︾粏淇℃伅
-     */
-    @PreAuthorize("@ss.hasPermi('system:notice:query')")
-    @GetMapping(value = "/{noticeId}")
-    public AjaxResult getInfo(@PathVariable Long noticeId)
-    {
-        return success(noticeService.selectNoticeById(noticeId));
-    }
-
-    /**
-     * 鏂板閫氱煡鍏憡
-     */
-    @PreAuthorize("@ss.hasPermi('system:notice:add')")
-    @Log(title = "閫氱煡鍏憡", businessType = BusinessType.INSERT)
-    @PostMapping
-    public AjaxResult add(@Validated @RequestBody SysNotice notice)
-    {
-        notice.setCreateBy(getUsername());
-        return toAjax(noticeService.insertNotice(notice));
-    }
-
-    /**
-     * 淇敼閫氱煡鍏憡
-     */
-    @PreAuthorize("@ss.hasPermi('system:notice:edit')")
-    @Log(title = "閫氱煡鍏憡", businessType = BusinessType.UPDATE)
-    @PutMapping
-    public AjaxResult edit(@Validated @RequestBody SysNotice notice)
-    {
-        notice.setUpdateBy(getUsername());
-        return toAjax(noticeService.updateNotice(notice));
-    }
-
-    /**
-     * 鍒犻櫎閫氱煡鍏憡
-     */
-    @PreAuthorize("@ss.hasPermi('system:notice:remove')")
-    @Log(title = "閫氱煡鍏憡", businessType = BusinessType.DELETE)
-    @DeleteMapping("/{noticeIds}")
-    public AjaxResult remove(@PathVariable Long[] noticeIds)
-    {
-        return toAjax(noticeService.deleteNoticeByIds(noticeIds));
-    }
-}
+package com.ruoyi.project.system.controller;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.framework.web.controller.BaseController;
+import com.ruoyi.framework.web.domain.AjaxResult;
+import com.ruoyi.framework.web.domain.R;
+import com.ruoyi.project.system.domain.SysNotice;
+import com.ruoyi.project.system.service.ISysNoticeService;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * 鍏憡 淇℃伅鎿嶄綔澶勭悊
+ *
+ * @author ruoyi
+ */
+@RestController
+@RequestMapping("/system/notice")
+public class SysNoticeController extends BaseController
+{
+    @Autowired
+    private ISysNoticeService noticeService;
+
+    /**
+     * 鑾峰彇閫氱煡鍏憡鍒楄〃
+     */
+    @GetMapping("/list")
+    public R<IPage<SysNotice>> list(SysNotice notice, Page page)
+    {
+        IPage<SysNotice> list = noticeService.selectNoticeList(notice, page);
+        return R.ok(list);
+    }
+
+    /**
+     * 鑾峰彇鏈鏁伴噺
+     */
+    @GetMapping("/getCount")
+    public R getCount(Long consigneeId)
+    {
+        return R.ok(noticeService.getCount(consigneeId));
+    }
+
+    /**
+     * 鏍规嵁閫氱煡鍏憡缂栧彿鑾峰彇璇︾粏淇℃伅
+     */
+    @GetMapping(value = "/{noticeId}")
+    public AjaxResult getInfo(@PathVariable Long noticeId)
+    {
+        return success(noticeService.selectNoticeById(noticeId));
+    }
+
+    /**
+     * 鏂板閫氱煡鍏憡
+     */
+    @PostMapping
+    public AjaxResult add(@Validated @RequestBody SysNotice notice)
+    {
+        return toAjax(noticeService.insertNotice(notice));
+    }
+
+    /**
+     * 淇敼閫氱煡鍏憡
+     */
+    @PutMapping
+    public AjaxResult edit(@Validated @RequestBody SysNotice notice)
+    {
+        return toAjax(noticeService.updateNotice(notice));
+    }
+
+    /**
+     * 鍒犻櫎閫氱煡鍏憡
+     */
+    @DeleteMapping("/{noticeIds}")
+    public AjaxResult remove(@PathVariable Long[] noticeIds)
+    {
+        return toAjax(noticeService.deleteNoticeByIds(noticeIds));
+    }
+
+    /**
+     * 涓�閿凡璇�
+     */
+    @PostMapping("/readAll")
+    public AjaxResult readAll()
+    {
+        return toAjax(noticeService.readAll());
+    }
+
+    @PostMapping("appReadNotice")
+    @ApiOperation("绉诲姩绔牴鎹秷鎭疘D杩涜宸茶")
+    public AjaxResult appReadNotice(@RequestParam("noticeId") Long noticeId) {
+        boolean result = noticeService.appReadNotice(noticeId);
+        return toAjax(result);
+    }
+}
diff --git a/src/main/java/com/ruoyi/project/system/domain/SysNotice.java b/src/main/java/com/ruoyi/project/system/domain/SysNotice.java
index b88a57c..8f901b8 100644
--- a/src/main/java/com/ruoyi/project/system/domain/SysNotice.java
+++ b/src/main/java/com/ruoyi/project/system/domain/SysNotice.java
@@ -76,6 +76,7 @@
     /**
      * 绉熸埛id
      */
+    @TableField(fill = FieldFill.INSERT)
     private Long tenantId;
 
 
diff --git a/src/main/java/com/ruoyi/project/system/mapper/SysNoticeMapper.java b/src/main/java/com/ruoyi/project/system/mapper/SysNoticeMapper.java
index 3a9370f..3a1e972 100644
--- a/src/main/java/com/ruoyi/project/system/mapper/SysNoticeMapper.java
+++ b/src/main/java/com/ruoyi/project/system/mapper/SysNoticeMapper.java
@@ -1,60 +1,65 @@
-package com.ruoyi.project.system.mapper;
-
-import java.util.List;
-import com.ruoyi.project.system.domain.SysNotice;
-
-/**
- * 閫氱煡鍏憡琛� 鏁版嵁灞�
- * 
- * @author ruoyi
- */
-public interface SysNoticeMapper
-{
-    /**
-     * 鏌ヨ鍏憡淇℃伅
-     * 
-     * @param noticeId 鍏憡ID
-     * @return 鍏憡淇℃伅
-     */
-    public SysNotice selectNoticeById(Long noticeId);
-
-    /**
-     * 鏌ヨ鍏憡鍒楄〃
-     * 
-     * @param notice 鍏憡淇℃伅
-     * @return 鍏憡闆嗗悎
-     */
-    public List<SysNotice> selectNoticeList(SysNotice notice);
-
-    /**
-     * 鏂板鍏憡
-     * 
-     * @param notice 鍏憡淇℃伅
-     * @return 缁撴灉
-     */
-    public int insertNotice(SysNotice notice);
-
-    /**
-     * 淇敼鍏憡
-     * 
-     * @param notice 鍏憡淇℃伅
-     * @return 缁撴灉
-     */
-    public int updateNotice(SysNotice notice);
-
-    /**
-     * 鎵归噺鍒犻櫎鍏憡
-     * 
-     * @param noticeId 鍏憡ID
-     * @return 缁撴灉
-     */
-    public int deleteNoticeById(Long noticeId);
-
-    /**
-     * 鎵归噺鍒犻櫎鍏憡淇℃伅
-     * 
-     * @param noticeIds 闇�瑕佸垹闄ょ殑鍏憡ID
-     * @return 缁撴灉
-     */
-    public int deleteNoticeByIds(Long[] noticeIds);
-}
\ No newline at end of file
+package com.ruoyi.project.system.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.project.system.domain.SysNotice;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * 閫氱煡鍏憡琛� 鏁版嵁灞�
+ *
+ * @author ruoyi
+ */
+@Mapper
+public interface SysNoticeMapper extends BaseMapper<SysNotice>
+{
+    /**
+     * 鏌ヨ鍏憡淇℃伅
+     *
+     * @param noticeId 鍏憡ID
+     * @return 鍏憡淇℃伅
+     */
+    public SysNotice selectNoticeById(Long noticeId);
+
+    /**
+     * 鏌ヨ鍏憡鍒楄〃
+     *
+     * @param notice 鍏憡淇℃伅
+     * @return 鍏憡闆嗗悎
+     */
+    public IPage<SysNotice> selectNoticeList(@Param("c") SysNotice notice, Page page);
+
+    /**
+     * 鏂板鍏憡
+     *
+     * @param notice 鍏憡淇℃伅
+     * @return 缁撴灉
+     */
+    public int insertNotice(SysNotice notice);
+
+    /**
+     * 淇敼鍏憡
+     *
+     * @param notice 鍏憡淇℃伅
+     * @return 缁撴灉
+     */
+    public int updateNotice(SysNotice notice);
+
+    /**
+     * 鎵归噺鍒犻櫎鍏憡
+     *
+     * @param noticeId 鍏憡ID
+     * @return 缁撴灉
+     */
+    public int deleteNoticeById(Long noticeId);
+
+    /**
+     * 鎵归噺鍒犻櫎鍏憡淇℃伅
+     *
+     * @param noticeIds 闇�瑕佸垹闄ょ殑鍏憡ID
+     * @return 缁撴灉
+     */
+    public int deleteNoticeByIds(Long[] noticeIds);
+}
diff --git a/src/main/java/com/ruoyi/project/system/mapper/SysUserMapper.java b/src/main/java/com/ruoyi/project/system/mapper/SysUserMapper.java
index 550fa51..8ac0025 100644
--- a/src/main/java/com/ruoyi/project/system/mapper/SysUserMapper.java
+++ b/src/main/java/com/ruoyi/project/system/mapper/SysUserMapper.java
@@ -14,7 +14,7 @@
  * 
  * @author ruoyi
  */
-public interface SysUserMapper
+public interface SysUserMapper extends BaseMapper<SysUser>
 {
     /**
      * 鏍规嵁鏉′欢鍒嗛〉鏌ヨ鐢ㄦ埛鍒楄〃
@@ -138,7 +138,7 @@
      */
     public SysUser checkEmailUnique(String email);
 
-    List<SysUser> selectList(List<Long> registrantIds);
+    List<SysUser> selectLists(List<Long> registrantIds);
 
     List<SysUser> selectUsersByIds(@Param("userIds") List<Long> userIds);
 }
diff --git a/src/main/java/com/ruoyi/project/system/service/ISysNoticeService.java b/src/main/java/com/ruoyi/project/system/service/ISysNoticeService.java
index 98bd890..66d184c 100644
--- a/src/main/java/com/ruoyi/project/system/service/ISysNoticeService.java
+++ b/src/main/java/com/ruoyi/project/system/service/ISysNoticeService.java
@@ -1,60 +1,92 @@
-package com.ruoyi.project.system.service;
-
-import java.util.List;
-import com.ruoyi.project.system.domain.SysNotice;
-
-/**
- * 鍏憡 鏈嶅姟灞�
- * 
- * @author ruoyi
- */
-public interface ISysNoticeService
-{
-    /**
-     * 鏌ヨ鍏憡淇℃伅
-     * 
-     * @param noticeId 鍏憡ID
-     * @return 鍏憡淇℃伅
-     */
-    public SysNotice selectNoticeById(Long noticeId);
-
-    /**
-     * 鏌ヨ鍏憡鍒楄〃
-     * 
-     * @param notice 鍏憡淇℃伅
-     * @return 鍏憡闆嗗悎
-     */
-    public List<SysNotice> selectNoticeList(SysNotice notice);
-
-    /**
-     * 鏂板鍏憡
-     * 
-     * @param notice 鍏憡淇℃伅
-     * @return 缁撴灉
-     */
-    public int insertNotice(SysNotice notice);
-
-    /**
-     * 淇敼鍏憡
-     * 
-     * @param notice 鍏憡淇℃伅
-     * @return 缁撴灉
-     */
-    public int updateNotice(SysNotice notice);
-
-    /**
-     * 鍒犻櫎鍏憡淇℃伅
-     * 
-     * @param noticeId 鍏憡ID
-     * @return 缁撴灉
-     */
-    public int deleteNoticeById(Long noticeId);
-    
-    /**
-     * 鎵归噺鍒犻櫎鍏憡淇℃伅
-     * 
-     * @param noticeIds 闇�瑕佸垹闄ょ殑鍏憡ID
-     * @return 缁撴灉
-     */
-    public int deleteNoticeByIds(Long[] noticeIds);
-}
+package com.ruoyi.project.system.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ruoyi.project.system.domain.SysNotice;
+
+import java.util.List;
+
+/**
+ * 鍏憡 鏈嶅姟灞�
+ *
+ * @author ruoyi
+ */
+public interface ISysNoticeService extends IService<SysNotice>
+{
+    /**
+     * 鏌ヨ鍏憡淇℃伅
+     *
+     * @param noticeId 鍏憡ID
+     * @return 鍏憡淇℃伅
+     */
+    public SysNotice selectNoticeById(Long noticeId);
+
+    /**
+     * 鏌ヨ鍏憡鍒楄〃
+     *
+     * @param notice 鍏憡淇℃伅
+     * @return 鍏憡闆嗗悎
+     */
+    public IPage<SysNotice> selectNoticeList(SysNotice notice, Page page);
+
+    /**
+     * 鏂板鍏憡
+     *
+     * @param notice 鍏憡淇℃伅
+     * @return 缁撴灉
+     */
+    public int insertNotice(SysNotice notice);
+
+    /**
+     * 淇敼鍏憡
+     *
+     * @param notice 鍏憡淇℃伅
+     * @return 缁撴灉
+     */
+    public int updateNotice(SysNotice notice);
+
+    /**
+     * 鍒犻櫎鍏憡淇℃伅
+     *
+     * @param noticeId 鍏憡ID
+     * @return 缁撴灉
+     */
+    public int deleteNoticeById(Long noticeId);
+
+    /**
+     * 鎵归噺鍒犻櫎鍏憡淇℃伅
+     *
+     * @param noticeIds 闇�瑕佸垹闄ょ殑鍏憡ID
+     * @return 缁撴灉
+     */
+    public int deleteNoticeByIds(Long[] noticeIds);
+
+    Long getCount(Long consigneeId);
+
+    int readAll();
+
+    /**
+     * 閫氳繃鎸囧畾浜哄彂閫佹彁閱�
+     * @param title 鏍囬
+     * @param message 娑堟伅
+     * @param jumpPath 璺宠浆鍦板潃
+     */
+    void simpleNoticeByUser(final String title, final String message, final List<Long> consigneeId,  final String jumpPath);
+
+    /**
+     * 閫氳繃鎵�鏈変汉 鍙戦�佹彁閱�
+     * @param title 鏍囬
+     * @param message 娑堟伅
+     * @param jumpPath 璺宠浆鍦板潃
+     */
+    void simpleNoticeAll(final String title, final String message,final String jumpPath);
+
+    /**
+     * APP鐐瑰嚮鎺ㄩ�佹秷鎭洿鏀逛负宸茶鐘舵��
+     *
+     * @param noticeId 娑堟伅ID
+     * @return 澶辫触/鎴愬姛
+     */
+    boolean appReadNotice(Long noticeId);
+}
diff --git a/src/main/java/com/ruoyi/project/system/service/impl/SysNoticeServiceImpl.java b/src/main/java/com/ruoyi/project/system/service/impl/SysNoticeServiceImpl.java
index 2b0191d..7811c14 100644
--- a/src/main/java/com/ruoyi/project/system/service/impl/SysNoticeServiceImpl.java
+++ b/src/main/java/com/ruoyi/project/system/service/impl/SysNoticeServiceImpl.java
@@ -1,92 +1,242 @@
-package com.ruoyi.project.system.service.impl;
-
-import java.util.List;
-import org.springframework.beans.factory.annotation.Autowired;
-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;
-
-/**
- * 鍏憡 鏈嶅姟灞傚疄鐜�
- * 
- * @author ruoyi
- */
-@Service
-public class SysNoticeServiceImpl implements ISysNoticeService
-{
-    @Autowired
-    private SysNoticeMapper noticeMapper;
-
-    /**
-     * 鏌ヨ鍏憡淇℃伅
-     * 
-     * @param noticeId 鍏憡ID
-     * @return 鍏憡淇℃伅
-     */
-    @Override
-    public SysNotice selectNoticeById(Long noticeId)
-    {
-        return noticeMapper.selectNoticeById(noticeId);
-    }
-
-    /**
-     * 鏌ヨ鍏憡鍒楄〃
-     * 
-     * @param notice 鍏憡淇℃伅
-     * @return 鍏憡闆嗗悎
-     */
-    @Override
-    public List<SysNotice> selectNoticeList(SysNotice notice)
-    {
-        return noticeMapper.selectNoticeList(notice);
-    }
-
-    /**
-     * 鏂板鍏憡
-     * 
-     * @param notice 鍏憡淇℃伅
-     * @return 缁撴灉
-     */
-    @Override
-    public int insertNotice(SysNotice notice)
-    {
-        return noticeMapper.insertNotice(notice);
-    }
-
-    /**
-     * 淇敼鍏憡
-     * 
-     * @param notice 鍏憡淇℃伅
-     * @return 缁撴灉
-     */
-    @Override
-    public int updateNotice(SysNotice notice)
-    {
-        return noticeMapper.updateNotice(notice);
-    }
-
-    /**
-     * 鍒犻櫎鍏憡瀵硅薄
-     * 
-     * @param noticeId 鍏憡ID
-     * @return 缁撴灉
-     */
-    @Override
-    public int deleteNoticeById(Long noticeId)
-    {
-        return noticeMapper.deleteNoticeById(noticeId);
-    }
-
-    /**
-     * 鎵归噺鍒犻櫎鍏憡淇℃伅
-     * 
-     * @param noticeIds 闇�瑕佸垹闄ょ殑鍏憡ID
-     * @return 缁撴灉
-     */
-    @Override
-    public int deleteNoticeByIds(Long[] noticeIds)
-    {
-        return noticeMapper.deleteNoticeByIds(noticeIds);
-    }
-}
+package com.ruoyi.project.system.service.impl;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.project.system.domain.SysDept;
+import com.ruoyi.project.system.domain.SysNotice;
+import com.ruoyi.project.system.domain.SysUser;
+import com.ruoyi.project.system.domain.SysUserDept;
+import com.ruoyi.project.system.mapper.SysDeptMapper;
+import com.ruoyi.project.system.mapper.SysNoticeMapper;
+import com.ruoyi.project.system.mapper.SysUserDeptMapper;
+import com.ruoyi.project.system.mapper.SysUserMapper;
+import com.ruoyi.project.system.service.ISysNoticeService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * 鍏憡 鏈嶅姟灞傚疄鐜�
+ *
+ * @author ruoyi
+ */
+@Service
+public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice> implements ISysNoticeService {
+
+    @Autowired
+    private SysNoticeMapper noticeMapper;
+
+    @Autowired
+    private SysUserMapper userMapper;
+
+    @Autowired
+    private SysDeptMapper deptMapper;
+
+    @Autowired
+    private SysUserDeptMapper userDeptMapper;
+
+    @Autowired
+    @Lazy
+    private ISysNoticeService sysNoticeService;
+
+    @Autowired
+    private UnipushService unipushService;
+
+    /**
+     * 鏌ヨ鍏憡淇℃伅
+     *
+     * @param noticeId 鍏憡ID
+     * @return 鍏憡淇℃伅
+     */
+    @Override
+    public SysNotice selectNoticeById(Long noticeId)
+    {
+        return noticeMapper.selectNoticeById(noticeId);
+    }
+
+    /**
+     * 鏌ヨ鍏憡鍒楄〃
+     *
+     * @param notice 鍏憡淇℃伅
+     * @return 鍏憡闆嗗悎
+     */
+    @Override
+    public IPage<SysNotice> selectNoticeList(SysNotice notice, Page page) {
+        return noticeMapper.selectNoticeList(notice, page);
+    }
+
+    /**
+     * 鏂板鍏憡
+     *
+     * @param notice 鍏憡淇℃伅
+     * @return 缁撴灉
+     */
+    @Override
+    public int insertNotice(SysNotice notice)
+    {
+        return noticeMapper.insertNotice(notice);
+    }
+
+    /**
+     * 淇敼鍏憡
+     *
+     * @param notice 鍏憡淇℃伅
+     * @return 缁撴灉
+     */
+    @Override
+    public int updateNotice(SysNotice notice)
+    {
+        return noticeMapper.updateNotice(notice);
+    }
+
+    /**
+     * 鍒犻櫎鍏憡瀵硅薄
+     *
+     * @param noticeId 鍏憡ID
+     * @return 缁撴灉
+     */
+    @Override
+    public int deleteNoticeById(Long noticeId)
+    {
+        return noticeMapper.deleteNoticeById(noticeId);
+    }
+
+    /**
+     * 鎵归噺鍒犻櫎鍏憡淇℃伅
+     *
+     * @param noticeIds 闇�瑕佸垹闄ょ殑鍏憡ID
+     * @return 缁撴灉
+     */
+    @Override
+    public int deleteNoticeByIds(Long[] noticeIds)
+    {
+        return noticeMapper.deleteNoticeByIds(noticeIds);
+    }
+
+    @Override
+    public Long getCount(Long consigneeId) {
+        return noticeMapper.selectCount(Wrappers.<SysNotice>lambdaQuery()
+                .eq(SysNotice::getStatus, "0")
+                .eq(SysNotice::getConsigneeId, consigneeId));
+    }
+
+    @Override
+    public int readAll() {
+        Long userId = SecurityUtils.getUserId();
+        return noticeMapper.update(null, Wrappers.<SysNotice>lambdaUpdate()
+                .eq(SysNotice::getConsigneeId, userId)
+                .eq(SysNotice::getStatus, "0")
+                .set(SysNotice::getStatus, "1"));
+    }
+
+    @Override
+    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, unipushService.convertWebPathToAppPath(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,  String jumpPath) {
+        Long userId = SecurityUtils.getLoginUser().getUserId();
+        if (userId == null) {
+            return;
+        }
+        Long rootDeptId = SecurityUtils.getLoginUser().getTenantId();
+        //  鏌ユ墍鏈夊瓙閮ㄩ棬
+        List<SysDept> childrenDepts = deptMapper.selectChildrenDeptById(rootDeptId);
+
+        //  缁勮 deptIds
+        List<Long> deptIds = childrenDepts.stream()
+                .map(SysDept::getDeptId)
+                .collect(Collectors.toList());
+        deptIds.add(rootDeptId);
+
+        //  鏌ョ敤鎴稩D
+        List<Long> userIds = userDeptMapper.selectList(
+                        Wrappers.<SysUserDept>lambdaQuery()
+                                .in(SysUserDept::getDeptId, deptIds)
+                ).stream()
+                .map(SysUserDept::getUserId)
+                .distinct()
+                .collect(Collectors.toList());
+
+        if (userIds.isEmpty()) {
+            return;
+        }
+
+        //  鏌ョ敤鎴�
+        List<SysUser> sysUsers = userMapper.selectList(
+                Wrappers.<SysUser>lambdaQuery()
+                        .eq(SysUser::getStatus, "0")
+                        .in(SysUser::getUserId, userIds)
+        );
+
+        //  鍙戦�氱煡
+        List<SysNotice> collect = sysUsers.stream()
+                .map(it -> convertSysNotice(
+                        title,
+                        message,
+                        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,String appJumpPath,Long currentUserId) {
+        SysNotice sysNotice = new SysNotice();
+        sysNotice.setNoticeType("1");
+        sysNotice.setNoticeTitle(title);//鏍囬
+        sysNotice.setNoticeContent(message);
+        sysNotice.setStatus("0");
+        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;
+    }
+}
diff --git a/src/main/java/com/ruoyi/sales/controller/BusinessOpportunityController.java b/src/main/java/com/ruoyi/sales/controller/BusinessOpportunityController.java
index ff320d0..82944fc 100644
--- a/src/main/java/com/ruoyi/sales/controller/BusinessOpportunityController.java
+++ b/src/main/java/com/ruoyi/sales/controller/BusinessOpportunityController.java
@@ -9,6 +9,8 @@
 import com.ruoyi.framework.web.controller.BaseController;
 import com.ruoyi.framework.web.domain.AjaxResult;
 import com.ruoyi.project.system.domain.SysNotice;
+import com.ruoyi.project.system.mapper.SysNoticeMapper;
+import com.ruoyi.project.system.service.impl.SysNoticeServiceImpl;
 import com.ruoyi.project.system.service.impl.UnipushService;
 import com.ruoyi.sales.mapper.BusinessDescriptionMapper;
 import com.ruoyi.sales.pojo.BusinessDescription;
@@ -46,6 +48,9 @@
 
     @Autowired
     private UnipushService unipushService;
+
+    @Autowired
+    private SysNoticeMapper sysNoticeMapper;
 
     @ApiOperation("鑾峰彇鐪佺骇鍒楄〃")
     @GetMapping("/getProvinceList")
@@ -91,8 +96,10 @@
         sysNotice.setNoticeType("1");
         sysNotice.setStatus("0");
         sysNotice.setSenderId(SecurityUtils.getUserId());
-        sysNotice.setConsigneeId(SecurityUtils.getUserId());
+        sysNotice.setConsigneeId(105L);
         sysNotice.setAppJumpPath("pages/opportunityManagement/index");
+        sysNoticeMapper.insert(sysNotice);
+        sysNoticeList.add(sysNotice);
         unipushService.sendClientMessage(sysNoticeList);
         return businessDescriptionMapper.insert(businessDescription) > 0 ? success() : error();
     }
@@ -116,8 +123,10 @@
             sysNotice.setNoticeType("1");
             sysNotice.setStatus("0");
             sysNotice.setSenderId(SecurityUtils.getUserId());
-            sysNotice.setConsigneeId(SecurityUtils.getUserId());
+            sysNotice.setConsigneeId(105L);
             sysNotice.setAppJumpPath("pages/opportunityManagement/index");
+            sysNoticeMapper.insert(sysNotice);
+            sysNoticeList.add(sysNotice);
             unipushService.sendClientMessage(sysNoticeList);
         }
         return businessDescriptionMapper.insert(businessDescription) > 0 ? success() : error();
diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml
index f0010a0..d70cddf 100644
--- a/src/main/resources/application-dev.yml
+++ b/src/main/resources/application-dev.yml
@@ -16,12 +16,12 @@
 
   # 涓帹 Unipush 閰嶇疆
   getui:
-    appId: PfjyAAE0FK64FaO1w2CMb1
-    appKey: zTMb831OEL6J4GK1uE3Ob4
-    masterSecret: K1GFtsv42v61tXGnF7SGE5
+    appId: Dtk2FRh0ps6art6PMXgPf2
+    appKey: tLzzJZ7VRi5S6zP2kQ0aG8
+    masterSecret: EDt5Px5cbc6QflUdwQbN92
     domain: https://restapi.getui.cn/v2/
     # 绂荤嚎鎺ㄩ�佷娇鐢ㄧ殑鍖呭悕/缁勪欢鍚�
-    intentComponent: uni.app.UNI099A590/io.dcloud.PandoraEntry
+    intentComponent: uni.app.UNI870C454/io.dcloud.PandoraEntry
 
 # 寮�鍙戠幆澧冮厤缃�
 server:
diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml
index 859e52e..534ffac 100644
--- a/src/main/resources/application-prod.yml
+++ b/src/main/resources/application-prod.yml
@@ -16,12 +16,12 @@
 
   # 涓帹 Unipush 閰嶇疆
   getui:
-    appId: PfjyAAE0FK64FaO1w2CMb1
-    appKey: zTMb831OEL6J4GK1uE3Ob4
-    masterSecret: K1GFtsv42v61tXGnF7SGE5
+    appId: Dtk2FRh0ps6art6PMXgPf2
+    appKey: tLzzJZ7VRi5S6zP2kQ0aG8
+    masterSecret: EDt5Px5cbc6QflUdwQbN92
     domain: https://restapi.getui.cn/v2/
     # 绂荤嚎鎺ㄩ�佷娇鐢ㄧ殑鍖呭悕/缁勪欢鍚�
-    intentComponent: uni.app.UNI099A590/io.dcloud.PandoraEntry
+    intentComponent: uni.app.UNI870C454/io.dcloud.PandoraEntry
 
 # 寮�鍙戠幆澧冮厤缃�
 server:
diff --git a/src/main/resources/mapper/system/SysNoticeMapper.xml b/src/main/resources/mapper/system/SysNoticeMapper.xml
index e152622..51e56d0 100644
--- a/src/main/resources/mapper/system/SysNoticeMapper.xml
+++ b/src/main/resources/mapper/system/SysNoticeMapper.xml
@@ -1,9 +1,9 @@
 <?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">
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ruoyi.project.system.mapper.SysNoticeMapper">
-    
+
     <resultMap type="com.ruoyi.project.system.domain.SysNotice" id="SysNoticeResult">
         <result property="noticeId"       column="notice_id"       />
         <result property="noticeTitle"    column="notice_title"    />
@@ -16,74 +16,109 @@
         <result property="updateTime"     column="update_time"     />
         <result property="remark"         column="remark"          />
     </resultMap>
-    
+
     <sql id="selectNoticeVo">
-        select notice_id, notice_title, notice_type, cast(notice_content as char) as notice_content, status, create_by, create_time, update_by, update_time, remark 
-		from sys_notice
+        select notice_id,
+               notice_title,
+               notice_type,
+               notice_content,
+               status,
+               create_by,
+               create_time,
+               update_by,
+               update_time,
+               remark,
+               sender_id,
+               consignee_id,
+               jump_path,
+               app_jump_path,
+               tenant_id
+        from sys_notice
     </sql>
-    
+
     <select id="selectNoticeById" parameterType="Long" resultMap="SysNoticeResult">
         <include refid="selectNoticeVo"/>
         where notice_id = #{noticeId}
     </select>
-    
+
     <select id="selectNoticeList" parameterType="com.ruoyi.project.system.domain.SysNotice" resultMap="SysNoticeResult">
         <include refid="selectNoticeVo"/>
         <where>
-			<if test="noticeTitle != null and noticeTitle != ''">
-				AND notice_title like concat('%', #{noticeTitle}, '%')
-			</if>
-			<if test="noticeType != null and noticeType != ''">
-				AND notice_type = #{noticeType}
-			</if>
-			<if test="createBy != null and createBy != ''">
-				AND create_by like concat('%', #{createBy}, '%')
-			</if>
-		</where>
+            <if test="c.noticeTitle != null and c.noticeTitle != ''">
+                AND notice_title like concat('%', #{c.noticeTitle}, '%')
+            </if>
+            <if test="c.noticeType != null and c.noticeType != ''">
+                AND notice_type = #{c.noticeType}
+            </if>
+            <if test="c.createBy != null and c.createBy != ''">
+                AND create_by like concat('%', #{c.createBy}, '%')
+            </if>
+            <if test="c.senderId != null and c.senderId != ''">
+                AND sender_id = #{c.senderId}
+            </if>
+            <if test="c.consigneeId != null and c.consigneeId != ''">
+                AND consignee_id = #{c.consigneeId}
+            </if>
+            <if test="c.status != null and c.status != ''">
+                AND status = #{c.status}
+            </if>
+        </where>
+        order by create_time desc
     </select>
-    
+
     <insert id="insertNotice" parameterType="com.ruoyi.project.system.domain.SysNotice">
         insert into sys_notice (
-			<if test="noticeTitle != null and noticeTitle != '' ">notice_title, </if>
-			<if test="noticeType != null and noticeType != '' ">notice_type, </if>
-			<if test="noticeContent != null and noticeContent != '' ">notice_content, </if>
-			<if test="status != null and status != '' ">status, </if>
-			<if test="remark != null and remark != ''">remark,</if>
- 			<if test="createBy != null and createBy != ''">create_by,</if>
- 			create_time
- 		)values(
-			<if test="noticeTitle != null and noticeTitle != ''">#{noticeTitle}, </if>
-			<if test="noticeType != null and noticeType != ''">#{noticeType}, </if>
-			<if test="noticeContent != null and noticeContent != ''">#{noticeContent}, </if>
-			<if test="status != null and status != ''">#{status}, </if>
-			<if test="remark != null and remark != ''">#{remark},</if>
- 			<if test="createBy != null and createBy != ''">#{createBy},</if>
- 			sysdate()
-		)
+        <if test="noticeTitle != null and noticeTitle != '' ">notice_title, </if>
+        <if test="noticeType != null and noticeType != '' ">notice_type, </if>
+        <if test="noticeContent != null and noticeContent != '' ">notice_content, </if>
+        <if test="status != null and status != '' ">status, </if>
+        <if test="remark != null and remark != ''">remark,</if>
+        <if test="senderId != null and senderId != ''">sender_id,</if>
+        <if test="consigneeId != null and consigneeId != ''">consignee_id,</if>
+        <if test="jumpPath != null and jumpPath != ''">jump_path,</if>
+        <if test="appJumpPath != null and appJumpPath != ''">app_jump_path,</if>
+        <if test="createBy != null and createBy != ''">create_by,</if>
+        <if test="tenantId != null and tenantId != ''">tenant_id,</if>
+        create_time
+        )values(
+        <if test="noticeTitle != null and noticeTitle != ''">#{noticeTitle}, </if>
+        <if test="noticeType != null and noticeType != ''">#{noticeType}, </if>
+        <if test="noticeContent != null and noticeContent != ''">#{noticeContent}, </if>
+        <if test="status != null and status != ''">#{status}, </if>
+        <if test="remark != null and remark != ''">#{remark},</if>
+        <if test="senderId != null and senderId != ''">#{senderId},</if>
+        <if test="consigneeId != null and consigneeId != ''">#{consigneeId},</if>
+        <if test="jumpPath != null and jumpPath != ''">#{jumpPath},</if>
+        <if test="appJumpPath != null and appJumpPath != ''">#{appJumpPath},</if>
+        <if test="pathParms != null and pathParms != ''">#{queryParms},</if>
+        <if test="createBy != null and createBy != ''">#{createBy},</if>
+        <if test="tenantId != null and tenantId != ''">#{tenantId},</if>
+        sysdate()
+        )
     </insert>
-	 
+
     <update id="updateNotice" parameterType="com.ruoyi.project.system.domain.SysNotice">
-        update sys_notice 
+        update sys_notice
         <set>
             <if test="noticeTitle != null and noticeTitle != ''">notice_title = #{noticeTitle}, </if>
             <if test="noticeType != null and noticeType != ''">notice_type = #{noticeType}, </if>
             <if test="noticeContent != null">notice_content = #{noticeContent}, </if>
             <if test="status != null and status != ''">status = #{status}, </if>
             <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
- 			update_time = sysdate()
+            update_time = sysdate()
         </set>
         where notice_id = #{noticeId}
     </update>
-	
+
     <delete id="deleteNoticeById" parameterType="Long">
         delete from sys_notice where notice_id = #{noticeId}
     </delete>
-    
+
     <delete id="deleteNoticeByIds" parameterType="Long">
-        delete from sys_notice where notice_id in 
+        delete from sys_notice where notice_id in
         <foreach item="noticeId" collection="array" open="(" separator="," close=")">
             #{noticeId}
         </foreach>
     </delete>
-    
-</mapper>
\ No newline at end of file
+
+</mapper>
diff --git a/src/main/resources/mapper/system/SysUserMapper.xml b/src/main/resources/mapper/system/SysUserMapper.xml
index 1b5cc71..3254895 100644
--- a/src/main/resources/mapper/system/SysUserMapper.xml
+++ b/src/main/resources/mapper/system/SysUserMapper.xml
@@ -188,7 +188,7 @@
  			#{item}
         </foreach>
 	</select>
-	<select id="selectList" resultType="com.ruoyi.project.system.domain.SysUser">
+	<select id="selectLists" resultType="com.ruoyi.project.system.domain.SysUser">
 		SELECT user_id, nick_name FROM sys_user
 		<where>
 			<if test="list != null and list.size() > 0">

--
Gitblit v1.9.3