This commit is contained in:
wangliwen 2022-05-30 14:22:40 +08:00
parent b5498b1a80
commit aa27a8ad5a
2 changed files with 25 additions and 15 deletions

View File

@ -3,6 +3,7 @@ package io.renren.common.aspect;
import io.renren.common.annotation.ActivitiNoticeOperation;
import io.renren.modules.notice.dto.SysNoticeDTO;
import io.renren.modules.notice.enums.NoticeStatusEnum;
import io.renren.modules.notice.service.SysNoticeService;
import io.renren.modules.sys.service.SysUserService;
import org.activiti.engine.delegate.DelegateTask;
@ -82,10 +83,10 @@ public class ActivitiNoticeAspect {
dto.setContent("您发起的流程当前审核节点为:" + activitiNoticeOperation.value() + "<br>当前审核人为" + sysUserService.get(Long.valueOf(delegateTask.getAssignee())).getRealName()); // 通知内容
dto.setReceiverType(1);
dto.setReceiverTypeIds(creator);
dto.setStatus(1);
dto.setStatus(NoticeStatusEnum.SEND.value());
dto.setSenderName("流程系统");
dto.setSenderDate(new Date());
dto.setCreator(null);
dto.setCreator(sysUserService.getByUsername("admin").getId());
dto.setCreateDate(new Date());
sysNoticeService.save(dto);
} catch (Exception e) {

View File

@ -16,6 +16,7 @@ import io.renren.modules.notice.enums.ReceiverTypeEnum;
import io.renren.modules.notice.service.SysNoticeService;
import io.renren.modules.notice.service.SysNoticeUserService;
import io.renren.modules.security.user.SecurityUser;
import io.renren.modules.sys.dto.SysUserDTO;
import io.renren.modules.sys.service.SysUserService;
import io.renren.websocket.WebSocketServer;
import io.renren.websocket.data.MessageData;
@ -24,13 +25,13 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 通知管理
*
*/
@Service
public class SysNoticeServiceImpl extends CrudServiceImpl<SysNoticeDao, SysNoticeEntity, SysNoticeDTO> implements SysNoticeService {
@ -42,8 +43,8 @@ public class SysNoticeServiceImpl extends CrudServiceImpl<SysNoticeDao, SysNotic
private WebSocketServer webSocketServer;
@Override
public QueryWrapper<SysNoticeEntity> getWrapper(Map<String, Object> params){
String type = (String)params.get("type");
public QueryWrapper<SysNoticeEntity> getWrapper(Map<String, Object> params) {
String type = (String) params.get("type");
QueryWrapper<SysNoticeEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(type), "type", type);
@ -80,7 +81,7 @@ public class SysNoticeServiceImpl extends CrudServiceImpl<SysNoticeDao, SysNotic
SysNoticeEntity entity = ConvertUtils.sourceToTarget(dto, SysNoticeEntity.class);
//更新发送者信息
if(dto.getStatus() == NoticeStatusEnum.SEND.value()){
if (dto.getStatus() == NoticeStatusEnum.SEND.value()) {
entity.setSenderName(SecurityUser.getUser().getRealName());
entity.setSenderDate(new Date());
}
@ -98,7 +99,7 @@ public class SysNoticeServiceImpl extends CrudServiceImpl<SysNoticeDao, SysNotic
SysNoticeEntity entity = ConvertUtils.sourceToTarget(dto, SysNoticeEntity.class);
//更新发送者信息
if(dto.getStatus() == NoticeStatusEnum.SEND.value()){
if (dto.getStatus() == NoticeStatusEnum.SEND.value()) {
entity.setSenderName(SecurityUser.getUser().getRealName());
entity.setSenderDate(new Date());
}
@ -112,14 +113,14 @@ public class SysNoticeServiceImpl extends CrudServiceImpl<SysNoticeDao, SysNotic
/**
* 发送通知
*/
public void sendNotice(SysNoticeDTO notice){
public void sendNotice(SysNoticeDTO notice) {
//如果是草稿在不发送通知
if(notice.getStatus() == NoticeStatusEnum.DRAFT.value()){
if (notice.getStatus() == NoticeStatusEnum.DRAFT.value()) {
return;
}
//全部用户
if(notice.getReceiverType() == ReceiverTypeEnum.ALL.value()){
if (notice.getReceiverType() == ReceiverTypeEnum.ALL.value()) {
//发送给全部用户
sendAllUser(notice);
@ -127,9 +128,17 @@ public class SysNoticeServiceImpl extends CrudServiceImpl<SysNoticeDao, SysNotic
MessageData<String> message = new MessageData<String>().msg(notice.getTitle());
webSocketServer.sendMessageAll(message);
}else { //选中用户
List<Long> userIdList = sysUserService.getUserIdListByDeptId(notice.getReceiverTypeList());
if(userIdList.size() == 0){
} else { //选中用户
List<Long> userIdList = new ArrayList<>();
SysUserDTO sysUserDTO =
sysUserService.get(Long.valueOf(notice.getReceiverTypeIds())); // 尝试直接查人员
if (sysUserDTO != null) {
userIdList.add(sysUserDTO.getId());
} else {
userIdList = sysUserService.getUserIdListByDeptId(notice.getReceiverTypeList());
}
if (userIdList.size() == 0) {
return;
}
@ -145,7 +154,7 @@ public class SysNoticeServiceImpl extends CrudServiceImpl<SysNoticeDao, SysNotic
/**
* 发送给全部用户
*/
public void sendAllUser(SysNoticeDTO notice){
public void sendAllUser(SysNoticeDTO notice) {
SysNoticeUserEntity noticeUser = new SysNoticeUserEntity()
.setNoticeId(notice.getId())
.setReadStatus(NoticeReadStatusEnum.UNREAD.value());
@ -155,7 +164,7 @@ public class SysNoticeServiceImpl extends CrudServiceImpl<SysNoticeDao, SysNotic
/**
* 发送给选中用户
*/
public void sendUser(SysNoticeDTO notice, List<Long> userIdList){
public void sendUser(SysNoticeDTO notice, List<Long> userIdList) {
userIdList.forEach(userId -> {
SysNoticeUserEntity noticeUser = new SysNoticeUserEntity()
.setNoticeId(notice.getId())