Kaynağa Gözat

Merge remote-tracking branch 'origin/dev' into dev

dzx 1 yıl önce
ebeveyn
işleme
ec172f8bf3

+ 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);
 }

+ 253 - 197
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());
@@ -145,7 +146,7 @@ public class NewsServiceImpl extends MPJBaseServiceImpl<NewsMapper, News> implem
         News news = BeanUtil.toBean(addProclamationDto, News.class);
         news.setTypeId(2);
         news.setEnabledMark(EnabledMark.ENABLED.getCode());
-        LambdaQueryWrapper<News> queryWrapperSortcode = new LambdaQueryWrapper<>();
+        //LambdaQueryWrapper<News> queryWrapperSortcode = new LambdaQueryWrapper<>();
         //queryWrapperSortcode.select("SELECT IFNULL(MAX(sort_code),1)");
         newsMapper.insert(news);
 
@@ -158,51 +159,14 @@ public class NewsServiceImpl extends MPJBaseServiceImpl<NewsMapper, News> implem
             }
         }
 
+        //如果状态是2,表示立即发布的公告,需要将阅读人添加进阅读关系表
+        if(addProclamationDto.getStatus() == 2){
+            addRelation(news);
+        }
+
         //公告需要添加阅读关系,关系类型 1=部门 2=人员 3=班级
         if (addProclamationDto.getSendRange() == 3 && addProclamationDto.getRelationList() != null) {
-            for (AddNewsRelationDto relationDto : addProclamationDto.getRelationList()) {
-                if (relationDto.getRelationType() == 1) {
-                    Department department = departmentMapper.selectById(relationDto.getRelationId());
-                    newsRelationConfigMapper.insert(new NewsRelationConfig(){{
-                        setNewsId(news.getId());
-                        setRelationId(relationDto.getRelationId());
-                        setRelationType(relationDto.getRelationType());
-                        if(department != null){
-                            setRelationName(department.getName());
-                        }
-                    }});
-                }
-                if (relationDto.getRelationType() == 2)  {
-                    XjrUser xjrUser = xjrUserMapper.selectById(relationDto.getRelationId());
-                    newsRelationConfigMapper.insert(new NewsRelationConfig(){{
-                        setNewsId(news.getId());
-                        setRelationId(relationDto.getRelationId());
-                        setRelationType(relationDto.getRelationType());
-                        if(xjrUser != null){
-                            setRelationName(xjrUser.getName());
-                        }
-                    }});
-                }
-                if (relationDto.getRelationType() == 3)  {
-                    BaseClass baseClass = baseClassMapper.selectById(relationDto.getRelationId());
-                    BaseGrade baseGrade = null;
-                    if(baseClass == null){
-                        baseGrade = baseGradeMapper.selectById(relationDto.getRelationId());
-                    }
-                    BaseGrade finalBaseGrade = baseGrade;
-                    newsRelationConfigMapper.insert(new NewsRelationConfig(){{
-                        setNewsId(news.getId());
-                        setRelationId(relationDto.getRelationId());
-                        setRelationType(relationDto.getRelationType());
-                        if(baseClass != null){
-                            setRelationName(baseClass.getName());
-                        }
-                        if(finalBaseGrade != null){
-                            setRelationName(finalBaseGrade.getName());
-                        }
-                    }});
-                }
-            }
+            addRelationConfig(news, addProclamationDto);
         }
         return true;
     }
@@ -215,20 +179,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 +200,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 +273,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 +296,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 +304,10 @@ 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(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(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() == 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(){{
-                            setNewsId(xjrNews.getId());
-                            setUserId(user.getId());
-                            setReadMark(0);
-                            setCreateDate(LocalDateTime.now());
-                        }});
-                    }
-                }
-            }
+            addRelation(xjrNews);
         }
 
-        if(xjrNews.getStatus() == 3){
+        if (xjrNews.getStatus() == 3) {
             //应该将关系配置表和关系表的数据设置为删除
         }
         return this.updateById(xjrNews);
@@ -453,45 +332,222 @@ public class NewsServiceImpl extends MPJBaseServiceImpl<NewsMapper, News> implem
         if (updateProclamationDto.getSendRange() == 3 && updateProclamationDto.getRelationList() != null) {
             newsRelationMapper.delete(Wrappers.lambdaQuery(NewsRelation.class).eq(NewsRelation::getNewsId, news.getId()));
             newsRelationConfigMapper.delete(Wrappers.lambdaQuery(NewsRelationConfig.class).eq(NewsRelationConfig::getNewsId, news.getId()));
+            updateRelationConfig(news, updateProclamationDto);
+        }
+        return true;
+    }
 
