Commit 5074daec by chentianzhong

AdminFeignClient 获取人员信以及相关调整,列表增加根据查询参数判断是否获取人员信息(目前仅放出头像)

parent 97be4aa0
package com.zq.email.dto;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.builder.ToStringBuilder;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.sql.Timestamp;
/**
* @author Zheng Jie
* @date 2019年10月24日20:48:53
*/
@Getter
@Setter
public class BaseDTO implements Serializable {
private String createBy;
private String updatedBy;
private Timestamp createTime;
private Timestamp updateTime;
@Override
public String toString() {
ToStringBuilder builder = new ToStringBuilder(this);
Field[] fields = this.getClass().getDeclaredFields();
try {
for (Field f : fields) {
f.setAccessible(true);
builder.append(f.getName(), f.get(this)).append("\n");
}
} catch (Exception e) {
builder.append("toString builder encounter an error");
}
return builder.toString();
}
}
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.zq.email.dto.admin;
import lombok.Data;
import java.io.Serializable;
/**
* @author Zheng Jie
* @date 2019-6-10 16:32:18
*/
@Data
public class DeptSmallDto implements Serializable {
private Long id;
private String name;
}
\ No newline at end of file
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.zq.email.dto.admin;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* @author Zheng Jie
* @date 2019-6-10 16:32:18
*/
@Data
@NoArgsConstructor
public class JobSmallDto implements Serializable {
private Long id;
private String name;
}
\ No newline at end of file
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.zq.email.dto.admin;
import lombok.Data;
import java.io.Serializable;
/**
* @author Zheng Jie
* @date 2018-11-23
*/
@Data
public class RoleSmallDto implements Serializable {
private Long id;
private String name;
private Integer level;
private String dataScope;
}
package com.zq.email.dto.admin;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.zq.email.dto.BaseDTO;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.util.Date;
import java.util.Set;
/**
* @author Zheng Jie
* @date 2018-11-23
*/
@Getter
@Setter
public class UserDto extends BaseDTO implements Serializable {
private Long id;
private Set<RoleSmallDto> roles;
private Set<JobSmallDto> jobs;
private DeptSmallDto dept;
private Long deptId;
private String username;
private String nickName;
private String email;
private String phone;
private String gender;
private String avatarName;
private String avatarPath;
@JsonIgnore
private String password;
private Integer enabled;
private Boolean isAdmin = false;
private Boolean isApiUser;
private String apiKey;
private Date pwdResetTime;
private String areaId;
private String cityName;
private String pCode;
private String orgCode;
private String courtCode;
private String courtName;
private String courtIdent;
private String photo;
private Integer isReceiver;
private String postDeptFile;
private Integer isLinux;
private Integer isPwdChange;
private Integer infoHidden;
private Integer enableArchive;
}
......@@ -9,6 +9,7 @@ import java.io.Serializable;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.zq.email.dto.admin.UserDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
......@@ -75,5 +76,10 @@ public class EmailPerson implements Serializable {
@TableField(exist = false)
private List<EmailPerson> receiverList;
//发送人信息
@TableField(exist = false)
private UserDto sender;
}
......@@ -7,6 +7,7 @@ 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.dto.admin.UserDto;
import com.zq.email.feign.fallback.AdminFeignFallbackFactory;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
......@@ -29,9 +30,21 @@ public interface AdminFeignClient {
@GetMapping("/oauth/getUserInfoByToken")
ResultVo<OnlineUserDto> getUserInfoByToken(@RequestParam String token);
@GetMapping("/users/getUserById/{userId}")
@AnonymousAccess
CustomerUserVo getUserById(@PathVariable Long userId);
@ApiOperation("根据用户ID查询用户信息,jpa")
@PostMapping("/users/findById")
ResultVo<UserDto> findById(@RequestParam Long userId);
@ApiOperation("根据用户名(邮箱)查询用户信息,jpa")
@PostMapping("/users/findByUsername")
ResultVo<UserDto> findByUsername(@RequestParam Long username);
@ApiOperation("根据用户标识(人员标识)查询用户信息,jpa")
@PostMapping("/users/findByPCode/{pCode}")
ResultVo<UserDto> findByPCode(@RequestParam("pcode") String pcode);
@ApiOperation("根据部门查询用户信息,jpa")
@PostMapping("/users/findByDeptIds")
ResultVo<List<UserDto>> findByDeptIds(@RequestParam("deptIds") List<Long> deptIds);
@GetMapping(value = "/users/getUserByDeptId/{deptId}")
ResultVo<List<CustomerUserVo>> getUserByDeptId(@PathVariable(value="deptId") Long deptId);
......@@ -45,9 +58,6 @@ public interface AdminFeignClient {
@GetMapping("/systemInfo/getBySystemTag/{systemTag}")
ResultVo<SystemInfo> getBySystemTag(@PathVariable String systemTag);
@ApiOperation("根据人员标识查询用户")
@AnonymousAccess
@GetMapping("/users/getBypCode/{pCode}")
ResultVo<CustomerUserVo> getBypCode(@PathVariable String pCode);
}
......@@ -5,6 +5,7 @@ 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.dto.admin.UserDto;
import com.zq.email.feign.AdminFeignClient;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
......@@ -35,34 +36,42 @@ public class AdminFeignFallbackFactory implements FallbackFactory<AdminFeignClie
@Override
public ResultVo<OnlineUserDto> getUserInfoByToken(String token) {
LOG.error("getUserInfoByToken 失败");
return ResultVo.fail(401, "获取人员token失败");
return ResultVo.fail("获取人员token失败");
}
@Override
public CustomerUserVo getUserById(Long userId) {
LOG.error("根据userId获取人员信息失败");
return null;
public ResultVo<UserDto> findById(Long userId) {
return ResultVo.fail("admin服务调用异常-->findById异常");
}
@Override
public ResultVo<List<CustomerUserVo>> getUserByDeptId(Long deptId) {
LOG.error("根据deptId获取部门人员信息失败");
return null;
public ResultVo<UserDto> findByUsername(Long username) {
return ResultVo.fail("admin服务调用异常-->findByUsername异常");
}
@Override
public ResultVo<DeptSimpleDto> getByDeptId(Long deptId) {
return null;
public ResultVo<UserDto> findByPCode(String pcode) {
return ResultVo.fail("admin服务调用异常-->findByPCode异常");
}
@Override
public ResultVo<SystemInfo> getBySystemTag(String systemTag) {
return null;
public ResultVo<List<UserDto>> findByDeptIds(List<Long> deptIds) {
return ResultVo.fail("admin服务调用异常-->findByDeptIds异常");
}
@Override
public ResultVo<CustomerUserVo> getBypCode(String pCode) {
return null;
public ResultVo<List<CustomerUserVo>> getUserByDeptId(Long deptId) {
return ResultVo.fail("admin服务调用异常-->getUserByDeptId异常");
}
@Override
public ResultVo<DeptSimpleDto> getByDeptId(Long deptId) {
return ResultVo.fail("admin服务调用异常-->getByDeptId异常");
}
@Override
public ResultVo<SystemInfo> getBySystemTag(String systemTag) {
return ResultVo.fail("admin服务调用异常-->getBySystemTag异常");
}
......
......@@ -4,6 +4,7 @@ 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.dto.admin.UserDto;
import com.zq.email.entity.EmailContent;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zq.email.vo.*;
......@@ -35,7 +36,7 @@ public interface IEmailContentService extends IService<EmailContent> {
List<DeptSimpleDto> findReceiveDeptByContentId(Long contentId);
List<CustomerUserVo> findReceiverByContentId(Long contentId);
List<UserDto> findReceiverByContentId(Long contentId);
List<Long> findRecentlySendEmail(Integer num);
......
......@@ -5,6 +5,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.admin.UserDto;
import com.zq.email.entity.EmailContent;
import com.zq.email.entity.EmailPerson;
import com.baomidou.mybatisplus.extension.service.IService;
......@@ -42,7 +43,7 @@ public interface IEmailPersonService extends IService<EmailPerson> {
EmailPerson saveEmailSender(CustomerUserVo userVo, EmailContent content, Long folderId, Integer isSend);
//保存收件人
void saveEmailReceiver(List<CustomerUserVo> receiverList, EmailContent content, Long folderId, Integer isPerson, Integer isSend);
void saveEmailReceiver(List<UserDto> receiverList, EmailContent content, Long folderId, Integer isPerson, Integer isSend);
//移动邮件到文件夹
void moveEmailFolder(EmailFolderMoveVo vo);
......@@ -91,7 +92,7 @@ public interface IEmailPersonService extends IService<EmailPerson> {
ResultVo getUserPolice();
//最近联系人
List<CustomerUserVo> recentlyContacts(List<Long> recentlySendEmail);
List<UserDto> recentlyContacts(List<Long> recentlySendEmail);
//
EmailPerson getByIdAndSendTime(Long personId, LocalDateTime sendTime);
......
......@@ -10,6 +10,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.admin.UserDto;
import com.zq.email.entity.EmailContent;
import com.zq.email.enums.EmailDegreeEnum;
import com.zq.email.enums.RemindEnum;
......@@ -183,16 +184,17 @@ public class EmailContentServiceImpl extends ServiceImpl<EmailContentMapper, Ema
}
@Override
public List<CustomerUserVo> findReceiverByContentId(Long contentId) {
List<CustomerUserVo> userVoList = new ArrayList<>();
public List<UserDto> findReceiverByContentId(Long contentId) {
List<UserDto> 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);
}
ResultVo<UserDto> userDtoResultVo = adminFeignClient.findById(Long.valueOf(userId));
log.error("findReceiverByContentId --> (userId = {"+userId+"}) 获取个人信息信息失败");
AssertUtils.isTrue(userDtoResultVo.isSuccess() && userDtoResultVo.getData()!=null, "获取个人信息失败!");
UserDto data = userDtoResultVo.getData();
userVoList.add(data);
}
}
......
......@@ -16,6 +16,7 @@ import com.zq.email.constants.EmailConstant;
import com.zq.email.dto.DeptSimpleDto;
import com.zq.email.dto.Person;
import com.zq.email.dto.SystemInfo;
import com.zq.email.dto.admin.UserDto;
import com.zq.email.entity.EmailAttach;
import com.zq.email.entity.EmailContent;
import com.zq.email.entity.EmailPerson;
......@@ -36,6 +37,7 @@ import com.zq.email.vo.api.ApiSendEmailVo;
import com.zq.email.vo.api.EmailEditApiVo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -64,6 +66,10 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
private final SmsUtil smsUtil;
private final MsgUtil msgUtil;
@Value("${spring.cloud.config.profile}")
private String profile;
@Override
public Integer emailCount(EmailReqVo vo) {
OnlineUserDto adminContext = TokenUtils.getAdminContext();
......@@ -119,6 +125,21 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
record.setEmailAttachList(this.emailAttachService.findByContentId(content.getId()));
record.setReceiverList(this.findReceiverByContentId(content.getId(), null));
}
//发送人头像
if (vo.getIsSenderPhoto()){
ResultVo<UserDto> senderVo = adminFeignClient.findById(content.getSendUserId());
if (senderVo.isSuccess() && senderVo.getData() !=null){
UserDto data = senderVo.getData();
UserDto userDto = new UserDto();
if (profile.contains("wan")) {
userDto.setPhoto(StrUtil.isNotBlank(data.getPhoto())?data.getPhoto().replace("http://147.1.3.87", "http://172.28.1.159:82"):data.getPhoto());
}else{
userDto.setPhoto(data.getPhoto());
}
record.setSender(userDto);
}
}
}
}
return page;
......@@ -152,12 +173,12 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
this.saveEmailSender(adminContext, content, folderId, vo.getIsSend());
//收件人
List<CustomerUserVo> receiverList = new ArrayList<>();
List<UserDto> receiverList = new ArrayList<>();
if (CollectionUtil.isNotEmpty(vo.getReceiver())) {
for (Long userId : vo.getReceiver()) {
CustomerUserVo receiver = this.adminFeignClient.getUserById(userId);
AssertUtils.notNull(receiver, "调用admin失败,根据userId获取人员接口异常");
receiverList.add(receiver);
ResultVo<UserDto> resultVo = this.adminFeignClient.findById(userId);
AssertUtils.isTrue(resultVo.isSuccess() && resultVo.getData()!=null, "调用admin失败,根据userId获取人员接口异常");
receiverList.add(resultVo.getData());
}
if (CollectionUtil.isNotEmpty(receiverList)){
......@@ -174,13 +195,10 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
}
//收件部门人员
List<CustomerUserVo> deptUserList = new ArrayList<>();
if (CollectionUtil.isNotEmpty(vo.getReceiveDeptList())) {
for (Long deptId : vo.getReceiveDeptList()) {
ResultVo<List<CustomerUserVo>> userByDeptId = adminFeignClient.getUserByDeptId(deptId);
AssertUtils.isTrue(userByDeptId.isSuccess(), "调用admin失败,根据deptId获取人员接口异常");
deptUserList.addAll(userByDeptId.getData());
}
ResultVo<List<UserDto>> byDeptIds = adminFeignClient.findByDeptIds(vo.getReceiveDeptList());
AssertUtils.isTrue(byDeptIds.isSuccess() && CollectionUtil.isNotEmpty(byDeptIds.getData()), "调用admin失败,根据deptId获取人员接口异常");
List<UserDto> deptUserList = byDeptIds.getData();
if (CollectionUtil.isNotEmpty(deptUserList)) {
//增加收件人
......@@ -245,11 +263,11 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
}
@Override
public void saveEmailReceiver(List<CustomerUserVo> receiverList, EmailContent content, Long folderId, Integer isPerson, Integer isSend) {
for (CustomerUserVo userVo : receiverList) {
public void saveEmailReceiver(List<UserDto> receiverList, EmailContent content, Long folderId, Integer isPerson, Integer isSend) {
for (UserDto userVo : receiverList) {
EmailPerson receivePerson = EmailPerson.builder()
.emailContentId(content.getId())
.userId(userVo.getUserId())
.userId(userVo.getId())
.userEmail(userVo.getUsername())
.userName(userVo.getNickName())
.deptId(userVo.getDeptId())
......@@ -709,10 +727,25 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
for (EmailPerson person : page.getRecords()) {
EmailContent content = this.emailContentService.getById(person.getEmailContentId());
person.setEmailContent(content);
if(vo.getFolderId().equals(EmailFolderEnum.FOLDER_ALREADY_SEND.getKey())){
person.setEmailAttachList(this.emailAttachService.findByContentId(content.getId()));
person.setReceiverList(this.findReceiverByContentId(content.getId(), null));
}
//发送人头像
if (vo.getIsSenderPhoto()){
ResultVo<UserDto> senderVo = adminFeignClient.findById(content.getSendUserId());
if (senderVo.isSuccess() && senderVo.getData() !=null){
UserDto data = senderVo.getData();
UserDto userDto = new UserDto();
if (profile.contains("wan")) {
userDto.setPhoto(StrUtil.isNotBlank(data.getPhoto())?data.getPhoto().replace("http://147.1.3.87", "http://172.28.1.159:82"):data.getPhoto());
}else{
userDto.setPhoto(data.getPhoto());
}
person.setSender(userDto);
}
}
}
}
return page;
......@@ -726,16 +759,19 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
}
@Override
public List<CustomerUserVo> recentlyContacts(List<Long> recentlySendEmail) {
List<CustomerUserVo> list = new ArrayList<>();
public List<UserDto> recentlyContacts(List<Long> recentlySendEmail) {
List<UserDto> list = new ArrayList<>();
if (CollectionUtil.isNotEmpty(recentlySendEmail)){
List<Person> personList = this.baseMapper.recentlyContacts(recentlySendEmail, EmailConstant.TYPE_EMAIL_RECEIVE, WhetherEnum.YES.getKey(), WhetherEnum.YES.getKey());
if (CollectionUtil.isNotEmpty(personList)){
for (Person person : personList) {
CustomerUserVo userById = this.adminFeignClient.getUserById(person.getId());
if (userById!=null){
list.add(userById);
}
ResultVo<UserDto> resultVo = this.adminFeignClient.findById(person.getId());
AssertUtils.isTrue(resultVo.isSuccess() && resultVo.getData()!=null, "调用admin失败,根据userId获取人员接口异常");
list.add(resultVo.getData());
// CustomerUserVo userById = this.adminFeignClient.findById(person.getId());
// if (userById!=null){
// list.add(userById);
// }
}
}
}
......@@ -766,94 +802,97 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
SystemInfo systemInfo = bySystemTag.getData();
AssertUtils.notNull(systemInfo, "调用admin服务异常,获取业务系统为空");
Set<CustomerUserVo> toUserSet = new LinkedHashSet<>();
Set<UserDto> toUserSet = new LinkedHashSet<>();
Set<Long> toUserIds= new LinkedHashSet<>();
ResultVo<CustomerUserVo> fromVo =adminFeignClient.getBypCode(emailVo.getFrom_id());
ResultVo<UserDto> fromVo = adminFeignClient.findByPCode(emailVo.getFrom_id());
AssertUtils.isTrue(fromVo.isSuccess() || fromVo.getData()!=null,"找不到发件人的门户信息");
ResultVo<CustomerUserVo> toVo =adminFeignClient.getBypCode(emailVo.getTo_id());
ResultVo<UserDto> toVo =adminFeignClient.findByPCode(emailVo.getTo_id());
AssertUtils.isTrue(toVo.isSuccess() || toVo.getData()!=null,"找不到收件人1的门户信息");
toUserIds.add(toVo.getData().getUserId());
toUserIds.add(toVo.getData().getId());
toUserSet.add(toVo.getData());
if(StrUtil.isNotBlank(emailVo.getTo_id2())){
ResultVo<CustomerUserVo> toVo2 =adminFeignClient.getBypCode(emailVo.getTo_id2());
ResultVo<UserDto> toVo2 = adminFeignClient.findByPCode(emailVo.getTo_id2());
AssertUtils.isTrue(toVo2.isSuccess() || toVo2.getData()!=null,"找不到收件人2的门户信息");
toUserIds.add(toVo2.getData().getUserId());
toUserIds.add(toVo2.getData().getId());
toUserSet.add(toVo2.getData());
}
EmailContent content = emailContentService.saveContentApi(emailVo, fromVo.getData(), new ArrayList<>(toUserIds));
this.saveEmailSender(fromVo.getData(), content, EmailFolderEnum.FOLDER_ALREADY_SEND.getKey().longValue(), WhetherEnum.YES.getKey());
//增加收件人
ArrayList<CustomerUserVo> toUserList = new ArrayList<>(toUserSet);
this.saveEmailReceiver(toUserList, content, EmailFolderEnum.FOLDER_INBOX.getKey().longValue(), WhetherEnum.YES.getKey(), WhetherEnum.YES.getKey());
//短信
//smsUtil.sendBatchSms(toUserList, "您有一封新的邮件,标题为《" + content.getTitle() + "》。请及时查收。", content.getId());
//代办
msgUtil.sendMsg(fromVo.getData().getNickName(), content, toUserList, systemInfo, EmailFolderEnum.FOLDER_INBOX.getKey());
return content;
// EmailContent content = emailContentService.saveContentApi(emailVo, fromVo.getData(), new ArrayList<>(toUserIds));
//
// this.saveEmailSender(fromVo.getData(), content, EmailFolderEnum.FOLDER_ALREADY_SEND.getKey().longValue(), WhetherEnum.YES.getKey());
// //增加收件人
// ArrayList<CustomerUserVo> toUserList = new ArrayList<>(toUserSet);
// this.saveEmailReceiver(toUserList, content, EmailFolderEnum.FOLDER_INBOX.getKey().longValue(), WhetherEnum.YES.getKey(), WhetherEnum.YES.getKey());
// //短信
// //smsUtil.sendBatchSms(toUserList, "您有一封新的邮件,标题为《" + content.getTitle() + "》。请及时查收。", content.getId());
// //代办
// msgUtil.sendMsg(fromVo.getData().getNickName(), content, toUserList, systemInfo, EmailFolderEnum.FOLDER_INBOX.getKey());
// return content;
return null;
}
@Override
public EmailContent sendEmailApi2(EmailEditApiVo vo) {
ResultVo<SystemInfo> bySystemTag = this.adminFeignClient.getBySystemTag(EmailConstant.SYSTEM_TAG);
AssertUtils.isTrue(bySystemTag.isSuccess(), "调用admin服务,获取业务系统异常");
SystemInfo systemInfo = bySystemTag.getData();
AssertUtils.notNull(systemInfo, "调用admin服务异常,获取业务系统为空");
CustomerUserVo formUser = adminFeignClient.getUserById(vo.getSender());
AssertUtils.notNull(formUser, "获取发送人失败:(sender="+vo.getSender()+")");
//邮件
EmailContent content = emailContentService.saveContentApi2(vo, formUser);
if (content !=null) {
//person,先删除
this.lambdaUpdate().eq(EmailPerson::getEmailContentId, content.getId()).remove();
//发件人
this.saveEmailSender(formUser, content,EmailFolderEnum.FOLDER_ALREADY_SEND.getKey().longValue(), WhetherEnum.YES.getKey());
//收件人
if (CollectionUtil.isNotEmpty(vo.getReceiver())) {
List<CustomerUserVo> receiverList = new ArrayList<>();
for (Long userId : vo.getReceiver()) {
CustomerUserVo receiver = this.adminFeignClient.getUserById(userId);
AssertUtils.notNull(receiver, "调用admin失败,根据userId获取人员接口异常");
receiverList.add(receiver);
}
if (CollectionUtil.isNotEmpty(receiverList)){
this.saveEmailReceiver(receiverList, content, EmailFolderEnum.FOLDER_INBOX.getKey().longValue(), WhetherEnum.YES.getKey(), WhetherEnum.YES.getKey());
if (vo.getIsSend().equals(WhetherEnum.YES.getKey()) && content.getSmsRemind().equals(WhetherEnum.YES.getKey())) {
smsUtil.sendBatchSms(receiverList, "您有一封新的邮件,标题为《" + content.getTitle() + "》。请及时查收。", content.getId());
}
if (vo.getIsSend().equals(WhetherEnum.YES.getKey()) && content.getMessageRemind().equals(WhetherEnum.YES.getKey())) {
msgUtil.sendMsg(formUser.getNickName(), content, receiverList, systemInfo, EmailFolderEnum.FOLDER_INBOX.getKey());
}
}
}
//收件部门人员
if (CollectionUtil.isNotEmpty(vo.getReceiveDeptList())) {
List<CustomerUserVo> deptUserList = new ArrayList<>();
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(deptUserList)){
this.saveEmailReceiver(deptUserList, content, EmailFolderEnum.FOLDER_DEPT_INBOX.getKey().longValue(), WhetherEnum.NO.getKey(), WhetherEnum.YES.getKey());
if (vo.getIsSend().equals(WhetherEnum.YES.getKey()) && content.getSmsRemind().equals(WhetherEnum.YES.getKey())) {
smsUtil.sendBatchSms(deptUserList, "您有一封新的邮件,标题为《" + content.getTitle() + "》。请及时查收。", content.getId());
}
if (vo.getIsSend().equals(WhetherEnum.YES.getKey()) && content.getMessageRemind().equals(WhetherEnum.YES.getKey())) {
msgUtil.sendMsg(formUser.getNickName(), content, deptUserList, systemInfo, EmailFolderEnum.FOLDER_DEPT_INBOX.getKey());
}
}
}
}
return content;
// ResultVo<SystemInfo> bySystemTag = this.adminFeignClient.getBySystemTag(EmailConstant.SYSTEM_TAG);
// AssertUtils.isTrue(bySystemTag.isSuccess(), "调用admin服务,获取业务系统异常");
// SystemInfo systemInfo = bySystemTag.getData();
// AssertUtils.notNull(systemInfo, "调用admin服务异常,获取业务系统为空");
//
// CustomerUserVo formUser = adminFeignClient.getUserById(vo.getSender());
// AssertUtils.notNull(formUser, "获取发送人失败:(sender="+vo.getSender()+")");
// //邮件
// EmailContent content = emailContentService.saveContentApi2(vo, formUser);
// if (content !=null) {
// //person,先删除
// this.lambdaUpdate().eq(EmailPerson::getEmailContentId, content.getId()).remove();
// //发件人
// this.saveEmailSender(formUser, content,EmailFolderEnum.FOLDER_ALREADY_SEND.getKey().longValue(), WhetherEnum.YES.getKey());
// //收件人
// if (CollectionUtil.isNotEmpty(vo.getReceiver())) {
// List<CustomerUserVo> receiverList = new ArrayList<>();
// for (Long userId : vo.getReceiver()) {
// CustomerUserVo receiver = this.adminFeignClient.getUserById(userId);
// AssertUtils.notNull(receiver, "调用admin失败,根据userId获取人员接口异常");
// receiverList.add(receiver);
// }
// if (CollectionUtil.isNotEmpty(receiverList)){
// this.saveEmailReceiver(receiverList, content, EmailFolderEnum.FOLDER_INBOX.getKey().longValue(), WhetherEnum.YES.getKey(), WhetherEnum.YES.getKey());
// if (vo.getIsSend().equals(WhetherEnum.YES.getKey()) && content.getSmsRemind().equals(WhetherEnum.YES.getKey())) {
// smsUtil.sendBatchSms(receiverList, "您有一封新的邮件,标题为《" + content.getTitle() + "》。请及时查收。", content.getId());
// }
// if (vo.getIsSend().equals(WhetherEnum.YES.getKey()) && content.getMessageRemind().equals(WhetherEnum.YES.getKey())) {
// msgUtil.sendMsg(formUser.getNickName(), content, receiverList, systemInfo, EmailFolderEnum.FOLDER_INBOX.getKey());
// }
// }
// }
//
// //收件部门人员
//
// if (CollectionUtil.isNotEmpty(vo.getReceiveDeptList())) {
// List<CustomerUserVo> deptUserList = new ArrayList<>();
// 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(deptUserList)){
// this.saveEmailReceiver(deptUserList, content, EmailFolderEnum.FOLDER_DEPT_INBOX.getKey().longValue(), WhetherEnum.NO.getKey(), WhetherEnum.YES.getKey());
// if (vo.getIsSend().equals(WhetherEnum.YES.getKey()) && content.getSmsRemind().equals(WhetherEnum.YES.getKey())) {
// smsUtil.sendBatchSms(deptUserList, "您有一封新的邮件,标题为《" + content.getTitle() + "》。请及时查收。", content.getId());
// }
// if (vo.getIsSend().equals(WhetherEnum.YES.getKey()) && content.getMessageRemind().equals(WhetherEnum.YES.getKey())) {
// msgUtil.sendMsg(formUser.getNickName(), content, deptUserList, systemInfo, EmailFolderEnum.FOLDER_DEPT_INBOX.getKey());
// }
// }
// }
// }
// return content;
return null;
}
@Override
......
......@@ -4,6 +4,7 @@ import cn.hutool.json.JSONUtil;
import com.zq.common.vo.CustomerUserVo;
import com.zq.email.constants.EmailConstant;
import com.zq.email.dto.SystemInfo;
import com.zq.email.dto.admin.UserDto;
import com.zq.email.entity.EmailContent;
import com.zq.email.feign.MessageFeignClient;
import lombok.extern.slf4j.Slf4j;
......@@ -30,14 +31,14 @@ public class MsgUtil {
//发送消息和代办
@Async
public void sendMsg(String sender, EmailContent content, List<CustomerUserVo> userVoList, SystemInfo systemInfo, Integer folderId) {
public void sendMsg(String sender, EmailContent content, List<UserDto> userVoList, 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", userVoList.stream().map(e->e.getUserId()).collect(Collectors.toList()));
params.put("userIdList", userVoList.stream().map(e->e.getId()).collect(Collectors.toList()));
params .put("businessId", content.getId());
params.put("jumpUrl", systemInfo.getHomeUrl() + "/#/detail?folderId="+folderId+"&contentId=" + content.getId());
log.debug("---发送内部消息打印内容: {}", JSONUtil.toJsonStr(params));
......
......@@ -10,6 +10,7 @@ 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.dto.admin.UserDto;
import com.zq.email.properties.SmsProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
......@@ -38,10 +39,10 @@ public class SmsUtil {
* @return
*/
@Async
public void sendBatchSms(List<CustomerUserVo> userVoList, String content, Long contentId) {
public void sendBatchSms(List<UserDto> userVoList, String content, Long contentId) {
String regex = "^1[3-9]\\d{9}";
StringBuffer sb = new StringBuffer();
for (CustomerUserVo userVo : userVoList) {
for (UserDto userVo : userVoList) {
if (userVo!=null && StrUtil.isNotBlank(userVo.getPhone()) && userVo.getPhone().matches(regex)){
sb.append(userVo.getPhone()).append(",");
}
......
package com.zq.email.vo;
import com.sun.org.apache.xpath.internal.operations.Bool;
import com.zq.common.vo.PageReqVo;
import com.zq.email.constants.EmailConstant;
import com.zq.email.enums.EmailFolderEnum;
......@@ -74,5 +75,7 @@ public class EmailReqVo extends PageReqVo {
private Integer searchRange = 0;
@ApiModelProperty("0未读 1已读")
private Integer isRead;
@ApiModelProperty("是否获取人员头像")
private Boolean isSenderPhoto = false;
}
......@@ -51,4 +51,8 @@ public class EmailSearchReqVo extends PageReqVo {
@ApiModelProperty("当前人员id :前端不用传")
private Long userId;
@ApiModelProperty("是否获取人员头像")
private Boolean isSenderPhoto = false;
}
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