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