-            for (AddNewsRelationDto relationDto : updateProclamationDto.getRelationList()) {
-                if (relationDto.getRelationType() == 1) {
-                    Department department = departmentMapper.selectById(relationDto.getRelationId());
-
-                    newsRelationConfigMapper.insert(new NewsRelationConfig(){{
-                        setNewsId(news.getId());
-                        setRelationId(relationDto.getRelationId());
-                        setRelationType(relationDto.getRelationType());
-                        if(department != null){
-                            setRelationName(department.getName());
+    /**
+     * 添加阅读关系配置表
+     * @param news
+     * @return
+     */
+    private Boolean updateRelationConfig(News news, UpdateProclamationDto updateProclamationDto){
+        AddProclamationDto addProclamationDto = BeanUtil.toBean(updateProclamationDto, AddProclamationDto.class);
+        return addRelationConfig(news, addProclamationDto);
+    }
+
+    private Boolean addRelationConfig(News news, AddProclamationDto addProclamationDto){
+        for (AddNewsRelationDto relationDto : addProclamationDto.getRelationList()) {
+            if (relationDto.getRelationType() == 1) {
+                Department department = departmentMapper.selectById(relationDto.getRelationId());
+                newsRelationConfigMapper.insert(new NewsRelationConfig() {{
+                    setNewsId(news.getId());
+                    setRelationId(relationDto.getRelationId());
+                    setRelationType(relationDto.getRelationType());
+                    if (department != null) {
+                        setRelationName(department.getName());
+                    }
+                }});
+            }
+            if (relationDto.getRelationType() == 2) {
+                XjrUser xjrUser = xjrUserMapper.selectById(relationDto.getRelationId());
+                newsRelationConfigMapper.insert(new NewsRelationConfig() {{
+                    setNewsId(news.getId());
+                    setRelationId(relationDto.getRelationId());
+                    setRelationType(relationDto.getRelationType());
+                    if (xjrUser != null) {
+                        setRelationName(xjrUser.getName());
+                    }
+                }});
+            }
+            if (relationDto.getRelationType() == 3) {
+                BaseClass baseClass = baseClassMapper.selectById(relationDto.getRelationId());
+                BaseGrade baseGrade = null;
+                if (baseClass == null) {
+                    baseGrade = baseGradeMapper.selectById(relationDto.getRelationId());
+                }
+                BaseGrade finalBaseGrade = baseGrade;
+                newsRelationConfigMapper.insert(new NewsRelationConfig() {{
+                    setNewsId(news.getId());
+                    setRelationId(relationDto.getRelationId());
+                    setRelationType(relationDto.getRelationType());
+                    if (baseClass != null) {
+                        setRelationName(baseClass.getName());
+                    }
+                    if (finalBaseGrade != null) {
+                        setRelationName(finalBaseGrade.getName());
+                    }
+                }});
+            }
+        }
+        return true;
+    }
+
+    /**
+     * 添加阅读关系到关系表
+     * @param xjrNews
+     * @return
+     */
+    private Boolean addRelation(News xjrNews){
+        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 (relationDto.getRelationType() == 2)  {
-                    XjrUser xjrUser = xjrUserMapper.selectById(relationDto.getRelationId());
-
-                    newsRelationConfigMapper.insert(new NewsRelationConfig(){{
-                        setNewsId(news.getId());
-                        setRelationId(relationDto.getRelationId());
-                        setRelationType(relationDto.getRelationType());
-                        if(xjrUser != null){
-                            setRelationName(xjrUser.getName());
+            }
+
+            //添加部门人员
+            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(user.getId());
+                                setReadMark(0);
+                                setCreateDate(LocalDateTime.now());
+                            }});
                         }
-                    }});
+                    }
+                }
+                //阅读关系是人员
+                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(newsRelationConfig.getRelationId());
+                            setReadMark(0);
+                            setCreateDate(LocalDateTime.now());
+                        }});
+                    }
                 }
-                if (relationDto.getRelationType() == 3)  {
-                    BaseClass baseClass = baseClassMapper.selectById(relationDto.getRelationId());
-
-                    newsRelationConfigMapper.insert(new NewsRelationConfig(){{
-                        setNewsId(news.getId());
-                        setRelationId(relationDto.getRelationId());
-                        setRelationType(relationDto.getRelationType());
-                        if(baseClass != null){
-                            setRelationName(baseClass.getName());
+                //阅读关系是班级
+                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());
         }
         return true;
     }
@@ -544,33 +600,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 +635,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 - 12
src/main/java/com/xjrsoft/module/student/controller/ClassHonorsController.java

@@ -2,7 +2,6 @@ package com.xjrsoft.module.student.controller;
 
 import cn.dev33.satoken.annotation.SaCheckPermission;
 import cn.hutool.core.bean.BeanUtil;
-import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.excel.EasyExcel;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.xjrsoft.common.model.result.RT;
@@ -19,14 +18,7 @@ import com.xjrsoft.module.student.vo.ClassHonorsVo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-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.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.validation.Valid;
@@ -53,9 +45,6 @@ public class ClassHonorsController {
     @SaCheckPermission("classhonors:detail")
     public RT<List<ClassHonorsSemesterClassTreeVo>> semesterClassTree(){
         List<ClassHonorsSemesterClassTreeVo> list = classHonorsService.getSemesterClassTree();
-        if(ObjectUtil.isNull(list) || list.size() == 0){
-            return RT.error("找不到此数据!");
-        }
         return RT.ok(list);
     }
 

+ 1 - 2
src/main/java/com/xjrsoft/module/student/dto/AddClassHonorsDto.java

@@ -4,7 +4,6 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 import java.io.Serializable;
-import java.util.Date;
 
 
 
@@ -53,7 +52,7 @@ public class AddClassHonorsDto implements Serializable {
     * 获奖日期
     */
     @ApiModelProperty("获奖日期")
-    private Date awardDate;
+    private String awardDate;
     /**
     * 附件文件id
     */

+ 2 - 0
src/main/java/com/xjrsoft/module/student/vo/ClassHonorsPageVo.java

@@ -2,6 +2,7 @@ package com.xjrsoft.module.student.vo;
 
 import com.alibaba.excel.annotation.ExcelProperty;
 import com.alibaba.excel.annotation.write.style.ContentStyle;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
@@ -57,5 +58,6 @@ public class ClassHonorsPageVo {
     @ContentStyle(dataFormat = 49)
     @ExcelProperty("获奖日期")
     @ApiModelProperty("获奖日期")
+    @JsonFormat(pattern = "yyyy-MM-dd")
     private Date awardDate;
 }

+ 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);
                 }
             }

+ 0 - 3
src/main/resources/application-dev.yml

@@ -13,9 +13,6 @@ spring:
           username: root
           password: Zwr~-f6H,u6QE^]C-AD_
 
