Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
email
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陈天仲
email
Commits
0c02ac1e
Commit
0c02ac1e
authored
Mar 23, 2023
by
chentianzhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化代码和排版
parent
94cc4aa6
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
450 additions
and
472 deletions
+450
-472
src/main/java/com/zq/email/controller/EmailApiController.java
+7
-6
src/main/java/com/zq/email/controller/EmailAttachController.java
+15
-94
src/main/java/com/zq/email/controller/EmailController.java
+3
-29
src/main/java/com/zq/email/feign/MessageFeignClient.java
+6
-6
src/main/java/com/zq/email/service/IEmailAttachService.java
+5
-0
src/main/java/com/zq/email/service/IEmailContentService.java
+3
-1
src/main/java/com/zq/email/service/IEmailPersonService.java
+37
-0
src/main/java/com/zq/email/service/impl/EmailAttachServiceImpl.java
+78
-1
src/main/java/com/zq/email/service/impl/EmailContentServiceImpl.java
+34
-34
src/main/java/com/zq/email/service/impl/EmailPersonServiceImpl.java
+179
-301
src/main/java/com/zq/email/utils/MsgUtil.java
+81
-0
src/main/java/com/zq/email/utils/SmsUtil.java
+2
-0
No files found.
src/main/java/com/zq/email/controller/EmailApiController.java
View file @
0c02ac1e
...
@@ -30,6 +30,7 @@ import io.swagger.annotations.Api;
...
@@ -30,6 +30,7 @@ import io.swagger.annotations.Api;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
net.bytebuddy.asm.Advice
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
...
@@ -74,25 +75,25 @@ public class EmailApiController {
...
@@ -74,25 +75,25 @@ public class EmailApiController {
AssertUtils
.
isTrue
(
businessSystemService
.
checkSystemInfo
(
emailVo
),
"业务系统信息验证不通过"
);
AssertUtils
.
isTrue
(
businessSystemService
.
checkSystemInfo
(
emailVo
),
"业务系统信息验证不通过"
);
emailVo
.
setIp
(
clientIP
);
emailVo
.
setIp
(
clientIP
);
emailVo
.
setMethodName
(
"/email/api/sendEmail"
);
emailVo
.
setMethodName
(
"/email/api/sendEmail"
);
SysLog
sysLog
=
null
;
try
{
try
{
EmailContent
content
=
this
.
emailPersonService
.
sendEmailApi
(
emailVo
);
EmailContent
content
=
this
.
emailPersonService
.
sendEmailApi
(
emailVo
);
sysLog
=
sysLog
Service
.
insertSysLog
(
emailVo
);
sysLogService
.
insertSysLog
(
emailVo
);
return
ResultVo
.
success
(
content
.
getId
());
return
ResultVo
.
success
(
content
.
getId
());
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
emailVo
.
setExceptionDetails
(
e
.
getLocalizedMessage
());
emailVo
.
setExceptionDetails
(
e
.
getLocalizedMessage
());
sysLog
=
sysLogService
.
insertSysLog
(
emailVo
);
SysLog
sysLog
=
sysLogService
.
insertSysLog
(
emailVo
);
log
.
error
(
"邮件api接口(兼容旧)失败!!!!!"
);
log
.
error
(
"邮件api接口(兼容旧)失败!!!!!"
);
log
.
error
(
e
.
getLocalizedMessage
(),
e
);
log
.
error
(
e
.
getLocalizedMessage
(),
e
);
emailVo
.
setExceptionDetails
(
e
.
getLocalizedMessage
());
emailVo
.
setExceptionDetails
(
e
.
getLocalizedMessage
());
sysLogService
.
updateById
(
sysLog
);
return
ResultVo
.
fail
(
sysLog
.
getExceptionDetails
());
}
}
return
ResultVo
.
fail
(
sysLog
.
getExceptionDetails
());
}
}
@ApiOperation
(
"邮件api接口
(兼容旧)
"
)
@ApiOperation
(
"邮件api接口
新
"
)
@AnonymousPostMapping
(
"emailSend"
)
@AnonymousPostMapping
(
"emailSend"
)
public
ResultVo
emailSend
(
@RequestBody
EmailEditApiVo
vo
)
{
public
ResultVo
emailSend
(
@RequestBody
EmailEditApiVo
vo
)
{
AssertUtils
.
hasText
(
vo
.
getTitle
(),
"缺少参数title"
);
AssertUtils
.
hasText
(
vo
.
getTitle
(),
"缺少参数title"
);
...
...
src/main/java/com/zq/email/controller/EmailAttachController.java
View file @
0c02ac1e
...
@@ -2,8 +2,12 @@ package com.zq.email.controller;
...
@@ -2,8 +2,12 @@ package com.zq.email.controller;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.io.FileUtil
;
import
cn.hutool.core.io.IoUtil
;
import
cn.hutool.core.util.IdUtil
;
import
cn.hutool.core.util.IdUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.extra.servlet.ServletUtil
;
import
cn.hutool.http.HttpUtil
;
import
cn.hutool.http.HttpUtil
;
import
cn.hutool.json.JSONUtil
;
import
cn.hutool.json.JSONUtil
;
import
com.zq.common.annotation.AnonymousAccess
;
import
com.zq.common.annotation.AnonymousAccess
;
...
@@ -31,6 +35,7 @@ import org.springframework.web.bind.annotation.*;
...
@@ -31,6 +35,7 @@ import org.springframework.web.bind.annotation.*;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.ByteArrayOutputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.OutputStream
;
import
java.io.OutputStream
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.charset.StandardCharsets
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
@@ -52,8 +57,7 @@ public class EmailAttachController {
...
@@ -52,8 +57,7 @@ public class EmailAttachController {
private
final
IEmailAttachService
emailAttachService
;
private
final
IEmailAttachService
emailAttachService
;
private
final
FileFeignClient
fileFeignClient
;
private
final
FileFeignClient
fileFeignClient
;
@Value
(
"${spring.cloud.config.profile}"
)
private
String
profile
;
@ApiOperation
(
"获取附件"
)
@ApiOperation
(
"获取附件"
)
@PostMapping
@PostMapping
...
@@ -64,41 +68,18 @@ public class EmailAttachController {
...
@@ -64,41 +68,18 @@ public class EmailAttachController {
@ApiOperation
(
"下载附件"
)
@ApiOperation
(
"下载附件"
)
@AnonymousGetMapping
(
"/download/{id}"
)
@AnonymousGetMapping
(
"/download/{id}"
)
public
void
download
(
HttpServletRequest
request
,
HttpServletResponse
response
,
@PathVariable
(
"id"
)
Stri
ng
id
)
{
public
void
download
(
HttpServletRequest
request
,
HttpServletResponse
response
,
@PathVariable
(
"id"
)
Lo
ng
id
)
{
EmailAttach
emailAttach
=
emailAttachService
.
getById
(
id
);
EmailAttach
emailAttach
=
emailAttachService
.
getById
(
id
);
AssertUtils
.
notNull
(
emailAttach
,
"获取附件信息失败"
);
AssertUtils
.
notNull
(
emailAttach
,
"获取附件信息失败"
);
String
download
=
emailAttach
.
getDownloadPath
();
log
.
info
(
"文件下载地址1111:{}"
,
download
);
String
download
=
emailAttachService
.
getDownloadPath
(
emailAttach
);
if
(
StrUtil
.
isBlank
(
download
)){
String
year
=
DateUtil
.
format
(
emailAttach
.
getSendTime
(),
"yyyy"
);
String
yearMonth
=
DateUtil
.
format
(
emailAttach
.
getSendTime
(),
"yyyyMM"
);
String
yearMonthDate
=
DateUtil
.
format
(
emailAttach
.
getSendTime
(),
"yyyyMMdd"
);
String
path
=
"/"
+
year
+
"/"
+
yearMonth
+
"/"
+
yearMonthDate
+
"/"
+
emailAttach
.
getAttachId
()
+
"/"
+
emailAttach
.
getAttachName
();
if
(
profile
.
equals
(
"product"
)
||
profile
.
equals
(
"test"
))
{
download
=
"http://147.1.3.87/attwjsf_email"
+
path
;
}
else
if
(
profile
.
equals
(
"wanpro"
)
||
profile
.
equals
(
"wantest"
)){
download
=
"http://172.28.1.159:82/attwjsf_yj"
+
path
;
}
}
else
{
if
(
profile
.
equals
(
"wanpro"
)
||
profile
.
equals
(
"wantest"
))
{
download
.
replaceAll
(
"147.2.3.3"
,
"172.28.1.70"
);
}
}
log
.
info
(
"文件下载地址2222:{}"
,
download
);
AssertUtils
.
hasText
(
download
,
"下载地址为空"
);
AssertUtils
.
hasText
(
download
,
"下载地址为空"
);
ByteArrayOutputStream
outputStream
=
new
ByteArrayOutputStream
();
ByteArrayOutputStream
outputStream
=
new
ByteArrayOutputStream
();
try
{
try
{
OutputStream
os
=
response
.
getOutputStream
();
HttpUtil
.
download
(
download
,
outputStream
,
true
);
HttpUtil
.
download
(
download
,
outputStream
,
true
);
byte
[]
bytes
=
outputStream
.
toByteArray
();
byte
[]
bytes
=
outputStream
.
toByteArray
();
response
.
reset
();
ServletUtil
.
write
(
response
,
IoUtil
.
toStream
(
bytes
),
"application/octet-stream"
,
response
.
setContentType
(
"application/octet-stream"
);
new
String
(
emailAttach
.
getAttachName
().
getBytes
(
StandardCharsets
.
UTF_8
),
StandardCharsets
.
ISO_8859_1
));
response
.
addHeader
(
"Content-Disposition"
,
"attachment;filename="
+
new
String
(
emailAttach
.
getAttachName
().
getBytes
(
StandardCharsets
.
UTF_8
),
StandardCharsets
.
ISO_8859_1
));
response
.
addHeader
(
"Content-Length"
,
""
+
bytes
.
length
);
os
.
write
(
bytes
);
os
.
flush
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"下载文件失败:"
+
e
.
getLocalizedMessage
(),
e
);
log
.
error
(
"下载文件失败:"
+
e
.
getLocalizedMessage
(),
e
);
AssertUtils
.
isTrue
(
false
,
"网络异常,下载文件失败"
);
AssertUtils
.
isTrue
(
false
,
"网络异常,下载文件失败"
);
...
@@ -109,26 +90,8 @@ public class EmailAttachController {
...
@@ -109,26 +90,8 @@ public class EmailAttachController {
@ApiOperation
(
"返回附件下载地址"
)
@ApiOperation
(
"返回附件下载地址"
)
@GetMapping
(
"/downloadPath/{id}"
)
@GetMapping
(
"/downloadPath/{id}"
)
public
ResultVo
downloadPath
(
@PathVariable
(
"id"
)
String
id
)
{
public
ResultVo
downloadPath
(
@PathVariable
(
"id"
)
Long
id
)
{
EmailAttach
emailAttach
=
emailAttachService
.
getById
(
id
);
String
download
=
emailAttachService
.
getDownloadPath
(
id
);
AssertUtils
.
notNull
(
emailAttach
,
"获取附件信息失败"
);
String
download
=
emailAttach
.
getDownloadPath
();
log
.
info
(
"文件下载地址 downloadPath 1111:{}"
,
download
);
if
(
StrUtil
.
isBlank
(
download
))
{
String
year
=
DateUtil
.
format
(
emailAttach
.
getSendTime
(),
"yyyy"
);
String
yearMonth
=
DateUtil
.
format
(
emailAttach
.
getSendTime
(),
"yyyyMM"
);
String
yearMonthDate
=
DateUtil
.
format
(
emailAttach
.
getSendTime
(),
"yyyyMMdd"
);
String
path
=
"/"
+
year
+
"/"
+
yearMonth
+
"/"
+
yearMonthDate
+
"/"
+
emailAttach
.
getAttachId
()
+
"/"
+
emailAttach
.
getAttachName
();
if
(
profile
.
equals
(
"product"
)
||
profile
.
equals
(
"test"
))
{
download
=
"http://147.1.3.87/attwjsf_email"
+
path
;
}
else
if
(
profile
.
equals
(
"wanpro"
)
||
profile
.
equals
(
"wantest"
))
{
download
=
"http://172.28.1.159:82/attwjsf_yj"
+
path
;
}
}
else
{
if
(
profile
.
equals
(
"wanpro"
)
||
profile
.
equals
(
"wantest"
))
{
download
.
replaceAll
(
"147.2.3.3"
,
"172.28.1.70"
);
}
}
AssertUtils
.
hasText
(
download
,
"内部错误,获取下载地址空"
);
AssertUtils
.
hasText
(
download
,
"内部错误,获取下载地址空"
);
return
ResultVo
.
success
(
download
);
return
ResultVo
.
success
(
download
);
}
}
...
@@ -137,50 +100,8 @@ public class EmailAttachController {
...
@@ -137,50 +100,8 @@ public class EmailAttachController {
@ApiOperation
(
"wps预览"
)
@ApiOperation
(
"wps预览"
)
@GetMapping
(
"/viewFileByWps/{id}"
)
@GetMapping
(
"/viewFileByWps/{id}"
)
public
ResultVo
viewFileByWps
(
@PathVariable
(
"id"
)
String
id
)
{
public
ResultVo
viewFileByWps
(
@PathVariable
(
"id"
)
Long
id
)
{
OnlineUserDto
adminContext
=
TokenUtils
.
getAdminContext
();
return
ResultVo
.
success
(
emailAttachService
.
getWpsPreviewUrl
(
id
));
AssertUtils
.
notNull
(
adminContext
,
"登录已失效,请重新登录后再次尝试!"
);
EmailAttach
emailAttach
=
emailAttachService
.
getById
(
id
);
AssertUtils
.
notNull
(
emailAttach
,
"获取附件信息失败"
);
AssertUtils
.
notNull
(
emailAttach
.
getAttachName
(),
"附件名称为空"
);
String
suffix
=
emailAttach
.
getAttachName
().
substring
(
emailAttach
.
getAttachName
().
lastIndexOf
(
"."
)
+
1
);
String
download
=
emailAttach
.
getDownloadPath
();
log
.
info
(
"文件下载地址 downloadPath 1111:{}"
,
download
);
if
(
StrUtil
.
isBlank
(
download
))
{
String
year
=
DateUtil
.
format
(
emailAttach
.
getSendTime
(),
"yyyy"
);
String
yearMonth
=
DateUtil
.
format
(
emailAttach
.
getSendTime
(),
"yyyyMM"
);
String
yearMonthDate
=
DateUtil
.
format
(
emailAttach
.
getSendTime
(),
"yyyyMMdd"
);
String
path
=
"/"
+
year
+
"/"
+
yearMonth
+
"/"
+
yearMonthDate
+
"/"
+
emailAttach
.
getAttachId
()
+
"/"
+
emailAttach
.
getAttachName
();
if
(
profile
.
equals
(
"product"
)
||
profile
.
equals
(
"test"
))
{
download
=
"http://147.1.3.87/attwjsf_email"
+
path
;
}
else
if
(
profile
.
equals
(
"wanpro"
)
||
profile
.
equals
(
"wantest"
))
{
download
=
"http://172.28.1.159:82/attwjsf_yj"
+
path
;
}
}
else
{
if
(
profile
.
equals
(
"wanpro"
)
||
profile
.
equals
(
"wantest"
))
{
download
.
replaceAll
(
"147.2.3.3"
,
"172.28.1.70"
);
}
}
log
.
info
(
"文件下载地址 downloadPath 222:{}"
,
download
);
AssertUtils
.
hasText
(
download
,
"获取到的下载地址为空"
);
//调用文件服务wps
FileViewVo
viewVo
=
new
FileViewVo
();
viewVo
.
setFileId
(
IdUtil
.
fastSimpleUUID
());
viewVo
.
setDownloadPath
(
download
);
viewVo
.
setFileType
(
suffix
);
viewVo
.
setFileName
(
emailAttach
.
getAttachName
());
viewVo
.
setUserId
(
String
.
valueOf
(
adminContext
.
getUserId
()));
ResultVo
<
String
>
resultVo
=
fileFeignClient
.
getViewUrlByDownloadPath
(
viewVo
);
log
.
info
(
"中台返回结果:"
+
JSONUtil
.
toJsonStr
(
resultVo
));
String
linkUrl
=
""
;
if
(
resultVo
.
isSuccess
()
&&
StrUtil
.
isNotBlank
(
resultVo
.
getData
())){
linkUrl
=
resultVo
.
getData
();
}
AssertUtils
.
hasText
(
linkUrl
,
"调用wps组件失败,失败原因("
+
resultVo
.
getErrMsg
()+
")"
);
return
ResultVo
.
success
(
linkUrl
);
}
}
...
...
src/main/java/com/zq/email/controller/EmailController.java
View file @
0c02ac1e
...
@@ -4,7 +4,6 @@ package com.zq.email.controller;
...
@@ -4,7 +4,6 @@ package com.zq.email.controller;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.collection.CollectionUtil
;
import
com.zq.common.utils.AssertUtils
;
import
com.zq.common.utils.AssertUtils
;
import
com.zq.common.utils.TokenUtils
;
import
com.zq.common.utils.TokenUtils
;
import
com.zq.common.vo.CustomerUserVo
;
import
com.zq.common.vo.OnlineUserDto
;
import
com.zq.common.vo.OnlineUserDto
;
import
com.zq.common.vo.ResultVo
;
import
com.zq.common.vo.ResultVo
;
import
com.zq.email.entity.EmailContent
;
import
com.zq.email.entity.EmailContent
;
...
@@ -18,16 +17,11 @@ import io.swagger.annotations.Api;
...
@@ -18,16 +17,11 @@ import io.swagger.annotations.Api;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.core.io.InputStreamResource
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
javax.mail.MessagingException
;
import
javax.mail.internet.MimeMessage
;
import
javax.mail.internet.MimeMessage
;
import
javax.servlet.ServletOutputStream
;
import
javax.servlet.ServletOutputStream
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.FileOutputStream
;
import
java.io.InputStream
;
import
java.util.List
;
import
java.util.List
;
/**
/**
...
@@ -107,33 +101,13 @@ public class EmailController {
...
@@ -107,33 +101,13 @@ public class EmailController {
AssertUtils
.
notNull
(
adminContext
,
"登录已失效,请重新登录后再次尝试!"
);
AssertUtils
.
notNull
(
adminContext
,
"登录已失效,请重新登录后再次尝试!"
);
AssertUtils
.
notNull
(
vo
.
getContentId
(),
"缺少参数:contentId"
);
AssertUtils
.
notNull
(
vo
.
getContentId
(),
"缺少参数:contentId"
);
EmailContent
content
=
emailContentService
.
getById
(
vo
.
getContentId
());
EmailContent
content
=
emailContentService
.
getById
(
vo
.
getContentId
());
AssertUtils
.
notNull
(
content
,
"获取邮件内容失败"
);
AssertUtils
.
notNull
(
content
,
"邮件内容读取失败"
);
EmailPerson
emailPerson
=
emailPersonService
.
getByIdAndSendTime
(
vo
.
getPersonId
(),
content
.
getSendTime
());
EmailPerson
emailPerson
=
emailPersonService
.
getByContentAndFolderId
(
content
.
getId
(),
content
.
getSendTime
(),
vo
.
getFolderId
());
AssertUtils
.
notNull
(
emailPerson
,
"获取邮件对应人员信息失败"
);
AssertUtils
.
notNull
(
emailPerson
,
"邮件人员信息不匹配"
);
AssertUtils
.
isTrue
(
emailPerson
.
getUserId
().
equals
(
adminContext
.
getUserId
())
,
"非本人邮件,不允许阅读"
);
emailPerson
.
setEmailContent
(
content
);
emailPerson
.
setEmailContent
(
content
);
return
ResultVo
.
success
(
emailPerson
);
return
ResultVo
.
success
(
emailPerson
);
}
}
// @ApiOperation("回复")
// @PostMapping("reply")
// public ResultVo reply(@RequestBody EmailEditVo vo) {
// AssertUtils.hasText(vo.getTitle(), "缺少参数:title");
// AssertUtils.notNull(vo.getIsSend(), "缺少参数: isSend");
// AssertUtils.isTrue(CollectionUtil.isNotEmpty(vo.getReceiver()) || CollectionUtil.isNotEmpty(vo.getReceiver()), "缺少参数:receiver和 receiveDeptList");
// emailPersonService.emailEditVo(vo);
// return ResultVo.success();
// }
//
// @ApiOperation("转发")
// @PostMapping("forward")
// public ResultVo forward(@RequestBody EmailEditVo vo) {
// AssertUtils.hasText(vo.getTitle(), "缺少参数:title");
// AssertUtils.notNull(vo.getIsSend(), "缺少参数: isSend");
// AssertUtils.isTrue(CollectionUtil.isNotEmpty(vo.getReceiver()) || CollectionUtil.isNotEmpty(vo.getReceiver()), "缺少参数:receiver和 receiveDeptList");
// emailPersonService.emailEditVo(vo);
// return ResultVo.success();
// }
@ApiOperation
(
"收件箱彻底删除"
)
@ApiOperation
(
"收件箱彻底删除"
)
@PostMapping
(
"delete"
)
@PostMapping
(
"delete"
)
...
...
src/main/java/com/zq/email/feign/MessageFeignClient.java
View file @
0c02ac1e
...
@@ -20,8 +20,8 @@ public interface MessageFeignClient {
...
@@ -20,8 +20,8 @@ public interface MessageFeignClient {
* @param param
* @param param
* @return
* @return
*/
*/
@PostMapping
(
"/web/send"
)
@PostMapping
(
"/web/send
Api
"
)
ResultVo
send
WebMessage
(
@RequestBody
Map
<
String
,
Object
>
param
);
ResultVo
send
Api
(
@RequestBody
Map
<
String
,
Object
>
param
);
/**
/**
* 新增待办事宜
* 新增待办事宜
...
@@ -32,8 +32,8 @@ public interface MessageFeignClient {
...
@@ -32,8 +32,8 @@ public interface MessageFeignClient {
* @param params content - 待办内容 - 必传
* @param params content - 待办内容 - 必传
* @return
* @return
*/
*/
@PostMapping
(
"/todo/addToDo"
)
@PostMapping
(
"/todo/addToDo
Api
"
)
ResultVo
addToDo
(
@RequestBody
Map
<
String
,
Object
>
params
);
ResultVo
addToDo
Api
(
@RequestBody
Map
<
String
,
Object
>
params
);
/**
/**
* 撤回网页消息
* 撤回网页消息
...
@@ -42,7 +42,7 @@ public interface MessageFeignClient {
...
@@ -42,7 +42,7 @@ public interface MessageFeignClient {
* @param params
* @param params
* @return
* @return
*/
*/
@DeleteMapping
(
"/web/
delMessageBySystem
"
)
@DeleteMapping
(
"/web/
revokeWebBySysInfo
"
)
ResultVo
revokeWebBySysInfo
(
@RequestBody
Map
<
String
,
Object
>
params
);
ResultVo
revokeWebBySysInfo
(
@RequestBody
Map
<
String
,
Object
>
params
);
/**
/**
...
@@ -52,7 +52,7 @@ public interface MessageFeignClient {
...
@@ -52,7 +52,7 @@ public interface MessageFeignClient {
* @param params
* @param params
* @return
* @return
*/
*/
@DeleteMapping
(
"/todo/
delMessageBySystem
"
)
@DeleteMapping
(
"/todo/
revokeTodoBySysInfo
"
)
ResultVo
revokeTodoBySysInfo
(
@RequestBody
Map
<
String
,
Object
>
params
);
ResultVo
revokeTodoBySysInfo
(
@RequestBody
Map
<
String
,
Object
>
params
);
}
}
src/main/java/com/zq/email/service/IEmailAttachService.java
View file @
0c02ac1e
...
@@ -24,4 +24,9 @@ public interface IEmailAttachService extends IService<EmailAttach> {
...
@@ -24,4 +24,9 @@ public interface IEmailAttachService extends IService<EmailAttach> {
List
<
EmailAttach
>
findByContentId
(
Long
contentId
);
List
<
EmailAttach
>
findByContentId
(
Long
contentId
);
String
getDownloadPath
(
Long
id
);
String
getDownloadPath
(
EmailAttach
emailAttach
);
String
getWpsPreviewUrl
(
Long
id
);
}
}
src/main/java/com/zq/email/service/IEmailContentService.java
View file @
0c02ac1e
...
@@ -27,6 +27,8 @@ public interface IEmailContentService extends IService<EmailContent> {
...
@@ -27,6 +27,8 @@ public interface IEmailContentService extends IService<EmailContent> {
EmailContent
saveContentApi
(
ApiSendEmailVo
emailVo
,
CustomerUserVo
data
,
List
<
Long
>
receiveIds
);
EmailContent
saveContentApi
(
ApiSendEmailVo
emailVo
,
CustomerUserVo
data
,
List
<
Long
>
receiveIds
);
EmailContent
saveContentApi2
(
EmailEditApiVo
vo
,
CustomerUserVo
formUser
);
void
setTaskEmail
(
EmailTaskVo
vo
);
void
setTaskEmail
(
EmailTaskVo
vo
);
void
setDegreeEmail
(
EmailDegreeVo
vo
);
void
setDegreeEmail
(
EmailDegreeVo
vo
);
...
@@ -37,5 +39,5 @@ public interface IEmailContentService extends IService<EmailContent> {
...
@@ -37,5 +39,5 @@ public interface IEmailContentService extends IService<EmailContent> {
List
<
Long
>
findRecentlySendEmail
(
Integer
num
);
List
<
Long
>
findRecentlySendEmail
(
Integer
num
);
EmailContent
saveContent
(
EmailEditApiVo
vo
,
CustomerUserVo
formUser
);
}
}
src/main/java/com/zq/email/service/IEmailPersonService.java
View file @
0c02ac1e
...
@@ -2,6 +2,7 @@ package com.zq.email.service;
...
@@ -2,6 +2,7 @@ package com.zq.email.service;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.zq.common.vo.CustomerUserVo
;
import
com.zq.common.vo.CustomerUserVo
;
import
com.zq.common.vo.OnlineUserDto
;
import
com.zq.common.vo.ResultVo
;
import
com.zq.common.vo.ResultVo
;
import
com.zq.email.entity.EmailContent
;
import
com.zq.email.entity.EmailContent
;
import
com.zq.email.entity.EmailPerson
;
import
com.zq.email.entity.EmailPerson
;
...
@@ -24,37 +25,61 @@ import java.util.List;
...
@@ -24,37 +25,61 @@ import java.util.List;
*/
*/
public
interface
IEmailPersonService
extends
IService
<
EmailPerson
>
{
public
interface
IEmailPersonService
extends
IService
<
EmailPerson
>
{
//邮件分页总数
Integer
emailCount
(
EmailReqVo
vo
);
Integer
emailCount
(
EmailReqVo
vo
);
//邮件分页列表
Page
<
EmailPerson
>
emailPage
(
EmailReqVo
vo
);
Page
<
EmailPerson
>
emailPage
(
EmailReqVo
vo
);
//写邮件
EmailContent
emailEditVo
(
EmailEditVo
vo
);
EmailContent
emailEditVo
(
EmailEditVo
vo
);
//保存发件人1
EmailPerson
saveEmailSender
(
OnlineUserDto
userDto
,
EmailContent
content
,
Long
folderId
,
Integer
isSend
);
//保存发件人2
EmailPerson
saveEmailSender
(
CustomerUserVo
userVo
,
EmailContent
content
,
Long
folderId
,
Integer
isSend
);
//保存收件人
void
saveEmailReceiver
(
List
<
CustomerUserVo
>
receiverList
,
EmailContent
content
,
Long
folderId
,
Integer
isPerson
,
Integer
isSend
);
//移动邮件到文件夹
void
moveEmailFolder
(
EmailFolderMoveVo
vo
);
void
moveEmailFolder
(
EmailFolderMoveVo
vo
);
//邮件接收人列表
List
<
EmailPerson
>
findReceiverByContentId
(
Long
contentId
);
List
<
EmailPerson
>
findReceiverByContentId
(
Long
contentId
);
//邮件接收人列表(包含回复邮件)
List
<
EmailPerson
>
findTaskEmailByContentId
(
Long
contentId
);
List
<
EmailPerson
>
findTaskEmailByContentId
(
Long
contentId
);
//全部已读
void
readAllEmails
(
Long
folderId
);
void
readAllEmails
(
Long
folderId
);
//已读
void
readEmail
(
EmailReadVo
vo
);
void
readEmail
(
EmailReadVo
vo
);
//删除已读(移动到回收站)
void
readToBin
(
Long
folderId
);
void
readToBin
(
Long
folderId
);
//删除已读(生成EML文件)
MimeMessage
emlFile
(
Long
contentId
);
MimeMessage
emlFile
(
Long
contentId
);
//删除所有收件人已删除邮件
void
deleteAllReceiverDelete
();
void
deleteAllReceiverDelete
();
//删除所有收件人未读邮件
void
deleteAllReceiverUnread
();
void
deleteAllReceiverUnread
();
// 0上一封 1下一封
// 0上一封 1下一封
EmailPerson
lastAndAfterEmail
(
EmailLastAndAfterReqVo
vo
,
Integer
type
);
EmailPerson
lastAndAfterEmail
(
EmailLastAndAfterReqVo
vo
,
Integer
type
);
//邮件撤回
void
recallPerson
(
EmailSendVo
vo
);
void
recallPerson
(
EmailSendVo
vo
);
//邮件撤回(发件箱列表撤回使用,如果该邮件存在收件人已读无法撤回)
void
recallEmail
(
Long
contentId
);
void
recallEmail
(
Long
contentId
);
//回收站恢复(列表)
void
resumeEmail
(
List
<
Long
>
personIdList
);
void
resumeEmail
(
List
<
Long
>
personIdList
);
Integer
searchTotal
(
EmailSearchReqVo
vo
);
Integer
searchTotal
(
EmailSearchReqVo
vo
);
...
@@ -64,13 +89,25 @@ public interface IEmailPersonService extends IService<EmailPerson> {
...
@@ -64,13 +89,25 @@ public interface IEmailPersonService extends IService<EmailPerson> {
//当前部门的人员
//当前部门的人员
ResultVo
getUserPolice
();
ResultVo
getUserPolice
();
//最近联系人
List
<
CustomerUserVo
>
recentlyContacts
(
List
<
Long
>
recentlySendEmail
);
List
<
CustomerUserVo
>
recentlyContacts
(
List
<
Long
>
recentlySendEmail
);
//
EmailPerson
getByIdAndSendTime
(
Long
personId
,
LocalDateTime
sendTime
);
EmailPerson
getByIdAndSendTime
(
Long
personId
,
LocalDateTime
sendTime
);
//移动邮件到自定义文件夹或回收站
void
moveDetailEmailFolder
(
EmailDetailVo
vo
);
void
moveDetailEmailFolder
(
EmailDetailVo
vo
);
/**
* 法意接口发送短信
* **/
EmailContent
sendEmailApi
(
ApiSendEmailVo
emailVo
);
EmailContent
sendEmailApi
(
ApiSendEmailVo
emailVo
);
/**
* 其他接口使用
* **/
EmailContent
sendEmailApi2
(
EmailEditApiVo
vo
);
EmailContent
sendEmailApi2
(
EmailEditApiVo
vo
);
//根据content和文件夹获取person
EmailPerson
getByContentAndFolderId
(
Long
contentId
,
LocalDateTime
sendTime
,
Long
folderId
);
}
}
src/main/java/com/zq/email/service/impl/EmailAttachServiceImpl.java
View file @
0c02ac1e
...
@@ -2,6 +2,9 @@ package com.zq.email.service.impl;
...
@@ -2,6 +2,9 @@ package com.zq.email.service.impl;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.util.IdUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.json.JSONUtil
;
import
com.zq.common.utils.AssertUtils
;
import
com.zq.common.utils.AssertUtils
;
import
com.zq.common.utils.TokenUtils
;
import
com.zq.common.utils.TokenUtils
;
import
com.zq.common.vo.*
;
import
com.zq.common.vo.*
;
...
@@ -13,8 +16,10 @@ import com.zq.email.mapper.EmailAttachMapper;
...
@@ -13,8 +16,10 @@ import com.zq.email.mapper.EmailAttachMapper;
import
com.zq.email.service.IEmailAttachService
;
import
com.zq.email.service.IEmailAttachService
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.zq.email.vo.EmailEditVo
;
import
com.zq.email.vo.EmailEditVo
;
import
com.zq.email.vo.
api.EmailEditApi
Vo
;
import
com.zq.email.vo.
FileView
Vo
;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
...
@@ -31,9 +36,12 @@ import java.util.List;
...
@@ -31,9 +36,12 @@ import java.util.List;
*/
*/
@Service
@Service
@RequiredArgsConstructor
@RequiredArgsConstructor
@Slf4j
public
class
EmailAttachServiceImpl
extends
ServiceImpl
<
EmailAttachMapper
,
EmailAttach
>
implements
IEmailAttachService
{
public
class
EmailAttachServiceImpl
extends
ServiceImpl
<
EmailAttachMapper
,
EmailAttach
>
implements
IEmailAttachService
{
private
final
FileFeignClient
fileFeignClient
;
private
final
FileFeignClient
fileFeignClient
;
@Value
(
"${spring.cloud.config.profile}"
)
private
String
profile
;
@Override
@Override
public
void
saveAttach
(
EmailEditVo
vo
,
EmailContent
content
)
{
public
void
saveAttach
(
EmailEditVo
vo
,
EmailContent
content
)
{
...
@@ -92,5 +100,74 @@ public class EmailAttachServiceImpl extends ServiceImpl<EmailAttachMapper, Email
...
@@ -92,5 +100,74 @@ public class EmailAttachServiceImpl extends ServiceImpl<EmailAttachMapper, Email
return
this
.
lambdaQuery
().
eq
(
EmailAttach:
:
getEmailContentId
,
contentId
).
orderByAsc
(
EmailAttach:
:
getId
).
list
();
return
this
.
lambdaQuery
().
eq
(
EmailAttach:
:
getEmailContentId
,
contentId
).
orderByAsc
(
EmailAttach:
:
getId
).
list
();
}
}
@Override
public
String
getDownloadPath
(
Long
id
)
{
EmailAttach
emailAttach
=
this
.
getById
(
id
);
AssertUtils
.
notNull
(
emailAttach
,
"获取附件信息失败"
);
String
download
=
emailAttach
.
getDownloadPath
();
if
(
StrUtil
.
isBlank
(
download
)){
String
year
=
DateUtil
.
format
(
emailAttach
.
getSendTime
(),
"yyyy"
);
String
yearMonth
=
DateUtil
.
format
(
emailAttach
.
getSendTime
(),
"yyyyMM"
);
String
yearMonthDate
=
DateUtil
.
format
(
emailAttach
.
getSendTime
(),
"yyyyMMdd"
);
String
path
=
"/"
+
year
+
"/"
+
yearMonth
+
"/"
+
yearMonthDate
+
"/"
+
emailAttach
.
getAttachId
()
+
"/"
+
emailAttach
.
getAttachName
();
if
(
profile
.
equals
(
"product"
)
||
profile
.
equals
(
"test"
))
{
download
=
"http://147.1.3.87/attwjsf_email"
+
path
;
}
else
if
(
profile
.
equals
(
"wanpro"
)
||
profile
.
equals
(
"wantest"
)){
download
=
"http://172.28.1.159:82/attwjsf_yj"
+
path
;
}
}
else
{
if
(
profile
.
equals
(
"wanpro"
)
||
profile
.
equals
(
"wantest"
))
{
download
.
replaceAll
(
"147.2.3.3"
,
"172.28.1.70"
);
}
}
return
download
;
}
@Override
public
String
getDownloadPath
(
EmailAttach
emailAttach
)
{
String
download
=
emailAttach
.
getDownloadPath
();
if
(
StrUtil
.
isBlank
(
download
)){
String
year
=
DateUtil
.
format
(
emailAttach
.
getSendTime
(),
"yyyy"
);
String
yearMonth
=
DateUtil
.
format
(
emailAttach
.
getSendTime
(),
"yyyyMM"
);
String
yearMonthDate
=
DateUtil
.
format
(
emailAttach
.
getSendTime
(),
"yyyyMMdd"
);
String
path
=
"/"
+
year
+
"/"
+
yearMonth
+
"/"
+
yearMonthDate
+
"/"
+
emailAttach
.
getAttachId
()
+
"/"
+
emailAttach
.
getAttachName
();
if
(
profile
.
equals
(
"product"
)
||
profile
.
equals
(
"test"
))
{
download
=
"http://147.1.3.87/attwjsf_email"
+
path
;
}
else
if
(
profile
.
equals
(
"wanpro"
)
||
profile
.
equals
(
"wantest"
)){
download
=
"http://172.28.1.159:82/attwjsf_yj"
+
path
;
}
}
else
{
if
(
profile
.
equals
(
"wanpro"
)
||
profile
.
equals
(
"wantest"
))
{
download
.
replaceAll
(
"147.2.3.3"
,
"172.28.1.70"
);
}
}
return
download
;
}
@Override
public
String
getWpsPreviewUrl
(
Long
id
)
{
OnlineUserDto
adminContext
=
TokenUtils
.
getAdminContext
();
AssertUtils
.
notNull
(
adminContext
,
"登录已失效,请重新登录后再次尝试!"
);
EmailAttach
emailAttach
=
this
.
getById
(
id
);
AssertUtils
.
notNull
(
emailAttach
,
"获取附件信息失败"
);
AssertUtils
.
hasText
(
emailAttach
.
getAttachName
(),
"附件名称为空"
);
String
downloadPath
=
this
.
getDownloadPath
(
emailAttach
);
String
suffix
=
emailAttach
.
getAttachName
().
substring
(
emailAttach
.
getAttachName
().
lastIndexOf
(
"."
)
+
1
);
AssertUtils
.
hasText
(
suffix
,
"错误的文件名称("
+
emailAttach
.
getAttachName
()+
"),导致获取文件类型失败"
);
FileViewVo
viewVo
=
new
FileViewVo
();
viewVo
.
setFileId
(
IdUtil
.
fastSimpleUUID
());
viewVo
.
setDownloadPath
(
downloadPath
);
viewVo
.
setFileType
(
suffix
);
viewVo
.
setFileName
(
emailAttach
.
getAttachName
());
viewVo
.
setUserId
(
String
.
valueOf
(
adminContext
.
getUserId
()));
ResultVo
<
String
>
resultVo
=
fileFeignClient
.
getViewUrlByDownloadPath
(
viewVo
);
log
.
info
(
"中台预览文件返回结果: {}"
,
JSONUtil
.
toJsonStr
(
resultVo
));
AssertUtils
.
isTrue
(
resultVo
.
isSuccess
()
&&
StrUtil
.
isNotBlank
(
resultVo
.
getData
()),
"调用wps组件失败:("
+
resultVo
.
getErrMsg
()+
")"
);
return
resultVo
.
getData
();
}
}
}
src/main/java/com/zq/email/service/impl/EmailContentServiceImpl.java
View file @
0c02ac1e
...
@@ -106,7 +106,7 @@ public class EmailContentServiceImpl extends ServiceImpl<EmailContentMapper, Ema
...
@@ -106,7 +106,7 @@ public class EmailContentServiceImpl extends ServiceImpl<EmailContentMapper, Ema
content
.
setSendUserEmail
(
data
.
getUsername
());
content
.
setSendUserEmail
(
data
.
getUsername
());
content
.
setSendUserName
(
data
.
getNickName
());
content
.
setSendUserName
(
data
.
getNickName
());
content
.
setSendTime
(
LocalDateTime
.
now
());
content
.
setSendTime
(
LocalDateTime
.
now
());
content
.
setIsTask
(
WhetherEnum
.
YES
.
getKey
());
content
.
setIsTask
(
WhetherEnum
.
NO
.
getKey
());
content
.
setSmsRemind
(
WhetherEnum
.
NO
.
getKey
());
content
.
setSmsRemind
(
WhetherEnum
.
NO
.
getKey
());
content
.
setMessageRemind
(
WhetherEnum
.
NO
.
getKey
());
content
.
setMessageRemind
(
WhetherEnum
.
NO
.
getKey
());
...
@@ -123,6 +123,39 @@ public class EmailContentServiceImpl extends ServiceImpl<EmailContentMapper, Ema
...
@@ -123,6 +123,39 @@ public class EmailContentServiceImpl extends ServiceImpl<EmailContentMapper, Ema
}
}
@Override
@Override
public
EmailContent
saveContentApi2
(
EmailEditApiVo
vo
,
CustomerUserVo
formUser
)
{
EmailContent
content
=
new
EmailContent
();
content
.
setTitle
(
vo
.
getTitle
());
content
.
setContent
(
vo
.
getContent
());
content
.
setDegree
(
vo
.
getDegree
());
content
.
setSendUserId
(
formUser
.
getUserId
());
content
.
setSendUserEmail
(
formUser
.
getUsername
());
content
.
setSendUserName
(
formUser
.
getNickName
());
content
.
setSendTime
(
LocalDateTime
.
now
());
content
.
setIsTask
(
vo
.
getIsTask
());
content
.
setSmsRemind
(
vo
.
getIsSmsRemind
());
content
.
setMessageRemind
(
vo
.
getIsMessageRemind
());
if
(
CollectionUtil
.
isNotEmpty
(
vo
.
getReceiver
())){
StringBuffer
r
=
new
StringBuffer
();
for
(
Long
userId
:
vo
.
getReceiver
())
{
r
.
append
(
userId
).
append
(
","
);
}
content
.
setUserList
(
r
.
toString
());
}
if
(
CollectionUtil
.
isNotEmpty
(
vo
.
getReceiveDeptList
())){
StringBuffer
sb
=
new
StringBuffer
();
for
(
Long
deptId
:
vo
.
getReceiveDeptList
())
{
sb
.
append
(
deptId
).
append
(
","
);
}
content
.
setDeptList
(
sb
.
toString
());
}
this
.
saveOrUpdate
(
content
);
return
content
;
}
@Override
public
void
setTaskEmail
(
EmailTaskVo
vo
)
{
public
void
setTaskEmail
(
EmailTaskVo
vo
)
{
this
.
lambdaUpdate
().
in
(
EmailContent:
:
getId
,
vo
.
getContentId
()).
set
(
EmailContent:
:
getIsTask
,
vo
.
getIsTask
()).
update
();
this
.
lambdaUpdate
().
in
(
EmailContent:
:
getId
,
vo
.
getContentId
()).
set
(
EmailContent:
:
getIsTask
,
vo
.
getIsTask
()).
update
();
}
}
...
@@ -187,37 +220,4 @@ public class EmailContentServiceImpl extends ServiceImpl<EmailContentMapper, Ema
...
@@ -187,37 +220,4 @@ public class EmailContentServiceImpl extends ServiceImpl<EmailContentMapper, Ema
return
list
;
return
list
;
}
}
@Override
public
EmailContent
saveContent
(
EmailEditApiVo
vo
,
CustomerUserVo
formUser
)
{
EmailContent
content
=
new
EmailContent
();
content
.
setTitle
(
vo
.
getTitle
());
content
.
setContent
(
vo
.
getContent
());
content
.
setDegree
(
vo
.
getDegree
());
content
.
setSendUserId
(
formUser
.
getUserId
());
content
.
setSendUserEmail
(
formUser
.
getUsername
());
content
.
setSendUserName
(
formUser
.
getNickName
());
content
.
setSendTime
(
LocalDateTime
.
now
());
content
.
setIsTask
(
WhetherEnum
.
YES
.
getKey
());
content
.
setSmsRemind
(
WhetherEnum
.
NO
.
getKey
());
content
.
setMessageRemind
(
WhetherEnum
.
NO
.
getKey
());
if
(
CollectionUtil
.
isNotEmpty
(
vo
.
getReceiver
())){
StringBuffer
r
=
new
StringBuffer
();
for
(
Long
userId
:
vo
.
getReceiver
())
{
r
.
append
(
userId
).
append
(
","
);
}
content
.
setUserList
(
r
.
toString
());
}
if
(
CollectionUtil
.
isNotEmpty
(
vo
.
getReceiveDeptList
())){
StringBuffer
sb
=
new
StringBuffer
();
for
(
Long
deptId
:
vo
.
getReceiveDeptList
())
{
sb
.
append
(
deptId
).
append
(
","
);
}
content
.
setDeptList
(
sb
.
toString
());
}
this
.
saveOrUpdate
(
content
);
return
content
;
}
}
}
src/main/java/com/zq/email/service/impl/EmailPersonServiceImpl.java
View file @
0c02ac1e
package
com
.
zq
.
email
.
service
.
impl
;
package
com
.
zq
.
email
.
service
.
impl
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.collection.ListUtil
;
import
cn.hutool.core.io.FileUtil
;
import
cn.hutool.core.io.file.FileWriter
;
import
cn.hutool.core.util.IdUtil
;
import
cn.hutool.core.util.StrUtil
;
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.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.zq.common.utils.AssertUtils
;
import
com.zq.common.utils.AssertUtils
;
import
com.zq.common.utils.TokenUtils
;
import
com.zq.common.utils.TokenUtils
;
import
com.zq.common.vo.CustomerUserVo
;
import
com.zq.common.vo.CustomerUserVo
;
import
com.zq.common.vo.OnlineUserDto
;
import
com.zq.common.vo.OnlineUserDto
;
import
com.zq.common.vo.ResultVo
;
import
com.zq.common.vo.ResultVo
;
import
com.zq.email.config.MyThreadPoolTaskExecutor
;
import
com.zq.email.constants.EmailConstant
;
import
com.zq.email.constants.EmailConstant
;
import
com.zq.email.dto.DeptDto
;
import
com.zq.email.dto.DeptSimpleDto
;
import
com.zq.email.dto.Person
;
import
com.zq.email.dto.Person
;
import
com.zq.email.dto.SystemInfo
;
import
com.zq.email.dto.SystemInfo
;
import
com.zq.email.entity.EmailAttach
;
import
com.zq.email.entity.EmailAttach
;
import
com.zq.email.entity.EmailContent
;
import
com.zq.email.entity.EmailContent
;
import
com.zq.email.entity.EmailFolder
;
import
com.zq.email.entity.EmailPerson
;
import
com.zq.email.entity.EmailPerson
;
import
com.zq.email.enums.EmailDegreeEnum
;
import
com.zq.email.enums.EmailFolderEnum
;
import
com.zq.email.enums.EmailFolderEnum
;
import
com.zq.email.enums.WhetherEnum
;
import
com.zq.email.enums.WhetherEnum
;
import
com.zq.email.feign.AdminFeignClient
;
import
com.zq.email.feign.AdminFeignClient
;
import
com.zq.email.feign.MessageFeignClient
;
import
com.zq.email.mapper.EmailPersonMapper
;
import
com.zq.email.mapper.EmailPersonMapper
;
import
com.zq.email.service.IEmailAttachService
;
import
com.zq.email.service.IEmailAttachService
;
import
com.zq.email.service.IEmailContentService
;
import
com.zq.email.service.IEmailContentService
;
...
@@ -38,42 +25,18 @@ import com.zq.email.service.IEmailPersonService;
...
@@ -38,42 +25,18 @@ import com.zq.email.service.IEmailPersonService;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.zq.email.utils.DateUtils
;
import
com.zq.email.utils.DateUtils
;
import
com.zq.email.utils.EmailUtil
;
import
com.zq.email.utils.EmailUtil
;
import
com.zq.email.utils.MsgUtil
;
import
com.zq.email.utils.SmsUtil
;
import
com.zq.email.utils.SmsUtil
;
import
com.zq.email.vo.*
;
import
com.zq.email.vo.*
;
import
com.zq.email.vo.api.ApiSendEmailVo
;
import
com.zq.email.vo.api.ApiSendEmailVo
;
import
com.zq.email.vo.api.EmailEditApiVo
;
import
com.zq.email.vo.api.EmailEditApiVo
;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.codec.binary.Base64
;
import
org.springframework.core.io.FileSystemResource
;
import
org.springframework.core.io.InputStreamResource
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.security.core.parameters.P
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
import
javax.activation.DataHandler
;
import
javax.activation.DataSource
;
import
javax.activation.FileDataSource
;
import
javax.activation.URLDataSource
;
import
javax.mail.Message
;
import
javax.mail.Multipart
;
import
javax.mail.Session
;
import
javax.mail.Session
;
import
javax.mail.internet.InternetAddress
;
import
javax.mail.internet.MimeBodyPart
;
import
javax.mail.internet.MimeMessage
;
import
javax.mail.internet.MimeMessage
;
import
javax.mail.internet.MimeMultipart
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.InputStream
;
import
java.net.URL
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.util.*
;
import
java.util.*
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
/**
/**
* <p>
* <p>
...
@@ -91,8 +54,8 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
...
@@ -91,8 +54,8 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
private
final
IEmailContentService
emailContentService
;
private
final
IEmailContentService
emailContentService
;
private
final
IEmailAttachService
emailAttachService
;
private
final
IEmailAttachService
emailAttachService
;
private
final
AdminFeignClient
adminFeignClient
;
private
final
AdminFeignClient
adminFeignClient
;
private
final
MessageFeignClient
messageFeignClient
;
private
final
SmsUtil
smsUtil
;
private
final
SmsUtil
smsUtil
;
private
final
MsgUtil
msgUtil
;
@Override
@Override
public
Integer
emailCount
(
EmailReqVo
vo
)
{
public
Integer
emailCount
(
EmailReqVo
vo
)
{
...
@@ -136,8 +99,10 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
...
@@ -136,8 +99,10 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
queryWrapper
.
ge
(
EmailPerson:
:
getSendTime
,
DateUtils
.
getRangeStart
(
vo
.
getSearchRange
()));
queryWrapper
.
ge
(
EmailPerson:
:
getSendTime
,
DateUtils
.
getRangeStart
(
vo
.
getSearchRange
()));
queryWrapper
.
le
(
EmailPerson:
:
getSendTime
,
LocalDateTime
.
now
());
queryWrapper
.
le
(
EmailPerson:
:
getSendTime
,
LocalDateTime
.
now
());
}
}
queryWrapper
.
orderByDesc
(
EmailPerson:
:
getSendTime
).
orderByAsc
(
EmailPerson:
:
getIsRead
);
queryWrapper
.
orderByAsc
(
EmailPerson:
:
getIsRead
).
orderByDesc
(
EmailPerson:
:
getSendTime
);
page
=
this
.
page
(
page
,
queryWrapper
);
page
=
this
.
page
(
page
,
queryWrapper
);
if
(
page
!=
null
&&
CollectionUtil
.
isNotEmpty
(
page
.
getRecords
())){
if
(
page
!=
null
&&
CollectionUtil
.
isNotEmpty
(
page
.
getRecords
())){
for
(
EmailPerson
record
:
page
.
getRecords
())
{
for
(
EmailPerson
record
:
page
.
getRecords
())
{
EmailContent
byId
=
this
.
emailContentService
.
getById
(
record
.
getEmailContentId
());
EmailContent
byId
=
this
.
emailContentService
.
getById
(
record
.
getEmailContentId
());
...
@@ -150,8 +115,14 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
...
@@ -150,8 +115,14 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
@Override
@Override
public
EmailContent
emailEditVo
(
EmailEditVo
vo
)
{
public
EmailContent
emailEditVo
(
EmailEditVo
vo
)
{
OnlineUserDto
adminContext
=
TokenUtils
.
getAdminContext
();
OnlineUserDto
adminContext
=
TokenUtils
.
getAdminContext
();
AssertUtils
.
notNull
(
adminContext
,
"登录已失效,请重新登录后再次尝试!"
);
AssertUtils
.
notNull
(
adminContext
,
"登录已失效,请重新登录后再次尝试!"
);
//获取代办前端路径
ResultVo
<
SystemInfo
>
bySystemTag
=
this
.
adminFeignClient
.
getBySystemTag
(
EmailConstant
.
SYSTEM_TAG
);
AssertUtils
.
isTrue
(
bySystemTag
.
isSuccess
(),
"调用admin服务,获取业务系统异常"
);
SystemInfo
systemInfo
=
bySystemTag
.
getData
();
AssertUtils
.
notNull
(
systemInfo
,
"调用admin服务异常,获取业务系统为空"
);
//邮件
//邮件
EmailContent
content
=
emailContentService
.
saveContent
(
vo
,
adminContext
);
EmailContent
content
=
emailContentService
.
saveContent
(
vo
,
adminContext
);
if
(
content
!=
null
)
{
if
(
content
!=
null
)
{
...
@@ -160,7 +131,8 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
...
@@ -160,7 +131,8 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
//person,先删除
//person,先删除
this
.
lambdaUpdate
().
eq
(
EmailPerson:
:
getEmailContentId
,
content
.
getId
()).
remove
();
this
.
lambdaUpdate
().
eq
(
EmailPerson:
:
getEmailContentId
,
content
.
getId
()).
remove
();
//发件人
//发件人
this
.
saveEmailSender
(
adminContext
,
content
,
vo
);
long
folderId
=
vo
.
getIsSend
().
equals
(
WhetherEnum
.
YES
.
getKey
())
?
EmailFolderEnum
.
FOLDER_ALREADY_SEND
.
getKey
().
longValue
()
:
EmailFolderEnum
.
FOLDER_OUTBOX
.
getKey
().
longValue
();
this
.
saveEmailSender
(
adminContext
,
content
,
folderId
,
vo
.
getIsSend
());
//vo.getIsSend() == 1就发送
//vo.getIsSend() == 1就发送
if
(
vo
.
getIsSend
()!=
null
&&
vo
.
getIsSend
().
equals
(
WhetherEnum
.
YES
.
getKey
()))
{
if
(
vo
.
getIsSend
()!=
null
&&
vo
.
getIsSend
().
equals
(
WhetherEnum
.
YES
.
getKey
()))
{
...
@@ -173,9 +145,15 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
...
@@ -173,9 +145,15 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
receiverList
.
add
(
receiver
);
receiverList
.
add
(
receiver
);
}
}
if
(
CollectionUtil
.
isNotEmpty
(
receiverList
)){
this
.
saveEmailReceiver
(
receiverList
,
content
,
EmailFolderEnum
.
FOLDER_INBOX
.
getKey
().
longValue
(),
WhetherEnum
.
YES
.
getKey
(),
WhetherEnum
.
YES
.
getKey
());
//发送短信
smsUtil
.
sendBatchSms
(
receiverList
,
"您有一封新的邮件,标题为《"
+
content
.
getTitle
()
+
"》。请及时查收。"
,
content
.
getId
());
//代办
msgUtil
.
sendMsg
(
content
,
receiverList
,
systemInfo
);
}
}
}
//收件部门人员
//收件部门人员
List
<
CustomerUserVo
>
deptUserList
=
new
ArrayList
<>();
List
<
CustomerUserVo
>
deptUserList
=
new
ArrayList
<>();
if
(
CollectionUtil
.
isNotEmpty
(
vo
.
getReceiveDeptList
()))
{
if
(
CollectionUtil
.
isNotEmpty
(
vo
.
getReceiveDeptList
()))
{
...
@@ -184,32 +162,17 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
...
@@ -184,32 +162,17 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
AssertUtils
.
isTrue
(
userByDeptId
.
isSuccess
(),
"调用admin失败,根据deptId获取人员接口异常"
);
AssertUtils
.
isTrue
(
userByDeptId
.
isSuccess
(),
"调用admin失败,根据deptId获取人员接口异常"
);
deptUserList
.
addAll
(
userByDeptId
.
getData
());
deptUserList
.
addAll
(
userByDeptId
.
getData
());
}
}
}
if
(
CollectionUtil
.
isNotEmpty
(
receiverList
))
{
//增加收件人
this
.
saveEmailReceiver
(
receiverList
,
content
,
vo
);
//短信
if
(
content
.
getSmsRemind
()!=
null
&&
content
.
getSmsRemind
()
==
1
)
{
new
Thread
(()
->
{
smsUtil
.
sendBatchSms
(
receiverList
,
"您有一封新的邮件,标题为《"
+
content
.
getTitle
()
+
"》。请及时查收。"
,
content
.
getId
());
}).
start
();
}
}
if
(
CollectionUtil
.
isNotEmpty
(
deptUserList
)){
//增加收件人
if
(
CollectionUtil
.
isNotEmpty
(
deptUserList
))
{
this
.
saveEmailReceiver
(
deptUserList
,
content
,
EmailFolderEnum
.
FOLDER_DEPT_INBOX
.
getKey
().
longValue
(),
WhetherEnum
.
NO
.
getKey
(),
WhetherEnum
.
YES
.
getKey
());
//增加收件部门
//短信
this
.
saveEmailReceiveDept
(
deptUserList
,
content
,
vo
);
//短信
if
(
content
.
getSmsRemind
()!=
null
&&
content
.
getSmsRemind
()
==
1
)
{
new
Thread
(()
->
{
smsUtil
.
sendBatchSms
(
deptUserList
,
"您有一封新的邮件,标题为《"
+
content
.
getTitle
()
+
"》。请及时查收。"
,
content
.
getId
());
smsUtil
.
sendBatchSms
(
deptUserList
,
"您有一封新的邮件,标题为《"
+
content
.
getTitle
()
+
"》。请及时查收。"
,
content
.
getId
());
}).
start
();
//代办
msgUtil
.
sendMsg
(
content
,
deptUserList
,
systemInfo
);
}
}
}
}
}
}
}
}
...
@@ -218,6 +181,71 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
...
@@ -218,6 +181,71 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
}
}
@Override
@Override
public
EmailPerson
saveEmailSender
(
OnlineUserDto
userDto
,
EmailContent
content
,
Long
folderId
,
Integer
isSend
)
{
EmailPerson
sender
=
EmailPerson
.
builder
()
.
emailContentId
(
content
.
getId
())
.
userId
(
userDto
.
getUserId
())
.
userEmail
(
userDto
.
getUserName
())
.
userName
(
userDto
.
getNickName
())
.
deptId
(
userDto
.
getDeptId
())
.
courtCode
(
userDto
.
getCourtCode
())
.
personType
(
EmailConstant
.
TYPE_EMAIL_SEND
)
.
sendTime
(
content
.
getSendTime
())
.
folderId
(
folderId
)
.
isRead
(
WhetherEnum
.
YES
.
getKey
())
.
isPerson
(
WhetherEnum
.
YES
.
getKey
())
.
isTask
(
content
.
getIsTask
())
.
isSend
(
isSend
)
.
build
();
this
.
save
(
sender
);
return
sender
;
}
@Override
public
EmailPerson
saveEmailSender
(
CustomerUserVo
userVo
,
EmailContent
content
,
Long
folderId
,
Integer
isSend
)
{
EmailPerson
sender
=
EmailPerson
.
builder
()
.
emailContentId
(
content
.
getId
())
.
userId
(
userVo
.
getUserId
())
.
userEmail
(
userVo
.
getUsername
())
.
userName
(
userVo
.
getNickName
())
.
deptId
(
userVo
.
getDeptId
())
.
courtCode
(
userVo
.
getCourtCode
())
.
personType
(
EmailConstant
.
TYPE_EMAIL_SEND
)
.
sendTime
(
content
.
getSendTime
())
.
folderId
(
folderId
)
.
isRead
(
WhetherEnum
.
YES
.
getKey
())
.
isPerson
(
WhetherEnum
.
YES
.
getKey
())
.
isTask
(
content
.
getIsTask
())
.
isSend
(
isSend
)
.
build
();
this
.
save
(
sender
);
return
sender
;
}
@Override
public
void
saveEmailReceiver
(
List
<
CustomerUserVo
>
receiverList
,
EmailContent
content
,
Long
folderId
,
Integer
isPerson
,
Integer
isSend
)
{
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
(
folderId
)
.
isRead
(
WhetherEnum
.
NO
.
getKey
())
.
isPerson
(
isPerson
)
.
isTask
(
content
.
getIsTask
())
.
isSend
(
isSend
)
.
build
();
this
.
save
(
receivePerson
);
}
}
@Override
public
void
moveEmailFolder
(
EmailFolderMoveVo
vo
)
{
public
void
moveEmailFolder
(
EmailFolderMoveVo
vo
)
{
List
<
EmailPerson
>
list
=
List
<
EmailPerson
>
list
=
this
.
lambdaQuery
()
this
.
lambdaQuery
()
...
@@ -230,21 +258,7 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
...
@@ -230,21 +258,7 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
person
.
setOldFolderId
(
person
.
getFolderId
());
person
.
setOldFolderId
(
person
.
getFolderId
());
person
.
setFolderId
(
vo
.
getFolderId
());
person
.
setFolderId
(
vo
.
getFolderId
());
}
}
this
.
updateBatchById
(
list
);
this
.
updateBatchById
(
list
);
// List<EmailPerson> personList = this.lambdaQuery()
// .ge(EmailPerson::getSendTime, DateUtils.getRangeStart(vo.getSearchRange()))
// .le(EmailPerson::getSendTime, LocalDateTime.now())
// .in(EmailPerson::getId, vo.getPersonIdList()).list();
// for (EmailPerson emailPerson : personList) {
// Long folderId = emailPerson.getFolderId();
// LocalDateTime sendTime = emailPerson.getSendTime();
// this.lambdaUpdate().eq(EmailPerson::getSendTime, sendTime)
// .eq(EmailPerson::getId, emailPerson.getId())
// .set(EmailPerson::getFolderId, vo.getFolderId())
// .set(EmailPerson::getOldFolderId, folderId).update();
// }
}
}
@Override
@Override
...
@@ -290,8 +304,6 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
...
@@ -290,8 +304,6 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
@Override
@Override
public
void
readEmail
(
EmailReadVo
vo
)
{
public
void
readEmail
(
EmailReadVo
vo
)
{
// List<EmailPerson> personList = new ArrayList<>();
// LocalDateTime rangeStart = DateUtils.getRangeStart(vo.getSearchRange());
this
.
lambdaUpdate
()
this
.
lambdaUpdate
()
.
ge
(
EmailPerson:
:
getSendTime
,
DateUtils
.
getRangeStart
(
vo
.
getSearchRange
()))
.
ge
(
EmailPerson:
:
getSendTime
,
DateUtils
.
getRangeStart
(
vo
.
getSearchRange
()))
.
le
(
EmailPerson:
:
getSendTime
,
LocalDateTime
.
now
())
.
le
(
EmailPerson:
:
getSendTime
,
LocalDateTime
.
now
())
...
@@ -429,34 +441,17 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
...
@@ -429,34 +441,17 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
}
}
}
}
return
null
;
return
null
;
}
}
@Override
@Override
public
void
recallPerson
(
EmailSendVo
vo
){
public
void
recallPerson
(
EmailSendVo
vo
){
this
.
lambdaUpdate
()
List
<
EmailPerson
>
personList
=
this
.
lambdaQuery
().
in
(
EmailPerson:
:
getId
,
vo
.
getPersonIdList
()).
list
();
.
in
(
EmailPerson:
:
getId
,
vo
.
getPersonIdList
())
for
(
EmailPerson
person
:
personList
)
{
.
set
(
EmailPerson:
:
getIsSend
,
vo
.
getIsSend
())
person
.
setIsSend
(
vo
.
getIsSend
());
.
update
();
this
.
updateById
(
person
);
msgUtil
.
revokeMsgByBusinessIdAndReceiverId
(
person
.
getEmailContentId
(),
person
.
getUserId
());
for
(
Long
id
:
vo
.
getPersonIdList
())
{
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"systemTag"
,
EmailConstant
.
SYSTEM_TAG
);
params
.
put
(
"businessId"
,
id
);
log
.
info
(
"撤回消息提醒: {}"
,
JSONUtil
.
toJsonStr
(
params
));
ResultVo
resultVo
=
messageFeignClient
.
revokeWebBySysInfo
(
params
);
log
.
info
(
"sendWebMessage: {}"
+
JSONUtil
.
toJsonStr
(
resultVo
));
ResultVo
resultVo1
=
messageFeignClient
.
revokeTodoBySysInfo
(
params
);
log
.
info
(
"addToDo: {}"
+
JSONUtil
.
toJsonStr
(
resultVo1
));
}
}
}
}
@Override
@Override
...
@@ -487,19 +482,7 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
...
@@ -487,19 +482,7 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
.
eq
(
EmailPerson:
:
getPersonType
,
EmailConstant
.
TYPE_EMAIL_SEND
)
.
eq
(
EmailPerson:
:
getPersonType
,
EmailConstant
.
TYPE_EMAIL_SEND
)
.
set
(
EmailPerson:
:
getFolderId
,
EmailFolderEnum
.
FOLDER_OUTBOX
.
getKey
())
.
set
(
EmailPerson:
:
getFolderId
,
EmailFolderEnum
.
FOLDER_OUTBOX
.
getKey
())
.
set
(
EmailPerson:
:
getIsSend
,
WhetherEnum
.
NO
.
getKey
()).
update
();
.
set
(
EmailPerson:
:
getIsSend
,
WhetherEnum
.
NO
.
getKey
()).
update
();
msgUtil
.
revokeMsgByBusinessId
(
contentId
);
//撤回消息和代办
for
(
EmailPerson
person
:
personList
)
{
this
.
removeById
(
person
.
getId
());
//删除收件人
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"systemTag"
,
EmailConstant
.
SYSTEM_TAG
);
params
.
put
(
"businessId"
,
person
.
getId
());
log
.
info
(
"撤回消息提醒: {}"
,
JSONUtil
.
toJsonStr
(
params
));
ResultVo
resultVo
=
messageFeignClient
.
revokeWebBySysInfo
(
params
);
log
.
info
(
"sendWebMessage: {}"
+
JSONUtil
.
toJsonStr
(
resultVo
));
ResultVo
resultVo1
=
messageFeignClient
.
revokeTodoBySysInfo
(
params
);
log
.
info
(
"addToDo: {}"
+
JSONUtil
.
toJsonStr
(
resultVo1
));
}
}
}
@Override
@Override
...
@@ -657,259 +640,154 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
...
@@ -657,259 +640,154 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
@Override
@Override
public
EmailContent
sendEmailApi
(
ApiSendEmailVo
emailVo
)
{
public
EmailContent
sendEmailApi
(
ApiSendEmailVo
emailVo
)
{
Set
<
CustomerUserVo
>
toUserList
=
new
LinkedHashSet
<>();
//获取代办前端路径
ResultVo
<
SystemInfo
>
bySystemTag
=
this
.
adminFeignClient
.
getBySystemTag
(
EmailConstant
.
SYSTEM_TAG
);
AssertUtils
.
isTrue
(
bySystemTag
.
isSuccess
(),
"调用admin服务,获取业务系统异常"
);
SystemInfo
systemInfo
=
bySystemTag
.
getData
();
AssertUtils
.
notNull
(
systemInfo
,
"调用admin服务异常,获取业务系统为空"
);
Set
<
CustomerUserVo
>
toUserSet
=
new
LinkedHashSet
<>();
Set
<
Long
>
toUserIds
=
new
LinkedHashSet
<>();
Set
<
Long
>
toUserIds
=
new
LinkedHashSet
<>();
ResultVo
<
CustomerUserVo
>
fromVo
=
adminFeignClient
.
getBypCode
(
emailVo
.
getFrom_id
());
ResultVo
<
CustomerUserVo
>
fromVo
=
adminFeignClient
.
getBypCode
(
emailVo
.
getFrom_id
());
AssertUtils
.
isTrue
(
fromVo
.
isSuccess
()
||
fromVo
.
getData
()!=
null
,
"找不到发件人的门户信息"
);
AssertUtils
.
isTrue
(
fromVo
.
isSuccess
()
||
fromVo
.
getData
()!=
null
,
"找不到发件人的门户信息"
);
ResultVo
<
CustomerUserVo
>
toVo
=
adminFeignClient
.
getBypCode
(
emailVo
.
getTo_id
());
ResultVo
<
CustomerUserVo
>
toVo
=
adminFeignClient
.
getBypCode
(
emailVo
.
getTo_id
());
AssertUtils
.
isTrue
(
toVo
.
isSuccess
()
||
toVo
.
getData
()!=
null
,
"找不到收件人1的门户信息"
);
AssertUtils
.
isTrue
(
toVo
.
isSuccess
()
||
toVo
.
getData
()!=
null
,
"找不到收件人1的门户信息"
);
toUserIds
.
add
(
toVo
.
getData
().
getUserId
());
toUserIds
.
add
(
toVo
.
getData
().
getUserId
());
toUser
Lis
t
.
add
(
toVo
.
getData
());
toUser
Se
t
.
add
(
toVo
.
getData
());
if
(
StrUtil
.
isNotBlank
(
emailVo
.
getTo_id2
())){
if
(
StrUtil
.
isNotBlank
(
emailVo
.
getTo_id2
())){
ResultVo
<
CustomerUserVo
>
toVo2
=
adminFeignClient
.
getBypCode
(
emailVo
.
getTo_id2
());
ResultVo
<
CustomerUserVo
>
toVo2
=
adminFeignClient
.
getBypCode
(
emailVo
.
getTo_id2
());
AssertUtils
.
isTrue
(
toVo2
.
isSuccess
()
||
toVo2
.
getData
()!=
null
,
"找不到收件人2的门户信息"
);
AssertUtils
.
isTrue
(
toVo2
.
isSuccess
()
||
toVo2
.
getData
()!=
null
,
"找不到收件人2的门户信息"
);
toUserIds
.
add
(
toVo2
.
getData
().
getUserId
());
toUserIds
.
add
(
toVo2
.
getData
().
getUserId
());
toUser
Lis
t
.
add
(
toVo2
.
getData
());
toUser
Se
t
.
add
(
toVo2
.
getData
());
}
}
EmailContent
content
=
emailContentService
.
saveContentApi
(
emailVo
,
fromVo
.
getData
(),
new
ArrayList
<>(
toUserIds
));
EmailContent
content
=
emailContentService
.
saveContentApi
(
emailVo
,
fromVo
.
getData
(),
new
ArrayList
<>(
toUserIds
));
this
.
saveEmailSender
Api
(
fromVo
.
getData
(),
content
);
this
.
saveEmailSender
(
fromVo
.
getData
(),
content
,
EmailFolderEnum
.
FOLDER_ALREADY_SEND
.
getKey
().
longValue
(),
WhetherEnum
.
YES
.
getKey
()
);
//增加收件人
//增加收件人
EmailEditVo
vo
=
EmailEditVo
.
builder
().
isTask
(
WhetherEnum
.
NO
.
getKey
())
ArrayList
<
CustomerUserVo
>
toUserList
=
new
ArrayList
<>(
toUserSet
);
.
isSend
(
WhetherEnum
.
YES
.
getKey
()).
build
();
this
.
saveEmailReceiver
(
toUserList
,
content
,
EmailFolderEnum
.
FOLDER_INBOX
.
getKey
().
longValue
(),
WhetherEnum
.
YES
.
getKey
(),
WhetherEnum
.
YES
.
getKey
());
this
.
saveEmailReceiver
(
new
ArrayList
<>(
toUserList
),
content
,
vo
);
//短信
//短信
if
(
content
.
getSmsRemind
()!=
null
&&
content
.
getSmsRemind
()
==
1
)
{
smsUtil
.
sendBatchSms
(
toUserList
,
"您有一封新的邮件,标题为《"
+
content
.
getTitle
()
+
"》。请及时查收。"
,
content
.
getId
());
new
Thread
(()
->
{
//代办
smsUtil
.
sendBatchSms
(
new
ArrayList
<>(
toUserList
),
"您有一封新的邮件,标题为《"
+
content
.
getTitle
()
+
"》。请及时查收。"
,
content
.
getId
());
msgUtil
.
sendMsg
(
content
,
toUserList
,
systemInfo
);
}).
start
();
}
return
content
;
return
content
;
}
}
@Override
@Override
public
EmailContent
sendEmailApi2
(
EmailEditApiVo
vo
)
{
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
());
CustomerUserVo
formUser
=
adminFeignClient
.
getUserById
(
vo
.
getSender
());
AssertUtils
.
notNull
(
formUser
,
"获取发送人失败:(sender="
+
vo
.
getSender
()+
")"
);
AssertUtils
.
notNull
(
formUser
,
"获取发送人失败:(sender="
+
vo
.
getSender
()+
")"
);
//邮件
//邮件
EmailContent
content
=
emailContentService
.
saveContent
(
vo
,
formUser
);
EmailContent
content
=
emailContentService
.
saveContent
Api2
(
vo
,
formUser
);
if
(
content
!=
null
)
{
if
(
content
!=
null
)
{
//附件
//person,先删除
//person,先删除
this
.
lambdaUpdate
().
eq
(
EmailPerson:
:
getEmailContentId
,
content
.
getId
()).
remove
();
this
.
lambdaUpdate
().
eq
(
EmailPerson:
:
getEmailContentId
,
content
.
getId
()).
remove
();
//发件人
//发件人
this
.
saveEmailSenderApi
(
formUser
,
content
);
this
.
saveEmailSender
(
formUser
,
content
,
EmailFolderEnum
.
FOLDER_ALREADY_SEND
.
getKey
().
longValue
(),
WhetherEnum
.
YES
.
getKey
());
//vo.getIsSend() == 1就发送
//收件人
//收件人
List
<
CustomerUserVo
>
receiverList
=
new
ArrayList
<>();
if
(
CollectionUtil
.
isNotEmpty
(
vo
.
getReceiver
()))
{
if
(
CollectionUtil
.
isNotEmpty
(
vo
.
getReceiver
()))
{
List
<
CustomerUserVo
>
receiverList
=
new
ArrayList
<>();
for
(
Long
userId
:
vo
.
getReceiver
())
{
for
(
Long
userId
:
vo
.
getReceiver
())
{
CustomerUserVo
receiver
=
this
.
adminFeignClient
.
getUserById
(
userId
);
CustomerUserVo
receiver
=
this
.
adminFeignClient
.
getUserById
(
userId
);
AssertUtils
.
notNull
(
receiver
,
"调用admin失败,根据userId获取人员接口异常"
);
AssertUtils
.
notNull
(
receiver
,
"调用admin失败,根据userId获取人员接口异常"
);
receiverList
.
add
(
receiver
);
receiverList
.
add
(
receiver
);
}
}
if
(
CollectionUtil
.
isNotEmpty
(
receiverList
)){
smsUtil
.
sendBatchSms
(
receiverList
,
"您有一封新的邮件,标题为《"
+
content
.
getTitle
()
+
"》。请及时查收。"
,
content
.
getId
());
msgUtil
.
sendMsg
(
content
,
receiverList
,
systemInfo
);
}
}
}
//收件部门人员
//收件部门人员
List
<
CustomerUserVo
>
deptUserList
=
new
ArrayList
<>();
if
(
CollectionUtil
.
isNotEmpty
(
vo
.
getReceiveDeptList
()))
{
if
(
CollectionUtil
.
isNotEmpty
(
vo
.
getReceiveDeptList
()))
{
List
<
CustomerUserVo
>
deptUserList
=
new
ArrayList
<>();
for
(
Long
deptId
:
vo
.
getReceiveDeptList
())
{
for
(
Long
deptId
:
vo
.
getReceiveDeptList
())
{
ResultVo
<
List
<
CustomerUserVo
>>
userByDeptId
=
adminFeignClient
.
getUserByDeptId
(
deptId
);
ResultVo
<
List
<
CustomerUserVo
>>
userByDeptId
=
adminFeignClient
.
getUserByDeptId
(
deptId
);
AssertUtils
.
isTrue
(
userByDeptId
.
isSuccess
(),
"调用admin失败,根据deptId获取人员接口异常"
);
AssertUtils
.
isTrue
(
userByDeptId
.
isSuccess
(),
"调用admin失败,根据deptId获取人员接口异常"
);
deptUserList
.
addAll
(
userByDeptId
.
getData
());
deptUserList
.
addAll
(
userByDeptId
.
getData
());
}
}
}
EmailEditVo
emailEditVo
=
EmailEditVo
.
builder
().
isTask
(
content
.
getIsTask
())
.
isSend
(
WhetherEnum
.
YES
.
getKey
()).
build
();
if
(
CollectionUtil
.
isNotEmpty
(
receiverList
))
{
if
(
CollectionUtil
.
isNotEmpty
(
deptUserList
)){
//增加收件人
smsUtil
.
sendBatchSms
(
deptUserList
,
"您有一封新的邮件,标题为《"
+
content
.
getTitle
()
+
"》。请及时查收。"
,
content
.
getId
());
this
.
saveEmailReceiver
(
receiverList
,
content
,
emailEditVo
);
msgUtil
.
sendMsg
(
content
,
deptUserList
,
systemInfo
);
//短信
if
(
content
.
getSmsRemind
()!=
null
&&
content
.
getSmsRemind
()
==
1
)
{
new
Thread
(()
->
{
smsUtil
.
sendBatchSms
(
receiverList
,
"您有一封新的邮件,标题为《"
+
content
.
getTitle
()
+
"》。请及时查收。"
,
content
.
getId
());
}).
start
();
}
}
if
(
CollectionUtil
.
isNotEmpty
(
deptUserList
))
{
//增加收件部门
this
.
saveEmailReceiveDept
(
deptUserList
,
content
,
emailEditVo
);
//短信
if
(
content
.
getSmsRemind
()!=
null
&&
content
.
getSmsRemind
()
==
1
)
{
new
Thread
(()
->
{
smsUtil
.
sendBatchSms
(
deptUserList
,
"您有一封新的邮件,标题为《"
+
content
.
getTitle
()
+
"》。请及时查收。"
,
content
.
getId
());
}).
start
();
}
}
}
}
}
}
return
content
;
return
content
;
}
}
@Override
public
EmailPerson
getByContentAndFolderId
(
Long
contentId
,
LocalDateTime
sendTime
,
Long
folderId
)
{
OnlineUserDto
adminContext
=
TokenUtils
.
getAdminContext
();
AssertUtils
.
notNull
(
adminContext
,
"登录已失效,请重新登录后再次尝试!"
);
private
void
saveEmailSenderApi
(
CustomerUserVo
userVo
,
EmailContent
content
)
{
LambdaQueryWrapper
<
EmailPerson
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
EmailPerson
sender
=
EmailPerson
.
builder
()
queryWrapper
.
emailContentId
(
content
.
getId
())
.
eq
(
contentId
!=
null
,
EmailPerson:
:
getEmailContentId
,
contentId
)
.
userId
(
userVo
.
getUserId
())
.
eq
(
sendTime
!=
null
,
EmailPerson:
:
getSendTime
,
sendTime
)
.
userEmail
(
userVo
.
getUsername
())
.
eq
(
EmailPerson:
:
getFolderId
,
folderId
);
.
userName
(
userVo
.
getNickName
())
.
deptId
(
userVo
.
getDeptId
())
switch
(
EmailFolderEnum
.
getEnumByKey
(
folderId
.
intValue
()))
{
.
courtCode
(
userVo
.
getCourtCode
())
case
FOLDER_INBOX:
//收件箱
.
personType
(
EmailConstant
.
TYPE_EMAIL_SEND
)
queryWrapper
.
sendTime
(
content
.
getSendTime
())
.
eq
(
EmailPerson:
:
getPersonType
,
EmailConstant
.
TYPE_EMAIL_RECEIVE
)
.
folderId
(
EmailFolderEnum
.
FOLDER_ALREADY_SEND
.
getKey
().
longValue
())
.
eq
(
EmailPerson:
:
getIsPerson
,
WhetherEnum
.
YES
.
getKey
())
.
isRead
(
WhetherEnum
.
YES
.
getKey
())
.
eq
(
EmailPerson:
:
getIsSend
,
WhetherEnum
.
YES
.
getKey
())
.
isPerson
(
WhetherEnum
.
YES
.
getKey
())
.
eq
(
EmailPerson:
:
getUserId
,
adminContext
.
getUserId
());
.
isTask
(
content
.
getIsTask
())
break
;
.
isSend
(
WhetherEnum
.
YES
.
getKey
())
case
FOLDER_DEPT_INBOX:
//部门邮件
.
build
();
queryWrapper
this
.
save
(
sender
);
.
eq
(
EmailPerson:
:
getPersonType
,
EmailConstant
.
TYPE_EMAIL_RECEIVE
)
}
.
eq
(
EmailPerson:
:
getIsPerson
,
WhetherEnum
.
NO
.
getKey
())
.
eq
(
EmailPerson:
:
getIsSend
,
WhetherEnum
.
YES
.
getKey
())
private
void
saveEmailSender
(
OnlineUserDto
adminContext
,
EmailContent
content
,
EmailEditVo
vo
)
{
.
eq
(
EmailPerson:
:
getUserId
,
adminContext
.
getUserId
());
EmailPerson
sender
=
EmailPerson
.
builder
()
break
;
.
emailContentId
(
content
.
getId
())
case
FOLDER_OUTBOX:
//草稿箱
.
userId
(
adminContext
.
getUserId
())
queryWrapper
.
userEmail
(
adminContext
.
getUserName
())
.
eq
(
EmailPerson:
:
getPersonType
,
EmailConstant
.
TYPE_EMAIL_SEND
)
.
userName
(
adminContext
.
getNickName
())
.
eq
(
EmailPerson:
:
getIsPerson
,
WhetherEnum
.
YES
.
getKey
())
.
deptId
(
adminContext
.
getDeptId
())
.
eq
(
EmailPerson:
:
getIsSend
,
WhetherEnum
.
NO
.
getKey
())
.
deptName
(
adminContext
.
getDeptName
())
.
eq
(
EmailPerson:
:
getUserId
,
adminContext
.
getUserId
());
.
courtCode
(
adminContext
.
getCourtCode
())
break
;
.
personType
(
EmailConstant
.
TYPE_EMAIL_SEND
)
case
FOLDER_ALREADY_SEND:
//已发送
.
sendTime
(
content
.
getSendTime
())
queryWrapper
.
folderId
(
vo
.
getIsSend
().
equals
(
WhetherEnum
.
YES
.
getKey
())
?
EmailFolderEnum
.
FOLDER_ALREADY_SEND
.
getKey
().
longValue
()
:
EmailFolderEnum
.
FOLDER_OUTBOX
.
getKey
().
longValue
())
.
eq
(
EmailPerson:
:
getPersonType
,
EmailConstant
.
TYPE_EMAIL_SEND
)
.
isRead
(
WhetherEnum
.
YES
.
getKey
())
.
eq
(
EmailPerson:
:
getIsPerson
,
WhetherEnum
.
YES
.
getKey
())
.
isPerson
(
WhetherEnum
.
YES
.
getKey
())
.
eq
(
EmailPerson:
:
getIsSend
,
WhetherEnum
.
YES
.
getKey
())
.
isTask
(
vo
.
getIsTask
())
.
eq
(
EmailPerson:
:
getUserId
,
adminContext
.
getUserId
());
.
isSend
(
vo
.
getIsSend
())
break
;
.
build
();
case
FOLDER_ALREADY_DELETE:
//回收站
this
.
save
(
sender
);
queryWrapper
}
.
eq
(
EmailPerson:
:
getUserId
,
adminContext
.
getUserId
());
break
;
default
:
queryWrapper
.
eq
(
EmailPerson:
:
getUserId
,
adminContext
.
getUserId
());
private
void
saveEmailReceiveDept
(
List
<
CustomerUserVo
>
receiverList
,
EmailContent
content
,
EmailEditVo
vo
)
{
break
;
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(() -> {
// 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);
// }).start();
//
// }
//内部消息提醒
if
(
content
.
getMessageRemind
()!=
null
&&
content
.
getMessageRemind
()
==
1
){
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
()+
"&contentId="
+
content
.
getId
());
ResultVo
resultVo
=
messageFeignClient
.
sendWebMessage
(
params
);
log
.
info
(
"发送内部短信内容打印: {}, feign结果:{}"
,
JSONUtil
.
toJsonStr
(
params
),
JSONUtil
.
toJsonStr
(
resultVo
));
ResultVo
resultVo1
=
messageFeignClient
.
addToDo
(
params
);
log
.
info
(
"发送代办内容打印: {}, feign结果:{}"
,
JSONUtil
.
toJsonStr
(
params
),
JSONUtil
.
toJsonStr
(
resultVo1
));
}
}
}
return
this
.
getOne
(
queryWrapper
,
false
);
}
}
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
(
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
())
.
isRead
(
WhetherEnum
.
NO
.
getKey
())
.
isPerson
(
WhetherEnum
.
YES
.
getKey
())
.
isTask
(
vo
.
getIsTask
())
.
isSend
(
vo
.
getIsSend
())
.
build
();
this
.
save
(
receivePerson
);
//内部消息提醒
if
(
content
.
getMessageRemind
()!=
null
&&
content
.
getMessageRemind
()
==
1
)
{
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
()+
"&contentId="
+
content
.
getId
());
ResultVo
resultVo
=
messageFeignClient
.
sendWebMessage
(
params
);
log
.
info
(
"发送内部短信内容打印: {}, feign结果:{}"
,
JSONUtil
.
toJsonStr
(
params
),
JSONUtil
.
toJsonStr
(
resultVo
));
ResultVo
resultVo1
=
messageFeignClient
.
addToDo
(
params
);
log
.
info
(
"发送代办内容打印: {}, feign结果:{}"
,
JSONUtil
.
toJsonStr
(
params
),
JSONUtil
.
toJsonStr
(
resultVo1
));
}
}
}
}
}
src/main/java/com/zq/email/utils/MsgUtil.java
0 → 100644
View file @
0c02ac1e
package
com
.
zq
.
email
.
utils
;
import
cn.hutool.core.codec.Base64
;
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.JSONUtil
;
import
com.zq.common.vo.CustomerUserVo
;
import
com.zq.common.vo.ResultVo
;
import
com.zq.email.constants.EmailConstant
;
import
com.zq.email.dto.SystemInfo
;
import
com.zq.email.entity.EmailContent
;
import
com.zq.email.feign.MessageFeignClient
;
import
com.zq.email.properties.SmsProperties
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
* @author wilmiam
* @since 2022-12-10 17:09
*/
@Slf4j
@Component
public
class
MsgUtil
{
@Resource
public
MessageFeignClient
messageFeignClient
;
/**
* 发送批量短信
*
* @return
*/
@Async
public
void
sendMsg
(
EmailContent
content
,
List
<
CustomerUserVo
>
userVoList
,
SystemInfo
systemInfo
)
{
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"systemTag"
,
EmailConstant
.
SYSTEM_TAG
);
params
.
put
(
"title"
,
"您有一封新邮件提醒"
);
params
.
put
(
"content"
,
"您有一封新的邮件,标题为《"
+
content
.
getTitle
()+
"》。请及时查收。"
);
params
.
put
(
"userIdList"
,
userVoList
.
stream
().
map
(
e
->
e
.
getUserId
()).
collect
(
Collectors
.
toList
()));
params
.
put
(
"businessId"
,
content
.
getId
());
params
.
put
(
"jumpUrl"
,
systemInfo
.
getHomeUrl
()
+
"/#/detail?contentId="
+
content
.
getId
());
log
.
debug
(
"---发送内部消息打印内容: {}"
,
JSONUtil
.
toJsonStr
(
params
));
messageFeignClient
.
sendApi
(
params
);
messageFeignClient
.
addToDoApi
(
params
);
}
@Async
public
void
revokeMsgByBusinessId
(
Long
businessId
)
{
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"systemTag"
,
EmailConstant
.
SYSTEM_TAG
);
params
.
put
(
"businessId"
,
businessId
);
log
.
debug
(
"---撤回内部消息打印内容: {}"
,
JSONUtil
.
toJsonStr
(
params
));
messageFeignClient
.
revokeWebBySysInfo
(
params
);
messageFeignClient
.
revokeTodoBySysInfo
(
params
);
}
@Async
public
void
revokeMsgByBusinessIdAndReceiverId
(
Long
businessId
,
Long
receiverId
)
{
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"systemTag"
,
EmailConstant
.
SYSTEM_TAG
);
params
.
put
(
"businessId"
,
businessId
);
params
.
put
(
"receiverId"
,
receiverId
);
log
.
debug
(
"---撤回内部消息打印内容: {}"
,
JSONUtil
.
toJsonStr
(
params
));
messageFeignClient
.
revokeWebBySysInfo
(
params
);
messageFeignClient
.
revokeTodoBySysInfo
(
params
);
}
}
src/main/java/com/zq/email/utils/SmsUtil.java
View file @
0c02ac1e
...
@@ -12,6 +12,7 @@ import com.zq.common.vo.CustomerUserVo;
...
@@ -12,6 +12,7 @@ import com.zq.common.vo.CustomerUserVo;
import
com.zq.common.vo.ResultVo
;
import
com.zq.common.vo.ResultVo
;
import
com.zq.email.properties.SmsProperties
;
import
com.zq.email.properties.SmsProperties
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
...
@@ -36,6 +37,7 @@ public class SmsUtil {
...
@@ -36,6 +37,7 @@ public class SmsUtil {
*
*
* @return
* @return
*/
*/
@Async
public
void
sendBatchSms
(
List
<
CustomerUserVo
>
userVoList
,
String
content
,
Long
contentId
)
{
public
void
sendBatchSms
(
List
<
CustomerUserVo
>
userVoList
,
String
content
,
Long
contentId
)
{
String
regex
=
"^1[3-9]\\d{9}"
;
String
regex
=
"^1[3-9]\\d{9}"
;
StringBuffer
sb
=
new
StringBuffer
();
StringBuffer
sb
=
new
StringBuffer
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment