Procházet zdrojové kódy

改变公告状态的时候判断的语句更正

phoenix před 1 rokem
rodič
revize
96aa5bf7f0

+ 64 - 10
src/main/java/com/xjrsoft/module/oa/controller/NewsController.java

@@ -109,6 +109,7 @@ public class NewsController {
                 .leftJoin(XjrUser.class,XjrUser::getId,NewsRelation::getUserId)
                 .eq(NewsRelation::getNewsId , id)
                 .disableSubLogicDel();
+
         if(ObjectUtil.isNotNull(news.getCreateUserId()) && StpUtil.getLoginIdAsLong() == news.getCreateUserId()){
             newsRelationVoList = newsRelationService.selectJoinList(NewsRelationVo.class, queryWrapper);
         }else{
@@ -328,7 +329,7 @@ public class NewsController {
                         .eq(News::getStatus, 2)
                         .gt(News::getSendEndDate, LocalDateTime.now())
                         .eq(News::getWfStatus, 1)
-                        .notIn(News::getId, "select distinct news_id from xjr_oa_news_relation where user_id = " + StpUtil.getLoginIdAsLong()));
+                        .notIn(News::getId, "select distinct news_id from xjr_oa_news_relation where read_mark = 1 and user_id = " + StpUtil.getLoginIdAsLong()));
 
                 newsCountTypeVo.setTypeId(typeId);
                 newsCountTypeVo.setTotal(notReadCount);
@@ -338,32 +339,76 @@ public class NewsController {
                         .eq(News::getStatus, 2)
                         .gt(News::getSendEndDate, LocalDateTime.now())
                         .eq(News::getWfStatus, 1)
-                        .notIn(News::getId, "select distinct news_id from xjr_oa_news_relation where user_id = " + StpUtil.getLoginIdAsLong())
+                        .notIn(News::getId, "select distinct news_id from xjr_oa_news_relation where read_mark = 1 and user_id = " + StpUtil.getLoginIdAsLong())
                         .orderByDesc(News::getReleaseTime)
                         .last("limit 1"));
             }
 
             //公告
             if(typeId == 2){
-                Long notReadCount = newsService.count(Wrappers.<News>query().lambda()
-                        .eq(News::getTypeId, typeId)
+                //公告发给全体的
+                Long notReadCountProclamationToAll = newsService.count(Wrappers.<News>query().lambda()
+                        .eq(News::getTypeId, 2)
                         .eq(News::getStatus, 2)
+                        .eq(News::getSendRange, 1)
                         .notIn(News::getId, "select distinct news_id from xjr_oa_news_relation where read_mark = 1 and user_id = " + StpUtil.getLoginIdAsLong())
                         .and(wp -> wp.gt(News::getSendEndDate, LocalDateTime.now())
                                 .or()
                                 .isNull(News::getSendEndDate)));
 
-                news = newsService.getOne(Wrappers.<News>query().lambda()
-                        .eq(News::getTypeId, typeId)
+                News newsAll = newsService.getOne(Wrappers.<News>query().lambda()
+                        .eq(News::getTypeId, 2)
                         .eq(News::getStatus, 2)
+                        .eq(News::getSendRange, 1)
                         .notIn(News::getId, "select distinct news_id from xjr_oa_news_relation where read_mark = 1 and user_id = " + StpUtil.getLoginIdAsLong())
                         .and(wp -> wp.gt(News::getSendEndDate, LocalDateTime.now())
                                 .or()
                                 .isNull(News::getSendEndDate))
                         .orderByDesc(News::getReleaseTime)
                         .last("limit 1"));
+
+                //公告发给非全体的
+                Long notReadCountProclamation = newsRelationService.count(Wrappers.<NewsRelation>query().lambda()
+                        .eq(NewsRelation::getReadMark, 2)
+                        .eq(NewsRelation::getUserId, 2)
+                        .in(NewsRelation::getNewsId, "select id from xjr_oa_news where delete_mark = 0 and type_id = 2 and (send_range = 2 or send_range = 3) AND (send_end_date > '" + LocalDateTime.now() + "' OR send_end_date IS NULL)"));
+
+
+                MPJLambdaWrapper<News> queryNews = new MPJLambdaWrapper<>();
+                queryNews
+                        .leftJoin(NewsRelation.class, NewsRelation::getNewsId, News::getId)
+                        .eq(News::getTypeId, typeId)
+                        .eq(News::getStatus, 2)
+                        .and(wp -> wp.eq(News::getSendRange, 2)
+                                .or()
+                                .eq(News::getSendRange, 3))
+                        .and(wp -> wp.gt(News::getSendEndDate, LocalDateTime.now())
+                                .or()
+                                .isNull(News::getSendEndDate))
+                        .eq(NewsRelation::getReadMark, 0)
+                        .eq(NewsRelation::getUserId, StpUtil.getLoginIdAsLong())
+                        .orderByDesc(News::getReleaseTime)
+                        .last("limit 1");
+
+
+                News newsNotAll = newsService.selectJoinOne(News.class, queryNews);
+                if(newsAll != null && newsNotAll != null){
+                    if(newsAll.getReleaseTime().compareTo(newsNotAll.getReleaseTime()) < 0){
+                        news = newsNotAll;
+                    }else {
+                        news = newsAll;
+                    }
+                }
+                if(newsAll != null && newsNotAll == null){
+                    news = newsAll;
+                }
+
+                if(newsAll == null && newsNotAll != null){
+                    news = newsNotAll;
+                }
+
                 newsCountTypeVo.setTypeId(typeId);
-                newsCountTypeVo.setTotal(notReadCount);
+                newsCountTypeVo.setTotal(notReadCountProclamationToAll + notReadCountProclamation);
             }
 
             if (news != null) {
@@ -389,16 +434,25 @@ public class NewsController {
                 .eq(News::getStatus, 2)
                 .gt(News::getSendEndDate, LocalDateTime.now())
                 .eq(News::getWfStatus, 1)
-                .notIn(News::getId, "select distinct news_id from xjr_oa_news_relation where user_id = " + StpUtil.getLoginIdAsLong()));
+                .notIn(News::getId, "select distinct news_id from xjr_oa_news_relation where read_mark = 1 user_id = " + StpUtil.getLoginIdAsLong()));
 
-        Long notReadCountProclamation = newsService.count(Wrappers.<News>query().lambda()
+        //公告发给全体的
+        Long notReadCountProclamationToAll = newsService.count(Wrappers.<News>query().lambda()
                 .eq(News::getTypeId, 2)
                 .eq(News::getStatus, 2)
+                .eq(News::getSendRange, 1)
                 .notIn(News::getId, "select distinct news_id from xjr_oa_news_relation where read_mark = 1 and user_id = " + StpUtil.getLoginIdAsLong())
                 .and(wp -> wp.gt(News::getSendEndDate, LocalDateTime.now())
                         .or()
                         .isNull(News::getSendEndDate)));
-        Long notReadCount = notReadCountNews + notReadCountProclamation;
+
+        //公告发给非全体的
+        Long notReadCountProclamation = newsRelationService.count(Wrappers.<NewsRelation>query().lambda()
+                .eq(NewsRelation::getReadMark, 2)
+                .eq(NewsRelation::getUserId, 2)
+                .in(NewsRelation::getNewsId, "select id from xjr_oa_news where delete_mark = 0 and type_id = 2 and status = 2 and (send_range = 2 or send_range = 3) AND (send_end_date > '" + LocalDateTime.now() + "' OR send_end_date IS NULL)"));
+
+        Long notReadCount = notReadCountNews + notReadCountProclamationToAll + notReadCountProclamation;
         return RT.ok(notReadCount);
     }
 }

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

@@ -473,17 +473,17 @@ public class NewsServiceImpl extends MPJBaseServiceImpl<NewsMapper, News> implem
                 }
             }
             //添加部门人员
-            if (deptIdList != null) {
+            if (deptIdList.size() > 0) {
                 newsRelationMapper.insertDeptUser(xjrNews.getId(), deptIdList);
             }
 
             //添加部门人员
-            if (classIdList != null) {
+            if (classIdList.size() > 0) {
                 newsRelationMapper.insertClassUser(xjrNews.getId(), classIdList);
             }
 
             //添加部门人员
-            if (userIdList != null) {
+            if (userIdList.size() > 0) {
                 newsRelationMapper.insertPersonl(xjrNews.getId(), userIdList);
             }