Przeglądaj źródła

公告改变状态添加人员

phoenix 1 rok temu
rodzic
commit
160c73cfb7

+ 5 - 1
src/main/java/com/xjrsoft/module/oa/mapper/NewsMapper.java

@@ -4,8 +4,12 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.github.yulichang.base.MPJBaseMapper;
 import com.xjrsoft.module.oa.dto.NewsPageDto;
 import com.xjrsoft.module.oa.entity.News;
+import com.xjrsoft.module.oa.vo.DeptIdOrClassIdVo;
 import com.xjrsoft.module.oa.vo.NewsPageVo;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * <p>
@@ -21,5 +25,5 @@ public interface NewsMapper extends MPJBaseMapper<News> {
 
     IPage<NewsPageVo> receiptBox(IPage<NewsPageDto> page,NewsPageDto dto);
 
-    //Boolean insert();
+    List<DeptIdOrClassIdVo> getDeptIdOrClassId(@Param("personalIdList") List<Long> personalIdList);
 }

+ 4 - 0
src/main/java/com/xjrsoft/module/oa/mapper/NewsRelationConfigMapper.java

@@ -6,4 +6,8 @@ import org.apache.ibatis.annotations.Mapper;
 
 @Mapper
 public interface NewsRelationConfigMapper  extends MPJBaseMapper<NewsRelationConfig> {
+
+    //硬删除关系配置
+//    @Update("DELETE FROM xjr_oa_news_relation_config WHERE ")
+//    void deleteNewsRelationConfig();
 }

+ 30 - 0
src/main/java/com/xjrsoft/module/oa/mapper/NewsRelationMapper.java

@@ -3,7 +3,37 @@ package com.xjrsoft.module.oa.mapper;
 import com.github.yulichang.base.MPJBaseMapper;
 import com.xjrsoft.module.oa.entity.NewsRelation;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 @Mapper
 public interface NewsRelationMapper extends MPJBaseMapper<NewsRelation> {
+    /**
+     * 添加全体教职工
+     * @param newsId
+     * @return
+     */
+    Boolean insertAllTeaStaff(@Param("newsId") Long newsId);
+    /**
+     * 添加部门下面的人
+     * @param newsId
+     * @param deptIdList
+     * @return
+     */
+    Boolean insertDeptUser(@Param("newsId") Long newsId, @Param("deptIdList")List<Long> deptIdList);
+    /**
+     * 添加班级下面的人
+     * @param newsId
+     * @param classIdList
+     * @return
+     */
+    Boolean insertClassUser(@Param("newsId") Long newsId, @Param("classIdList")List<Long> classIdList);
+    /**
+     * 添加人员下面的人
+     * @param newsId
+     * @param userIdList
+     * @return
+     */
+    Boolean insertPersonl(@Param("newsId") Long newsId, @Param("userIdList")List<Long> userIdList);
 }

+ 186 - 122
src/main/java/com/xjrsoft/module/oa/service/impl/NewsServiceImpl.java

@@ -36,7 +36,9 @@ import com.xjrsoft.module.oa.service.INewsRelationService;
 import com.xjrsoft.module.oa.service.INewsService;
 import com.xjrsoft.module.oa.vo.*;
 import com.xjrsoft.module.organization.dto.WeChatSendMessageDto;
-import com.xjrsoft.module.organization.entity.*;
+import com.xjrsoft.module.organization.entity.Department;
+import com.xjrsoft.module.organization.entity.User;
+import com.xjrsoft.module.organization.entity.UserDeptRelation;
 import com.xjrsoft.module.organization.mapper.DepartmentMapper;
 import com.xjrsoft.module.organization.mapper.UserDeptRelationMapper;
 import com.xjrsoft.module.organization.mapper.UserMapper;
@@ -53,7 +55,6 @@ import org.springframework.transaction.annotation.Transactional;
 import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.Date;
-import java.util.HashMap;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -104,7 +105,7 @@ public class NewsServiceImpl extends MPJBaseServiceImpl<NewsMapper, News> implem
         List<NewsGradeClassTreeVo> treeVoList = new ArrayList<NewsGradeClassTreeVo>();
 
         //虚拟父级
-        treeVoList.add(new NewsGradeClassTreeVo(){{
+        treeVoList.add(new NewsGradeClassTreeVo() {{
             setId(666666L);
             setName("班级");
         }});
@@ -118,7 +119,7 @@ public class NewsServiceImpl extends MPJBaseServiceImpl<NewsMapper, News> implem
                 .leftJoin(BaseGrade.class, BaseGrade::getId, BaseClass::getGradeId);
         List<BaseGrade> gradeList = baseClassMapper.selectJoinList(BaseGrade.class, queryGrade);
         gradeList.forEach((node) -> {
-            treeVoList.add(new NewsGradeClassTreeVo(){{
+            treeVoList.add(new NewsGradeClassTreeVo() {{
                 setId(node.getId());
                 setName(node.getName());
                 setParentId(666666L);
@@ -129,7 +130,7 @@ public class NewsServiceImpl extends MPJBaseServiceImpl<NewsMapper, News> implem
         List<BaseClass> classList = baseClassMapper.selectList(new QueryWrapper<BaseClass>());
         //获取班级荣誉中出现的学期下的所有班级作为树的子级
         classList.forEach((node) -> {
-            treeVoList.add(new NewsGradeClassTreeVo(){{
+            treeVoList.add(new NewsGradeClassTreeVo() {{
                 setId(node.getId());
                 setName(node.getName());
                 setParentId(node.getGradeId());
@@ -163,41 +164,41 @@ public class NewsServiceImpl extends MPJBaseServiceImpl<NewsMapper, News> implem
             for (AddNewsRelationDto relationDto : addProclamationDto.getRelationList()) {
                 if (relationDto.getRelationType() == 1) {
                     Department department = departmentMapper.selectById(relationDto.getRelationId());
-                    newsRelationConfigMapper.insert(new NewsRelationConfig(){{
+                    newsRelationConfigMapper.insert(new NewsRelationConfig() {{
                         setNewsId(news.getId());
                         setRelationId(relationDto.getRelationId());
                         setRelationType(relationDto.getRelationType());
-                        if(department != null){
+                        if (department != null) {
                             setRelationName(department.getName());
                         }
                     }});
                 }
-                if (relationDto.getRelationType() == 2)  {
+                if (relationDto.getRelationType() == 2) {
                     XjrUser xjrUser = xjrUserMapper.selectById(relationDto.getRelationId());
-                    newsRelationConfigMapper.insert(new NewsRelationConfig(){{
+                    newsRelationConfigMapper.insert(new NewsRelationConfig() {{
                         setNewsId(news.getId());
                         setRelationId(relationDto.getRelationId());
                         setRelationType(relationDto.getRelationType());
-                        if(xjrUser != null){
+                        if (xjrUser != null) {
                             setRelationName(xjrUser.getName());
                         }
                     }});
                 }
-                if (relationDto.getRelationType() == 3)  {
+                if (relationDto.getRelationType() == 3) {
                     BaseClass baseClass = baseClassMapper.selectById(relationDto.getRelationId());
                     BaseGrade baseGrade = null;
-                    if(baseClass == null){
+                    if (baseClass == null) {
                         baseGrade = baseGradeMapper.selectById(relationDto.getRelationId());
                     }
                     BaseGrade finalBaseGrade = baseGrade;
-                    newsRelationConfigMapper.insert(new NewsRelationConfig(){{
+                    newsRelationConfigMapper.insert(new NewsRelationConfig() {{
                         setNewsId(news.getId());
                         setRelationId(relationDto.getRelationId());
                         setRelationType(relationDto.getRelationType());
-                        if(baseClass != null){
+                        if (baseClass != null) {
                             setRelationName(baseClass.getName());
                         }
-                        if(finalBaseGrade != null){
+                        if (finalBaseGrade != null) {
                             setRelationName(finalBaseGrade.getName());
                         }
                     }});
@@ -215,20 +216,20 @@ public class NewsServiceImpl extends MPJBaseServiceImpl<NewsMapper, News> implem
                 .selectAs(Department::getName, ProclamationVo::getSendDeptIdCN)
                 .select(News.class, x -> VoToColumnUtil.fieldsToColumns(ProclamationVo.class).contains(x.getProperty()))
                 .leftJoin(Department.class, Department::getId, News::getSendDeptId)
-                .eq(News::getId , id);
+                .eq(News::getId, id);
         ProclamationVo proclamationVo = this.selectJoinOne(ProclamationVo.class, queryWrapperNews);
         if (proclamationVo == null) {
-           return null;
+            return null;
         }
 
         //添加阅读关系集合
         List<NewsRelationConfigVo> newsRelationConfigVoList = new ArrayList<>();
         //公告在草稿状态还没有阅读状态,只有阅读关系
-        if(proclamationVo.getStatus() == 1){
+        if (proclamationVo.getStatus() == 1) {
             MPJLambdaWrapper<NewsRelationConfig> queryWrapperNewsRelationConfig = new MPJLambdaWrapper<>();
             queryWrapperNewsRelationConfig
                     .select(NewsRelationConfig.class, x -> VoToColumnUtil.fieldsToColumns(NewsRelationConfigVo.class).contains(x.getProperty()))
-                    .eq(NewsRelationConfig::getNewsId , proclamationVo.getId());
+                    .eq(NewsRelationConfig::getNewsId, proclamationVo.getId());
             newsRelationConfigVoList = newsRelationConfigMapper.selectJoinList(NewsRelationConfigVo.class, queryWrapperNewsRelationConfig);
         }
         proclamationVo.setNewsRelationConfigVoList(newsRelationConfigVoList);
@@ -236,22 +237,22 @@ public class NewsServiceImpl extends MPJBaseServiceImpl<NewsMapper, News> implem
         //添加阅读状态集合
         List<NewsRelationVo> newsRelationVoList = new ArrayList<>();
         //公告在发布状态或下架状态
-        if(proclamationVo.getStatus() == 2 || proclamationVo.getStatus() == 3){
+        if (proclamationVo.getStatus() == 2 || proclamationVo.getStatus() == 3) {
             MPJLambdaWrapper<NewsRelation> queryWrapper = new MPJLambdaWrapper<>();
             queryWrapper
                     .select(NewsRelation::getId)
-                    .selectAs(XjrUser::getName,NewsRelationVo::getUserName)
+                    .selectAs(XjrUser::getName, NewsRelationVo::getUserName)
                     .select(NewsRelation.class, x -> VoToColumnUtil.fieldsToColumns(NewsRelationVo.class).contains(x.getProperty()))
-                    .leftJoin(XjrUser.class,XjrUser::getId,NewsRelation::getUserId)
-                    .eq(NewsRelation::getNewsId , proclamationVo.getId())
+                    .leftJoin(XjrUser.class, XjrUser::getId, NewsRelation::getUserId)
+                    .eq(NewsRelation::getNewsId, proclamationVo.getId())
                     .disableSubLogicDel();
             //当是发布人点击了该公告可以看到其下所有人的回复
-            if(ObjectUtil.isNotNull(proclamationVo.getCreateUserId()) && StpUtil.getLoginIdAsLong() == proclamationVo.getCreateUserId()) {
+            if (ObjectUtil.isNotNull(proclamationVo.getCreateUserId()) && StpUtil.getLoginIdAsLong() == proclamationVo.getCreateUserId()) {
                 newsRelationVoList = newsRelationService.selectJoinList(NewsRelationVo.class, queryWrapper);
-            }else {//当不是发布人点击了该公告只能看到自己的回复
-                queryWrapper.eq(NewsRelation::getUserId , StpUtil.getLoginIdAsLong());
+            } else {//当不是发布人点击了该公告只能看到自己的回复
+                queryWrapper.eq(NewsRelation::getUserId, StpUtil.getLoginIdAsLong());
                 NewsRelationVo newsRelationVo = newsRelationService.selectJoinOne(NewsRelationVo.class, queryWrapper);
-                if(ObjectUtil.isNotNull(newsRelationVo)){
+                if (ObjectUtil.isNotNull(newsRelationVo)) {
                     newsRelationVoList.add(newsRelationVo);
                 }
             }
@@ -309,7 +310,8 @@ public class NewsServiceImpl extends MPJBaseServiceImpl<NewsMapper, News> implem
                 .or()
                 .eq(News::getSendRange, 2)
                 .orderByDesc(News::getReleaseTime)
-                .disableSubLogicDel();;
+                .disableSubLogicDel();
+        ;
         IPage<ProclamationPageVo> page = this.selectJoinListPage(ConventPage.getPage(dto), ProclamationPageVo.class, queryNews);
         return page;
     }
@@ -331,7 +333,7 @@ public class NewsServiceImpl extends MPJBaseServiceImpl<NewsMapper, News> implem
 
         xjrNews.setStatus(changeNewsDto.getStatus());
         //发布公告,将阅读关系中选择的阅读人添加到关系表
-        if(xjrNews.getStatus() == 2){
+        if (xjrNews.getStatus() == 2) {
             //将发布时间改为当前时间
             xjrNews.setReleaseTime(LocalDateTime.now());
             //将张贴时间改为当前时间
@@ -339,96 +341,158 @@ public class NewsServiceImpl extends MPJBaseServiceImpl<NewsMapper, News> implem
             xjrNews.setModifyUserId(StpUtil.getLoginIdAsLong());
             xjrNews.setModifyDate(LocalDateTime.now());
 
-            LambdaQueryWrapper<NewsRelationConfig> queryConfig = new LambdaQueryWrapper<>();
-            queryConfig
-                    .eq(NewsRelationConfig::getNewsId, xjrNews.getId());
-            List<NewsRelationConfig> newsRelationConfigList = newsRelationConfigMapper.selectList(queryConfig);
-
-            HashMap<Long, XjrUser> userMap = new HashMap<>();
-            if(xjrNews.getSendRange() == 3){
-                //遍历所有关系配置
-                for (NewsRelationConfig newsRelationConfig : newsRelationConfigList) {
-                    //阅读关系是部门
-                    if(newsRelationConfig.getRelationType() == 1){
-                        // 获取部门下的人员添加
-                        Long deptId = newsRelationConfig.getRelationId();
-                        MPJLambdaWrapper<XjrUser> queryUser = new MPJLambdaWrapper<>();
-                        queryUser
-                                .leftJoin(UserDeptRelation.class,UserDeptRelation::getUserId,XjrUser::getId)
-                                .leftJoin(Department.class,Department::getId,UserDeptRelation::getDeptId)
-                                .eq(Department::getId,deptId);
-                        List<XjrUser> userList = xjrUserMapper.selectJoinList(XjrUser.class,queryUser);
-                        for (XjrUser user: userList) {
-                            if(!userMap.containsKey(user.getId())){
-                                userMap.put(user.getId(),user);
-                                newsRelationMapper.insert(new NewsRelation(){{
-                                    setNewsId(xjrNews.getId());
-                                    setUserId(user.getId());
-                                    setReadMark(0);
-                                    setCreateDate(LocalDateTime.now());
-                                }});
+            if (xjrNews.getSendRange() == 3) {
+                //查出当前公告的关系配置
+                //部门
+                LambdaQueryWrapper<NewsRelationConfig> queryDeptList = new LambdaQueryWrapper<>();
+                queryDeptList
+                        .eq(NewsRelationConfig::getNewsId, xjrNews.getId())
+                        .eq(NewsRelationConfig::getRelationType, 1);
+                List<NewsRelationConfig> deptList = newsRelationConfigMapper.selectList(queryDeptList);
+                List<Long> deptIdList = new ArrayList<>();
+                for (NewsRelationConfig newsRelationConfig : deptList) {
+                    deptIdList.add(newsRelationConfig.getRelationId());
+                }
+
+                //人员
+                LambdaQueryWrapper<NewsRelationConfig> queryPersonalList = new LambdaQueryWrapper<>();
+                queryPersonalList
+                        .eq(NewsRelationConfig::getNewsId, xjrNews.getId())
+                        .eq(NewsRelationConfig::getRelationType, 2);
+                List<NewsRelationConfig> personalList = newsRelationConfigMapper.selectList(queryPersonalList);
+                List<Long> personalIdList = new ArrayList<>();
+                for (NewsRelationConfig newsRelationConfig : personalList) {
+                    personalIdList.add(newsRelationConfig.getRelationId());
+                }
+
+                //班级
+                LambdaQueryWrapper<NewsRelationConfig> queryClassList = new LambdaQueryWrapper<>();
+                queryClassList
+                        .eq(NewsRelationConfig::getNewsId, xjrNews.getId())
+                        .eq(NewsRelationConfig::getRelationType, 3);
+                List<NewsRelationConfig> classList = newsRelationConfigMapper.selectList(queryClassList);
+                List<Long> classIdList = new ArrayList<>();
+                for (NewsRelationConfig newsRelationConfig : classList) {
+                    classIdList.add(newsRelationConfig.getRelationId());
+                }
+
+                //对人员进行筛选,避免重复添加
+                List<Long> userIdList = new ArrayList<>();
+                if (personalIdList != null) {
+                    //获取人员的班级或者部门
+                    List<DeptIdOrClassIdVo> deptIdOrClassIdVoList = newsMapper.getDeptIdOrClassId(personalIdList);
+                    for (DeptIdOrClassIdVo deptIdOrClassIdVo : deptIdOrClassIdVoList) {
+                        if (deptIdOrClassIdVo.getClassId() != null) {//有班级是学生
+                            if (!classIdList.contains(deptIdOrClassIdVo.getClassId())) {
+                                userIdList.add(deptIdOrClassIdVo.getUserId());
+                            }
+                        } else {
+                            if (!deptIdList.contains(deptIdOrClassIdVo.getDeptId())) {
+                                userIdList.add(deptIdOrClassIdVo.getUserId());
                             }
                         }
                     }
-                    //阅读关系是人员
-                    if(newsRelationConfig.getRelationType() == 2){
-                        if(!userMap.containsKey(newsRelationConfig.getRelationId())){
-                            userMap.put(newsRelationConfig.getRelationId(),new XjrUser(){{
-                                setId(newsRelationConfig.getRelationId());
-                            }});
-                            newsRelationMapper.insert(new NewsRelation(){{
+                }
+
+                //添加部门人员
+                if (deptIdList != null) {
+                    newsRelationMapper.insertDeptUser(xjrNews.getId(), deptIdList);
+                }
+
+                //添加部门人员
+                if (classIdList != null) {
+                    newsRelationMapper.insertClassUser(xjrNews.getId(), classIdList);
+                }
+
+                //添加部门人员
+                if (userIdList != null) {
+                    newsRelationMapper.insertPersonl(xjrNews.getId(), userIdList);
+                }
+            }
+
+            //遍历所有关系配置
+           /* for (NewsRelationConfig newsRelationConfig : newsRelationConfigList) {
+                //阅读关系是部门
+                if (newsRelationConfig.getRelationType() == 1) {
+                    // 获取部门下的人员添加
+                    Long deptId = newsRelationConfig.getRelationId();
+                    MPJLambdaWrapper<XjrUser> queryUser = new MPJLambdaWrapper<>();
+                    queryUser
+                            .leftJoin(UserDeptRelation.class, UserDeptRelation::getUserId, XjrUser::getId)
+                            .leftJoin(Department.class, Department::getId, UserDeptRelation::getDeptId)
+                            .leftJoin(UserRoleRelation.class, UserRoleRelation::getUserId, XjrUser::getId)
+                            .leftJoin(Role.class, Role::getId, UserRoleRelation::getRoleId)
+                            .eq(Department::getId, deptId)
+                            .eq(Role::getId, 2);
+                    List<XjrUser> userList = xjrUserMapper.selectJoinList(XjrUser.class, queryUser);
+                    for (XjrUser user : userList) {
+                        if (!userMap.containsKey(user.getId())) {
+                            userMap.put(user.getId(), user);
+                            newsRelationMapper.insert(new NewsRelation() {{
                                 setNewsId(xjrNews.getId());
-                                setUserId(newsRelationConfig.getRelationId());
+                                setUserId(user.getId());
                                 setReadMark(0);
                                 setCreateDate(LocalDateTime.now());
                             }});
                         }
                     }
-                    //阅读关系是班级
-                    if(newsRelationConfig.getRelationType() == 3){
-                        // 获取班级下的人员添加
-                        Long classId = newsRelationConfig.getRelationId();
-                        MPJLambdaWrapper<XjrUser> queryUser = new MPJLambdaWrapper<>();
-                        queryUser
-                                .leftJoin(BaseStudentSchoolRoll.class,BaseStudentSchoolRoll::getUserId,XjrUser::getId)
-                                .eq(BaseStudentSchoolRoll::getClassId,classId);
-                        List<XjrUser> userList = xjrUserMapper.selectJoinList(XjrUser.class,queryUser);
-                        for (XjrUser user: userList) {
-                            if(!userMap.containsKey(user.getId())){
-                                userMap.put(user.getId(),user);
-                                newsRelationMapper.insert(new NewsRelation(){{
-                                    setNewsId(xjrNews.getId());
-                                    setUserId(user.getId());
-                                    setReadMark(0);
-                                    setCreateDate(LocalDateTime.now());
-                                }});
-                            }
-                        }
-                    }
                 }
-            }
-            if(xjrNews.getSendRange() == 1){
-                MPJLambdaWrapper<XjrUser> queryUser = new MPJLambdaWrapper<>();
-                queryUser
-                        .leftJoin(UserRoleRelation.class, UserRoleRelation::getUserId, XjrUser::getId)
-                        .leftJoin(Role.class, Role::getId, UserRoleRelation::getRoleId)
-                        .eq(Role::getId,2);
-                List<XjrUser> userList = xjrUserMapper.selectJoinList(XjrUser.class,queryUser);
-                for (XjrUser user: userList) {
-                    if(!userMap.containsKey(user.getId())){
-                        userMap.put(user.getId(),user);
-                        newsRelationMapper.insert(new NewsRelation(){{
+                //阅读关系是人员
+                if (newsRelationConfig.getRelationType() == 2) {
+                    if (!userMap.containsKey(newsRelationConfig.getRelationId())) {
+                        userMap.put(newsRelationConfig.getRelationId(), new XjrUser() {{
+                            setId(newsRelationConfig.getRelationId());
+                        }});
+                        newsRelationMapper.insert(new NewsRelation() {{
                             setNewsId(xjrNews.getId());
-                            setUserId(user.getId());
+                            setUserId(newsRelationConfig.getRelationId());
                             setReadMark(0);
                             setCreateDate(LocalDateTime.now());
                         }});
                     }
                 }
+                //阅读关系是班级
+                if (newsRelationConfig.getRelationType() == 3) {
+                    // 获取班级下的人员添加
+                    Long classId = newsRelationConfig.getRelationId();
+                    MPJLambdaWrapper<XjrUser> queryUser = new MPJLambdaWrapper<>();
+                    queryUser
+                            .leftJoin(BaseStudentSchoolRoll.class, BaseStudentSchoolRoll::getUserId, XjrUser::getId)
+                            .eq(BaseStudentSchoolRoll::getClassId, classId);
+                    List<XjrUser> userList = xjrUserMapper.selectJoinList(XjrUser.class, queryUser);
+                    for (XjrUser user : userList) {
+                        if (!userMap.containsKey(user.getId())) {
+                            userMap.put(user.getId(), user);
+                            newsRelationMapper.insert(new NewsRelation() {{
+                                setNewsId(xjrNews.getId());
+                                setUserId(user.getId());
+                                setReadMark(0);
+                                setCreateDate(LocalDateTime.now());
+                            }});
+                        }
+                    }
+                }
+            }*/
+            if (xjrNews.getSendRange() == 2) {
+//                MPJLambdaWrapper<XjrUser> queryUser = new MPJLambdaWrapper<>();
+//                queryUser
+//                        .leftJoin(UserRoleRelation.class, UserRoleRelation::getUserId, XjrUser::getId)
+//                        .leftJoin(Role.class, Role::getId, UserRoleRelation::getRoleId)
+//                        .eq(Role::getId, 2);
+//                List<XjrUser> userList = xjrUserMapper.selectJoinList(XjrUser.class, queryUser);
+//                for (XjrUser user : userList) {
+//                    newsRelationMapper.insert(new NewsRelation() {{
+//                        setNewsId(xjrNews.getId());
+//                        setUserId(user.getId());
+//                        setReadMark(0);
+//                        setCreateDate(LocalDateTime.now());
+//                    }});
+//                }
+                newsRelationMapper.insertAllTeaStaff(xjrNews.getId());
             }
         }
 
-        if(xjrNews.getStatus() == 3){
+        if (xjrNews.getStatus() == 3) {
             //应该将关系配置表和关系表的数据设置为删除
         }
         return this.updateById(xjrNews);
@@ -458,35 +522,35 @@ public class NewsServiceImpl extends MPJBaseServiceImpl<NewsMapper, News> implem
                 if (relationDto.getRelationType() == 1) {
                     Department department = departmentMapper.selectById(relationDto.getRelationId());
 
-                    newsRelationConfigMapper.insert(new NewsRelationConfig(){{
+                    newsRelationConfigMapper.insert(new NewsRelationConfig() {{
                         setNewsId(news.getId());
                         setRelationId(relationDto.getRelationId());
                         setRelationType(relationDto.getRelationType());
-                        if(department != null){
+                        if (department != null) {
                             setRelationName(department.getName());
                         }
                     }});
                 }
-                if (relationDto.getRelationType() == 2)  {
+                if (relationDto.getRelationType() == 2) {
                     XjrUser xjrUser = xjrUserMapper.selectById(relationDto.getRelationId());
 
-                    newsRelationConfigMapper.insert(new NewsRelationConfig(){{
+                    newsRelationConfigMapper.insert(new NewsRelationConfig() {{
                         setNewsId(news.getId());
                         setRelationId(relationDto.getRelationId());
                         setRelationType(relationDto.getRelationType());
-                        if(xjrUser != null){
+                        if (xjrUser != null) {
                             setRelationName(xjrUser.getName());
                         }
                     }});
                 }
-                if (relationDto.getRelationType() == 3)  {
+                if (relationDto.getRelationType() == 3) {
                     BaseClass baseClass = baseClassMapper.selectById(relationDto.getRelationId());
 
-                    newsRelationConfigMapper.insert(new NewsRelationConfig(){{
+                    newsRelationConfigMapper.insert(new NewsRelationConfig() {{
                         setNewsId(news.getId());
                         setRelationId(relationDto.getRelationId());
                         setRelationType(relationDto.getRelationType());
-                        if(baseClass != null){
+                        if (baseClass != null) {
                             setRelationName(baseClass.getName());
                         }
                     }});
@@ -544,33 +608,33 @@ public class NewsServiceImpl extends MPJBaseServiceImpl<NewsMapper, News> implem
                     Long deptId = relationDto.getRelationId();
                     MPJLambdaWrapper<XjrUser> queryUser = new MPJLambdaWrapper<>();
                     queryUser
-                            .leftJoin(UserDeptRelation.class,UserDeptRelation::getUserId,XjrUser::getId)
-                            .leftJoin(Department.class,Department::getId,UserDeptRelation::getDeptId)
-                            .eq(Department::getId,deptId);
-                    List<XjrUser> userList = xjrUserMapper.selectJoinList(XjrUser.class,queryUser);
-                    for (XjrUser user: userList) {
+                            .leftJoin(UserDeptRelation.class, UserDeptRelation::getUserId, XjrUser::getId)
+                            .leftJoin(Department.class, Department::getId, UserDeptRelation::getDeptId)
+                            .eq(Department::getId, deptId);
+                    List<XjrUser> userList = xjrUserMapper.selectJoinList(XjrUser.class, queryUser);
+                    for (XjrUser user : userList) {
                         newsRelation.setUserId(user.getId());
                         newsRelationMapper.insert(newsRelation);
                     }
                 }
-                if (relationDto.getRelationType() == 2)  {
+                if (relationDto.getRelationType() == 2) {
                     newsRelation.setUserId(relationDto.getRelationId());
                     newsRelationMapper.insert(newsRelation);
                 }
-                if (relationDto.getRelationType() == 3)  {
+                if (relationDto.getRelationType() == 3) {
                     // 获取班级下的人员添加
                     Long deptId = relationDto.getRelationId();
                     MPJLambdaWrapper<XjrUser> queryUser = new MPJLambdaWrapper<>();
                     queryUser
-                            .leftJoin(UserDeptRelation.class,UserDeptRelation::getUserId,XjrUser::getId)
-                            .leftJoin(Department.class,Department::getId,UserDeptRelation::getDeptId)
-                            .eq(Department::getId,deptId);
-                    List<XjrUser> userList = xjrUserMapper.selectJoinList(XjrUser.class,queryUser);
+                            .leftJoin(UserDeptRelation.class, UserDeptRelation::getUserId, XjrUser::getId)
+                            .leftJoin(Department.class, Department::getId, UserDeptRelation::getDeptId)
+                            .eq(Department::getId, deptId);
+                    List<XjrUser> userList = xjrUserMapper.selectJoinList(XjrUser.class, queryUser);
                     List<Long> userIdList = new ArrayList<>();
-                    for (XjrUser user: userList) {
+                    for (XjrUser user : userList) {
                         userIdList.add(user.getId());
                     }
-                    for (Long userId: userIdList) {
+                    for (Long userId : userIdList) {
                         newsRelation.setUserId(userId);
                         newsRelationMapper.insert(newsRelation);
                     }
@@ -579,7 +643,7 @@ public class NewsServiceImpl extends MPJBaseServiceImpl<NewsMapper, News> implem
         }
 
         //添加新闻和公告的时候,如果状态是2,表示新闻和公告实时发布了,张贴开始时间就应该是发布时间需要发送消息
-        if(ObjectUtil.isNotNull(addNewsDto.getStatus()) && addNewsDto.getStatus() == 2){
+        if (ObjectUtil.isNotNull(addNewsDto.getStatus()) && addNewsDto.getStatus() == 2) {
             SendMessage(news.getId());
         }
 

+ 16 - 0
src/main/java/com/xjrsoft/module/oa/vo/DeptIdOrClassIdVo.java

@@ -0,0 +1,16 @@
+package com.xjrsoft.module.oa.vo;
+
+import lombok.Data;
+
+/**
+ * @description:TODO
+ * @author: phoenix
+ * @create: 2024/1/10 17:31
+ * @Version 1.0
+ */
+@Data
+public class DeptIdOrClassIdVo {
+    private Long userId;
+    private Long deptId;
+    private Long classId;
+}

+ 1 - 1
src/main/java/com/xjrsoft/module/teacher/service/impl/WfTeacherleaveServiceImpl.java

@@ -116,7 +116,7 @@ public class WfTeacherleaveServiceImpl extends MPJBaseServiceImpl<WfTeacherleave
                     QueryWrapper<WfHeadTeacherLeave> queryWrapperSortcode = new QueryWrapper<>();
                     queryWrapperSortcode.select("IFNULL(MAX(sort_code),0) as sortCode");
                     WfHeadTeacherLeave w = wfHeadTeacherLeaveService.getOne(queryWrapperSortcode);
-                    wfHeadTeacherLeave.setSortCode(w.getSortCode());
+                    wfHeadTeacherLeave.setSortCode(w.getSortCode()+1);
                     wfHeadTeacherLeaveList.add(wfHeadTeacherLeave);
                 }
             }

+ 21 - 0
src/main/resources/mapper/oa/NewsMapper.xml

@@ -62,4 +62,25 @@
         order by
         t.send_start_date desc,t.release_time desc
     </select>
+
+    <select id="getDeptIdOrClassId" parameterType="java.util.List"
+            resultType="com.xjrsoft.module.oa.vo.DeptIdOrClassIdVo">
+        select
+            t.id as userId,
+            t2.id as deptId,
+            t3.id as classId
+        from xjr_user t
+                 left join xjr_user_dept_relation t1 on t1.user_id = t.id
+                 LEFT JOIN xjr_department t2 ON t2.id = t1.dept_id
+                 left join base_student_school_roll t3 on t3.user_id = t.id
+                 left join base_class t4 on t4.id = t3.class_id
+        where t.delete_mark = 0
+        <if test="personalIdList != null and personalIdList.size() > 0">
+            and t.id in
+            <foreach item="userId" index="index" collection="personalIdList" open="(" close=")"
+                     separator=",">
+                #{userId}
+            </foreach>
+        </if>
+    </select>
 </mapper>

+ 82 - 0
src/main/resources/mapper/oa/NewsRelationMapper.xml

@@ -0,0 +1,82 @@
+<?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.xjrsoft.module.oa.mapper.NewsRelationMapper">
+    <insert id="insertAllTeaStaff" parameterType="java.lang.Long">
+        insert into xjr_oa_news_relation (id, news_id, user_id, create_date, read_mark)
+            (select
+                     UNIX_TIMESTAMP()*(FLOOR(RAND() * (1000 - 1 + 1)) + 1)*(FLOOR(RAND() * (1000 - 1 + 1)) + 1),
+                     #{newsId},
+                     t.id,
+                     NOW(),
+                     0
+             from xjr_user t
+                      left join xjr_user_role_relation t3 on t3.user_id = t.id
+                      LEFT JOIN xjr_role t4 ON t4.id = t3.role_id
+             where t.delete_mark = 0 and t4.id = 2)
+    </insert>
+
+    <insert id="insertDeptUser">
+        insert into xjr_oa_news_relation (id, news_id, user_id, create_date, read_mark)
+        (select
+        UNIX_TIMESTAMP()*(FLOOR(RAND() * (1000 - 1 + 1)) + 1)*(FLOOR(RAND() * (1000 - 1 + 1)) + 1),
+        #{newsId},
+        t.id,
+        NOW(),
+        0
+        from xjr_user t
+        left join xjr_user_dept_relation t1 on t1.user_id = t.id
+        LEFT JOIN xjr_department t2 ON t2.id = t1.dept_id
+        left join xjr_user_role_relation t3 on t3.user_id = t.id
+        LEFT JOIN xjr_role t4 ON t4.id = t3.role_id
+        where t.delete_mark = 0 and t4.id = 2
+        <if test="deptIdList != null and deptIdList.size() > 0">
+            and t2.id in
+            <foreach item="deptId" index="index" collection="deptIdList" open="(" close=")"
+                     separator=",">
+                #{deptId}
+            </foreach>
+        </if>)
+    </insert>
+
+    <insert id="insertClassUser">
+        insert into xjr_oa_news_relation (id, news_id, user_id, create_date, read_mark)
+        (select
+        UNIX_TIMESTAMP()*(FLOOR(RAND() * (1000 - 1 + 1)) + 1)*(FLOOR(RAND() * (1000 - 1 + 1)) + 1),
+        #{newsId},
+        t.id,
+        NOW(),
+        0
+        from xjr_user t
+        left join base_student_school_roll t1 on t1.user_id = t.id
+        LEFT JOIN base_class t2 ON t2.id = t1.class_id
+        where t.delete_mark = 0
+        <if test="classIdList != null and classIdList.size() > 0">
+            and t2.id in
+            <foreach item="classId" index="index" collection="classIdList" open="(" close=")"
+                     separator=",">
+                #{classId}
+            </foreach>
+        </if>)
+    </insert>
+
+    <insert id="insertClassUser">
+        insert into xjr_oa_news_relation (id, news_id, user_id, create_date, read_mark)
+        (select
+        UNIX_TIMESTAMP()*(FLOOR(RAND() * (1000 - 1 + 1)) + 1)*(FLOOR(RAND() * (1000 - 1 + 1)) + 1),
+        #{newsId},
+        t.id,
+        NOW(),
+        0
+        from xjr_user t
+        where t.delete_mark = 0
+        <if test="userIdList != null and userIdList.size() > 0">
+            and t.id in
+            <foreach item="userId" index="index" collection="userIdList" open="(" close=")"
+                     separator=",">
+                #{userId}
+            </foreach>
+        </if>)
+    </insert>
+</mapper>

+ 3 - 2
src/test/java/com/xjrsoft/xjrsoftboot/DateTime.java

@@ -16,11 +16,12 @@ public class DateTime {
     @Test
     public void collectionTest(){
         Long num1 = 23L;
-        Long num2 = 23L;
+        Long num2 = 25L;
         List<Long> list = new ArrayList<>();
         list.add(num1);
         list.add(num2);
         Long num3 = 23L;
-        System.err.println(list.contains(23L));
+        List<Long> classIdList = new ArrayList<>();
+        System.err.println(list.contains(classIdList));
     }
 }