Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
IM
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
iBizPOC_20003
IM
提交
4ea407b2
提交
4ea407b2
编写于
4月 09, 2020
作者:
Crimson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
usr代码添加回调rest信息
上级
c3dab18a
变更
1
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
93 行增加
和
0 行删除
+93
-0
IMService.java
...-web/src/main/java/com/ibiz/web/ht/service/IMService.java
+93
-0
未找到文件。
im-app/im-app-web/src/main/java/com/ibiz/web/ht/service/IMService.java
浏览文件 @
4ea407b2
package
com
.
ibiz
.
web
.
ht
.
service
;
import
java.nio.charset.Charset
;
import
java.util.ArrayList
;
import
java.util.List
;
import
com.alibaba.fastjson.JSONArray
;
import
com.ibiz.web.ps.domain.PS
;
import
com.ibiz.web.ps.service.PSService
;
import
lombok.extern.slf4j.Slf4j
;
import
com.alibaba.fastjson.JSONObject
;
...
...
@@ -12,6 +16,12 @@ import feign.Feign;
import
feign.codec.Decoder
;
import
feign.codec.Encoder
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpMethod
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.converter.HttpMessageConverter
;
import
org.springframework.http.converter.StringHttpMessageConverter
;
import
org.springframework.util.DigestUtils
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
...
...
@@ -31,6 +41,9 @@ import com.ibiz.util.config.UniWFClientProperties;
import
com.ibiz.util.feign.UniWFFeignClient
;
import
com.ibiz.util.config.SysInfoProperties
;
import
com.ibiz.util.domain.*
;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.MultiValueMap
;
import
org.springframework.web.client.RestTemplate
;
@Service
public
class
IMService
{
...
...
@@ -43,6 +56,9 @@ public class IMService {
UniWFFeignClient
uniWFFeignClient
;
@Autowired
PSService
psService
;
@Autowired
public
IMService
(
Decoder
decoder
,
Encoder
encoder
,
Client
client
,
Contract
contract
,
FeignRequestInterceptor
feignRequestInterceptor
,
WebClientProperties
webClientProperties
,
UniWFClientProperties
uniWFClientProperties
)
{
...
...
@@ -218,7 +234,84 @@ public class IMService {
// 保存业务数据
this
.
update
(
im_id
,
im
);
// FOR TEST ADD gotostep
if
(
"finish"
.
equals
(
type
)
||
"gotostep"
.
equals
(
type
))
{
// PS
PS
ps
=
new
PS
();
ps
.
setPSId
(
im
.
getIMId
());
ps
=
psService
.
get
(
ps
.
getPSId
());
if
(
ps
!=
null
)
{
ps
.
setImstate
(
"30"
);
// psService.update(ps.getPSId(), ps);
}
if
(
data
.
getString
(
"callbackdata"
)
!=
null
)
{
JSONArray
callbackdata
=
JSONObject
.
parseArray
(
data
.
getString
(
"callbackdata"
));
if
(
callbackdata
.
size
()
>
0
)
{
for
(
int
i
=
0
;
i
<
callbackdata
.
size
();
i
++)
{
JSONObject
jo
=
callbackdata
.
getJSONObject
(
i
);
HttpMethod
httpMethod
=
HttpMethod
.
valueOf
(
jo
.
getString
(
"method"
));
String
url
=
jo
.
getString
(
"url"
);
JSONObject
params
=
null
;
if
(
jo
.
getBoolean
(
"containspk"
))
{
String
replaceStr
=
url
.
substring
(
url
.
indexOf
(
"{"
),
url
.
indexOf
(
"}"
)
+
1
);
replaceStr
=
"\\"
+
replaceStr
;
replaceStr
=
replaceStr
.
substring
(
0
,
replaceStr
.
length
()
-
1
)
+
"\\}"
;
url
=
url
.
replaceAll
(
replaceStr
,
im
.
getIMId
());
}
if
(
jo
.
getBoolean
(
"containset"
))
{
params
=
(
JSONObject
)
JSONObject
.
toJSON
(
ps
);
}
doRestRequest
(
url
,
httpMethod
,
getHeader
(),
params
);
}
}
}
}
data
.
put
(
"rst"
,
"1"
);
return
data
;
}
public
JSONObject
getHeader
(){
JSONObject
header
=
new
JSONObject
();
header
.
put
(
"Content-Type"
,
"application/json"
);
// String token= null;
// try {
// Base64 base64 = new Base64();
// token = base64.encodeToString((username+":"+password).getBytes("UTF-8"));
// } catch (UnsupportedEncodingException e) {
// e.printStackTrace();
// }
// header.put("Authorization","Basic "+ token);
return
header
;
}
private
String
doRestRequest
(
String
url
,
HttpMethod
method
,
JSONObject
headerMap
,
JSONObject
paramMap
){
RestTemplate
restTemplate
=
getRestTemplate
();
HttpHeaders
headers
=
new
HttpHeaders
();
if
(
headerMap
!=
null
){
for
(
String
key
:
headerMap
.
keySet
()){
headers
.
add
(
key
,
headerMap
.
getString
(
key
));
}
}
MultiValueMap
<
String
,
String
>
params
=
new
LinkedMultiValueMap
<
String
,
String
>();
HttpEntity
<
String
>
entity
;
if
(
paramMap
!=
null
){
entity
=
new
HttpEntity
<>(
paramMap
.
toString
(),
headers
);
}
else
{
entity
=
new
HttpEntity
<>(
null
,
headers
);
}
ResponseEntity
<
String
>
responseEntity
=
restTemplate
.
exchange
(
url
,
method
,
entity
,
String
.
class
);
return
responseEntity
.
getBody
();
}
private
RestTemplate
getRestTemplate
(){
RestTemplate
restTemplate
=
new
RestTemplate
();
for
(
HttpMessageConverter
<?>
httpMessageConverter
:
restTemplate
.
getMessageConverters
())
{
if
(
httpMessageConverter
instanceof
StringHttpMessageConverter
)
{
((
StringHttpMessageConverter
)
httpMessageConverter
).
setDefaultCharset
(
Charset
.
forName
(
"UTF-8"
));
break
;
}
}
return
restTemplate
;
}
}
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录