diff --git a/src/main/java/neatlogic/module/tenant/api/systemnotice/SystemNoticeDeleteApi.java b/src/main/java/neatlogic/module/tenant/api/systemnotice/SystemNoticeDeleteApi.java
index 261e09503c8585996e1d006ee10e2b925e212949..312444aee2d7a4514f73fd1831e6a0606a943e5c 100644
--- a/src/main/java/neatlogic/module/tenant/api/systemnotice/SystemNoticeDeleteApi.java
+++ b/src/main/java/neatlogic/module/tenant/api/systemnotice/SystemNoticeDeleteApi.java
@@ -15,16 +15,23 @@ along with this program. If not, see .*/
package neatlogic.module.tenant.api.systemnotice;
+import com.alibaba.fastjson.JSONObject;
+import neatlogic.framework.asynchronization.threadlocal.TenantContext;
import neatlogic.framework.auth.core.AuthAction;
+import neatlogic.framework.auth.label.SYSTEM_NOTICE_MODIFY;
import neatlogic.framework.common.constvalue.ApiParamType;
import neatlogic.framework.restful.annotation.*;
import neatlogic.framework.restful.constvalue.OperationTypeEnum;
import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase;
+import neatlogic.framework.scheduler.core.IJob;
+import neatlogic.framework.scheduler.core.SchedulerManager;
+import neatlogic.framework.scheduler.dto.JobObject;
+import neatlogic.framework.scheduler.exception.ScheduleHandlerNotFoundException;
import neatlogic.framework.systemnotice.dao.mapper.SystemNoticeMapper;
import neatlogic.framework.systemnotice.dto.SystemNoticeVo;
import neatlogic.framework.systemnotice.exception.SystemNoticeNotFoundException;
-import neatlogic.framework.auth.label.SYSTEM_NOTICE_MODIFY;
-import com.alibaba.fastjson.JSONObject;
+import neatlogic.module.framework.systemnotice.schedule.IssueSystemNoticeJob;
+import neatlogic.module.framework.systemnotice.schedule.StopSystemNoticeJob;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -39,6 +46,9 @@ public class SystemNoticeDeleteApi extends PrivateApiComponentBase {
@Resource
private SystemNoticeMapper systemNoticeMapper;
+ @Resource
+ private SchedulerManager schedulerManager;
+
@Override
public String getToken() {
return "systemnotice/delete";
@@ -72,6 +82,27 @@ public class SystemNoticeDeleteApi extends PrivateApiComponentBase {
**/
systemNoticeMapper.deleteRecipientByNoticeId(vo.getId());
systemNoticeMapper.deleteSystemNoticeById(vo.getId());
+ systemNoticeMapper.deleteSystemNoticeUserByNoticeId(vo.getId());
+ {
+ IJob jobHandler = SchedulerManager.getHandler(IssueSystemNoticeJob.class.getName());
+ if (jobHandler == null) {
+ throw new ScheduleHandlerNotFoundException(IssueSystemNoticeJob.class.getName());
+ }
+ String tenantUuid = TenantContext.get().getTenantUuid();
+ JobObject jobObject = new JobObject.Builder(vo.getId().toString(), jobHandler.getGroupName(), jobHandler.getClassName(), tenantUuid)
+ .build();
+ schedulerManager.unloadJob(jobObject);
+ }
+ {
+ IJob jobHandler = SchedulerManager.getHandler(StopSystemNoticeJob.class.getName());
+ if (jobHandler == null) {
+ throw new ScheduleHandlerNotFoundException(StopSystemNoticeJob.class.getName());
+ }
+ String tenantUuid = TenantContext.get().getTenantUuid();
+ JobObject jobObject = new JobObject.Builder(vo.getId().toString(), jobHandler.getGroupName(), jobHandler.getClassName(), tenantUuid)
+ .build();
+ schedulerManager.unloadJob(jobObject);
+ }
return null;
}
}
diff --git a/src/main/java/neatlogic/module/tenant/api/systemnotice/SystemNoticeIssueApi.java b/src/main/java/neatlogic/module/tenant/api/systemnotice/SystemNoticeIssueApi.java
index b39352c041bdd7973ee3f56b6b23f0d8bf9f0886..a1a39942e3aec806728569ce4e464e6c7df84577 100644
--- a/src/main/java/neatlogic/module/tenant/api/systemnotice/SystemNoticeIssueApi.java
+++ b/src/main/java/neatlogic/module/tenant/api/systemnotice/SystemNoticeIssueApi.java
@@ -15,41 +15,33 @@ along with this program. If not, see .*/
package neatlogic.module.tenant.api.systemnotice;
-import neatlogic.framework.asynchronization.thread.NeatLogicThread;
-import neatlogic.framework.asynchronization.threadpool.CachedThreadPool;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.TypeReference;
+import neatlogic.framework.asynchronization.threadlocal.TenantContext;
import neatlogic.framework.auth.core.AuthAction;
-import neatlogic.framework.common.config.Config;
+import neatlogic.framework.auth.label.SYSTEM_NOTICE_MODIFY;
import neatlogic.framework.common.constvalue.ApiParamType;
-import neatlogic.framework.common.constvalue.GroupSearch;
-import neatlogic.framework.common.constvalue.UserType;
-import neatlogic.framework.common.dto.BasePageVo;
-import neatlogic.framework.common.util.PageUtil;
-import neatlogic.framework.dao.mapper.UserMapper;
-import neatlogic.framework.dao.mapper.UserSessionMapper;
+import neatlogic.framework.crossover.CrossoverServiceFactory;
import neatlogic.framework.restful.annotation.*;
import neatlogic.framework.restful.constvalue.OperationTypeEnum;
import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase;
+import neatlogic.framework.scheduler.core.IJob;
+import neatlogic.framework.scheduler.core.SchedulerManager;
+import neatlogic.framework.scheduler.dto.JobObject;
+import neatlogic.framework.scheduler.exception.ScheduleHandlerNotFoundException;
import neatlogic.framework.systemnotice.dao.mapper.SystemNoticeMapper;
-import neatlogic.framework.systemnotice.dto.SystemNoticeRecipientVo;
-import neatlogic.framework.systemnotice.dto.SystemNoticeUserVo;
import neatlogic.framework.systemnotice.dto.SystemNoticeVo;
import neatlogic.framework.systemnotice.exception.SystemNoticeExpiredTimeLessThanActiveTimeException;
import neatlogic.framework.systemnotice.exception.SystemNoticeHasBeenIssuedException;
import neatlogic.framework.systemnotice.exception.SystemNoticeNotFoundException;
-import neatlogic.framework.auth.label.SYSTEM_NOTICE_MODIFY;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
-import com.alibaba.fastjson.TypeReference;
-import org.apache.commons.collections4.CollectionUtils;
+import neatlogic.framework.systemnotice.service.ISystemNoticeCrossoverService;
+import neatlogic.module.framework.systemnotice.schedule.IssueSystemNoticeJob;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
-import java.util.ArrayList;
import java.util.Date;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-import java.util.stream.Collectors;
@AuthAction(action = SYSTEM_NOTICE_MODIFY.class)
@Service
@@ -57,16 +49,13 @@ import java.util.stream.Collectors;
@Transactional
public class SystemNoticeIssueApi extends PrivateApiComponentBase {
- private final static Integer PAGE_SIZE = 100;
+// private final static Integer PAGE_SIZE = 100;
@Resource
private SystemNoticeMapper systemNoticeMapper;
@Resource
- private UserMapper userMapper;
-
- @Resource
- private UserSessionMapper userSessionMapper;
+ private SchedulerManager schedulerManager;
@Override
public String getToken() {
@@ -122,78 +111,91 @@ public class SystemNoticeIssueApi extends PrivateApiComponentBase {
vo.setStatus(SystemNoticeVo.Status.ISSUED.getValue());
vo.setIssueTime(vo.getStartTime() == null ? new Date() : vo.getStartTime());
- /* 如果没有忽略已读,则把system_notice_user中的is_read设为0 **/
- if (vo.getIgnoreRead() != null && vo.getIgnoreRead() == 0) {
- /* 经测试,该语句update 53万条数据耗时约1.2s,故不单独开线程执行 **/
- systemNoticeMapper.updateReadStatusToNotReadByNoticeId(vo.getId());
- }
-
- List recipientList = systemNoticeMapper.getRecipientListByNoticeId(vo.getId());
- if (CollectionUtils.isNotEmpty(recipientList)) {
- long expireTime = currentTimeMillis - TimeUnit.MINUTES.toMillis(Config.USER_EXPIRETIME());
- if (recipientList.stream().anyMatch(o -> UserType.ALL.getValue().equals(o.getUuid()))) {
- /* 如果通知范围是所有人,那么找出当前所有的在线用户 **/
- int allOnlineUserCount = userSessionMapper.getAllOnlineUserCount(new Date(expireTime));
- if (allOnlineUserCount > 0) {
- CachedThreadPool.execute(new NeatLogicThread("NOTICE-INSERTER") {
- @Override
- protected void execute() {
- Date expireDate = new Date(expireTime);
- BasePageVo pageVo = new BasePageVo();
- pageVo.setPageSize(PAGE_SIZE);
- pageVo.setPageCount(PageUtil.getPageCount(allOnlineUserCount, pageVo.getPageSize()));
- List noticeUserVoList = new ArrayList<>();
- for (int i = 1; i <= pageVo.getPageCount(); i++) {
- pageVo.setCurrentPage(i);
- List allOnlineUser = userSessionMapper.getAllOnlineUser(expireDate, pageVo.getStartNum(), pageVo.getPageSize());
- if (CollectionUtils.isNotEmpty(allOnlineUser)) {
- allOnlineUser.forEach(o -> noticeUserVoList.add(new SystemNoticeUserVo(vo.getId(), o)));
- systemNoticeMapper.batchInsertSystemNoticeUser(noticeUserVoList);
- noticeUserVoList.clear();
- }
- }
- }
- });
- }
- } else {
- List userUuidList = recipientList.stream()
- .filter(o -> GroupSearch.USER.getValue().equals(o.getType()))
- .map(SystemNoticeRecipientVo::getUuid)
- .collect(Collectors.toList());
- List teamUuidList = recipientList.stream()
- .filter(o -> GroupSearch.TEAM.getValue().equals(o.getType()))
- .map(SystemNoticeRecipientVo::getUuid)
- .collect(Collectors.toList());
- List roleUuidList = recipientList.stream()
- .filter(o -> GroupSearch.ROLE.getValue().equals(o.getType()))
- .map(SystemNoticeRecipientVo::getUuid)
- .collect(Collectors.toList());
- int onlineUserCount = userSessionMapper.getOnlineUserUuidListByUserUuidListAndTeamUuidListAndRoleUuidListAndGreaterThanSessionTimeCount
- (userUuidList, teamUuidList, roleUuidList, new Date(expireTime));
- if (onlineUserCount > 0) {
- CachedThreadPool.execute(new NeatLogicThread("NOTICE-INSERTER") {
- @Override
- protected void execute() {
- Date expireDate = new Date(expireTime);
- int count = onlineUserCount / PAGE_SIZE + 1;
- List noticeUserVoList = new ArrayList<>();
- for (int i = 0; i < count; i++) {
- List onlineUserList = userSessionMapper.getOnlineUserUuidListByUserUuidListAndTeamUuidListAndRoleUuidListAndGreaterThanSessionTime
- (userUuidList, teamUuidList, roleUuidList, expireDate, true, i, PAGE_SIZE);
- if (CollectionUtils.isNotEmpty(onlineUserList)) {
- onlineUserList.forEach(o -> noticeUserVoList.add(new SystemNoticeUserVo(vo.getId(), o)));
- systemNoticeMapper.batchInsertSystemNoticeUser(noticeUserVoList);
- noticeUserVoList.clear();
- }
- }
- }
- });
- }
- }
+// /* 如果没有忽略已读,则把system_notice_user中的is_read设为0 **/
+// if (vo.getIgnoreRead() != null && vo.getIgnoreRead() == 0) {
+// /* 经测试,该语句update 53万条数据耗时约1.2s,故不单独开线程执行 **/
+// systemNoticeMapper.updateReadStatusToNotReadByNoticeId(vo.getId());
+// }
+//
+// List recipientList = systemNoticeMapper.getRecipientListByNoticeId(vo.getId());
+// if (CollectionUtils.isNotEmpty(recipientList)) {
+// long expireTime = currentTimeMillis - TimeUnit.MINUTES.toMillis(Config.USER_EXPIRETIME());
+// if (recipientList.stream().anyMatch(o -> UserType.ALL.getValue().equals(o.getUuid()))) {
+// /* 如果通知范围是所有人,那么找出当前所有的在线用户 **/
+// int allOnlineUserCount = userSessionMapper.getAllOnlineUserCount(new Date(expireTime));
+// if (allOnlineUserCount > 0) {
+// CachedThreadPool.execute(new NeatLogicThread("NOTICE-INSERTER") {
+// @Override
+// protected void execute() {
+// Date expireDate = new Date(expireTime);
+// BasePageVo pageVo = new BasePageVo();
+// pageVo.setPageSize(PAGE_SIZE);
+// pageVo.setPageCount(PageUtil.getPageCount(allOnlineUserCount, pageVo.getPageSize()));
+// List noticeUserVoList = new ArrayList<>();
+// for (int i = 1; i <= pageVo.getPageCount(); i++) {
+// pageVo.setCurrentPage(i);
+// List allOnlineUser = userSessionMapper.getAllOnlineUser(expireDate, pageVo.getStartNum(), pageVo.getPageSize());
+// if (CollectionUtils.isNotEmpty(allOnlineUser)) {
+// allOnlineUser.forEach(o -> noticeUserVoList.add(new SystemNoticeUserVo(vo.getId(), o)));
+// systemNoticeMapper.batchInsertSystemNoticeUser(noticeUserVoList);
+// noticeUserVoList.clear();
+// }
+// }
+// }
+// });
+// }
+// } else {
+// List userUuidList = recipientList.stream()
+// .filter(o -> GroupSearch.USER.getValue().equals(o.getType()))
+// .map(SystemNoticeRecipientVo::getUuid)
+// .collect(Collectors.toList());
+// List teamUuidList = recipientList.stream()
+// .filter(o -> GroupSearch.TEAM.getValue().equals(o.getType()))
+// .map(SystemNoticeRecipientVo::getUuid)
+// .collect(Collectors.toList());
+// List roleUuidList = recipientList.stream()
+// .filter(o -> GroupSearch.ROLE.getValue().equals(o.getType()))
+// .map(SystemNoticeRecipientVo::getUuid)
+// .collect(Collectors.toList());
+// int onlineUserCount = userSessionMapper.getOnlineUserUuidListByUserUuidListAndTeamUuidListAndRoleUuidListAndGreaterThanSessionTimeCount
+// (userUuidList, teamUuidList, roleUuidList, new Date(expireTime));
+// if (onlineUserCount > 0) {
+// CachedThreadPool.execute(new NeatLogicThread("NOTICE-INSERTER") {
+// @Override
+// protected void execute() {
+// Date expireDate = new Date(expireTime);
+// int count = onlineUserCount / PAGE_SIZE + 1;
+// List noticeUserVoList = new ArrayList<>();
+// for (int i = 0; i < count; i++) {
+// List onlineUserList = userSessionMapper.getOnlineUserUuidListByUserUuidListAndTeamUuidListAndRoleUuidListAndGreaterThanSessionTime
+// (userUuidList, teamUuidList, roleUuidList, expireDate, true, i, PAGE_SIZE);
+// if (CollectionUtils.isNotEmpty(onlineUserList)) {
+// onlineUserList.forEach(o -> noticeUserVoList.add(new SystemNoticeUserVo(vo.getId(), o)));
+// systemNoticeMapper.batchInsertSystemNoticeUser(noticeUserVoList);
+// noticeUserVoList.clear();
+// }
+// }
+// }
+// });
+// }
+// }
+// }
+ ISystemNoticeCrossoverService systemNoticeCrossoverService = CrossoverServiceFactory.getApi(ISystemNoticeCrossoverService.class);
+ systemNoticeCrossoverService.issueSystemNotice(vo);
+ } else {
+ IJob jobHandler = SchedulerManager.getHandler(IssueSystemNoticeJob.class.getName());
+ if (jobHandler == null) {
+ throw new ScheduleHandlerNotFoundException(IssueSystemNoticeJob.class.getName());
}
+ String tenantUuid = TenantContext.get().getTenantUuid();
+ JobObject jobObject = new JobObject.Builder(vo.getId().toString(), jobHandler.getGroupName(), jobHandler.getClassName(), tenantUuid)
+ .withBeginTime(vo.getStartTime())
+ .withIntervalInSeconds(60 * 60)
+ .withRepeatCount(0)
+ .build();
+ schedulerManager.loadJob(jobObject);
}
systemNoticeMapper.updateSystemNoticeIssueInfo(vo);
-
return null;
}
}
diff --git a/src/main/java/neatlogic/module/tenant/api/systemnotice/SystemNoticePullApi.java b/src/main/java/neatlogic/module/tenant/api/systemnotice/SystemNoticePullApi.java
index 71cecffd63d161d41145ab873c725ebe28a4edd2..419f4629600eba259630776ec4272a62862772a3 100644
--- a/src/main/java/neatlogic/module/tenant/api/systemnotice/SystemNoticePullApi.java
+++ b/src/main/java/neatlogic/module/tenant/api/systemnotice/SystemNoticePullApi.java
@@ -15,6 +15,9 @@ along with this program. If not, see .*/
package neatlogic.module.tenant.api.systemnotice;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.TypeReference;
import neatlogic.framework.asynchronization.threadlocal.UserContext;
import neatlogic.framework.common.constvalue.ApiParamType;
import neatlogic.framework.common.constvalue.UserType;
@@ -27,10 +30,6 @@ import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase;
import neatlogic.framework.systemnotice.dao.mapper.SystemNoticeMapper;
import neatlogic.framework.systemnotice.dto.SystemNoticeVo;
import neatlogic.framework.util.HtmlUtil;
-import neatlogic.module.tenant.service.systemnotice.SystemNoticeService;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
-import com.alibaba.fastjson.TypeReference;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
@@ -44,9 +43,6 @@ import java.util.stream.Collectors;
@OperationType(type = OperationTypeEnum.OPERATE)
public class SystemNoticePullApi extends PrivateApiComponentBase {
- @Resource
- private SystemNoticeService systemNoticeService;
-
@Resource
private SystemNoticeMapper systemNoticeMapper;
@@ -90,10 +86,10 @@ public class SystemNoticePullApi extends PrivateApiComponentBase {
uuidList.addAll(authenticationInfoVo.getTeamUuidList());
uuidList.addAll(authenticationInfoVo.getRoleUuidList());
- systemNoticeService.clearSystemNoticeUser();
- systemNoticeService.stopExpiredSystemNotice();
- systemNoticeService.pullIssuedSystemNotice();
- systemNoticeService.pullActiveSystemNotice();
+// systemNoticeService.clearSystemNoticeUser();
+// systemNoticeService.stopExpiredSystemNotice();
+// systemNoticeService.pullIssuedSystemNotice();
+// systemNoticeService.pullActiveSystemNotice();
vo.setRecipientList(uuidList);
vo.setIsRead(0);
diff --git a/src/main/java/neatlogic/module/tenant/api/systemnotice/SystemNoticeStopApi.java b/src/main/java/neatlogic/module/tenant/api/systemnotice/SystemNoticeStopApi.java
index a180ed015860da28bfe0351d6f834c2f0b2b416a..81b9f3e10b91953f5184877b69749bfa84831483 100644
--- a/src/main/java/neatlogic/module/tenant/api/systemnotice/SystemNoticeStopApi.java
+++ b/src/main/java/neatlogic/module/tenant/api/systemnotice/SystemNoticeStopApi.java
@@ -15,17 +15,23 @@ along with this program. If not, see .*/
package neatlogic.module.tenant.api.systemnotice;
+import com.alibaba.fastjson.JSONObject;
+import neatlogic.framework.asynchronization.threadlocal.TenantContext;
import neatlogic.framework.asynchronization.threadlocal.UserContext;
import neatlogic.framework.auth.core.AuthAction;
+import neatlogic.framework.auth.label.SYSTEM_NOTICE_MODIFY;
import neatlogic.framework.common.constvalue.ApiParamType;
import neatlogic.framework.restful.annotation.*;
import neatlogic.framework.restful.constvalue.OperationTypeEnum;
import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase;
+import neatlogic.framework.scheduler.core.IJob;
+import neatlogic.framework.scheduler.core.SchedulerManager;
+import neatlogic.framework.scheduler.dto.JobObject;
+import neatlogic.framework.scheduler.exception.ScheduleHandlerNotFoundException;
import neatlogic.framework.systemnotice.dao.mapper.SystemNoticeMapper;
import neatlogic.framework.systemnotice.dto.SystemNoticeVo;
import neatlogic.framework.systemnotice.exception.SystemNoticeNotFoundException;
-import neatlogic.framework.auth.label.SYSTEM_NOTICE_MODIFY;
-import com.alibaba.fastjson.JSONObject;
+import neatlogic.module.framework.systemnotice.schedule.StopSystemNoticeJob;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@@ -38,6 +44,9 @@ public class SystemNoticeStopApi extends PrivateApiComponentBase {
@Resource
private SystemNoticeMapper systemNoticeMapper;
+ @Resource
+ private SchedulerManager schedulerManager;
+
@Override
public String getToken() {
return "systemnotice/stop";
@@ -58,13 +67,24 @@ public class SystemNoticeStopApi extends PrivateApiComponentBase {
@Description(desc = "停用系统公告")
@Override
public Object myDoService(JSONObject jsonObj) throws Exception {
- SystemNoticeVo vo = systemNoticeMapper.getSystemNoticeBaseInfoById(jsonObj.getLong("id"));
+ Long id = jsonObj.getLong("id");
+ SystemNoticeVo vo = systemNoticeMapper.getSystemNoticeBaseInfoById(id);
if(vo == null){
- throw new SystemNoticeNotFoundException(vo.getId());
+ throw new SystemNoticeNotFoundException(id);
}
vo.setLcu(UserContext.get().getUserUuid());
/** 停用后清除下发时段,下次下发时再指定 **/
systemNoticeMapper.stopSystemNoticeById(vo);
+
+ IJob jobHandler = SchedulerManager.getHandler(StopSystemNoticeJob.class.getName());
+ if (jobHandler == null) {
+ throw new ScheduleHandlerNotFoundException(StopSystemNoticeJob.class.getName());
+ }
+ String tenantUuid = TenantContext.get().getTenantUuid();
+ JobObject jobObject = new JobObject.Builder(vo.getId().toString(), jobHandler.getGroupName(), jobHandler.getClassName(), tenantUuid)
+ .build();
+ schedulerManager.unloadJob(jobObject);
+
return null;
}
}
diff --git a/src/main/java/neatlogic/module/tenant/service/systemnotice/LoginPullSystemNoticeProcessor.java b/src/main/java/neatlogic/module/tenant/service/systemnotice/LoginPullSystemNoticeProcessor.java
deleted file mode 100755
index d3226b4563706127ce74128ccf87c3f98e07d613..0000000000000000000000000000000000000000
--- a/src/main/java/neatlogic/module/tenant/service/systemnotice/LoginPullSystemNoticeProcessor.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package neatlogic.module.tenant.service.systemnotice;
-
-import neatlogic.framework.login.core.LoginPostProcessorBase;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-/**
- * @Title: LoginPullSystemNoticeProcessor
- * @Package neatlogic.framework.message.login.handler
- * @Description: 登录后拉取系统公告处理器
- * @Author: laiwt
- * @Date: 2021/1/15 15:38
- **/
-@Service
-public class LoginPullSystemNoticeProcessor extends LoginPostProcessorBase {
-
- @Autowired
- private SystemNoticeService systemNoticeService;
-
- @Override
- protected void myLoginAfterInitialization() {
-
- /** 清理掉system_notice_user中因删除公告或更改公告通知对象而遗留的记录 **/
- systemNoticeService.clearSystemNoticeUser();
-
- /** 检查是否存在【已下发却到了失效时间的】公告,如果有,则停用 **/
- systemNoticeService.stopExpiredSystemNotice();
-
- /** 在system_notice_user插入【当前用户可看的】、【已下发的】公告 **/
- systemNoticeService.pullIssuedSystemNotice();
-
- /**
- * 检查是否存在【当前用户可看的】、【到了生效时间,却还没下发】公告,如果有,则下发给当前用户
- * 其他的通知用户,如果在线则由前端定时拉取,如果离线则登录时拉取
- **/
- systemNoticeService.pullActiveSystemNotice();
- }
-
-}
diff --git a/src/main/java/neatlogic/module/tenant/service/systemnotice/SystemNoticeService.java b/src/main/java/neatlogic/module/tenant/service/systemnotice/SystemNoticeService.java
deleted file mode 100755
index 3544e1c772cc0475ae11afb400f567968d9a54ce..0000000000000000000000000000000000000000
--- a/src/main/java/neatlogic/module/tenant/service/systemnotice/SystemNoticeService.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package neatlogic.module.tenant.service.systemnotice;
-
-
-/**
- * @Title: SystemNoticeService
- * @Package: neatlogic.framework.systemnotice.service
- * @Description:
- * @Author: laiwt
- * @Date: 2021/1/20 11:00
- **/
-public interface SystemNoticeService {
-
- /**
- * @Description: 清理掉system_notice_user中因删除公告或更改公告通知对象而遗留的记录
- * @Author: laiwt
- * @Date: 2021/1/20 11:10
- * @Params: []
- * @Returns: void
- **/
- public void clearSystemNoticeUser();
-
- /**
- * @Description: 检查是否存在【已下发却到了失效时间的】公告,如果有,则停用
- * @Author: laiwt
- * @Date: 2021/1/20 11:12
- * @Params: []
- * @Returns: void
- **/
- public void stopExpiredSystemNotice();
-
- /**
- * @Description: 在system_notice_user插入【当前用户可看的】、【已下发的】公告
- * @Author: laiwt
- * @Date: 2021/1/20 11:12
- * @Params: []
- * @Returns: void
- **/
- public void pullIssuedSystemNotice();
-
- /**
- * @Description: 检查是否存在【当前用户可看的】、【到了生效时间,却还没下发】公告,
- * 如果有则下发给当前用户
- * @Author: laiwt
- * @Date: 2021/1/20 11:13
- * @Params: []
- * @Returns: void
- **/
- public void pullActiveSystemNotice();
-}
diff --git a/src/main/java/neatlogic/module/tenant/service/systemnotice/SystemNoticeServiceImpl.java b/src/main/java/neatlogic/module/tenant/service/systemnotice/SystemNoticeServiceImpl.java
deleted file mode 100755
index 9ecbc266be0ac4487aad8e37c83d812f5522b969..0000000000000000000000000000000000000000
--- a/src/main/java/neatlogic/module/tenant/service/systemnotice/SystemNoticeServiceImpl.java
+++ /dev/null
@@ -1,108 +0,0 @@
-package neatlogic.module.tenant.service.systemnotice;
-
-import neatlogic.framework.asynchronization.threadlocal.UserContext;
-import neatlogic.framework.common.constvalue.UserType;
-import neatlogic.framework.dao.mapper.RoleMapper;
-import neatlogic.framework.dao.mapper.TeamMapper;
-import neatlogic.framework.systemnotice.dao.mapper.SystemNoticeMapper;
-import neatlogic.framework.systemnotice.dto.SystemNoticeUserVo;
-import neatlogic.framework.systemnotice.dto.SystemNoticeVo;
-import org.apache.commons.collections4.CollectionUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- * @Title: SystemNoticeServiceImpl
- * @Package: neatlogic.framework.systemnotice.service
- * @Description:
- * @Author: laiwt
- * @Date: 2021/1/20 11:02
- **/
-@Service
-public class SystemNoticeServiceImpl implements SystemNoticeService{
-
- @Autowired
- private SystemNoticeMapper systemNoticeMapper;
-
- @Autowired
- private RoleMapper roleMapper;
-
- @Autowired
- private TeamMapper teamMapper;
-
- @Override
- public void clearSystemNoticeUser() {
- List recipientUuidList = getRecipientUuidList();
- Set noticeIdList = new HashSet<>();
- /** 获取system_notice_user中,因公告被删除而残留的记录 **/
- noticeIdList.addAll(systemNoticeMapper.getNotExistsNoticeIdListFromNoticeUserByUserUuid(UserContext.get().getUserUuid(true)));
- /** 获取system_notice_user中,因更改公告通知对象而残留的记录 **/
- noticeIdList.addAll(systemNoticeMapper.getNotInNoticeScopeNoticeIdListByUserUuid(recipientUuidList,UserContext.get().getUserUuid(true)));
- /** 清理掉上述两种记录 **/
- if(CollectionUtils.isNotEmpty(noticeIdList)){
- systemNoticeMapper.deleteSystemNoticeUserByUserUuid(UserContext.get().getUserUuid(true),noticeIdList);
- }
- }
-
- @Override
- public void stopExpiredSystemNotice() {
- List recipientUuidList = getRecipientUuidList();
- List expiredNoticeList = systemNoticeMapper.getExpiredNoticeListByRecipientUuidList(recipientUuidList);
- if (CollectionUtils.isNotEmpty(expiredNoticeList)) {
- for (SystemNoticeVo vo : expiredNoticeList) {
- systemNoticeMapper.stopSystemNoticeById(vo);
- }
- }
- }
-
- @Override
- public void pullIssuedSystemNotice() {
- List recipientUuidList = getRecipientUuidList();
- List issuedNoticeList = systemNoticeMapper.getIssuedNoticeIdListByRecipientUuidList(recipientUuidList);
- if (CollectionUtils.isNotEmpty(issuedNoticeList)) {
- List noticeUserVoList = new ArrayList<>();
- for (Long id : issuedNoticeList) {
- noticeUserVoList.add(new SystemNoticeUserVo(id, UserContext.get().getUserUuid(true)));
- }
- systemNoticeMapper.batchInsertSystemNoticeUser(noticeUserVoList);
- }
- }
-
- @Override
- public void pullActiveSystemNotice() {
- List recipientUuidList = getRecipientUuidList();
- List hasBeenActiveNoticeList = systemNoticeMapper.getHasBeenActiveNoticeListByRecipientUuidList(recipientUuidList);
- if (CollectionUtils.isNotEmpty(hasBeenActiveNoticeList)) {
- List currentUserNoticeList = new ArrayList<>();
- /** 更改这些公告的状态为已下发 **/
- for (SystemNoticeVo vo : hasBeenActiveNoticeList) {
- vo.setStatus(SystemNoticeVo.Status.ISSUED.getValue());
- vo.setIssueTime(vo.getStartTime());
- systemNoticeMapper.updateSystemNoticeStatus(vo);
- currentUserNoticeList.add(new SystemNoticeUserVo(vo.getId(), UserContext.get().getUserUuid(true)));
- /** 如果没有忽略已读,那么更改is_read为0 **/
- if(vo.getIgnoreRead() != null && vo.getIgnoreRead() == 0){
- systemNoticeMapper.updateSystemNoticeUserReadStatus(vo.getId(),UserContext.get().getUserUuid(true),0);
- }
- }
- /** 发送给当前用户 **/
- if (CollectionUtils.isNotEmpty(currentUserNoticeList)) {
- systemNoticeMapper.batchInsertSystemNoticeUser(currentUserNoticeList);
- }
- }
- }
-
- private List getRecipientUuidList(){
- List uuidList = new ArrayList<>();
- uuidList.add(UserContext.get().getUserUuid(true));
- uuidList.add(UserType.ALL.getValue());
- uuidList.addAll(teamMapper.getTeamUuidListByUserUuid(UserContext.get().getUserUuid(true)));
- uuidList.addAll(roleMapper.getRoleUuidListByUserUuid(UserContext.get().getUserUuid(true)));
- return uuidList;
- }
-}