Commit 9af12362 by chentianzhong

提一个版本

parent a68c1bb3
......@@ -5,6 +5,7 @@ import com.zq.common.utils.AssertUtils;
import com.zq.common.vo.ResultVo;
import com.zq.email.service.IEmailContentService;
import com.zq.email.vo.EmailDegreeVo;
import com.zq.email.vo.EmailDetailVo;
import com.zq.email.vo.EmailReqVo;
import com.zq.email.vo.EmailTaskVo;
import io.swagger.annotations.Api;
......@@ -53,4 +54,19 @@ public class EmailContentController {
return ResultVo.success();
}
@ApiOperation("从content中获取邮件收件部门(草稿箱用)")
@PostMapping("findReceiveDeptByContentId")
public ResultVo findReceiveDeptByContentId(@RequestBody EmailDetailVo vo) {
AssertUtils.notNull(vo.getContentId(), "缺少参数:contentId");
return ResultVo.success(emailContentService.findReceiveDeptByContentId(vo.getContentId()));
}
@ApiOperation("从content中获取邮件收件人(草稿箱用)")
@PostMapping("findReceiverByContentId")
public ResultVo findReceiverByContentId(@RequestBody EmailDetailVo vo) {
AssertUtils.notNull(vo.getContentId(), "缺少参数:contentId");
return ResultVo.success(emailContentService.findReceiverByContentId(vo.getContentId()));
}
}
......@@ -9,6 +9,7 @@ import com.zq.common.vo.ResultVo;
import com.zq.email.entity.EmailContent;
import com.zq.email.entity.EmailPerson;
import com.zq.email.enums.SearchRangeEnum;
import com.zq.email.enums.WhetherEnum;
import com.zq.email.service.IEmailContentService;
import com.zq.email.service.IEmailPersonService;
import com.zq.email.vo.*;
......@@ -88,7 +89,9 @@ public class EmailController {
AssertUtils.notNull(vo.getIsSend(), "缺少参数: isSend");
log.info("vo.getReceiver()"+vo.getReceiver());
log.info("vo.getReceiveDeptList()"+vo.getReceiveDeptList());
AssertUtils.isTrue(CollectionUtil.isNotEmpty(vo.getReceiver()) || CollectionUtil.isNotEmpty(vo.getReceiveDeptList()), "缺少参数:receiver和 receiveDeptList");
if ((vo.getIsSend().equals(WhetherEnum.YES.getKey()))) {
AssertUtils.isTrue(CollectionUtil.isNotEmpty(vo.getReceiver()) || CollectionUtil.isNotEmpty(vo.getReceiveDeptList()), "缺少参数:receiver和 receiveDeptList");
}
emailPersonService.emailEditVo(vo);
return ResultVo.success();
}
......@@ -99,11 +102,9 @@ public class EmailController {
OnlineUserDto adminContext = TokenUtils.getAdminContext();
AssertUtils.notNull(adminContext, "登录已失效,请重新登录后再次尝试!");
AssertUtils.notNull(vo.getPersonId(), "缺少参数:personId");
AssertUtils.notNull(vo.getContentId(), "缺少参数:contentId");
EmailPerson emailPerson = emailPersonService.getById(vo.getPersonId());
AssertUtils.notNull(emailPerson, "获取邮件对应人员信息失败");
AssertUtils.isTrue(emailPerson.getUserId().equals(adminContext.getUserId()) , "非本人邮件,不允许阅读");
AssertUtils.isTrue(emailPerson.getEmailContentId() == vo.getContentId() , "邮件不匹配");
EmailContent content = emailContentService.getById(emailPerson.getEmailContentId());
AssertUtils.notNull(content, "获取邮件内容失败");
emailPerson.setEmailContent(content);
......@@ -172,6 +173,7 @@ public class EmailController {
@PostMapping("lastEmail")
public ResultVo lastEmail(@RequestBody EmailLastAndAfterReqVo vo) {
AssertUtils.notNull(vo.getFolderId(), "缺少参数:folderId");
AssertUtils.notNull(vo.getCurrentPersonId(), "缺少参数:currentPersonId");
EmailPerson person = this.emailPersonService.lastAndAfterEmail(vo, 0);
AssertUtils.notNull(person, "没有上一封了");
return ResultVo.success(person);
......@@ -181,12 +183,20 @@ public class EmailController {
@PostMapping("afterEmail")
public ResultVo afterEmail(@RequestBody EmailLastAndAfterReqVo vo) {
AssertUtils.notNull(vo.getFolderId(), "缺少参数:folderId");
AssertUtils.notNull(vo.getCurrentPersonId(), "缺少参数:currentPersonId");
EmailPerson person = this.emailPersonService.lastAndAfterEmail(vo, 1);
AssertUtils.notNull(person, "没有下一封了");
return ResultVo.success(person);
}
@ApiOperation("获取当前部门的人员")
@GetMapping("getUserPolice")
public ResultVo getUserPolice() {
return emailPersonService.getUserPolice();
}
......
......@@ -42,27 +42,20 @@ public class EmailPersonController {
return ResultVo.success();
}
@ApiOperation("任务邮件收件人详情")
@ApiOperation("任务邮件收件人详情(收件箱和个人文件夹用)")
@PostMapping("findTaskEmailByContentId")
public ResultVo findTaskEmailByContentId(@RequestBody EmailDetailVo vo) {
AssertUtils.notNull(vo.getContentId(), "缺少参数:contentId");
return ResultVo.success(emailPersonService.findTaskEmailByContentId(vo.getContentId()));
}
@ApiOperation("邮件收件人详情")
@PostMapping("findReceiverByContentId")
@ApiOperation("非任务邮件收件人详情(收件箱和个人文件夹用)")
@PostMapping("findReceiverByContentId")
public ResultVo findReceiverByContentId(@RequestBody EmailDetailVo vo) {
AssertUtils.notNull(vo.getContentId(), "缺少参数:contentId");
return ResultVo.success(emailPersonService.findReceiverByContentId(vo.getContentId()));
}
@ApiOperation("获取邮件收件部门")
@PostMapping("findReceiveDeptByContentId")
public ResultVo findReceiveDeptByContentId(@RequestBody EmailDetailVo vo) {
AssertUtils.notNull(vo.getContentId(), "缺少参数:contentId");
return ResultVo.success(emailPersonService.findReceiveDeptByContentId(vo.getContentId()));
}
@ApiOperation("设置为已读或未读")
@PostMapping("readEmail")
public ResultVo readEmail(@RequestBody EmailReadVo vo) {
......
package com.zq.email.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@Data
public class SystemInfo implements Serializable {
private Long id;
@ApiModelProperty("系统名称")
private String systemName;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("更新时间")
private Date updateTime;
@ApiModelProperty("系统标识")
private String systemTag;
@ApiModelProperty("状态 0-禁用 1-启用")
private Integer state;
@ApiModelProperty("访问地址")
private String homeUrl;
@ApiModelProperty("系统图标Base64")
private String systemLogo;
@ApiModelProperty("短信平台自定义号")
private String smsId;
@ApiModelProperty("移动端首页")
private String mobileHomeUrl;
@ApiModelProperty("在门户中是否隐藏 0-显示 1-隐藏")
private Integer isHidden;
}
......@@ -6,6 +6,7 @@ import com.zq.common.vo.CustomerUserVo;
import com.zq.common.vo.OnlineUserDto;
import com.zq.common.vo.ResultVo;
import com.zq.email.dto.DeptSimpleDto;
import com.zq.email.dto.SystemInfo;
import com.zq.email.feign.fallback.AdminFeignFallbackFactory;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
......@@ -38,4 +39,7 @@ public interface AdminFeignClient {
@GetMapping("/dept/getByDeptId/{deptId}")
ResultVo<DeptSimpleDto> getByDeptId(@PathVariable Long deptId);
@GetMapping("/systemInfo/getBySystemTag/{systemTag}")
ResultVo<SystemInfo> getBySystemTag(@PathVariable String systemTag);
}
package com.zq.email.feign;
import com.zq.common.vo.ResultVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.Map;
/**
* message 服务feign调用接口
*/
@FeignClient(name = "MESSAGE-SERVER", path = "/message")
public interface MessageFeignClient {
/**
* 发送网页短信提醒(门户的统一消息)
*
* @param param
* @return
*/
@PostMapping("/web/send")
ResultVo sendWebMessage(@RequestBody Map<String, Object> param);
/**
* 新增待办事宜
*
* @param params systemTag - 系统标识 - 必传
* @param params userList - 待办用户集合 - 必传
* @param params title - 待办标题 - 必传
* @param params content - 待办内容 - 必传
* @return
*/
@PostMapping("/todo/addToDo")
ResultVo addToDo(@RequestBody Map<String, Object> params);
/**
* 撤回网页消息
* 参数businessId,systemTag
*
* @param params
* @return
*/
@PostMapping("/web/delMessageBySystem")
ResultVo revokeWebBySysInfo(@RequestBody Map<String, Object> params);
/**
* 撤回待办
* 参数businessId,systemTag
*
* @param params
* @return
*/
@PostMapping("/todo/delMessageBySystem")
ResultVo revokeTodoBySysInfo(@RequestBody Map<String, Object> params);
}
......@@ -4,6 +4,7 @@ import com.zq.common.vo.CustomerUserVo;
import com.zq.common.vo.OnlineUserDto;
import com.zq.common.vo.ResultVo;
import com.zq.email.dto.DeptSimpleDto;
import com.zq.email.dto.SystemInfo;
import com.zq.email.feign.AdminFeignClient;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
......@@ -49,6 +50,11 @@ public class AdminFeignFallbackFactory implements FallbackFactory<AdminFeignClie
return null;
}
@Override
public ResultVo<SystemInfo> getBySystemTag(String systemTag) {
return null;
}
};
}
......
......@@ -21,12 +21,5 @@ public class SmsProperties {
*/
private String appKey;
/**
* 内网地址
*/
private String insideUrl;
/**
* 外网地址
*/
private String outsideUrl;
private String url;
}
package com.zq.email.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zq.common.vo.CustomerUserVo;
import com.zq.common.vo.OnlineUserDto;
import com.zq.email.dto.DeptSimpleDto;
import com.zq.email.entity.EmailContent;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zq.email.vo.*;
import io.swagger.models.auth.In;
import java.util.List;
/**
* <p>
* 服务类
......@@ -23,4 +27,7 @@ public interface IEmailContentService extends IService<EmailContent> {
void setDegreeEmail(EmailDegreeVo vo);
List<DeptSimpleDto> findReceiveDeptByContentId(Long contentId);
List<CustomerUserVo> findReceiverByContentId(Long contentId);
}
package com.zq.email.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zq.common.vo.ResultVo;
import com.zq.email.dto.DeptDto;
import com.zq.email.dto.DeptSimpleDto;
import com.zq.email.entity.EmailPerson;
......@@ -34,8 +35,6 @@ public interface IEmailPersonService extends IService<EmailPerson> {
List<EmailPerson> findTaskEmailByContentId(Long contentId);
List<DeptSimpleDto> findReceiveDeptByContentId(Long contentId);
void readAllEmails(Long folderId);
void readEmail(EmailReadVo vo);
......@@ -60,4 +59,7 @@ public interface IEmailPersonService extends IService<EmailPerson> {
Integer searchTotal(EmailSearchReqVo vo);
Page searchPage(EmailSearchReqVo vo);
//当前部门的人员
ResultVo getUserPolice();
}
......@@ -40,9 +40,22 @@ public class EmailAttachServiceImpl extends ServiceImpl<EmailAttachMapper, Email
if(CollectionUtil.isNotEmpty(vo.getFileIds())) {
//拿到旧附件
list = this.lambdaQuery().eq(EmailAttach::getEmailContentId, content.getId()).in(EmailAttach::getAttachId, vo.getFileIds()).list();
for (EmailAttach emailAttach : list) {
emailAttach.setId(null);
//list = this.lambdaQuery().eq(EmailAttach::getEmailContentId, content.getId()).in(EmailAttach::getAttachId, vo.getFileIds()).list();
//list = this.lambdaQuery().in(EmailAttach::getAttachId, vo.getFileIds()).list();
for (String fileId : vo.getFileIds()) {
ResultVo<SysFileUploadVo> uploadFileById = fileFeignClient.getUploadFileById(fileId);
if (uploadFileById.isSuccess() && uploadFileById.getData()!=null){
SysFileUploadVo data = uploadFileById.getData();
EmailAttach emailAttach = EmailAttach.builder()
.emailContentId(content.getId())
.attachId(data.getId())
.attachName(data.getFileName())
.attachSize(data.getSize())
.downloadPath(data.getDownloadPath())
.sendTime(content.getSendTime())
.build();
list.add(emailAttach);
}
}
}
//先检查旧附件
......
......@@ -2,12 +2,17 @@ package com.zq.email.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zq.common.utils.AssertUtils;
import com.zq.common.vo.CustomerUserVo;
import com.zq.common.vo.OnlineUserDto;
import com.zq.common.vo.ResultVo;
import com.zq.email.dto.DeptSimpleDto;
import com.zq.email.entity.EmailContent;
import com.zq.email.enums.RemindEnum;
import com.zq.email.enums.WhetherEnum;
import com.zq.email.feign.AdminFeignClient;
import com.zq.email.mapper.EmailContentMapper;
import com.zq.email.service.IEmailContentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
......@@ -15,10 +20,13 @@ import com.zq.email.vo.EmailDegreeVo;
import com.zq.email.vo.EmailEditVo;
import com.zq.email.vo.EmailReqVo;
import com.zq.email.vo.EmailTaskVo;
import lombok.RequiredArgsConstructor;
import net.bytebuddy.matcher.CollectionErasureMatcher;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
/**
* <p>
......@@ -29,8 +37,11 @@ import java.time.LocalDateTime;
* @since 2023-03-06
*/
@Service
@RequiredArgsConstructor
public class EmailContentServiceImpl extends ServiceImpl<EmailContentMapper, EmailContent> implements IEmailContentService {
private final AdminFeignClient adminFeignClient;
@Override
public EmailContent saveContent(EmailEditVo vo, OnlineUserDto adminContext) {
EmailContent content = null;
......@@ -90,4 +101,38 @@ public class EmailContentServiceImpl extends ServiceImpl<EmailContentMapper, Ema
public void setDegreeEmail(EmailDegreeVo vo) {
this.lambdaUpdate().in(EmailContent::getId, vo.getContentId()).set(EmailContent::getDegree, vo.getDegree()).update();
}
@Override
public List<DeptSimpleDto> findReceiveDeptByContentId(Long contentId) {
List<DeptSimpleDto> deptDtoList = new ArrayList<>();
EmailContent content = this.getById(contentId);
if (StrUtil.isNotBlank(content.getDeptList())){
String[] deptIds = content.getDeptList().split(",");
for (String deptId : deptIds) {
ResultVo<DeptSimpleDto> byDeptId = adminFeignClient.getByDeptId(Long.valueOf(deptId));
if (byDeptId.isSuccess() && byDeptId.getData()!=null){
deptDtoList.add(byDeptId.getData());
}
}
}
return deptDtoList;
}
@Override
public List<CustomerUserVo> findReceiverByContentId(Long contentId) {
List<CustomerUserVo> userVoList = new ArrayList<>();
EmailContent content = this.getById(contentId);
if (StrUtil.isNotBlank(content.getUserList())){
String[] userIds = content.getUserList().split(",");
for (String userId : userIds) {
CustomerUserVo userById = adminFeignClient.getUserById(Long.valueOf(userId));
if (userById!=null){
userVoList.add(userById);
}
}
}
return userVoList;
}
}
......@@ -6,6 +6,7 @@ import cn.hutool.core.io.file.FileWriter;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
......@@ -17,6 +18,7 @@ import com.zq.common.vo.ResultVo;
import com.zq.email.constants.EmailConstant;
import com.zq.email.dto.DeptDto;
import com.zq.email.dto.DeptSimpleDto;
import com.zq.email.dto.SystemInfo;
import com.zq.email.entity.EmailAttach;
import com.zq.email.entity.EmailContent;
import com.zq.email.entity.EmailFolder;
......@@ -24,6 +26,7 @@ import com.zq.email.entity.EmailPerson;
import com.zq.email.enums.EmailFolderEnum;
import com.zq.email.enums.WhetherEnum;
import com.zq.email.feign.AdminFeignClient;
import com.zq.email.feign.MessageFeignClient;
import com.zq.email.mapper.EmailPersonMapper;
import com.zq.email.service.IEmailAttachService;
import com.zq.email.service.IEmailContentService;
......@@ -31,8 +34,10 @@ import com.zq.email.service.IEmailPersonService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zq.email.utils.DateUtils;
import com.zq.email.utils.EmailUtil;
import com.zq.email.utils.SmsUtil;
import com.zq.email.vo.*;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.binary.Base64;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.InputStreamResource;
......@@ -60,9 +65,7 @@ import java.io.FileOutputStream;
import java.io.InputStream;
import java.net.URL;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.util.*;
/**
* <p>
......@@ -74,6 +77,7 @@ import java.util.Properties;
*/
@Service
@RequiredArgsConstructor
@Slf4j
public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, EmailPerson> implements IEmailPersonService {
private final static String DATE_FORMAT = "/yyyyMM/dd/";
......@@ -84,6 +88,8 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
private final IEmailContentService emailContentService;
private final IEmailAttachService emailAttachService;
private final AdminFeignClient adminFeignClient;
private final MessageFeignClient messageFeignClient;
private final SmsUtil smsUtil;
@Override
public Integer emailCount(EmailReqVo vo) {
......@@ -141,16 +147,45 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
this.saveEmailSender(adminContext, content, vo);
//vo.getIsSend() == 1就发送
if (vo.getIsSend()!=null && vo.getIsSend().equals(WhetherEnum.YES.getKey())) {
//增加收件人
//收件人
List<CustomerUserVo> receiverList = new ArrayList<>();
if (CollectionUtil.isNotEmpty(vo.getReceiver())) {
this.saveEmailReceiver(vo.getReceiver(), content, vo);
for (Long userId : vo.getReceiver()) {
CustomerUserVo receiver = this.adminFeignClient.getUserById(userId);
AssertUtils.notNull(receiver, "调用admin失败,根据userId获取人员接口异常");
receiverList.add(receiver);
}
}
//增加收件部门
//收件部门人员
List<CustomerUserVo> deptUserList = new ArrayList<>();
if (CollectionUtil.isNotEmpty(vo.getReceiveDeptList())) {
this.saveEmailReceiveDept(vo.getReceiveDeptList(), content, vo);
for (Long deptId : vo.getReceiveDeptList()) {
ResultVo<List<CustomerUserVo>> userByDeptId = adminFeignClient.getUserByDeptId(deptId);
AssertUtils.isTrue(userByDeptId.isSuccess(), "调用admin失败,根据deptId获取人员接口异常");
deptUserList.addAll(userByDeptId.getData());
}
}
if (CollectionUtil.isNotEmpty(receiverList)) {
//增加收件人
this.saveEmailReceiver(receiverList, content, vo);
//短信
smsUtil.sendBatchSms(receiverList, "您有一封新的邮件,标题为《"+content.getTitle()+"》。请及时查收。", content.getId());
}
if (CollectionUtil.isNotEmpty(deptUserList)) {
//增加收件部门
this.saveEmailReceiveDept(deptUserList, content, vo);
//短信
smsUtil.sendBatchSms(deptUserList, "您有一封新的邮件,标题为《"+content.getTitle()+"》。请及时查收。", content.getId());
}
}
//消息提醒
}
......@@ -193,23 +228,6 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
}
@Override
public List<DeptSimpleDto> findReceiveDeptByContentId(Long contentId) {
List<DeptSimpleDto> deptDtoList = new ArrayList<>();
EmailContent content = this.emailContentService.getById(contentId);
if (StrUtil.isNotBlank(content.getDeptList())){
String[] deptIds = content.getDeptList().split(",");
for (String deptId : deptIds) {
ResultVo<DeptSimpleDto> byDeptId = adminFeignClient.getByDeptId(Long.valueOf(deptId));
if (byDeptId.isSuccess() && byDeptId.getData()!=null){
deptDtoList.add(byDeptId.getData());
}
}
}
return deptDtoList;
}
@Override
public void readAllEmails(Long folderId) {
OnlineUserDto adminContext = TokenUtils.getAdminContext();
AssertUtils.notNull(adminContext, "登录已失效,请重新登录后再次尝试!");
......@@ -325,12 +343,14 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
if (type.equals(WhetherEnum.YES.getKey())){
queryWrapper.lt(EmailPerson::getId, vo.getCurrentPersonId());
queryWrapper.orderByDesc(EmailPerson::getId);
}else if (type.equals(WhetherEnum.NO.getKey())){
queryWrapper.gt(EmailPerson::getId, vo.getCurrentPersonId());
queryWrapper.orderByAsc(EmailPerson::getId);
}else{
AssertUtils.isTrue(false, "向上或向下查询参数不对");
}
List<EmailPerson> list = this.list(queryWrapper);
//List<EmailPerson> list = this.list(queryWrapper);
EmailPerson person = this.getOne(queryWrapper, false);
if (person!=null){
EmailContent content = this.emailContentService.getById(person.getEmailContentId());
......@@ -351,9 +371,22 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
@Override
public void recallEmail(Long contentId) {
List<EmailPerson> list = this.lambdaQuery()
.eq(EmailPerson::getEmailContentId, contentId)
.eq(EmailPerson::getIsRead, WhetherEnum.YES.getKey())
.eq(EmailPerson::getPersonType, EmailConstant.TYPE_EMAIL_RECEIVE).list();
AssertUtils.isTrue(CollectionUtil.isEmpty(list), "邮件已被收件人已读,无法撤回");
//删除收件人
this.lambdaUpdate()
.eq(EmailPerson::getEmailContentId, contentId)
.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();
}
......@@ -454,6 +487,13 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
return page;
}
@Override
public ResultVo getUserPolice() {
OnlineUserDto adminContext = TokenUtils.getAdminContext();
AssertUtils.notNull(adminContext, "登录已失效,请重新登录后再次尝试!");
return this.adminFeignClient.getUserByDeptId(adminContext.getDeptId());
}
private void saveEmailSender(OnlineUserDto adminContext, EmailContent content, EmailEditVo vo) {
EmailPerson sender = EmailPerson.builder()
.emailContentId(content.getId())
......@@ -474,46 +514,70 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
this.save(sender);
}
private void saveEmailReceiveDept(List<Long> deptIds, EmailContent content, EmailEditVo vo) {
List<EmailPerson> receiverList = new ArrayList<>();
for (Long deptId : deptIds) {
ResultVo<List<CustomerUserVo>> userByDeptId = adminFeignClient.getUserByDeptId(deptId);
AssertUtils.isTrue(userByDeptId.isSuccess(), "获取部门人员失败(deptId: "+deptId+")");
AssertUtils.notNull(userByDeptId.getData(), "获取部门人员为null(deptId: "+deptId+")");
for (CustomerUserVo receiver : userByDeptId.getData()) {
EmailPerson receivePerson = EmailPerson.builder()
.emailContentId(content.getId())
.userId(receiver.getUserId())
.userEmail(receiver.getUsername())
.userName(receiver.getNickName())
.deptId(receiver.getDeptId())
.courtCode(receiver.getCourtCode())
.personType(EmailConstant.TYPE_EMAIL_RECEIVE)
.sendTime(content.getSendTime())
.folderId(EmailFolderEnum.FOLDER_DEPT_INBOX.getKey().longValue())
.isRead(WhetherEnum.NO.getKey())
.isPerson(WhetherEnum.NO.getKey())
.isTask(vo.getIsTask())
.isSend(vo.getIsSend())
.build();
receiverList.add(receivePerson);
private void saveEmailReceiveDept(List<CustomerUserVo> receiverList, EmailContent content, EmailEditVo vo) {
ResultVo<SystemInfo> bySystemTag = this.adminFeignClient.getBySystemTag(EmailConstant.SYSTEM_TAG);
AssertUtils.isTrue(bySystemTag.isSuccess(), "调用admin服务异常");
SystemInfo systemInfo = bySystemTag.getData();
AssertUtils.notNull(systemInfo, "调用admin服务异常,获取业务系统地址为空");
for (CustomerUserVo userVo : receiverList) {
EmailPerson receivePerson = EmailPerson.builder()
.emailContentId(content.getId())
.userId(userVo.getUserId())
.userEmail(userVo.getUsername())
.userName(userVo.getNickName())
.deptId(userVo.getDeptId())
.courtCode(userVo.getCourtCode())
.personType(EmailConstant.TYPE_EMAIL_RECEIVE)
.sendTime(content.getSendTime())
.folderId(EmailFolderEnum.FOLDER_DEPT_INBOX.getKey().longValue())
.isRead(WhetherEnum.NO.getKey())
.isPerson(WhetherEnum.NO.getKey())
.isTask(vo.getIsTask())
.isSend(vo.getIsSend())
.build();
this.save(receivePerson);
//内部消息提醒
if (content.getMessageRemind()!=null && content.getMessageRemind() == 1){
new Thread(new Runnable() {
@Override
public void run() {
Map<String, Object> params = new HashMap<>();
params .put("systemTag", EmailConstant.SYSTEM_TAG);
params .put("title","您有一封新邮件提醒");
params .put("content", "您有一封新的邮件,标题为《"+content.getTitle()+"》。请及时查收。");
params.put("userIdList", Collections.singletonList(userVo.getUserId()));
params .put("businessId", receivePerson.getId());
params.put("jumpUrl", systemInfo.getHomeUrl() + "/#/detail?personId" + receivePerson.getId());
log.info("发送内部短信内容打印: {}", JSONUtil.toJsonStr(params));
messageFeignClient .sendWebMessage(params);
messageFeignClient .addToDo(params);
}
});
}
}
this.saveBatch(receiverList);
}
private void saveEmailReceiver(List<Long> receiverIds, EmailContent content, EmailEditVo vo) {
List<EmailPerson> receiverList = new ArrayList<>();
for (Long userId : receiverIds) {
CustomerUserVo receiver = adminFeignClient.getUserById(userId);
AssertUtils.notNull(receiver, "获取收件人失败(userId: "+userId+")");
private void saveEmailReceiver(List<CustomerUserVo> receiverList, EmailContent content, EmailEditVo vo) {
ResultVo<SystemInfo> bySystemTag = this.adminFeignClient.getBySystemTag(EmailConstant.SYSTEM_TAG);
AssertUtils.isTrue(bySystemTag.isSuccess(), "调用admin服务异常");
SystemInfo systemInfo = bySystemTag.getData();
AssertUtils.notNull(systemInfo, "调用admin服务异常,获取业务系统地址为空");
for (CustomerUserVo userVo : receiverList) {
EmailPerson receivePerson = EmailPerson.builder()
.emailContentId(content.getId())
.userId(receiver.getUserId())
.userEmail(receiver.getUsername())
.userName(receiver.getNickName())
.deptId(receiver.getDeptId())
.courtCode(receiver.getCourtCode())
.userId(userVo.getUserId())
.userEmail(userVo.getUsername())
.userName(userVo.getNickName())
.deptId(userVo.getDeptId())
.courtCode(userVo.getCourtCode())
.personType(EmailConstant.TYPE_EMAIL_RECEIVE)
.sendTime(content.getSendTime())
.folderId(EmailFolderEnum.FOLDER_INBOX.getKey().longValue())
......@@ -522,9 +586,32 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
.isTask(vo.getIsTask())
.isSend(vo.getIsSend())
.build();
receiverList.add(receivePerson);
this.save(receivePerson);
//内部消息提醒
if (content.getMessageRemind()!=null && content.getMessageRemind() == 1){
new Thread(new Runnable() {
@Override
public void run() {
Map<String, Object> params = new HashMap<>();
params .put("systemTag", EmailConstant.SYSTEM_TAG);
params .put("title","您有一封新邮件提醒");
params .put("content", "您有一封新的邮件,标题为《"+content.getTitle()+"》。请及时查收。");
params.put("userIdList", Collections.singletonList(userVo.getUserId()));
params .put("businessId", receivePerson.getId());
params.put("jumpUrl", systemInfo.getHomeUrl() + "/#/oaContent/index?personId=" + receivePerson.getId());
log.info("发送内部短信内容打印: {}", JSONUtil.toJsonStr(params));
messageFeignClient .sendWebMessage(params);
messageFeignClient .addToDo(params);
}
});
}
}
this.saveBatch(receiverList);
}
......
package com.zq.email.utils;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.net.url.UrlQuery;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.zq.common.vo.CustomerUserVo;
import com.zq.common.vo.ResultVo;
import com.zq.email.properties.SmsProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author wilmiam
......@@ -17,68 +30,53 @@ public class SmsUtil {
@Resource
public SmsProperties smsProperties;
// /**
// * 发送短信
// *
// * @return
// */
// public ResultVo sendSms(Map<String, Object> params) {
// ResultVo resultVo = ResultVo.success();
// if ("wantest".equals(active) || "wanpro".equals(active)) {
// String url = smsConfig.getOutsideUrl() + "/outside/send";
// resultVo = sendRequest(url, params);
// }
// if ("test".equals(active) || "product".equals(active)) {
// String url = smsConfig.getInsideUrl() + "/inside/send";
// resultVo = sendRequest(url, params);
// }
// return resultVo;
// }
//
// /**
// * 发送批量短信
// *
// * @return
// */
// public ResultVo sendBatchSms(Map<String, Object> params) {
// ResultVo resultVo = ResultVo.success();
// if ("wantest".equals(active) || "wanpro".equals(active)) {
// String url = smsConfig.getOutsideUrl() + "/outside/sendBatch";
// resultVo = sendRequest(url, params);
// }
// if ("test".equals(active) || "product".equals(active)) {
// String url = smsConfig.getInsideUrl() + "/inside/sendBatch";
// resultVo = sendRequest(url, params);
// }
// return resultVo;
// }
//
// private ResultVo sendRequest(String url, Map<String, Object> params) {
// log.debug("发送短信请求 => {} \nRequest Body:\n\t{}\n", url, UrlQuery.of(params));
//
// HttpRequest request = HttpUtil.createPost(url)
// .header("APP_ID", smsConfig.getAppId())
// .header("APP_KEY", smsConfig.getAppKey())
// .body(JSONUtil.toJsonStr(params));
//
// HttpResponse response;
// try {
// response = request.execute();
// } catch (Exception e) {
// log.error("调用短信接口失败", e);
// return ResultVo.fail("调用短信接口失败:" + e.getMessage());
// }
//
// String body = response.body();
//
// log.debug("发送短信响应 => {}", body);
//
// try {
// return JSONUtil.toBean(body, ResultVo.class);
// } catch (Exception e) {
// log.error("调用短信接口解析失败", e);
// return ResultVo.fail("调用短信接口失败:" + e.getMessage());
// }
// }
/**
* 发送批量短信
*
* @return
*/
public void sendBatchSms(List<CustomerUserVo> userVoList, String content, Long contentId) {
String regex = "^1[3-9]\\d{9}";
StringBuffer sb = new StringBuffer();
for (CustomerUserVo userVo : userVoList) {
if (userVo!=null && StrUtil.isNotBlank(userVo.getPhone()) && userVo.getPhone().matches(regex)){
sb.append(userVo.getPhone()).append(",");
}
}
Map<String, Object> map = new HashMap<>();
map.put("phones", Base64.encode(sb.toString().getBytes()));
map.put("formId", Base64.encode("oa_email".getBytes()));
map.put("content", Base64.encode(content.getBytes()));
map.put("isReply", Base64.encode("0".getBytes()));
String param= JSONUtil.toJsonStr(map);
sendRequest(Base64.encode(param.getBytes()), contentId);
}
private void sendRequest(String content, Long contentId) {
log.info("发送短信请求 => 邮件标识:{},请求地址:{}", contentId, smsProperties.getUrl());
Map<String, Object> map = new HashMap<>();
map.put("data", content);
String param = JSONUtil.toJsonStr(map);
log.info("参数 => {}, 邮件标识:{}", contentId, param);
HttpRequest request = HttpUtil.createPost(smsProperties.getUrl())
.header("APP_ID", Base64.encode(smsProperties.getAppId().getBytes()))
.header("APP_KEY", Base64.encode(smsProperties.getAppKey().getBytes()))
.body(param);
try {
HttpResponse response = request.execute();
String body = response.body();
log.info("发送短信响应 => {}, 邮件标识:{}", body, contentId);
ResultVo resultVo = JSONUtil.toBean(body, ResultVo.class);
log.info("发送短信响应 => {}, 邮件标识:{}", resultVo.isSuccess(), contentId);
} catch (Exception e) {
log.error("调用短信接口失败");
log.error(e.getLocalizedMessage(), e);
}
}
}
......@@ -49,5 +49,4 @@ public class EmailEditVo {
@ApiModelProperty("附件")
private List<MultipartFile> fileList;
}
......@@ -57,4 +57,10 @@ spring:
multi-statement-allow: true
#是否开启 swagger-ui
swagger:
enabled: true
\ No newline at end of file
enabled: true
sms:
app-id: oa-mobile
app-key: GY@mobile$2022
url: http://171.106.48.55:19891/ums/inside_new/sendBatch
\ No newline at end of file
......@@ -57,4 +57,9 @@ spring:
multi-statement-allow: true
#是否开启 swagger-ui
swagger:
enabled: true
\ No newline at end of file
enabled: true
sms:
app-id: oa-mobile
app-key: GY@mobile$2022
url: http://171.106.48.55:19891/ums/inside_new/sendBatch
......@@ -56,4 +56,10 @@ spring:
multi-statement-allow: true
#是否开启 swagger-ui
swagger:
enabled: false
\ No newline at end of file
enabled: false
sms:
app-id: oa-mobile
app-key: GY@mobile$2022
url: http://172.28.1.71:9888/ums/inside_new/sendBatch
\ No newline at end of file
......@@ -56,4 +56,9 @@ spring:
multi-statement-allow: true
#是否开启 swagger-ui
swagger:
enabled: false
\ No newline at end of file
enabled: false
sms:
app-id: oa-mobile
app-key: GY@mobile$2022
url: http://172.28.1.71:9888/ums/inside_new/sendBatch
\ No newline at end of file
......@@ -55,7 +55,7 @@
</if>
<if test="s.attachName != null and s.attachName !='' ">
AND EC."ATTACH_NAME" LIKE concat('%', #{s.attachName}, '%')
AND EA."ATTACH_NAME" LIKE concat('%', #{s.attachName}, '%')
</if>
</where>
ORDER BY EP."ID" DESC
......@@ -116,7 +116,7 @@
</if>
<if test="s.attachName != null and s.attachName !='' ">
AND EC."ATTACH_NAME" LIKE concat('%', #{s.attachName}, '%')
AND EA."ATTACH_NAME" LIKE concat('%', #{s.attachName}, '%')
</if>
</where>
ORDER BY EP."ID" DESC
......
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