Prechádzať zdrojové kódy

修改公告通知功能

ouyang 1 rok pred
rodič
commit
88994194b0

+ 12 - 0
project_data/sql/0.0.5/soc/soc.sql

@@ -221,3 +221,15 @@ INSERT INTO `sys_menu` (`id`, `menu_name`, `parent_id`, `order_num`, `path`, `co
 delete from sys_config where config_key = 'CUSTOMER_SERVICE';
 INSERT INTO `sys_config` (`config_id`, `config_name`, `config_key`, `config_value`, `config_type`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (202, '客服服务', 'CUSTOMER_SERVICE', '', 'Y', '超级管理员', '2023-12-25 10:16:37', '', NULL, NULL);
 
+DROP TABLE IF EXISTS `core_announcement_notification_to_orgtype`;
+CREATE TABLE `core_announcement_notification_to_orgtype`  (
+                                                              `announcement_notification_id` bigint(0) NOT NULL,
+                                                              `org_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL
+) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
+delete from sys_menu where id in(00000000000000002196,00000000000000002208,00000000000000002209,00000000000000002210, 00000000000000002211,00000000000000002212);
+INSERT INTO `sys_menu`(`id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `platform_type`, `icon`, `image_path`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (00000000000000002196, '通知公告', 2207, 1, 'core/message', 'core/message/index', NULL, 1, 0, 'C', '0', '0', 'core:notification:list', '1', 'dashboard', NULL, '超级管理员', '2023-09-13 17:50:26', '超级管理员', '2023-09-15 16:47:45', '');
+INSERT INTO `sys_menu`(`id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `platform_type`, `icon`, `image_path`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (00000000000000002208, '通知公告详情', 2196, 1, '', NULL, NULL, 1, 0, 'F', '0', '0', 'core:notification:query', '1', '#', NULL, '超级管理员', '2023-09-19 15:17:27', '', NULL, '');
+INSERT INTO `sys_menu`(`id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `platform_type`, `icon`, `image_path`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (00000000000000002209, '通知公告编辑', 2196, 2, '', NULL, NULL, 1, 0, 'F', '0', '0', 'core:notification:edit', '1', '#', NULL, '超级管理员', '2023-09-19 15:17:56', '', NULL, '');
+INSERT INTO `sys_menu`(`id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `platform_type`, `icon`, `image_path`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (00000000000000002210, '新增通知公告', 2196, 3, '', NULL, NULL, 1, 0, 'F', '0', '0', 'core:notification:add', '1', '#', NULL, '超级管理员', '2023-09-19 15:18:18', '', NULL, '');
+INSERT INTO `sys_menu`(`id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `platform_type`, `icon`, `image_path`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (00000000000000002211, '删除通知公告', 2196, 4, '', NULL, NULL, 1, 0, 'F', '0', '0', 'core:notification:remove', '1', '#', NULL, '超级管理员', '2023-09-19 15:18:42', '', NULL, '');
+INSERT INTO `sys_menu`(`id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `platform_type`, `icon`, `image_path`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (00000000000000002212, '发布通知公告', 2196, 5, '', NULL, NULL, 1, 0, 'F', '0', '0', 'core:notification:publish', '1', '#', NULL, '超级管理员', '2023-09-19 15:19:03', '', NULL, '');

+ 35 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/message/domain/CoreAnnouncementNotificationToOrgtype.java

@@ -0,0 +1,35 @@
+package com.xunmei.common.core.domain.message.domain;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.xunmei.common.core.web.domain.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ * 公告通知对象 core_announcement_notification
+ *
+ * @author xunmei
+ * @date 2023-09-13
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@TableName("core_announcement_notification_to_orgtype")
+@ApiModel(value = "CoreAnnouncementNotificationToOrgtype" , description = "公告通知")
+public class CoreAnnouncementNotificationToOrgtype extends BaseEntity
+        {
+         private static final long serialVersionUID=1L;
+    @JsonSerialize(using = ToStringSerializer.class)
+
+    private Long announcementNotificationId;
+
+    /** 机构 */
+    @JsonSerialize(using = ToStringSerializer.class)
+    private String orgType;
+
+
+   }

+ 3 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/message/dto/CoreAnnouncementNotificationAppPageDto.java

@@ -40,4 +40,7 @@ public class CoreAnnouncementNotificationAppPageDto
 
             @JsonSerialize(using = ToStringSerializer.class)
             private List<Long> tagRoleIds;
+
+            private Integer orgType;
+            private String orgPath;
         }

+ 1 - 1
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/message/dto/CoreAnnouncementNotificationDto.java

@@ -59,7 +59,7 @@ private static final long serialVersionUID=1L;
             /**
              * 机构类型
              */
-      private String  tagOrgType;
+      private List<String>  tagOrgTypes;
     /** 目标机构 */
     private List<Long> tagOrgIds;
 

+ 2 - 1
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/message/vo/CoreAnnouncementNotificationPageVo.java

@@ -69,7 +69,8 @@ public class CoreAnnouncementNotificationPageVo {
     /**
      * 机构类型
      */
-    private String tagOrgType;
+    private List<String>  tagOrgTypes;
+    //private String  tagOrgType;
     /**
      * 目标机构
      */

+ 7 - 4
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/message/mapper/CoreAnnouncementNotificationMapper.java

@@ -2,10 +2,7 @@ package com.xunmei.core.message.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.xunmei.common.core.domain.message.domain.CoreAnnouncementNotification;
-import com.xunmei.common.core.domain.message.domain.CoreAnnouncementNotificationToOrg;
-import com.xunmei.common.core.domain.message.domain.CoreAnnouncementNotificationToRole;
-import com.xunmei.common.core.domain.message.domain.CoreAnnouncementNotificationToUser;
+import com.xunmei.common.core.domain.message.domain.*;
 import com.xunmei.common.core.domain.message.dto.CoreAnnouncementNotificationAppPageDto;
 import com.xunmei.common.core.domain.message.dto.CoreAnnouncementNotificationPageDto;
 import com.xunmei.common.core.domain.message.vo.CoreAnnouncementNotificationAppPageVo;
@@ -101,4 +98,10 @@ public interface CoreAnnouncementNotificationMapper extends BaseMapper<CoreAnnou
     Integer selectNoRead(Long userId);
 
     List<Long> selectAllTongZhi(@Param("orgId") Long orgId, @Param("orgType") Integer orgType, @Param("roles") Long[] roles);
+
+    void insertBatchToOrgType(@Param("list") List<CoreAnnouncementNotificationToOrgtype> list);
+
+    void deleteOrgtype(@Param("notificationId") Long notificationId);
+
+    List<CoreAnnouncementNotificationToOrgtype> selectOrgtypeIds( @Param("records") List<CoreAnnouncementNotificationPageVo> records);
 }

+ 63 - 19
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/message/service/impl/CoreAnnouncementNotificationServiceImpl.java

@@ -12,10 +12,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.xunmei.common.core.constant.ErrorMsgConstants;
 import com.xunmei.common.core.constant.SecurityConstants;
-import com.xunmei.common.core.domain.message.domain.CoreAnnouncementNotification;
-import com.xunmei.common.core.domain.message.domain.CoreAnnouncementNotificationToOrg;
-import com.xunmei.common.core.domain.message.domain.CoreAnnouncementNotificationToRole;
-import com.xunmei.common.core.domain.message.domain.CoreAnnouncementNotificationToUser;
+import com.xunmei.common.core.domain.message.domain.*;
 import com.xunmei.common.core.domain.message.dto.CoreAnnouncementNotificationAppPageDto;
 import com.xunmei.common.core.domain.message.dto.CoreAnnouncementNotificationDto;
 import com.xunmei.common.core.domain.message.dto.CoreAnnouncementNotificationPageDto;
@@ -167,10 +164,12 @@ public class CoreAnnouncementNotificationServiceImpl extends ServiceImpl<CoreAnn
     private Page<CoreAnnouncementNotificationPageVo> getOrgAndRoleListMap(Page<CoreAnnouncementNotificationPageVo> page) {
         List<CoreAnnouncementNotificationPageVo> records = page.getRecords();
         List<CoreAnnouncementNotificationToOrg> notificationToOrgs = coreAnnouncementNotificationMapper.selectOrgIds(records);
-        List<CoreAnnouncementNotificationToRole> notificationToRoles = coreAnnouncementNotificationMapper.selectRoleIds(records);
+        //List<CoreAnnouncementNotificationToRole> notificationToRoles = coreAnnouncementNotificationMapper.selectRoleIds(records);
+        List<CoreAnnouncementNotificationToOrgtype> notificationToOrgtypes = coreAnnouncementNotificationMapper.selectOrgtypeIds(records);
         for(CoreAnnouncementNotificationPageVo record : records){
             record.setTagOrgIds(notificationToOrgs.stream().filter(org -> org.getAnnouncementNotificationId().equals(record.getId())).map(CoreAnnouncementNotificationToOrg::getOrgId).collect(Collectors.toList()));
-            record.setTagRoleIds(notificationToRoles.stream().filter(role -> role.getAnnouncementNotificationId().equals(record.getId())).map(CoreAnnouncementNotificationToRole::getRoleId).collect(Collectors.toList()));
+            record.setTagOrgTypes(notificationToOrgtypes.stream().filter(orgtype -> orgtype.getAnnouncementNotificationId().equals(record.getId())).map(CoreAnnouncementNotificationToOrgtype::getOrgType).collect(Collectors.toList()));
+           // record.setTagRoleIds(notificationToRoles.stream().filter(role -> role.getAnnouncementNotificationId().equals(record.getId())).map(CoreAnnouncementNotificationToRole::getRoleId).collect(Collectors.toList()));
         }
         return page;
     }
@@ -191,9 +190,12 @@ public class CoreAnnouncementNotificationServiceImpl extends ServiceImpl<CoreAnn
         List<CoreAnnouncementNotificationPageVo> records = new ArrayList<>();
         records.add(vo);
         List<CoreAnnouncementNotificationToOrg> notificationToOrgs = coreAnnouncementNotificationMapper.selectOrgIds(records);
-        List<CoreAnnouncementNotificationToRole> notificationToRoles = coreAnnouncementNotificationMapper.selectRoleIds(records);
+        List<CoreAnnouncementNotificationToOrgtype> notificationToOrgtypes = coreAnnouncementNotificationMapper.selectOrgtypeIds(records);
+
+       // List<CoreAnnouncementNotificationToRole> notificationToRoles = coreAnnouncementNotificationMapper.selectRoleIds(records);
         vo.setTagOrgIds(notificationToOrgs.stream().filter(org -> org.getAnnouncementNotificationId().equals(vo.getId())).map(CoreAnnouncementNotificationToOrg::getOrgId).collect(Collectors.toList()));
-        vo.setTagRoleIds(notificationToRoles.stream().filter(role -> role.getAnnouncementNotificationId().equals(vo.getId())).map(CoreAnnouncementNotificationToRole::getRoleId).collect(Collectors.toList()));
+        vo.setTagOrgTypes(notificationToOrgtypes.stream().filter(org -> org.getAnnouncementNotificationId().equals(vo.getId())).map(CoreAnnouncementNotificationToOrgtype::getOrgType).collect(Collectors.toList()));
+        //vo.setTagRoleIds(notificationToRoles.stream().filter(role -> role.getAnnouncementNotificationId().equals(vo.getId())).map(CoreAnnouncementNotificationToRole::getRoleId).collect(Collectors.toList()));
         return vo;
     }
 
@@ -217,8 +219,18 @@ public class CoreAnnouncementNotificationServiceImpl extends ServiceImpl<CoreAnn
     @Override
    @Transactional(rollbackFor =  Exception.class)
     public void insertCoreAnnouncementNotification(CoreAnnouncementNotificationDto request) {
-        List<Long> orgIds = request.getTagOrgIds();
-        List<Long> roleIds = request.getTagRoleIds();
+        List<Long> orgIds = new ArrayList<>();
+       /* List<Long> roleIds = request.getTagRoleIds();*/
+        List<String> orgTypes = request.getTagOrgTypes();
+        SysOrg sysOrg = RemoteCallHandlerExecutor.executeRemoteCall(() -> orgService.selectSysOrgById(request.getOrgId(), SecurityConstants.INNER), ErrorMsgConstants.QUERY_ORG_DATA_ERROR);
+        List<SysOrg> orgList = RemoteCallHandlerExecutor.executeRemoteCall(() -> orgService.findAllOrg(SecurityConstants.INNER), ErrorMsgConstants.QUERY_ORG_DATA_ERROR);
+        //获取机构创建机构下的指定类型的机构
+        List<SysOrg> orgLists = orgList.stream().filter(r->(r.getType()!=null&&orgTypes.contains(r.getType().toString()))&&(r.getPath()!=null&&r.getPath().contains(sysOrg.getPath()))).collect(Collectors.toList());
+        if(CollectionUtil.isEmpty(orgLists)){
+            throw new RuntimeException("没有指定机构类型的机构");
+        }else{
+            orgLists.forEach(r->{orgIds.add(r.getId());});
+        }
         CoreAnnouncementNotification notification = this.buildSaveObject(request);
         if(CollectionUtil.isNotEmpty(orgIds)){
             List<CoreAnnouncementNotificationToOrg> list = new ArrayList<>();
@@ -230,7 +242,19 @@ public class CoreAnnouncementNotificationServiceImpl extends ServiceImpl<CoreAnn
             });
             coreAnnouncementNotificationMapper.insertBatchToOrg(list);
         }
-        if(CollectionUtil.isNotEmpty(roleIds)){
+        if(CollectionUtil.isNotEmpty(orgTypes)){
+            List<CoreAnnouncementNotificationToOrgtype> list = new ArrayList<>();
+            orgTypes.forEach(type -> {
+                CoreAnnouncementNotificationToOrgtype orgtype = new CoreAnnouncementNotificationToOrgtype();
+                orgtype.setOrgType(type);
+                orgtype.setAnnouncementNotificationId(notification.getId());
+                list.add(orgtype);
+            });
+            coreAnnouncementNotificationMapper.insertBatchToOrgType(list);
+        }
+
+
+       /* if(CollectionUtil.isNotEmpty(roleIds)){
             List<CoreAnnouncementNotificationToRole> list = new ArrayList<>();
             roleIds.forEach(roleId -> {
                 CoreAnnouncementNotificationToRole toOrg = new CoreAnnouncementNotificationToRole();
@@ -239,7 +263,7 @@ public class CoreAnnouncementNotificationServiceImpl extends ServiceImpl<CoreAnn
                 list.add(toOrg);
             });
             coreAnnouncementNotificationMapper.insertBatchToRole(list);
-        }
+        }*/
          coreAnnouncementNotificationMapper.insert(notification);
     }
 
