Ver código fonte

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

dzx 1 ano atrás
pai
commit
b7e074bb97

+ 1 - 1
Makefile

@@ -2,7 +2,7 @@ merge:
 	git checkout master;git merge dev;git push;git checkout dev;
 
 create-tag:
-	git checkout master;git tag v1.2.9;git push origin --tags;git checkout dev;
+	git checkout master;git tag v1.3.1;git push origin --tags;git checkout dev;
 
 remove-tag:
 	git tag -d v1.2.0;git push origin :refs/tags/v1.1.8;

+ 83 - 20
src/main/java/com/xjrsoft/module/oa/controller/NewsController.java

@@ -23,6 +23,8 @@ import com.xjrsoft.module.oa.service.INewsRelationConfigService;
 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.entity.Department;
+import com.xjrsoft.module.organization.mapper.DepartmentMapper;
 import com.xjrsoft.module.system.entity.File;
 import com.xjrsoft.module.teacher.entity.XjrUser;
 import io.swagger.annotations.Api;
@@ -50,6 +52,8 @@ public class NewsController {
 
     private INewsRelationService newsRelationService;
     private INewsAppendixService newsAppendixService;
+
+    private DepartmentMapper departmentMapper;
     private INewsRelationConfigService newsRelationConfigService;
 
     @GetMapping
@@ -105,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{
@@ -118,6 +123,11 @@ public class NewsController {
         NewsVo newsVo = BeanUtil.toBean(news, NewsVo.class);
         newsVo.setRelationList(newsRelationVoList);
 
+        Department department = departmentMapper.selectById(newsVo.getSendDeptId());
+        if(department != null){
+            newsVo.setSendDeptIdCN(department.getName());
+        }
+
         if (BooleanUtils.isTrue(isRead)) {
 //            NewsRelation newsRelation = new NewsRelation();
 //            newsRelation.setNewsId(id);
@@ -316,50 +326,94 @@ public class NewsController {
             if(typeId == 1){
                 Long notReadCount = newsService.count(Wrappers.<News>query().lambda()
                         .eq(News::getTypeId, typeId)
+                        .eq(News::getStatus, 2)
                         .gt(News::getSendEndDate, LocalDateTime.now())
-                        .eq(News::getDeleteMark, 0)
                         .eq(News::getWfStatus, 1)
-                        .notIn(News::getId, "select distinct news_id from xjr_oa_news_relation where user_id = " + StpUtil.getLoginIdAsLong()));
+                        .notInSql(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);
 
                 news = newsService.getOne(Wrappers.<News>query().lambda()
                         .eq(News::getTypeId, typeId)
+                        .eq(News::getStatus, 2)
                         .gt(News::getSendEndDate, LocalDateTime.now())
-                        .eq(News::getDeleteMark, 0)
                         .eq(News::getWfStatus, 1)
-                        .notIn(News::getId, "select distinct news_id from xjr_oa_news_relation where user_id = " + StpUtil.getLoginIdAsLong())
+                        .notInSql(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)
-                        .eq(News::getDeleteMark, 0)
-                        .notIn(News::getId, "select distinct news_id from xjr_oa_news_relation where read_mark = 1 and user_id = " + StpUtil.getLoginIdAsLong())
+                //公告发给全体的
+                Long notReadCountProclamationToAll = newsService.count(Wrappers.<News>query().lambda()
+                        .eq(News::getTypeId, 2)
+                        .eq(News::getStatus, 2)
+                        .eq(News::getSendRange, 1)
+                        .notInSql(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)
-                        .eq(News::getDeleteMark, 0)
-                        .notIn(News::getId, "select distinct news_id from xjr_oa_news_relation where read_mark = 1 and user_id = " + StpUtil.getLoginIdAsLong())
+                News newsAll = newsService.getOne(Wrappers.<News>query().lambda()
+                        .eq(News::getTypeId, 2)
+                        .eq(News::getStatus, 2)
+                        .eq(News::getSendRange, 1)
+                        .notInSql(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)
+                        .inSql(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) {
                 newsCountTypeVo.setTime(news.getReleaseTime());
-                newsCountTypeVo.setTitle(news.getBriefHead());
+                newsCountTypeVo.setTitle(news.getFullHead());
             }
             newsCountTypeVoList.add(newsCountTypeVo);
         }
@@ -377,19 +431,28 @@ public class NewsController {
     public RT<Long> unreadCount() {
         Long notReadCountNews = newsService.count(Wrappers.<News>query().lambda()
                 .eq(News::getTypeId, 1)
+                .eq(News::getStatus, 2)
                 .gt(News::getSendEndDate, LocalDateTime.now())
-                .eq(News::getDeleteMark, 0)
                 .eq(News::getWfStatus, 1)
-                .notIn(News::getId, "select distinct news_id from xjr_oa_news_relation where user_id = " + StpUtil.getLoginIdAsLong()));
+                .notInSql(News::getId, "select distinct news_id from xjr_oa_news_relation where read_mark = 1 and 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::getDeleteMark, 0)
-                .notIn(News::getId, "select distinct news_id from xjr_oa_news_relation where read_mark = 1 and user_id = " + StpUtil.getLoginIdAsLong())
+                .eq(News::getStatus, 2)
+                .eq(News::getSendRange, 1)
+                .notInSql(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)
+                .inSql(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);
             }
 

+ 5 - 0
src/main/java/com/xjrsoft/module/oa/vo/NewsVo.java

@@ -80,6 +80,11 @@ public class NewsVo {
      */
     @ApiModelProperty("发送部门")
     private Long sendDeptId;
+    /**
+     * 发送部门
+     */
+    @ApiModelProperty("发送部门")
+    private String sendDeptIdCN;
 
     /**
      * 张贴开起时间

+ 2 - 3
src/main/resources/mapper/oa/NewsMapper.xml

@@ -30,12 +30,11 @@
         select
         t.*
         from xjr_oa_news t
-        left join xjr_oa_news_relation t1 on t1.news_id = t.id
         where t.delete_mark = 0 and
         (t.send_end_date > now() or t.send_end_date is null)
           and t.status = 2
-        <if test="dto.type != null and dto.type == 2 and dto.loginId != null and dto.loginId > 0">
-            and (t1.user_id = #{dto.loginId} or t.send_range = 1)
+        <if test="dto.type != null and dto.type == 2 and dto.loginId != null">
+            and (t.send_range = 1 or t.id in (select news_id from xjr_oa_news_relation t1 where user_id = #{dto.loginId}))
         </if>
         <if test="dto.type != null and dto.type == 1">
             and t.wf_status = 1