-
-
-
   redis:
     database: 11
     host: 10.150.10.139

+ 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="insertPersonl">
+        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>

+ 52 - 0
src/main/resources/sqlScript/20240109_sql.sql

@@ -0,0 +1,52 @@
+
+
+ALTER TABLE xjr_oa_news ADD COLUMN `wf_status` int not null default 0 COMMENT '状态(1:结束 0:未结束)' AFTER send_range;
+
+-- ------------------------------------------------------------------评价--------------------------------------------------------------------
+
+-- ----------------------------
+-- 评价模版
+-- ----------------------------
+DROP TABLE IF EXISTS evaluate_template;
+CREATE TABLE evaluate_template
+(
+    id BIGINT NOT NULL COMMENT '主键编号',
+    `create_user_id` BIGINT NULL DEFAULT NULL COMMENT '创建人',
+    `create_date` datetime NULL DEFAULT NULL COMMENT '创建时间',
+    `modify_user_id` BIGINT NULL DEFAULT NULL COMMENT '修改人',
+    `modify_date` datetime NULL DEFAULT NULL COMMENT '修改时间',
+    `delete_mark` INT NOT NULL COMMENT '删除标记',
+    `enabled_mark` INT NOT NULL COMMENT '有效标志',
+    `sort_code` INT NULL DEFAULT NULL COMMENT '序号',
+    `name`  varchar(200) NULL DEFAULT NULL COMMENT '模板名称',
+    `evaluate_type` VARCHAR(30) NULL DEFAULT NULL COMMENT '评价类型(xjr_dictionary_item[evaluate_type])',
+    `total` float NULL DEFAULT NULL COMMENT '评价总分',
+    `dept_ids` json NULL DEFAULT NULL COMMENT '使用部门ids',
+    `remark` varchar(1000)NULL DEFAULT NULL  COMMENT '备注',
+    `status` int not null default 0 COMMENT '状态(0:禁用 1:启用)',
+    PRIMARY KEY (`id`)
+) ENGINE=INNODB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT '评价模版';
+
+-- ------------------------------------------------------------------评价--------------------------------------------------------------------
+
+DROP TABLE IF EXISTS `wf_head_teacher_leave`;
+CREATE TABLE `wf_head_teacher_leave` (
+     `id` bigint NOT NULL COMMENT '主键编号',
+     `create_user_id` bigint DEFAULT NULL COMMENT '创建人',
+     `create_date` datetime DEFAULT NULL COMMENT '创建时间',
+     `modify_user_id` bigint DEFAULT NULL COMMENT '修改人',
+     `modify_date` datetime DEFAULT NULL COMMENT '修改时间',
+     `delete_mark` int NOT NULL COMMENT '删除标记',
+     `enabled_mark` int NOT NULL COMMENT '有效标志',
+     `sort_code` int DEFAULT NULL COMMENT '序号',
+     `wf_teacherleave_id` bigint DEFAULT NULL COMMENT '教职工请假编号',
+     `applicant_user_id` bigint DEFAULT NULL COMMENT '申请人',
+     `leave_reason` varchar(20) DEFAULT NULL COMMENT '请假原因(xjr_dictionary_item[leave_reason])',
+     `start_time` date DEFAULT NULL COMMENT '请假日期',
+     `time_period` int DEFAULT NULL COMMENT '请假时间段 1=上午 2=下午',
+     `is_substitute` int NOT NULL DEFAULT '0' COMMENT '是否有替班教师(1:是 0:否)',
+     `substitute_user_id` bigint DEFAULT NULL COMMENT '替换教师',
+     `remark` varchar(1000) DEFAULT NULL COMMENT '备注',
+     `status` int NOT NULL DEFAULT '0' COMMENT '状态(1:结束 0:未结束)',
+     PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='班主任事项请假';

+ 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));
     }
 }