@@ -266,11 +290,19 @@ public class CoreAnnouncementNotificationServiceImpl extends ServiceImpl<CoreAnn
     @Transactional(rollbackFor =  Exception.class)
     @Override
     public void updateCoreAnnouncementNotification(CoreAnnouncementNotificationDto request) {
-        List<Long> orgIds = request.getTagOrgIds();
-        List<Long> roleIds = request.getTagRoleIds();
-        //删除公告通知与角色和机构的关系
-        coreAnnouncementNotificationMapper.deleteRole(request.getId());
+        List<Long> orgIds = new ArrayList<>();
+        List<String> orgTypes = request.getTagOrgTypes();
+        SysOrg sysOrg = RemoteCallHandlerExecutor.executeRemoteCall(() -> orgService.selectSysOrgById(request.getOrgId(), SecurityConstants.INNER), ErrorMsgConstants.QUERY_ORG_DATA_ERROR);
+        List<SysOrg> orgList = RemoteCallHandlerExecutor.executeRemoteCall(() -> orgService.findAllOrg(SecurityConstants.INNER), ErrorMsgConstants.QUERY_ORG_DATA_ERROR);
+        //获取机构创建机构下的指定类型的机构
+        List<SysOrg> orgLists = orgList.stream().filter(r->(r.getType()!=null&&orgTypes.contains(r.getType().toString()))&&(r.getPath()!=null&&r.getPath().contains(sysOrg.getPath()))).collect(Collectors.toList());
+        if(CollectionUtil.isEmpty(orgLists)){
+            throw new RuntimeException("没有指定机构类型的机构");
+        }else{
+            orgLists.forEach(r->{orgIds.add(r.getId());});
+        }
         coreAnnouncementNotificationMapper.deleteOrg(request.getId());
+        coreAnnouncementNotificationMapper.deleteOrgtype(request.getId());
         CoreAnnouncementNotification notification = this.buildSaveObject(request);
         if(CollectionUtil.isNotEmpty(orgIds)){
             List<CoreAnnouncementNotificationToOrg> list = new ArrayList<>();
@@ -282,7 +314,18 @@ public class CoreAnnouncementNotificationServiceImpl extends ServiceImpl<CoreAnn
             });
             coreAnnouncementNotificationMapper.insertBatchToOrg(list);
         }
