Commit 8b347ae8 by chentianzhong

已读代办和撤回。取消撤回代办

parent 0af94f29
......@@ -5,6 +5,7 @@ import com.zq.common.vo.ResultVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
......@@ -76,8 +77,8 @@ public interface MessageFeignClient {
@ApiOperation("内部已读")
@PostMapping("/web/batchSetReadByUser")
public ResultVo batchSetReadByUser(@RequestBody Map<String, Object> params);
@PostMapping("/web/batchSetRead/{businessId}")
public ResultVo batchSetReadByUser(@RequestBody Map<String, Object> params, @PathVariable("businessId") String businessId);
@ApiOperation("根据系统标识及业务id和人员id关闭(已读)代办")
......
package com.zq.email.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
......@@ -42,6 +43,7 @@ import javax.mail.Session;
import javax.mail.internet.MimeMessage;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
/**
* <p>
......@@ -309,23 +311,64 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
OnlineUserDto adminContext = TokenUtils.getAdminContext();
AssertUtils.notNull(adminContext, "登录已失效,请重新登录后再次尝试!");
LocalDateTime rangeStart = DateUtils.getRangeStart(2);
this.lambdaUpdate()
.eq(EmailPerson::getUserId, adminContext.getUserId())
List<EmailPerson> personList = this.lambdaQuery().eq(EmailPerson::getUserId, adminContext.getUserId())
.eq(EmailPerson::getFolderId, folderId)
.eq(EmailPerson::getPersonType, EmailConstant.TYPE_EMAIL_RECEIVE)
.eq(EmailPerson::getIsRead, WhetherEnum.NO.getKey())
.ge(EmailPerson::getSendTime, rangeStart)
.le(EmailPerson::getSendTime, LocalDateTime.now())
.set(EmailPerson::getIsRead, WhetherEnum.YES.getKey())
.update();
.list();
if (CollectionUtil.isNotEmpty(personList)){
List<Long> ids = personList.stream().map(EmailPerson::getId).collect(Collectors.toList());
for (EmailPerson person : personList) {
msgUtil.doneMsgByBusinessIdAndReceiverId(person.getEmailContentId(), person.getUserId());
}
this.lambdaUpdate().in(EmailPerson::getId, ids)
.set(EmailPerson::getIsRead, WhetherEnum.YES.getKey()).update();
}
}
@Override
public void readEmail(EmailReadVo vo) {
this.lambdaUpdate()
.ge(vo.getSearchRange()!=null, EmailPerson::getSendTime, DateUtils.getRangeStart(vo.getSearchRange()))
OnlineUserDto adminContext = TokenUtils.getAdminContext();
AssertUtils.notNull(adminContext, "登录已失效,请重新登录后再次尝试!");
List<EmailPerson> personList = this.lambdaQuery()
.ge(vo.getSearchRange() != null, EmailPerson::getSendTime, DateUtils.getRangeStart(vo.getSearchRange()))
.le(EmailPerson::getSendTime, LocalDateTime.now())
.in(EmailPerson::getId, vo.getPersonIdList())
.set(EmailPerson::getIsRead, vo.getIsRead()).update();
.list();
if (CollectionUtil.isNotEmpty(personList)){
List<Long> ids = personList.stream().map(EmailPerson::getId).collect(Collectors.toList());
for (EmailPerson person : personList) {
if (vo.getIsRead().equals(WhetherEnum.YES.getKey())) {
msgUtil.doneMsgByBusinessIdAndReceiverId(person.getEmailContentId(), person.getUserId());
}
// else{
// //获取代办前端路径
// ResultVo<SystemInfo> bySystemTag = this.adminFeignClient.getBySystemTag(EmailConstant.SYSTEM_TAG);
// AssertUtils.isTrue(bySystemTag.isSuccess(), "调用admin服务,获取业务系统异常");
// SystemInfo systemInfo = bySystemTag.getData();
// AssertUtils.notNull(systemInfo, "调用admin服务异常,获取业务系统为空");
//
// EmailContent content = this.emailContentService.getById(person.getId());
//
// List<Long> receiverList = new ArrayList<>();
// receiverList.add(person.getUserId());
// msgUtil.sendMsg2(adminContext.getNickName(), content, receiverList, systemInfo, EmailFolderEnum.FOLDER_INBOX.getKey());
// }
}
this.lambdaUpdate().in(EmailPerson::getId, ids)
.set(EmailPerson::getIsRead,vo.getIsRead()).update();
}
}
@Override
......@@ -471,14 +514,37 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
@Override
public void recallPerson(EmailSendVo vo){
OnlineUserDto adminContext = TokenUtils.getAdminContext();
AssertUtils.notNull(adminContext, "登录已失效,请重新登录后再次尝试!");
List<EmailPerson> personList = this.lambdaQuery().in(EmailPerson::getId, vo.getPersonIdList()).list();
for (EmailPerson person : personList) {
person.setIsSend(vo.getIsSend());
this.updateById(person);
if (vo.getIsSend().equals(WhetherEnum.NO.getKey())) {
msgUtil.revokeMsgByBusinessIdAndReceiverId(person.getEmailContentId(), person.getUserId());
}else{
//获取代办前端路径
ResultVo<SystemInfo> bySystemTag = this.adminFeignClient.getBySystemTag(EmailConstant.SYSTEM_TAG);
AssertUtils.isTrue(bySystemTag.isSuccess(), "调用admin服务,获取业务系统异常");
SystemInfo systemInfo = bySystemTag.getData();
AssertUtils.notNull(systemInfo, "调用admin服务异常,获取业务系统为空");
EmailContent content = this.emailContentService.getById(person.getEmailContentId());
List<Long> receiverList = new ArrayList<>();
receiverList.add(person.getUserId());
msgUtil.sendMsg2(adminContext.getNickName(), content, receiverList, systemInfo, EmailFolderEnum.FOLDER_INBOX.getKey());
}
}
//如果全部撤回
}
@Override
public void recallEmail(Long contentId) {
......@@ -501,12 +567,14 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
// .eq(EmailPerson::getIsRead, WhetherEnum.NO.getKey())
// .eq(EmailPerson::getPersonType, EmailConstant.TYPE_EMAIL_RECEIVE).remove();
//将发件人设置为未发送
//将发件人设置为未发送、草稿箱
this.lambdaUpdate()
.eq(EmailPerson::getEmailContentId, contentId)
.eq(EmailPerson::getPersonType, EmailConstant.TYPE_EMAIL_SEND)
.set(EmailPerson::getFolderId, EmailFolderEnum.FOLDER_OUTBOX.getKey())
.set(EmailPerson::getIsSend, WhetherEnum.NO.getKey()).update();
//将收件人设置未发送
this.lambdaUpdate()
.eq(EmailPerson::getEmailContentId, contentId)
......
......@@ -45,6 +45,24 @@ public class MsgUtil {
}
@Async
public void sendMsg2(String sender, EmailContent content, List<Long> userIds, SystemInfo systemInfo, Integer folderId) {
Map<String, Object> params = new HashMap<>();
params .put("systemTag", EmailConstant.SYSTEM_TAG);
params .put("sender", sender);
params .put("nickName", sender);
params .put("title","您有一封新邮件提醒");
params .put("content", "请查收我的邮件!主题:"+content.getTitle()+"。");
params.put("userIdList",userIds);
params .put("businessId", content.getId());
params.put("jumpUrl", systemInfo.getHomeUrl() + "/#/detail?folderId="+folderId+"&contentId=" + content.getId());
log.debug("---发送内部消息打印内容: {}", JSONUtil.toJsonStr(params));
messageFeignClient.sendApi(params);
messageFeignClient.addToDoApi(params);
}
//撤回消息和代办
@Async
public void revokeMsgByBusinessId(Long businessId) {
......@@ -76,11 +94,9 @@ public class MsgUtil {
public void doneMsgByBusinessIdAndReceiverId(Long businessId, Long receiverId) {
Map<String, Object> params = new HashMap<>();
params .put("systemTag", EmailConstant.SYSTEM_TAG);
params .put("businessId", businessId);
params .put("todoUserId", receiverId);
params .put("receiverId", receiverId);
params .put("id", receiverId);
log.debug("---已读消息代办: {}", JSONUtil.toJsonStr(params));
messageFeignClient.batchSetReadByUser(params);
messageFeignClient.batchSetReadByUser(params, String.valueOf(businessId));
messageFeignClient.doneByBusinessIdAndSystemTagAndTodoUserId(params);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment