Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yanxuan-qc-change-system
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
胡园园
yanxuan-qc-change-system
Commits
b791dea4
Commit
b791dea4
authored
Nov 23, 2022
by
“zcwang”
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/feature-changeFlow-221110' into feature-changeFlow-221110
parents
19ce167c
8fc593b3
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
1264 additions
and
1263 deletions
+1264
-1263
pom.xml
pom.xml
+26
-25
RpcTemplate.java
...l/yanxuan/change/integration/email/conig/RpcTemplate.java
+271
-271
ThirdCommonApolloConfig.java
...ange/integration/email/conig/ThirdCommonApolloConfig.java
+74
-74
BaseConvertor.java
...yanxuan/change/integration/email/email/BaseConvertor.java
+49
-49
EmailTemplateRpcResult.java
...hange/integration/email/email/EmailTemplateRpcResult.java
+38
-38
IusRpcResult.java
.../yanxuan/change/integration/email/email/IusRpcResult.java
+43
-43
OverTimeFlowVo.java
...anxuan/change/integration/email/email/OverTimeFlowVo.java
+28
-28
ProblemConfigureModel.java
...change/integration/email/email/ProblemConfigureModel.java
+22
-22
RpcObjectHandler.java
...xuan/change/integration/email/email/RpcObjectHandler.java
+25
-25
IEmailEhcService.java
...an/change/integration/email/service/IEmailEhcService.java
+111
-111
IEmailService.java
...nxuan/change/integration/email/service/IEmailService.java
+50
-50
IIusService.java
...yanxuan/change/integration/email/service/IIusService.java
+137
-137
ISupplierEmailService.java
...ange/integration/email/service/ISupplierEmailService.java
+11
-11
IUasEhcClient.java
...nxuan/change/integration/email/service/IUasEhcClient.java
+21
-21
EncodeUtil.java
...ail/yanxuan/change/integration/email/util/EncodeUtil.java
+53
-53
HttpClientUtil.java
...yanxuan/change/integration/email/util/HttpClientUtil.java
+305
-305
No files found.
pom.xml
View file @
b791dea4
...
@@ -379,32 +379,33 @@
...
@@ -379,32 +379,33 @@
</exclusions>
</exclusions>
</dependency>
</dependency>
<!--qc -->
<!--qc -->
<dependency>
<!-- <dependency>-->
<groupId>
com.netease.yanxuan
</groupId>
<!-- <groupId>com.netease.yanxuan</groupId>-->
<artifactId>
yanxuan-qc-service-client
</artifactId>
<!-- <artifactId>yanxuan-qc-service-client</artifactId>-->
<version>
2.0.0-SNAPSHOT
</version>
<!-- <version>2.0.0-SNAPSHOT</version>-->
</dependency>
<!-- </dependency>-->
<dependency>
<!-- <dependency>-->
<groupId>
com.netease.yanxuan
</groupId>
<!-- <groupId>com.netease.yanxuan</groupId>-->
<artifactId>
yanxuan-qc-parent
</artifactId>
<!-- <artifactId>yanxuan-qc-parent</artifactId>-->
<version>
2.0.0-SNAPSHOT
</version>
<!-- <version>2.0.0-SNAPSHOT</version>-->
</dependency>
<!-- </dependency>-->
<dependency>
<!-- <dependency>-->
<groupId>
com.netease.mail.yanxuan
</groupId>
<!-- <groupId>com.netease.mail.yanxuan</groupId>-->
<artifactId>
dschedule-boot-starter
</artifactId>
<!-- <artifactId>dschedule-boot-starter</artifactId>-->
<version>
1.0.3-SNAPSHOT
</version>
<!-- <version>1.0.3-SNAPSHOT</version>-->
</dependency>
<!-- </dependency>-->
<dependency>
<!-- <dependency>-->
<groupId>
com.netease.mailsaas
</groupId>
<!-- <groupId>com.netease.mailsaas</groupId>-->
<artifactId>
saas-kit-java-bundle
</artifactId>
<!-- <artifactId>saas-kit-java-bundle</artifactId>-->
<version>
0.1.0-SNAPSHOT
</version>
<!-- <version>0.1.0-SNAPSHOT</version>-->
</dependency>
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.assertj</groupId>-->
<!-- <artifactId>assertj-core</artifactId>-->
<!-- <version>3.18.1</version>-->
<!-- </dependency>-->
<dependency>
<groupId>
org.assertj
</groupId>
<artifactId>
assertj-core
</artifactId>
<version>
3.18.1
</version>
</dependency>
</dependencies>
</dependencies>
...
...
yanxuan-qc-change-system-integration/src/main/java/com/netease/mail/yanxuan/change/integration/email/conig/RpcTemplate.java
View file @
b791dea4
package
com
.
netease
.
mail
.
yanxuan
.
change
.
integration
.
email
.
conig
;
//
package com.netease.mail.yanxuan.change.integration.email.conig;
//
import
com.alibaba.fastjson.JSON
;
//
import com.alibaba.fastjson.JSON;
import
com.alibaba.fastjson.parser.ParserConfig
;
//
import com.alibaba.fastjson.parser.ParserConfig;
import
com.netease.mail.yanxuan.change.integration.email.enums.EmailType
;
//
import com.netease.mail.yanxuan.change.integration.email.enums.EmailType;
import
com.netease.mail.yanxuan.change.integration.email.exception.RpcException
;
//
import com.netease.mail.yanxuan.change.integration.email.exception.RpcException;
import
com.netease.mail.yanxuan.change.integration.email.exception.RpcStatusException
;
//
import com.netease.mail.yanxuan.change.integration.email.exception.RpcStatusException;
import
com.netease.mail.yanxuan.change.integration.email.exception.RpcTimeoutException
;
//
import com.netease.mail.yanxuan.change.integration.email.exception.RpcTimeoutException;
import
com.netease.mail.yanxuan.change.integration.email.util.EncodeUtil
;
//
import com.netease.mail.yanxuan.change.integration.email.util.EncodeUtil;
import
com.netease.mail.yanxuan.change.integration.email.util.HttpClientUtil
;
//
import com.netease.mail.yanxuan.change.integration.email.util.HttpClientUtil;
import
org.aspectj.weaver.Checker
;
//
import org.aspectj.weaver.Checker;
import
org.slf4j.Logger
;
//
import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
//
import org.slf4j.LoggerFactory;
import
org.springframework.beans.factory.annotation.Value
;
//
import org.springframework.beans.factory.annotation.Value;
import
org.springframework.stereotype.Component
;
//
import org.springframework.stereotype.Component;
import
org.springframework.util.CollectionUtils
;
//
import org.springframework.util.CollectionUtils;
import
org.springframework.util.StringUtils
;
//
import org.springframework.util.StringUtils;
//
import
java.io.IOException
;
//
import java.io.IOException;
import
java.util.List
;
//
import java.util.List;
import
java.util.Map
;
//
import java.util.Map;
//
/**
/
//
**
* rpc 请求封装,在 HttpClientUtil 基础上加入了返回值处理和日志
//
* rpc 请求封装,在 HttpClientUtil 基础上加入了返回值处理和日志
*
//
*
* @author lwtang
//
* @author lwtang
* @date 2019-02-19
//
* @date 2019-02-19
*/
//
*/
@Component
//
@Component
public
class
RpcTemplate
{
//
public class RpcTemplate {
//
//
private
Logger
logger
=
LoggerFactory
.
getLogger
(
RpcTemplate
.
class
);
//
private Logger logger = LoggerFactory.getLogger(RpcTemplate.class);
//
@Value
(
"${act.rpc.get.retry:1}"
)
//
@Value("${act.rpc.get.retry:1}")
private
int
rpcGetRetry
;
//
private int rpcGetRetry;
//
@Value
(
"${act.rpc.post.retry:0}"
)
//
@Value("${act.rpc.post.retry:0}")
private
int
rpcPostRetry
;
//
private int rpcPostRetry;
//
public
RpcTemplate
()
{
//
public RpcTemplate() {
ParserConfig
.
getGlobalInstance
().
setAutoTypeSupport
(
true
);
//
ParserConfig.getGlobalInstance().setAutoTypeSupport(true);
}
//
}
//
private
String
convertParam
(
Object
param
)
{
//
private String convertParam(Object param) {
if
(
param
instanceof
String
)
{
//
if (param instanceof String) {
return
(
String
)
param
;
//
return (String) param;
}
//
}
String
reqParam
=
""
;
//
String reqParam = "";
if
(
param
instanceof
Map
)
{
//
if (param instanceof Map) {
reqParam
=
EncodeUtil
.
encodeMap
((
Map
)
param
);
//
reqParam = EncodeUtil.encodeMap((Map) param);
}
else
if
(
param
!=
null
)
{
//
} else if (param != null) {
reqParam
=
JSON
.
toJSONString
(
param
);
//
reqParam = JSON.toJSONString(param);
}
//
}
return
reqParam
;
//
return reqParam;
}
//
}
//
private
<
T
>
T
execute
(
String
url
,
Object
params
,
CallHandler
<
T
>
handler
,
//
private <T> T execute(String url, Object params, CallHandler<T> handler,
CallTemplate
callTemplate
,
int
retryTime
,
Method
method
)
{
//
CallTemplate callTemplate, int retryTime, Method method) {
int
tryTimes
=
0
;
//
int tryTimes = 0;
RpcException
rpcException
=
null
;
//
RpcException rpcException = null;
String
respBody
=
null
;
//
String respBody = null;
int
statusCode
=
200
;
//
int statusCode = 200;
while
(
tryTimes
<=
retryTime
)
{
//
while (tryTimes <= retryTime) {
long
startTime
=
System
.
currentTimeMillis
();
//
long startTime = System.currentTimeMillis();
try
{
//
try {
respBody
=
callTemplate
.
executeCall
();
//
respBody = callTemplate.executeCall();
if
(
StringUtils
.
isEmpty
(
respBody
))
{
//
if (StringUtils.isEmpty(respBody)) {
throw
new
RpcException
(
"response empty"
);
//
throw new RpcException("response empty");
}
//
}
//
T
t
=
handler
.
handle
(
respBody
);
//
T t = handler.handle(respBody);
return
t
;
//
return t;
}
catch
(
RpcTimeoutException
e
)
{
//
} catch (RpcTimeoutException e) {
rpcException
=
e
;
//
rpcException = e;
}
catch
(
RpcStatusException
e
)
{
//
} catch (RpcStatusException e) {
rpcException
=
e
;
//
rpcException = e;
statusCode
=
e
.
getCode
();
//
statusCode = e.getCode();
}
catch
(
RpcException
e
)
{
//
} catch (RpcException e) {
rpcException
=
e
;
//
rpcException = e;
}
catch
(
Exception
e
)
{
//
} catch (Exception e) {
rpcException
=
new
RpcException
(
e
);
//
rpcException = new RpcException(e);
}
finally
{
//
} finally {
if
(
logger
.
isDebugEnabled
())
{
//
if (logger.isDebugEnabled()) {
long
costTime
=
System
.
currentTimeMillis
()
-
startTime
;
//
long costTime = System.currentTimeMillis() - startTime;
String
reqParam
=
convertParam
(
params
);
//
String reqParam = convertParam(params);
logger
.
debug
(
//
logger.debug(
"process request, url={}, method={}, params={}, statusCode = {}, response={}, cost={}ms"
,
//
"process request, url={}, method={}, params={}, statusCode = {}, response={}, cost={}ms",
url
,
method
.
name
(),
reqParam
,
statusCode
,
respBody
,
costTime
);
//
url, method.name(), reqParam, statusCode, respBody, costTime);
}
//
}
}
//
}
tryTimes
++;
//
tryTimes++;
}
//
}
//
logger
.
error
(
"request error, url={}, params={}, statusCode = {}, respBody={}"
,
url
,
//
logger.error("request error, url={}, params={}, statusCode = {}, respBody={}", url,
convertParam
(
params
),
statusCode
,
respBody
,
rpcException
);
//
convertParam(params), statusCode, respBody, rpcException);
//
if
(
rpcException
==
null
)
{
//
if (rpcException == null) {
rpcException
=
new
RpcException
(
"服务异常"
);
//
rpcException = new RpcException("服务异常");
}
//
}
throw
rpcException
;
//
throw rpcException;
}
//
}
//
/**
//
/**
* Get 请求
//
* Get 请求
*
//
*
* @param url
//
* @param url
* @param params
//
* @param params
* @param header
//
* @param header
* @param timeout
//
* @param timeout
* -1 取默认的超时时间
//
* -1 取默认的超时时间
* @param handler
//
* @param handler
* @param <T>
//
* @param <T>
* @return
//
* @return
*/
//
*/
public
<
T
>
T
get
(
String
url
,
Map
<
String
,
Object
>
params
,
Map
<
String
,
String
>
header
,
//
public <T> T get(String url, Map<String, Object> params, Map<String, String> header,
int
timeout
,
CallHandler
<
T
>
handler
,
Integer
retryTimes
)
{
//
int timeout, CallHandler<T> handler, Integer retryTimes) {
CallTemplate
template
=
()
->
HttpClientUtil
.
get
(
url
,
params
,
header
,
timeout
);
//
CallTemplate template = () -> HttpClientUtil.get(url, params, header, timeout);
return
this
.
execute
(
url
,
params
,
handler
,
template
,
retryTimes
,
Method
.
GET
);
//
return this.execute(url, params, handler, template, retryTimes, Method.GET);
}
//
}
//
public
<
T
>
T
get
(
String
url
,
Map
<
String
,
Object
>
params
,
CallHandler
<
T
>
handler
)
{
//
public <T> T get(String url, Map<String, Object> params, CallHandler<T> handler) {
return
get
(
url
,
params
,
null
,
-
1
,
handler
,
rpcGetRetry
);
//
return get(url, params, null, -1, handler, rpcGetRetry);
}
//
}
//
/**
//
/**
* Post请求(url encoded)
//
* Post请求(url encoded)
*
//
*
* @param url
//
* @param url
* @param params
//
* @param params
* @param timeout
//
* @param timeout
* @param handler
//
* @param handler
* @param <T>
//
* @param <T>
* @return
//
* @return
*/
//
*/
public
<
T
>
T
post
(
String
url
,
Map
<
String
,
Object
>
params
,
int
timeout
,
CallHandler
<
T
>
handler
,
//
public <T> T post(String url, Map<String, Object> params, int timeout, CallHandler<T> handler,
Integer
retryTime
)
{
//
Integer retryTime) {
CallTemplate
template
=
()
->
HttpClientUtil
.
post
(
url
,
params
,
timeout
);
//
CallTemplate template = () -> HttpClientUtil.post(url, params, timeout);
return
this
.
execute
(
url
,
params
,
handler
,
template
,
retryTime
,
Method
.
POST
);
//
return this.execute(url, params, handler, template, retryTime, Method.POST);
}
//
}
//
/**
//
/**
* Post请求(url encoded)
//
* Post请求(url encoded)
*
//
*
* @param url
//
* @param url
* @param params
//
* @param params
* @param timeout
//
* @param timeout
* @param handler
//
* @param handler
* @param <T>
//
* @param <T>
* @return
//
* @return
*/
//
*/
public
<
T
>
T
post
(
String
url
,
Map
<
String
,
Object
>
params
,
int
timeout
,
CallHandler
<
T
>
handler
)
{
//
public <T> T post(String url, Map<String, Object> params, int timeout, CallHandler<T> handler) {
CallTemplate
template
=
()
->
HttpClientUtil
.
post
(
url
,
params
,
timeout
);
//
CallTemplate template = () -> HttpClientUtil.post(url, params, timeout);
return
this
.
execute
(
url
,
params
,
handler
,
template
,
rpcPostRetry
,
Method
.
POST
);
//
return this.execute(url, params, handler, template, rpcPostRetry, Method.POST);
}
//
}
//
/**
//
/**
* Post Json请求
//
* Post Json请求
*
//
*
* @param url
//
* @param url
* @param params
//
* @param params
* @param timeout
//
* @param timeout
* @param handler
//
* @param handler
* @param <T>
//
* @param <T>
* @return
//
* @return
*/
//
*/
public
<
T
>
T
postJson
(
String
url
,
String
params
,
int
timeout
,
CallHandler
<
T
>
handler
,
//
public <T> T postJson(String url, String params, int timeout, CallHandler<T> handler,
Integer
retryTime
)
{
//
Integer retryTime) {
CallTemplate
template
=
()
->
HttpClientUtil
.
postJson
(
url
,
params
,
timeout
);
//
CallTemplate template = () -> HttpClientUtil.postJson(url, params, timeout);
return
this
.
execute
(
url
,
params
,
handler
,
template
,
retryTime
,
Method
.
POST
);
//
return this.execute(url, params, handler, template, retryTime, Method.POST);
}
//
}
//
/**
//
/**
* Post Json请求
//
* Post Json请求
*
//
*
* @param url
//
* @param url
* @param params
//
* @param params
* @param timeout
//
* @param timeout
* @param handler
//
* @param handler
* @param <T>
//
* @param <T>
* @return
//
* @return
*/
//
*/
public
<
T
>
T
postJson
(
String
url
,
String
params
,
int
timeout
,
CallHandler
<
T
>
handler
)
{
//
public <T> T postJson(String url, String params, int timeout, CallHandler<T> handler) {
CallTemplate
template
=
()
->
HttpClientUtil
.
postJson
(
url
,
params
,
timeout
);
//
CallTemplate template = () -> HttpClientUtil.postJson(url, params, timeout);
return
this
.
execute
(
url
,
params
,
handler
,
template
,
rpcPostRetry
,
Method
.
POST
);
//
return this.execute(url, params, handler, template, rpcPostRetry, Method.POST);
}
//
}
//
enum
RpcStatus
{
//
enum RpcStatus {
//
/**
//
/**
* 成功
//
* 成功
*/
//
*/
SUCCESS
(
1
),
//
SUCCESS(1),
//
/**
//
/**
* 告警(请求成功,但非理想值)
//
* 告警(请求成功,但非理想值)
*/
//
*/
WARNING
(
2
),
//
WARNING(2),
//
/**
//
/**
* 异常
//
* 异常
*/
//
*/
EXCEPTION
(
3
),
//
EXCEPTION(3),
//
/**
//
/**
* 超时
//
* 超时
*/
//
*/
TIMEOUT
(
4
);
//
TIMEOUT(4);
//
private
int
value
;
//
private int value;
//
RpcStatus
(
int
value
)
{
//
RpcStatus(int value) {
this
.
value
=
value
;
//
this.value = value;
}
//
}
//
public
int
getValue
()
{
//
public int getValue() {
return
value
;
//
return value;
}
//
}
}
//
}
//
enum
Method
{
//
enum Method {
//
/**
//
/**
* Get请求
//
* Get请求
*/
//
*/
GET
,
//
GET,
//
/**
//
/**
* Post表单请求
//
* Post表单请求
*/
//
*/
POST
,
//
POST,
}
//
}
//
/**
//
/**
* 模板调用
//
* 模板调用
*/
//
*/
@FunctionalInterface
//
@FunctionalInterface
public
interface
CallTemplate
{
//
public interface CallTemplate {
//
/**
//
/**
* 模板调用类
//
* 模板调用类
*/
//
*/
String
executeCall
();
//
String executeCall();
}
//
}
//
/**
//
/**
* 报文解析
//
* 报文解析
*/
//
*/
@FunctionalInterface
//
@FunctionalInterface
public
interface
CallHandler
<
T
>
{
//
public interface CallHandler<T> {
//
/**
//
/**
* 报文解析
//
* 报文解析
*
//
*
* @param resp
//
* @param resp
* response body
//
* response body
*/
//
*/
T
handle
(
String
resp
)
throws
IOException
;
//
T handle(String resp) throws IOException;
//
/**
//
/**
* 校验数据体
//
* 校验数据体
*
//
*
* @param t
//
* @param t
* @return
//
* @return
*/
//
*/
default
boolean
check
(
T
t
)
{
//
default boolean check(T t) {
return
true
;
//
return true;
}
//
}
}
//
}
//
}
//
}
yanxuan-qc-change-system-integration/src/main/java/com/netease/mail/yanxuan/change/integration/email/conig/ThirdCommonApolloConfig.java
View file @
b791dea4
package
com
.
netease
.
mail
.
yanxuan
.
change
.
integration
.
email
.
conig
;
//
package com.netease.mail.yanxuan.change.integration.email.conig;
//
//
import
java.util.List
;
//
import java.util.List;
import
java.util.Optional
;
//
import java.util.Optional;
import
java.util.stream.Collectors
;
//
import java.util.stream.Collectors;
//
//
import
com.netease.mail.yanxuan.change.integration.email.email.JumpLinkModel
;
//
import com.netease.mail.yanxuan.change.integration.email.email.JumpLinkModel;
import
com.netease.mail.yanxuan.change.integration.email.email.ProblemConfigureModel
;
//
import com.netease.mail.yanxuan.change.integration.email.email.ProblemConfigureModel;
import
org.springframework.beans.factory.annotation.Value
;
//
import org.springframework.beans.factory.annotation.Value;
import
org.springframework.stereotype.Component
;
//
import org.springframework.stereotype.Component;
//
import
com.ctrip.framework.apollo.spring.annotation.EnableAutoUpdateApolloConfig
;
//
import com.ctrip.framework.apollo.spring.annotation.EnableAutoUpdateApolloConfig;
import
com.ctrip.framework.apollo.spring.annotation.ValueMapping
;
//
import com.ctrip.framework.apollo.spring.annotation.ValueMapping;
//
import
lombok.Data
;
//
import lombok.Data;
import
org.springframework.util.CollectionUtils
;
//
import org.springframework.util.CollectionUtils;
/**
/
//
**
* 第三方平台通用apollo配置
//
* 第三方平台通用apollo配置
*/
//
*/
@Data
//
@Data
@Component
//
@Component
@EnableAutoUpdateApolloConfig
(
"3rd.base"
)
//
@EnableAutoUpdateApolloConfig("3rd.base")
public
class
ThirdCommonApolloConfig
{
//
public class ThirdCommonApolloConfig {
//
private
static
final
String
DEFAULT
=
"default"
;
//
private static final String DEFAULT = "default";
//
/**
//
/**
* 异常超级管理员(各个接入的服务业务架构统一角色id)
//
* 异常超级管理员(各个接入的服务业务架构统一角色id)
*/
//
*/
@Value
(
"${abnormalAdminRoleId:7956010101}"
)
//
@Value("${abnormalAdminRoleId:7956010101}")
private
Long
abnormalAdminRoleId
;
//
private Long abnormalAdminRoleId;
//
/**
//
/**
* 各工作台待办跳转链接
//
* 各工作台待办跳转链接
*/
//
*/
@ValueMapping
(
"${jumpLink:[]}"
)
//
@ValueMapping("${jumpLink:[]}")
private
List
<
JumpLinkModel
>
jumpLinkMap
;
//
private List<JumpLinkModel> jumpLinkMap;
//
/**
//
/**
* 各工作台邮件
//
* 各工作台邮件
*/
//
*/
@ValueMapping
(
"${emailFlowUrl:[]}"
)
//
@ValueMapping("${emailFlowUrl:[]}")
private
List
<
JumpLinkModel
>
emailFlowUrl
;
//
private List<JumpLinkModel> emailFlowUrl;
//
//
/**
//
/**
* 根据产品号获取跳转链接
//
* 根据产品号获取跳转链接
*
//
*
* @param productCode
//
* @param productCode
* @return
//
* @return
*/
//
*/
public
Optional
<
JumpLinkModel
>
getJumpLinkByProductCode
(
String
productCode
)
{
//
public Optional<JumpLinkModel> getJumpLinkByProductCode(String productCode) {
List
<
JumpLinkModel
>
list
=
jumpLinkMap
.
stream
().
filter
(
x
->
productCode
.
equals
(
x
.
getProductCode
()))
//
List<JumpLinkModel> list = jumpLinkMap.stream().filter(x -> productCode.equals(x.getProductCode()))
.
collect
(
Collectors
.
toList
());
//
.collect(Collectors.toList());
if
(!
CollectionUtils
.
isEmpty
(
list
))
{
//
if (!CollectionUtils.isEmpty(list)) {
return
Optional
.
of
(
list
.
get
(
0
));
//
return Optional.of(list.get(0));
}
else
{
//
} else {
list
=
jumpLinkMap
.
stream
().
filter
(
x
->
DEFAULT
.
equals
(
x
.
getProductCode
())).
collect
(
Collectors
.
toList
());
//
list = jumpLinkMap.stream().filter(x -> DEFAULT.equals(x.getProductCode())).collect(Collectors.toList());
if
(!
CollectionUtils
.
isEmpty
(
list
))
{
//
if (!CollectionUtils.isEmpty(list)) {
return
Optional
.
of
(
list
.
get
(
0
));
//
return Optional.of(list.get(0));
}
//
}
}
//
}
return
Optional
.
of
(
jumpLinkMap
.
get
(
0
));
//
return Optional.of(jumpLinkMap.get(0));
}
//
}
//
@ValueMapping
(
"${warehouseConfigureModel:{}}"
)
//
@ValueMapping("${warehouseConfigureModel:{}}")
private
ProblemConfigureModel
warehouseConfigureModel
;
//
private ProblemConfigureModel warehouseConfigureModel;
//
@ValueMapping
(
"${carrierConfigureModel:{}}"
)
//
@ValueMapping("${carrierConfigureModel:{}}")
private
ProblemConfigureModel
carrierConfigureModel
;
//
private ProblemConfigureModel carrierConfigureModel;
//
}
//
}
yanxuan-qc-change-system-integration/src/main/java/com/netease/mail/yanxuan/change/integration/email/email/BaseConvertor.java
View file @
b791dea4
package
com
.
netease
.
mail
.
yanxuan
.
change
.
integration
.
email
.
email
;
//
package com.netease.mail.yanxuan.change.integration.email.email;
//
import
org.assertj.core.util.Lists
;
//
import org.assertj.core.util.Lists;
import
lombok.SneakyThrows
;
//
import lombok.SneakyThrows;
import
org.springframework.beans.BeanUtils
;
//
import org.springframework.beans.BeanUtils;
//
import
java.util.ArrayList
;
//
import java.util.ArrayList;
import
java.util.List
;
//
import java.util.List;
//
public
class
BaseConvertor
{
//
public class BaseConvertor {
@SneakyThrows
//
@SneakyThrows
public
static
<
T
>
T
convert
(
Object
object
,
final
Class
<
T
>
clazz
)
{
//
public static <T> T convert(Object object, final Class<T> clazz) {
if
(
object
==
null
)
{
//
if (object == null) {
return
null
;
//
return null;
}
//
}
T
t
=
clazz
.
newInstance
();
//
T t = clazz.newInstance();
BeanUtils
.
copyProperties
(
object
,
t
);
//
BeanUtils.copyProperties(object, t);
return
t
;
//
return t;
}
//
}
//
@SneakyThrows
//
@SneakyThrows
public
static
void
copyProperties
(
Object
source
,
Object
target
)
{
//
public static void copyProperties(Object source, Object target) {
BeanUtils
.
copyProperties
(
source
,
target
);
//
BeanUtils.copyProperties(source, target);
}
//
}
//
@SneakyThrows
//
@SneakyThrows
public
static
<
T
>
List
<
T
>
convert
(
List
<?>
objects
,
final
Class
<
T
>
clazz
)
{
//
public static <T> List<T> convert(List<?> objects, final Class<T> clazz) {
if
(
org
.
apache
.
commons
.
collections
.
CollectionUtils
.
isEmpty
(
objects
))
{
//
if (org.apache.commons.collections.CollectionUtils.isEmpty(objects)) {
return
new
ArrayList
<>();
//
return new ArrayList<>();
}
//
}
List
<
T
>
retList
=
Lists
.
newArrayList
();
//
List<T> retList = Lists.newArrayList();
objects
.
forEach
(
object
->
{
//
objects.forEach(object -> {
try
{
//
try {
T
t
=
clazz
.
newInstance
();
//
T t = clazz.newInstance();
BeanUtils
.
copyProperties
(
object
,
t
);
//
BeanUtils.copyProperties(object, t);
retList
.
add
(
t
);
//
retList.add(t);
}
catch
(
Exception
ex
)
{
//
} catch (Exception ex) {
try
{
//
try {
throw
ex
;
//
throw ex;
}
catch
(
InstantiationException
e
)
{
//
} catch (InstantiationException e) {
e
.
printStackTrace
();
//
e.printStackTrace();
}
catch
(
IllegalAccessException
e
)
{
//
} catch (IllegalAccessException e) {
e
.
printStackTrace
();
//
e.printStackTrace();
}
//
}
}
//
}
});
//
});
return
retList
;
//
return retList;
}
//
}
}
//
}
yanxuan-qc-change-system-integration/src/main/java/com/netease/mail/yanxuan/change/integration/email/email/EmailTemplateRpcResult.java
View file @
b791dea4
package
com
.
netease
.
mail
.
yanxuan
.
change
.
integration
.
email
.
email
;
//
package com.netease.mail.yanxuan.change.integration.email.email;
//
import
com.alibaba.fastjson.JSON
;
//
import com.alibaba.fastjson.JSON;
import
com.alibaba.fastjson.JSONObject
;
//
import com.alibaba.fastjson.JSONObject;
import
com.netease.mail.yanxuan.change.integration.email.conig.RpcTemplate
;
//
import com.netease.mail.yanxuan.change.integration.email.conig.RpcTemplate;
import
com.netease.mail.yanxuan.change.common.bean.ResponseCode
;
//
import com.netease.mail.yanxuan.change.common.bean.ResponseCode;
import
com.netease.mail.yanxuan.change.integration.email.exception.RpcException
;
//
import com.netease.mail.yanxuan.change.integration.email.exception.RpcException;
//
import
java.io.IOException
;
//
import java.io.IOException;
//
public
class
EmailTemplateRpcResult
<
T
>
implements
RpcTemplate
.
CallHandler
<
T
>
{
//
public class EmailTemplateRpcResult<T> implements RpcTemplate.CallHandler<T> {
//
private
static
final
String
CODE
=
"code"
;
//
private static final String CODE = "code";
//
private
static
final
String
RESULT
=
"data"
;
//
private static final String RESULT = "data";
//
private
static
final
String
MESSAGE
=
"errorMessage"
;
//
private static final String MESSAGE = "errorMessage";
//
private
Class
<
T
>
tClass
;
//
private Class<T> tClass;
//
public
EmailTemplateRpcResult
(
Class
<
T
>
tClass
){
//
public EmailTemplateRpcResult(Class<T> tClass){
this
.
tClass
=
tClass
;
//
this.tClass = tClass;
}
//
}
//
@Override
//
@Override
public
T
handle
(
String
resp
)
throws
IOException
{
//
public T handle(String resp) throws IOException {
JSONObject
rpcResult
=
JSON
.
parseObject
(
resp
);
//
JSONObject rpcResult = JSON.parseObject(resp);
EmailTemplateResponResult
responResult
=
new
EmailTemplateResponResult
();
//
EmailTemplateResponResult responResult = new EmailTemplateResponResult();
int
code
=
rpcResult
.
getIntValue
(
CODE
);
//
int code = rpcResult.getIntValue(CODE);
if
(
code
==
ResponseCode
.
SUCCESS
.
getCode
()){
//
if(code == ResponseCode.SUCCESS.getCode()){
String
data
=
rpcResult
.
getString
(
RESULT
);
//
String data = rpcResult.getString(RESULT);
responResult
.
setData
(
data
);
//
responResult.setData(data);
return
(
T
)
responResult
;
//
return (T) responResult;
}
//
}
String
errorMessage
=
rpcResult
.
getString
(
MESSAGE
);
//
String errorMessage = rpcResult.getString(MESSAGE);
throw
new
RpcException
(
"email template response error, code : "
+
code
+
" , errorMessage : "
+
errorMessage
);
//
throw new RpcException("email template response error, code : " + code + " , errorMessage : " + errorMessage);
}
//
}
}
//
}
yanxuan-qc-change-system-integration/src/main/java/com/netease/mail/yanxuan/change/integration/email/email/IusRpcResult.java
View file @
b791dea4
package
com
.
netease
.
mail
.
yanxuan
.
change
.
integration
.
email
.
email
;
//
package com.netease.mail.yanxuan.change.integration.email.email;
//
import
com.alibaba.fastjson.JSON
;
//
import com.alibaba.fastjson.JSON;
import
com.alibaba.fastjson.JSONObject
;
//
import com.alibaba.fastjson.JSONObject;
import
com.netease.mail.yanxuan.change.integration.email.conig.RpcTemplate
;
//
import com.netease.mail.yanxuan.change.integration.email.conig.RpcTemplate;
import
com.netease.mail.yanxuan.change.common.bean.ResponseCode
;
//
import com.netease.mail.yanxuan.change.common.bean.ResponseCode;
import
com.netease.mail.yanxuan.change.integration.email.exception.RpcException
;
//
import com.netease.mail.yanxuan.change.integration.email.exception.RpcException;
import
com.netease.mail.yanxuan.change.integration.email.dto.UserInfoDTO
;
//
import com.netease.mail.yanxuan.change.integration.email.dto.UserInfoDTO;
import
java.io.IOException
;
//
import java.io.IOException;
//
public
class
IusRpcResult
<
T
>
implements
RpcTemplate
.
CallHandler
<
T
>
{
//
public class IusRpcResult<T> implements RpcTemplate.CallHandler<T> {
//
private
static
final
String
CODE
=
"code"
;
//
private static final String CODE = "code";
//
private
static
final
String
RESULT
=
"data"
;
//
private static final String RESULT = "data";
//
private
static
final
String
ERROR_CODE
=
"errorCode"
;
//
private static final String ERROR_CODE = "errorCode";
//
private
static
final
String
ERROR_MESSAGE
=
"errorMsg"
;
//
private static final String ERROR_MESSAGE = "errorMsg";
//
private
Class
<
T
>
tClass
;
//
private Class<T> tClass;
//
public
IusRpcResult
(
Class
<
T
>
tClass
)
{
//
public IusRpcResult(Class<T> tClass) {
this
.
tClass
=
tClass
;
//
this.tClass = tClass;
}
//
}
//
@Override
//
@Override
public
T
handle
(
String
resp
)
throws
IOException
{
//
public T handle(String resp) throws IOException {
JSONObject
rpcResult
=
JSON
.
parseObject
(
resp
);
//
JSONObject rpcResult = JSON.parseObject(resp);
ResponseResult
responResult
=
new
ResponseResult
();
//
ResponseResult responResult = new ResponseResult();
int
code
=
rpcResult
.
getIntValue
(
CODE
);
//
int code = rpcResult.getIntValue(CODE);
if
(
code
==
ResponseCode
.
SUCCESS
.
getCode
())
{
//
if (code == ResponseCode.SUCCESS.getCode()) {
String
data
=
rpcResult
.
getString
(
RESULT
);
//
String data = rpcResult.getString(RESULT);
UserInfoDTO
jsonObject
=
JSON
.
parseObject
(
data
,
UserInfoDTO
.
class
);
//
UserInfoDTO jsonObject = JSON.parseObject(data, UserInfoDTO.class);
responResult
.
setData
(
jsonObject
);
//
responResult.setData(jsonObject);
return
(
T
)
responResult
;
//
return (T) responResult;
}
//
}
String
errorMessage
=
rpcResult
.
getString
(
ERROR_MESSAGE
);
//
String errorMessage = rpcResult.getString(ERROR_MESSAGE);
Integer
errorCode
=
rpcResult
.
getInteger
(
ERROR_CODE
);
//
Integer errorCode = rpcResult.getInteger(ERROR_CODE);
throw
new
RpcException
(
"ius response error, resp="
+
JSON
.
toJSONString
(
resp
)
+
" , errorCode : "
+
errorCode
//
throw new RpcException("ius response error, resp=" + JSON.toJSONString(resp) + " , errorCode : " + errorCode
+
" , errorMessage : "
+
errorMessage
);
//
+ " , errorMessage : " + errorMessage);
}
//
}
}
//
}
yanxuan-qc-change-system-integration/src/main/java/com/netease/mail/yanxuan/change/integration/email/email/OverTimeFlowVo.java
View file @
b791dea4
package
com
.
netease
.
mail
.
yanxuan
.
change
.
integration
.
email
.
email
;
//
package com.netease.mail.yanxuan.change.integration.email.email;
//
import
lombok.Builder
;
//
import lombok.Builder;
import
lombok.Data
;
//
import lombok.Data;
import
java.util.List
;
//
import java.util.List;
//
@Data
//
@Data
@Builder
//
@Builder
public
class
OverTimeFlowVo
{
//
public class OverTimeFlowVo {
//
/**
//
/**
* 用户邮箱
//
* 用户邮箱
*/
//
*/
private
String
uid
;
//
private String uid;
//
/**
//
/**
* 工单列表
//
* 工单列表
*/
//
*/
private
List
<
OverTimeUserVo
>
flowIdList
;
//
private List<OverTimeUserVo> flowIdList;
//
@Override
//
@Override
protected
Object
clone
()
throws
CloneNotSupportedException
{
//
protected Object clone() throws CloneNotSupportedException {
OverTimeFlowVo
vo
=
(
OverTimeFlowVo
)
super
.
clone
();
//
OverTimeFlowVo vo = (OverTimeFlowVo) super.clone();
vo
.
setUid
(
vo
.
getUid
());
//
vo.setUid(vo.getUid());
vo
.
setFlowIdList
(
BaseConvertor
.
convert
(
vo
.
getFlowIdList
(),
OverTimeUserVo
.
class
));
//
vo.setFlowIdList(BaseConvertor.convert(vo.getFlowIdList(), OverTimeUserVo.class));
return
vo
;
//
return vo;
}
//
}
}
//
}
yanxuan-qc-change-system-integration/src/main/java/com/netease/mail/yanxuan/change/integration/email/email/ProblemConfigureModel.java
View file @
b791dea4
package
com
.
netease
.
mail
.
yanxuan
.
change
.
integration
.
email
.
email
;
//
package com.netease.mail.yanxuan.change.integration.email.email;
//
import
com.netease.mail.yanxuan.qc.service.client.meta.abnormal.LabelModel
;
//
import com.netease.mail.yanxuan.qc.service.client.meta.abnormal.LabelModel;
import
lombok.Data
;
//
import lombok.Data;
//
import
java.util.List
;
//
import java.util.List;
//
@Data
//
@Data
public
class
ProblemConfigureModel
{
//
public class ProblemConfigureModel {
/**
//
/**
* 问题类型配置表id
//
* 问题类型配置表id
*/
//
*/
private
Long
problemTypeId
;
//
private Long problemTypeId;
/**
//
/**
* 异常环节
//
* 异常环节
*/
//
*/
private
List
<
LabelModel
>
abnormalLinks
;
//
private List<LabelModel> abnormalLinks;
/**
//
/**
* 问题分类
//
* 问题分类
*/
//
*/
private
List
<
LabelModel
>
flowProblems
;
//
private List<LabelModel> flowProblems;
}
//
}
yanxuan-qc-change-system-integration/src/main/java/com/netease/mail/yanxuan/change/integration/email/email/RpcObjectHandler.java
View file @
b791dea4
package
com
.
netease
.
mail
.
yanxuan
.
change
.
integration
.
email
.
email
;
//
package com.netease.mail.yanxuan.change.integration.email.email;
//
import
com.alibaba.fastjson.JSON
;
//
import com.alibaba.fastjson.JSON;
import
com.netease.mail.yanxuan.change.integration.email.conig.RpcTemplate
;
//
import com.netease.mail.yanxuan.change.integration.email.conig.RpcTemplate;
//
import
java.io.IOException
;
//
import java.io.IOException;
//
/**
/
//
**
* 直接序列化返回对象
//
* 直接序列化返回对象
*
//
*
* @author lwtang
//
* @author lwtang
* @date 2019-02-20
//
* @date 2019-02-20
*/
//
*/
public
class
RpcObjectHandler
<
T
>
implements
RpcTemplate
.
CallHandler
<
T
>
{
//
public class RpcObjectHandler<T> implements RpcTemplate.CallHandler<T> {
//
private
Class
<
T
>
tClass
;
//
private Class<T> tClass;
//
//
public
RpcObjectHandler
(
Class
<
T
>
tClass
)
{
this
.
tClass
=
tClass
;}
//
public RpcObjectHandler(Class<T> tClass) {this.tClass = tClass;}
//
@Override
//
@Override
public
T
handle
(
String
resp
)
throws
IOException
{
//
public T handle(String resp) throws IOException {
return
JSON
.
parseObject
(
resp
,
tClass
);
//
return JSON.parseObject(resp, tClass);
}
//
}
}
//
}
yanxuan-qc-change-system-integration/src/main/java/com/netease/mail/yanxuan/change/integration/email/service/IEmailEhcService.java
View file @
b791dea4
package
com
.
netease
.
mail
.
yanxuan
.
change
.
integration
.
email
.
service
;
//
package com.netease.mail.yanxuan.change.integration.email.service;
//
import
com.netease.mail.yanxuan.change.integration.email.email.*
;
//
import com.netease.mail.yanxuan.change.integration.email.email.*;
import
com.netease.mail.yanxuan.change.integration.email.enums.EmailEhcFlowEnum
;
//
import com.netease.mail.yanxuan.change.integration.email.enums.EmailEhcFlowEnum;
import
java.io.File
;
//
import java.io.File;
import
java.util.Collection
;
//
import java.util.Collection;
import
java.util.List
;
//
import java.util.List;
//
public
interface
IEmailEhcService
{
//
public interface IEmailEhcService {
/**
//
/**
* 任务工单发送邮件
//
* 任务工单发送邮件
*
//
*
* @param toList
//
* @param toList
* 收件人列表
//
* 收件人列表
* @param ccList
//
* @param ccList
* 抄送人列表
//
* 抄送人列表
* @param model
//
* @param model
* 要素
//
* 要素
* @param emailEhcFlowEnum
//
* @param emailEhcFlowEnum
*/
//
*/
void
sendTaskEmail
(
Collection
<
String
>
toList
,
Collection
<
String
>
ccList
,
AbnormalTaskFlowEhcEmailModel
model
,
//
void sendTaskEmail(Collection<String> toList, Collection<String> ccList, AbnormalTaskFlowEhcEmailModel model,
EmailEhcFlowEnum
emailEhcFlowEnum
);
//
EmailEhcFlowEnum emailEhcFlowEnum);
//
/**
//
/**
* 供应商专属邮件发送
//
* 供应商专属邮件发送
*
// *
* @param supplierId
//
* @param supplierId
* @param model
//
* @param model
* @param emailEhcFlowEnum
//
* @param emailEhcFlowEnum
*/
//
*/
void
sendSupplierEmail
(
String
supplierId
,
AbnormalTaskFlowEhcEmailModel
model
,
EmailEhcFlowEnum
emailEhcFlowEnum
);
//
void sendSupplierEmail(String supplierId, AbnormalTaskFlowEhcEmailModel model, EmailEhcFlowEnum emailEhcFlowEnum);
//
/**
//
/**
* 供应商惩罚工单发送邮件
//
* 供应商惩罚工单发送邮件
*
// *
* @param toList
//
* @param toList
* @param ccList
//
* @param ccList
* @param model
//
* @param model
* @param emailEhcFlowEnum
//
* @param emailEhcFlowEnum
*/
//
*/
void
sendPunishEmail
(
Collection
<
String
>
toList
,
Collection
<
String
>
ccList
,
AbnormalPunishFlowEhcEmailModel
model
,
//
void sendPunishEmail(Collection<String> toList, Collection<String> ccList, AbnormalPunishFlowEhcEmailModel model,
EmailEhcFlowEnum
emailEhcFlowEnum
);
//
EmailEhcFlowEnum emailEhcFlowEnum);
//
/**
//
/**
* 异常问题工单发送邮件
//
* 异常问题工单发送邮件
*
//
*
* @param toList
//
* @param toList
* 收件人列表
//
* 收件人列表
* @param ccList
//
* @param ccList
* 抄送人列表.
//
* 抄送人列表.
* @param emailEhcFlowEnum
//
* @param emailEhcFlowEnum
* 邮件模板
//
* 邮件模板
* @param abnormalEhcEmailModel
//
* @param abnormalEhcEmailModel
* 数据
//
* 数据
*/
//
*/
void
sendAbnormalEmail
(
Collection
<
String
>
toList
,
Collection
<
String
>
ccList
,
EmailEhcFlowEnum
emailEhcFlowEnum
,
//
void sendAbnormalEmail(Collection<String> toList, Collection<String> ccList, EmailEhcFlowEnum emailEhcFlowEnum,
AbnormalEhcEmailModel
abnormalEhcEmailModel
);
//
AbnormalEhcEmailModel abnormalEhcEmailModel);
//
/**
//
/**
* 批量事件工单发送邮件
//
* 批量事件工单发送邮件
*
// *
* @param toList
//
* @param toList
* @param ccList
//
* @param ccList
* @param model
//
* @param model
* @param
//
* @param
*/
//
*/
void
sendBathEventEmail
(
Collection
<
String
>
toList
,
Collection
<
String
>
ccList
,
AbnormalBathEventEhcEmailModel
model
,
//
void sendBathEventEmail(Collection<String> toList, Collection<String> ccList, AbnormalBathEventEhcEmailModel model,
EmailEhcFlowEnum
emailEhcFlowEnum
);
//
EmailEhcFlowEnum emailEhcFlowEnum);
//
/**
//
/**
* 临期/过期工单发送邮件
//
* 临期/过期工单发送邮件
*
// *
* @param toList
//
* @param toList
* @param ccList
//
* @param ccList
* @param model
//
* @param model
* @param emailEhcFlowEnum
//
* @param emailEhcFlowEnum
*/
//
*/
void
sendOverTimeEmail
(
Collection
<
String
>
toList
,
Collection
<
String
>
ccList
,
FlowEhcOverTimeEmailModel
model
,
//
void sendOverTimeEmail(Collection<String> toList, Collection<String> ccList, FlowEhcOverTimeEmailModel model,
EmailEhcFlowEnum
emailEhcFlowEnum
);
//
EmailEhcFlowEnum emailEhcFlowEnum);
//
/**
//
/**
* 邮件发送
//
* 邮件发送
*
//
*
* @param toList
//
* @param toList
* 收件人列表
//
* 收件人列表
* @param ccList
//
* @param ccList
* 抄送人列表
//
* 抄送人列表
* @param factor
//
* @param factor
* 要素
//
* 要素
* @param fileList
//
* @param fileList
* 附件
//
* 附件
*/
//
*/
void
sendEmail
(
Collection
<
String
>
toList
,
Collection
<
String
>
ccList
,
EmailEhcFactor
factor
,
List
<
File
>
fileList
);
//
void sendEmail(Collection<String> toList, Collection<String> ccList, EmailEhcFactor factor, List<File> fileList);
//
/**
//
/**
* 获取邮件发送工单地址
//
* 获取邮件发送工单地址
*
// *
* @param uid
//
* @param uid
* @return
//
* @return
*/
//
*/
String
getEmailContentUrl
(
String
uid
);
//
String getEmailContentUrl(String uid);
//
/**
//
/**
* 获取异常任务工单邮件发送地址
//
* 获取异常任务工单邮件发送地址
*
// *
* @param uid
//
* @param uid
* @param execUserType
//
* @param execUserType
* @return
//
* @return
*/
//
*/
String
getTaskFlowEmailUrl
(
String
uid
,
Integer
execUserType
);
//
String getTaskFlowEmailUrl(String uid, Integer execUserType);
}
//
}
yanxuan-qc-change-system-integration/src/main/java/com/netease/mail/yanxuan/change/integration/email/service/IEmailService.java
View file @
b791dea4
package
com
.
netease
.
mail
.
yanxuan
.
change
.
integration
.
email
.
service
;
//
package com.netease.mail.yanxuan.change.integration.email.service;
//
import
com.netease.mail.yanxuan.change.integration.email.email.EmailFactor
;
//
import com.netease.mail.yanxuan.change.integration.email.email.EmailFactor;
import
java.io.File
;
//
import java.io.File;
import
java.util.Collection
;
//
import java.util.Collection;
import
java.util.List
;
//
import java.util.List;
//
/**
/
//
**
* 发送邮件
//
* 发送邮件
*/
//
*/
public
interface
IEmailService
{
//
public interface IEmailService {
//
/**
//
/**
* @param to 收件人
//
* @param to 收件人
* @param emailFactor 邮件要素
//
* @param emailFactor 邮件要素
*/
//
*/
void
sendEmail
(
String
to
,
EmailFactor
emailFactor
);
//
void sendEmail(String to, EmailFactor emailFactor);
//
/**
//
/**
* @param toList 收件人列表
//
* @param toList 收件人列表
* @param factor 要素
//
* @param factor 要素
*/
//
*/
void
sendEmail
(
Collection
<
String
>
toList
,
EmailFactor
factor
);
//
void sendEmail(Collection<String> toList, EmailFactor factor);
//
/**
//
/**
* @param toList 收件人
//
* @param toList 收件人
* @param ccList 抄送人
//
* @param ccList 抄送人
* @param factor 要素
//
* @param factor 要素
* @param fileList 附件
//
* @param fileList 附件
*/
//
*/
void
sendEmail
(
String
toList
,
String
ccList
,
EmailFactor
factor
,
List
<
File
>
fileList
);
//
void sendEmail(String toList, String ccList, EmailFactor factor,List<File> fileList);
//
/**
//
/**
*
//
*
* @param toList 收件人列表
//
* @param toList 收件人列表
* @param ccList 抄送人列表
//
* @param ccList 抄送人列表
* @param factor 要素
//
* @param factor 要素
*/
//
*/
void
sendEmail
(
Collection
<
String
>
toList
,
Collection
<
String
>
ccList
,
EmailFactor
factor
);
//
void sendEmail(Collection<String> toList, Collection<String> ccList, EmailFactor factor);
//
/**
//
/**
* @param toList 收件人列表
//
* @param toList 收件人列表
* @param ccList 抄送人列表
//
* @param ccList 抄送人列表
* @param factor 要素
//
* @param factor 要素
* @param fileList 附件
//
* @param fileList 附件
*/
//
*/
void
sendEmail
(
Collection
<
String
>
toList
,
Collection
<
String
>
ccList
,
EmailFactor
factor
,
List
<
File
>
fileList
);
//
void sendEmail(Collection<String> toList, Collection<String> ccList, EmailFactor factor, List<File> fileList);
//
//
}
//
}
yanxuan-qc-change-system-integration/src/main/java/com/netease/mail/yanxuan/change/integration/email/service/IIusService.java
View file @
b791dea4
package
com
.
netease
.
mail
.
yanxuan
.
change
.
integration
.
email
.
service
;
//
package com.netease.mail.yanxuan.change.integration.email.service;
//
import
java.util.List
;
//
import java.util.List;
//
import
com.netease.mail.yanxuan.change.integration.email.dto.DeptIdLevelLeaderDTO
;
//
import com.netease.mail.yanxuan.change.integration.email.dto.DeptIdLevelLeaderDTO;
import
com.netease.mail.yanxuan.change.integration.email.dto.ThirdOrgPosDTO
;
//
import com.netease.mail.yanxuan.change.integration.email.dto.ThirdOrgPosDTO;
import
com.netease.mail.yanxuan.change.integration.email.dto.UserInfoDTO
;
//
import com.netease.mail.yanxuan.change.integration.email.dto.UserInfoDTO;
import
com.netease.mail.yanxuan.change.integration.email.dto.UserUniteOrgMetaDTO
;
//
import com.netease.mail.yanxuan.change.integration.email.dto.UserUniteOrgMetaDTO;
import
com.netease.mail.yanxuan.change.integration.email.email.SearchResult
;
//
import com.netease.mail.yanxuan.change.integration.email.email.SearchResult;
import
com.netease.mail.yanxuan.change.integration.email.dto.UserProductRoleStaticsInfosDTO
;
//
import com.netease.mail.yanxuan.change.integration.email.dto.UserProductRoleStaticsInfosDTO;
import
com.netease.mail.yanxuan.change.integration.email.email.UserVO
;
//
import com.netease.mail.yanxuan.change.integration.email.email.UserVO;
import
com.netease.yanxuan.flowx.sdk.meta.dto.base.UserBaseDTO
;
//
import com.netease.yanxuan.flowx.sdk.meta.dto.base.UserBaseDTO;
//
/**
/
//
**
* @author jiyuwang 商品是否有模块化受控标准
//
* @author jiyuwang 商品是否有模块化受控标准
*/
//
*/
public
interface
IIusService
{
//
public interface IIusService {
//
/**
//
/**
* 获取用户的部门信息和在职情况
//
* 获取用户的部门信息和在职情况
*
// *
* @param uid
//
* @param uid
* @return
//
* @return
*/
//
*/
UserInfoDTO
getUserInfo
(
String
uid
);
//
UserInfoDTO getUserInfo(String uid);
//
/**
//
/**
* 查询用户集合,不传时查全部
//
* 查询用户集合,不传时查全部
* http://yx.mail.netease.com/bee#/interface/list;serviceCode=yanxuan-ius;branchName=master;selectedInterface=1010712
//
* http://yx.mail.netease.com/bee#/interface/list;serviceCode=yanxuan-ius;branchName=master;selectedInterface=1010712
* @param productCode
//
* @param productCode
* @param uid
//
* @param uid
* @return
//
* @return
*/
//
*/
List
<
UserInfoDTO
>
queryUserInfo
(
String
productCode
,
String
uid
);
//
List<UserInfoDTO> queryUserInfo(String productCode, String uid);
//
/**
//
/**
* 根据uid获取部门
//
* 根据uid获取部门
*
// *
* @param uid
//
* @param uid
* @return
//
* @return
*/
//
*/
String
getOrgByUid
(
String
uid
);
//
String getOrgByUid(String uid);
//
/**
//
/**
* 判断用户是否离职
//
* 判断用户是否离职
*
// *
* @param uid
//
* @param uid
* @return true: 离职;false: 未离职
//
* @return true: 离职;false: 未离职
*/
//
*/
boolean
checkUserIsLeave
(
String
uid
);
//
boolean checkUserIsLeave(String uid);
//
/**
//
/**
* 获取部门负责人
//
* 获取部门负责人
*
// *
* @param uid
//
* @param uid
* @param orgPosId
//
* @param orgPosId
* @return
//
* @return
*/
//
*/
List
<
DeptIdLevelLeaderDTO
>
getDeptIdLevelLeader
(
String
uid
,
Integer
orgPosId
);
//
List<DeptIdLevelLeaderDTO> getDeptIdLevelLeader(String uid, Integer orgPosId);
//
/**
//
/**
* 根据用户获取三级部门负责人
//
* 根据用户获取三级部门负责人
*
// *
* @param uid
//
* @param uid
* @return
//
* @return
*/
//
*/
List
<
DeptIdLevelLeaderDTO
>
getThreeLevelDeptLeader
(
String
uid
);
//
List<DeptIdLevelLeaderDTO> getThreeLevelDeptLeader(String uid);
//
/**
//
/**
* 获取四级部门负责人
//
* 获取四级部门负责人
* @param uid
//
* @param uid
* @return
//
* @return
*/
//
*/
List
<
DeptIdLevelLeaderDTO
>
getForthLevelDeptLeader
(
String
uid
);
//
List<DeptIdLevelLeaderDTO> getForthLevelDeptLeader(String uid);
//
/**
//
/**
* 模糊查询用户信息
//
* 模糊查询用户信息
*/
//
*/
List
<
UserUniteOrgMetaDTO
>
fuzzyQueryUserInformation
(
int
queryType
,
String
keyword
);
//
List<UserUniteOrgMetaDTO> fuzzyQueryUserInformation(int queryType, String keyword);
//
/**
//
/**
* 模糊查询用户信息(权限中心)
//
* 模糊查询用户信息(权限中心)
*/
//
*/
List
<
UserUniteOrgMetaDTO
>
fuzzyQueryUserInfo
(
Long
orgPosId
,
int
level
,
int
type
,
int
queryType
,
String
keyword
);
//
List<UserUniteOrgMetaDTO> fuzzyQueryUserInfo(Long orgPosId, int level, int type, int queryType, String keyword);
//
/**
//
/**
* 获得该系统下的该用户组织身份权限或者特殊权限
//
* 获得该系统下的该用户组织身份权限或者特殊权限
*
// *
* @param staff
//
* @param staff
* @param roleId
//
* @param roleId
* @param orgPosId
//
* @param orgPosId
* @param stationId
//
* @param stationId
* @param locked
//
* @param locked
* @param keyword
//
* @param keyword
* @param curPage
//
* @param curPage
* @param pageSize
//
* @param pageSize
* @return
//
* @return
*/
//
*/
SearchResult
<
UserProductRoleStaticsInfosDTO
>
getAllUserProductRoleInfos
(
Integer
staff
,
Long
roleId
,
Long
orgPosId
,
//
SearchResult<UserProductRoleStaticsInfosDTO> getAllUserProductRoleInfos(Integer staff, Long roleId, Long orgPosId,
Integer
stationId
,
Integer
locked
,
String
keyword
,
Integer
curPage
,
Integer
pageSize
);
//
Integer stationId, Integer locked, String keyword, Integer curPage, Integer pageSize);
//
/**
//
/**
* 根据产品号和 roleId 获取用户列表
//
* 根据产品号和 roleId 获取用户列表
*
// *
* @param productCode
//
* @param productCode
* @param roleId
//
* @param roleId
* @return
//
* @return
*/
//
*/
List
<
UserBaseDTO
>
listUserByRoleId
(
String
productCode
,
Long
roleId
);
//
List<UserBaseDTO> listUserByRoleId(String productCode, Long roleId);
//
/**
//
/**
* 根据uid获取三级部门人员相关信息
//
* 根据uid获取三级部门人员相关信息
* @param uid
//
* @param uid
* @return
//
* @return
*/
//
*/
UserVO
lv3UserInfo
(
String
uid
);
//
UserVO lv3UserInfo(String uid);
//
/**
//
/**
* 获取用户所在系统编码(弃用)
//
* 获取用户所在系统编码(弃用)
*
//
*
* @param uid
//
* @param uid
* @return
//
* @return
*/
//
*/
@Deprecated
//
@Deprecated
List
<
String
>
listProductHasUid
(
String
uid
);
//
List<String> listProductHasUid(String uid);
//
/**
//
/**
* 三级部门查询列表
//
* 三级部门查询列表
* @param name
//
* @param name
* @return
//
* @return
*/
//
*/
List
<
ThirdOrgPosDTO
>
getThirdOrgPosName
(
String
name
);
//
List<ThirdOrgPosDTO> getThirdOrgPosName(String name);
//
//
//
//
}
//
}
yanxuan-qc-change-system-integration/src/main/java/com/netease/mail/yanxuan/change/integration/email/service/ISupplierEmailService.java
View file @
b791dea4
package
com
.
netease
.
mail
.
yanxuan
.
change
.
integration
.
email
.
service
;
//package com.netease.mail.yanxuan.change.integration.email.service;
//
//
import
com.netease.mail.yanxuan.change.integration.email.email.SupplierEmailResponseResult
;
//import com.netease.mail.yanxuan.change.integration.email.email.SupplierEmailResponseResult;
import
com.netease.mail.yanxuan.change.integration.email.email.SupplierEmailSendReq
;
//import com.netease.mail.yanxuan.change.integration.email.email.SupplierEmailSendReq;
//
public
interface
ISupplierEmailService
{
//public interface ISupplierEmailService {
//
SupplierEmailResponseResult
sendSupplierEmail
(
SupplierEmailSendReq
req
);
// SupplierEmailResponseResult sendSupplierEmail(SupplierEmailSendReq req);
}
//}
\ No newline at end of file
\ No newline at end of file
yanxuan-qc-change-system-integration/src/main/java/com/netease/mail/yanxuan/change/integration/email/service/IUasEhcClient.java
View file @
b791dea4
package
com
.
netease
.
mail
.
yanxuan
.
change
.
integration
.
email
.
service
;
//package com.netease.mail.yanxuan.change.integration.email.service;
//
import
java.io.File
;
//import java.io.File;
import
java.util.Collection
;
//import java.util.Collection;
import
java.util.List
;
//import java.util.List;
//
public
interface
IUasEhcClient
{
//public interface IUasEhcClient {
//
/**
// /**
* 邮件发送
// * 邮件发送
*
// *
* @param subject
// * @param subject
* @param content
// * @param content
* @param toList
// * @param toList
* @param ccList
// * @param ccList
* @param fileList
// * @param fileList
*/
// */
void
sendEmail
(
String
subject
,
String
content
,
Collection
<
String
>
toList
,
Collection
<
String
>
ccList
,
// void sendEmail(String subject, String content, Collection<String> toList, Collection<String> ccList,
List
<
File
>
fileList
);
// List<File> fileList);
}
//}
\ No newline at end of file
\ No newline at end of file
yanxuan-qc-change-system-integration/src/main/java/com/netease/mail/yanxuan/change/integration/email/util/EncodeUtil.java
View file @
b791dea4
package
com
.
netease
.
mail
.
yanxuan
.
change
.
integration
.
email
.
util
;
//
package com.netease.mail.yanxuan.change.integration.email.util;
//
import
java.net.URLDecoder
;
//
import java.net.URLDecoder;
import
java.net.URLEncoder
;
//
import java.net.URLEncoder;
import
java.util.ArrayList
;
//
import java.util.ArrayList;
import
java.util.List
;
//
import java.util.List;
import
java.util.Map
;
//
import java.util.Map;
import
org.apache.commons.lang3.StringUtils
;
//
import org.apache.commons.lang3.StringUtils;
//
/**
/
//
**
* @author lwtang
//
* @author lwtang
* @date 2019-02-19
//
* @date 2019-02-19
*/
//
*/
public
class
EncodeUtil
{
//
public class EncodeUtil {
//
private
static
final
char
[]
CHARS
=
new
char
[]
{
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
//
private static final char[] CHARS = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8',
'9'
,
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
};
//
'9', 'a', 'b', 'c', 'd', 'e', 'f' };
//
public
static
String
encode
(
String
text
)
{
//
public static String encode(String text) {
try
{
//
try {
return
URLEncoder
.
encode
(
text
,
"UTF-8"
);
//
return URLEncoder.encode(text, "UTF-8");
}
catch
(
Exception
e
)
{
//
} catch (Exception e) {
return
text
;
//
return text;
}
//
}
}
//
}
//
public
static
String
encodeMap
(
Map
<?,
?>
map
)
{
//
public static String encodeMap(Map<?, ?> map) {
List
<
String
>
lines
=
new
ArrayList
<>();
//
List<String> lines = new ArrayList<>();
for
(
Map
.
Entry
<?,
?>
entry:
map
.
entrySet
())
{
//
for (Map.Entry<?, ?> entry: map.entrySet()) {
lines
.
add
(
String
.
valueOf
(
entry
.
getKey
())
+
"="
+
String
.
valueOf
(
entry
.
getValue
()));
//
lines.add(String.valueOf(entry.getKey()) + "=" + String.valueOf(entry.getValue()));
}
//
}
return
StringUtils
.
join
(
lines
,
"&"
);
//
return StringUtils.join(lines, "&");
}
//
}
//
public
static
String
decode
(
String
text
)
{
//
public static String decode(String text) {
try
{
//
try {
return
URLDecoder
.
decode
(
text
,
"UTF-8"
);
//
return URLDecoder.decode(text, "UTF-8");
}
catch
(
Exception
e
)
{
//
} catch (Exception e) {
return
text
;
//
return text;
}
//
}
}
//
}
//
public
static
String
ASCIIHex
(
String
text
)
{
//
public static String ASCIIHex(String text) {
byte
[]
bytes
=
text
.
getBytes
();
//
byte[] bytes = text.getBytes();
char
[]
chars
=
new
char
[
bytes
.
length
*
2
];
//
char[] chars = new char[bytes.length * 2];
for
(
int
i
=
0
;
i
<
bytes
.
length
;
i
++)
{
//
for (int i = 0; i < bytes.length; i++) {
chars
[
2
*
i
]
=
CHARS
[
bytes
[
i
]
>>
4
];
//
chars[2 * i] = CHARS[bytes[i] >> 4];
chars
[
2
*
i
+
1
]
=
CHARS
[
bytes
[
i
]
%
16
];
//
chars[2 * i + 1] = CHARS[bytes[i] % 16];
}
//
}
return
new
String
(
chars
).
toUpperCase
();
//
return new String(chars).toUpperCase();
}
//
}
//
}
//
}
yanxuan-qc-change-system-integration/src/main/java/com/netease/mail/yanxuan/change/integration/email/util/HttpClientUtil.java
View file @
b791dea4
package
com
.
netease
.
mail
.
yanxuan
.
change
.
integration
.
email
.
util
;
//
package com.netease.mail.yanxuan.change.integration.email.util;
//
import
com.netease.mail.yanxuan.change.integration.email.exception.RpcConnectException
;
//
import com.netease.mail.yanxuan.change.integration.email.exception.RpcConnectException;
import
com.netease.mail.yanxuan.change.integration.email.exception.RpcException
;
//
import com.netease.mail.yanxuan.change.integration.email.exception.RpcException;
import
com.netease.mail.yanxuan.change.integration.email.exception.RpcStatusException
;
//
import com.netease.mail.yanxuan.change.integration.email.exception.RpcStatusException;
import
com.netease.mail.yanxuan.change.integration.email.exception.RpcTimeoutException
;
//
import com.netease.mail.yanxuan.change.integration.email.exception.RpcTimeoutException;
import
org.apache.http.Consts
;
//
import org.apache.http.Consts;
import
org.apache.http.Header
;
//
import org.apache.http.Header;
import
org.apache.http.HttpEntity
;
//
import org.apache.http.HttpEntity;
import
org.apache.http.client.config.RequestConfig
;
//
import org.apache.http.client.config.RequestConfig;
import
org.apache.http.client.entity.UrlEncodedFormEntity
;
//
import org.apache.http.client.entity.UrlEncodedFormEntity;
import
org.apache.http.client.methods.CloseableHttpResponse
;
//
import org.apache.http.client.methods.CloseableHttpResponse;
import
org.apache.http.client.methods.HttpGet
;
//
import org.apache.http.client.methods.HttpGet;
import
org.apache.http.client.methods.HttpPost
;
//
import org.apache.http.client.methods.HttpPost;
import
org.apache.http.client.methods.HttpRequestBase
;
//
import org.apache.http.client.methods.HttpRequestBase;
import
org.apache.http.config.*
;
//
import org.apache.http.config.*;
import
org.apache.http.conn.socket.ConnectionSocketFactory
;
//
import org.apache.http.conn.socket.ConnectionSocketFactory;
import
org.apache.http.conn.socket.PlainConnectionSocketFactory
;
//
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import
org.apache.http.conn.ssl.SSLConnectionSocketFactory
;
//
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import
org.apache.http.entity.ContentType
;
//
import org.apache.http.entity.ContentType;
import
org.apache.http.entity.StringEntity
;
//
import org.apache.http.entity.StringEntity;
import
org.apache.http.impl.client.CloseableHttpClient
;
//
import org.apache.http.impl.client.CloseableHttpClient;
import
org.apache.http.impl.client.HttpClients
;
//
import org.apache.http.impl.client.HttpClients;
import
org.apache.http.impl.conn.PoolingHttpClientConnectionManager
;
//
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import
org.apache.http.message.BasicHeader
;
//
import org.apache.http.message.BasicHeader;
import
org.apache.http.message.BasicNameValuePair
;
//
import org.apache.http.message.BasicNameValuePair;
import
org.apache.http.ssl.SSLContexts
;
//
import org.apache.http.ssl.SSLContexts;
import
org.apache.http.util.EntityUtils
;
//
import org.apache.http.util.EntityUtils;
import
org.slf4j.Logger
;
//
import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
//
import org.slf4j.LoggerFactory;
//
import
javax.net.ssl.SSLContext
;
//
import javax.net.ssl.SSLContext;
import
javax.net.ssl.TrustManager
;
//
import javax.net.ssl.TrustManager;
import
javax.net.ssl.X509TrustManager
;
//
import javax.net.ssl.X509TrustManager;
import
java.io.IOException
;
//
import java.io.IOException;
import
java.io.UnsupportedEncodingException
;
//
import java.io.UnsupportedEncodingException;
import
java.net.ConnectException
;
//
import java.net.ConnectException;
import
java.net.SocketTimeoutException
;
//
import java.net.SocketTimeoutException;
import
java.net.URI
;
//
import java.net.URI;
import
java.net.URLEncoder
;
//
import java.net.URLEncoder;
import
java.nio.charset.CodingErrorAction
;
//
import java.nio.charset.CodingErrorAction;
import
java.security.KeyManagementException
;
//
import java.security.KeyManagementException;
import
java.security.NoSuchAlgorithmException
;
//
import java.security.NoSuchAlgorithmException;
import
java.security.cert.CertificateException
;
//
import java.security.cert.CertificateException;
import
java.security.cert.X509Certificate
;
//
import java.security.cert.X509Certificate;
import
java.util.HashMap
;
//
import java.util.HashMap;
import
java.util.List
;
//
import java.util.List;
import
java.util.Map
;
//
import java.util.Map;
import
java.util.stream.Collectors
;
//
import java.util.stream.Collectors;
//
/**
/
//
**
* HttpClient 封装
//
* HttpClient 封装
*
//
*
* @author lwtang
//
* @author lwtang
* @date 2019-02-19
//
* @date 2019-02-19
*/
//
*/
public
class
HttpClientUtil
{
//
public class HttpClientUtil {
//
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
HttpClientUtil
.
class
);
//
private static final Logger LOG = LoggerFactory.getLogger(HttpClientUtil.class);
//
private
static
final
int
DEFAULT_TIME_OUT
=
5000
;
//
private static final int DEFAULT_TIME_OUT = 5000;
//
private
static
final
String
DEFAULT_ENCODING
=
"UTF-8"
;
//
private static final String DEFAULT_ENCODING = "UTF-8";
//
private
static
PoolingHttpClientConnectionManager
connManager
=
null
;
//
private static PoolingHttpClientConnectionManager connManager = null;
//
private
static
CloseableHttpClient
httpclient
=
null
;
//
private static CloseableHttpClient httpclient = null;
//
//
static
{
//
static {
try
{
//
try {
SSLContext
sslContext
=
SSLContexts
.
custom
().
build
();
//
SSLContext sslContext = SSLContexts.custom().build();
sslContext
.
init
(
null
,
new
TrustManager
[]
{
new
DefaultTrustManager
()
},
null
);
//
sslContext.init(null, new TrustManager[] { new DefaultTrustManager() }, null);
//
Registry
<
ConnectionSocketFactory
>
socketFactoryRegistry
=
RegistryBuilder
//
Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder
.<
ConnectionSocketFactory
>
create
()
//
.<ConnectionSocketFactory>create()
.
register
(
"http"
,
PlainConnectionSocketFactory
.
INSTANCE
)
//
.register("http", PlainConnectionSocketFactory.INSTANCE)
.
register
(
"https"
,
new
SSLConnectionSocketFactory
(
sslContext
)).
build
();
//
.register("https", new SSLConnectionSocketFactory(sslContext)).build();
//
connManager
=
new
PoolingHttpClientConnectionManager
(
socketFactoryRegistry
);
//
connManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry);
httpclient
=
HttpClients
.
custom
().
setConnectionManager
(
connManager
).
build
();
//
httpclient = HttpClients.custom().setConnectionManager(connManager).build();
// Create socket configuration
//
// Create socket configuration
SocketConfig
socketConfig
=
SocketConfig
.
custom
().
setSoKeepAlive
(
true
)
//
SocketConfig socketConfig = SocketConfig.custom().setSoKeepAlive(true)
.
setSoReuseAddress
(
true
).
setSoTimeout
(
DEFAULT_TIME_OUT
).
setTcpNoDelay
(
true
).
build
();
//
.setSoReuseAddress(true).setSoTimeout(DEFAULT_TIME_OUT).setTcpNoDelay(true).build();
connManager
.
setDefaultSocketConfig
(
socketConfig
);
//
connManager.setDefaultSocketConfig(socketConfig);
// Create message constraints
//
// Create message constraints
MessageConstraints
messageConstraints
=
MessageConstraints
.
custom
()
//
MessageConstraints messageConstraints = MessageConstraints.custom()
.
setMaxHeaderCount
(
200
).
setMaxLineLength
(
2000
).
build
();
//
.setMaxHeaderCount(200).setMaxLineLength(2000).build();
// Create connection configuration
//
// Create connection configuration
ConnectionConfig
connectionConfig
=
ConnectionConfig
.
custom
()
//
ConnectionConfig connectionConfig = ConnectionConfig.custom()
.
setMalformedInputAction
(
CodingErrorAction
.
IGNORE
)
//
.setMalformedInputAction(CodingErrorAction.IGNORE)
.
setUnmappableInputAction
(
CodingErrorAction
.
IGNORE
).
setCharset
(
Consts
.
UTF_8
)
//
.setUnmappableInputAction(CodingErrorAction.IGNORE).setCharset(Consts.UTF_8)
.
setMessageConstraints
(
messageConstraints
).
build
();
//
.setMessageConstraints(messageConstraints).build();
connManager
.
setDefaultConnectionConfig
(
connectionConfig
);
//
connManager.setDefaultConnectionConfig(connectionConfig);
connManager
.
setMaxTotal
(
300
);
//
connManager.setMaxTotal(300);
connManager
.
setDefaultMaxPerRoute
(
100
);
//
connManager.setDefaultMaxPerRoute(100);
}
catch
(
KeyManagementException
e
)
{
//
} catch (KeyManagementException e) {
LOG
.
error
(
"KeyManagementException"
,
e
);
//
LOG.error("KeyManagementException", e);
}
catch
(
NoSuchAlgorithmException
e
)
{
//
} catch (NoSuchAlgorithmException e) {
LOG
.
error
(
"NoSuchAlgorithmException"
,
e
);
//
LOG.error("NoSuchAlgorithmException", e);
}
//
}
}
//
}
//
public
static
String
get
(
String
url
,
Map
<
String
,
Object
>
params
,
Map
<
String
,
String
>
header
,
//
public static String get(String url, Map<String, Object> params, Map<String, String> header,
int
timeout
)
{
//
int timeout) {
return
doGet
(
url
,
params
,
header
,
DEFAULT_ENCODING
,
timeout
);
//
return doGet(url, params, header, DEFAULT_ENCODING, timeout);
}
//
}
//
public
static
String
doGet
(
String
url
,
Map
<
String
,
Object
>
params
,
Map
<
String
,
String
>
header
,
//
public static String doGet(String url, Map<String, Object> params, Map<String, String> header,
String
encoding
,
int
timeout
)
{
//
String encoding, int timeout) {
String
responseString
=
null
;
//
String responseString = null;
//
HttpGet
get
=
new
HttpGet
();
//
HttpGet get = new HttpGet();
fillUrl
(
url
,
params
,
encoding
,
get
);
//
fillUrl(url, params, encoding, get);
fillHeader
(
header
,
get
);
//
fillHeader(header, get);
fillConfig
(
timeout
,
timeout
,
get
);
//
fillConfig(timeout, timeout, get);
//
try
{
//
try {
CloseableHttpResponse
response
=
httpclient
.
execute
(
get
);
//
CloseableHttpResponse response = httpclient.execute(get);
try
{
//
try {
int
resHttpCode
=
response
.
getStatusLine
().
getStatusCode
();
//
int resHttpCode = response.getStatusLine().getStatusCode();
if
(
resHttpCode
!=
200
)
{
//
if( resHttpCode != 200) {
throw
new
RpcStatusException
(
resHttpCode
,
"status code "
+
resHttpCode
+
" not equal 200"
);
//
throw new RpcStatusException(resHttpCode, "status code " + resHttpCode + " not equal 200");
}
//
}
HttpEntity
entity
=
response
.
getEntity
();
//
HttpEntity entity = response.getEntity();
try
{
//
try {
if
(
entity
!=
null
)
{
//
if (entity != null) {
responseString
=
EntityUtils
.
toString
(
entity
,
encoding
);
//
responseString = EntityUtils.toString(entity, encoding);
}
//
}
}
finally
{
//
} finally {
if
(
entity
!=
null
)
{
//
if (entity != null) {
entity
.
getContent
().
close
();
//
entity.getContent().close();
}
//
}
}
//
}
return
responseString
;
//
return responseString;
}
catch
(
Exception
e
)
{
//
} catch (Exception e) {
LOG
.
error
(
"[HttpUtils Get response error]"
,
e
);
//
LOG.error("[HttpUtils Get response error]", e);
throw
e
;
//
throw e;
}
finally
{
//
} finally {
if
(
response
!=
null
)
{
//
if (response != null) {
response
.
close
();
//
response.close();
}
//
}
}
//
}
}
catch
(
ConnectException
e
)
{
//
} catch (ConnectException e) {
throw
new
RpcConnectException
(
"request connect failed!"
);
//
throw new RpcConnectException("request connect failed!");
}
catch
(
SocketTimeoutException
e
)
{
//
} catch (SocketTimeoutException e) {
throw
new
RpcTimeoutException
(
"request timeout!"
);
//
throw new RpcTimeoutException("request timeout!");
}
catch
(
IOException
e
)
{
//
} catch (IOException e) {
LOG
.
error
(
"[query webservice error]"
,
e
);
//
LOG.error("[query webservice error]", e);
}
finally
{
//
} finally {
get
.
releaseConnection
();
//
get.releaseConnection();
}
//
}
return
responseString
;
//
return responseString;
}
//
}
//
//
//
public
static
String
postJson
(
String
url
,
String
params
,
int
timeout
)
{
//
public static String postJson(String url, String params, int timeout) {
Map
<
String
,
String
>
header
=
new
HashMap
<>();
//
Map<String, String> header = new HashMap<>();
header
.
put
(
"Content-type"
,
ContentType
.
APPLICATION_JSON
.
getMimeType
());
//
header.put("Content-type", ContentType.APPLICATION_JSON.getMimeType());
return
doPost
(
url
,
new
StringEntity
(
params
,
DEFAULT_ENCODING
),
header
,
DEFAULT_ENCODING
,
//
return doPost(url, new StringEntity(params, DEFAULT_ENCODING), header, DEFAULT_ENCODING,
timeout
);
//
timeout);
}
//
}
//
//
public
static
String
post
(
String
url
,
Map
<
String
,
Object
>
params
,
int
timeout
)
{
//
public static String post(String url, Map<String, Object> params, int timeout) {
Map
<
String
,
String
>
header
=
new
HashMap
<>();
//
Map<String, String> header = new HashMap<>();
header
.
put
(
"Content-type"
,
ContentType
.
APPLICATION_FORM_URLENCODED
.
getMimeType
());
//
header.put("Content-type", ContentType.APPLICATION_FORM_URLENCODED.getMimeType());
//
HttpEntity
httpEntity
=
null
;
//
HttpEntity httpEntity = null;
if
(
params
!=
null
&&
params
.
size
()
>
0
)
{
//
if (params != null && params.size() > 0) {
List
<
BasicNameValuePair
>
formParams
=
params
.
entrySet
().
stream
()
//
List<BasicNameValuePair> formParams = params.entrySet().stream()
.
map
(
entry
->
new
BasicNameValuePair
(
entry
.
getKey
(),
//
.map(entry -> new BasicNameValuePair(entry.getKey(),
entry
.
getValue
()
==
null
?
""
:
entry
.
getValue
().
toString
()))
//
entry.getValue() == null ? "" : entry.getValue().toString()))
.
collect
(
Collectors
.
toList
());
//
.collect(Collectors.toList());
//
try
{
//
try {
httpEntity
=
new
UrlEncodedFormEntity
(
formParams
,
DEFAULT_ENCODING
);
//
httpEntity = new UrlEncodedFormEntity(formParams, DEFAULT_ENCODING);
}
catch
(
UnsupportedEncodingException
e
)
{
//
} catch (UnsupportedEncodingException e) {
throw
new
RpcException
(
e
);
//
throw new RpcException(e);
}
//
}
}
//
}
return
doPost
(
url
,
httpEntity
,
header
,
DEFAULT_ENCODING
,
timeout
);
//
return doPost(url, httpEntity, header, DEFAULT_ENCODING, timeout);
}
//
}
//
//
public
static
String
doPost
(
String
url
,
HttpEntity
params
,
Map
<
String
,
String
>
header
,
//
public static String doPost(String url, HttpEntity params, Map<String, String> header,
String
encoding
,
int
timeout
)
{
//
String encoding, int timeout) {
String
responseContent
=
null
;
//
String responseContent = null;
//
HttpPost
post
=
new
HttpPost
(
url
);
//
HttpPost post = new HttpPost(url);
//
fillHeader
(
header
,
post
);
//
fillHeader(header, post);
fillConfig
(
timeout
,
timeout
,
post
);
//
fillConfig(timeout, timeout, post);
//
post
.
setEntity
(
params
);
//
post.setEntity(params);
try
{
//
try {
CloseableHttpResponse
response
=
httpclient
.
execute
(
post
);
//
CloseableHttpResponse response = httpclient.execute(post);
try
{
//
try {
HttpEntity
entity
=
response
.
getEntity
();
//
HttpEntity entity = response.getEntity();
responseContent
=
EntityUtils
.
toString
(
entity
,
encoding
);
//
responseContent = EntityUtils.toString(entity, encoding);
}
finally
{
//
} finally {
if
(
response
!=
null
)
{
//
if (response != null) {
response
.
close
();
//
response.close();
}
//
}
}
//
}
}
catch
(
ConnectException
e
)
{
//
} catch (ConnectException e) {
throw
new
RpcConnectException
(
"request connect failed!"
);
//
throw new RpcConnectException("request connect failed!");
}
catch
(
SocketTimeoutException
e
)
{
//
} catch (SocketTimeoutException e) {
throw
new
RpcTimeoutException
(
"request timeout!"
);
//
throw new RpcTimeoutException("request timeout!");
}
catch
(
IOException
e
)
{
//
} catch (IOException e) {
LOG
.
error
(
"[query webservice error]"
,
e
);
//
LOG.error("[query webservice error]", e);
}
finally
{
//
} finally {
post
.
releaseConnection
();
//
post.releaseConnection();
}
//
}
return
responseContent
;
//
return responseContent;
}
//
}
//
/**
//
/**
* concat url
//
* concat url
*/
//
*/
private
static
String
fillUrl
(
String
url
,
Map
<
String
,
Object
>
params
,
String
encoding
,
//
private static String fillUrl(String url, Map<String, Object> params, String encoding,
HttpRequestBase
requestBase
)
{
//
HttpRequestBase requestBase) {
StringBuilder
sb
=
new
StringBuilder
();
//
StringBuilder sb = new StringBuilder();
sb
.
append
(
url
);
//
sb.append(url);
int
i
=
0
;
//
int i = 0;
if
(
params
!=
null
&&
params
.
size
()
>
0
)
{
//
if (params != null && params.size() > 0) {
for
(
Map
.
Entry
<
String
,
Object
>
entry:
params
.
entrySet
())
{
//
for (Map.Entry<String, Object> entry: params.entrySet()) {
if
(
i
==
0
&&
!
url
.
contains
(
"?"
))
{
//
if (i == 0 && !url.contains("?")) {
sb
.
append
(
"?"
);
//
sb.append("?");
}
else
{
//
} else {
sb
.
append
(
"&"
);
//
sb.append("&");
}
//
}
sb
.
append
(
entry
.
getKey
());
//
sb.append(entry.getKey());
sb
.
append
(
"="
);
//
sb.append("=");
Object
v
=
entry
.
getValue
();
//
Object v = entry.getValue();
String
value
=
v
==
null
?
""
:
v
.
toString
();
//
String value = v == null ? "" : v.toString();
encoding
=
encoding
==
null
?
Consts
.
UTF_8
.
name
()
:
encoding
;
//
encoding = encoding == null ? Consts.UTF_8.name() : encoding;
try
{
//
try {
sb
.
append
(
URLEncoder
.
encode
(
value
,
encoding
));
//
sb.append(URLEncoder.encode(value, encoding));
}
catch
(
UnsupportedEncodingException
e
)
{
//
} catch (UnsupportedEncodingException e) {
LOG
.
warn
(
"encoding common get params error, value={}"
,
value
,
e
);
//
LOG.warn("encoding common get params error, value={}", value, e);
try
{
//
try {
sb
.
append
(
URLEncoder
.
encode
(
value
,
encoding
));
//
sb.append(URLEncoder.encode(value, encoding));
}
catch
(
Exception
ex
)
{
//
} catch (Exception ex) {
e
.
printStackTrace
();
//
e.printStackTrace();
}
//
}
}
//
}
i
++;
//
i++;
}
//
}
}
//
}
requestBase
.
setURI
(
URI
.
create
(
sb
.
toString
()));
//
requestBase.setURI(URI.create(sb.toString()));
return
sb
.
toString
();
//
return sb.toString();
}
//
}
//
//
private
static
void
fillHeader
(
Map
<
String
,
String
>
header
,
HttpRequestBase
requestBase
)
{
//
private static void fillHeader(Map<String, String> header, HttpRequestBase requestBase) {
if
(
header
==
null
||
header
.
size
()
==
0
)
{
//
if (header == null || header.size() == 0) {
return
;
//
return;
}
//
}
//
Header
[]
headers
=
header
.
entrySet
().
stream
()
//
Header[] headers = header.entrySet().stream()
.
map
(
entry
->
new
BasicHeader
(
entry
.
getKey
(),
entry
.
getValue
()))
//
.map(entry -> new BasicHeader(entry.getKey(), entry.getValue()))
.
collect
(
Collectors
.
toList
()).
toArray
(
new
Header
[
header
.
size
()]);
//
.collect(Collectors.toList()).toArray(new Header[header.size()]);
//
if
(
headers
.
length
>
0
)
{
//
if (headers.length > 0) {
requestBase
.
setHeaders
(
headers
);
//
requestBase.setHeaders(headers);
}
//
}
}
//
}
//
//
/**
//
/**
* fill common conf
//
* fill common conf
*/
//
*/
private
static
void
fillConfig
(
int
connectTimeout
,
int
soTimeout
,
HttpRequestBase
requestBase
)
{
//
private static void fillConfig(int connectTimeout, int soTimeout, HttpRequestBase requestBase) {
if
(
connectTimeout
<=
0
)
{
//
if (connectTimeout <= 0) {
connectTimeout
=
DEFAULT_TIME_OUT
;
//
connectTimeout = DEFAULT_TIME_OUT;
}
//
}
if
(
soTimeout
<=
0
)
{
//
if (soTimeout <= 0) {
soTimeout
=
DEFAULT_TIME_OUT
;
//
soTimeout = DEFAULT_TIME_OUT;
}
//
}
//
RequestConfig
requestConfig
=
RequestConfig
.
custom
().
setSocketTimeout
(
soTimeout
)
//
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(soTimeout)
.
setConnectTimeout
(
connectTimeout
).
setConnectionRequestTimeout
(
connectTimeout
).
build
();
//
.setConnectTimeout(connectTimeout).setConnectionRequestTimeout(connectTimeout).build();
requestBase
.
setConfig
(
requestConfig
);
//
requestBase.setConfig(requestConfig);
}
//
}
//
//
public
static
class
DefaultTrustManager
implements
X509TrustManager
{
//
public static class DefaultTrustManager implements X509TrustManager {
//
@Override
//
@Override
public
void
checkClientTrusted
(
X509Certificate
[]
x509Certificates
,
String
s
)
//
public void checkClientTrusted(X509Certificate[] x509Certificates, String s)
throws
CertificateException
{}
//
throws CertificateException {}
//
@Override
//
@Override
public
void
checkServerTrusted
(
X509Certificate
[]
x509Certificates
,
String
s
)
//
public void checkServerTrusted(X509Certificate[] x509Certificates, String s)
throws
CertificateException
{}
//
throws CertificateException {}
//
@Override
//
@Override
public
X509Certificate
[]
getAcceptedIssuers
()
{
//
public X509Certificate[] getAcceptedIssuers() {
return
new
X509Certificate
[
0
];
//
return new X509Certificate[0];
}
//
}
}
//
}
//
}
//
}
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