-        if(CollectionUtil.isNotEmpty(roleIds)){
+        if(CollectionUtil.isNotEmpty(orgTypes)){
+            List<CoreAnnouncementNotificationToOrgtype> list = new ArrayList<>();
+            orgTypes.forEach(type -> {
+                CoreAnnouncementNotificationToOrgtype orgtype = new CoreAnnouncementNotificationToOrgtype();
+                orgtype.setOrgType(type);
+                orgtype.setAnnouncementNotificationId(notification.getId());
+                list.add(orgtype);
+            });
+            coreAnnouncementNotificationMapper.insertBatchToOrgType(list);
+        }
+
+  /*      if(CollectionUtil.isNotEmpty(roleIds)){
             List<CoreAnnouncementNotificationToRole> list = new ArrayList<>();
             roleIds.forEach(roleId -> {
                 CoreAnnouncementNotificationToRole toOrg = new CoreAnnouncementNotificationToRole();
@@ -291,7 +334,7 @@ public class CoreAnnouncementNotificationServiceImpl extends ServiceImpl<CoreAnn
                 list.add(toOrg);
             });
             coreAnnouncementNotificationMapper.insertBatchToRole(list);
-        }
+        }*/
          coreAnnouncementNotificationMapper.updateById(notification);
     }
 
@@ -307,8 +350,9 @@ public class CoreAnnouncementNotificationServiceImpl extends ServiceImpl<CoreAnn
         //删除公告通知与角色和机构的关系
         //刪除已读记录
         for(Long id:ids){
-            coreAnnouncementNotificationMapper.deleteRole(id);
+           // coreAnnouncementNotificationMapper.deleteRole(id);
             coreAnnouncementNotificationMapper.deleteOrg(id);
+            coreAnnouncementNotificationMapper.deleteOrgtype(id);
             coreAnnouncementNotificationMapper.deleteNotificationToUsers(id);
         }
 

+ 24 - 1
soc-modules/soc-modules-core/src/main/resources/mapper/message/CoreAnnouncementNotificationMapper.xml

@@ -80,7 +80,7 @@
             #{item.id}
         </foreach>
     </select>
-    <select id="selectAppPage"
+<!--    <select id="selectAppPage"
             resultType="com.xunmei.common.core.domain.message.vo.MessageAppPageVo">
         select T.*,T.file_list as strFileList,T.org_name as publishOrg from (select a.* from core_announcement_notification a
                          left join core_announcement_notification_to_role b on a.id = b.announcement_notification_id
@@ -90,6 +90,13 @@
                                 #{item}
                             </foreach> and a.messag_type=1))
                          GROUP BY a.id) T
+    </select>-->
+    <select id="selectAppPage"
+            resultType="com.xunmei.common.core.domain.message.vo.MessageAppPageVo">
+        select T.*,T.file_list as strFileList,T.org_name as publishOrg from (select a.* from core_announcement_notification a
+        left join core_announcement_notification_to_org c on a.id = c.announcement_notification_id
+        where a.messag_status = 1 and c.org_id = #{request.orgId}
+        GROUP BY a.id) T ORDER BY publish_time desc
     </select>
     <select id="selectNotificationToUsers"
             resultType="com.xunmei.common.core.domain.message.domain.CoreAnnouncementNotificationToUser">
@@ -147,6 +154,13 @@
         WHERE
             user_id=#{userId}
     </select>
+    <select id="selectOrgtypeIds"
+            resultType="com.xunmei.common.core.domain.message.domain.CoreAnnouncementNotificationToOrgtype">
+        select * from core_announcement_notification_to_orgtype where announcement_notification_id in
+        <foreach collection="records" item="item" open="(" close=")" separator=",">
+            #{item.id}
+        </foreach>
+    </select>
 
     <insert id="insertCoreAnnouncementNotification" parameterType="com.xunmei.common.core.domain.message.domain.CoreAnnouncementNotification">
         insert into core_announcement_notification
@@ -223,6 +237,12 @@
         insert into core_announcement_notification_to_user(id,announcement_notification_id,org_id,user_id)
         values(#{notificationUser.id},#{notificationUser.announcementNotificationId},#{notificationUser.orgId},#{notificationUser.userId})
     </insert>
+    <insert id="insertBatchToOrgType">
+        insert into core_announcement_notification_to_orgtype (announcement_notification_id, org_type)values
+        <foreach collection="list" item="item" index="index"  separator="," >
+            (#{item.announcementNotificationId},#{item.orgType})
+        </foreach>
+    </insert>
 
     <update id="updateCoreAnnouncementNotification" parameterType="com.xunmei.common.core.domain.message.domain.CoreAnnouncementNotification">
         update core_announcement_notification
@@ -288,4 +308,7 @@
     <delete id="deleteOrg">
         delete from core_announcement_notification_to_org  where announcement_notification_id = #{notificationId}
     </delete>
+    <delete id="deleteOrgtype">
+        delete from core_announcement_notification_to_orgtype  where announcement_notification_id = #{notificationId}
+    </delete>
 </mapper>